Commit 1863bfeb authored by hjk's avatar hjk
Browse files

Cleanup SettingsDialog



Change-Id: Ibbbf7d507e28201c2e7e466ab24b39e9e0e44fb4
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent e833b794
......@@ -29,33 +29,34 @@
#include "settingsdialog.h"
#include <extensionsystem/pluginmanager.h>
#include "icore.h"
#include <extensionsystem/pluginmanager.h>
#include <utils/hostosinfo.h>
#include <utils/filterlineedit.h>
#include <QSettings>
#include <QSortFilterProxyModel>
#include <QItemSelectionModel>
#include <QApplication>
#include <QDialogButtonBox>
#include <QFrame>
#include <QGridLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QIcon>
#include <QItemSelectionModel>
#include <QLabel>
#include <QLineEdit>
#include <QListView>
#include <QPointer>
#include <QPushButton>
#include <QToolButton>
#include <QToolBar>
#include <QScrollBar>
#include <QSettings>
#include <QSortFilterProxyModel>
#include <QSpacerItem>
#include <QStyle>
#include <QStackedLayout>
#include <QGridLayout>
#include <QLineEdit>
#include <QFrame>
#include <QDialogButtonBox>
#include <QListView>
#include <QApplication>
#include <QGroupBox>
#include <QStyle>
#include <QStyledItemDelegate>
#include <QToolBar>
#include <QToolButton>
static const char categoryKeyC[] = "General/LastPreferenceCategory";
static const char pageKeyC[] = "General/LastPreferencePage";
......@@ -64,7 +65,7 @@ const int categoryIconSize = 24;
namespace Core {
namespace Internal {
QPointer<SettingsDialog> SettingsDialog::m_instance = 0;
static QPointer<SettingsDialog> m_instance = 0;
// ----------- Category model
......@@ -325,11 +326,11 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
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"
QString initialCategory = categoryId;
QString initialPage = pageId;
QString initialCategory = categoryId.toString();
QString initialPage = pageId.toString();
if (initialCategory.isEmpty() && initialPage.isEmpty()) {
QSettings *settings = ICore::settings();
initialCategory = settings->value(QLatin1String(categoryKeyC), QVariant(QString())).toString();
......@@ -565,12 +566,10 @@ QSize SettingsDialog::sizeHint() const
}
SettingsDialog *SettingsDialog::getSettingsDialog(QWidget *parent,
const QString &initialCategory,
const QString &initialPage)
Id initialCategory, Id initialPage)
{
if (!m_instance) {
if (!m_instance)
m_instance = new SettingsDialog(parent);
}
m_instance->showPage(initialCategory, initialPage);
return m_instance;
}
......@@ -602,6 +601,5 @@ bool SettingsDialog::execDialog()
return m_applied;
}
} // namespace Internal
} // namespace Core
......@@ -31,6 +31,7 @@
#define SETTINGSDIALOG_H
#include "coreplugin/dialogs/ioptionspage.h"
#include "coreplugin/id.h"
#include <QList>
#include <QSet>
......@@ -46,9 +47,7 @@ class QLabel;
class QListView;
QT_END_NAMESPACE
namespace Utils {
class FilterLineEdit;
}
namespace Utils { class FilterLineEdit; }
namespace Core {
namespace Internal {
......@@ -61,13 +60,11 @@ class SettingsDialog : public QDialog
Q_OBJECT
public:
// Returns a settings dialog. This makes sure that always only
// a single settings dialog instance is running.
// The dialog will be deleted automatically on close.
static SettingsDialog *getSettingsDialog(QWidget *parent,
const QString &initialCategory = QString(),
const QString &initialPage = QString());
Id initialCategory, Id initialPage);
// Run the dialog and wait for it to finish.
// Returns if the changes have been applied.
bool execDialog();
......@@ -92,7 +89,7 @@ private:
void createGui();
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 ensureCategoryWidget(Category *category);
void disconnectTabWidgets();
......@@ -112,7 +109,6 @@ private:
bool m_applied;
bool m_finished;
QList<QEventLoop *> m_eventLoops;
static QPointer<SettingsDialog> m_instance;
};
} // namespace Internal
......
......@@ -965,7 +965,7 @@ bool MainWindow::showOptionsDialog(Id category, Id page, QWidget *parent)
emit m_coreImpl->optionsDialogRequested();
if (!parent)
parent = this;
SettingsDialog *dialog = SettingsDialog::getSettingsDialog(parent, category.toString(), page.toString());
SettingsDialog *dialog = SettingsDialog::getSettingsDialog(parent, category, page);
return dialog->execDialog();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment