forked from qt-creator/qt-creator
Core: Inline newdialog.ui
Change-Id: Ic6019a5254bddf30bade0246448aad96d60d9c99 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -29,7 +29,7 @@ add_qtc_plugin(Core
|
||||
dialogs/externaltoolconfig.cpp dialogs/externaltoolconfig.h dialogs/externaltoolconfig.ui
|
||||
dialogs/filepropertiesdialog.cpp dialogs/filepropertiesdialog.h dialogs/filepropertiesdialog.ui
|
||||
dialogs/ioptionspage.cpp dialogs/ioptionspage.h
|
||||
dialogs/newdialog.cpp dialogs/newdialog.h dialogs/newdialog.ui
|
||||
dialogs/newdialog.cpp dialogs/newdialog.h
|
||||
dialogs/newdialogwidget.cpp dialogs/newdialogwidget.h
|
||||
dialogs/openwithdialog.cpp dialogs/openwithdialog.h dialogs/openwithdialog.ui
|
||||
dialogs/promptoverwritedialog.cpp dialogs/promptoverwritedialog.h
|
||||
|
@@ -208,7 +208,7 @@ Project {
|
||||
"externaltoolconfig.cpp", "externaltoolconfig.h", "externaltoolconfig.ui",
|
||||
"filepropertiesdialog.cpp", "filepropertiesdialog.h", "filepropertiesdialog.ui",
|
||||
"ioptionspage.cpp", "ioptionspage.h",
|
||||
"newdialog.cpp", "newdialog.h", "newdialog.ui",
|
||||
"newdialog.cpp", "newdialog.h",
|
||||
"newdialogwidget.cpp", "newdialogwidget.h",
|
||||
"openwithdialog.cpp", "openwithdialog.h", "openwithdialog.ui",
|
||||
"promptoverwritedialog.cpp", "promptoverwritedialog.h",
|
||||
|
@@ -1,206 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Core::Internal::NewDialog</class>
|
||||
<widget class="QDialog" name="Core::Internal::NewDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>880</width>
|
||||
<height>520</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>New Project</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Choose a template:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTreeView" name="templateCategoryView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>1000</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>97</red>
|
||||
<green>97</green>
|
||||
<blue>97</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>97</red>
|
||||
<green>97</green>
|
||||
<blue>97</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>120</red>
|
||||
<green>120</green>
|
||||
<blue>120</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"> QTreeView::branch {
|
||||
background: transparent;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="indentation">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="itemsExpandable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="headerHidden">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QListView" name="templatesView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>180</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
<property name="uniformItemSizes">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="imageLabel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="templateDescription">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@@ -24,22 +24,29 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "newdialogwidget.h"
|
||||
#include "ui_newdialog.h"
|
||||
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QDebug>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QHeaderView>
|
||||
#include <QItemDelegate>
|
||||
#include <QKeyEvent>
|
||||
#include <QLabel>
|
||||
#include <QListView>
|
||||
#include <QModelIndex>
|
||||
#include <QPainter>
|
||||
#include <QPushButton>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QStandardItem>
|
||||
#include <QTextBrowser>
|
||||
#include <QTreeView>
|
||||
|
||||
Q_DECLARE_METATYPE(Core::IWizardFactory*)
|
||||
|
||||
@@ -169,18 +176,56 @@ Q_DECLARE_METATYPE(WizardFactoryContainer)
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
using namespace Layouting;
|
||||
|
||||
NewDialogWidget::NewDialogWidget(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_comboBox(new QComboBox)
|
||||
, m_templateCategoryView(new QTreeView)
|
||||
, m_templatesView(new QListView)
|
||||
, m_imageLabel(new QLabel)
|
||||
, m_templateDescription(new QTextBrowser)
|
||||
|
||||
NewDialogWidget::NewDialogWidget(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
m_ui(new Ui::NewDialog)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
ICore::registerWindow(this, Context("Core.NewDialog"));
|
||||
m_ui->setupUi(this);
|
||||
QPalette p = m_ui->frame->palette();
|
||||
resize(880, 520);
|
||||
|
||||
auto frame = new QFrame;
|
||||
frame->setAutoFillBackground(true);
|
||||
frame->setFrameShape(QFrame::StyledPanel);
|
||||
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Ok,
|
||||
Qt::Horizontal);
|
||||
|
||||
m_templateCategoryView->setStyleSheet(QString::fromUtf8(" QTreeView::branch {\n"
|
||||
" background: transparent;\n"
|
||||
" }"));
|
||||
m_templateCategoryView->setIndentation(0);
|
||||
m_templateCategoryView->setRootIsDecorated(false);
|
||||
m_templateCategoryView->setItemsExpandable(false);
|
||||
m_templateCategoryView->setHeaderHidden(true);
|
||||
m_templateCategoryView->header()->setVisible(false);
|
||||
|
||||
m_templatesView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_templatesView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
m_templatesView->setUniformItemSizes(false);
|
||||
|
||||
m_templateDescription->setFocusPolicy(Qt::NoFocus);
|
||||
m_templateDescription->setFrameShape(QFrame::NoFrame);
|
||||
|
||||
Column { m_imageLabel, m_templateDescription }.attachTo(frame);
|
||||
|
||||
Column {
|
||||
Row { QCoreApplication::translate("Core::Internal::NewDialog", "Choose a template:"),
|
||||
Stretch(), m_comboBox },
|
||||
Row { m_templateCategoryView, m_templatesView, frame },
|
||||
buttonBox
|
||||
}.attachTo(this);
|
||||
|
||||
QPalette p = frame->palette();
|
||||
p.setColor(QPalette::Window, p.color(QPalette::Base));
|
||||
m_ui->frame->setPalette(p);
|
||||
m_okButton = m_ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||
frame->setPalette(p);
|
||||
m_okButton = buttonBox->button(QDialogButtonBox::Ok);
|
||||
m_okButton->setDefault(true);
|
||||
m_okButton->setText(tr("Choose..."));
|
||||
|
||||
@@ -189,40 +234,46 @@ NewDialogWidget::NewDialogWidget(QWidget *parent) :
|
||||
m_filterProxyModel = new PlatformFilterProxyModel(this);
|
||||
m_filterProxyModel->setSourceModel(m_model);
|
||||
|
||||
m_ui->templateCategoryView->setModel(m_filterProxyModel);
|
||||
m_ui->templateCategoryView->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
m_ui->templateCategoryView->setItemDelegate(new FancyTopLevelDelegate(this));
|
||||
m_templateCategoryView->setModel(m_filterProxyModel);
|
||||
m_templateCategoryView->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
m_templateCategoryView->setItemDelegate(new FancyTopLevelDelegate(this));
|
||||
|
||||
m_ui->templatesView->setModel(m_filterProxyModel);
|
||||
m_ui->templatesView->setIconSize(QSize(ICON_SIZE, ICON_SIZE));
|
||||
m_templatesView->setModel(m_filterProxyModel);
|
||||
m_templatesView->setIconSize(QSize(ICON_SIZE, ICON_SIZE));
|
||||
|
||||
const bool alternativeWizardStyle = ICore::settings()->value(ALTERNATIVE_WIZARD_STYLE, false).toBool();
|
||||
|
||||
if (alternativeWizardStyle) {
|
||||
m_ui->templatesView->setGridSize(QSize(256, 128));
|
||||
m_ui->templatesView->setIconSize(QSize(96, 96));
|
||||
m_ui->templatesView->setSpacing(4);
|
||||
m_templatesView->setGridSize(QSize(256, 128));
|
||||
m_templatesView->setIconSize(QSize(96, 96));
|
||||
m_templatesView->setSpacing(4);
|
||||
|
||||
m_ui->templatesView->setViewMode(QListView::IconMode);
|
||||
m_ui->templatesView->setMovement(QListView::Static);
|
||||
m_ui->templatesView->setResizeMode(QListView::Adjust);
|
||||
m_ui->templatesView->setSelectionRectVisible(false);
|
||||
m_ui->templatesView->setWrapping(true);
|
||||
m_ui->templatesView->setWordWrap(true);
|
||||
m_templatesView->setViewMode(QListView::IconMode);
|
||||
m_templatesView->setMovement(QListView::Static);
|
||||
m_templatesView->setResizeMode(QListView::Adjust);
|
||||
m_templatesView->setSelectionRectVisible(false);
|
||||
m_templatesView->setWrapping(true);
|
||||
m_templatesView->setWordWrap(true);
|
||||
}
|
||||
|
||||
connect(m_ui->templateCategoryView->selectionModel(), &QItemSelectionModel::currentChanged,
|
||||
this, &NewDialogWidget::currentCategoryChanged);
|
||||
connect(m_templateCategoryView->selectionModel(),
|
||||
&QItemSelectionModel::currentChanged,
|
||||
this,
|
||||
&NewDialogWidget::currentCategoryChanged);
|
||||
|
||||
connect(m_ui->templatesView->selectionModel(), &QItemSelectionModel::currentChanged,
|
||||
this, &NewDialogWidget::currentItemChanged);
|
||||
connect(m_templatesView->selectionModel(),
|
||||
&QItemSelectionModel::currentChanged,
|
||||
this,
|
||||
&NewDialogWidget::currentItemChanged);
|
||||
|
||||
connect(m_ui->templatesView, &QListView::doubleClicked, this, &NewDialogWidget::accept);
|
||||
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &NewDialogWidget::accept);
|
||||
connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &NewDialogWidget::reject);
|
||||
connect(m_templatesView, &QListView::doubleClicked, this, &NewDialogWidget::accept);
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &NewDialogWidget::accept);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &NewDialogWidget::reject);
|
||||
|
||||
connect(m_ui->comboBox, &QComboBox::currentIndexChanged,
|
||||
this, &NewDialogWidget::setSelectedPlatform);
|
||||
connect(m_comboBox,
|
||||
&QComboBox::currentIndexChanged,
|
||||
this,
|
||||
&NewDialogWidget::setSelectedPlatform);
|
||||
}
|
||||
|
||||
// Sort by category. id
|
||||
@@ -258,19 +309,19 @@ void NewDialogWidget::setWizardFactories(QList<IWizardFactory *> factories,
|
||||
|
||||
const bool allowAllTemplates = ICore::settings()->value(ALLOW_ALL_TEMPLATES, true).toBool();
|
||||
if (allowAllTemplates)
|
||||
m_ui->comboBox->addItem(tr("All Templates"), Id().toSetting());
|
||||
m_comboBox->addItem(tr("All Templates"), Id().toSetting());
|
||||
|
||||
for (Id platform : availablePlatforms) {
|
||||
const QString displayNameForPlatform = IWizardFactory::displayNameForPlatform(platform);
|
||||
m_ui->comboBox->addItem(tr("%1 Templates").arg(displayNameForPlatform), platform.toSetting());
|
||||
m_comboBox->addItem(tr("%1 Templates").arg(displayNameForPlatform), platform.toSetting());
|
||||
}
|
||||
|
||||
m_ui->comboBox->setCurrentIndex(0); // "All templates"
|
||||
m_ui->comboBox->setEnabled(!availablePlatforms.isEmpty());
|
||||
m_comboBox->setCurrentIndex(0); // "All templates"
|
||||
m_comboBox->setEnabled(!availablePlatforms.isEmpty());
|
||||
|
||||
const bool showPlatformFilter = ICore::settings()->value(SHOW_PLATOFORM_FILTER, true).toBool();
|
||||
if (!showPlatformFilter)
|
||||
m_ui->comboBox->hide();
|
||||
m_comboBox->hide();
|
||||
|
||||
for (IWizardFactory *factory : qAsConst(factories)) {
|
||||
QStandardItem *kindItem;
|
||||
@@ -299,9 +350,9 @@ void NewDialogWidget::showDialog()
|
||||
QString lastCategory = ICore::settings()->value(QLatin1String(LAST_CATEGORY_KEY)).toString();
|
||||
|
||||
if (!lastPlatform.isEmpty()) {
|
||||
int index = m_ui->comboBox->findData(lastPlatform);
|
||||
int index = m_comboBox->findData(lastPlatform);
|
||||
if (index != -1)
|
||||
m_ui->comboBox->setCurrentIndex(index);
|
||||
m_comboBox->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
static_cast<PlatformFilterProxyModel *>(m_filterProxyModel)->manualReset();
|
||||
@@ -314,16 +365,16 @@ void NewDialogWidget::showDialog()
|
||||
if (!idx.isValid())
|
||||
idx = m_filterProxyModel->index(0,0, m_filterProxyModel->index(0,0));
|
||||
|
||||
m_ui->templateCategoryView->setCurrentIndex(idx);
|
||||
m_templateCategoryView->setCurrentIndex(idx);
|
||||
|
||||
// We need to ensure that the category has default focus
|
||||
m_ui->templateCategoryView->setFocus(Qt::NoFocusReason);
|
||||
m_templateCategoryView->setFocus(Qt::NoFocusReason);
|
||||
|
||||
for (int row = 0; row < m_filterProxyModel->rowCount(); ++row)
|
||||
m_ui->templateCategoryView->setExpanded(m_filterProxyModel->index(row, 0), true);
|
||||
m_templateCategoryView->setExpanded(m_filterProxyModel->index(row, 0), true);
|
||||
|
||||
// Ensure that item description is visible on first show
|
||||
currentItemChanged(m_filterProxyModel->index(0, 0, m_ui->templatesView->rootIndex()));
|
||||
currentItemChanged(m_filterProxyModel->index(0, 0, m_templatesView->rootIndex()));
|
||||
|
||||
updateOkButton();
|
||||
show();
|
||||
@@ -331,8 +382,8 @@ void NewDialogWidget::showDialog()
|
||||
|
||||
Id NewDialogWidget::selectedPlatform() const
|
||||
{
|
||||
const int index = m_ui->comboBox->currentIndex();
|
||||
return Id::fromSetting(m_ui->comboBox->itemData(index));
|
||||
const int index = m_comboBox->currentIndex();
|
||||
return Id::fromSetting(m_comboBox->itemData(index));
|
||||
}
|
||||
|
||||
bool NewDialogWidget::event(QEvent *event)
|
||||
@@ -349,12 +400,11 @@ bool NewDialogWidget::event(QEvent *event)
|
||||
|
||||
NewDialogWidget::~NewDialogWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
IWizardFactory *NewDialogWidget::currentWizardFactory() const
|
||||
{
|
||||
QModelIndex index = m_filterProxyModel->mapToSource(m_ui->templatesView->currentIndex());
|
||||
QModelIndex index = m_filterProxyModel->mapToSource(m_templatesView->currentIndex());
|
||||
return factoryOfItem(m_model->itemFromIndex(index));
|
||||
}
|
||||
|
||||
@@ -387,10 +437,10 @@ void NewDialogWidget::currentCategoryChanged(const QModelIndex &index)
|
||||
if (index.parent() != m_model->invisibleRootItem()->index()) {
|
||||
QModelIndex sourceIndex = m_filterProxyModel->mapToSource(index);
|
||||
sourceIndex = m_filterProxyModel->mapFromSource(sourceIndex);
|
||||
m_ui->templatesView->setRootIndex(sourceIndex);
|
||||
m_templatesView->setRootIndex(sourceIndex);
|
||||
// Focus the first item by default
|
||||
m_ui->templatesView->setCurrentIndex(
|
||||
m_filterProxyModel->index(0, 0, m_ui->templatesView->rootIndex()));
|
||||
m_templatesView->setCurrentIndex(
|
||||
m_filterProxyModel->index(0, 0, m_templatesView->rootIndex()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,30 +466,29 @@ void NewDialogWidget::currentItemChanged(const QModelIndex &index)
|
||||
+ "<li>" + displayNamesForSupportedPlatforms.join("</li><li>") + "</li>"
|
||||
+ QLatin1String("</ul>");
|
||||
|
||||
m_ui->templateDescription->setHtml(desciption);
|
||||
m_templateDescription->setHtml(desciption);
|
||||
|
||||
if (!wizard->descriptionImage().isEmpty()) {
|
||||
m_ui->imageLabel->setVisible(true);
|
||||
m_ui->imageLabel->setPixmap(wizard->descriptionImage());
|
||||
m_imageLabel->setVisible(true);
|
||||
m_imageLabel->setPixmap(wizard->descriptionImage());
|
||||
} else {
|
||||
m_ui->imageLabel->setVisible(false);
|
||||
m_imageLabel->setVisible(false);
|
||||
}
|
||||
|
||||
} else {
|
||||
m_ui->templateDescription->clear();
|
||||
m_templateDescription->clear();
|
||||
}
|
||||
updateOkButton();
|
||||
}
|
||||
|
||||
void NewDialogWidget::saveState()
|
||||
{
|
||||
const QModelIndex filterIdx = m_ui->templateCategoryView->currentIndex();
|
||||
const QModelIndex filterIdx = m_templateCategoryView->currentIndex();
|
||||
const QModelIndex idx = m_filterProxyModel->mapToSource(filterIdx);
|
||||
QStandardItem *currentItem = m_model->itemFromIndex(idx);
|
||||
if (currentItem)
|
||||
ICore::settings()->setValue(LAST_CATEGORY_KEY, currentItem->data(Qt::UserRole));
|
||||
ICore::settings()->setValueWithDefault(LAST_PLATFORM_KEY,
|
||||
m_ui->comboBox->currentData().toString());
|
||||
ICore::settings()->setValueWithDefault(LAST_PLATFORM_KEY, m_comboBox->currentData().toString());
|
||||
}
|
||||
|
||||
static void runWizard(IWizardFactory *wizard, const FilePath &defaultLocation, Id platform,
|
||||
@@ -452,7 +501,7 @@ static void runWizard(IWizardFactory *wizard, const FilePath &defaultLocation, I
|
||||
void NewDialogWidget::accept()
|
||||
{
|
||||
saveState();
|
||||
if (m_ui->templatesView->currentIndex().isValid()) {
|
||||
if (m_templatesView->currentIndex().isValid()) {
|
||||
IWizardFactory *wizard = currentWizardFactory();
|
||||
if (QTC_GUARD(wizard)) {
|
||||
QMetaObject::invokeMethod(wizard, std::bind(&runWizard, wizard, m_defaultLocation,
|
||||
|
@@ -34,19 +34,22 @@
|
||||
#include <QVariantMap>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QComboBox;
|
||||
class QLabel;
|
||||
class QListView;
|
||||
class QModelIndex;
|
||||
class QSortFilterProxyModel;
|
||||
class QPushButton;
|
||||
class QSortFilterProxyModel;
|
||||
class QStandardItem;
|
||||
class QStandardItemModel;
|
||||
class QTextBrowser;
|
||||
class QTreeView;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
|
||||
namespace Internal {
|
||||
|
||||
namespace Ui { class NewDialog; }
|
||||
|
||||
class NewDialogWidget : public QDialog, public NewDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -82,9 +85,13 @@ private:
|
||||
void addItem(QStandardItem *topLevelCategoryItem, IWizardFactory *factory);
|
||||
void saveState();
|
||||
|
||||
Ui::NewDialog *m_ui;
|
||||
QStandardItemModel *m_model;
|
||||
QSortFilterProxyModel *m_filterProxyModel;
|
||||
QComboBox *m_comboBox;
|
||||
QTreeView *m_templateCategoryView;
|
||||
QListView *m_templatesView;
|
||||
QLabel *m_imageLabel;
|
||||
QTextBrowser *m_templateDescription;
|
||||
QPushButton *m_okButton = nullptr;
|
||||
QList<QStandardItem *> m_categoryItems;
|
||||
Utils::FilePath m_defaultLocation;
|
||||
|
Reference in New Issue
Block a user