From 61bab6b1f1b6b2b8bec9b47989f04da1cb1b3b18 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 25 Sep 2014 08:15:07 +1000 Subject: [PATCH] Sanitised version. Some settings are only accessible via manually editing the config file. --- apps/opencs/CMakeLists.txt | 1 - apps/opencs/editor.cpp | 31 +- apps/opencs/model/settings/usersettings.cpp | 18 +- apps/opencs/model/settings/usersettings.hpp | 1 + apps/opencs/view/doc/view.cpp | 22 +- apps/opencs/view/render/scenewidget.cpp | 18 +- apps/opencs/view/settings/dialog.cpp | 376 ++++---------------- apps/opencs/view/settings/dialog.hpp | 18 +- apps/opencs/view/settings/settingwindow.cpp | 9 +- apps/opencs/view/settings/settingwindow.hpp | 8 +- files/ui/settingstab.ui | 318 ----------------- 11 files changed, 118 insertions(+), 702 deletions(-) delete mode 100644 files/ui/settingstab.ui diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index ad04b8a372..7094f8799e 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -142,7 +142,6 @@ set (OPENCS_RES ${CMAKE_SOURCE_DIR}/files/opencs/resources.qrc set (OPENCS_UI ${CMAKE_SOURCE_DIR}/files/ui/contentselector.ui ${CMAKE_SOURCE_DIR}/files/ui/filedialog.ui - ${CMAKE_SOURCE_DIR}/files/ui/settingstab.ui ) source_group (opencs FILES ${OPENCS_SRC} ${OPENCS_HDR}) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 960e54e880..57b0707aa2 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -314,40 +314,19 @@ std::auto_ptr CS::Editor::setupGraphics() factory->loadAllFiles(); - bool shaders = true; // default if setting does not exist - if(mUserSettings.hasSettingDefinitions("Objects/shaders")) - shaders = mUserSettings.settingValue("Objects/shaders").toStdString() == "true" ? true : false; - else - mUserSettings.setDefinitions("Objects/shaders", (QStringList() << QString(shaders ? "true" : "false"))); + bool shaders = mUserSettings.setting("Objects/shaders", (QStringList() << QString("true"))) == "true" ? true : false; sh::Factory::getInstance ().setShadersEnabled (shaders); - std::string fog("true"); - if(mUserSettings.hasSettingDefinitions("Shader/fog")) - fog = mUserSettings.settingValue("Shader/fog").toStdString(); - else - mUserSettings.setDefinitions("Shader/fog", (QStringList() << QString(fog.c_str()))); + std::string fog = mUserSettings.setting("Shader/fog", (QStringList() << QString("true"))).toStdString(); sh::Factory::getInstance().setGlobalSetting ("fog", fog); - std::string shadows("false"); - if(mUserSettings.hasSettingDefinitions("Shader/shadows")) - shadows = shaders? mUserSettings.settingValue("Shader/shadows").toStdString() : "false"; - else - mUserSettings.setDefinitions("Shader/shadows", (QStringList() << QString(shadows.c_str()))); + std::string shadows = mUserSettings.setting("Shader/shadows", (QStringList() << QString("false"))).toStdString(); sh::Factory::getInstance().setGlobalSetting ("shadows", shadows); - std::string shadows_pssm("false"); - if(mUserSettings.hasSettingDefinitions("Shader/shadows_pssm")) - shadows_pssm = mUserSettings.settingValue("Shader/shadows_pssm").toStdString(); - else - mUserSettings.setDefinitions("Shader/shadows_pssm", (QStringList() << QString(shadows_pssm.c_str()))); + std::string shadows_pssm = mUserSettings.setting("Shader/shadows_pssm", (QStringList() << QString("false"))).toStdString(); sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", shadows_pssm); - - std::string render_refraction("false"); - if(mUserSettings.hasSettingDefinitions("Shader/render_refraction")) - render_refraction = mUserSettings.settingValue("Shader/render_refraction").toStdString(); - else - mUserSettings.setDefinitions("Shader/render_refraction", (QStringList() << QString(render_refraction.c_str()))); + std::string render_refraction = mUserSettings.setting("Shader/render_refraction", (QStringList() << QString("false"))).toStdString(); sh::Factory::getInstance ().setGlobalSetting ("render_refraction", render_refraction); // internal setting - may be switched on or off by the use of shader configurations diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 44473c03d1..a4655f7bfa 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -57,8 +57,6 @@ void UserSettings::buildSettingModelDefaults() page = "Objects"; { - QString section = "Group1"; - Setting *numLights = createSetting (Type_SpinBox, page, "num lights"); numLights->setDefaultValue(8); numLights->setEditorSetting(true); @@ -112,7 +110,6 @@ void UserSettings::buildSettingModelDefaults() timerStart->setViewLocation(3, 2); } -#if 0 page = "Window Size"; { Setting *width = createSetting (Type_LineEdit, page, "Width"); @@ -151,7 +148,6 @@ void UserSettings::buildSettingModelDefaults() QStringList() << "480" << "600" << "768" << "900" ); } -#endif page = "Display Format"; { @@ -499,6 +495,20 @@ QStringList UserSettings::getShaderLanguageByRenderer(const QString &renderer) return result; } +// if the key is not found create one with a defaut value +QString UserSettings::setting(const QString &viewKey, const QStringList &list) +{ + if(mSettingDefinitions->contains(viewKey)) + return settingValue(viewKey); + else if(!list.empty()) + { + mSettingDefinitions->setValue (viewKey, list); + return list.at(0); + } + + return QString(); +} + bool UserSettings::hasSettingDefinitions (const QString &viewKey) const { return (mSettingDefinitions->contains (viewKey)); diff --git a/apps/opencs/model/settings/usersettings.hpp b/apps/opencs/model/settings/usersettings.hpp index dfefb131a4..01e50739f1 100644 --- a/apps/opencs/model/settings/usersettings.hpp +++ b/apps/opencs/model/settings/usersettings.hpp @@ -81,6 +81,7 @@ namespace CSMSettings { QStringList getShaderLanguageByRenderer(const QString &renderer); QStringList getOgreOptions(const QString &key, const QString &renderer); QStringList getOgreRenderers(); + QString setting(const QString &viewKey, const QStringList &list = QStringList()); private: diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 3a62aeafb7..2ff00a5351 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -455,11 +455,8 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin bool isReferenceable = std::find(referenceables.begin(), referenceables.end(), id.getType()) != referenceables.end(); // User setting to reuse sub views (on a per top level view basis) - bool reuse = true; - if(userSettings.hasSettingDefinitions("SubView/reuse")) - reuse = userSettings.settingValue("SubView/reuse").toStdString() == "true" ? true : false; - else - userSettings.setDefinitions("SubView/reuse", (QStringList() << QString(reuse ? "true" : "false"))); + bool reuse = + userSettings.setting("SubView/reuse", (QStringList() << QString("true"))) == "true" ? true : false; if(reuse) { foreach(SubView *sb, mSubViews) @@ -478,12 +475,8 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin // // If the sub view limit setting is one, the sub view title bar is hidden and the // text in the main title bar is adjusted accordingly - int maxSubView = 3; - if(userSettings.hasSettingDefinitions("SubView/max subviews")) - maxSubView = userSettings.settingValue("SubView/max subviews").toInt(); - else - userSettings.setDefinitions("SubView/max subviews", (QStringList() << QString(maxSubView))); - + int maxSubView = + userSettings.setting("SubView/max subviews", (QStringList() << QString("3"))).toInt(); if(mSubViews.size() >= maxSubView) // create a new top level view { mViewManager.addView(mDocument, id, hint); @@ -506,11 +499,8 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin if (!hint.empty()) view->useHint (hint); - int minWidth = 325; // default value to use if none found - if(userSettings.hasSettingDefinitions("SubView/minimum width")) - minWidth = userSettings.settingValue("SubView/minimum width").toInt(); - else - userSettings.setDefinitions("SubView/minimum width", (QStringList() << QString(minWidth))); + int minWidth = + userSettings.setting("SubView/minimum width", (QStringList() << QString("325"))).toInt(); view->setMinimumWidth(minWidth); view->setStatusBar (mShowStatusBar->isChecked()); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 8605f5d0f7..ff1765f354 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -47,17 +47,11 @@ namespace CSVRender mCamera->setNearClipDistance (0.1); CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); - int farClipDist = 300000; - if(userSettings.hasSettingDefinitions("Scene/far clip distance")) - farClipDist = userSettings.settingValue("Scene/far clip distance").toInt(); - else - userSettings.setDefinitions("Scene/far clip distance", (QStringList() << QString(farClipDist))); + + int farClipDist = userSettings.setting("Scene/far clip distance", (QStringList() << QString("300000"))).toInt(); mCamera->setFarClipDistance (farClipDist); - if(userSettings.hasSettingDefinitions("Scene/fast factor")) - mFastFactor = userSettings.settingValue("Scene/fast factor").toInt(); - else - userSettings.setDefinitions("Scene/fast factor", (QStringList() << QString(mFastFactor))); + mFastFactor = userSettings.setting("Scene/fast factor", (QStringList() << QString("4"))).toInt(); mCamera->roll (Ogre::Degree (90)); @@ -67,11 +61,7 @@ namespace CSVRender connect (timer, SIGNAL (timeout()), this, SLOT (update())); - int timerStart = 20; - if(userSettings.hasSettingDefinitions("Scene/timer start")) - timerStart = userSettings.settingValue("Scene/timer start").toInt(); - else - userSettings.setDefinitions("Scene/timer start", (QStringList() << QString(timerStart))); + int timerStart = userSettings.setting("Scene/timer start", (QStringList() << QString("20"))).toInt(); timer->start (timerStart); /// \todo make shortcut configurable diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index 7648813bf5..56bc1fdfee 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -1,273 +1,100 @@ #include "dialog.hpp" +#include #include -#include #include +#include +#include #include "../../model/settings/usersettings.hpp" + #include "page.hpp" -#include -#include +#include -namespace { +#include -QRect getMaximumResolution() +#include +#include +#include + +#include +#include + +CSVSettings::Dialog::Dialog(QMainWindow *parent) + : mStackedWidget (0), mDebugMode (false), SettingWindow (parent) { - QRect max; - int screens = QApplication::desktop()->screenCount(); - for(int i = 0; i < screens; ++i) - { - QRect res = QApplication::desktop()->screenGeometry(i); - if(res.width() > max.width()) - max.setWidth(res.width()); - if(res.height() > max.height()) - max.setHeight(res.height()); - } - return max; + setWindowTitle(QString::fromUtf8 ("User Settings")); + + setupDialog(); + + connect (mPageListWidget, + SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)), + this, + SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*))); } -QString getAspect(int x, int y) +void CSVSettings::Dialog::slotChangePage + (QListWidgetItem *cur, QListWidgetItem *prev) { - int gcd = boost::math::gcd (x, y); - int xaspect = x / gcd; - int yaspect = y / gcd; - // special case: 8 : 5 is usually referred to as 16:10 - if (xaspect == 8 && yaspect == 5) - return QString("16:10"); + mStackedWidget->changePage + (mPageListWidget->row (cur), mPageListWidget->row (prev)); - return QString(QString::number(xaspect) + ":" + QString::number(yaspect)); + layout()->activate(); + setFixedSize(minimumSizeHint()); } -QString getCurrentOgreResolution() +void CSVSettings::Dialog::setupDialog() { - Ogre::ConfigOptionMap& renderOpt = - Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); - Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); - for(; it != renderOpt.end(); ++it) - { - if(it->first == "Video Mode" ) - { - QRegExp re("^(\\d+ x \\d+)"); - if (re.indexIn(it->second.currentValue.c_str(), 0) > -1) - return re.cap(1); - } - } - return QString(); // found nothing -} + //create central widget with it's layout and immediate children + QWidget *centralWidget = new QGroupBox (this); -bool customCompare(const QString &s1, const QString &s2) -{ - int x1, x2, y1, y2; - QRegExp re("^(\\d+) x (\\d+)"); + centralWidget->setLayout (new QHBoxLayout()); + centralWidget->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Preferred); + setCentralWidget (centralWidget); + setDockOptions (QMainWindow::AllowNestedDocks); - if(re.indexIn(s1) > -1) - { - x1 = re.cap(1).toInt(); - y1 = re.cap(2).toInt(); - } - if(re.indexIn(s2) > -1) - { - x2 = re.cap(1).toInt(); - y2 = re.cap(2).toInt(); - } - - if(x1 == x2) - return y1 > y2; - else - return x1 > x2; -} - -QStringList getAvailableResolutions() -{ - // store available rendering devices and available resolutions - QStringList result; - - Ogre::ConfigOptionMap& renderOpt = Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); - Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); - for(;it != renderOpt.end(); ++it) - { - if(it->first == "Video Mode" ) - { - if(it->second.possibleValues.empty()) - { - return result; // FIXME: add error message - } - // Store Available Resolutions - Ogre::StringVector::iterator iter = it->second.possibleValues.begin(); - for(; iter != it->second.possibleValues.end(); ++iter) - { - // extract x and y values - QRegExp re("^(\\d+) x (\\d+)"); - if(re.indexIn((*iter).c_str(), 0) > -1) - { - QString aspect = getAspect(re.cap(1).toInt(), re.cap(2).toInt()); - QString resolution = re.cap(1) + QString(" x ") + re.cap(2); - if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) { - resolution.append(QObject::tr("\t(Wide ") + aspect + ")"); - - } else if (aspect == QLatin1String("4:3")) { - resolution.append(QObject::tr("\t(Standard 4:3)")); - } - result.append(resolution); - } - } - } - } - result.removeDuplicates(); - qStableSort(result.begin(), result.end(), customCompare); - return result; -} - -} - - -CSVSettings::Dialog::Dialog(QTabWidget *parent) - : mDebugMode (false), SettingWindow (parent) -{ - setObjectName(QString::fromUtf8 ("User Settings")); - - setupUi(this); - - // Set the maximum res we can set in windowed mode - QRect res = getMaximumResolution(); - sbWidth->setMaximum(res.width()); - sbHeight->setMaximum(res.height()); - - connect(cbOverride, SIGNAL(toggled(bool)), this, SLOT(slotOverrideToggled(bool))); - connect(cmbRenderSys, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(slotRendererChanged(const QString&))); - - displayGroup_Window->installEventFilter(this); -} - -bool CSVSettings::Dialog::eventFilter(QObject *target, QEvent *event) -{ - if (event->type() == QEvent::MouseButtonDblClick) - { - if(stackedWidget->currentWidget() == page_1) - { - stackedWidget->setCurrentWidget(page_2); - return false; - } - else if(stackedWidget->currentWidget() == page_2) - { - stackedWidget->setCurrentWidget(page_1); - return false; - } - } - - return QTabWidget::eventFilter(target, event); -} - -void CSVSettings::Dialog::slotRendererChanged(const QString &renderer) -{ - cmbAntiAlias->clear(); - cmbAntiAlias->addItems(model()->getOgreOptions(QString("FSAA"), renderer)); - - cmbShaderLang->clear(); - cmbShaderLang->addItems(model()->getShaderLanguageByRenderer(renderer)); -} - -void CSVSettings::Dialog::slotOverrideToggled(bool checked) -{ - if(checked) - { - labRenderSys->setEnabled(false); - cmbRenderSys->setEnabled(false); - labAntiAlias->setEnabled(false); - cmbAntiAlias->setEnabled(false); - labShaderLang->setEnabled(false); - cmbShaderLang->setEnabled(false); - } - else - { - labRenderSys->setEnabled(true); - cmbRenderSys->setEnabled(true); - labAntiAlias->setEnabled(true); - cmbAntiAlias->setEnabled(true); - labShaderLang->setEnabled(true); - cmbShaderLang->setEnabled(true); - } + buildPageListWidget (centralWidget); + buildStackedWidget (centralWidget); } void CSVSettings::Dialog::buildPages() { - int index = -1; - - // initialised in the constructor - slotOverrideToggled(cbOverride->isChecked()); - - // Ogre renderer - cmbRenderSys->clear(); - cmbRenderSys->addItems(model()->getOgreRenderers()); - - // antialiasing - QString antialiasing = model()->settingValue("Video/antialiasing"); - index = cmbAntiAlias->findData(antialiasing, Qt::DisplayRole); - if(index != -1) - cmbAntiAlias->setCurrentIndex(index); - - // shader lang - QString shaderlang = model()->settingValue("General/shader mode"); - index = cmbShaderLang->findData(shaderlang, Qt::DisplayRole); - if(index != -1) - cmbShaderLang->setCurrentIndex(index); - - if(model()->settingValue("Window Size/Width") != "") - sbWidth->setValue(model()->settingValue("Window Size/Width").toInt()); - - if(model()->settingValue("Window Size/Height") != "") - sbHeight->setValue(model()->settingValue("Window Size/Height").toInt()); - - // update display resolution combo box - cmbStdWinSize->clear(); - cmbStdWinSize->addItems(getAvailableResolutions()); - - QString currRes = model()->settingValue("Window Size/Width") + " x " + - model()->settingValue("Window Size/Height"); - - index = cmbStdWinSize->findData(currRes, Qt::DisplayRole, Qt::MatchStartsWith); - if(index != -1) - { - // show the values in ini file - cmbStdWinSize->setCurrentIndex(index); - } - else - { - // show what's in Ogre instead - index = cmbStdWinSize->findData(getCurrentOgreResolution(), - Qt::DisplayRole, Qt::MatchStartsWith); - if(index != -1) - cmbStdWinSize->setCurrentIndex(index); - } - - // status bar - cbStatusBar->setChecked(model()->settingValue("Display/show statusbar") == "true"); - - // subview - if(model()->hasSettingDefinitions("SubView/minimum width")) - sbMinSubViewWidth->setValue(model()->settingValue("SubView/minimum width").toInt()); - else - sbMinSubViewWidth->setValue(325); - - if(model()->hasSettingDefinitions("SubView/max subviews")) - sbMaxSubViews->setValue(model()->settingValue("SubView/max subviews").toInt()); - else - sbMaxSubViews->setValue(3); - - cbReuseSubView->setChecked(model()->settingValue("SubView/reuse") == "true"); - SettingWindow::createPages (); + QFontMetrics fm (QApplication::font()); + foreach (Page *page, SettingWindow::pages()) { QString pageName = page->objectName(); - // each page is added as a tab to Ui::TabWiget - addTab(page, page->objectName()); - // add section and views to the page - page->showWidgets(); + int textWidth = fm.width(pageName); + + new QListWidgetItem (pageName, mPageListWidget); + mPageListWidget->setFixedWidth (textWidth + 50); + + mStackedWidget->addWidget (&dynamic_cast(*(page))); } + + resize (mStackedWidget->sizeHint()); +} + +void CSVSettings::Dialog::buildPageListWidget (QWidget *centralWidget) +{ + mPageListWidget = new QListWidget (centralWidget); + mPageListWidget->setMinimumWidth(50); + mPageListWidget->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Expanding); + + mPageListWidget->setSelectionBehavior (QAbstractItemView::SelectItems); + + centralWidget->layout()->addWidget(mPageListWidget); +} + +void CSVSettings::Dialog::buildStackedWidget (QWidget *centralWidget) +{ + mStackedWidget = new ResizeableStackedWidget (centralWidget); + + centralWidget->layout()->addWidget (mStackedWidget); } void CSVSettings::Dialog::closeEvent (QCloseEvent *event) @@ -276,59 +103,6 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) //model is updated SettingWindow::closeEvent (event); - // override - if(cbOverride->isChecked()) - model()->setDefinitions("Video/use settings.cfg", QStringList("true")); - else - model()->setDefinitions("Video/use settings.cfg", QStringList("false")); - - // render system - model()->setDefinitions("Video/render system", - QStringList(cmbRenderSys->currentText())); - - // antialiasing - model()->setDefinitions("Video/antialiasing", - QStringList(cmbAntiAlias->currentText())); - - // shader lang (no group means "General" group) - model()->setDefinitions("shader mode", - QStringList(cmbShaderLang->currentText().toLower())); - - // window size - if(page_2->isEnabled()) - { - QRegExp re("^(\\d+) x (\\d+)"); - if(re.indexIn(cmbStdWinSize->currentText()) > -1) - { - model()->setDefinitions("Window Size/Width", QStringList(re.cap(1))); - model()->setDefinitions("Window Size/Height", QStringList(re.cap(2))); - } - } - else - { - model()->setDefinitions("Window Size/Width", - QStringList(QString::number(sbWidth->value()))); - model()->setDefinitions("Window Size/Height", - QStringList(QString::number(sbHeight->value()))); - } - - // status bar - if(cbStatusBar->isChecked()) - model()->setDefinitions("Display/show statusbar", QStringList("true")); - else - model()->setDefinitions("Display/show statusbar", QStringList("false")); - - // subview - model()->setDefinitions("SubView/minimum width", - QStringList(QString::number(sbMinSubViewWidth->value()))); - model()->setDefinitions("SubView/max subviews", - QStringList(QString::number(sbMaxSubViews->value()))); - - if(cbReuseSubView->isChecked()) - model()->setDefinitions("SubView/reuse", QStringList("true")); - else - model()->setDefinitions("SubView/reuse", QStringList("false")); - saveSettings(); } @@ -340,20 +114,8 @@ void CSVSettings::Dialog::show() setViewValues(); } - QWidget *currView = QApplication::activeWindow(); - if(currView) - { - // place at the center of the window with focus - QSize size = currView->size(); - move(currView->geometry().x()+(size.width() - frameGeometry().width())/2, - currView->geometry().y()+(size.height() - frameGeometry().height())/2); - } - else - { - // something's gone wrong, place at the center of the screen - QPoint screenCenter = QApplication::desktop()->screenGeometry().center(); - move(screenCenter - QPoint(frameGeometry().width()/2, - frameGeometry().height()/2)); - } + QPoint screenCenter = QApplication::desktop()->screenGeometry().center(); + + move (screenCenter - geometry().center()); QWidget::show(); } diff --git a/apps/opencs/view/settings/dialog.hpp b/apps/opencs/view/settings/dialog.hpp index 47422feb42..b0e12c4615 100644 --- a/apps/opencs/view/settings/dialog.hpp +++ b/apps/opencs/view/settings/dialog.hpp @@ -2,23 +2,28 @@ #define CSVSETTINGS_DIALOG_H #include "settingwindow.hpp" +#include "resizeablestackedwidget.hpp" #include -#include "ui_settingstab.h" +class QStackedWidget; +class QListWidget; +class QListWidgetItem; namespace CSVSettings { class Page; - class Dialog : public SettingWindow, private Ui::TabWidget + class Dialog : public SettingWindow { Q_OBJECT + QListWidget *mPageListWidget; + ResizeableStackedWidget *mStackedWidget; bool mDebugMode; public: - explicit Dialog (QTabWidget *parent = 0); + explicit Dialog (QMainWindow *parent = 0); ///Enables setting debug mode. When the dialog opens, a page is created ///which displays the SettingModel's contents in a Tree view. @@ -29,11 +34,13 @@ namespace CSVSettings { /// Settings are written on close void closeEvent (QCloseEvent *event); - bool eventFilter(QObject *target, QEvent *event); + void setupDialog(); private: void buildPages(); + void buildPageListWidget (QWidget *centralWidget); + void buildStackedWidget (QWidget *centralWidget); public slots: @@ -41,8 +48,7 @@ namespace CSVSettings { private slots: - void slotOverrideToggled(bool checked); - void slotRendererChanged(const QString &renderer); + void slotChangePage (QListWidgetItem *, QListWidgetItem *); }; } #endif // CSVSETTINGS_DIALOG_H diff --git a/apps/opencs/view/settings/settingwindow.cpp b/apps/opencs/view/settings/settingwindow.cpp index d9bc890b16..7cdf2bded9 100644 --- a/apps/opencs/view/settings/settingwindow.cpp +++ b/apps/opencs/view/settings/settingwindow.cpp @@ -1,16 +1,15 @@ -#include "settingwindow.hpp" - #include #include #include "../../model/settings/setting.hpp" #include "../../model/settings/connector.hpp" #include "../../model/settings/usersettings.hpp" +#include "settingwindow.hpp" #include "page.hpp" #include "view.hpp" -CSVSettings::SettingWindow::SettingWindow(QTabWidget *parent) - : QTabWidget(parent) +CSVSettings::SettingWindow::SettingWindow(QWidget *parent) + : QMainWindow(parent) {} void CSVSettings::SettingWindow::createPages() @@ -20,7 +19,7 @@ void CSVSettings::SettingWindow::createPages() QList connectedSettings; foreach (const QString &pageName, pageMap.keys()) - { + { QList pageSettings = pageMap.value (pageName); mPages.append (new Page (pageName, pageSettings, this)); diff --git a/apps/opencs/view/settings/settingwindow.hpp b/apps/opencs/view/settings/settingwindow.hpp index 024873ae0c..2266f130df 100644 --- a/apps/opencs/view/settings/settingwindow.hpp +++ b/apps/opencs/view/settings/settingwindow.hpp @@ -1,7 +1,7 @@ #ifndef CSVSETTINGS_SETTINGWINDOW_HPP #define CSVSETTINGS_SETTINGWINDOW_HPP -#include +#include #include #include "../../model/settings/support.hpp" @@ -18,7 +18,7 @@ namespace CSVSettings { typedef QList PageList; - class SettingWindow : public QTabWidget + class SettingWindow : public QMainWindow { Q_OBJECT @@ -26,7 +26,7 @@ namespace CSVSettings { CSMSettings::UserSettings *mModel; public: - explicit SettingWindow(QTabWidget *parent = 0); + explicit SettingWindow(QWidget *parent = 0); ///retrieve a reference to a view based on it's page and setting name View *findView (const QString &pageName, const QString &setting); @@ -50,8 +50,6 @@ namespace CSVSettings { ///sets the defined values for the views that have been created void setViewValues(); - CSMSettings::UserSettings *model() { return mModel; } - private: ///create connections between settings (used for proxy settings) diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui deleted file mode 100644 index 0a94348d12..0000000000 --- a/files/ui/settingstab.ui +++ /dev/null @@ -1,318 +0,0 @@ - - - TabWidget - - - - 0 - 0 - 400 - 313 - - - - User Settings - - - 0 - - - - Display Settings - - - - - 10 - 200 - 371 - 79 - - - - Subviews - - - - - 240 - 21 - 102 - 17 - - - - Show Status Bar - - - - - - 240 - 49 - 101 - 17 - - - - Reuse Subviews - - - - - - - 10 - 140 - 211 - 51 - - - - Window Size - - - - true - - - - 10 - 20 - 191 - 22 - - - - 0 - - - - true - - - - - 0 - 0 - 191 - 22 - - - - - - - - 186 - 16777215 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - true - - - - - 0 - 0 - 191 - 22 - - - - - - - - - - 21 - 29 - 231 - 17 - - - - Use Render System Settings from OpenMW - - - true - - - - - - 10 - 10 - 371 - 125 - - - - Render System - - - - - 172 - 42 - 181 - 20 - - - - false - - - - - - 12 - 94 - 54 - 16 - - - - Antialiasing - - - - - - 12 - 68 - 84 - 16 - - - - Shader Language - - - - - - 12 - 42 - 104 - 16 - - - - Rendering Subsystem - - - - - - 172 - 68 - 181 - 20 - - - - - - - 172 - 94 - 181 - 20 - - - - - - - - 20 - 220 - 191 - 48 - - - - - - - Max Number of Subviews: - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1 - - - - - - - Min Subview Width: - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 50 - - - 20000 - - - 5 - - - - - - displayGroup_Render - displayGroup_Subviews - displayGroup_Window - cbOverride - layoutWidget_2 - - - - cbOverride - cmbRenderSys - cmbShaderLang - cmbAntiAlias - sbWidth - sbHeight - sbMaxSubViews - sbMinSubViewWidth - cbStatusBar - cbReuseSubView - cmbStdWinSize - - - -