1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 12:23:53 +00:00

Show status bar setting working (feature #854). Turns out signals were not needed, may need to clean up later.

This commit is contained in:
cc9cii 2014-09-18 16:05:32 +10:00
parent 86636bd960
commit d9b0c81299
8 changed files with 50 additions and 2 deletions

View file

@ -55,6 +55,8 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit)
connect (&mStartup, SIGNAL (loadDocument()), this, SLOT (loadDocument ())); connect (&mStartup, SIGNAL (loadDocument()), this, SLOT (loadDocument ()));
connect (&mStartup, SIGNAL (editConfig()), this, SLOT (showSettings ())); connect (&mStartup, SIGNAL (editConfig()), this, SLOT (showSettings ()));
connect (&mSettings, SIGNAL (toggleStatusBar(bool)), &mViewManager, SLOT (toggleStatusBar(bool)));
connect (&mFileDialog, SIGNAL(signalOpenFiles (const boost::filesystem::path&)), connect (&mFileDialog, SIGNAL(signalOpenFiles (const boost::filesystem::path&)),
this, SLOT(openFiles (const boost::filesystem::path&))); this, SLOT(openFiles (const boost::filesystem::path&)));

View file

@ -40,6 +40,7 @@ void CSVDoc::View::closeEvent (QCloseEvent *event)
"Window Size/Height", "Window Size/Height",
QStringList(QString::number(frameGeometry().height()))); QStringList(QString::number(frameGeometry().height())));
CSMSettings::UserSettings::instance().saveDefinitions(); CSMSettings::UserSettings::instance().saveDefinitions();
// closeRequest() returns true if last document // closeRequest() returns true if last document
mViewManager.removeDocAndView(mDocument); mViewManager.removeDocAndView(mDocument);
} }
@ -442,6 +443,14 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin
view->useHint (hint); view->useHint (hint);
view->setStatusBar (mShowStatusBar->isChecked()); 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); 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() void CSVDoc::View::loadErrorLog()
{ {
addSubView (CSMWorld::UniversalId (CSMWorld::UniversalId::Type_LoadErrorLog, 0)); addSubView (CSMWorld::UniversalId (CSMWorld::UniversalId::Type_LoadErrorLog, 0));

View file

@ -106,6 +106,8 @@ namespace CSVDoc
void updateProgress (int current, int max, int type, int threads); void updateProgress (int current, int max, int type, int threads);
void toggleStatusBar(bool checked);
Operations *getOperations() const; Operations *getOperations() const;
/// Function called by view manager when user preferences are updated /// Function called by view manager when user preferences are updated

View file

@ -140,6 +140,10 @@ CSVDoc::View *CSVDoc::ViewManager::addView (CSMDoc::Document *document)
mViews.push_back (view); mViews.push_back (view);
std::string showStatusBar =
CSMSettings::UserSettings::instance().settingValue("Display/show statusbar").toStdString();
view->toggleStatusBar (showStatusBar == "true");
view->show(); view->show();
connect (view, SIGNAL (newGameRequest ()), this, SIGNAL (newGameRequest())); connect (view, SIGNAL (newGameRequest ()), this, SIGNAL (newGameRequest()));
@ -388,6 +392,13 @@ bool CSVDoc::ViewManager::removeDocument (CSVDoc::View *view)
return true; 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<View *>::const_iterator iter (mViews.begin()); iter!=mViews.end(); ++iter)
//(*iter)->toggleStatusBar(checked);
}
void CSVDoc::ViewManager::exitApplication (CSVDoc::View *view) void CSVDoc::ViewManager::exitApplication (CSVDoc::View *view)
{ {
if(!removeDocument(view)) // close the current document first if(!removeDocument(view)) // close the current document first

View file

@ -74,6 +74,8 @@ namespace CSVDoc
void exitApplication (CSVDoc::View *view); void exitApplication (CSVDoc::View *view);
void toggleStatusBar(bool checked);
private slots: private slots:
void documentStateChanged (int state, CSMDoc::Document *document); void documentStateChanged (int state, CSMDoc::Document *document);

View file

@ -155,6 +155,9 @@ CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent)
connect(cbOverride, SIGNAL(toggled(bool)), this, SLOT(slotOverrideToggled(bool))); connect(cbOverride, SIGNAL(toggled(bool)), this, SLOT(slotOverrideToggled(bool)));
connect(cmbRenderSys, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(slotRendererChanged(const QString&))); connect(cmbRenderSys, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(slotRendererChanged(const QString&)));
connect(rbStdWinSize, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); 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) bool CSVSettings::SettingsDialog::eventFilter(QObject *target, QEvent *event)
@ -295,13 +298,17 @@ void CSVSettings::SettingsDialog::setViewValues()
else else
{ {
// show what's in Ogre instead // 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) if(index != -1)
cmbStdWinSize->setCurrentIndex(index); cmbStdWinSize->setCurrentIndex(index);
rbCustWinSize->setChecked(true); rbCustWinSize->setChecked(true);
slotStandardToggled(false); slotStandardToggled(false);
} }
// status bar
cbStatusBar->setChecked(mModel->settingValue("Display/show statusbar") == "true");
} }
void CSVSettings::SettingsDialog::saveSettings() void CSVSettings::SettingsDialog::saveSettings()
@ -368,6 +375,12 @@ void CSVSettings::SettingsDialog::saveSettings()
QStringList(QString::number(sbHeight->value()))); 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(); mModel->saveDefinitions();
} }

View file

@ -55,6 +55,10 @@ namespace CSVSettings {
void slotRendererChanged(const QString &renderer); void slotRendererChanged(const QString &renderer);
void slotOverrideToggled(bool checked); void slotOverrideToggled(bool checked);
void slotStandardToggled(bool checked); void slotStandardToggled(bool checked);
signals:
void toggleStatusBar(bool checked);
}; };
} }
#endif // CSVSETTINGS_SETTINGSDIALOG_H #endif // CSVSETTINGS_SETTINGSDIALOG_H

View file

@ -285,7 +285,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QCheckBox" name="checkBox"> <widget class="QCheckBox" name="cbStatusBar">
<property name="text"> <property name="text">
<string>Show Status Bar</string> <string>Show Status Bar</string>
</property> </property>