forked from qt-creator/qt-creator
Cleanup SettingsDialog
Change-Id: Ibbbf7d507e28201c2e7e466ab24b39e9e0e44fb4 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -29,33 +29,34 @@
|
|||||||
|
|
||||||
#include "settingsdialog.h"
|
#include "settingsdialog.h"
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
|
||||||
#include "icore.h"
|
#include "icore.h"
|
||||||
|
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/filterlineedit.h>
|
#include <utils/filterlineedit.h>
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QApplication>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QDialogButtonBox>
|
||||||
#include <QItemSelectionModel>
|
#include <QFrame>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QGroupBox>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
#include <QItemSelectionModel>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
|
||||||
#include <QToolButton>
|
|
||||||
#include <QToolBar>
|
|
||||||
#include <QScrollBar>
|
|
||||||
#include <QSpacerItem>
|
|
||||||
#include <QStyle>
|
|
||||||
#include <QStackedLayout>
|
|
||||||
#include <QGridLayout>
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QFrame>
|
|
||||||
#include <QDialogButtonBox>
|
|
||||||
#include <QListView>
|
#include <QListView>
|
||||||
#include <QApplication>
|
#include <QPointer>
|
||||||
#include <QGroupBox>
|
#include <QPushButton>
|
||||||
|
#include <QScrollBar>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
#include <QSpacerItem>
|
||||||
|
#include <QStackedLayout>
|
||||||
|
#include <QStyle>
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
|
#include <QToolBar>
|
||||||
|
#include <QToolButton>
|
||||||
|
|
||||||
static const char categoryKeyC[] = "General/LastPreferenceCategory";
|
static const char categoryKeyC[] = "General/LastPreferenceCategory";
|
||||||
static const char pageKeyC[] = "General/LastPreferencePage";
|
static const char pageKeyC[] = "General/LastPreferencePage";
|
||||||
@@ -64,7 +65,7 @@ const int categoryIconSize = 24;
|
|||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
QPointer<SettingsDialog> SettingsDialog::m_instance = 0;
|
static QPointer<SettingsDialog> m_instance = 0;
|
||||||
|
|
||||||
// ----------- Category model
|
// ----------- Category model
|
||||||
|
|
||||||
@@ -325,11 +326,11 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
|
|||||||
m_categoryList->setFocus();
|
m_categoryList->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::showPage(const QString &categoryId, const QString &pageId)
|
void SettingsDialog::showPage(Id categoryId, Id pageId)
|
||||||
{
|
{
|
||||||
// handle the case of "show last page"
|
// handle the case of "show last page"
|
||||||
QString initialCategory = categoryId;
|
QString initialCategory = categoryId.toString();
|
||||||
QString initialPage = pageId;
|
QString initialPage = pageId.toString();
|
||||||
if (initialCategory.isEmpty() && initialPage.isEmpty()) {
|
if (initialCategory.isEmpty() && initialPage.isEmpty()) {
|
||||||
QSettings *settings = ICore::settings();
|
QSettings *settings = ICore::settings();
|
||||||
initialCategory = settings->value(QLatin1String(categoryKeyC), QVariant(QString())).toString();
|
initialCategory = settings->value(QLatin1String(categoryKeyC), QVariant(QString())).toString();
|
||||||
@@ -565,12 +566,10 @@ QSize SettingsDialog::sizeHint() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
SettingsDialog *SettingsDialog::getSettingsDialog(QWidget *parent,
|
SettingsDialog *SettingsDialog::getSettingsDialog(QWidget *parent,
|
||||||
const QString &initialCategory,
|
Id initialCategory, Id initialPage)
|
||||||
const QString &initialPage)
|
|
||||||
{
|
{
|
||||||
if (!m_instance) {
|
if (!m_instance)
|
||||||
m_instance = new SettingsDialog(parent);
|
m_instance = new SettingsDialog(parent);
|
||||||
}
|
|
||||||
m_instance->showPage(initialCategory, initialPage);
|
m_instance->showPage(initialCategory, initialPage);
|
||||||
return m_instance;
|
return m_instance;
|
||||||
}
|
}
|
||||||
@@ -602,6 +601,5 @@ bool SettingsDialog::execDialog()
|
|||||||
return m_applied;
|
return m_applied;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#define SETTINGSDIALOG_H
|
#define SETTINGSDIALOG_H
|
||||||
|
|
||||||
#include "coreplugin/dialogs/ioptionspage.h"
|
#include "coreplugin/dialogs/ioptionspage.h"
|
||||||
|
#include "coreplugin/id.h"
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
@@ -46,9 +47,7 @@ class QLabel;
|
|||||||
class QListView;
|
class QListView;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils { class FilterLineEdit; }
|
||||||
class FilterLineEdit;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -61,13 +60,11 @@ class SettingsDialog : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Returns a settings dialog. This makes sure that always only
|
// Returns a settings dialog. This makes sure that always only
|
||||||
// a single settings dialog instance is running.
|
// a single settings dialog instance is running.
|
||||||
// The dialog will be deleted automatically on close.
|
// The dialog will be deleted automatically on close.
|
||||||
static SettingsDialog *getSettingsDialog(QWidget *parent,
|
static SettingsDialog *getSettingsDialog(QWidget *parent,
|
||||||
const QString &initialCategory = QString(),
|
Id initialCategory, Id initialPage);
|
||||||
const QString &initialPage = QString());
|
|
||||||
// Run the dialog and wait for it to finish.
|
// Run the dialog and wait for it to finish.
|
||||||
// Returns if the changes have been applied.
|
// Returns if the changes have been applied.
|
||||||
bool execDialog();
|
bool execDialog();
|
||||||
@@ -92,7 +89,7 @@ private:
|
|||||||
|
|
||||||
void createGui();
|
void createGui();
|
||||||
void showCategory(int index);
|
void showCategory(int index);
|
||||||
void showPage(const QString &categoryId, const QString &pageId);
|
void showPage(Id categoryId, Id pageId);
|
||||||
void updateEnabledTabs(Category *category, const QString &searchText);
|
void updateEnabledTabs(Category *category, const QString &searchText);
|
||||||
void ensureCategoryWidget(Category *category);
|
void ensureCategoryWidget(Category *category);
|
||||||
void disconnectTabWidgets();
|
void disconnectTabWidgets();
|
||||||
@@ -112,7 +109,6 @@ private:
|
|||||||
bool m_applied;
|
bool m_applied;
|
||||||
bool m_finished;
|
bool m_finished;
|
||||||
QList<QEventLoop *> m_eventLoops;
|
QList<QEventLoop *> m_eventLoops;
|
||||||
static QPointer<SettingsDialog> m_instance;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -965,7 +965,7 @@ bool MainWindow::showOptionsDialog(Id category, Id page, QWidget *parent)
|
|||||||
emit m_coreImpl->optionsDialogRequested();
|
emit m_coreImpl->optionsDialogRequested();
|
||||||
if (!parent)
|
if (!parent)
|
||||||
parent = this;
|
parent = this;
|
||||||
SettingsDialog *dialog = SettingsDialog::getSettingsDialog(parent, category.toString(), page.toString());
|
SettingsDialog *dialog = SettingsDialog::getSettingsDialog(parent, category, page);
|
||||||
return dialog->execDialog();
|
return dialog->execDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user