From d9b0c8129969b425d60830eb9816a79db5ec5fa7 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 18 Sep 2014 16:05:32 +1000 Subject: [PATCH] Show status bar setting working (feature #854). Turns out signals were not needed, may need to clean up later. --- apps/opencs/editor.cpp | 2 ++ apps/opencs/view/doc/view.cpp | 14 ++++++++++++++ apps/opencs/view/doc/view.hpp | 2 ++ apps/opencs/view/doc/viewmanager.cpp | 11 +++++++++++ apps/opencs/view/doc/viewmanager.hpp | 2 ++ apps/opencs/view/settings/settingsdialog.cpp | 15 ++++++++++++++- apps/opencs/view/settings/settingsdialog.hpp | 4 ++++ files/ui/settingstab.ui | 2 +- 8 files changed, 50 insertions(+), 2 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 8590657ad..766726bce 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -55,6 +55,8 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit) connect (&mStartup, SIGNAL (loadDocument()), this, SLOT (loadDocument ())); connect (&mStartup, SIGNAL (editConfig()), this, SLOT (showSettings ())); + connect (&mSettings, SIGNAL (toggleStatusBar(bool)), &mViewManager, SLOT (toggleStatusBar(bool))); + connect (&mFileDialog, SIGNAL(signalOpenFiles (const boost::filesystem::path&)), this, SLOT(openFiles (const boost::filesystem::path&))); diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 2ac5d7236..c7186a4e6 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -40,6 +40,7 @@ void CSVDoc::View::closeEvent (QCloseEvent *event) "Window Size/Height", QStringList(QString::number(frameGeometry().height()))); CSMSettings::UserSettings::instance().saveDefinitions(); + // closeRequest() returns true if last document mViewManager.removeDocAndView(mDocument); } @@ -442,6 +443,14 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin view->useHint (hint); view->setStatusBar (mShowStatusBar->isChecked()); +// NOTE: only required if show status bar setting should be applied to existing +// window +#if 0 + std::string showStatusBar = + CSMSettings::UserSettings::instance().settingValue("Display/show statusbar").toStdString(); + + view->setStatusBar (showStatusBar == "true"); +#endif mSubViewWindow.addDockWidget (Qt::TopDockWidgetArea, view); @@ -662,6 +671,11 @@ void CSVDoc::View::toggleShowStatusBar (bool show) } } +void CSVDoc::View::toggleStatusBar(bool checked) +{ + mShowStatusBar->setChecked(checked); +} + void CSVDoc::View::loadErrorLog() { addSubView (CSMWorld::UniversalId (CSMWorld::UniversalId::Type_LoadErrorLog, 0)); diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp index 9b4f2099b..e7c813c5c 100644 --- a/apps/opencs/view/doc/view.hpp +++ b/apps/opencs/view/doc/view.hpp @@ -106,6 +106,8 @@ namespace CSVDoc void updateProgress (int current, int max, int type, int threads); + void toggleStatusBar(bool checked); + Operations *getOperations() const; /// Function called by view manager when user preferences are updated diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index 638b42d5f..d5e5e7027 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -140,6 +140,10 @@ CSVDoc::View *CSVDoc::ViewManager::addView (CSMDoc::Document *document) mViews.push_back (view); + std::string showStatusBar = + CSMSettings::UserSettings::instance().settingValue("Display/show statusbar").toStdString(); + + view->toggleStatusBar (showStatusBar == "true"); view->show(); connect (view, SIGNAL (newGameRequest ()), this, SIGNAL (newGameRequest())); @@ -388,6 +392,13 @@ bool CSVDoc::ViewManager::removeDocument (CSVDoc::View *view) return true; } +void CSVDoc::ViewManager::toggleStatusBar(bool checked) +{ + // NOTE: below only required if status bar change is to be applied to existing + //for (std::vector::const_iterator iter (mViews.begin()); iter!=mViews.end(); ++iter) + //(*iter)->toggleStatusBar(checked); +} + void CSVDoc::ViewManager::exitApplication (CSVDoc::View *view) { if(!removeDocument(view)) // close the current document first diff --git a/apps/opencs/view/doc/viewmanager.hpp b/apps/opencs/view/doc/viewmanager.hpp index 753d7f0cb..61b807960 100644 --- a/apps/opencs/view/doc/viewmanager.hpp +++ b/apps/opencs/view/doc/viewmanager.hpp @@ -74,6 +74,8 @@ namespace CSVDoc void exitApplication (CSVDoc::View *view); + void toggleStatusBar(bool checked); + private slots: void documentStateChanged (int state, CSMDoc::Document *document); diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index 4c426ff6d..886ba6da6 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -155,6 +155,9 @@ CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) connect(cbOverride, SIGNAL(toggled(bool)), this, SLOT(slotOverrideToggled(bool))); connect(cmbRenderSys, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(slotRendererChanged(const QString&))); connect(rbStdWinSize, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); + + // to update the checkbox on the view menu + connect(cbStatusBar, SIGNAL(toggled(bool)), this, SIGNAL (toggleStatusBar(bool))); } bool CSVSettings::SettingsDialog::eventFilter(QObject *target, QEvent *event) @@ -295,13 +298,17 @@ void CSVSettings::SettingsDialog::setViewValues() else { // show what's in Ogre instead - index = cmbStdWinSize->findData(getCurrentOgreResolution(), Qt::DisplayRole, Qt::MatchStartsWith); + index = cmbStdWinSize->findData(getCurrentOgreResolution(), + Qt::DisplayRole, Qt::MatchStartsWith); if(index != -1) cmbStdWinSize->setCurrentIndex(index); rbCustWinSize->setChecked(true); slotStandardToggled(false); } + + // status bar + cbStatusBar->setChecked(mModel->settingValue("Display/show statusbar") == "true"); } void CSVSettings::SettingsDialog::saveSettings() @@ -368,6 +375,12 @@ void CSVSettings::SettingsDialog::saveSettings() QStringList(QString::number(sbHeight->value()))); } + // status bar + if(cbStatusBar->isChecked()) + mModel->setDefinitions("Display/show statusbar", QStringList("true")); + else + mModel->setDefinitions("Display/show statusbar", QStringList("false")); + mModel->saveDefinitions(); } diff --git a/apps/opencs/view/settings/settingsdialog.hpp b/apps/opencs/view/settings/settingsdialog.hpp index 07f5ebf24..3dda0700c 100644 --- a/apps/opencs/view/settings/settingsdialog.hpp +++ b/apps/opencs/view/settings/settingsdialog.hpp @@ -55,6 +55,10 @@ namespace CSVSettings { void slotRendererChanged(const QString &renderer); void slotOverrideToggled(bool checked); void slotStandardToggled(bool checked); + + signals: + + void toggleStatusBar(bool checked); }; } #endif // CSVSETTINGS_SETTINGSDIALOG_H diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 2cef67b0e..0b365634e 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -285,7 +285,7 @@ - + Show Status Bar