let the settings dialog be a singleton (thanks to Max Blazejak for the patch!)

svn path=/trunk/KDE/kdebase/apps/; revision=661508
This commit is contained in:
Peter Penz 2007-05-05 20:53:14 +00:00
parent be7f817875
commit d00a895131
3 changed files with 29 additions and 21 deletions

View file

@ -950,9 +950,7 @@ void DolphinMainWindow::compareFiles()
void DolphinMainWindow::editSettings() void DolphinMainWindow::editSettings()
{ {
// TODO: make a static method for opening the settings dialog DolphinSettingsDialog::instance(this).exec();
DolphinSettingsDialog dlg(this);
dlg.exec();
} }
void DolphinMainWindow::init() void DolphinMainWindow::init()

View file

@ -25,12 +25,31 @@
#include "viewsettingspage.h" #include "viewsettingspage.h"
#include "dolphinapplication.h" #include "dolphinapplication.h"
#include "dolphinmainwindow.h" #include "dolphinmainwindow.h"
//Added by qt3to4:
#include <QFrame> DolphinSettingsDialog& DolphinSettingsDialog::instance(DolphinMainWindow* mainWindow)
{
static DolphinSettingsDialog* instance = 0;
if (instance == 0) {
instance = new DolphinSettingsDialog(mainWindow);
}
return *instance;
}
DolphinSettingsDialog::~DolphinSettingsDialog()
{
}
void DolphinSettingsDialog::slotButtonClicked(int button)
{
if (button == Ok || button == Apply) {
applySettings();
}
KPageDialog::slotButtonClicked(button);
}
DolphinSettingsDialog::DolphinSettingsDialog(DolphinMainWindow* mainWindow) : DolphinSettingsDialog::DolphinSettingsDialog(DolphinMainWindow* mainWindow) :
KPageDialog(), KPageDialog(),
m_mainWindow(mainWindow) m_mainWindow(mainWindow)
{ {
const QSize minSize = minimumSize(); const QSize minSize = minimumSize();
setMinimumSize(QSize(512, minSize.height())); setMinimumSize(QSize(512, minSize.height()));
@ -49,17 +68,6 @@ DolphinSettingsDialog::DolphinSettingsDialog(DolphinMainWindow* mainWindow) :
viewSettingsFrame->setIcon(KIcon("view-choose")); viewSettingsFrame->setIcon(KIcon("view-choose"));
} }
DolphinSettingsDialog::~DolphinSettingsDialog()
{}
void DolphinSettingsDialog::slotButtonClicked(int button)
{
if (button == Ok || button == Apply) {
applySettings();
}
KPageDialog::slotButtonClicked(button);
}
void DolphinSettingsDialog::applySettings() void DolphinSettingsDialog::applySettings()
{ {
m_generalSettingsPage->applySettings(); m_generalSettingsPage->applySettings();

View file

@ -39,18 +39,20 @@ class DolphinSettingsDialog : public KPageDialog
Q_OBJECT Q_OBJECT
public: public:
explicit DolphinSettingsDialog(DolphinMainWindow* mainWindow); static DolphinSettingsDialog& instance(DolphinMainWindow* mainWindow);
virtual ~DolphinSettingsDialog(); virtual ~DolphinSettingsDialog();
protected slots: protected slots:
virtual void slotButtonClicked(int button); virtual void slotButtonClicked(int button);
private:
DolphinSettingsDialog(DolphinMainWindow* mainWindow);
void applySettings();
private: private:
DolphinMainWindow* m_mainWindow; DolphinMainWindow* m_mainWindow;
GeneralSettingsPage* m_generalSettingsPage; GeneralSettingsPage* m_generalSettingsPage;
ViewSettingsPage* m_viewSettingsPage; ViewSettingsPage* m_viewSettingsPage;
void applySettings();
}; };
#endif #endif