diff --git a/src/plugins/coreplugin/CMakeLists.txt b/src/plugins/coreplugin/CMakeLists.txt
index 06b4242fe36..8b6710e8b4a 100644
--- a/src/plugins/coreplugin/CMakeLists.txt
+++ b/src/plugins/coreplugin/CMakeLists.txt
@@ -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
diff --git a/src/plugins/coreplugin/coreplugin.qbs b/src/plugins/coreplugin/coreplugin.qbs
index 59e1d9e1665..537f4833880 100644
--- a/src/plugins/coreplugin/coreplugin.qbs
+++ b/src/plugins/coreplugin/coreplugin.qbs
@@ -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",
diff --git a/src/plugins/coreplugin/dialogs/newdialog.ui b/src/plugins/coreplugin/dialogs/newdialog.ui
deleted file mode 100644
index efa530fde57..00000000000
--- a/src/plugins/coreplugin/dialogs/newdialog.ui
+++ /dev/null
@@ -1,206 +0,0 @@
-
-
- Core::Internal::NewDialog
-
-
-
- 0
- 0
- 880
- 520
-
-
-
-
- 0
- 0
-
-
-
- New Project
-
-
- -
-
-
- Choose a template:
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 1000
- 16777215
-
-
-
-
-
-
-
-
- 97
- 97
- 97
-
-
-
-
-
-
-
-
- 97
- 97
- 97
-
-
-
-
-
-
-
-
- 120
- 120
- 120
-
-
-
-
-
-
-
- Qt::StrongFocus
-
-
- QTreeView::branch {
- background: transparent;
- }
-
-
- 0
-
-
- false
-
-
- false
-
-
- true
-
-
- false
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 0
- 180
-
-
-
- Qt::StrongFocus
-
-
- QAbstractItemView::SelectRows
-
-
- QAbstractItemView::ScrollPerPixel
-
-
- false
-
-
-
- -
-
-
- true
-
-
- QFrame::StyledPanel
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- Qt::NoFocus
-
-
- QFrame::NoFrame
-
-
-
-
-
-
- -
-
-
-
-
-
- Qt::Horizontal
-
-
- QSizePolicy::MinimumExpanding
-
-
-
- 0
- 0
-
-
-
-
- -
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
- QDialogButtonBox::Cancel|QDialogButtonBox::Ok
-
-
-
-
-
-
-
-
diff --git a/src/plugins/coreplugin/dialogs/newdialogwidget.cpp b/src/plugins/coreplugin/dialogs/newdialogwidget.cpp
index 712f70fdc97..d7de3f710c2 100644
--- a/src/plugins/coreplugin/dialogs/newdialogwidget.cpp
+++ b/src/plugins/coreplugin/dialogs/newdialogwidget.cpp
@@ -24,22 +24,29 @@
****************************************************************************/
#include "newdialogwidget.h"
-#include "ui_newdialog.h"
#include
#include
#include
+#include
#include
#include
+#include
#include
+#include
+#include
#include
#include
+#include
+#include
#include
#include
#include
#include
#include
+#include
+#include
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 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(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)
+ "" + displayNamesForSupportedPlatforms.join("") + ""
+ QLatin1String("");
- 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,
diff --git a/src/plugins/coreplugin/dialogs/newdialogwidget.h b/src/plugins/coreplugin/dialogs/newdialogwidget.h
index 8239f4cdd6a..7f9853115a4 100644
--- a/src/plugins/coreplugin/dialogs/newdialogwidget.h
+++ b/src/plugins/coreplugin/dialogs/newdialogwidget.h
@@ -34,19 +34,22 @@
#include
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 m_categoryItems;
Utils::FilePath m_defaultLocation;