From 0ec20b23aa4a2cfad0145dc33fc0b16104b811bb Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 14 Sep 2014 12:48:00 +1000 Subject: [PATCH 01/48] Initial working version. Video/rendering options supported. No GUI yet. --- apps/opencs/editor.cpp | 32 ++++- apps/opencs/model/settings/usersettings.cpp | 130 ++++++++++++++++++-- apps/opencs/model/settings/usersettings.hpp | 1 + 3 files changed, 150 insertions(+), 13 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index e8e2d9077..d3e5c6720 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -259,21 +259,32 @@ int CS::Editor::run() std::auto_ptr CS::Editor::setupGraphics() { - // TODO: setting - Ogre::Root::getSingleton().setRenderSystem(Ogre::Root::getSingleton().getRenderSystemByName("OpenGL Rendering Subsystem")); + std::string rendersystem = mUserSettings.settingValue("Video/render system").toStdString(); + Ogre::Root::getSingleton().setRenderSystem(Ogre::Root::getSingleton().getRenderSystemByName(rendersystem)); + std::cout << "editor: render system " + rendersystem << std::endl; // FIXME: debug Ogre::Root::getSingleton().initialise(false); // Create a hidden background window to keep resources Ogre::NameValuePairList params; params.insert(std::make_pair("title", "")); - params.insert(std::make_pair("FSAA", "0")); - params.insert(std::make_pair("vsync", "false")); + + std::string antialiasing = mUserSettings.settingValue("Video/antialiasing").toStdString(); + if(antialiasing == "MSAA 16") antialiasing = "16"; + else if(antialiasing == "MSAA 8") antialiasing = "8"; + else if(antialiasing == "MSAA 4") antialiasing = "4"; + else if(antialiasing == "MSAA 2") antialiasing = "2"; + else antialiasing = "0"; + params.insert(std::make_pair("FSAA", antialiasing)); + + std::string vsync = mUserSettings.settingValue("Video/vsync").toStdString() == "true" ? "true" : "false"; + params.insert(std::make_pair("vsync", vsync)); params.insert(std::make_pair("hidden", "true")); #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE params.insert(std::make_pair("macAPI", "cocoa")); #endif - Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, false, ¶ms); + bool fullscreen = mUserSettings.settingValue("Video/fullscreen").toStdString() == "true" ? true : false; + Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, fullscreen, ¶ms); hiddenWindow->setActive(false); sh::OgrePlatform* platform = @@ -286,7 +297,16 @@ std::auto_ptr CS::Editor::setupGraphics() std::auto_ptr factory (new sh::Factory (platform)); - factory->setCurrentLanguage (sh::Language_GLSL); /// \todo make this configurable + std::string shLang = mUserSettings.settingValue("Shiny/language").toStdString(); + enum sh::Language lang; + if(shLang == "CG") lang = sh::Language_CG; + else if(shLang == "HLSL") lang = sh::Language_HLSL; + else if(shLang == "GLSL") lang = sh::Language_GLSL; + else if(shLang == "GLSLES") lang = sh::Language_GLSLES; + else if(shLang == "Count") lang = sh::Language_Count; + else lang = sh::Language_None; + + factory->setCurrentLanguage (lang); factory->setWriteSourceCache (true); factory->setReadSourceCache (true); factory->setReadMicrocodeCache (true); diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 04f98f0d6..be0e3ab26 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -4,10 +4,13 @@ #include #include +#include + #include #include "setting.hpp" #include "support.hpp" +#include #include /** @@ -26,17 +29,66 @@ namespace boost } /* namespace boost */ #endif /* (BOOST_VERSION <= 104600) */ +/* + * FIXME: temporary notes + * + * - CSVSettings::Dialog::Dialog is the settings window + * - provide a hard coded default if not found in config file + * - provide tooltips + * - save/cancel option (or auto-save?) + * - opencs.ini: where all these settings are saved + * . error if can't create file (directory permissions) or save file (file permissions) + * - settings.cfg: where Graphics default settings come from (read only) + * . warning if neither default or user cfg not found or not readable (file permissions) + * - openmw.cfg: not used + * + * - Tabbed view similar to OpenMW or Launcher + * . Video Settings + * . Display Settngs + * . Misc Settings + * + * - Video settings: tick box for "Use the video settings from OpenMW" (default, + * individual settings greyed out) + * . CS::Editor::setupGraphics() + * . the defaults should be the initial setting when unticked, unless previous user + * settings were found + * # OpenGL/Direct3D9 Rendering Subsystem + * # Vsync + * # FSAA (antialiasing) + * # GLSL/CG shader language + * . other shiny options + * . screen number + * # full screen / windowed (resolution) <- replace already existing + * + * - Display Settings + * . text only / icon + text <- replace already existing + * . limit the number of subviews per top level view + * . option to reuse subviews + * . v/w/dialoguesubview min width 325 + * . filter pattern syntax + * + * - misc + * . v/r/scenewidget mFastFactor(4) + * . v/r/scenewidget far clip distance + * . v/r/scenewidget start timer 20 + * . v/r/scenewidget shortcut + * . v/d/adjusterwidget error + * . v/r/navigation factor /= 2 + * . v/w/table redirect extended action + */ + CSMSettings::UserSettings *CSMSettings::UserSettings::mUserSettingsInstance = 0; CSMSettings::UserSettings::UserSettings (const Files::ConfigurationManager& configurationManager) -: mCfgMgr (configurationManager) + : mCfgMgr (configurationManager) + , mSettingDefinitions(NULL) + , mSettingCfgDefinitions(NULL) { assert(!mUserSettingsInstance); mUserSettingsInstance = this; - mSettingDefinitions = 0; - buildSettingModelDefaults(); + mSettingCfgDefinitions = new QSettings(QSettings::IniFormat, QSettings::UserScope, ""); } void CSMSettings::UserSettings::buildSettingModelDefaults() @@ -276,6 +328,8 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() CSMSettings::UserSettings::~UserSettings() { + delete mSettingDefinitions; + delete mSettingCfgDefinitions; mUserSettingsInstance = 0; } @@ -305,6 +359,54 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName) mSettingDefinitions = new QSettings (QSettings::IniFormat, QSettings::UserScope, "opencs", QString(), this); + + // if user setting (opencs.ini) exists + // if readable, then check whether the option to use settings.cfg video settings should be used is set + // use the config settings from settings.cfg + // else if video config found + // use the config settings from opencs.ini + // if any of the config option is not found, use hard coded default in this file + // + + // Create the settings manager and load default settings file + const std::string localdefault = mCfgMgr.getLocalPath().string() + "/settings-default.cfg"; + const std::string globaldefault = mCfgMgr.getGlobalPath().string() + "/settings-default.cfg"; + + Settings::Manager settings; + // prefer local + if (boost::filesystem::exists(localdefault)) + settings.loadDefault(localdefault); + else if (boost::filesystem::exists(globaldefault)) + settings.loadDefault(globaldefault); + else + std::cerr<< "No default settings file found! Make sure the file \"settings-default.cfg\" was properly installed."<< std::endl; + + // load user settings if they exist, otherwise just load the default settings as user settings + const std::string settingspath = mCfgMgr.getUserConfigPath().string() + "/settings.cfg"; + if (boost::filesystem::exists(settingspath)) + settings.loadUser(settingspath); + else if (boost::filesystem::exists(localdefault)) + settings.loadUser(localdefault); + else if (boost::filesystem::exists(globaldefault)) + settings.loadUser(globaldefault); + + std::string renderSystem = settings.getString("render system", "Video"); + std::cout << "user settings: render system " + renderSystem << std::endl; // FIXME: debug + + if(renderSystem == "") + { +#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 + renderSystem = "Direct3D9 Rendering Subsystem"; +#else + renderSystem = "OpenGL Rendering Subsystem"; +#endif + } + mSettingCfgDefinitions->setValue("Video/render system", renderSystem.c_str()); + // Force shiny language based on render system + if(renderSystem == "Direct3D9 Rendering Subsystem") + mSettingDefinitions->setValue("Shiny/language", "CG"); + else + mSettingDefinitions->setValue("Shiny/language", "GLSL"); } bool CSMSettings::UserSettings::hasSettingDefinitions @@ -326,10 +428,25 @@ void CSMSettings::UserSettings::saveDefinitions() const QString CSMSettings::UserSettings::settingValue (const QString &settingKey) { - if (!mSettingDefinitions->contains (settingKey)) - return QString(); + QStringList defs; - QStringList defs = mSettingDefinitions->value (settingKey).toStringList(); + // check if video settings are overriden + if(settingKey.contains(QRegExp("^\\b(Video)", Qt::CaseInsensitive)) && + mSettingDefinitions->value("Video/override settings.cfg") == "true") + { + std::cout << "user settings: override " << std::endl; // FIXME: debug + if (!mSettingCfgDefinitions->contains (settingKey)) + return QString(); + else + defs = mSettingCfgDefinitions->value (settingKey).toStringList(); + } + else + { + if (!mSettingDefinitions->contains (settingKey)) + return QString(); + + defs = mSettingDefinitions->value (settingKey).toStringList(); + } if (defs.isEmpty()) return QString(); @@ -387,7 +504,6 @@ void CSMSettings::UserSettings::removeSetting } } - CSMSettings::SettingPageMap CSMSettings::UserSettings::settingPageMap() const { SettingPageMap pageMap; diff --git a/apps/opencs/model/settings/usersettings.hpp b/apps/opencs/model/settings/usersettings.hpp index 7e553caf6..9d9b5c9b0 100644 --- a/apps/opencs/model/settings/usersettings.hpp +++ b/apps/opencs/model/settings/usersettings.hpp @@ -33,6 +33,7 @@ namespace CSMSettings { const Files::ConfigurationManager& mCfgMgr; QSettings *mSettingDefinitions; + QSettings *mSettingCfgDefinitions; QList mSettings; public: From e4b836608cdeaf461a8bfd461e9d17164af97ac4 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 14 Sep 2014 14:04:47 +1000 Subject: [PATCH 02/48] Partially address feature #854 by reading the status bar setting from opencs.ini. Missing GUI update that will affect new top level windows. --- apps/opencs/view/doc/view.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index cf5148391..0ba9f80f7 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -98,6 +98,10 @@ void CSVDoc::View::setupViewMenu() mShowStatusBar = new QAction (tr ("Show Status Bar"), this); mShowStatusBar->setCheckable (true); connect (mShowStatusBar, SIGNAL (toggled (bool)), this, SLOT (toggleShowStatusBar (bool))); + std::string showStatusBar = + CSMSettings::UserSettings::instance().settingValue("Display/show statusbar").toStdString(); + if(showStatusBar == "true") + mShowStatusBar->setChecked(true); view->addAction (mShowStatusBar); QAction *filters = new QAction (tr ("Filters"), this); @@ -650,4 +654,4 @@ void CSVDoc::View::run (const std::string& profile, const std::string& startupIn void CSVDoc::View::stop() { mDocument->stopRunning(); -} \ No newline at end of file +} From ecb4154ac016b67e0289e16759fd2e21d42968fa Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 15 Sep 2014 19:33:38 +1000 Subject: [PATCH 03/48] Fixed default settings logic and cleaned up comments. --- apps/opencs/model/settings/usersettings.cpp | 73 +++------------------ 1 file changed, 8 insertions(+), 65 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index be0e3ab26..6ccc9ddb0 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -29,54 +29,6 @@ namespace boost } /* namespace boost */ #endif /* (BOOST_VERSION <= 104600) */ -/* - * FIXME: temporary notes - * - * - CSVSettings::Dialog::Dialog is the settings window - * - provide a hard coded default if not found in config file - * - provide tooltips - * - save/cancel option (or auto-save?) - * - opencs.ini: where all these settings are saved - * . error if can't create file (directory permissions) or save file (file permissions) - * - settings.cfg: where Graphics default settings come from (read only) - * . warning if neither default or user cfg not found or not readable (file permissions) - * - openmw.cfg: not used - * - * - Tabbed view similar to OpenMW or Launcher - * . Video Settings - * . Display Settngs - * . Misc Settings - * - * - Video settings: tick box for "Use the video settings from OpenMW" (default, - * individual settings greyed out) - * . CS::Editor::setupGraphics() - * . the defaults should be the initial setting when unticked, unless previous user - * settings were found - * # OpenGL/Direct3D9 Rendering Subsystem - * # Vsync - * # FSAA (antialiasing) - * # GLSL/CG shader language - * . other shiny options - * . screen number - * # full screen / windowed (resolution) <- replace already existing - * - * - Display Settings - * . text only / icon + text <- replace already existing - * . limit the number of subviews per top level view - * . option to reuse subviews - * . v/w/dialoguesubview min width 325 - * . filter pattern syntax - * - * - misc - * . v/r/scenewidget mFastFactor(4) - * . v/r/scenewidget far clip distance - * . v/r/scenewidget start timer 20 - * . v/r/scenewidget shortcut - * . v/d/adjusterwidget error - * . v/r/navigation factor /= 2 - * . v/w/table redirect extended action - */ - CSMSettings::UserSettings *CSMSettings::UserSettings::mUserSettingsInstance = 0; CSMSettings::UserSettings::UserSettings (const Files::ConfigurationManager& configurationManager) @@ -88,7 +40,7 @@ CSMSettings::UserSettings::UserSettings (const Files::ConfigurationManager& conf mUserSettingsInstance = this; buildSettingModelDefaults(); - mSettingCfgDefinitions = new QSettings(QSettings::IniFormat, QSettings::UserScope, ""); + mSettingCfgDefinitions = new QSettings(QSettings::IniFormat, QSettings::UserScope, "", QString(), this); } void CSMSettings::UserSettings::buildSettingModelDefaults() @@ -328,8 +280,6 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() CSMSettings::UserSettings::~UserSettings() { - delete mSettingDefinitions; - delete mSettingCfgDefinitions; mUserSettingsInstance = 0; } @@ -360,15 +310,7 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName) mSettingDefinitions = new QSettings (QSettings::IniFormat, QSettings::UserScope, "opencs", QString(), this); - // if user setting (opencs.ini) exists - // if readable, then check whether the option to use settings.cfg video settings should be used is set - // use the config settings from settings.cfg - // else if video config found - // use the config settings from opencs.ini - // if any of the config option is not found, use hard coded default in this file - // - - // Create the settings manager and load default settings file + // prepare to use the settings from settings.cfg const std::string localdefault = mCfgMgr.getLocalPath().string() + "/settings-default.cfg"; const std::string globaldefault = mCfgMgr.getGlobalPath().string() + "/settings-default.cfg"; @@ -391,8 +333,6 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName) settings.loadUser(globaldefault); std::string renderSystem = settings.getString("render system", "Video"); - std::cout << "user settings: render system " + renderSystem << std::endl; // FIXME: debug - if(renderSystem == "") { #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 @@ -402,11 +342,15 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName) #endif } mSettingCfgDefinitions->setValue("Video/render system", renderSystem.c_str()); - // Force shiny language based on render system + // force shiny language based on render system if(renderSystem == "Direct3D9 Rendering Subsystem") mSettingDefinitions->setValue("Shiny/language", "CG"); else mSettingDefinitions->setValue("Shiny/language", "GLSL"); + + // check if override entry exists (default: override) + if(!mSettingDefinitions->childGroups().contains("Video", Qt::CaseInsensitive)) + mSettingDefinitions->setValue("Video/use settings.cfg", "true"); } bool CSMSettings::UserSettings::hasSettingDefinitions @@ -432,9 +376,8 @@ QString CSMSettings::UserSettings::settingValue (const QString &settingKey) // check if video settings are overriden if(settingKey.contains(QRegExp("^\\b(Video)", Qt::CaseInsensitive)) && - mSettingDefinitions->value("Video/override settings.cfg") == "true") + mSettingDefinitions->value("Video/use settings.cfg") == "true") { - std::cout << "user settings: override " << std::endl; // FIXME: debug if (!mSettingCfgDefinitions->contains (settingKey)) return QString(); else From ffaca7a8754c5540782554ec87337c6f277180a7 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 16 Sep 2014 07:44:07 +1000 Subject: [PATCH 04/48] GUI added, but not yet functional. --- apps/opencs/CMakeLists.txt | 3 +- apps/opencs/editor.cpp | 4 +- apps/opencs/editor.hpp | 4 +- apps/opencs/model/settings/usersettings.cpp | 2 + apps/opencs/view/settings/settingsdialog.cpp | 126 +++++++ apps/opencs/view/settings/settingsdialog.hpp | 56 +++ apps/opencs/view/settings/settingwindow.cpp | 2 +- apps/opencs/view/settings/settingwindow.hpp | 2 +- files/ui/settingstab.ui | 343 +++++++++++++++++++ 9 files changed, 535 insertions(+), 7 deletions(-) create mode 100644 apps/opencs/view/settings/settingsdialog.cpp create mode 100644 apps/opencs/view/settings/settingsdialog.hpp create mode 100644 files/ui/settingstab.ui diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 7094f8799..be536535e 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -99,7 +99,7 @@ opencs_units_noqt (view/tools opencs_units (view/settings settingwindow - dialog + settingsdialog page view booleanview @@ -142,6 +142,7 @@ 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 d3e5c6720..1887629f9 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -28,7 +28,7 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit) setupDataFiles (config.first); CSMSettings::UserSettings::instance().loadSettings ("opencs.ini"); - mSettings.setModel (CSMSettings::UserSettings::instance()); + //mSettings.setModel (CSMSettings::UserSettings::instance()); ogreInit.init ((mCfgMgr.getUserConfigPath() / "opencsOgre.log").string()); @@ -189,7 +189,7 @@ void CS::Editor::createNewFile (const boost::filesystem::path &savePath) files.push_back(path.toUtf8().constData()); } - files.push_back(mFileDialog.filename().toUtf8().constData()); + files.push_back (savePath); mDocumentManager.addDocument (files, savePath, true); diff --git a/apps/opencs/editor.hpp b/apps/opencs/editor.hpp index c87e24e77..4ccc61a02 100644 --- a/apps/opencs/editor.hpp +++ b/apps/opencs/editor.hpp @@ -26,7 +26,7 @@ #include "view/doc/filedialog.hpp" #include "view/doc/newgame.hpp" -#include "view/settings/dialog.hpp" +#include "view/settings/settingsdialog.hpp" namespace OgreInit { @@ -46,7 +46,7 @@ namespace CS CSVDoc::ViewManager mViewManager; CSVDoc::StartupDialogue mStartup; CSVDoc::NewGameDialogue mNewGame; - CSVSettings::Dialog mSettings; + CSVSettings::SettingsDialog mSettings; CSVDoc::FileDialog mFileDialog; boost::filesystem::path mLocal; boost::filesystem::path mResources; diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 6ccc9ddb0..e655a66a3 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -40,6 +40,8 @@ CSMSettings::UserSettings::UserSettings (const Files::ConfigurationManager& conf mUserSettingsInstance = this; buildSettingModelDefaults(); + + // for overriding opencs.ini settings with those from settings.cfg mSettingCfgDefinitions = new QSettings(QSettings::IniFormat, QSettings::UserScope, "", QString(), this); } diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp new file mode 100644 index 000000000..db7b49a54 --- /dev/null +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -0,0 +1,126 @@ +#include "settingsdialog.hpp" + +#include +#include +#include +#include +#include + +#include "../../model/settings/usersettings.hpp" + +#include "page.hpp" + +#include + +#include + +#include +#include +#include + +#include +#include + +CSVSettings::SettingsDialog::SettingsDialog(QMainWindow *parent) + : /*mStackedWidget (0),*/ mDebugMode (false), SettingWindow (parent) +{ + setWindowTitle(QString::fromUtf8 ("User Settings")); + + setupUi(this); + + //setupDialog(); + + //connect (mPageListWidget, + //SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)), + //this, + //SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*))); +} + +void CSVSettings::SettingsDialog::slotChangePage + (QListWidgetItem *cur, QListWidgetItem *prev) +{ + //mStackedWidget->changePage + //(mPageListWidget->row (cur), mPageListWidget->row (prev)); + + layout()->activate(); + setFixedSize(minimumSizeHint()); +} + +void CSVSettings::SettingsDialog::setupDialog() +{ + //create central widget with it's layout and immediate children + QWidget *centralWidget = new QGroupBox (this); + + centralWidget->setLayout (new QHBoxLayout()); + centralWidget->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Preferred); + //setCentralWidget (centralWidget); + //setDockOptions (QMainWindow::AllowNestedDocks); + + buildPageListWidget (centralWidget); + buildStackedWidget (centralWidget); +} + +void CSVSettings::SettingsDialog::buildPages() +{ + SettingWindow::createPages (); +#if 0 + + QFontMetrics fm (QApplication::font()); + + foreach (Page *page, SettingWindow::pages()) + { + QString pageName = page->objectName(); + + //int textWidth = fm.width(pageName); + + //new QListWidgetItem (pageName, mPageListWidget); + //mPageListWidget->setFixedWidth (textWidth + 50); + + //mStackedWidget->addWidget (&dynamic_cast(*(page))); + } + + //resize (mStackedWidget->sizeHint()); +#endif +} + +void CSVSettings::SettingsDialog::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::SettingsDialog::buildStackedWidget (QWidget *centralWidget) +{ + //mStackedWidget = new ResizeableStackedWidget (centralWidget); + + //centralWidget->layout()->addWidget (mStackedWidget); +} + +void CSVSettings::SettingsDialog::closeEvent (QCloseEvent *event) +{ + //SettingWindow::closeEvent() must be called first to ensure + //model is updated + //SettingWindow::closeEvent (event); + + //saveSettings(); +} + +void CSVSettings::SettingsDialog::show() +{ + //if (pages().isEmpty()) + { + //buildPages(); + //setViewValues(); + } + //if( + + QPoint screenCenter = QApplication::desktop()->screenGeometry().center(); + + move (screenCenter - geometry().center()); + QWidget::show(); +} diff --git a/apps/opencs/view/settings/settingsdialog.hpp b/apps/opencs/view/settings/settingsdialog.hpp new file mode 100644 index 000000000..e9bd2d043 --- /dev/null +++ b/apps/opencs/view/settings/settingsdialog.hpp @@ -0,0 +1,56 @@ +#ifndef CSVSETTINGS_SETTINGSDIALOG_H +#define CSVSETTINGS_SETTINGSDIALOG_H + +#include "settingwindow.hpp" +//#include "resizeablestackedwidget.hpp" +#include + +#include "ui_settingstab.h" + +//class QStackedWidget; +//class QListWidget; +class QListWidgetItem; + +namespace CSVSettings { + + //class Page; + + class SettingsDialog : public SettingWindow, private Ui::TabWidget + { + Q_OBJECT + + //QListWidget *mPageListWidget; + //ResizeableStackedWidget *mStackedWidget; + bool mDebugMode; + + public: + + /*explicit*/ SettingsDialog (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. + void enableDebugMode (bool state, QStandardItemModel *model = 0); + + protected: + + /// Settings are written on close + void closeEvent (QCloseEvent *event); + + void setupDialog(); + + private: + + void buildPages(); + void buildPageListWidget (QWidget *centralWidget); + void buildStackedWidget (QWidget *centralWidget); + + public slots: + + void show(); + + private slots: + + void slotChangePage (QListWidgetItem *, QListWidgetItem *); + }; +} +#endif // CSVSETTINGS_SETTINGSDIALOG_H diff --git a/apps/opencs/view/settings/settingwindow.cpp b/apps/opencs/view/settings/settingwindow.cpp index 7cdf2bded..c70418553 100644 --- a/apps/opencs/view/settings/settingwindow.cpp +++ b/apps/opencs/view/settings/settingwindow.cpp @@ -9,7 +9,7 @@ #include "view.hpp" CSVSettings::SettingWindow::SettingWindow(QWidget *parent) - : QMainWindow(parent) + : QTabWidget(parent) {} void CSVSettings::SettingWindow::createPages() diff --git a/apps/opencs/view/settings/settingwindow.hpp b/apps/opencs/view/settings/settingwindow.hpp index 2266f130d..b1f55d67f 100644 --- a/apps/opencs/view/settings/settingwindow.hpp +++ b/apps/opencs/view/settings/settingwindow.hpp @@ -18,7 +18,7 @@ namespace CSVSettings { typedef QList PageList; - class SettingWindow : public QMainWindow + class SettingWindow : public QTabWidget { Q_OBJECT diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui new file mode 100644 index 000000000..620e8d0c5 --- /dev/null +++ b/files/ui/settingstab.ui @@ -0,0 +1,343 @@ + + + TabWidget + + + + 0 + 0 + 400 + 300 + + + + User Settings + + + 0 + + + + Video Settings + + + + + 20 + 181 + 351 + 71 + + + + + + + Standard: + + + true + + + buttonGroup + + + + + + + Resolution + + + + + + + Full Screen + + + + + + + Custom; + + + buttonGroup + + + + + + + + 180 + 0 + + + + + + + + + 186 + 16777215 + + + + + + + + + + + + + 10 + 8 + 371 + 153 + + + + Render System + + + + + + 10 + 165 + 371 + 99 + + + + Display + + + + + + 21 + 26 + 351 + 125 + + + + + + + + 0 + 22 + + + + Use Render System Settings from OpenMW + + + true + + + + + + + Rendering Subsystem + + + + + + + false + + + + OpenGL Rendering Subsystem + + + + + Direct3D9 Rendering Subsystem + + + + + + + + Vertical Sync + + + + + + + Antialiasing + + + + + + + + Off + + + + + MSAA 2 + + + + + MSAA 4 + + + + + MSAA 8 + + + + + MSAA 8 (Quality) + + + + + + + + Shader Language + + + + + + + + HLSL + + + + + CG + + + + + + + renderGroup + layoutWidget + displayGroup + layoutWidget_Screen + + + + Display Settings + + + + + 20 + 30 + 351 + 116 + + + + + + + Max Number of Subviews + + + + + + + Min Subview Width + + + + + + + Reuse Subviews + + + + + + + + Text Only + + + + + Text + Icon + + + + + + + + + + + 325 + + + 20000 + + + 5 + + + + + + + Show Icon + + + + + + + + + 10 + 10 + 371 + 151 + + + + GroupBox + + + groupBox + layoutWidget2 + + + + Misc Settings + + + + + + + + + From d679e0e0126c31fa77946e9480942a7782051334 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 16 Sep 2014 19:50:25 +1000 Subject: [PATCH 05/48] Made more progress. Grey out disabled settings. --- apps/opencs/CMakeLists.txt | 2 - apps/opencs/editor.cpp | 4 +- apps/opencs/model/settings/usersettings.cpp | 5 +- apps/opencs/view/settings/settingsdialog.cpp | 214 ++++++++++++++++++- apps/opencs/view/settings/settingsdialog.hpp | 12 +- apps/opencs/view/settings/settingwindow.cpp | 2 +- apps/opencs/view/settings/settingwindow.hpp | 2 +- files/ui/settingstab.ui | 123 ++++++----- 8 files changed, 296 insertions(+), 68 deletions(-) diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index be536535e..a58c1a614 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -98,9 +98,7 @@ opencs_units_noqt (view/tools ) opencs_units (view/settings - settingwindow settingsdialog - page view booleanview textview diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 1887629f9..77921a335 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -283,8 +283,10 @@ std::auto_ptr CS::Editor::setupGraphics() #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE params.insert(std::make_pair("macAPI", "cocoa")); #endif + // FIXME: don't apply the fullscreen here, apply to the editor window bool fullscreen = mUserSettings.settingValue("Video/fullscreen").toStdString() == "true" ? true : false; - Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, fullscreen, ¶ms); + //Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, fullscreen, ¶ms); + Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, false, ¶ms); hiddenWindow->setActive(false); sh::OgrePlatform* platform = diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index e655a66a3..cd9bf6a33 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -377,8 +377,9 @@ QString CSMSettings::UserSettings::settingValue (const QString &settingKey) QStringList defs; // check if video settings are overriden - if(settingKey.contains(QRegExp("^\\b(Video)", Qt::CaseInsensitive)) && - mSettingDefinitions->value("Video/use settings.cfg") == "true") + if(settingKey.contains(QRegExp("^Video\\b", Qt::CaseInsensitive)) && + mSettingDefinitions->value("Video/use settings.cfg") == "true" && + settingKey.contains(QRegExp("^Video/\\brender|antialiasing|vsync|fullscreen\\b", Qt::CaseInsensitive))) { if (!mSettingCfgDefinitions->contains (settingKey)) return QString(); diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index db7b49a54..973a60e2c 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -8,6 +8,8 @@ #include "../../model/settings/usersettings.hpp" +//#include "ui_settingstab.h" + #include "page.hpp" #include @@ -20,15 +22,157 @@ #include #include +#include + +#include +#include +//#include +#include + +namespace +{ +// copied from launcher +QString getAspect(int x, int y) +{ + 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"); + + return QString(QString::number(xaspect) + ":" + QString::number(yaspect)); +} + +QRect getMaximumResolution() +{ + 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; +} + +QString getCurrentResolution() +{ + QString 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" ) + { + QRegExp re("^(\\d+) x (\\d+)"); + int pos = re.indexIn(it->second.currentValue.c_str(), 0); + if (pos > -1) + { + QString aspect = getAspect(re.cap(1).toInt(), re.cap(2).toInt()); + result = re.cap(1) + QString(" x ") + re.cap(2); + if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) + { + //result.append(QObject::tr("\t(Wide ") + aspect + ")"); + + } + else if (aspect == QLatin1String("4:3")) + { + //result.append(QObject::tr("\t(Standard 4:3)")); + } + } + } + } + return result; +} -CSVSettings::SettingsDialog::SettingsDialog(QMainWindow *parent) - : /*mStackedWidget (0),*/ mDebugMode (false), SettingWindow (parent) +QStringList getAvailableResolutions() { - setWindowTitle(QString::fromUtf8 ("User Settings")); + // 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 == "Rendering Device" ) + { + if(it->second.possibleValues.empty()) + { + QMessageBox msgBox; + msgBox.setWindowTitle(QObject::tr("Error retrieving rendering device")); + msgBox.setIcon(QMessageBox::Critical); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setText(QObject::tr("
Ogre Rendering Device empty<./b>

")); + msgBox.exec(); + return result; + } + //std::cout << "rd current: " << it->second.currentValue << std::endl; // FIXME: debug + // Store Available Rendering Devices + std::vector::iterator iter = it->second.possibleValues.begin(); + for(;iter != it->second.possibleValues.end(); ++iter) + { + std::cout << "rd: " << *iter << std::endl; // FIXME: debug + } + } + if(it->first == "Video Mode" ) + { + if(it->second.possibleValues.empty()) + { + QMessageBox msgBox; + msgBox.setWindowTitle(QObject::tr("Error receiving resolutions")); + msgBox.setIcon(QMessageBox::Critical); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setText(QObject::tr("
Ogre Video Modes empty.

")); + msgBox.exec(); + return result; + } + // FIXME: how to default to the current value? + std::cout << "vm current: " << it->second.currentValue << std::endl; // FIXME: debug + // Store Available Resolutions + std::vector::iterator iter = it->second.possibleValues.begin(); + for(;iter != it->second.possibleValues.end(); ++iter) + { + // extract x and y values + QRegExp re("^(\\d+) x (\\d+)"); + int pos = re.indexIn((*iter).c_str(), 0); + if (pos > -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(); + return result; +} + +} + +CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) + : /*mStackedWidget (0), mDebugMode (false),*/ QTabWidget (parent) +{ + setObjectName("User Settings"); setupUi(this); - //setupDialog(); + // Set the maximum res we can set in windowed mode + QRect res = getMaximumResolution(); + spinBox_x->setMaximum(res.width()); + spinBox_y->setMaximum(res.height()); //connect (mPageListWidget, //SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)), @@ -36,6 +180,7 @@ CSVSettings::SettingsDialog::SettingsDialog(QMainWindow *parent) //SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*))); } +// FIXME: don't need this one, as we don't use pages void CSVSettings::SettingsDialog::slotChangePage (QListWidgetItem *cur, QListWidgetItem *prev) { @@ -46,6 +191,7 @@ void CSVSettings::SettingsDialog::slotChangePage setFixedSize(minimumSizeHint()); } +// FIXME: don't need this one since we use setupUi void CSVSettings::SettingsDialog::setupDialog() { //create central widget with it's layout and immediate children @@ -62,8 +208,8 @@ void CSVSettings::SettingsDialog::setupDialog() void CSVSettings::SettingsDialog::buildPages() { - SettingWindow::createPages (); #if 0 + SettingWindow::createPages (); QFontMetrics fm (QApplication::font()); @@ -117,10 +263,62 @@ void CSVSettings::SettingsDialog::show() //buildPages(); //setViewValues(); } - //if( - QPoint screenCenter = QApplication::desktop()->screenGeometry().center(); + if(CSMSettings::UserSettings::instance().settingValue("Video/use settings.cfg").toStdString() == "true") + { + label_RenderingSubsystem->setEnabled(false); + comboBox_rendersystem->setEnabled(false); + label_Antialiasing->setEnabled(false); + comboBox_antialiasing->setEnabled(false); + checkBox_vsync->setEnabled(false); + label_ShaderLanguage->setEnabled(false); + comboBox_shaderlanguage->setEnabled(false); + + } + else + checkBox_override->setChecked(false); - move (screenCenter - geometry().center()); + if(CSMSettings::UserSettings::instance().settingValue("Video/fullscreen").toStdString() == "true") + { + checkBox_fullscreen->setChecked(true); + + label_Resolution->setEnabled(false); + radioButton_standard_res->setEnabled(false); + radioButton_custom_res->setEnabled(false); + comboBox_std_window_size->setEnabled(false); + spinBox_x->setEnabled(false); + spinBox_y->setEnabled(false); + } + else + { + checkBox_fullscreen->setChecked(false); + } + + // update display resolution combo box + // FIXME: update opencs window size + comboBox_std_window_size->clear(); + comboBox_std_window_size->addItems(getAvailableResolutions()); + int index = comboBox_std_window_size->findData(getCurrentResolution(), + Qt::DisplayRole, + Qt::MatchStartsWith); + if(index != -1) + comboBox_std_window_size->setCurrentIndex(index); + + // place the widget and make it visible + 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)); + } QWidget::show(); } diff --git a/apps/opencs/view/settings/settingsdialog.hpp b/apps/opencs/view/settings/settingsdialog.hpp index e9bd2d043..2d16efe34 100644 --- a/apps/opencs/view/settings/settingsdialog.hpp +++ b/apps/opencs/view/settings/settingsdialog.hpp @@ -1,7 +1,7 @@ #ifndef CSVSETTINGS_SETTINGSDIALOG_H #define CSVSETTINGS_SETTINGSDIALOG_H -#include "settingwindow.hpp" +//#include "settingwindow.hpp" //#include "resizeablestackedwidget.hpp" #include @@ -11,11 +11,17 @@ //class QListWidget; class QListWidgetItem; +#if 0 +namespace Ui { + class TabWidget; +} +#endif + namespace CSVSettings { //class Page; - class SettingsDialog : public SettingWindow, private Ui::TabWidget + class SettingsDialog : public QTabWidget, private Ui::TabWidget { Q_OBJECT @@ -25,7 +31,7 @@ namespace CSVSettings { public: - /*explicit*/ SettingsDialog (QMainWindow *parent = 0); + /*explicit*/ SettingsDialog (QTabWidget *parent = 0); ///Enables setting debug mode. When the dialog opens, a page is created ///which displays the SettingModel's contents in a Tree view. diff --git a/apps/opencs/view/settings/settingwindow.cpp b/apps/opencs/view/settings/settingwindow.cpp index c70418553..7cdf2bded 100644 --- a/apps/opencs/view/settings/settingwindow.cpp +++ b/apps/opencs/view/settings/settingwindow.cpp @@ -9,7 +9,7 @@ #include "view.hpp" CSVSettings::SettingWindow::SettingWindow(QWidget *parent) - : QTabWidget(parent) + : QMainWindow(parent) {} void CSVSettings::SettingWindow::createPages() diff --git a/apps/opencs/view/settings/settingwindow.hpp b/apps/opencs/view/settings/settingwindow.hpp index b1f55d67f..2266f130d 100644 --- a/apps/opencs/view/settings/settingwindow.hpp +++ b/apps/opencs/view/settings/settingwindow.hpp @@ -18,7 +18,7 @@ namespace CSVSettings { typedef QList PageList; - class SettingWindow : public QTabWidget + class SettingWindow : public QMainWindow { Q_OBJECT diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 620e8d0c5..b75db685f 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -7,7 +7,7 @@ 0 0 400 - 300 + 313 @@ -24,13 +24,13 @@ 20 - 181 + 188 351 - 71 + 81 - + Standard: @@ -43,7 +43,7 @@ - + Resolution @@ -57,7 +57,7 @@ - + Custom; @@ -67,7 +67,20 @@ - + + + + + 186 + 16777215 + + + + + + + + @@ -77,19 +90,19 @@ - - + + - 186 - 16777215 + 16777215 + 2 + + Qt::Horizontal + - - - @@ -98,7 +111,7 @@ 10 8 371 - 153 + 156 @@ -109,9 +122,9 @@ 10 - 165 + 170 371 - 99 + 108 @@ -121,21 +134,15 @@ - 21 + 20 26 351 - 125 + 129 - - - 0 - 22 - - Use Render System Settings from OpenMW @@ -144,14 +151,14 @@ - + Rendering Subsystem - + false @@ -168,21 +175,42 @@ - + + + + Antialiasing + + + + Vertical Sync - - + + - Antialiasing + Shader Language - + + + + + HLSL + + + + + CG + + + + + @@ -211,25 +239,20 @@ - - - - Shader Language + + + + + 16777215 + 2 + + + + color: rgb(215, 215, 215); + + + Qt::Horizontal - - - - - - - HLSL - - - - - CG - - From e3da37567b998ed25ab019e316c889699b5a29e2 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 17 Sep 2014 06:11:41 +1000 Subject: [PATCH 06/48] Cleaned up and got some signals going. --- apps/opencs/editor.cpp | 2 +- apps/opencs/view/settings/settingsdialog.cpp | 272 +++++++++---------- apps/opencs/view/settings/settingsdialog.hpp | 36 +-- files/ui/settingstab.ui | 25 -- 4 files changed, 134 insertions(+), 201 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 77921a335..1c54062d8 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -284,7 +284,7 @@ std::auto_ptr CS::Editor::setupGraphics() params.insert(std::make_pair("macAPI", "cocoa")); #endif // FIXME: don't apply the fullscreen here, apply to the editor window - bool fullscreen = mUserSettings.settingValue("Video/fullscreen").toStdString() == "true" ? true : false; + //bool fullscreen = mUserSettings.settingValue("Video/fullscreen").toStdString() == "true" ? true : false; //Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, fullscreen, ¶ms); Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, false, ¶ms); hiddenWindow->setActive(false); diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index 973a60e2c..9162aa449 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -1,37 +1,17 @@ #include "settingsdialog.hpp" -#include -#include -#include -#include -#include - -#include "../../model/settings/usersettings.hpp" - -//#include "ui_settingstab.h" - -#include "page.hpp" - -#include - -#include - -#include -#include -#include - -#include -#include +#include #include -#include -#include -//#include #include +#include +#include "../../model/settings/usersettings.hpp" + namespace { -// copied from launcher +// copied from the launcher & adapted + QString getAspect(int x, int y) { int gcd = boost::math::gcd (x, y); @@ -61,34 +41,20 @@ QRect getMaximumResolution() QString getCurrentResolution() { - QString result; - Ogre::ConfigOptionMap& renderOpt = Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); - for(;it != renderOpt.end(); ++it) + for(; it != renderOpt.end(); ++it) { if(it->first == "Video Mode" ) { - QRegExp re("^(\\d+) x (\\d+)"); + QRegExp re("^(\\d+ x \\d+)"); int pos = re.indexIn(it->second.currentValue.c_str(), 0); if (pos > -1) - { - QString aspect = getAspect(re.cap(1).toInt(), re.cap(2).toInt()); - result = re.cap(1) + QString(" x ") + re.cap(2); - if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) - { - //result.append(QObject::tr("\t(Wide ") + aspect + ")"); - - } - else if (aspect == QLatin1String("4:3")) - { - //result.append(QObject::tr("\t(Standard 4:3)")); - } - } + return re.cap(1); } } - return result; + return QString(); // found nothing } QStringList getAvailableResolutions() @@ -104,15 +70,8 @@ QStringList getAvailableResolutions() { if(it->second.possibleValues.empty()) { - QMessageBox msgBox; - msgBox.setWindowTitle(QObject::tr("Error retrieving rendering device")); - msgBox.setIcon(QMessageBox::Critical); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setText(QObject::tr("
Ogre Rendering Device empty<./b>

")); - msgBox.exec(); - return result; + return result; // FIXME: add error message } - //std::cout << "rd current: " << it->second.currentValue << std::endl; // FIXME: debug // Store Available Rendering Devices std::vector::iterator iter = it->second.possibleValues.begin(); for(;iter != it->second.possibleValues.end(); ++iter) @@ -124,19 +83,13 @@ QStringList getAvailableResolutions() { if(it->second.possibleValues.empty()) { - QMessageBox msgBox; - msgBox.setWindowTitle(QObject::tr("Error receiving resolutions")); - msgBox.setIcon(QMessageBox::Critical); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setText(QObject::tr("
Ogre Video Modes empty.

")); - msgBox.exec(); - return result; + return result; // FIXME: add error message } // FIXME: how to default to the current value? std::cout << "vm current: " << it->second.currentValue << std::endl; // FIXME: debug // Store Available Resolutions std::vector::iterator iter = it->second.possibleValues.begin(); - for(;iter != it->second.possibleValues.end(); ++iter) + for(; iter != it->second.possibleValues.end(); ++iter) { // extract x and y values QRegExp re("^(\\d+) x (\\d+)"); @@ -160,111 +113,111 @@ QStringList getAvailableResolutions() return result; } -} - -CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) - : /*mStackedWidget (0), mDebugMode (false),*/ QTabWidget (parent) +QStringList getAvailableOptions(const QString &key) { - setObjectName("User Settings"); + QStringList result; - setupUi(this); + Ogre::ConfigOptionMap& renderOpt = + Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); + Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); - // Set the maximum res we can set in windowed mode - QRect res = getMaximumResolution(); - spinBox_x->setMaximum(res.width()); - spinBox_y->setMaximum(res.height()); + uint row = 0; + for(; it != renderOpt.end(); ++it, ++row) + { + Ogre::StringVector::iterator opt_it = it->second.possibleValues.begin(); + uint idx = 0; - //connect (mPageListWidget, - //SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)), - //this, - //SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*))); -} + for(; opt_it != it->second.possibleValues.end(); ++opt_it, ++idx) + { + if(strcmp (key.toStdString().c_str(), it->first.c_str()) == 0) + { + result << ((key == "FSAA") ? QString("MSAA ") : QString("")) + + QString::fromStdString((*opt_it).c_str()).simplified(); + } + } + } -// FIXME: don't need this one, as we don't use pages -void CSVSettings::SettingsDialog::slotChangePage - (QListWidgetItem *cur, QListWidgetItem *prev) -{ - //mStackedWidget->changePage - //(mPageListWidget->row (cur), mPageListWidget->row (prev)); + // Sort ascending + qSort(result.begin(), result.end(), naturalSortLessThanCI); - layout()->activate(); - setFixedSize(minimumSizeHint()); -} + // Replace the zero option with Off + int index = result.indexOf("MSAA 0"); -// FIXME: don't need this one since we use setupUi -void CSVSettings::SettingsDialog::setupDialog() -{ - //create central widget with it's layout and immediate children - QWidget *centralWidget = new QGroupBox (this); + if(index != -1) + result.replace(index, QObject::tr("Off")); - centralWidget->setLayout (new QHBoxLayout()); - centralWidget->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Preferred); - //setCentralWidget (centralWidget); - //setDockOptions (QMainWindow::AllowNestedDocks); + return result; +} - buildPageListWidget (centralWidget); - buildStackedWidget (centralWidget); } -void CSVSettings::SettingsDialog::buildPages() +CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) + : /*mDebugMode (false),*/ QTabWidget (parent) { -#if 0 - SettingWindow::createPages (); - - QFontMetrics fm (QApplication::font()); - - foreach (Page *page, SettingWindow::pages()) - { - QString pageName = page->objectName(); - - //int textWidth = fm.width(pageName); + setObjectName("User Settings"); - //new QListWidgetItem (pageName, mPageListWidget); - //mPageListWidget->setFixedWidth (textWidth + 50); + setupUi(this); - //mStackedWidget->addWidget (&dynamic_cast(*(page))); - } + // Set the maximum res we can set in windowed mode + QRect res = getMaximumResolution(); + spinBox_x->setMaximum(res.width()); + spinBox_y->setMaximum(res.height()); - //resize (mStackedWidget->sizeHint()); -#endif + connect(comboBox_rendersystem, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged(const QString&))); + connect(checkBox_fullscreen, SIGNAL(stateChanged(int)), this, SLOT(slotFullScreenChanged(int))); + connect(radioButton_standard_res, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); } -void CSVSettings::SettingsDialog::buildPageListWidget (QWidget *centralWidget) +void CSVSettings::SettingsDialog::rendererChanged() { - //mPageListWidget = new QListWidget (centralWidget); - //mPageListWidget->setMinimumWidth(50); - //mPageListWidget->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Expanding); - - //mPageListWidget->setSelectionBehavior (QAbstractItemView::SelectItems); - - //centralWidget->layout()->addWidget(mPageListWidget); + comboBox_antialiasing->clear(); + comboBox_antialiasing->addItems(getAvailableOptions(QString("FSAA"))); } -void CSVSettings::SettingsDialog::buildStackedWidget (QWidget *centralWidget) +void CSVSettings::SettingsDialog::slotFullScreenChanged(int state) { - //mStackedWidget = new ResizeableStackedWidget (centralWidget); - - //centralWidget->layout()->addWidget (mStackedWidget); + if (state == Qt::Checked) { + label_Resolution->setEnabled(false); + radioButton_standard_res->setEnabled(false); + radioButton_custom_res->setEnabled(false); + comboBox_std_window_size->setEnabled(false); + spinBox_x->setEnabled(false); + spinBox_y->setEnabled(false); + } + else + { + label_Resolution->setEnabled(true); + radioButton_standard_res->setEnabled(true); + radioButton_custom_res->setEnabled(true); + comboBox_std_window_size->setEnabled(true); + spinBox_x->setEnabled(true); + spinBox_y->setEnabled(true); + } } -void CSVSettings::SettingsDialog::closeEvent (QCloseEvent *event) +// FIXME: what to do with updating window size +void CSVSettings::SettingsDialog::slotStandardToggled(bool checked) { - //SettingWindow::closeEvent() must be called first to ensure - //model is updated - //SettingWindow::closeEvent (event); - - //saveSettings(); + if (checked) + { + comboBox_std_window_size->setEnabled(true); + spinBox_x->setEnabled(false); + spinBox_y->setEnabled(false); + } + else + { + comboBox_std_window_size->setEnabled(false); + spinBox_x->setEnabled(true); + spinBox_y->setEnabled(true); + } } -void CSVSettings::SettingsDialog::show() +void CSVSettings::SettingsDialog::setViewValues() { - //if (pages().isEmpty()) - { - //buildPages(); - //setViewValues(); - } + //rendererChanged(Ogre::Root::getSingleton().getRenderSystemByName(renderer.toStdString())); + rendererChanged(); // setup antialiasing options - if(CSMSettings::UserSettings::instance().settingValue("Video/use settings.cfg").toStdString() == "true") + if(CSMSettings::UserSettings::instance().settingValue("Video/use settings.cfg") == "true") { label_RenderingSubsystem->setEnabled(false); comboBox_rendersystem->setEnabled(false); @@ -278,20 +231,16 @@ void CSVSettings::SettingsDialog::show() else checkBox_override->setChecked(false); - if(CSMSettings::UserSettings::instance().settingValue("Video/fullscreen").toStdString() == "true") + if(CSMSettings::UserSettings::instance().settingValue("Window Size/Width") != "") { - checkBox_fullscreen->setChecked(true); - - label_Resolution->setEnabled(false); - radioButton_standard_res->setEnabled(false); - radioButton_custom_res->setEnabled(false); - comboBox_std_window_size->setEnabled(false); - spinBox_x->setEnabled(false); - spinBox_y->setEnabled(false); + spinBox_x->setValue( + CSMSettings::UserSettings::instance().settingValue("Window Size/Width").toInt()); } - else + + if(CSMSettings::UserSettings::instance().settingValue("Window Size/Height") != "") { - checkBox_fullscreen->setChecked(false); + spinBox_y->setValue( + CSMSettings::UserSettings::instance().settingValue("Window Size/Height").toInt()); } // update display resolution combo box @@ -304,6 +253,33 @@ void CSVSettings::SettingsDialog::show() if(index != -1) comboBox_std_window_size->setCurrentIndex(index); + slotStandardToggled(radioButton_standard_res->isChecked() ? true : false); + + if(CSMSettings::UserSettings::instance().settingValue("Video/fullscreen") == "true") + { + checkBox_fullscreen->setChecked(true); + slotFullScreenChanged(Qt::Checked); + } + else + { + checkBox_fullscreen->setChecked(false); + slotFullScreenChanged(Qt::Unchecked); + } +} + +void CSVSettings::SettingsDialog::closeEvent (QCloseEvent *event) +{ + //SettingWindow::closeEvent() must be called first to ensure + //model is updated + //SettingWindow::closeEvent (event); + + //saveSettings(); +} + +void CSVSettings::SettingsDialog::show() +{ + setViewValues(); + // place the widget and make it visible QWidget *currView = QApplication::activeWindow(); if(currView) diff --git a/apps/opencs/view/settings/settingsdialog.hpp b/apps/opencs/view/settings/settingsdialog.hpp index 2d16efe34..8f80fbc12 100644 --- a/apps/opencs/view/settings/settingsdialog.hpp +++ b/apps/opencs/view/settings/settingsdialog.hpp @@ -1,62 +1,44 @@ #ifndef CSVSETTINGS_SETTINGSDIALOG_H #define CSVSETTINGS_SETTINGSDIALOG_H -//#include "settingwindow.hpp" -//#include "resizeablestackedwidget.hpp" #include #include "ui_settingstab.h" -//class QStackedWidget; -//class QListWidget; class QListWidgetItem; -#if 0 -namespace Ui { - class TabWidget; -} -#endif - namespace CSVSettings { - //class Page; - class SettingsDialog : public QTabWidget, private Ui::TabWidget { Q_OBJECT - //QListWidget *mPageListWidget; - //ResizeableStackedWidget *mStackedWidget; - bool mDebugMode; - public: - /*explicit*/ SettingsDialog (QTabWidget *parent = 0); + SettingsDialog (QTabWidget *parent = 0); + + int windowWidth(); + int windowHeight(); ///Enables setting debug mode. When the dialog opens, a page is created ///which displays the SettingModel's contents in a Tree view. - void enableDebugMode (bool state, QStandardItemModel *model = 0); + //void enableDebugMode (bool state, QStandardItemModel *model = 0); protected: /// Settings are written on close void closeEvent (QCloseEvent *event); - void setupDialog(); - private: - void buildPages(); - void buildPageListWidget (QWidget *centralWidget); - void buildStackedWidget (QWidget *centralWidget); + void setViewValues(); public slots: void show(); - - private slots: - - void slotChangePage (QListWidgetItem *, QListWidgetItem *); + void rendererChanged(); + void slotFullScreenChanged(int state); + void slotStandardToggled(bool checked); }; } #endif // CSVSETTINGS_SETTINGSDIALOG_H diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index b75db685f..8e69767f5 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -212,31 +212,6 @@
- - - Off - - - - - MSAA 2 - - - - - MSAA 4 - - - - - MSAA 8 - - - - - MSAA 8 (Quality) - - From cb15750e402327137273c0f57d13a5c2ff174cb5 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 17 Sep 2014 06:29:11 +1000 Subject: [PATCH 07/48] Removed fullscreen checkbox and associated code. Doesn't really make sense for opencs and a fullscreen windowed mode is just a click or keyboard shortcut away, anyway. --- apps/opencs/editor.cpp | 4 +- apps/opencs/view/settings/settingsdialog.cpp | 33 ---------- apps/opencs/view/settings/settingsdialog.hpp | 1 - files/ui/settingstab.ui | 67 +++++++------------- 4 files changed, 24 insertions(+), 81 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 1c54062d8..79e33e56b 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -283,9 +283,7 @@ std::auto_ptr CS::Editor::setupGraphics() #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE params.insert(std::make_pair("macAPI", "cocoa")); #endif - // FIXME: don't apply the fullscreen here, apply to the editor window - //bool fullscreen = mUserSettings.settingValue("Video/fullscreen").toStdString() == "true" ? true : false; - //Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, fullscreen, ¶ms); + // NOTE: fullscreen mode not supported (doesn't really make sense for opencs) Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, false, ¶ms); hiddenWindow->setActive(false); diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index 9162aa449..92447664f 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -164,7 +164,6 @@ CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) spinBox_y->setMaximum(res.height()); connect(comboBox_rendersystem, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged(const QString&))); - connect(checkBox_fullscreen, SIGNAL(stateChanged(int)), this, SLOT(slotFullScreenChanged(int))); connect(radioButton_standard_res, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); } @@ -174,27 +173,6 @@ void CSVSettings::SettingsDialog::rendererChanged() comboBox_antialiasing->addItems(getAvailableOptions(QString("FSAA"))); } -void CSVSettings::SettingsDialog::slotFullScreenChanged(int state) -{ - if (state == Qt::Checked) { - label_Resolution->setEnabled(false); - radioButton_standard_res->setEnabled(false); - radioButton_custom_res->setEnabled(false); - comboBox_std_window_size->setEnabled(false); - spinBox_x->setEnabled(false); - spinBox_y->setEnabled(false); - } - else - { - label_Resolution->setEnabled(true); - radioButton_standard_res->setEnabled(true); - radioButton_custom_res->setEnabled(true); - comboBox_std_window_size->setEnabled(true); - spinBox_x->setEnabled(true); - spinBox_y->setEnabled(true); - } -} - // FIXME: what to do with updating window size void CSVSettings::SettingsDialog::slotStandardToggled(bool checked) { @@ -254,17 +232,6 @@ void CSVSettings::SettingsDialog::setViewValues() comboBox_std_window_size->setCurrentIndex(index); slotStandardToggled(radioButton_standard_res->isChecked() ? true : false); - - if(CSMSettings::UserSettings::instance().settingValue("Video/fullscreen") == "true") - { - checkBox_fullscreen->setChecked(true); - slotFullScreenChanged(Qt::Checked); - } - else - { - checkBox_fullscreen->setChecked(false); - slotFullScreenChanged(Qt::Unchecked); - } } void CSVSettings::SettingsDialog::closeEvent (QCloseEvent *event) diff --git a/apps/opencs/view/settings/settingsdialog.hpp b/apps/opencs/view/settings/settingsdialog.hpp index 8f80fbc12..d971b9c2a 100644 --- a/apps/opencs/view/settings/settingsdialog.hpp +++ b/apps/opencs/view/settings/settingsdialog.hpp @@ -37,7 +37,6 @@ namespace CSVSettings { void show(); void rendererChanged(); - void slotFullScreenChanged(int state); void slotStandardToggled(bool checked); }; } diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 8e69767f5..2b1b561da 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -26,11 +26,24 @@ 20 188 351 - 81 + 51
- + + + + + + + + 186 + 16777215 + + + + + Standard: @@ -43,21 +56,7 @@ - - - - Resolution - - - - - - - Full Screen - - - - + Custom; @@ -67,20 +66,14 @@ - - - - - 186 - 16777215 - + + + + Window Size - - - - + @@ -90,19 +83,6 @@ - - - - - 16777215 - 2 - - - - Qt::Horizontal - - - @@ -124,7 +104,7 @@ 10 170 371 - 108 + 81 @@ -211,8 +191,7 @@ - - + From 9dc4af69c6f4ec0df12a22bb43f05bcbc1c8ffa0 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 17 Sep 2014 17:13:21 +1000 Subject: [PATCH 08/48] Got window size to work correctly. Started to incorporate parts of previous settings implementation where possible. --- apps/opencs/CMakeLists.txt | 3 + apps/opencs/editor.cpp | 2 +- apps/opencs/view/doc/view.cpp | 10 +- apps/opencs/view/settings/settingsdialog.cpp | 113 ++++++++++++++++--- apps/opencs/view/settings/settingsdialog.hpp | 24 +++- 5 files changed, 126 insertions(+), 26 deletions(-) diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index a58c1a614..02a6c25a0 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -99,6 +99,9 @@ opencs_units_noqt (view/tools opencs_units (view/settings settingsdialog + settingwindow + dialog + page view booleanview textview diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 79e33e56b..5fc2562ed 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -28,7 +28,7 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit) setupDataFiles (config.first); CSMSettings::UserSettings::instance().loadSettings ("opencs.ini"); - //mSettings.setModel (CSMSettings::UserSettings::instance()); + mSettings.setModel (CSMSettings::UserSettings::instance()); ogreInit.init ((mCfgMgr.getUserConfigPath() / "opencsOgre.log").string()); diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 0ba9f80f7..28ef002d4 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "../../model/doc/document.hpp" #include "../../model/settings/usersettings.hpp" @@ -325,7 +326,14 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to QString height = CSMSettings::UserSettings::instance().settingValue ("Window Size/Height"); - resize (width.toInt(), height.toInt()); + // trick to get the window decorations and their sizes + show(); + hide(); + resize (width.toInt() - (frameGeometry().width() - geometry().width()), + height.toInt() - (frameGeometry().height() - geometry().height())); + // start at the centre of the screen + QPoint screenCenter = QApplication::desktop()->screenGeometry().center(); + move(screenCenter - QPoint(frameGeometry().width()/2, frameGeometry().height()/2)); mSubViewWindow.setDockOptions (QMainWindow::AllowNestedDocks); diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index 92447664f..b49ab2c34 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -39,7 +39,7 @@ QRect getMaximumResolution() return max; } -QString getCurrentResolution() +QString getCurrentOgreResolution() { Ogre::ConfigOptionMap& renderOpt = Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); @@ -152,7 +152,7 @@ QStringList getAvailableOptions(const QString &key) } CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) - : /*mDebugMode (false),*/ QTabWidget (parent) + : QTabWidget (parent) { setObjectName("User Settings"); @@ -163,7 +163,7 @@ CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) spinBox_x->setMaximum(res.width()); spinBox_y->setMaximum(res.height()); - connect(comboBox_rendersystem, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged(const QString&))); + connect(comboBox_rendersystem, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged())); connect(radioButton_standard_res, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); } @@ -195,7 +195,7 @@ void CSVSettings::SettingsDialog::setViewValues() //rendererChanged(Ogre::Root::getSingleton().getRenderSystemByName(renderer.toStdString())); rendererChanged(); // setup antialiasing options - if(CSMSettings::UserSettings::instance().settingValue("Video/use settings.cfg") == "true") + if(mModel->settingValue("Video/use settings.cfg") == "true") { label_RenderingSubsystem->setEnabled(false); comboBox_rendersystem->setEnabled(false); @@ -209,29 +209,105 @@ void CSVSettings::SettingsDialog::setViewValues() else checkBox_override->setChecked(false); - if(CSMSettings::UserSettings::instance().settingValue("Window Size/Width") != "") - { - spinBox_x->setValue( - CSMSettings::UserSettings::instance().settingValue("Window Size/Width").toInt()); - } + if(mModel->settingValue("Window Size/Width") != "") + spinBox_x->setValue(mModel->settingValue("Window Size/Width").toInt()); - if(CSMSettings::UserSettings::instance().settingValue("Window Size/Height") != "") - { - spinBox_y->setValue( - CSMSettings::UserSettings::instance().settingValue("Window Size/Height").toInt()); - } + if(mModel->settingValue("Window Size/Height") != "") + spinBox_y->setValue(mModel->settingValue("Window Size/Height").toInt()); // update display resolution combo box - // FIXME: update opencs window size comboBox_std_window_size->clear(); comboBox_std_window_size->addItems(getAvailableResolutions()); - int index = comboBox_std_window_size->findData(getCurrentResolution(), + + QString currRes = mModel->settingValue("Window Size/Width") + " x " + + mModel->settingValue("Window Size/Height"); + + int index = comboBox_std_window_size->findData(currRes, Qt::DisplayRole, Qt::MatchStartsWith); if(index != -1) + { + // show the values in ini file comboBox_std_window_size->setCurrentIndex(index); + slotStandardToggled(true); + } + else + { + // show what's in Ogre instead + index = comboBox_std_window_size->findData(getCurrentOgreResolution(), + Qt::DisplayRole, + Qt::MatchStartsWith); + if(index != -1) + comboBox_std_window_size->setCurrentIndex(index); + + radioButton_custom_res->setChecked(true); + slotStandardToggled(false); + } +} - slotStandardToggled(radioButton_standard_res->isChecked() ? true : false); +void CSVSettings::SettingsDialog::saveSettings() +{ +#if 0 + //setting the definition in the model automatically syncs with the file + foreach (const Page *page, mPages) + { + foreach (const View *view, page->views()) + { + if (!view->serializable()) + continue; + + mModel->setDefinitions (view->viewKey(), view->selectedValues()); + } + } +#endif + mModel->saveDefinitions(); +} + +void CSVSettings::SettingsDialog::createConnections + (const QList &list) +{ +#if 0 + foreach (const CSMSettings::Setting *setting, list) + { + View *masterView = findView (setting->page(), setting->name()); + + CSMSettings::Connector *connector = + new CSMSettings::Connector (masterView, this); + + connect (masterView, + SIGNAL (viewUpdated(const QString &, const QStringList &)), + connector, + SLOT (slotUpdateSlaves()) + ); + + const CSMSettings::ProxyValueMap &proxyMap = setting->proxyLists(); + + foreach (const QString &key, proxyMap.keys()) + { + QStringList keyPair = key.split('/'); + + if (keyPair.size() != 2) + continue; + + View *slaveView = findView (keyPair.at(0), keyPair.at(1)); + + if (!slaveView) + { + qWarning () << "Unable to create connection for view " + << key; + continue; + } + + QList proxyList = proxyMap.value (key); + connector->addSlaveView (slaveView, proxyList); + + connect (slaveView, + SIGNAL (viewUpdated(const QString &, const QStringList &)), + connector, + SLOT (slotUpdateMaster())); + } + } +#endif } void CSVSettings::SettingsDialog::closeEvent (QCloseEvent *event) @@ -239,8 +315,9 @@ void CSVSettings::SettingsDialog::closeEvent (QCloseEvent *event) //SettingWindow::closeEvent() must be called first to ensure //model is updated //SettingWindow::closeEvent (event); + QApplication::focusWidget()->clearFocus(); - //saveSettings(); + saveSettings(); } void CSVSettings::SettingsDialog::show() diff --git a/apps/opencs/view/settings/settingsdialog.hpp b/apps/opencs/view/settings/settingsdialog.hpp index d971b9c2a..c5c848b59 100644 --- a/apps/opencs/view/settings/settingsdialog.hpp +++ b/apps/opencs/view/settings/settingsdialog.hpp @@ -7,35 +7,47 @@ class QListWidgetItem; +namespace CSMSettings +{ + class Setting; + class UserSettings; +} + namespace CSVSettings { class SettingsDialog : public QTabWidget, private Ui::TabWidget { Q_OBJECT + CSMSettings::UserSettings *mModel; + public: SettingsDialog (QTabWidget *parent = 0); - int windowWidth(); - int windowHeight(); - - ///Enables setting debug mode. When the dialog opens, a page is created - ///which displays the SettingModel's contents in a Tree view. - //void enableDebugMode (bool state, QStandardItemModel *model = 0); + ///set the model the view uses (instance of UserSettings) + void setModel (CSMSettings::UserSettings &model) { mModel = &model; } protected: + ///save settings from the GUI to file + void saveSettings(); + /// Settings are written on close void closeEvent (QCloseEvent *event); private: + ///sets the defined values for the views that have been created void setViewValues(); + ///create connections between settings (used for proxy settings) + void createConnections (const QList &list); + public slots: void show(); + void rendererChanged(); void slotStandardToggled(bool checked); }; From 62d2811285df434be726d08275de195a72a90775 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 18 Sep 2014 07:52:54 +1000 Subject: [PATCH 09/48] Window size improvements. Added promoted widgets but seems to be require signal filters for disabled widgets to receive mouse events. --- apps/opencs/CMakeLists.txt | 4 +- apps/opencs/editor.cpp | 2 +- apps/opencs/model/settings/usersettings.cpp | 68 +++++- apps/opencs/model/settings/usersettings.hpp | 3 + apps/opencs/view/doc/view.cpp | 8 + apps/opencs/view/settings/clickcombobox.cpp | 9 + apps/opencs/view/settings/clickcombobox.hpp | 20 ++ apps/opencs/view/settings/clickspinbox.cpp | 11 + apps/opencs/view/settings/clickspinbox.hpp | 20 ++ apps/opencs/view/settings/settingsdialog.cpp | 223 +++++++++++++------ apps/opencs/view/settings/settingsdialog.hpp | 5 +- files/ui/settingstab.ui | 196 ++++++++++------ 12 files changed, 430 insertions(+), 139 deletions(-) create mode 100644 apps/opencs/view/settings/clickcombobox.cpp create mode 100644 apps/opencs/view/settings/clickcombobox.hpp create mode 100644 apps/opencs/view/settings/clickspinbox.cpp create mode 100644 apps/opencs/view/settings/clickspinbox.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 02a6c25a0..0ee7c1aea 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -109,6 +109,8 @@ opencs_units (view/settings rangeview resizeablestackedwidget spinbox + clickspinbox + clickcombobox ) opencs_units_noqt (view/settings @@ -166,7 +168,7 @@ qt4_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI}) qt4_wrap_cpp(OPENCS_MOC_SRC ${OPENCS_HDR_QT}) qt4_add_resources(OPENCS_RES_SRC ${OPENCS_RES}) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) +include_directories(${CMAKE_CURRENT_BINARY_DIR} view/settings) if(APPLE) set (OPENCS_MAC_ICON ${CMAKE_SOURCE_DIR}/files/mac/opencs.icns) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 5fc2562ed..8590657ad 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -297,7 +297,7 @@ std::auto_ptr CS::Editor::setupGraphics() std::auto_ptr factory (new sh::Factory (platform)); - std::string shLang = mUserSettings.settingValue("Shiny/language").toStdString(); + std::string shLang = mUserSettings.settingValue("Shader/language").toStdString(); enum sh::Language lang; if(shLang == "CG") lang = sh::Language_CG; else if(shLang == "HLSL") lang = sh::Language_HLSL; diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index cd9bf6a33..e8ee98277 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -5,9 +5,12 @@ #include #include +#include #include +#include + #include "setting.hpp" #include "support.hpp" #include @@ -344,17 +347,76 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName) #endif } mSettingCfgDefinitions->setValue("Video/render system", renderSystem.c_str()); - // force shiny language based on render system + // force shader language based on render system if(renderSystem == "Direct3D9 Rendering Subsystem") - mSettingDefinitions->setValue("Shiny/language", "CG"); + mSettingDefinitions->setValue("Shader/language", "CG"); else - mSettingDefinitions->setValue("Shiny/language", "GLSL"); + mSettingDefinitions->setValue("Shader/language", "GLSL"); // check if override entry exists (default: override) if(!mSettingDefinitions->childGroups().contains("Video", Qt::CaseInsensitive)) mSettingDefinitions->setValue("Video/use settings.cfg", "true"); } +QStringList CSMSettings::UserSettings::getOgreOptions(const QString &key, const QString &renderer) +{ + QStringList result; + + Ogre::ConfigOptionMap& renderOpt = + //Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); + Ogre::Root::getSingleton().getRenderSystemByName(renderer.toStdString())->getConfigOptions(); + Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); + + uint row = 0; + for(; it != renderOpt.end(); ++it, ++row) + { + Ogre::StringVector::iterator opt_it = it->second.possibleValues.begin(); + uint idx = 0; + + for(; opt_it != it->second.possibleValues.end(); ++opt_it, ++idx) + { + if(strcmp (key.toStdString().c_str(), it->first.c_str()) == 0) + { + result << ((key == "FSAA") ? QString("MSAA ") : QString("")) + + QString::fromStdString((*opt_it).c_str()).simplified(); + } + } + } + + // Sort ascending + qSort(result.begin(), result.end(), naturalSortLessThanCI); + + // Replace the zero option with Off + int index = result.indexOf("MSAA 0"); + + if(index != -1) + result.replace(index, QObject::tr("Off")); + + return result; +} + +QStringList CSMSettings::UserSettings::getShaderLanguageByRenderer(const QString &renderer) +{ + QStringList result; + + if(renderer == "Direct3D9 Rendering Subsystem") + { + result.append("CG"); + result.append("HLSL"); + result.append("None"); + } + else if(renderer == "OpenGL Rendering Subsystem") + { + result.append("GLSL"); + result.append("GLSLES"); + result.append("None"); + } + else + result.append("None"); + + return result; +} + bool CSMSettings::UserSettings::hasSettingDefinitions (const QString &viewKey) const { diff --git a/apps/opencs/model/settings/usersettings.hpp b/apps/opencs/model/settings/usersettings.hpp index 9d9b5c9b0..b45fa3d83 100644 --- a/apps/opencs/model/settings/usersettings.hpp +++ b/apps/opencs/model/settings/usersettings.hpp @@ -76,6 +76,9 @@ namespace CSMSettings { ///Save any unsaved changes in the QSettings object void saveDefinitions() const; + QStringList getShaderLanguageByRenderer(const QString &renderer); + QStringList getOgreOptions(const QString &key, const QString &renderer); + private: void buildSettingModelDefaults(); diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 349b1e037..2ac5d7236 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -32,6 +32,14 @@ void CSVDoc::View::closeEvent (QCloseEvent *event) event->ignore(); else { + // save window size first + CSMSettings::UserSettings::instance().setDefinitions( + "Window Size/Width", + QStringList(QString::number(frameGeometry().width()))); + CSMSettings::UserSettings::instance().setDefinitions( + "Window Size/Height", + QStringList(QString::number(frameGeometry().height()))); + CSMSettings::UserSettings::instance().saveDefinitions(); // closeRequest() returns true if last document mViewManager.removeDocAndView(mDocument); } diff --git a/apps/opencs/view/settings/clickcombobox.cpp b/apps/opencs/view/settings/clickcombobox.cpp new file mode 100644 index 000000000..f313ffe84 --- /dev/null +++ b/apps/opencs/view/settings/clickcombobox.cpp @@ -0,0 +1,9 @@ +#include "clickcombobox.hpp" + +#include + +void ClickComboBox::mouseReleaseEvent(QMouseEvent *e) +{ + emit mouseReleased(); +} + diff --git a/apps/opencs/view/settings/clickcombobox.hpp b/apps/opencs/view/settings/clickcombobox.hpp new file mode 100644 index 000000000..f3385f407 --- /dev/null +++ b/apps/opencs/view/settings/clickcombobox.hpp @@ -0,0 +1,20 @@ +#ifndef CSVSETTINGS_CLICKCOMBOBOX_H +#define CSVSETTINGS_CLICKCOMBOBOX_H + +#include +#include + +class ClickComboBox : public QComboBox +{ + Q_OBJECT + + public: + explicit ClickComboBox(QWidget *parent = 0) { } + void mouseReleaseEvent(QMouseEvent *e); + + signals: + void mouseReleased(); + +}; + +#endif /* CSVSETTINGS_CLICKCOMBOBOX_H */ diff --git a/apps/opencs/view/settings/clickspinbox.cpp b/apps/opencs/view/settings/clickspinbox.cpp new file mode 100644 index 000000000..e94b9b3d0 --- /dev/null +++ b/apps/opencs/view/settings/clickspinbox.cpp @@ -0,0 +1,11 @@ +#include "clickspinbox.hpp" + +#include +#include + +void ClickSpinBox::mouseReleaseEvent(QMouseEvent *e) +{ + std::cout << "emit" << std::endl; + emit mouseReleased(); +} + diff --git a/apps/opencs/view/settings/clickspinbox.hpp b/apps/opencs/view/settings/clickspinbox.hpp new file mode 100644 index 000000000..0db534e51 --- /dev/null +++ b/apps/opencs/view/settings/clickspinbox.hpp @@ -0,0 +1,20 @@ +#ifndef CSVSETTINGS_CLICKSPINBOX_H +#define CSVSETTINGS_CLICKSPINBOX_H + +#include +#include + +class ClickSpinBox : public QSpinBox +{ + Q_OBJECT + + public: + explicit ClickSpinBox(QWidget *parent = 0) { } + void mouseReleaseEvent(QMouseEvent *e); + + signals: + void mouseReleased(); + +}; + +#endif /* CSVSETTINGS_CLICKSPINBOX_H */ diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index b49ab2c34..34a6c5527 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -5,7 +5,6 @@ #include -#include #include "../../model/settings/usersettings.hpp" namespace @@ -49,14 +48,35 @@ QString getCurrentOgreResolution() if(it->first == "Video Mode" ) { QRegExp re("^(\\d+ x \\d+)"); - int pos = re.indexIn(it->second.currentValue.c_str(), 0); - if (pos > -1) + if (re.indexIn(it->second.currentValue.c_str(), 0) > -1) return re.cap(1); } } return QString(); // found nothing } +bool customCompare(const QString &s1, const QString &s2) +{ + int x1, x2, y1, y2; + QRegExp re("^(\\d+) x (\\d+)"); + + 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 @@ -93,8 +113,7 @@ QStringList getAvailableResolutions() { // extract x and y values QRegExp re("^(\\d+) x (\\d+)"); - int pos = re.indexIn((*iter).c_str(), 0); - if (pos > -1) + 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); @@ -110,42 +129,7 @@ QStringList getAvailableResolutions() } } result.removeDuplicates(); - return result; -} - -QStringList getAvailableOptions(const QString &key) -{ - QStringList result; - - Ogre::ConfigOptionMap& renderOpt = - Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); - Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); - - uint row = 0; - for(; it != renderOpt.end(); ++it, ++row) - { - Ogre::StringVector::iterator opt_it = it->second.possibleValues.begin(); - uint idx = 0; - - for(; opt_it != it->second.possibleValues.end(); ++opt_it, ++idx) - { - if(strcmp (key.toStdString().c_str(), it->first.c_str()) == 0) - { - result << ((key == "FSAA") ? QString("MSAA ") : QString("")) - + QString::fromStdString((*opt_it).c_str()).simplified(); - } - } - } - - // Sort ascending - qSort(result.begin(), result.end(), naturalSortLessThanCI); - - // Replace the zero option with Off - int index = result.indexOf("MSAA 0"); - - if(index != -1) - result.replace(index, QObject::tr("Off")); - + qStableSort(result.begin(), result.end(), customCompare); return result; } @@ -163,17 +147,75 @@ CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) spinBox_x->setMaximum(res.width()); spinBox_y->setMaximum(res.height()); - connect(comboBox_rendersystem, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged())); + connect(checkBox_override, SIGNAL(toggled(bool)), this, SLOT(slotOverrideToggled(bool))); + connect(comboBox_rendersystem, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(slotRendererChanged(const QString&))); connect(radioButton_standard_res, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); + + connect(comboBox_std_window_size, SIGNAL(mouseReleased()), this, SLOT(slotStandardClicked())); + connect(spinBox_x, SIGNAL(mouseReleased()), this, SLOT(slotCustomClicked())); + connect(spinBox_y, SIGNAL(mouseReleased()), this, SLOT(slotCustomClicked())); } -void CSVSettings::SettingsDialog::rendererChanged() +void CSVSettings::SettingsDialog::slotStandardClicked() +{ + std::cout << "click" << std::endl; + if(!radioButton_standard_res->isChecked()) + radioButton_standard_res->toggle(); +} + +void CSVSettings::SettingsDialog::slotCustomClicked() +{ + std::cout << "click" << std::endl; + if(radioButton_standard_res->isChecked()) + radioButton_standard_res->toggle(); +} + +void CSVSettings::SettingsDialog::slotRendererChanged(const QString &renderer) { comboBox_antialiasing->clear(); - comboBox_antialiasing->addItems(getAvailableOptions(QString("FSAA"))); + comboBox_antialiasing->addItems(mModel->getOgreOptions(QString("FSAA"), renderer)); + + comboBox_shaderlanguage->clear(); + comboBox_shaderlanguage->addItems(mModel->getShaderLanguageByRenderer(renderer)); + + if(mModel->settingValue("Video/use settings.cfg") == "true") + { + label_RenderingSubsystem->setEnabled(false); + comboBox_rendersystem->setEnabled(false); + label_Antialiasing->setEnabled(false); + comboBox_antialiasing->setEnabled(false); + checkBox_vsync->setEnabled(false); + label_ShaderLanguage->setEnabled(false); + comboBox_shaderlanguage->setEnabled(false); + } + else + checkBox_override->setChecked(false); +} + +void CSVSettings::SettingsDialog::slotOverrideToggled(bool checked) +{ + if(checked) + { + label_RenderingSubsystem->setEnabled(false); + comboBox_rendersystem->setEnabled(false); + label_Antialiasing->setEnabled(false); + comboBox_antialiasing->setEnabled(false); + checkBox_vsync->setEnabled(false); + label_ShaderLanguage->setEnabled(false); + comboBox_shaderlanguage->setEnabled(false); + } + else + { + label_RenderingSubsystem->setEnabled(true); + comboBox_rendersystem->setEnabled(true); + label_Antialiasing->setEnabled(true); + comboBox_antialiasing->setEnabled(true); + checkBox_vsync->setEnabled(true); + label_ShaderLanguage->setEnabled(true); + comboBox_shaderlanguage->setEnabled(true); + } } -// FIXME: what to do with updating window size void CSVSettings::SettingsDialog::slotStandardToggled(bool checked) { if (checked) @@ -192,22 +234,28 @@ void CSVSettings::SettingsDialog::slotStandardToggled(bool checked) void CSVSettings::SettingsDialog::setViewValues() { - //rendererChanged(Ogre::Root::getSingleton().getRenderSystemByName(renderer.toStdString())); - rendererChanged(); // setup antialiasing options + int index = -1; - if(mModel->settingValue("Video/use settings.cfg") == "true") - { - label_RenderingSubsystem->setEnabled(false); - comboBox_rendersystem->setEnabled(false); - label_Antialiasing->setEnabled(false); - comboBox_antialiasing->setEnabled(false); - checkBox_vsync->setEnabled(false); - label_ShaderLanguage->setEnabled(false); - comboBox_shaderlanguage->setEnabled(false); + // initialised in the constructor + slotOverrideToggled(checkBox_override->isChecked()); - } - else - checkBox_override->setChecked(false); + // Ogre initialised earlier + slotRendererChanged(Ogre::Root::getSingleton().getRenderSystem()->getName().c_str()); + + // antialiasing + QString antialiasing = mModel->settingValue("Video/antialiasing"); + index = comboBox_antialiasing->findData(antialiasing, Qt::DisplayRole); + if(index != -1) + comboBox_antialiasing->setCurrentIndex(index); + + // vsync + checkBox_vsync->setChecked(mModel->settingValue("Video/vsync") == "true"); + + // shader lang + QString shaderlang = mModel->settingValue("Shader/language"); + index = comboBox_shaderlanguage->findData(shaderlang, Qt::DisplayRole); + if(index != -1) + comboBox_shaderlanguage->setCurrentIndex(index); if(mModel->settingValue("Window Size/Width") != "") spinBox_x->setValue(mModel->settingValue("Window Size/Width").toInt()); @@ -222,9 +270,7 @@ void CSVSettings::SettingsDialog::setViewValues() QString currRes = mModel->settingValue("Window Size/Width") + " x " + mModel->settingValue("Window Size/Height"); - int index = comboBox_std_window_size->findData(currRes, - Qt::DisplayRole, - Qt::MatchStartsWith); + index = comboBox_std_window_size->findData(currRes, Qt::DisplayRole, Qt::MatchStartsWith); if(index != -1) { // show the values in ini file @@ -234,9 +280,7 @@ void CSVSettings::SettingsDialog::setViewValues() else { // show what's in Ogre instead - index = comboBox_std_window_size->findData(getCurrentOgreResolution(), - Qt::DisplayRole, - Qt::MatchStartsWith); + index = comboBox_std_window_size->findData(getCurrentOgreResolution(), Qt::DisplayRole, Qt::MatchStartsWith); if(index != -1) comboBox_std_window_size->setCurrentIndex(index); @@ -260,6 +304,55 @@ void CSVSettings::SettingsDialog::saveSettings() } } #endif + std::cout << "closeEvent" << std::endl; + + // override + if(checkBox_override->isChecked()) + mModel->setDefinitions("Video/use settings.cfg", QStringList("true")); + else + mModel->setDefinitions("Video/use settings.cfg", QStringList("false")); + + // render system + mModel->setDefinitions("Video/render system", + QStringList(comboBox_rendersystem->currentText())); + + // vsync + if(checkBox_vsync->isChecked()) + mModel->setDefinitions("Video/vsync", QStringList("true")); + else + mModel->setDefinitions("Video/vsync", QStringList("false")); + + // antialiasing + mModel->setDefinitions("Video/antialiasing", + QStringList(comboBox_antialiasing->currentText())); +#if 0 + QRegExp reAA("^\\D*(\\d+)\\D*"); + if(reAA.indexIn(comboBox_antialiasing->currentText()) > -1) + mModel->setDefinitions("Video/antialiasing", QStringList(reAA.cap(1))); +#endif + + // shader lang + mModel->setDefinitions("Shader/language", + QStringList(comboBox_shaderlanguage->currentText())); + + // window size + if(radioButton_standard_res->isChecked()) + { + QRegExp re("^(\\d+) x (\\d+)"); + if(re.indexIn(comboBox_std_window_size->currentText()) > -1) + { + mModel->setDefinitions("Window Size/Width", QStringList(re.cap(1))); + mModel->setDefinitions("Window Size/Height", QStringList(re.cap(2))); + } + } + else + { + mModel->setDefinitions("Window Size/Width", + QStringList(QString::number(spinBox_x->value()))); + mModel->setDefinitions("Window Size/Height", + QStringList(QString::number(spinBox_y->value()))); + } + mModel->saveDefinitions(); } diff --git a/apps/opencs/view/settings/settingsdialog.hpp b/apps/opencs/view/settings/settingsdialog.hpp index c5c848b59..737ebdb07 100644 --- a/apps/opencs/view/settings/settingsdialog.hpp +++ b/apps/opencs/view/settings/settingsdialog.hpp @@ -48,7 +48,10 @@ namespace CSVSettings { void show(); - void rendererChanged(); + void slotStandardClicked(); + void slotCustomClicked(); + void slotRendererChanged(const QString &renderer); + void slotOverrideToggled(bool checked); void slotStandardToggled(bool checked); }; } diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 2b1b561da..51566869a 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -31,56 +31,63 @@ - + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + - + 186 16777215 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + - - - - Standard: - - - true + + + + + 180 + 0 + - - buttonGroup - - + - Custom; + Custom: buttonGroup - + - Window Size + - - - - - 180 - 0 - + + + + Standard: + + true + + + buttonGroup + @@ -108,10 +115,10 @@ - Display + Window Size - + 20 @@ -180,7 +187,7 @@ - HLSL + GLSL @@ -212,7 +219,7 @@ renderGroup - layoutWidget + layoutWidget_Render displayGroup layoutWidget_Screen @@ -220,34 +227,46 @@ Display Settings - + - 20 - 30 + 10 + 10 + 371 + 71 + + + + + + + + + + 9 + 110 + 371 + 111 + + + + Subviews + + + + + + 21 + 20 351 - 116 + 45 - - - - - Max Number of Subviews - - - - - - - Min Subview Width - - - - - + + + - Reuse Subviews + Display Format: @@ -265,11 +284,51 @@ - - + + + + Show Status Bar + + - + + + + + + 21 + 130 + 351 + 71 + + + + + + + Max Number of Subviews: + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Min Subview Width: + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + 325 @@ -281,29 +340,18 @@ - - + + - Show Icon + Reuse Subviews - - - - 10 - 10 - 371 - 151 - - - - GroupBox - - + groupBox_2 groupBox + layoutWidget layoutWidget2 @@ -312,6 +360,18 @@ + + + ClickSpinBox + QSpinBox +
clickspinbox.hpp
+
+ + ClickComboBox + QComboBox +
clickcombobox.hpp
+
+
From 86636bd960add71e66efd8e5c429321ea1df67b3 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 18 Sep 2014 12:23:41 +1000 Subject: [PATCH 10/48] Mouse events to disabled objects implemented via a signal filter. --- apps/opencs/CMakeLists.txt | 4 +- apps/opencs/view/settings/clickcombobox.cpp | 9 - apps/opencs/view/settings/clickcombobox.hpp | 20 -- apps/opencs/view/settings/clickspinbox.cpp | 11 - apps/opencs/view/settings/clickspinbox.hpp | 20 -- apps/opencs/view/settings/settingsdialog.cpp | 165 +++++++------ apps/opencs/view/settings/settingsdialog.hpp | 6 +- files/ui/settingstab.ui | 230 +++++++++---------- 8 files changed, 204 insertions(+), 261 deletions(-) delete mode 100644 apps/opencs/view/settings/clickcombobox.cpp delete mode 100644 apps/opencs/view/settings/clickcombobox.hpp delete mode 100644 apps/opencs/view/settings/clickspinbox.cpp delete mode 100644 apps/opencs/view/settings/clickspinbox.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 0ee7c1aea..02a6c25a0 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -109,8 +109,6 @@ opencs_units (view/settings rangeview resizeablestackedwidget spinbox - clickspinbox - clickcombobox ) opencs_units_noqt (view/settings @@ -168,7 +166,7 @@ qt4_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI}) qt4_wrap_cpp(OPENCS_MOC_SRC ${OPENCS_HDR_QT}) qt4_add_resources(OPENCS_RES_SRC ${OPENCS_RES}) -include_directories(${CMAKE_CURRENT_BINARY_DIR} view/settings) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) if(APPLE) set (OPENCS_MAC_ICON ${CMAKE_SOURCE_DIR}/files/mac/opencs.icns) diff --git a/apps/opencs/view/settings/clickcombobox.cpp b/apps/opencs/view/settings/clickcombobox.cpp deleted file mode 100644 index f313ffe84..000000000 --- a/apps/opencs/view/settings/clickcombobox.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "clickcombobox.hpp" - -#include - -void ClickComboBox::mouseReleaseEvent(QMouseEvent *e) -{ - emit mouseReleased(); -} - diff --git a/apps/opencs/view/settings/clickcombobox.hpp b/apps/opencs/view/settings/clickcombobox.hpp deleted file mode 100644 index f3385f407..000000000 --- a/apps/opencs/view/settings/clickcombobox.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef CSVSETTINGS_CLICKCOMBOBOX_H -#define CSVSETTINGS_CLICKCOMBOBOX_H - -#include -#include - -class ClickComboBox : public QComboBox -{ - Q_OBJECT - - public: - explicit ClickComboBox(QWidget *parent = 0) { } - void mouseReleaseEvent(QMouseEvent *e); - - signals: - void mouseReleased(); - -}; - -#endif /* CSVSETTINGS_CLICKCOMBOBOX_H */ diff --git a/apps/opencs/view/settings/clickspinbox.cpp b/apps/opencs/view/settings/clickspinbox.cpp deleted file mode 100644 index e94b9b3d0..000000000 --- a/apps/opencs/view/settings/clickspinbox.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "clickspinbox.hpp" - -#include -#include - -void ClickSpinBox::mouseReleaseEvent(QMouseEvent *e) -{ - std::cout << "emit" << std::endl; - emit mouseReleased(); -} - diff --git a/apps/opencs/view/settings/clickspinbox.hpp b/apps/opencs/view/settings/clickspinbox.hpp deleted file mode 100644 index 0db534e51..000000000 --- a/apps/opencs/view/settings/clickspinbox.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef CSVSETTINGS_CLICKSPINBOX_H -#define CSVSETTINGS_CLICKSPINBOX_H - -#include -#include - -class ClickSpinBox : public QSpinBox -{ - Q_OBJECT - - public: - explicit ClickSpinBox(QWidget *parent = 0) { } - void mouseReleaseEvent(QMouseEvent *e); - - signals: - void mouseReleased(); - -}; - -#endif /* CSVSETTINGS_CLICKSPINBOX_H */ diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index 34a6c5527..4c426ff6d 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -144,75 +144,90 @@ CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent) // Set the maximum res we can set in windowed mode QRect res = getMaximumResolution(); - spinBox_x->setMaximum(res.width()); - spinBox_y->setMaximum(res.height()); + sbWidth->setMaximum(res.width()); + sbHeight->setMaximum(res.height()); - connect(checkBox_override, SIGNAL(toggled(bool)), this, SLOT(slotOverrideToggled(bool))); - connect(comboBox_rendersystem, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(slotRendererChanged(const QString&))); - connect(radioButton_standard_res, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); + // to enable mouse events on disabled widgets + cmbStdWinSize->installEventFilter(this); + sbWidth->installEventFilter(this); + sbHeight->installEventFilter(this); - connect(comboBox_std_window_size, SIGNAL(mouseReleased()), this, SLOT(slotStandardClicked())); - connect(spinBox_x, SIGNAL(mouseReleased()), this, SLOT(slotCustomClicked())); - connect(spinBox_y, SIGNAL(mouseReleased()), this, SLOT(slotCustomClicked())); + 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))); } -void CSVSettings::SettingsDialog::slotStandardClicked() +bool CSVSettings::SettingsDialog::eventFilter(QObject *target, QEvent *event) { - std::cout << "click" << std::endl; - if(!radioButton_standard_res->isChecked()) - radioButton_standard_res->toggle(); -} + QWidget *item = qobject_cast(target); + if (target == cmbStdWinSize) + { + if (!item->isEnabled() && (event->type() == QEvent::MouseButtonRelease)) + { + rbCustWinSize->setChecked(false); + rbStdWinSize->setChecked(true); + slotStandardToggled(true); -void CSVSettings::SettingsDialog::slotCustomClicked() -{ - std::cout << "click" << std::endl; - if(radioButton_standard_res->isChecked()) - radioButton_standard_res->toggle(); + return false; + } + } + else if (target == sbWidth || target == sbHeight) + { + if (!item->isEnabled() && (event->type() == QEvent::MouseButtonPress)) + { + rbStdWinSize->setChecked(false); + rbCustWinSize->setChecked(true); + slotStandardToggled(false); + + return false; + } + } + return QTabWidget::eventFilter(target, event); } void CSVSettings::SettingsDialog::slotRendererChanged(const QString &renderer) { - comboBox_antialiasing->clear(); - comboBox_antialiasing->addItems(mModel->getOgreOptions(QString("FSAA"), renderer)); + cmbAntiAlias->clear(); + cmbAntiAlias->addItems(mModel->getOgreOptions(QString("FSAA"), renderer)); - comboBox_shaderlanguage->clear(); - comboBox_shaderlanguage->addItems(mModel->getShaderLanguageByRenderer(renderer)); + cmbShaderLang->clear(); + cmbShaderLang->addItems(mModel->getShaderLanguageByRenderer(renderer)); if(mModel->settingValue("Video/use settings.cfg") == "true") { - label_RenderingSubsystem->setEnabled(false); - comboBox_rendersystem->setEnabled(false); - label_Antialiasing->setEnabled(false); - comboBox_antialiasing->setEnabled(false); - checkBox_vsync->setEnabled(false); - label_ShaderLanguage->setEnabled(false); - comboBox_shaderlanguage->setEnabled(false); + labRenderSys->setEnabled(false); + cmbRenderSys->setEnabled(false); + labAntiAlias->setEnabled(false); + cmbAntiAlias->setEnabled(false); + cbVsync->setEnabled(false); + labShaderLang->setEnabled(false); + cmbShaderLang->setEnabled(false); } else - checkBox_override->setChecked(false); + cbOverride->setChecked(false); } void CSVSettings::SettingsDialog::slotOverrideToggled(bool checked) { if(checked) { - label_RenderingSubsystem->setEnabled(false); - comboBox_rendersystem->setEnabled(false); - label_Antialiasing->setEnabled(false); - comboBox_antialiasing->setEnabled(false); - checkBox_vsync->setEnabled(false); - label_ShaderLanguage->setEnabled(false); - comboBox_shaderlanguage->setEnabled(false); + labRenderSys->setEnabled(false); + cmbRenderSys->setEnabled(false); + labAntiAlias->setEnabled(false); + cmbAntiAlias->setEnabled(false); + cbVsync->setEnabled(false); + labShaderLang->setEnabled(false); + cmbShaderLang->setEnabled(false); } else { - label_RenderingSubsystem->setEnabled(true); - comboBox_rendersystem->setEnabled(true); - label_Antialiasing->setEnabled(true); - comboBox_antialiasing->setEnabled(true); - checkBox_vsync->setEnabled(true); - label_ShaderLanguage->setEnabled(true); - comboBox_shaderlanguage->setEnabled(true); + labRenderSys->setEnabled(true); + cmbRenderSys->setEnabled(true); + labAntiAlias->setEnabled(true); + cmbAntiAlias->setEnabled(true); + cbVsync->setEnabled(true); + labShaderLang->setEnabled(true); + cmbShaderLang->setEnabled(true); } } @@ -220,15 +235,15 @@ void CSVSettings::SettingsDialog::slotStandardToggled(bool checked) { if (checked) { - comboBox_std_window_size->setEnabled(true); - spinBox_x->setEnabled(false); - spinBox_y->setEnabled(false); + cmbStdWinSize->setEnabled(true); + sbWidth->setEnabled(false); + sbHeight->setEnabled(false); } else { - comboBox_std_window_size->setEnabled(false); - spinBox_x->setEnabled(true); - spinBox_y->setEnabled(true); + cmbStdWinSize->setEnabled(false); + sbWidth->setEnabled(true); + sbHeight->setEnabled(true); } } @@ -237,54 +252,54 @@ void CSVSettings::SettingsDialog::setViewValues() int index = -1; // initialised in the constructor - slotOverrideToggled(checkBox_override->isChecked()); + slotOverrideToggled(cbOverride->isChecked()); // Ogre initialised earlier slotRendererChanged(Ogre::Root::getSingleton().getRenderSystem()->getName().c_str()); // antialiasing QString antialiasing = mModel->settingValue("Video/antialiasing"); - index = comboBox_antialiasing->findData(antialiasing, Qt::DisplayRole); + index = cmbAntiAlias->findData(antialiasing, Qt::DisplayRole); if(index != -1) - comboBox_antialiasing->setCurrentIndex(index); + cmbAntiAlias->setCurrentIndex(index); // vsync - checkBox_vsync->setChecked(mModel->settingValue("Video/vsync") == "true"); + cbVsync->setChecked(mModel->settingValue("Video/vsync") == "true"); // shader lang QString shaderlang = mModel->settingValue("Shader/language"); - index = comboBox_shaderlanguage->findData(shaderlang, Qt::DisplayRole); + index = cmbShaderLang->findData(shaderlang, Qt::DisplayRole); if(index != -1) - comboBox_shaderlanguage->setCurrentIndex(index); + cmbShaderLang->setCurrentIndex(index); if(mModel->settingValue("Window Size/Width") != "") - spinBox_x->setValue(mModel->settingValue("Window Size/Width").toInt()); + sbWidth->setValue(mModel->settingValue("Window Size/Width").toInt()); if(mModel->settingValue("Window Size/Height") != "") - spinBox_y->setValue(mModel->settingValue("Window Size/Height").toInt()); + sbHeight->setValue(mModel->settingValue("Window Size/Height").toInt()); // update display resolution combo box - comboBox_std_window_size->clear(); - comboBox_std_window_size->addItems(getAvailableResolutions()); + cmbStdWinSize->clear(); + cmbStdWinSize->addItems(getAvailableResolutions()); QString currRes = mModel->settingValue("Window Size/Width") + " x " + mModel->settingValue("Window Size/Height"); - index = comboBox_std_window_size->findData(currRes, Qt::DisplayRole, Qt::MatchStartsWith); + index = cmbStdWinSize->findData(currRes, Qt::DisplayRole, Qt::MatchStartsWith); if(index != -1) { // show the values in ini file - comboBox_std_window_size->setCurrentIndex(index); + cmbStdWinSize->setCurrentIndex(index); slotStandardToggled(true); } else { // show what's in Ogre instead - index = comboBox_std_window_size->findData(getCurrentOgreResolution(), Qt::DisplayRole, Qt::MatchStartsWith); + index = cmbStdWinSize->findData(getCurrentOgreResolution(), Qt::DisplayRole, Qt::MatchStartsWith); if(index != -1) - comboBox_std_window_size->setCurrentIndex(index); + cmbStdWinSize->setCurrentIndex(index); - radioButton_custom_res->setChecked(true); + rbCustWinSize->setChecked(true); slotStandardToggled(false); } } @@ -307,39 +322,39 @@ void CSVSettings::SettingsDialog::saveSettings() std::cout << "closeEvent" << std::endl; // override - if(checkBox_override->isChecked()) + if(cbOverride->isChecked()) mModel->setDefinitions("Video/use settings.cfg", QStringList("true")); else mModel->setDefinitions("Video/use settings.cfg", QStringList("false")); // render system mModel->setDefinitions("Video/render system", - QStringList(comboBox_rendersystem->currentText())); + QStringList(cmbRenderSys->currentText())); // vsync - if(checkBox_vsync->isChecked()) + if(cbVsync->isChecked()) mModel->setDefinitions("Video/vsync", QStringList("true")); else mModel->setDefinitions("Video/vsync", QStringList("false")); // antialiasing mModel->setDefinitions("Video/antialiasing", - QStringList(comboBox_antialiasing->currentText())); + QStringList(cmbAntiAlias->currentText())); #if 0 QRegExp reAA("^\\D*(\\d+)\\D*"); - if(reAA.indexIn(comboBox_antialiasing->currentText()) > -1) + if(reAA.indexIn(cmbAntiAlias->currentText()) > -1) mModel->setDefinitions("Video/antialiasing", QStringList(reAA.cap(1))); #endif // shader lang mModel->setDefinitions("Shader/language", - QStringList(comboBox_shaderlanguage->currentText())); + QStringList(cmbShaderLang->currentText())); // window size - if(radioButton_standard_res->isChecked()) + if(rbStdWinSize->isChecked()) { QRegExp re("^(\\d+) x (\\d+)"); - if(re.indexIn(comboBox_std_window_size->currentText()) > -1) + if(re.indexIn(cmbStdWinSize->currentText()) > -1) { mModel->setDefinitions("Window Size/Width", QStringList(re.cap(1))); mModel->setDefinitions("Window Size/Height", QStringList(re.cap(2))); @@ -348,9 +363,9 @@ void CSVSettings::SettingsDialog::saveSettings() else { mModel->setDefinitions("Window Size/Width", - QStringList(QString::number(spinBox_x->value()))); + QStringList(QString::number(sbWidth->value()))); mModel->setDefinitions("Window Size/Height", - QStringList(QString::number(spinBox_y->value()))); + QStringList(QString::number(sbHeight->value()))); } mModel->saveDefinitions(); diff --git a/apps/opencs/view/settings/settingsdialog.hpp b/apps/opencs/view/settings/settingsdialog.hpp index 737ebdb07..07f5ebf24 100644 --- a/apps/opencs/view/settings/settingsdialog.hpp +++ b/apps/opencs/view/settings/settingsdialog.hpp @@ -36,6 +36,8 @@ namespace CSVSettings { /// Settings are written on close void closeEvent (QCloseEvent *event); + bool eventFilter(QObject *target, QEvent *event); + private: ///sets the defined values for the views that have been created @@ -48,8 +50,8 @@ namespace CSVSettings { void show(); - void slotStandardClicked(); - void slotCustomClicked(); + //void slotStandardClicked(); + //void slotCustomClicked(); void slotRendererChanged(const QString &renderer); void slotOverrideToggled(bool checked); void slotStandardToggled(bool checked); diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 51566869a..2cef67b0e 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -20,104 +20,6 @@ Video Settings - - - - 20 - 188 - 351 - 51 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 186 - 16777215 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 180 - 0 - - - - - - - - Custom: - - - buttonGroup - - - - - - - - - - - - - - Standard: - - - true - - - buttonGroup - - - - - - - - - 10 - 8 - 371 - 156 - - - - Render System - - - - - - 10 - 170 - 371 - 81 - - - - Window Size - - @@ -129,7 +31,7 @@ - + Use Render System Settings from OpenMW @@ -139,14 +41,14 @@ - + Rendering Subsystem - + false @@ -163,28 +65,28 @@ - + Antialiasing - + Vertical Sync - + Shader Language - + GLSL @@ -198,7 +100,7 @@ - + @@ -218,10 +120,108 @@ - renderGroup + + + + 20 + 188 + 351 + 51 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 186 + 16777215 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 180 + 0 + + + + + + + + Custom: + + + buttonGroup + + + + + + + + + + + + + + Standard: + + + true + + + buttonGroup + + + + + + + + + 10 + 8 + 371 + 156 + + + + Render System + + + + + + 10 + 170 + 371 + 81 + + + + Window Size + + + displayGroup_Render layoutWidget_Render - displayGroup - layoutWidget_Screen + displayGroup_Window + layoutWidget_Window @@ -360,18 +360,6 @@ - - - ClickSpinBox - QSpinBox -
clickspinbox.hpp
-
- - ClickComboBox - QComboBox -
clickcombobox.hpp
-
-
From d9b0c8129969b425d60830eb9816a79db5ec5fa7 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 18 Sep 2014 16:05:32 +1000 Subject: [PATCH 11/48] 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 From 575780ec0d32a3dda6f08b201eb5d6fdf128ee46 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 18 Sep 2014 17:13:53 +1000 Subject: [PATCH 12/48] Display format settings working. --- apps/opencs/view/settings/settingsdialog.cpp | 17 +++ files/ui/settingstab.ui | 133 ++++++++++++------- 2 files changed, 100 insertions(+), 50 deletions(-) diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index 886ba6da6..8cd811e11 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -309,6 +309,17 @@ void CSVSettings::SettingsDialog::setViewValues() // status bar cbStatusBar->setChecked(mModel->settingValue("Display/show statusbar") == "true"); + + // display format + QString recStat = mModel->settingValue("Display Format/Record Status Display"); + index = cmbRecStatus->findData(recStat, Qt::DisplayRole); + if(index != -1) + cmbRecStatus->setCurrentIndex(index); + + QString refIdType = mModel->settingValue("Display Format/Referenceable ID Type Display"); + index = cmbRefIdType->findData(refIdType, Qt::DisplayRole); + if(index != -1) + cmbRefIdType->setCurrentIndex(index); } void CSVSettings::SettingsDialog::saveSettings() @@ -381,6 +392,12 @@ void CSVSettings::SettingsDialog::saveSettings() else mModel->setDefinitions("Display/show statusbar", QStringList("false")); + // display format + mModel->setDefinitions("Display Format/Record Status Display", + QStringList(cmbRecStatus->currentText())); + mModel->setDefinitions("Display Format/Referenceable ID Type Display", + QStringList(cmbRefIdType->currentText())); + mModel->saveDefinitions(); } diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 0b365634e..ab559d9e7 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -227,24 +227,88 @@ Display Settings - + 10 10 371 - 71 + 81 - + Display Format + + + + 10 + 20 + 351 + 48 + + + + + + + Record Status: + + + + + + + + Text Only + + + + + Icon Only + + + + + Icon and Text + + + + + + + + Referenceable ID Type: + + + + + + + + Text Only + + + + + Icon Only + + + + + Icon and Text + + + + + + - + 9 - 110 + 140 371 111 @@ -253,51 +317,11 @@ Subviews - - - - 21 - 20 - 351 - 45 - - - - - - - Display Format: - - - - - - - - Text Only - - - - - Text + Icon - - - - - - - - Show Status Bar - - - - - 21 - 130 + 160 351 71 @@ -349,10 +373,19 @@ - groupBox_2 - groupBox - layoutWidget - layoutWidget2 + + + + 20 + 110 + 102 + 17 + + + + Show Status Bar + + From 52354b14fc308cccd07086c43e04db43fcc43368 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 18 Sep 2014 22:17:37 +1000 Subject: [PATCH 13/48] Fixed compilation issue on linux. Updated shader mode selection logic (thanks scrawl). Cleaned up a little but needs more once things are settled. --- apps/opencs/editor.cpp | 12 ++--- apps/opencs/model/settings/usersettings.cpp | 49 +++++++++++++------- apps/opencs/model/settings/usersettings.hpp | 1 + apps/opencs/view/settings/settingsdialog.cpp | 24 ++++++---- files/ui/settingstab.ui | 10 ---- 5 files changed, 53 insertions(+), 43 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 766726bce..d4ea32b26 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -299,14 +299,12 @@ std::auto_ptr CS::Editor::setupGraphics() std::auto_ptr factory (new sh::Factory (platform)); - std::string shLang = mUserSettings.settingValue("Shader/language").toStdString(); + std::string shLang = mUserSettings.settingValue("General/shader mode").toStdString(); enum sh::Language lang; - if(shLang == "CG") lang = sh::Language_CG; - else if(shLang == "HLSL") lang = sh::Language_HLSL; - else if(shLang == "GLSL") lang = sh::Language_GLSL; - else if(shLang == "GLSLES") lang = sh::Language_GLSLES; - else if(shLang == "Count") lang = sh::Language_Count; - else lang = sh::Language_None; + if(shLang == "glsl") lang = sh::Language_GLSL; + else if(shLang == "glsles") lang = sh::Language_GLSLES; + else if(shLang == "hlsl") lang = sh::Language_HLSL; + else lang = sh::Language_CG; factory->setCurrentLanguage (lang); factory->setWriteSourceCache (true); diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index e8ee98277..64d69eab8 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -347,24 +347,49 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName) #endif } mSettingCfgDefinitions->setValue("Video/render system", renderSystem.c_str()); + + std::string currShader = settings.getString("shader mode", "General"); + // can't call Ogre::Root at this point as it hasn't been initialised + QString rend = renderSystem.c_str(); + bool openGL = rend.contains(QRegExp("^OpenGL", Qt::CaseInsensitive)); + bool glES = rend.contains(QRegExp("^OpenGL ES", Qt::CaseInsensitive)); + // force shader language based on render system - if(renderSystem == "Direct3D9 Rendering Subsystem") - mSettingDefinitions->setValue("Shader/language", "CG"); - else - mSettingDefinitions->setValue("Shader/language", "GLSL"); + if(currShader == "" + || (openGL && currShader == "hlsl") + || (!openGL && currShader == "glsl") + || (glES && currShader != "glsles")) + { + QString shader = openGL ? (glES ? "glsles" : "glsl") : "hlsl"; + mSettingDefinitions->setValue("General/shader mode", shader); + } // check if override entry exists (default: override) if(!mSettingDefinitions->childGroups().contains("Video", Qt::CaseInsensitive)) mSettingDefinitions->setValue("Video/use settings.cfg", "true"); } +QStringList CSMSettings::UserSettings::getOgreRenderers() +{ + QStringList result; + + Ogre::RenderSystemList renderers = Ogre::Root::getSingleton().getAvailableRenderers(); + Ogre::RenderSystemList::iterator it = renderers.begin(); + for(; it != renderers.end(); ++it) + result.append((*it)->getName().c_str()); + + return result; +} + QStringList CSMSettings::UserSettings::getOgreOptions(const QString &key, const QString &renderer) { QStringList result; - Ogre::ConfigOptionMap& renderOpt = - //Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); - Ogre::Root::getSingleton().getRenderSystemByName(renderer.toStdString())->getConfigOptions(); + Ogre::RenderSystem *rend = Ogre::Root::getSingleton().getRenderSystem(); + if(!rend) + return result; + + Ogre::ConfigOptionMap& renderOpt = rend->getConfigOptions(); Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); uint row = 0; @@ -400,19 +425,11 @@ QStringList CSMSettings::UserSettings::getShaderLanguageByRenderer(const QString QStringList result; if(renderer == "Direct3D9 Rendering Subsystem") - { - result.append("CG"); result.append("HLSL"); - result.append("None"); - } else if(renderer == "OpenGL Rendering Subsystem") - { result.append("GLSL"); + else if(renderer.contains(QRegExp("^OpenGL ES", Qt::CaseInsensitive))) result.append("GLSLES"); - result.append("None"); - } - else - result.append("None"); return result; } diff --git a/apps/opencs/model/settings/usersettings.hpp b/apps/opencs/model/settings/usersettings.hpp index b45fa3d83..c957cd5b6 100644 --- a/apps/opencs/model/settings/usersettings.hpp +++ b/apps/opencs/model/settings/usersettings.hpp @@ -78,6 +78,7 @@ namespace CSMSettings { QStringList getShaderLanguageByRenderer(const QString &renderer); QStringList getOgreOptions(const QString &key, const QString &renderer); + QStringList getOgreRenderers(); private: diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index 8cd811e11..bd39056c2 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -93,7 +93,7 @@ QStringList getAvailableResolutions() return result; // FIXME: add error message } // Store Available Rendering Devices - std::vector::iterator iter = it->second.possibleValues.begin(); + Ogre::StringVector::iterator iter = it->second.possibleValues.begin(); for(;iter != it->second.possibleValues.end(); ++iter) { std::cout << "rd: " << *iter << std::endl; // FIXME: debug @@ -108,7 +108,7 @@ QStringList getAvailableResolutions() // FIXME: how to default to the current value? std::cout << "vm current: " << it->second.currentValue << std::endl; // FIXME: debug // Store Available Resolutions - std::vector::iterator iter = it->second.possibleValues.begin(); + Ogre::StringVector::iterator iter = it->second.possibleValues.begin(); for(; iter != it->second.possibleValues.end(); ++iter) { // extract x and y values @@ -202,7 +202,7 @@ void CSVSettings::SettingsDialog::slotRendererChanged(const QString &renderer) cmbRenderSys->setEnabled(false); labAntiAlias->setEnabled(false); cmbAntiAlias->setEnabled(false); - cbVsync->setEnabled(false); + //cbVsync->setEnabled(false); labShaderLang->setEnabled(false); cmbShaderLang->setEnabled(false); } @@ -218,7 +218,7 @@ void CSVSettings::SettingsDialog::slotOverrideToggled(bool checked) cmbRenderSys->setEnabled(false); labAntiAlias->setEnabled(false); cmbAntiAlias->setEnabled(false); - cbVsync->setEnabled(false); + //cbVsync->setEnabled(false); labShaderLang->setEnabled(false); cmbShaderLang->setEnabled(false); } @@ -228,7 +228,7 @@ void CSVSettings::SettingsDialog::slotOverrideToggled(bool checked) cmbRenderSys->setEnabled(true); labAntiAlias->setEnabled(true); cmbAntiAlias->setEnabled(true); - cbVsync->setEnabled(true); + //cbVsync->setEnabled(true); labShaderLang->setEnabled(true); cmbShaderLang->setEnabled(true); } @@ -257,8 +257,10 @@ void CSVSettings::SettingsDialog::setViewValues() // initialised in the constructor slotOverrideToggled(cbOverride->isChecked()); - // Ogre initialised earlier - slotRendererChanged(Ogre::Root::getSingleton().getRenderSystem()->getName().c_str()); + // Ogre renderer + cmbRenderSys->clear(); + cmbRenderSys->addItems(mModel->getOgreRenderers()); + //slotRendererChanged(Ogre::Root::getSingleton().getRenderSystem()->getName().c_str()); // antialiasing QString antialiasing = mModel->settingValue("Video/antialiasing"); @@ -267,10 +269,12 @@ void CSVSettings::SettingsDialog::setViewValues() cmbAntiAlias->setCurrentIndex(index); // vsync - cbVsync->setChecked(mModel->settingValue("Video/vsync") == "true"); + //cbVsync->setChecked(mModel->settingValue("Video/vsync") == "true"); + cbVsync->setChecked(false); // disable vsync option for now + cbVsync->setEnabled(false); // disable vsync option for now // shader lang - QString shaderlang = mModel->settingValue("Shader/language"); + QString shaderlang = mModel->settingValue("General/shader mode"); index = cmbShaderLang->findData(shaderlang, Qt::DisplayRole); if(index != -1) cmbShaderLang->setCurrentIndex(index); @@ -366,7 +370,7 @@ void CSVSettings::SettingsDialog::saveSettings() // shader lang mModel->setDefinitions("Shader/language", - QStringList(cmbShaderLang->currentText())); + QStringList(cmbShaderLang->currentText().toLower())); // window size if(rbStdWinSize->isChecked()) diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index ab559d9e7..c818e3c7d 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -52,16 +52,6 @@ false - - - OpenGL Rendering Subsystem - - - - - Direct3D9 Rendering Subsystem - - From 5dfcd2ed01e7fe0ab4225848a28e4d4cbb10acf2 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 19 Sep 2014 08:29:06 +1000 Subject: [PATCH 14/48] Removed standard window size combobox. Rearranged widgets. --- apps/opencs/model/settings/usersettings.cpp | 17 +- apps/opencs/model/settings/usersettings.hpp | 2 + apps/opencs/view/settings/settingsdialog.cpp | 20 +-- files/ui/settingstab.ui | 178 ++++++++----------- 4 files changed, 98 insertions(+), 119 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 64d69eab8..b3f17a4ff 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -371,21 +371,22 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName) QStringList CSMSettings::UserSettings::getOgreRenderers() { - QStringList result; - - Ogre::RenderSystemList renderers = Ogre::Root::getSingleton().getAvailableRenderers(); - Ogre::RenderSystemList::iterator it = renderers.begin(); - for(; it != renderers.end(); ++it) - result.append((*it)->getName().c_str()); + if(mOgreRenderers.empty()) + { + Ogre::RenderSystemList renderers = Ogre::Root::getSingleton().getAvailableRenderers(); + Ogre::RenderSystemList::iterator it = renderers.begin(); + for(; it != renderers.end(); ++it) + mOgreRenderers.append((*it)->getName().c_str()); + } - return result; + return mOgreRenderers; } QStringList CSMSettings::UserSettings::getOgreOptions(const QString &key, const QString &renderer) { QStringList result; - Ogre::RenderSystem *rend = Ogre::Root::getSingleton().getRenderSystem(); + Ogre::RenderSystem *rend = Ogre::Root::getSingleton().getRenderSystemByName(renderer.toStdString()); if(!rend) return result; diff --git a/apps/opencs/model/settings/usersettings.hpp b/apps/opencs/model/settings/usersettings.hpp index c957cd5b6..dfefb131a 100644 --- a/apps/opencs/model/settings/usersettings.hpp +++ b/apps/opencs/model/settings/usersettings.hpp @@ -35,6 +35,8 @@ namespace CSMSettings { QSettings *mSettingDefinitions; QSettings *mSettingCfgDefinitions; QList mSettings; + QStringList mOgreRenderers; + public: diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp index bd39056c2..7d5e5bec5 100644 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ b/apps/opencs/view/settings/settingsdialog.cpp @@ -154,7 +154,7 @@ 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))); + //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))); @@ -167,9 +167,9 @@ bool CSVSettings::SettingsDialog::eventFilter(QObject *target, QEvent *event) { if (!item->isEnabled() && (event->type() == QEvent::MouseButtonRelease)) { - rbCustWinSize->setChecked(false); - rbStdWinSize->setChecked(true); - slotStandardToggled(true); + //rbCustWinSize->setChecked(false); + //rbStdWinSize->setChecked(true); + //slotStandardToggled(true); return false; } @@ -178,9 +178,9 @@ bool CSVSettings::SettingsDialog::eventFilter(QObject *target, QEvent *event) { if (!item->isEnabled() && (event->type() == QEvent::MouseButtonPress)) { - rbStdWinSize->setChecked(false); - rbCustWinSize->setChecked(true); - slotStandardToggled(false); + //rbStdWinSize->setChecked(false); + //rbCustWinSize->setChecked(true); + //slotStandardToggled(false); return false; } @@ -307,7 +307,7 @@ void CSVSettings::SettingsDialog::setViewValues() if(index != -1) cmbStdWinSize->setCurrentIndex(index); - rbCustWinSize->setChecked(true); + //rbCustWinSize->setChecked(true); slotStandardToggled(false); } @@ -369,11 +369,11 @@ void CSVSettings::SettingsDialog::saveSettings() #endif // shader lang - mModel->setDefinitions("Shader/language", + mModel->setDefinitions("General/shader mode", QStringList(cmbShaderLang->currentText().toLower())); // window size - if(rbStdWinSize->isChecked()) + if(0) //rbStdWinSize->isChecked()) { QRegExp re("^(\\d+) x (\\d+)"); if(re.indexIn(cmbStdWinSize->currentText()) > -1) diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index c818e3c7d..f5b0e6a5b 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -14,7 +14,7 @@ User Settings - 0 + 1 @@ -76,18 +76,7 @@ - - - - GLSL - - - - - CG - - - + @@ -110,78 +99,6 @@ - - - - 20 - 188 - 351 - 51 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 186 - 16777215 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 180 - 0 - - - - - - - - Custom: - - - buttonGroup - - - - - - - - - - - - - - Standard: - - - true - - - buttonGroup - - - - - @@ -195,23 +112,22 @@ Render System - + - 10 - 170 + 9 + 169 371 - 81 + 101 - Window Size + Shader displayGroup_Render layoutWidget_Render - displayGroup_Window - layoutWidget_Window + groupBox @@ -229,7 +145,7 @@ Display Format - + 10 @@ -298,9 +214,9 @@ 9 - 140 + 160 371 - 111 + 101 @@ -311,7 +227,7 @@ 21 - 160 + 180 351 71 @@ -363,11 +279,56 @@ + + + + 10 + 100 + 191 + 51 + + + + Window Size + + + + + 10 + 20 + 171 + 22 + + + + + + + + 186 + 16777215 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + - 20 - 110 + 240 + 120 102 17 @@ -376,16 +337,31 @@ Show Status Bar + displayGroup_Window + displayGroup_DisplayFormat + displayGroup_Subviews + layoutWidget2 + cbStatusBar Misc Settings + + + false + + + + 70 + 100 + 69 + 22 + + + - - - From dbd1ab05d3d47754b29e127f1cde300477a9e304 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 21 Sep 2014 20:55:52 +1000 Subject: [PATCH 15/48] Integrated into the original settings design, except using tabs rather than list & stacked widgets. Works but visuals need updating. --- apps/opencs/CMakeLists.txt | 1 - apps/opencs/editor.hpp | 4 +- apps/opencs/model/settings/setting.cpp | 13 +- apps/opencs/model/settings/setting.hpp | 5 +- apps/opencs/model/settings/support.hpp | 12 +- apps/opencs/model/settings/usersettings.cpp | 181 ++++++- apps/opencs/view/settings/dialog.cpp | 375 +++++++++++++- apps/opencs/view/settings/dialog.hpp | 30 +- apps/opencs/view/settings/settingsdialog.cpp | 486 ------------------- apps/opencs/view/settings/settingsdialog.hpp | 64 --- apps/opencs/view/settings/settingwindow.cpp | 168 ++++++- apps/opencs/view/settings/settingwindow.hpp | 9 +- files/ui/settingstab.ui | 108 +++-- 13 files changed, 790 insertions(+), 666 deletions(-) delete mode 100644 apps/opencs/view/settings/settingsdialog.cpp delete mode 100644 apps/opencs/view/settings/settingsdialog.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 02a6c25a0..ad04b8a37 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -98,7 +98,6 @@ opencs_units_noqt (view/tools ) opencs_units (view/settings - settingsdialog settingwindow dialog page diff --git a/apps/opencs/editor.hpp b/apps/opencs/editor.hpp index 4ccc61a02..c87e24e77 100644 --- a/apps/opencs/editor.hpp +++ b/apps/opencs/editor.hpp @@ -26,7 +26,7 @@ #include "view/doc/filedialog.hpp" #include "view/doc/newgame.hpp" -#include "view/settings/settingsdialog.hpp" +#include "view/settings/dialog.hpp" namespace OgreInit { @@ -46,7 +46,7 @@ namespace CS CSVDoc::ViewManager mViewManager; CSVDoc::StartupDialogue mStartup; CSVDoc::NewGameDialogue mNewGame; - CSVSettings::SettingsDialog mSettings; + CSVSettings::Dialog mSettings; CSVDoc::FileDialog mFileDialog; boost::filesystem::path mLocal; boost::filesystem::path mResources; diff --git a/apps/opencs/model/settings/setting.cpp b/apps/opencs/model/settings/setting.cpp index 2f86d4ff8..9e1b497b1 100644 --- a/apps/opencs/model/settings/setting.cpp +++ b/apps/opencs/model/settings/setting.cpp @@ -2,7 +2,7 @@ #include "support.hpp" CSMSettings::Setting::Setting(SettingType typ, const QString &settingName, - const QString &pageName) + const QString &pageName, const QString §ion) : mIsEditorSetting (false) { buildDefaultSetting(); @@ -17,6 +17,7 @@ CSMSettings::Setting::Setting(SettingType typ, const QString &settingName, setProperty (Property_SettingType, QVariant (settingType).toString()); setProperty (Property_Page, pageName); setProperty (Property_Name, settingName); + setProperty (Property_Section, section); } void CSMSettings::Setting::buildDefaultSetting() @@ -194,6 +195,16 @@ QString CSMSettings::Setting::page() const return property (Property_Page).at(0); } +void CSMSettings::Setting::setSection (const QString &value) +{ + setProperty (Property_Section, value); +} + +QString CSMSettings::Setting::section() const +{ + return property (Property_Section).at(0); +} + void CSMSettings::Setting::setPrefix (const QString &value) { setProperty (Property_Prefix, value); diff --git a/apps/opencs/model/settings/setting.hpp b/apps/opencs/model/settings/setting.hpp index e40302f00..ed897e591 100644 --- a/apps/opencs/model/settings/setting.hpp +++ b/apps/opencs/model/settings/setting.hpp @@ -30,7 +30,7 @@ namespace CSMSettings public: explicit Setting(SettingType typ, const QString &settingName, - const QString &pageName); + const QString &pageName, const QString §ion = QString()); void addProxy (const Setting *setting, const QStringList &vals); void addProxy (const Setting *setting, const QList &list); @@ -80,6 +80,9 @@ namespace CSMSettings void setPage (const QString &value); QString page() const; + void setSection (const QString &value); + QString section() const; + void setPrefix (const QString &value); QString prefix() const; diff --git a/apps/opencs/model/settings/support.hpp b/apps/opencs/model/settings/support.hpp index 229e293b8..40db648dc 100644 --- a/apps/opencs/model/settings/support.hpp +++ b/apps/opencs/model/settings/support.hpp @@ -35,12 +35,13 @@ namespace CSMSettings Property_TickInterval = 19, Property_TicksAbove = 20, Property_TicksBelow = 21, + Property_Section = 22, //Stringlists should always be the last items - Property_DefaultValues = 22, - Property_DeclaredValues = 23, - Property_DefinedValues = 24, - Property_Proxies = 25 + Property_DefaultValues = 23, + Property_DeclaredValues = 24, + Property_DefinedValues = 25, + Property_Proxies = 26 }; ///Basic setting widget types. @@ -106,7 +107,7 @@ namespace CSMSettings "is_multi_line", "widget_width", "view_row", "view_column", "delimiter", "is_serializable","column_span", "row_span", "minimum", "maximum", "special_value_text", "prefix", "suffix", "single_step", "wrapping", - "tick_interval", "ticks_above", "ticks_below", + "tick_interval", "ticks_above", "ticks_below", "section", "defaults", "declarations", "definitions", "proxies" }; @@ -135,6 +136,7 @@ namespace CSMSettings "1", //tick interval "false", //ticks above "true", //ticks below + "", //Section "", //default values "", //declared values "", //defined values diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index b3f17a4ff..664865289 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -32,9 +32,12 @@ namespace boost } /* namespace boost */ #endif /* (BOOST_VERSION <= 104600) */ -CSMSettings::UserSettings *CSMSettings::UserSettings::mUserSettingsInstance = 0; +namespace CSMSettings +{ + +UserSettings *UserSettings::mUserSettingsInstance = 0; -CSMSettings::UserSettings::UserSettings (const Files::ConfigurationManager& configurationManager) +UserSettings::UserSettings (const Files::ConfigurationManager& configurationManager) : mCfgMgr (configurationManager) , mSettingDefinitions(NULL) , mSettingCfgDefinitions(NULL) @@ -48,9 +51,138 @@ CSMSettings::UserSettings::UserSettings (const Files::ConfigurationManager& conf mSettingCfgDefinitions = new QSettings(QSettings::IniFormat, QSettings::UserScope, "", QString(), this); } -void CSMSettings::UserSettings::buildSettingModelDefaults() +/* + * Original Design: + * + * + * QGridLayout QGroupBox + * ^ ^ + * | | + * | 1 | + * SettingLayout......Frame + * ^ ^ QMainWindow + * | | ^ QObject + * / \ | ^ + * / \ | | + * / \ 0..n | | 0..n + * View......Page........SettingWindow......UserSettings......Setting + * ^ 0..n ^ + * | | + * | | + * ListView, | + * TextView, etc | + * | + * | + * QStackedWidget QListWidget.....Dialog + * ^ : + * | : + * | : + * ResizeableStackedWidget..... + * + * + * When a Page is created with a list of Views, the Views are added to the Frame. + * + * Editor ctor + * -> Dialog ctor + * -> SettingWindow ctor + * -> SettingWindow::setModel() + * -> Dialog::setupDialog() + * -> buildPageListWidget + * -> buildStackedWidget + * + * Editor::showSettings() + * -> Dialog::show() + * -> Dialog::buildPages() <-- [first time only] + * -> SettingWindow::createPages() + * -> Page ctor + * -> Page::setupViews() + * -> Page::addView() + * -> Frame::addWidget() + * -> SettingLayout::addWidget() + * -> [add page widgets to the stack] + * + */ +/* + * Modified Design: + * + * +----------------------------------------+ + * |+---------+---------+---------+ | + * || | | | | + * || +----------------------------+| + * || || + * || +--------------------------------+ || + * || | | || + * || | View View | || + * || | View View | || + * || | | || + * || +---- Section -------------------+ || + * || || + * || +--------------------------------+ || + * || | | || + * || | +-------------+ | || + * || | | View/Frame | | || + * || | +-------------+ | || + * || | | || + * || +---- Section -------------------+ || + * || || + * || || + * |+-------------- Page ------------------+| + * +---------- SettingWindow ---------------+ + * + * + * + * QGridLayout QGroupBox + * ^ ^ + * | | + * | 1 | + * SettingLayout......Frame + * ^ ^ QTabWidget + * | | ^ QObject + * / \ | ^ + * / \ | | + * / \ 0..n | | 0..n + * View......Page........SettingWindow......UserSettings......Setting + * ^ 0..n ^ + * | | + * | Ui::TabWidget | + * ListView, ^ | + * TextView, etc | | + * \ | + * \ | + * \ | + * Dialog + * + * + * + * + * + * View/Page is still used to uniquely identify a setting (i.e. Section is for + * visual presentation only). This means all views on a page should be unique + * (as before) + * + * + * Editor ctor + * -> Dialog ctor + * -> SettingWindow ctor + * -> SettingWindow::setModel() + * -> Dialog::setupDialog() <-- [no longer required] + * + * Editor::showSettings() + * -> Dialog::show() + * -> Dialog::buildPages() <-- [first time only] + * -> SettingWindow::createPages() + * -> Page ctor + * -> Page::setupViews() + * -> Page::addView() + * -> Frame::addWidget() + * -> SettingLayout::addWidget() + * -> [add pages to tabs then call showWidgets()] + */ +void UserSettings::buildSettingModelDefaults() { - QString section = "Window Size"; + QString section; + + section = "Window Size"; { Setting *width = createSetting (Type_LineEdit, section, "Width"); Setting *height = createSetting (Type_LineEdit, section, "Height"); @@ -283,12 +415,12 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() } } -CSMSettings::UserSettings::~UserSettings() +UserSettings::~UserSettings() { mUserSettingsInstance = 0; } -void CSMSettings::UserSettings::loadSettings (const QString &fileName) +void UserSettings::loadSettings (const QString &fileName) { QString userFilePath = QString::fromUtf8 (mCfgMgr.getUserConfigPath().string().c_str()); @@ -369,7 +501,7 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName) mSettingDefinitions->setValue("Video/use settings.cfg", "true"); } -QStringList CSMSettings::UserSettings::getOgreRenderers() +QStringList UserSettings::getOgreRenderers() { if(mOgreRenderers.empty()) { @@ -382,7 +514,7 @@ QStringList CSMSettings::UserSettings::getOgreRenderers() return mOgreRenderers; } -QStringList CSMSettings::UserSettings::getOgreOptions(const QString &key, const QString &renderer) +QStringList UserSettings::getOgreOptions(const QString &key, const QString &renderer) { QStringList result; @@ -421,7 +553,7 @@ QStringList CSMSettings::UserSettings::getOgreOptions(const QString &key, const return result; } -QStringList CSMSettings::UserSettings::getShaderLanguageByRenderer(const QString &renderer) +QStringList UserSettings::getShaderLanguageByRenderer(const QString &renderer) { QStringList result; @@ -435,24 +567,22 @@ QStringList CSMSettings::UserSettings::getShaderLanguageByRenderer(const QString return result; } -bool CSMSettings::UserSettings::hasSettingDefinitions - (const QString &viewKey) const +bool UserSettings::hasSettingDefinitions (const QString &viewKey) const { return (mSettingDefinitions->contains (viewKey)); } -void CSMSettings::UserSettings::setDefinitions - (const QString &key, const QStringList &list) +void UserSettings::setDefinitions (const QString &key, const QStringList &list) { mSettingDefinitions->setValue (key, list); } -void CSMSettings::UserSettings::saveDefinitions() const +void UserSettings::saveDefinitions() const { mSettingDefinitions->sync(); } -QString CSMSettings::UserSettings::settingValue (const QString &settingKey) +QString UserSettings::settingValue (const QString &settingKey) { QStringList defs; @@ -480,22 +610,20 @@ QString CSMSettings::UserSettings::settingValue (const QString &settingKey) return defs.at(0); } -CSMSettings::UserSettings& CSMSettings::UserSettings::instance() +UserSettings& UserSettings::instance() { assert(mUserSettingsInstance); return *mUserSettingsInstance; } -void CSMSettings::UserSettings::updateUserSetting(const QString &settingKey, - const QStringList &list) +void UserSettings::updateUserSetting(const QString &settingKey, const QStringList &list) { mSettingDefinitions->setValue (settingKey ,list); emit userSettingUpdated (settingKey, list); } -CSMSettings::Setting *CSMSettings::UserSettings::findSetting - (const QString &pageName, const QString &settingName) +Setting *UserSettings::findSetting (const QString &pageName, const QString &settingName) { foreach (Setting *setting, mSettings) { @@ -508,8 +636,7 @@ CSMSettings::Setting *CSMSettings::UserSettings::findSetting return 0; } -void CSMSettings::UserSettings::removeSetting - (const QString &pageName, const QString &settingName) +void UserSettings::removeSetting (const QString &pageName, const QString &settingName) { if (mSettings.isEmpty()) return; @@ -530,7 +657,7 @@ void CSMSettings::UserSettings::removeSetting } } -CSMSettings::SettingPageMap CSMSettings::UserSettings::settingPageMap() const +SettingPageMap UserSettings::settingPageMap() const { SettingPageMap pageMap; @@ -540,8 +667,8 @@ CSMSettings::SettingPageMap CSMSettings::UserSettings::settingPageMap() const return pageMap; } -CSMSettings::Setting *CSMSettings::UserSettings::createSetting - (CSMSettings::SettingType typ, const QString &page, const QString &name) +Setting *UserSettings::createSetting + (SettingType typ, const QString &page, const QString &name) { //get list of all settings for the current setting name if (findSetting (page, name)) @@ -560,10 +687,12 @@ CSMSettings::Setting *CSMSettings::UserSettings::createSetting return setting; } -QStringList CSMSettings::UserSettings::definitions (const QString &viewKey) const +QStringList UserSettings::definitions (const QString &viewKey) const { if (mSettingDefinitions->contains (viewKey)) return mSettingDefinitions->value (viewKey).toStringList(); return QStringList(); } + +} diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index 72a022c9d..e9ae194ce 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -1,39 +1,233 @@ #include "dialog.hpp" -#include +//#include #include +#include #include -#include -#include +//#include +//#include #include "../../model/settings/usersettings.hpp" #include "page.hpp" -#include +//#include -#include +//#include -#include -#include -#include +//#include +//#include +//#include #include #include -CSVSettings::Dialog::Dialog(QMainWindow *parent) - : mStackedWidget (0), mDebugMode (false), SettingWindow (parent) +#include +#include + +namespace { + +QRect getMaximumResolution() +{ + 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; +} + +QString getAspect(int x, int y) +{ + 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"); + + return QString(QString::number(xaspect) + ":" + QString::number(yaspect)); +} + +QString getCurrentOgreResolution() +{ + 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 +} + +bool customCompare(const QString &s1, const QString &s2) +{ + int x1, x2, y1, y2; + QRegExp re("^(\\d+) x (\\d+)"); + + 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() { - setWindowTitle(QString::fromUtf8 ("User Settings")); + // 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 == "Rendering Device" ) + { + if(it->second.possibleValues.empty()) + { + return result; // FIXME: add error message + } + // Store Available Rendering Devices + Ogre::StringVector::iterator iter = it->second.possibleValues.begin(); + for(;iter != it->second.possibleValues.end(); ++iter) + { + std::cout << "rd: " << *iter << std::endl; // FIXME: debug + } + } + if(it->first == "Video Mode" ) + { + if(it->second.possibleValues.empty()) + { + return result; // FIXME: add error message + } + // FIXME: how to default to the current value? + std::cout << "vm current: " << it->second.currentValue << std::endl; // FIXME: debug + // 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) + : /*mStackedWidget (0),*/ 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&))); + // to update the checkbox on the view menu + connect(cbStatusBar, SIGNAL(toggled(bool)), this, SIGNAL (toggleStatusBar(bool))); setupDialog(); +#if 0 + // FIXME: delete - don't need this for tabs connect (mPageListWidget, SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*))); +#endif +} + +void CSVSettings::Dialog::slotRendererChanged(const QString &renderer) +{ + cmbAntiAlias->clear(); + cmbAntiAlias->addItems(model()->getOgreOptions(QString("FSAA"), renderer)); + + cmbShaderLang->clear(); + cmbShaderLang->addItems(model()->getShaderLanguageByRenderer(renderer)); + + if(model()->settingValue("Video/use settings.cfg") == "true") + { + labRenderSys->setEnabled(false); + cmbRenderSys->setEnabled(false); + labAntiAlias->setEnabled(false); + cmbAntiAlias->setEnabled(false); + //cbVsync->setEnabled(false); + labShaderLang->setEnabled(false); + cmbShaderLang->setEnabled(false); + } + else + cbOverride->setChecked(false); +} + +void CSVSettings::Dialog::slotOverrideToggled(bool checked) +{ + if(checked) + { + labRenderSys->setEnabled(false); + cmbRenderSys->setEnabled(false); + labAntiAlias->setEnabled(false); + cmbAntiAlias->setEnabled(false); + //cbVsync->setEnabled(false); + labShaderLang->setEnabled(false); + cmbShaderLang->setEnabled(false); + } + else + { + labRenderSys->setEnabled(true); + cmbRenderSys->setEnabled(true); + labAntiAlias->setEnabled(true); + cmbAntiAlias->setEnabled(true); + //cbVsync->setEnabled(true); + labShaderLang->setEnabled(true); + cmbShaderLang->setEnabled(true); + } } +#if 0 +// FIXME: delete - not required for tabs void CSVSettings::Dialog::slotChangePage (QListWidgetItem *cur, QListWidgetItem *prev) { @@ -43,9 +237,11 @@ void CSVSettings::Dialog::slotChangePage layout()->activate(); setFixedSize(minimumSizeHint()); } +#endif void CSVSettings::Dialog::setupDialog() { +#if 0 //create central widget with it's layout and immediate children QWidget *centralWidget = new QGroupBox (this); @@ -56,29 +252,112 @@ void CSVSettings::Dialog::setupDialog() buildPageListWidget (centralWidget); buildStackedWidget (centralWidget); +#endif } void CSVSettings::Dialog::buildPages() { + int index = -1; + + // initialised in the constructor + slotOverrideToggled(cbOverride->isChecked()); + + // Ogre renderer + cmbRenderSys->clear(); + cmbRenderSys->addItems(model()->getOgreRenderers()); + //slotRendererChanged(Ogre::Root::getSingleton().getRenderSystem()->getName().c_str()); + + // antialiasing + QString antialiasing = model()->settingValue("Video/antialiasing"); + index = cmbAntiAlias->findData(antialiasing, Qt::DisplayRole); + if(index != -1) + cmbAntiAlias->setCurrentIndex(index); + + // vsync + //cbVsync->setChecked(model()->settingValue("Video/vsync") == "true"); + cbVsync->setChecked(false); // disable vsync option for now + cbVsync->setEnabled(false); // disable vsync option for now + + // 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); + //slotStandardToggled(true); + } + else + { + // show what's in Ogre instead + index = cmbStdWinSize->findData(getCurrentOgreResolution(), + Qt::DisplayRole, Qt::MatchStartsWith); + if(index != -1) + cmbStdWinSize->setCurrentIndex(index); + + //rbCustWinSize->setChecked(true); + //slotStandardToggled(false); + } + + // status bar + cbStatusBar->setChecked(model()->settingValue("Display/show statusbar") == "true"); + + // display format + QString recStat = model()->settingValue("Display Format/Record Status Display"); + index = cmbRecStatus->findData(recStat, Qt::DisplayRole); + if(index != -1) + cmbRecStatus->setCurrentIndex(index); + + QString refIdType = model()->settingValue("Display Format/Referenceable ID Type Display"); + index = cmbRefIdType->findData(refIdType, Qt::DisplayRole); + if(index != -1) + cmbRefIdType->setCurrentIndex(index); + SettingWindow::createPages (); - QFontMetrics fm (QApplication::font()); + //QFontMetrics fm (QApplication::font()); foreach (Page *page, SettingWindow::pages()) { QString pageName = page->objectName(); - int textWidth = fm.width(pageName); + //int textWidth = fm.width(pageName); + + // each page is added as a tab to Ui::TabWiget + addTab(page, page->objectName()); + + // add section and views to the page + buildTabPage(page); + page->showWidgets(); - new QListWidgetItem (pageName, mPageListWidget); - mPageListWidget->setFixedWidth (textWidth + 50); + //new QListWidgetItem (pageName, mPageListWidget); + //mPageListWidget->setFixedWidth (textWidth + 50); - mStackedWidget->addWidget (&dynamic_cast(*(page))); + //mStackedWidget->addWidget (&dynamic_cast(*(page))); } - resize (mStackedWidget->sizeHint()); + //resize (mStackedWidget->sizeHint()); } +#if 0 +// FIXME: delete - not required, using tabs instead void CSVSettings::Dialog::buildPageListWidget (QWidget *centralWidget) { mPageListWidget = new QListWidget (centralWidget); @@ -96,6 +375,7 @@ void CSVSettings::Dialog::buildStackedWidget (QWidget *centralWidget) centralWidget->layout()->addWidget (mStackedWidget); } +#endif void CSVSettings::Dialog::closeEvent (QCloseEvent *event) { @@ -103,6 +383,67 @@ 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())); + + // vsync + if(cbVsync->isChecked()) + model()->setDefinitions("Video/vsync", QStringList("true")); + else + model()->setDefinitions("Video/vsync", QStringList("false")); + + // antialiasing + model()->setDefinitions("Video/antialiasing", + QStringList(cmbAntiAlias->currentText())); +#if 0 + QRegExp reAA("^\\D*(\\d+)\\D*"); + if(reAA.indexIn(cmbAntiAlias->currentText()) > -1) + model()->setDefinitions("Video/antialiasing", QStringList(reAA.cap(1))); +#endif + + // shader lang + model()->setDefinitions("General/shader mode", + QStringList(cmbShaderLang->currentText().toLower())); + + // window size + if(0) //rbStdWinSize->isChecked()) + { + 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")); + + // display format + model()->setDefinitions("Display Format/Record Status Display", + QStringList(cmbRecStatus->currentText())); + model()->setDefinitions("Display Format/Referenceable ID Type Display", + QStringList(cmbRefIdType->currentText())); + + std::cout << "closeEvent" << std::endl; + saveSettings(); } diff --git a/apps/opencs/view/settings/dialog.hpp b/apps/opencs/view/settings/dialog.hpp index b0e12c461..c82df8dad 100644 --- a/apps/opencs/view/settings/dialog.hpp +++ b/apps/opencs/view/settings/dialog.hpp @@ -2,28 +2,30 @@ #define CSVSETTINGS_DIALOG_H #include "settingwindow.hpp" -#include "resizeablestackedwidget.hpp" +//#include "resizeablestackedwidget.hpp" #include -class QStackedWidget; -class QListWidget; -class QListWidgetItem; +//class QStackedWidget; +//class QListWidget; +//class QListWidgetItem; + +#include "ui_settingstab.h" namespace CSVSettings { class Page; - class Dialog : public SettingWindow + class Dialog : public SettingWindow, private Ui::TabWidget { Q_OBJECT - QListWidget *mPageListWidget; - ResizeableStackedWidget *mStackedWidget; + //QListWidget *mPageListWidget; + //ResizeableStackedWidget *mStackedWidget; bool mDebugMode; public: - explicit Dialog (QMainWindow *parent = 0); + explicit Dialog (QTabWidget *parent = 0); ///Enables setting debug mode. When the dialog opens, a page is created ///which displays the SettingModel's contents in a Tree view. @@ -39,8 +41,8 @@ namespace CSVSettings { private: void buildPages(); - void buildPageListWidget (QWidget *centralWidget); - void buildStackedWidget (QWidget *centralWidget); + //void buildPageListWidget (QWidget *centralWidget); + //void buildStackedWidget (QWidget *centralWidget); public slots: @@ -48,7 +50,13 @@ namespace CSVSettings { private slots: - void slotChangePage (QListWidgetItem *, QListWidgetItem *); + //void slotChangePage (QListWidgetItem *, QListWidgetItem *); // FIXME: delete + void slotOverrideToggled(bool checked); + void slotRendererChanged(const QString &renderer); + + signals: + + void toggleStatusBar(bool checked); // FIXME: maybe not needed }; } #endif // CSVSETTINGS_DIALOG_H diff --git a/apps/opencs/view/settings/settingsdialog.cpp b/apps/opencs/view/settings/settingsdialog.cpp deleted file mode 100644 index 7d5e5bec5..000000000 --- a/apps/opencs/view/settings/settingsdialog.cpp +++ /dev/null @@ -1,486 +0,0 @@ -#include "settingsdialog.hpp" - -#include -#include - -#include - -#include "../../model/settings/usersettings.hpp" - -namespace -{ -// copied from the launcher & adapted - -QString getAspect(int x, int y) -{ - 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"); - - return QString(QString::number(xaspect) + ":" + QString::number(yaspect)); -} - -QRect getMaximumResolution() -{ - 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; -} - -QString getCurrentOgreResolution() -{ - 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 -} - -bool customCompare(const QString &s1, const QString &s2) -{ - int x1, x2, y1, y2; - QRegExp re("^(\\d+) x (\\d+)"); - - 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 == "Rendering Device" ) - { - if(it->second.possibleValues.empty()) - { - return result; // FIXME: add error message - } - // Store Available Rendering Devices - Ogre::StringVector::iterator iter = it->second.possibleValues.begin(); - for(;iter != it->second.possibleValues.end(); ++iter) - { - std::cout << "rd: " << *iter << std::endl; // FIXME: debug - } - } - if(it->first == "Video Mode" ) - { - if(it->second.possibleValues.empty()) - { - return result; // FIXME: add error message - } - // FIXME: how to default to the current value? - std::cout << "vm current: " << it->second.currentValue << std::endl; // FIXME: debug - // 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::SettingsDialog::SettingsDialog(QTabWidget *parent) - : QTabWidget (parent) -{ - setObjectName("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()); - - // to enable mouse events on disabled widgets - cmbStdWinSize->installEventFilter(this); - sbWidth->installEventFilter(this); - sbHeight->installEventFilter(this); - - 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) -{ - QWidget *item = qobject_cast(target); - if (target == cmbStdWinSize) - { - if (!item->isEnabled() && (event->type() == QEvent::MouseButtonRelease)) - { - //rbCustWinSize->setChecked(false); - //rbStdWinSize->setChecked(true); - //slotStandardToggled(true); - - return false; - } - } - else if (target == sbWidth || target == sbHeight) - { - if (!item->isEnabled() && (event->type() == QEvent::MouseButtonPress)) - { - //rbStdWinSize->setChecked(false); - //rbCustWinSize->setChecked(true); - //slotStandardToggled(false); - - return false; - } - } - return QTabWidget::eventFilter(target, event); -} - -void CSVSettings::SettingsDialog::slotRendererChanged(const QString &renderer) -{ - cmbAntiAlias->clear(); - cmbAntiAlias->addItems(mModel->getOgreOptions(QString("FSAA"), renderer)); - - cmbShaderLang->clear(); - cmbShaderLang->addItems(mModel->getShaderLanguageByRenderer(renderer)); - - if(mModel->settingValue("Video/use settings.cfg") == "true") - { - labRenderSys->setEnabled(false); - cmbRenderSys->setEnabled(false); - labAntiAlias->setEnabled(false); - cmbAntiAlias->setEnabled(false); - //cbVsync->setEnabled(false); - labShaderLang->setEnabled(false); - cmbShaderLang->setEnabled(false); - } - else - cbOverride->setChecked(false); -} - -void CSVSettings::SettingsDialog::slotOverrideToggled(bool checked) -{ - if(checked) - { - labRenderSys->setEnabled(false); - cmbRenderSys->setEnabled(false); - labAntiAlias->setEnabled(false); - cmbAntiAlias->setEnabled(false); - //cbVsync->setEnabled(false); - labShaderLang->setEnabled(false); - cmbShaderLang->setEnabled(false); - } - else - { - labRenderSys->setEnabled(true); - cmbRenderSys->setEnabled(true); - labAntiAlias->setEnabled(true); - cmbAntiAlias->setEnabled(true); - //cbVsync->setEnabled(true); - labShaderLang->setEnabled(true); - cmbShaderLang->setEnabled(true); - } -} - -void CSVSettings::SettingsDialog::slotStandardToggled(bool checked) -{ - if (checked) - { - cmbStdWinSize->setEnabled(true); - sbWidth->setEnabled(false); - sbHeight->setEnabled(false); - } - else - { - cmbStdWinSize->setEnabled(false); - sbWidth->setEnabled(true); - sbHeight->setEnabled(true); - } -} - -void CSVSettings::SettingsDialog::setViewValues() -{ - int index = -1; - - // initialised in the constructor - slotOverrideToggled(cbOverride->isChecked()); - - // Ogre renderer - cmbRenderSys->clear(); - cmbRenderSys->addItems(mModel->getOgreRenderers()); - //slotRendererChanged(Ogre::Root::getSingleton().getRenderSystem()->getName().c_str()); - - // antialiasing - QString antialiasing = mModel->settingValue("Video/antialiasing"); - index = cmbAntiAlias->findData(antialiasing, Qt::DisplayRole); - if(index != -1) - cmbAntiAlias->setCurrentIndex(index); - - // vsync - //cbVsync->setChecked(mModel->settingValue("Video/vsync") == "true"); - cbVsync->setChecked(false); // disable vsync option for now - cbVsync->setEnabled(false); // disable vsync option for now - - // shader lang - QString shaderlang = mModel->settingValue("General/shader mode"); - index = cmbShaderLang->findData(shaderlang, Qt::DisplayRole); - if(index != -1) - cmbShaderLang->setCurrentIndex(index); - - if(mModel->settingValue("Window Size/Width") != "") - sbWidth->setValue(mModel->settingValue("Window Size/Width").toInt()); - - if(mModel->settingValue("Window Size/Height") != "") - sbHeight->setValue(mModel->settingValue("Window Size/Height").toInt()); - - // update display resolution combo box - cmbStdWinSize->clear(); - cmbStdWinSize->addItems(getAvailableResolutions()); - - QString currRes = mModel->settingValue("Window Size/Width") + " x " + - mModel->settingValue("Window Size/Height"); - - index = cmbStdWinSize->findData(currRes, Qt::DisplayRole, Qt::MatchStartsWith); - if(index != -1) - { - // show the values in ini file - cmbStdWinSize->setCurrentIndex(index); - slotStandardToggled(true); - } - else - { - // show what's in Ogre instead - 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"); - - // display format - QString recStat = mModel->settingValue("Display Format/Record Status Display"); - index = cmbRecStatus->findData(recStat, Qt::DisplayRole); - if(index != -1) - cmbRecStatus->setCurrentIndex(index); - - QString refIdType = mModel->settingValue("Display Format/Referenceable ID Type Display"); - index = cmbRefIdType->findData(refIdType, Qt::DisplayRole); - if(index != -1) - cmbRefIdType->setCurrentIndex(index); -} - -void CSVSettings::SettingsDialog::saveSettings() -{ -#if 0 - //setting the definition in the model automatically syncs with the file - foreach (const Page *page, mPages) - { - foreach (const View *view, page->views()) - { - if (!view->serializable()) - continue; - - mModel->setDefinitions (view->viewKey(), view->selectedValues()); - } - } -#endif - std::cout << "closeEvent" << std::endl; - - // override - if(cbOverride->isChecked()) - mModel->setDefinitions("Video/use settings.cfg", QStringList("true")); - else - mModel->setDefinitions("Video/use settings.cfg", QStringList("false")); - - // render system - mModel->setDefinitions("Video/render system", - QStringList(cmbRenderSys->currentText())); - - // vsync - if(cbVsync->isChecked()) - mModel->setDefinitions("Video/vsync", QStringList("true")); - else - mModel->setDefinitions("Video/vsync", QStringList("false")); - - // antialiasing - mModel->setDefinitions("Video/antialiasing", - QStringList(cmbAntiAlias->currentText())); -#if 0 - QRegExp reAA("^\\D*(\\d+)\\D*"); - if(reAA.indexIn(cmbAntiAlias->currentText()) > -1) - mModel->setDefinitions("Video/antialiasing", QStringList(reAA.cap(1))); -#endif - - // shader lang - mModel->setDefinitions("General/shader mode", - QStringList(cmbShaderLang->currentText().toLower())); - - // window size - if(0) //rbStdWinSize->isChecked()) - { - QRegExp re("^(\\d+) x (\\d+)"); - if(re.indexIn(cmbStdWinSize->currentText()) > -1) - { - mModel->setDefinitions("Window Size/Width", QStringList(re.cap(1))); - mModel->setDefinitions("Window Size/Height", QStringList(re.cap(2))); - } - } - else - { - mModel->setDefinitions("Window Size/Width", - QStringList(QString::number(sbWidth->value()))); - mModel->setDefinitions("Window Size/Height", - 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")); - - // display format - mModel->setDefinitions("Display Format/Record Status Display", - QStringList(cmbRecStatus->currentText())); - mModel->setDefinitions("Display Format/Referenceable ID Type Display", - QStringList(cmbRefIdType->currentText())); - - mModel->saveDefinitions(); -} - -void CSVSettings::SettingsDialog::createConnections - (const QList &list) -{ -#if 0 - foreach (const CSMSettings::Setting *setting, list) - { - View *masterView = findView (setting->page(), setting->name()); - - CSMSettings::Connector *connector = - new CSMSettings::Connector (masterView, this); - - connect (masterView, - SIGNAL (viewUpdated(const QString &, const QStringList &)), - connector, - SLOT (slotUpdateSlaves()) - ); - - const CSMSettings::ProxyValueMap &proxyMap = setting->proxyLists(); - - foreach (const QString &key, proxyMap.keys()) - { - QStringList keyPair = key.split('/'); - - if (keyPair.size() != 2) - continue; - - View *slaveView = findView (keyPair.at(0), keyPair.at(1)); - - if (!slaveView) - { - qWarning () << "Unable to create connection for view " - << key; - continue; - } - - QList proxyList = proxyMap.value (key); - connector->addSlaveView (slaveView, proxyList); - - connect (slaveView, - SIGNAL (viewUpdated(const QString &, const QStringList &)), - connector, - SLOT (slotUpdateMaster())); - } - } -#endif -} - -void CSVSettings::SettingsDialog::closeEvent (QCloseEvent *event) -{ - //SettingWindow::closeEvent() must be called first to ensure - //model is updated - //SettingWindow::closeEvent (event); - QApplication::focusWidget()->clearFocus(); - - saveSettings(); -} - -void CSVSettings::SettingsDialog::show() -{ - setViewValues(); - - // place the widget and make it visible - 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)); - } - QWidget::show(); -} diff --git a/apps/opencs/view/settings/settingsdialog.hpp b/apps/opencs/view/settings/settingsdialog.hpp deleted file mode 100644 index 3dda0700c..000000000 --- a/apps/opencs/view/settings/settingsdialog.hpp +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef CSVSETTINGS_SETTINGSDIALOG_H -#define CSVSETTINGS_SETTINGSDIALOG_H - -#include - -#include "ui_settingstab.h" - -class QListWidgetItem; - -namespace CSMSettings -{ - class Setting; - class UserSettings; -} - -namespace CSVSettings { - - class SettingsDialog : public QTabWidget, private Ui::TabWidget - { - Q_OBJECT - - CSMSettings::UserSettings *mModel; - - public: - - SettingsDialog (QTabWidget *parent = 0); - - ///set the model the view uses (instance of UserSettings) - void setModel (CSMSettings::UserSettings &model) { mModel = &model; } - - protected: - - ///save settings from the GUI to file - void saveSettings(); - - /// Settings are written on close - void closeEvent (QCloseEvent *event); - - bool eventFilter(QObject *target, QEvent *event); - - private: - - ///sets the defined values for the views that have been created - void setViewValues(); - - ///create connections between settings (used for proxy settings) - void createConnections (const QList &list); - - public slots: - - void show(); - - //void slotStandardClicked(); - //void slotCustomClicked(); - 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/apps/opencs/view/settings/settingwindow.cpp b/apps/opencs/view/settings/settingwindow.cpp index 7cdf2bded..f016f1e3d 100644 --- a/apps/opencs/view/settings/settingwindow.cpp +++ b/apps/opencs/view/settings/settingwindow.cpp @@ -1,15 +1,19 @@ +#include "settingwindow.hpp" + #include +//#include +//#include +//#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(QWidget *parent) - : QMainWindow(parent) +CSVSettings::SettingWindow::SettingWindow(QTabWidget *parent) + : QTabWidget(parent) {} void CSVSettings::SettingWindow::createPages() @@ -19,7 +23,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)); @@ -37,6 +41,162 @@ void CSVSettings::SettingWindow::createPages() createConnections(connectedSettings); } +void CSVSettings::SettingWindow::buildTabPage(Page* tab) +{ + CSMSettings::SettingPageMap pageMap = mModel->settingPageMap(); + QList pageSettings = pageMap.value (tab->objectName()); + //tab->setupViews(pageSettings); +#if 0 + QFontMetrics fm (QApplication::font()); + //int textWidth = fm.width(pageName); // FIXME: + QString pageName = tab->objectName(); + + std::cout << "pageName: " + pageName.toStdString() << std::endl; // FIXME: + QList settingList = mModel->settingPageMap.value(pageName); + //foreach (View *view, page->views()) + //{ + //std::cout << "view key: " + view->viewKey().toStdString() << std::endl; + //if(!settingList.empty()) + //{ + QGroupBox *section = new QGroupBox(tab); + section->setGeometry(5, 5, this->width()-15, this->height()-15); // FIXME: frame thickness calculation + // FIXME: assume a single grid for now + QGridLayout *gridLayout = new QGridLayout(section); + gridLayout->setObjectName(QString::fromUtf8("gridLayout")); + gridLayout->setContentsMargins(5, 5, 5, 5); + + foreach(CSMSettings::Setting * setting, settingList) + { + // enum ViewType {ViewType_Boolean = 0, + // ViewType_List = 1, + // ViewType_Range = 2, + // ViewType_Text = 3, + // ViewType_Undefined = 4 }; + // enum SettingType {* 0 - 9 - Boolean widgets + // * 10-19 - List widgets + // * 21-29 - Range widgets + // * 31-39 - Text widgets + // * + // * Each range corresponds to a View_Type enum by a factor of 10. + // * + // * Even-numbered values are single-value widgets + // * Odd-numbered values are multi-valued widgets + // + // Type_CheckBox = 0, + // Type_RadioButton = 1, + // Type_ListView = 10, + // Type_ComboBox = 11, + // Type_SpinBox = 21, + // Type_DoubleSpinBox = 23, + // Type_Slider = 25, + // Type_Dial = 27, + // Type_TextArea = 30, + // Type_LineEdit = 31, + // Type_Undefined = 40 }; + // + std::cout << "view type: " + std::to_string(setting->viewType()) << std::endl; + std::cout << "setting type: " + std::to_string(setting->type()) << std::endl; + switch(setting->viewType()) + { + case ViewType_Boolean: + break; + case ViewType_List: + break; + case ViewType_Range: + break; + case ViewType_Text: + break; + default: + std::cerr << "ViewType_Undefined" << std::endl; + } + QLabel *lab = 0; + if(!gridLayout->itemAtPosition(setting->viewRow(), 0)) + { + lab = new QLabel(section); + lab->setText(setting->name()); + int textWidth = fm.width(setting->name()); // FIXME: + lab->setMinimumWidth(std::max(textWidth, this->width()/3)); + } + else + { + lab = dynamic_cast (gridLayout->itemAtPosition(setting->viewRow(), 0)->widget()); + QString oldLabel = lab->text(); + lab->setText(oldLabel + ", " + setting->name()); + } + switch(setting->type()) + { + case CSMSettings::SettingType::Type_RadioButton: + { + int rowNum = gridLayout->rowCount(); + if(!gridLayout->itemAtPosition(setting->viewRow(), 0)) + if(lab) gridLayout->addWidget(lab, rowNum, 0); + //lab->setStyleSheet("background-color:yellow;"); // FIXME: + int colNum = 1; + if(setting->declaredValues().size() > 1) // button group FIXME: try isMultiValue() + { + QButtonGroup * buttonGroup = new QButtonGroup(section); + //buttonGroup->setStyleSheet("background-color:red;"); // FIXME: + //gridLayout->addWidget(buttonGroup, rowNum, 1); + foreach(QString string, setting->declaredValues()) + { + QRadioButton *rb = new QRadioButton(string, section); + //rb->setStyleSheet("background-color:blue;"); // FIXME: + gridLayout->addWidget(rb, rowNum, colNum++); + buttonGroup->addButton(rb); + } + } + else // single radio button + { + std::cout << "default values size: " + std::to_string(setting->declaredValues().size()) << std::endl; + QRadioButton *rb = new QRadioButton(section); + if(rb) rb->setText(setting->declaredValues().at(0)); + gridLayout->addWidget(rb, gridLayout->rowCount(), 1); + } + break; + } + case CSMSettings::SettingType::Type_LineEdit: + { + if(!gridLayout->itemAtPosition(setting->viewRow(), 0)) + if(lab) gridLayout->addWidget(lab, setting->viewRow(), 0); + QLineEdit *item = new QLineEdit(section); + //QLabel *lab = new QLabel(section); + //lab->setText(setting->name()); // FIXME: how to put lables in proper place if many items in the same row + gridLayout->addWidget(item, setting->viewRow(), setting->viewColumn()+1, + setting->rowSpan(), setting->columnSpan()); + item->setText(setting->defaultValues().at(0)); //FIXME: check if empty first? + break; + } + case CSMSettings::SettingType::Type_ComboBox: + { + QComboBox *item = new QComboBox(section); + //QLabel *lab = new QLabel(section); + if(!gridLayout->itemAtPosition(setting->viewRow(), 0)) + if(lab) gridLayout->addWidget(lab, setting->viewRow(), 0); + //lab->setText(setting->name()); + gridLayout->addWidget(item, setting->viewRow(), setting->viewColumn()+1, + setting->rowSpan(), setting->columnSpan()); + item->clear(); + item->addItems(setting->declaredValues()); //FIXME: check if empty first? + break; + } + default: + break; + } + } + section->resize(section->width(), gridLayout->rowCount() * (fm.lineSpacing() + 10)); // 10 is extra line space + //tab->adjustSize(); + //} + //QWidget *item = new QWidget(tab); + //item->setObjectName(QString::fromUtf8("cmbAntiAlias")); + //} + + //new QListWidgetItem (pageName, mPageListWidget); + //mPageListWidget->setFixedWidth (textWidth + 50); + + //mStackedWidget->addWidget (&dynamic_cast(*(page))); +#endif +} + void CSVSettings::SettingWindow::createConnections (const QList &list) { diff --git a/apps/opencs/view/settings/settingwindow.hpp b/apps/opencs/view/settings/settingwindow.hpp index 2266f130d..5ed02681c 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 QMainWindow + class SettingWindow : public QTabWidget { Q_OBJECT @@ -26,7 +26,7 @@ namespace CSVSettings { CSMSettings::UserSettings *mModel; public: - explicit SettingWindow(QWidget *parent = 0); + explicit SettingWindow(QTabWidget *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,6 +50,9 @@ namespace CSVSettings { ///sets the defined values for the views that have been created void setViewValues(); + void buildTabPage(Page* tab); + 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 index f5b0e6a5b..3d9a9ed46 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -145,7 +145,7 @@ Display Format - + 10 @@ -223,7 +223,7 @@ Subviews - + 21 @@ -291,37 +291,73 @@ Window Size - + + + true + 10 20 171 - 22 + 21 - - - - - - 186 - 16777215 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - + + 0 + + + + true + + + + + 0 + 0 + 171 + 22 + + + + + + + + 186 + 16777215 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + false + + + + 0 + 0 + 171 + 22 + + + + @@ -340,27 +376,9 @@ displayGroup_Window displayGroup_DisplayFormat displayGroup_Subviews - layoutWidget2 + displayGroup_WindowSize cbStatusBar - - - Misc Settings - - - - false - - - - 70 - 100 - 69 - 22 - - - - From 17a74da65065c2617626d516904477492c83112b Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 21 Sep 2014 21:10:18 +1000 Subject: [PATCH 16/48] Cleaned up comments and dead code. --- apps/opencs/model/settings/usersettings.cpp | 127 ---------------- apps/opencs/view/settings/dialog.cpp | 84 ----------- apps/opencs/view/settings/dialog.hpp | 8 - apps/opencs/view/settings/settingwindow.cpp | 159 -------------------- apps/opencs/view/settings/settingwindow.hpp | 1 - 5 files changed, 379 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 664865289..8ef56e202 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -51,133 +51,6 @@ UserSettings::UserSettings (const Files::ConfigurationManager& configurationMana mSettingCfgDefinitions = new QSettings(QSettings::IniFormat, QSettings::UserScope, "", QString(), this); } -/* - * Original Design: - * - * - * QGridLayout QGroupBox - * ^ ^ - * | | - * | 1 | - * SettingLayout......Frame - * ^ ^ QMainWindow - * | | ^ QObject - * / \ | ^ - * / \ | | - * / \ 0..n | | 0..n - * View......Page........SettingWindow......UserSettings......Setting - * ^ 0..n ^ - * | | - * | | - * ListView, | - * TextView, etc | - * | - * | - * QStackedWidget QListWidget.....Dialog - * ^ : - * | : - * | : - * ResizeableStackedWidget..... - * - * - * When a Page is created with a list of Views, the Views are added to the Frame. - * - * Editor ctor - * -> Dialog ctor - * -> SettingWindow ctor - * -> SettingWindow::setModel() - * -> Dialog::setupDialog() - * -> buildPageListWidget - * -> buildStackedWidget - * - * Editor::showSettings() - * -> Dialog::show() - * -> Dialog::buildPages() <-- [first time only] - * -> SettingWindow::createPages() - * -> Page ctor - * -> Page::setupViews() - * -> Page::addView() - * -> Frame::addWidget() - * -> SettingLayout::addWidget() - * -> [add page widgets to the stack] - * - */ -/* - * Modified Design: - * - * +----------------------------------------+ - * |+---------+---------+---------+ | - * || | | | | - * || +----------------------------+| - * || || - * || +--------------------------------+ || - * || | | || - * || | View View | || - * || | View View | || - * || | | || - * || +---- Section -------------------+ || - * || || - * || +--------------------------------+ || - * || | | || - * || | +-------------+ | || - * || | | View/Frame | | || - * || | +-------------+ | || - * || | | || - * || +---- Section -------------------+ || - * || || - * || || - * |+-------------- Page ------------------+| - * +---------- SettingWindow ---------------+ - * - * - * - * QGridLayout QGroupBox - * ^ ^ - * | | - * | 1 | - * SettingLayout......Frame - * ^ ^ QTabWidget - * | | ^ QObject - * / \ | ^ - * / \ | | - * / \ 0..n | | 0..n - * View......Page........SettingWindow......UserSettings......Setting - * ^ 0..n ^ - * | | - * | Ui::TabWidget | - * ListView, ^ | - * TextView, etc | | - * \ | - * \ | - * \ | - * Dialog - * - * - * - * - * - * View/Page is still used to uniquely identify a setting (i.e. Section is for - * visual presentation only). This means all views on a page should be unique - * (as before) - * - * - * Editor ctor - * -> Dialog ctor - * -> SettingWindow ctor - * -> SettingWindow::setModel() - * -> Dialog::setupDialog() <-- [no longer required] - * - * Editor::showSettings() - * -> Dialog::show() - * -> Dialog::buildPages() <-- [first time only] - * -> SettingWindow::createPages() - * -> Page ctor - * -> Page::setupViews() - * -> Page::addView() - * -> Frame::addWidget() - * -> SettingLayout::addWidget() - * -> [add pages to tabs then call showWidgets()] - */ void UserSettings::buildSettingModelDefaults() { QString section; diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index e9ae194ce..df832cf92 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -1,27 +1,12 @@ #include "dialog.hpp" -//#include #include #include #include -//#include -//#include #include "../../model/settings/usersettings.hpp" - #include "page.hpp" -//#include - -//#include - -//#include -//#include -//#include - -#include -#include - #include #include @@ -170,14 +155,6 @@ CSVSettings::Dialog::Dialog(QTabWidget *parent) connect(cbStatusBar, SIGNAL(toggled(bool)), this, SIGNAL (toggleStatusBar(bool))); setupDialog(); - -#if 0 - // FIXME: delete - don't need this for tabs - connect (mPageListWidget, - SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)), - this, - SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*))); -#endif } void CSVSettings::Dialog::slotRendererChanged(const QString &renderer) @@ -226,33 +203,8 @@ void CSVSettings::Dialog::slotOverrideToggled(bool checked) } } -#if 0 -// FIXME: delete - not required for tabs -void CSVSettings::Dialog::slotChangePage - (QListWidgetItem *cur, QListWidgetItem *prev) -{ - mStackedWidget->changePage - (mPageListWidget->row (cur), mPageListWidget->row (prev)); - - layout()->activate(); - setFixedSize(minimumSizeHint()); -} -#endif - void CSVSettings::Dialog::setupDialog() { -#if 0 - //create central widget with it's layout and immediate children - QWidget *centralWidget = new QGroupBox (this); - - centralWidget->setLayout (new QHBoxLayout()); - centralWidget->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Preferred); - setCentralWidget (centralWidget); - setDockOptions (QMainWindow::AllowNestedDocks); - - buildPageListWidget (centralWidget); - buildStackedWidget (centralWidget); -#endif } void CSVSettings::Dialog::buildPages() @@ -332,51 +284,17 @@ void CSVSettings::Dialog::buildPages() SettingWindow::createPages (); - //QFontMetrics fm (QApplication::font()); - foreach (Page *page, SettingWindow::pages()) { QString pageName = page->objectName(); - - //int textWidth = fm.width(pageName); - // each page is added as a tab to Ui::TabWiget addTab(page, page->objectName()); // add section and views to the page - buildTabPage(page); page->showWidgets(); - - //new QListWidgetItem (pageName, mPageListWidget); - //mPageListWidget->setFixedWidth (textWidth + 50); - - //mStackedWidget->addWidget (&dynamic_cast(*(page))); } - - //resize (mStackedWidget->sizeHint()); -} - -#if 0 -// FIXME: delete - not required, using tabs instead -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); -} -#endif - void CSVSettings::Dialog::closeEvent (QCloseEvent *event) { //SettingWindow::closeEvent() must be called first to ensure @@ -442,8 +360,6 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) model()->setDefinitions("Display Format/Referenceable ID Type Display", QStringList(cmbRefIdType->currentText())); - std::cout << "closeEvent" << std::endl; - saveSettings(); } diff --git a/apps/opencs/view/settings/dialog.hpp b/apps/opencs/view/settings/dialog.hpp index c82df8dad..d1c09fb1e 100644 --- a/apps/opencs/view/settings/dialog.hpp +++ b/apps/opencs/view/settings/dialog.hpp @@ -2,13 +2,8 @@ #define CSVSETTINGS_DIALOG_H #include "settingwindow.hpp" -//#include "resizeablestackedwidget.hpp" #include -//class QStackedWidget; -//class QListWidget; -//class QListWidgetItem; - #include "ui_settingstab.h" namespace CSVSettings { @@ -41,8 +36,6 @@ namespace CSVSettings { private: void buildPages(); - //void buildPageListWidget (QWidget *centralWidget); - //void buildStackedWidget (QWidget *centralWidget); public slots: @@ -50,7 +43,6 @@ namespace CSVSettings { private slots: - //void slotChangePage (QListWidgetItem *, QListWidgetItem *); // FIXME: delete void slotOverrideToggled(bool checked); void slotRendererChanged(const QString &renderer); diff --git a/apps/opencs/view/settings/settingwindow.cpp b/apps/opencs/view/settings/settingwindow.cpp index f016f1e3d..d9bc890b1 100644 --- a/apps/opencs/view/settings/settingwindow.cpp +++ b/apps/opencs/view/settings/settingwindow.cpp @@ -1,9 +1,6 @@ #include "settingwindow.hpp" #include -//#include -//#include -//#include #include #include "../../model/settings/setting.hpp" @@ -41,162 +38,6 @@ void CSVSettings::SettingWindow::createPages() createConnections(connectedSettings); } -void CSVSettings::SettingWindow::buildTabPage(Page* tab) -{ - CSMSettings::SettingPageMap pageMap = mModel->settingPageMap(); - QList pageSettings = pageMap.value (tab->objectName()); - //tab->setupViews(pageSettings); -#if 0 - QFontMetrics fm (QApplication::font()); - //int textWidth = fm.width(pageName); // FIXME: - QString pageName = tab->objectName(); - - std::cout << "pageName: " + pageName.toStdString() << std::endl; // FIXME: - QList settingList = mModel->settingPageMap.value(pageName); - //foreach (View *view, page->views()) - //{ - //std::cout << "view key: " + view->viewKey().toStdString() << std::endl; - //if(!settingList.empty()) - //{ - QGroupBox *section = new QGroupBox(tab); - section->setGeometry(5, 5, this->width()-15, this->height()-15); // FIXME: frame thickness calculation - // FIXME: assume a single grid for now - QGridLayout *gridLayout = new QGridLayout(section); - gridLayout->setObjectName(QString::fromUtf8("gridLayout")); - gridLayout->setContentsMargins(5, 5, 5, 5); - - foreach(CSMSettings::Setting * setting, settingList) - { - // enum ViewType {ViewType_Boolean = 0, - // ViewType_List = 1, - // ViewType_Range = 2, - // ViewType_Text = 3, - // ViewType_Undefined = 4 }; - // enum SettingType {* 0 - 9 - Boolean widgets - // * 10-19 - List widgets - // * 21-29 - Range widgets - // * 31-39 - Text widgets - // * - // * Each range corresponds to a View_Type enum by a factor of 10. - // * - // * Even-numbered values are single-value widgets - // * Odd-numbered values are multi-valued widgets - // - // Type_CheckBox = 0, - // Type_RadioButton = 1, - // Type_ListView = 10, - // Type_ComboBox = 11, - // Type_SpinBox = 21, - // Type_DoubleSpinBox = 23, - // Type_Slider = 25, - // Type_Dial = 27, - // Type_TextArea = 30, - // Type_LineEdit = 31, - // Type_Undefined = 40 }; - // - std::cout << "view type: " + std::to_string(setting->viewType()) << std::endl; - std::cout << "setting type: " + std::to_string(setting->type()) << std::endl; - switch(setting->viewType()) - { - case ViewType_Boolean: - break; - case ViewType_List: - break; - case ViewType_Range: - break; - case ViewType_Text: - break; - default: - std::cerr << "ViewType_Undefined" << std::endl; - } - QLabel *lab = 0; - if(!gridLayout->itemAtPosition(setting->viewRow(), 0)) - { - lab = new QLabel(section); - lab->setText(setting->name()); - int textWidth = fm.width(setting->name()); // FIXME: - lab->setMinimumWidth(std::max(textWidth, this->width()/3)); - } - else - { - lab = dynamic_cast (gridLayout->itemAtPosition(setting->viewRow(), 0)->widget()); - QString oldLabel = lab->text(); - lab->setText(oldLabel + ", " + setting->name()); - } - switch(setting->type()) - { - case CSMSettings::SettingType::Type_RadioButton: - { - int rowNum = gridLayout->rowCount(); - if(!gridLayout->itemAtPosition(setting->viewRow(), 0)) - if(lab) gridLayout->addWidget(lab, rowNum, 0); - //lab->setStyleSheet("background-color:yellow;"); // FIXME: - int colNum = 1; - if(setting->declaredValues().size() > 1) // button group FIXME: try isMultiValue() - { - QButtonGroup * buttonGroup = new QButtonGroup(section); - //buttonGroup->setStyleSheet("background-color:red;"); // FIXME: - //gridLayout->addWidget(buttonGroup, rowNum, 1); - foreach(QString string, setting->declaredValues()) - { - QRadioButton *rb = new QRadioButton(string, section); - //rb->setStyleSheet("background-color:blue;"); // FIXME: - gridLayout->addWidget(rb, rowNum, colNum++); - buttonGroup->addButton(rb); - } - } - else // single radio button - { - std::cout << "default values size: " + std::to_string(setting->declaredValues().size()) << std::endl; - QRadioButton *rb = new QRadioButton(section); - if(rb) rb->setText(setting->declaredValues().at(0)); - gridLayout->addWidget(rb, gridLayout->rowCount(), 1); - } - break; - } - case CSMSettings::SettingType::Type_LineEdit: - { - if(!gridLayout->itemAtPosition(setting->viewRow(), 0)) - if(lab) gridLayout->addWidget(lab, setting->viewRow(), 0); - QLineEdit *item = new QLineEdit(section); - //QLabel *lab = new QLabel(section); - //lab->setText(setting->name()); // FIXME: how to put lables in proper place if many items in the same row - gridLayout->addWidget(item, setting->viewRow(), setting->viewColumn()+1, - setting->rowSpan(), setting->columnSpan()); - item->setText(setting->defaultValues().at(0)); //FIXME: check if empty first? - break; - } - case CSMSettings::SettingType::Type_ComboBox: - { - QComboBox *item = new QComboBox(section); - //QLabel *lab = new QLabel(section); - if(!gridLayout->itemAtPosition(setting->viewRow(), 0)) - if(lab) gridLayout->addWidget(lab, setting->viewRow(), 0); - //lab->setText(setting->name()); - gridLayout->addWidget(item, setting->viewRow(), setting->viewColumn()+1, - setting->rowSpan(), setting->columnSpan()); - item->clear(); - item->addItems(setting->declaredValues()); //FIXME: check if empty first? - break; - } - default: - break; - } - } - section->resize(section->width(), gridLayout->rowCount() * (fm.lineSpacing() + 10)); // 10 is extra line space - //tab->adjustSize(); - //} - //QWidget *item = new QWidget(tab); - //item->setObjectName(QString::fromUtf8("cmbAntiAlias")); - //} - - //new QListWidgetItem (pageName, mPageListWidget); - //mPageListWidget->setFixedWidth (textWidth + 50); - - //mStackedWidget->addWidget (&dynamic_cast(*(page))); -#endif -} - void CSVSettings::SettingWindow::createConnections (const QList &list) { diff --git a/apps/opencs/view/settings/settingwindow.hpp b/apps/opencs/view/settings/settingwindow.hpp index 5ed02681c..024873ae0 100644 --- a/apps/opencs/view/settings/settingwindow.hpp +++ b/apps/opencs/view/settings/settingwindow.hpp @@ -50,7 +50,6 @@ namespace CSVSettings { ///sets the defined values for the views that have been created void setViewValues(); - void buildTabPage(Page* tab); CSMSettings::UserSettings *model() { return mModel; } private: From 02f8f5419266d5b047aaf1edb988de93fbc5df5b Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 22 Sep 2014 07:50:35 +1000 Subject: [PATCH 17/48] Fixed checkbox behaviour. Added some shader settings. --- apps/opencs/editor.cpp | 6 +- apps/opencs/model/settings/usersettings.cpp | 135 +++++++++++++++++--- apps/opencs/view/settings/booleanview.cpp | 28 +++- apps/opencs/view/settings/dialog.cpp | 4 +- 4 files changed, 142 insertions(+), 31 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index d4ea32b26..c2e679eb3 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -314,10 +314,10 @@ std::auto_ptr CS::Editor::setupGraphics() factory->loadAllFiles(); - sh::Factory::getInstance().setGlobalSetting ("fog", "true"); + sh::Factory::getInstance().setGlobalSetting ("fog", mUserSettings.settingValue("shader/fog").toStdString() == "true" ? "true" : "false"); - sh::Factory::getInstance().setGlobalSetting ("shadows", "false"); - sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", "false"); + sh::Factory::getInstance().setGlobalSetting ("shadows", mUserSettings.settingValue("shader/shadows").toStdString() == "true" ? "true" : "false"); + sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", mUserSettings.settingValue("shader/shadows_pssm").toStdString() == "true" ? "true" : "false"); sh::Factory::getInstance ().setGlobalSetting ("render_refraction", "false"); diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 8ef56e202..919e3dd98 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -53,12 +53,108 @@ UserSettings::UserSettings (const Files::ConfigurationManager& configurationMana void UserSettings::buildSettingModelDefaults() { - QString section; + QString page; - section = "Window Size"; + page = "Shader"; { - Setting *width = createSetting (Type_LineEdit, section, "Width"); - Setting *height = createSetting (Type_LineEdit, section, "Height"); + QString section = "Group1"; + + Setting *fog = createSetting (Type_CheckBox, page, "fog"); + fog->setDeclaredValues(QStringList() << "true" << "false"); + fog->setDefaultValue("true"); + fog->setEditorSetting(true); + fog->setSpecialValueText("Enable Fog"); + fog->setWidgetWidth(15); + fog->setColumnSpan (2); + fog->setViewLocation(1, 1); + + Setting *shadows = createSetting (Type_CheckBox, page, "shadows"); + shadows->setDeclaredValues(QStringList() << "true" << "false"); + shadows->setDefaultValue("false"); + shadows->setEditorSetting(true); + shadows->setSpecialValueText("Enable Shadows"); + shadows->setWidgetWidth(15); + //shadows->setColumnSpan (2); + shadows->setViewLocation(2, 1); + + Setting *shadows_pssm = createSetting (Type_CheckBox, page, "shadows_pssm"); + shadows_pssm->setDeclaredValues(QStringList() << "true" << "false"); + shadows_pssm->setDefaultValue("false"); + shadows_pssm->setEditorSetting(true); + shadows_pssm->setSpecialValueText("Enable PSSM Shadows"); + shadows_pssm->setWidgetWidth(15); + //shadows_pssm->setColumnSpan (2); + shadows_pssm->setViewLocation(3, 1); + + // FIXME: add option to put label elsewhere (i.e. no frame text) + Setting *numLights = createSetting (Type_SpinBox, page, "num lights"); + numLights->setDefaultValue(8); + numLights->setEditorSetting(true); + numLights->setColumnSpan (2); + numLights->setMinimum (0); + numLights->setMaximum (100); // FIXME: not sure what the max value should be + numLights->setWidgetWidth (15); + numLights->setSpecialValueText ("Nothing!"); // text to display when value is 0 + numLights->setViewLocation(4, 1); + + Setting *simpleWater = createSetting (Type_CheckBox, page, "simple_water"); + simpleWater->setDeclaredValues(QStringList() << "true" << "false"); + simpleWater->setDefaultValue("false"); + simpleWater->setEditorSetting(true); + simpleWater->setSpecialValueText("Enable Simple Water"); + simpleWater->setWidgetWidth(15); + simpleWater->setColumnSpan (2); + simpleWater->setViewLocation(2, 4); + + Setting *waterEnabled = createSetting (Type_DoubleSpinBox, page, "waterEnabled"); + waterEnabled->setDefaultValue(0.00); + waterEnabled->setEditorSetting(true); + //waterEnabled->setColumnSpan (2); + waterEnabled->setMinimum (0); + waterEnabled->setMaximum (100.00); // FIXME: not sure what the max value should be + waterEnabled->setWidgetWidth (15); + waterEnabled->setViewLocation(3, 4); + + Setting *waterLevel = createSetting (Type_DoubleSpinBox, page, "waterLevel"); + waterLevel->setDefaultValue(0.00); + waterLevel->setEditorSetting(true); + //waterLevel->setColumnSpan (2); + waterLevel->setMinimum (0); + waterLevel->setMaximum (100.00); // FIXME: not sure what the max value should be + waterLevel->setWidgetWidth (15); + waterLevel->setViewLocation(4, 4); + + Setting *waterTimer = createSetting (Type_DoubleSpinBox, page, "waterTimer"); + waterTimer->setDefaultValue(0.00); + waterTimer->setEditorSetting(true); + //waterTimer->setColumnSpan (2); + waterTimer->setMinimum (0); + waterTimer->setMaximum (100.00); // FIXME: not sure what the max value should be + waterTimer->setWidgetWidth (15); + waterTimer->setViewLocation(5, 4); + +#if 0 + sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", "false"); + + sh::Factory::getInstance ().setGlobalSetting ("render_refraction", "false"); + + sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false"); + + + +sh::Factory::getInstance ().setSharedParameter ("windDir_windSpeed", sh::makeProperty(new sh::Vector3(0.5, -0.8, 0.2))); +sh::Factory::getInstance ().setSharedParameter ("waterSunFade_sunHeight", sh::makeProperty(new sh::Vector2(1, 0.6))); +sh::Factory::getInstance ().setGlobalSetting ("refraction", Settings::Manager::getBool("refraction", "Water") ? "true" : "false"); +sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false"); +sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makeProperty (new sh::Vector4(0,0,0,0))); +#endif + } + +#if 0 + page = "Window Size"; + { + Setting *width = createSetting (Type_LineEdit, page, "Width"); + Setting *height = createSetting (Type_LineEdit, page, "Height"); width->setWidgetWidth (5); height->setWidgetWidth (8); @@ -75,7 +171,7 @@ void UserSettings::buildSettingModelDefaults() /* *Create the proxy setting for predefined values */ - Setting *preDefined = createSetting (Type_ComboBox, section, + Setting *preDefined = createSetting (Type_ComboBox, page, "Pre-Defined"); preDefined->setDeclaredValues (QStringList() << "640 x 480" @@ -94,7 +190,7 @@ void UserSettings::buildSettingModelDefaults() ); } - section = "Display Format"; + page = "Display Format"; { QString defaultValue = "Icon and Text"; @@ -102,10 +198,10 @@ void UserSettings::buildSettingModelDefaults() << defaultValue << "Icon Only" << "Text Only"; Setting *rsd = createSetting (Type_RadioButton, - section, "Record Status Display"); + page, "Record Status Display"); Setting *ritd = createSetting (Type_RadioButton, - section, "Referenceable ID Type Display"); + page, "Referenceable ID Type Display"); rsd->setDeclaredValues (values); ritd->setDeclaredValues (values); @@ -113,8 +209,9 @@ void UserSettings::buildSettingModelDefaults() rsd->setEditorSetting (true); ritd->setEditorSetting (true); } +#endif - section = "Proxy Selection Test"; + page = "Proxy Selection Test"; { /****************************************************************** * There are three types of values: @@ -142,30 +239,30 @@ void UserSettings::buildSettingModelDefaults() //create setting objects, specifying the basic widget type, //the page name, and the view name - Setting *masterBoolean = createSetting (Type_RadioButton, section, + Setting *masterBoolean = createSetting (Type_RadioButton, page, "Master Proxy"); - Setting *slaveBoolean = createSetting (Type_CheckBox, section, + Setting *slaveBoolean = createSetting (Type_CheckBox, page, "Proxy Checkboxes"); - Setting *slaveSingleText = createSetting (Type_LineEdit, section, + Setting *slaveSingleText = createSetting (Type_LineEdit, page, "Proxy TextBox 1"); - Setting *slaveMultiText = createSetting (Type_LineEdit, section, + Setting *slaveMultiText = createSetting (Type_LineEdit, page, "ProxyTextBox 2"); - Setting *slaveAlphaSpinbox = createSetting (Type_SpinBox, section, + Setting *slaveAlphaSpinbox = createSetting (Type_SpinBox, page, "Alpha Spinbox"); - Setting *slaveIntegerSpinbox = createSetting (Type_SpinBox, section, + Setting *slaveIntegerSpinbox = createSetting (Type_SpinBox, page, "Int Spinbox"); Setting *slaveDoubleSpinbox = createSetting (Type_DoubleSpinBox, - section, "Double Spinbox"); + page, "Double Spinbox"); - Setting *slaveSlider = createSetting (Type_Slider, section, "Slider"); + Setting *slaveSlider = createSetting (Type_Slider, page, "Slider"); - Setting *slaveDial = createSetting (Type_Dial, section, "Dial"); + Setting *slaveDial = createSetting (Type_Dial, page, "Dial"); //set declared values for selected views masterBoolean->setDeclaredValues (QStringList() @@ -366,7 +463,7 @@ void UserSettings::loadSettings (const QString &fileName) || (glES && currShader != "glsles")) { QString shader = openGL ? (glES ? "glsles" : "glsl") : "hlsl"; - mSettingDefinitions->setValue("General/shader mode", shader); + mSettingDefinitions->setValue("shader mode", shader); //no group means "General" group } // check if override entry exists (default: override) diff --git a/apps/opencs/view/settings/booleanview.cpp b/apps/opencs/view/settings/booleanview.cpp index 2a3f0cba6..fa66a2a8f 100644 --- a/apps/opencs/view/settings/booleanview.cpp +++ b/apps/opencs/view/settings/booleanview.cpp @@ -20,8 +20,19 @@ CSVSettings::BooleanView::BooleanView (CSMSettings::Setting *setting, switch (setting->type()) { - case CSMSettings::Type_CheckBox: - button = new QCheckBox (value, this); + case CSMSettings::Type_CheckBox: { + if(mButtons.empty()) // show only one for checkboxes + { + button = new QCheckBox (value, this); + button->setChecked (setting->defaultValues().at(0) == "true" ? true : false); + + // special visual treatment option for checkboxes + if(setting->specialValueText() != "") { + Frame::setTitle(""); + button->setText(setting->specialValueText()); + } + } + } break; case CSMSettings::Type_RadioButton: @@ -32,14 +43,17 @@ CSVSettings::BooleanView::BooleanView (CSMSettings::Setting *setting, break; } - connect (button, SIGNAL (clicked (bool)), - this, SLOT (slotToggled (bool))); + if(setting->type() != CSMSettings::Type_CheckBox || mButtons.empty()) + { + connect (button, SIGNAL (clicked (bool)), + this, SLOT (slotToggled (bool))); - button->setObjectName (value); + button->setObjectName (value); - addWidget (button); + addWidget (button); - mButtons[value] = button; + mButtons[value] = button; + } } } diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index df832cf92..331cbc3f3 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -326,8 +326,8 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) model()->setDefinitions("Video/antialiasing", QStringList(reAA.cap(1))); #endif - // shader lang - model()->setDefinitions("General/shader mode", + // shader lang (no group means "General" group) + model()->setDefinitions("shader mode", QStringList(cmbShaderLang->currentText().toLower())); // window size From 71a38808840bcaa23f82822c20532c44dc6ced79 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 22 Sep 2014 12:19:18 +1000 Subject: [PATCH 18/48] Added workarounds to add QLabel. Add stylesheet option to apply to View's QGroupBox. RangeViews are now right aligned. Added content margins to the page/tab's layout. --- apps/opencs/model/settings/setting.cpp | 10 ++++++++++ apps/opencs/model/settings/setting.hpp | 3 +++ apps/opencs/model/settings/support.hpp | 12 +++++++----- apps/opencs/model/settings/usersettings.cpp | 20 ++++++++++++++++---- apps/opencs/view/settings/frame.cpp | 4 ++++ apps/opencs/view/settings/page.cpp | 16 +++++++++++++++- apps/opencs/view/settings/rangeview.cpp | 1 + apps/opencs/view/settings/view.cpp | 3 +++ 8 files changed, 59 insertions(+), 10 deletions(-) diff --git a/apps/opencs/model/settings/setting.cpp b/apps/opencs/model/settings/setting.cpp index 9e1b497b1..c29b0e2dd 100644 --- a/apps/opencs/model/settings/setting.cpp +++ b/apps/opencs/model/settings/setting.cpp @@ -205,6 +205,16 @@ QString CSMSettings::Setting::section() const return property (Property_Section).at(0); } +void CSMSettings::Setting::setStyleSheet (const QString &value) +{ + setProperty (Property_StyleSheet, value); +} + +QString CSMSettings::Setting::styleSheet() const +{ + return property (Property_StyleSheet).at(0); +} + void CSMSettings::Setting::setPrefix (const QString &value) { setProperty (Property_Prefix, value); diff --git a/apps/opencs/model/settings/setting.hpp b/apps/opencs/model/settings/setting.hpp index ed897e591..b8c72c4bc 100644 --- a/apps/opencs/model/settings/setting.hpp +++ b/apps/opencs/model/settings/setting.hpp @@ -83,6 +83,9 @@ namespace CSMSettings void setSection (const QString &value); QString section() const; + void setStyleSheet (const QString &value); + QString styleSheet() const; + void setPrefix (const QString &value); QString prefix() const; diff --git a/apps/opencs/model/settings/support.hpp b/apps/opencs/model/settings/support.hpp index 40db648dc..8c82b17a6 100644 --- a/apps/opencs/model/settings/support.hpp +++ b/apps/opencs/model/settings/support.hpp @@ -36,12 +36,13 @@ namespace CSMSettings Property_TicksAbove = 20, Property_TicksBelow = 21, Property_Section = 22, + Property_StyleSheet = 23, //Stringlists should always be the last items - Property_DefaultValues = 23, - Property_DeclaredValues = 24, - Property_DefinedValues = 25, - Property_Proxies = 26 + Property_DefaultValues = 24, + Property_DeclaredValues = 25, + Property_DefinedValues = 26, + Property_Proxies = 27 }; ///Basic setting widget types. @@ -107,7 +108,7 @@ namespace CSMSettings "is_multi_line", "widget_width", "view_row", "view_column", "delimiter", "is_serializable","column_span", "row_span", "minimum", "maximum", "special_value_text", "prefix", "suffix", "single_step", "wrapping", - "tick_interval", "ticks_above", "ticks_below", "section", + "tick_interval", "ticks_above", "ticks_below", "section", "stylesheet", "defaults", "declarations", "definitions", "proxies" }; @@ -137,6 +138,7 @@ namespace CSMSettings "false", //ticks above "true", //ticks below "", //Section + "", //StyleSheet "", //default values "", //declared values "", //defined values diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 919e3dd98..35c19a176 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -66,6 +66,7 @@ void UserSettings::buildSettingModelDefaults() fog->setSpecialValueText("Enable Fog"); fog->setWidgetWidth(15); fog->setColumnSpan (2); + fog->setStyleSheet ("QGroupBox { border: 0px; }"); fog->setViewLocation(1, 1); Setting *shadows = createSetting (Type_CheckBox, page, "shadows"); @@ -75,6 +76,7 @@ void UserSettings::buildSettingModelDefaults() shadows->setSpecialValueText("Enable Shadows"); shadows->setWidgetWidth(15); //shadows->setColumnSpan (2); + shadows->setStyleSheet ("QGroupBox { border: 0px; }"); shadows->setViewLocation(2, 1); Setting *shadows_pssm = createSetting (Type_CheckBox, page, "shadows_pssm"); @@ -84,6 +86,7 @@ void UserSettings::buildSettingModelDefaults() shadows_pssm->setSpecialValueText("Enable PSSM Shadows"); shadows_pssm->setWidgetWidth(15); //shadows_pssm->setColumnSpan (2); + shadows_pssm->setStyleSheet ("QGroupBox { border: 0px; }"); shadows_pssm->setViewLocation(3, 1); // FIXME: add option to put label elsewhere (i.e. no frame text) @@ -93,7 +96,7 @@ void UserSettings::buildSettingModelDefaults() numLights->setColumnSpan (2); numLights->setMinimum (0); numLights->setMaximum (100); // FIXME: not sure what the max value should be - numLights->setWidgetWidth (15); + numLights->setWidgetWidth (10); numLights->setSpecialValueText ("Nothing!"); // text to display when value is 0 numLights->setViewLocation(4, 1); @@ -104,6 +107,7 @@ void UserSettings::buildSettingModelDefaults() simpleWater->setSpecialValueText("Enable Simple Water"); simpleWater->setWidgetWidth(15); simpleWater->setColumnSpan (2); + simpleWater->setStyleSheet ("QGroupBox { border: 0px; }"); simpleWater->setViewLocation(2, 4); Setting *waterEnabled = createSetting (Type_DoubleSpinBox, page, "waterEnabled"); @@ -112,7 +116,7 @@ void UserSettings::buildSettingModelDefaults() //waterEnabled->setColumnSpan (2); waterEnabled->setMinimum (0); waterEnabled->setMaximum (100.00); // FIXME: not sure what the max value should be - waterEnabled->setWidgetWidth (15); + waterEnabled->setWidgetWidth (10); waterEnabled->setViewLocation(3, 4); Setting *waterLevel = createSetting (Type_DoubleSpinBox, page, "waterLevel"); @@ -121,7 +125,7 @@ void UserSettings::buildSettingModelDefaults() //waterLevel->setColumnSpan (2); waterLevel->setMinimum (0); waterLevel->setMaximum (100.00); // FIXME: not sure what the max value should be - waterLevel->setWidgetWidth (15); + waterLevel->setWidgetWidth (10); waterLevel->setViewLocation(4, 4); Setting *waterTimer = createSetting (Type_DoubleSpinBox, page, "waterTimer"); @@ -130,9 +134,17 @@ void UserSettings::buildSettingModelDefaults() //waterTimer->setColumnSpan (2); waterTimer->setMinimum (0); waterTimer->setMaximum (100.00); // FIXME: not sure what the max value should be - waterTimer->setWidgetWidth (15); + waterTimer->setWidgetWidth (10); waterTimer->setViewLocation(5, 4); + Setting *text = createSetting (Type_Undefined, page, "text"); + text->setSpecialValueText("This is a test"); // hack to place text labels + text->setEditorSetting(false); + text->setSerializable (false); + //text->setColumnSpan (1); + text->setWidgetWidth (15); + text->setViewLocation(5, 1); + #if 0 sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", "false"); diff --git a/apps/opencs/view/settings/frame.cpp b/apps/opencs/view/settings/frame.cpp index 019024776..39aafe652 100644 --- a/apps/opencs/view/settings/frame.cpp +++ b/apps/opencs/view/settings/frame.cpp @@ -14,7 +14,11 @@ CSVSettings::Frame::Frame (bool isVisible, const QString &title, mVisibleBoxStyle = styleSheet(); if (!isVisible) + { + // must be Page, not a View setStyleSheet (sInvisibleBoxStyle); + mLayout->setContentsMargins(10, 15, 10, 15); + } setLayout (mLayout); } diff --git a/apps/opencs/view/settings/page.cpp b/apps/opencs/view/settings/page.cpp index afd4bff5e..ed4cdd6bc 100644 --- a/apps/opencs/view/settings/page.cpp +++ b/apps/opencs/view/settings/page.cpp @@ -1,4 +1,7 @@ #include "page.hpp" + +#include + #include "view.hpp" #include "booleanview.hpp" #include "textview.hpp" @@ -38,7 +41,18 @@ void CSVSettings::Page::setupViews void CSVSettings::Page::addView (CSMSettings::Setting *setting) { if (setting->viewType() == ViewType_Undefined) - return; + { + if(setting->specialValueText() != "") + { + // hack to put a label + addWidget(new QLabel(setting->specialValueText()), + setting->viewRow(), setting->viewColumn(), + setting->rowSpan(), setting->columnSpan()); + return; + } + else + return; + } View *view = mViewFactories[setting->viewType()]->createView(setting, this); diff --git a/apps/opencs/view/settings/rangeview.cpp b/apps/opencs/view/settings/rangeview.cpp index 8ae6caca0..606ad4939 100644 --- a/apps/opencs/view/settings/rangeview.cpp +++ b/apps/opencs/view/settings/rangeview.cpp @@ -127,6 +127,7 @@ void CSVSettings::RangeView::buildSpinBox (CSMSettings::Setting *setting) mRangeWidget->setProperty ("prefix", setting->prefix()); mRangeWidget->setProperty ("suffix", setting->suffix()); mRangeWidget->setProperty ("wrapping", setting->wrapping()); + dynamic_cast (mRangeWidget)->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); } diff --git a/apps/opencs/view/settings/view.cpp b/apps/opencs/view/settings/view.cpp index 69109e2b3..f95bb5c03 100644 --- a/apps/opencs/view/settings/view.cpp +++ b/apps/opencs/view/settings/view.cpp @@ -22,6 +22,9 @@ CSVSettings::View::View(CSMSettings::Setting *setting, setObjectName (setting->name()); buildView(); buildModel (setting); + // apply stylesheet to view's frame if exists + if(setting->styleSheet() != "") + Frame::setStyleSheet (setting->styleSheet()); } void CSVSettings::View::buildModel (const CSMSettings::Setting *setting) From fc8d6da6a2df0692c52738dd610cb40de66cbbca Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 22 Sep 2014 16:24:06 +1000 Subject: [PATCH 19/48] Added more shader settings. --- apps/opencs/editor.cpp | 21 ++-- apps/opencs/model/settings/usersettings.cpp | 104 +++++++++++++++----- apps/opencs/view/settings/frame.cpp | 3 +- files/ui/settingstab.ui | 2 +- 4 files changed, 97 insertions(+), 33 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index c2e679eb3..25e65b7ee 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -263,7 +263,6 @@ std::auto_ptr CS::Editor::setupGraphics() { std::string rendersystem = mUserSettings.settingValue("Video/render system").toStdString(); Ogre::Root::getSingleton().setRenderSystem(Ogre::Root::getSingleton().getRenderSystemByName(rendersystem)); - std::cout << "editor: render system " + rendersystem << std::endl; // FIXME: debug Ogre::Root::getSingleton().initialise(false); @@ -300,6 +299,7 @@ std::auto_ptr CS::Editor::setupGraphics() std::auto_ptr factory (new sh::Factory (platform)); std::string shLang = mUserSettings.settingValue("General/shader mode").toStdString(); + //std::string shLang = mUserSettings.getShaderLanguageByRenderer(rendersystem.c_str()).at(0).toStdString(); enum sh::Language lang; if(shLang == "glsl") lang = sh::Language_GLSL; else if(shLang == "glsles") lang = sh::Language_GLSLES; @@ -314,16 +314,23 @@ std::auto_ptr CS::Editor::setupGraphics() factory->loadAllFiles(); - sh::Factory::getInstance().setGlobalSetting ("fog", mUserSettings.settingValue("shader/fog").toStdString() == "true" ? "true" : "false"); + sh::Factory::getInstance().setGlobalSetting ("fog", + mUserSettings.settingValue("shader/fog").toStdString()); - sh::Factory::getInstance().setGlobalSetting ("shadows", mUserSettings.settingValue("shader/shadows").toStdString() == "true" ? "true" : "false"); - sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", mUserSettings.settingValue("shader/shadows_pssm").toStdString() == "true" ? "true" : "false"); + sh::Factory::getInstance().setGlobalSetting ("shadows", + mUserSettings.settingValue("shader/shadows").toStdString()); - sh::Factory::getInstance ().setGlobalSetting ("render_refraction", "false"); + sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", + mUserSettings.settingValue("shader/shadows_pssm").toStdString()); - sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false"); + sh::Factory::getInstance ().setGlobalSetting ("render_refraction", + mUserSettings.settingValue("shader/render_refraction").toStdString()); - sh::Factory::getInstance ().setGlobalSetting ("num_lights", "8"); + sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", + mUserSettings.settingValue("shader/viewproj_fix").toStdString()); + + sh::Factory::getInstance ().setGlobalSetting ("num_lights", + mUserSettings.settingValue("shader/num_lights").toStdString()); /// \todo add more configurable shiny settings diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 35c19a176..3fcf083d1 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -66,7 +66,7 @@ void UserSettings::buildSettingModelDefaults() fog->setSpecialValueText("Enable Fog"); fog->setWidgetWidth(15); fog->setColumnSpan (2); - fog->setStyleSheet ("QGroupBox { border: 0px; }"); + fog->setStyleSheet ("QGroupBox { border: 0px; spacing: 5; }"); fog->setViewLocation(1, 1); Setting *shadows = createSetting (Type_CheckBox, page, "shadows"); @@ -75,7 +75,7 @@ void UserSettings::buildSettingModelDefaults() shadows->setEditorSetting(true); shadows->setSpecialValueText("Enable Shadows"); shadows->setWidgetWidth(15); - //shadows->setColumnSpan (2); + shadows->setColumnSpan (2); shadows->setStyleSheet ("QGroupBox { border: 0px; }"); shadows->setViewLocation(2, 1); @@ -85,65 +85,121 @@ void UserSettings::buildSettingModelDefaults() shadows_pssm->setEditorSetting(true); shadows_pssm->setSpecialValueText("Enable PSSM Shadows"); shadows_pssm->setWidgetWidth(15); - //shadows_pssm->setColumnSpan (2); - shadows_pssm->setStyleSheet ("QGroupBox { border: 0px; }"); + shadows_pssm->setColumnSpan (2); + shadows_pssm->setStyleSheet ("QGroupBox { border: 0px; spacing: 5; }"); shadows_pssm->setViewLocation(3, 1); - // FIXME: add option to put label elsewhere (i.e. no frame text) Setting *numLights = createSetting (Type_SpinBox, page, "num lights"); numLights->setDefaultValue(8); numLights->setEditorSetting(true); - numLights->setColumnSpan (2); + numLights->setColumnSpan (1); numLights->setMinimum (0); numLights->setMaximum (100); // FIXME: not sure what the max value should be numLights->setWidgetWidth (10); numLights->setSpecialValueText ("Nothing!"); // text to display when value is 0 - numLights->setViewLocation(4, 1); + numLights->setViewLocation(4, 2); + Setting *nlText = createSetting (Type_Undefined, page, "nlText"); + nlText->setSpecialValueText("Num Lights"); // hack to place text labels + nlText->setEditorSetting(false); + nlText->setSerializable (false); + nlText->setColumnSpan (1); + nlText->setWidgetWidth (10); + nlText->setViewLocation(4, 1); + + Setting *renderRefraction = createSetting (Type_CheckBox, page, "renderRefraction"); + renderRefraction->setDeclaredValues(QStringList() << "true" << "false"); + renderRefraction->setDefaultValue("false"); + renderRefraction->setEditorSetting(true); + renderRefraction->setSpecialValueText("Enable Render Refraction"); + renderRefraction->setWidgetWidth(20); + renderRefraction->setColumnSpan (2); + renderRefraction->setStyleSheet ("QGroupBox { border: 0px; }"); + renderRefraction->setViewLocation(5, 1); + + Setting *viewproj_fix = createSetting (Type_CheckBox, page, "viewproj_fix"); + viewproj_fix->setDeclaredValues(QStringList() << "true" << "false"); + viewproj_fix->setDefaultValue("false"); + viewproj_fix->setEditorSetting(true); + viewproj_fix->setSpecialValueText("View Proj Fix"); + viewproj_fix->setWidgetWidth(20); + viewproj_fix->setColumnSpan (2); + viewproj_fix->setStyleSheet ("QGroupBox { border: 0px; }"); + viewproj_fix->setViewLocation(6, 1); Setting *simpleWater = createSetting (Type_CheckBox, page, "simple_water"); simpleWater->setDeclaredValues(QStringList() << "true" << "false"); simpleWater->setDefaultValue("false"); simpleWater->setEditorSetting(true); simpleWater->setSpecialValueText("Enable Simple Water"); - simpleWater->setWidgetWidth(15); - simpleWater->setColumnSpan (2); + simpleWater->setWidgetWidth(25); + simpleWater->setColumnSpan (3); simpleWater->setStyleSheet ("QGroupBox { border: 0px; }"); - simpleWater->setViewLocation(2, 4); + simpleWater->setViewLocation(1, 5); Setting *waterEnabled = createSetting (Type_DoubleSpinBox, page, "waterEnabled"); waterEnabled->setDefaultValue(0.00); waterEnabled->setEditorSetting(true); - //waterEnabled->setColumnSpan (2); + waterEnabled->setColumnSpan (1); waterEnabled->setMinimum (0); waterEnabled->setMaximum (100.00); // FIXME: not sure what the max value should be waterEnabled->setWidgetWidth (10); - waterEnabled->setViewLocation(3, 4); + //waterEnabled->setStyleSheet("QGroupBox { border:2px; padding 2px; margin: 2px;} QGroupBox::title { text: \"test\" }"); + waterEnabled->setViewLocation(2, 6); + Setting *weText = createSetting (Type_Undefined, page, "weText"); + weText->setSpecialValueText("Water Enabled"); + weText->setEditorSetting(false); + weText->setSerializable (false); + weText->setColumnSpan (1); + weText->setWidgetWidth (10); + weText->setViewLocation(2, 5); Setting *waterLevel = createSetting (Type_DoubleSpinBox, page, "waterLevel"); waterLevel->setDefaultValue(0.00); waterLevel->setEditorSetting(true); - //waterLevel->setColumnSpan (2); + waterLevel->setColumnSpan (1); waterLevel->setMinimum (0); waterLevel->setMaximum (100.00); // FIXME: not sure what the max value should be waterLevel->setWidgetWidth (10); - waterLevel->setViewLocation(4, 4); + waterLevel->setViewLocation(3, 6); + Setting *wlText = createSetting (Type_Undefined, page, "wlText"); + wlText->setSpecialValueText("Water Level"); // hack to place text labels + wlText->setEditorSetting(false); + wlText->setSerializable (false); + wlText->setColumnSpan (1); + wlText->setWidgetWidth (10); + wlText->setViewLocation(3, 5); Setting *waterTimer = createSetting (Type_DoubleSpinBox, page, "waterTimer"); waterTimer->setDefaultValue(0.00); waterTimer->setEditorSetting(true); - //waterTimer->setColumnSpan (2); + waterTimer->setColumnSpan (1); waterTimer->setMinimum (0); waterTimer->setMaximum (100.00); // FIXME: not sure what the max value should be waterTimer->setWidgetWidth (10); - waterTimer->setViewLocation(5, 4); - - Setting *text = createSetting (Type_Undefined, page, "text"); - text->setSpecialValueText("This is a test"); // hack to place text labels - text->setEditorSetting(false); - text->setSerializable (false); - //text->setColumnSpan (1); - text->setWidgetWidth (15); - text->setViewLocation(5, 1); + waterTimer->setViewLocation(4, 6); + Setting *wtText = createSetting (Type_Undefined, page, "wtText"); + wtText->setSpecialValueText("Water Timer"); // hack to place text labels + wtText->setEditorSetting(false); + wtText->setSerializable (false); + wtText->setColumnSpan (1); + wtText->setWidgetWidth (10); + wtText->setViewLocation(4, 5); + + + Setting *spaceText = createSetting (Type_Undefined, page, "spaceText"); + spaceText->setSpecialValueText(" "); + spaceText->setEditorSetting(false); + spaceText->setSerializable (false); + spaceText->setColumnSpan (1); + spaceText->setWidgetWidth (5); + spaceText->setViewLocation(3, 4); + Setting *spaceText2 = createSetting (Type_Undefined, page, "spaceText2"); + spaceText2->setSpecialValueText(" "); + spaceText2->setEditorSetting(false); + spaceText2->setSerializable (false); + spaceText2->setColumnSpan (1); + spaceText2->setWidgetWidth (5); + spaceText2->setViewLocation(3, 7); #if 0 sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", "false"); diff --git a/apps/opencs/view/settings/frame.cpp b/apps/opencs/view/settings/frame.cpp index 39aafe652..c39eba890 100644 --- a/apps/opencs/view/settings/frame.cpp +++ b/apps/opencs/view/settings/frame.cpp @@ -16,7 +16,8 @@ CSVSettings::Frame::Frame (bool isVisible, const QString &title, if (!isVisible) { // must be Page, not a View - setStyleSheet (sInvisibleBoxStyle); + //setStyleSheet (sInvisibleBoxStyle); + setStyleSheet("QGroupBox { border:0px; }"); mLayout->setContentsMargins(10, 15, 10, 15); } diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 3d9a9ed46..ceb0a898f 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -122,7 +122,7 @@ - Shader + title displayGroup_Render From 48f96df29d325026487eeffdb6c9a8033416436d Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 22 Sep 2014 18:50:48 +1000 Subject: [PATCH 20/48] Fixed checkboxes saving invalid values. --- apps/opencs/view/settings/booleanview.cpp | 16 +++++++++++----- apps/opencs/view/settings/booleanview.hpp | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/apps/opencs/view/settings/booleanview.cpp b/apps/opencs/view/settings/booleanview.cpp index fa66a2a8f..58b822179 100644 --- a/apps/opencs/view/settings/booleanview.cpp +++ b/apps/opencs/view/settings/booleanview.cpp @@ -12,13 +12,13 @@ CSVSettings::BooleanView::BooleanView (CSMSettings::Setting *setting, Page *parent) - : View (setting, parent) + : mType(setting->type()), View (setting, parent) { foreach (const QString &value, setting->declaredValues()) { QAbstractButton *button = 0; - switch (setting->type()) + switch (mType) { case CSMSettings::Type_CheckBox: { if(mButtons.empty()) // show only one for checkboxes @@ -43,7 +43,7 @@ CSVSettings::BooleanView::BooleanView (CSMSettings::Setting *setting, break; } - if(setting->type() != CSMSettings::Type_CheckBox || mButtons.empty()) + if(mType != CSMSettings::Type_CheckBox || mButtons.empty()) { connect (button, SIGNAL (clicked (bool)), this, SLOT (slotToggled (bool))); @@ -67,8 +67,14 @@ void CSVSettings::BooleanView::slotToggled (bool state) foreach (QString key, mButtons.keys()) { - if (mButtons.value(key)->isChecked()) - values.append (key); + // checkbox values are true/false unlike radio buttons + if(mType == CSMSettings::Type_CheckBox) + values.append(mButtons.value(key)->isChecked() ? "true" : "false"); + else + { + if (mButtons.value(key)->isChecked()) + values.append (key); + } } setSelectedValues (values, false); diff --git a/apps/opencs/view/settings/booleanview.hpp b/apps/opencs/view/settings/booleanview.hpp index 55ef0bb08..53198234a 100644 --- a/apps/opencs/view/settings/booleanview.hpp +++ b/apps/opencs/view/settings/booleanview.hpp @@ -16,6 +16,7 @@ namespace CSVSettings Q_OBJECT QMap mButtons; + enum CSMSettings::SettingType mType; public: explicit BooleanView (CSMSettings::Setting *setting, From c4f11785ecd08839575acdb2715758e49532ec6d Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 22 Sep 2014 21:12:26 +1000 Subject: [PATCH 21/48] Added a window size change easter egg. --- apps/opencs/view/settings/dialog.cpp | 33 +++- apps/opencs/view/settings/dialog.hpp | 2 + files/ui/settingstab.ui | 264 ++++++++++++++------------- 3 files changed, 167 insertions(+), 132 deletions(-) diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index 331cbc3f3..3f8143aa2 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -154,9 +154,30 @@ CSVSettings::Dialog::Dialog(QTabWidget *parent) // to update the checkbox on the view menu connect(cbStatusBar, SIGNAL(toggled(bool)), this, SIGNAL (toggleStatusBar(bool))); + displayGroup_Window->installEventFilter(this); + setupDialog(); } +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(); @@ -254,7 +275,6 @@ void CSVSettings::Dialog::buildPages() { // show the values in ini file cmbStdWinSize->setCurrentIndex(index); - //slotStandardToggled(true); } else { @@ -263,9 +283,6 @@ void CSVSettings::Dialog::buildPages() Qt::DisplayRole, Qt::MatchStartsWith); if(index != -1) cmbStdWinSize->setCurrentIndex(index); - - //rbCustWinSize->setChecked(true); - //slotStandardToggled(false); } // status bar @@ -331,7 +348,7 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) QStringList(cmbShaderLang->currentText().toLower())); // window size - if(0) //rbStdWinSize->isChecked()) + if(page_2->isEnabled()) { QRegExp re("^(\\d+) x (\\d+)"); if(re.indexIn(cmbStdWinSize->currentText()) > -1) @@ -339,9 +356,9 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) model()->setDefinitions("Window Size/Width", QStringList(re.cap(1))); model()->setDefinitions("Window Size/Height", QStringList(re.cap(2))); } - //} - //else - //{ + } + else + { model()->setDefinitions("Window Size/Width", QStringList(QString::number(sbWidth->value()))); model()->setDefinitions("Window Size/Height", diff --git a/apps/opencs/view/settings/dialog.hpp b/apps/opencs/view/settings/dialog.hpp index d1c09fb1e..e2e93d8a1 100644 --- a/apps/opencs/view/settings/dialog.hpp +++ b/apps/opencs/view/settings/dialog.hpp @@ -33,6 +33,8 @@ namespace CSVSettings { void setupDialog(); + bool eventFilter(QObject *target, QEvent *event); + private: void buildPages(); diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index ceb0a898f..de7014b4a 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -14,121 +14,8 @@ User Settings - 1 + 0 - - - Video Settings - - - - - 20 - 26 - 351 - 129 - - - - - - - Use Render System Settings from OpenMW - - - true - - - - - - - Rendering Subsystem - - - - - - - false - - - - - - - Antialiasing - - - - - - - Vertical Sync - - - - - - - Shader Language - - - - - - - - - - - - - - 16777215 - 2 - - - - color: rgb(215, 215, 215); - - - Qt::Horizontal - - - - - - - - - 10 - 8 - 371 - 156 - - - - Render System - - - - - - 9 - 169 - 371 - 101 - - - - title - - - displayGroup_Render - layoutWidget_Render - groupBox - Display Settings @@ -284,7 +171,7 @@ 10 100 - 191 + 201 51 @@ -299,14 +186,14 @@ 10 20 - 171 - 21 + 181 + 22 0 - + true @@ -315,7 +202,7 @@ 0 0 - 171 + 181 22 @@ -344,15 +231,15 @@ + + true + - - false - 0 0 - 171 + 181 22 @@ -373,13 +260,142 @@ Show Status Bar + layoutWidget_Subviews displayGroup_Window displayGroup_DisplayFormat displayGroup_Subviews - displayGroup_WindowSize cbStatusBar + + + Video Settings + + + + + 20 + 26 + 351 + 129 + + + + + + + Use Render System Settings from OpenMW + + + true + + + + + + + Rendering Subsystem + + + + + + + false + + + + + + + Antialiasing + + + + + + + Vertical Sync + + + + + + + Shader Language + + + + + + + + + + + + + + 16777215 + 2 + + + + color: rgb(215, 215, 215); + + + Qt::Horizontal + + + + + + + + + 10 + 8 + 371 + 156 + + + + Render System + + + + + + 9 + 169 + 371 + 101 + + + + title + + + displayGroup_Render + layoutWidget_Render + groupBox + + + cmbRecStatus + cmbRefIdType + sbWidth + sbHeight + cbStatusBar + spinBox_max_subviews + spinBox_min_subview_width + checkBox_reuse_subview + cbOverride + cmbRenderSys + cbVsync + cmbAntiAlias + cmbShaderLang + cmbStdWinSize + From c8ae8f4a6d9e98ef6a450304a7c0b16c1b14cc49 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 23 Sep 2014 06:30:41 +1000 Subject: [PATCH 22/48] Added minimum width setting for subviews - regionmap, table, scene, preview and dialogue. It should be noted that the setting is not the starting minimum width, i.e. it won't be possible to reduce the width of the subview after the creation. Also, one setting applies to all subviews. It may be desirable to have individual settings. --- apps/opencs/view/settings/dialog.cpp | 9 +++++++++ apps/opencs/view/world/dialoguesubview.cpp | 8 +++++++- apps/opencs/view/world/previewsubview.cpp | 11 ++++++++++- apps/opencs/view/world/regionmapsubview.cpp | 10 +++++++++- apps/opencs/view/world/scenesubview.cpp | 11 +++++++++-- apps/opencs/view/world/tablesubview.cpp | 8 ++++++++ files/ui/settingstab.ui | 6 +++--- 7 files changed, 55 insertions(+), 8 deletions(-) diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index 3f8143aa2..561eccc5c 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -299,6 +299,12 @@ void CSVSettings::Dialog::buildPages() if(index != -1) cmbRefIdType->setCurrentIndex(index); + // subview + if(model()->hasSettingDefinitions("SubView/minimum width")) + sbMinSubViewWidth->setValue(model()->settingValue("SubView/minimum width").toInt()); + else + sbMinSubViewWidth->setValue(325); + SettingWindow::createPages (); foreach (Page *page, SettingWindow::pages()) @@ -376,6 +382,9 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) QStringList(cmbRecStatus->currentText())); model()->setDefinitions("Display Format/Referenceable ID Type Display", QStringList(cmbRefIdType->currentText())); + // subview + model()->setDefinitions("SubView/minimum width", + QStringList(QString::number(sbMinSubViewWidth->value()))); saveSettings(); } diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index 57069bec0..d6a2bc13e 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -27,6 +27,7 @@ #include "../../model/world/tablemimedata.hpp" #include "../../model/doc/document.hpp" #include "../../model/world/commands.hpp" +#include "../../model/settings/usersettings.hpp" #include "recordstatusdelegate.hpp" #include "util.hpp" @@ -392,7 +393,12 @@ void CSVWorld::EditWidget::remake(int row) mWidgetMapper->setCurrentModelIndex(mTable->index(row, 0)); - this->setMinimumWidth(325); /// \todo replace hardcoded value with a user setting + int minWidth = 325; + if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) + minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); + else + CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); + this->setMinimumWidth(minWidth); this->setWidget(mMainWidget); this->setWidgetResizable(true); } diff --git a/apps/opencs/view/world/previewsubview.cpp b/apps/opencs/view/world/previewsubview.cpp index 1e106c69f..f56ca7674 100644 --- a/apps/opencs/view/world/previewsubview.cpp +++ b/apps/opencs/view/world/previewsubview.cpp @@ -8,6 +8,8 @@ #include "../widget/scenetoolbar.hpp" #include "../widget/scenetoolmode.hpp" +#include "../../model/settings/usersettings.hpp" + CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document) : SubView (id) { @@ -41,6 +43,13 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo widget->setLayout (layout); + int minWidth = 325; + if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) + minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); + else + CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); + widget->setMinimumWidth(minWidth); + setWidget (widget); connect (mScene, SIGNAL (closeRequest()), this, SLOT (closeRequest())); @@ -63,4 +72,4 @@ void CSVWorld::PreviewSubView::referenceableIdChanged (const std::string& id) setWindowTitle ("Preview: Reference to "); else setWindowTitle (("Preview: Reference to " + id).c_str()); -} \ No newline at end of file +} diff --git a/apps/opencs/view/world/regionmapsubview.cpp b/apps/opencs/view/world/regionmapsubview.cpp index a7675a4a6..2e20be349 100644 --- a/apps/opencs/view/world/regionmapsubview.cpp +++ b/apps/opencs/view/world/regionmapsubview.cpp @@ -2,6 +2,7 @@ #include "regionmapsubview.hpp" #include "regionmap.hpp" +#include "../../model/settings/usersettings.hpp" CSVWorld::RegionMapSubView::RegionMapSubView (CSMWorld::UniversalId universalId, CSMDoc::Document& document) @@ -9,6 +10,13 @@ CSVWorld::RegionMapSubView::RegionMapSubView (CSMWorld::UniversalId universalId, { mRegionMap = new RegionMap (universalId, document, this); + int minWidth = 325; + if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) + minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); + else + CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); + mRegionMap->setMinimumWidth(minWidth); + setWidget (mRegionMap); connect (mRegionMap, SIGNAL (editRequest (const CSMWorld::UniversalId&, const std::string&)), @@ -24,4 +32,4 @@ void CSVWorld::RegionMapSubView::editRequest (const CSMWorld::UniversalId& id, const std::string& hint) { focusId (id, hint); -} \ No newline at end of file +} diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index 52bd47b54..f2cc8505b 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -9,7 +9,7 @@ #include #include "../../model/doc/document.hpp" - +#include "../../model/settings/usersettings.hpp" #include "../../model/world/cellselection.hpp" #include "../filter/filterbox.hpp" @@ -74,6 +74,13 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D widget->setLayout (layout); + int minWidth = 325; + if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) + minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); + else + CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); + widget->setMinimumWidth(minWidth); + setWidget (widget); } @@ -254,4 +261,4 @@ void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceW mScene->selectDefaultNavigationMode(); setFocusProxy (mScene); -} \ No newline at end of file +} diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index e2c8d5c1e..4a87319eb 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -6,6 +6,7 @@ #include "../../model/doc/document.hpp" #include "../../model/world/tablemimedata.hpp" +#include "../../model/settings/usersettings.hpp" #include "../filter/filterbox.hpp" #include "table.hpp" @@ -34,6 +35,13 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D widget->setLayout (layout); + int minWidth = 325; + if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) + minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); + else + CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); + widget->setMinimumWidth(minWidth); + setWidget (widget); connect (mTable, SIGNAL (editRequest (const CSMWorld::UniversalId&, const std::string&)), diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index de7014b4a..88b7e9231 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -142,7 +142,7 @@ - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -260,10 +260,10 @@ Show Status Bar + displayGroup_Subviews layoutWidget_Subviews displayGroup_Window displayGroup_DisplayFormat - displayGroup_Subviews cbStatusBar @@ -387,7 +387,7 @@ sbHeight cbStatusBar spinBox_max_subviews - spinBox_min_subview_width + sbMinSubViewWidth checkBox_reuse_subview cbOverride cmbRenderSys From 437fb774c5c99966f637781914557566ce88ba87 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 23 Sep 2014 07:16:07 +1000 Subject: [PATCH 23/48] Re-implemented subview minimum size setting. --- apps/opencs/view/doc/view.cpp | 7 +++++++ apps/opencs/view/settings/dialog.cpp | 2 -- apps/opencs/view/world/dialoguesubview.cpp | 7 ------- apps/opencs/view/world/previewsubview.cpp | 9 --------- apps/opencs/view/world/regionmapsubview.cpp | 8 -------- apps/opencs/view/world/scenesubview.cpp | 7 ------- apps/opencs/view/world/tablesubview.cpp | 8 -------- files/ui/settingstab.ui | 6 ------ 8 files changed, 7 insertions(+), 47 deletions(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index c7186a4e6..e77b995fc 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -442,6 +442,13 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin if (!hint.empty()) view->useHint (hint); + int minWidth = 325; // default value if none found + if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) + minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); + else + CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); + view->setMinimumWidth(minWidth); + view->setStatusBar (mShowStatusBar->isChecked()); // NOTE: only required if show status bar setting should be applied to existing // window diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index 561eccc5c..d35492ea2 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -302,8 +302,6 @@ void CSVSettings::Dialog::buildPages() // subview if(model()->hasSettingDefinitions("SubView/minimum width")) sbMinSubViewWidth->setValue(model()->settingValue("SubView/minimum width").toInt()); - else - sbMinSubViewWidth->setValue(325); SettingWindow::createPages (); diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index d6a2bc13e..8790601ea 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -27,7 +27,6 @@ #include "../../model/world/tablemimedata.hpp" #include "../../model/doc/document.hpp" #include "../../model/world/commands.hpp" -#include "../../model/settings/usersettings.hpp" #include "recordstatusdelegate.hpp" #include "util.hpp" @@ -393,12 +392,6 @@ void CSVWorld::EditWidget::remake(int row) mWidgetMapper->setCurrentModelIndex(mTable->index(row, 0)); - int minWidth = 325; - if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) - minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); - else - CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); - this->setMinimumWidth(minWidth); this->setWidget(mMainWidget); this->setWidgetResizable(true); } diff --git a/apps/opencs/view/world/previewsubview.cpp b/apps/opencs/view/world/previewsubview.cpp index f56ca7674..316f7c71e 100644 --- a/apps/opencs/view/world/previewsubview.cpp +++ b/apps/opencs/view/world/previewsubview.cpp @@ -8,8 +8,6 @@ #include "../widget/scenetoolbar.hpp" #include "../widget/scenetoolmode.hpp" -#include "../../model/settings/usersettings.hpp" - CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document) : SubView (id) { @@ -43,13 +41,6 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo widget->setLayout (layout); - int minWidth = 325; - if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) - minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); - else - CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); - widget->setMinimumWidth(minWidth); - setWidget (widget); connect (mScene, SIGNAL (closeRequest()), this, SLOT (closeRequest())); diff --git a/apps/opencs/view/world/regionmapsubview.cpp b/apps/opencs/view/world/regionmapsubview.cpp index 2e20be349..411e24e75 100644 --- a/apps/opencs/view/world/regionmapsubview.cpp +++ b/apps/opencs/view/world/regionmapsubview.cpp @@ -2,7 +2,6 @@ #include "regionmapsubview.hpp" #include "regionmap.hpp" -#include "../../model/settings/usersettings.hpp" CSVWorld::RegionMapSubView::RegionMapSubView (CSMWorld::UniversalId universalId, CSMDoc::Document& document) @@ -10,13 +9,6 @@ CSVWorld::RegionMapSubView::RegionMapSubView (CSMWorld::UniversalId universalId, { mRegionMap = new RegionMap (universalId, document, this); - int minWidth = 325; - if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) - minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); - else - CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); - mRegionMap->setMinimumWidth(minWidth); - setWidget (mRegionMap); connect (mRegionMap, SIGNAL (editRequest (const CSMWorld::UniversalId&, const std::string&)), diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index f2cc8505b..699bf81f6 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -74,13 +74,6 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D widget->setLayout (layout); - int minWidth = 325; - if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) - minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); - else - CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); - widget->setMinimumWidth(minWidth); - setWidget (widget); } diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index 4a87319eb..e2c8d5c1e 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -6,7 +6,6 @@ #include "../../model/doc/document.hpp" #include "../../model/world/tablemimedata.hpp" -#include "../../model/settings/usersettings.hpp" #include "../filter/filterbox.hpp" #include "table.hpp" @@ -35,13 +34,6 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D widget->setLayout (layout); - int minWidth = 325; - if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) - minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); - else - CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); - widget->setMinimumWidth(minWidth); - setWidget (widget); connect (mTable, SIGNAL (editRequest (const CSMWorld::UniversalId&, const std::string&)), diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 88b7e9231..5a8d71976 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -146,12 +146,6 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - 325 - - - 20000 - 5 From 62406d53221fac74240393bda1e6402ed759037d Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 23 Sep 2014 07:28:55 +1000 Subject: [PATCH 24/48] Use reasonable values for the spinbox. --- apps/opencs/view/settings/dialog.cpp | 2 ++ files/ui/settingstab.ui | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index d35492ea2..561eccc5c 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -302,6 +302,8 @@ void CSVSettings::Dialog::buildPages() // subview if(model()->hasSettingDefinitions("SubView/minimum width")) sbMinSubViewWidth->setValue(model()->settingValue("SubView/minimum width").toInt()); + else + sbMinSubViewWidth->setValue(325); SettingWindow::createPages (); diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 5a8d71976..2aafdeb00 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -146,6 +146,12 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + 50 + + + 20000 + 5 From ffae816aabea9ac173456999d76eb047bda5f750 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 23 Sep 2014 17:01:08 +1000 Subject: [PATCH 25/48] Max subviews setting working. However there is no way to remove the last subview once the title bar is removed and the look of the filter box is broken without the title bar. --- apps/opencs/model/settings/usersettings.cpp | 10 --- apps/opencs/view/doc/subview.cpp | 9 +++ apps/opencs/view/doc/subview.hpp | 9 +++ apps/opencs/view/doc/view.cpp | 68 ++++++++++++++++++--- apps/opencs/view/doc/view.hpp | 6 +- apps/opencs/view/doc/viewmanager.cpp | 9 +++ apps/opencs/view/doc/viewmanager.hpp | 7 +++ apps/opencs/view/settings/dialog.cpp | 7 +++ files/ui/settingstab.ui | 7 ++- 9 files changed, 110 insertions(+), 22 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 3fcf083d1..82f4bc750 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -202,18 +202,8 @@ void UserSettings::buildSettingModelDefaults() spaceText2->setViewLocation(3, 7); #if 0 - sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", "false"); - - sh::Factory::getInstance ().setGlobalSetting ("render_refraction", "false"); - - sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false"); - - - sh::Factory::getInstance ().setSharedParameter ("windDir_windSpeed", sh::makeProperty(new sh::Vector3(0.5, -0.8, 0.2))); sh::Factory::getInstance ().setSharedParameter ("waterSunFade_sunHeight", sh::makeProperty(new sh::Vector2(1, 0.6))); -sh::Factory::getInstance ().setGlobalSetting ("refraction", Settings::Manager::getBool("refraction", "Water") ? "true" : "false"); -sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false"); sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makeProperty (new sh::Vector4(0,0,0,0))); #endif } diff --git a/apps/opencs/view/doc/subview.cpp b/apps/opencs/view/doc/subview.cpp index 9c3c4e5e9..be03f91a5 100644 --- a/apps/opencs/view/doc/subview.cpp +++ b/apps/opencs/view/doc/subview.cpp @@ -1,5 +1,7 @@ #include "subview.hpp" +#include "view.hpp" + CSVDoc::SubView::SubView (const CSMWorld::UniversalId& id) : mUniversalId (id) { /// \todo add a button to the title bar that clones this sub view @@ -25,3 +27,10 @@ void CSVDoc::SubView::setUniversalId (const CSMWorld::UniversalId& id) mUniversalId = id; setWindowTitle (mUniversalId.toString().c_str()); } + +void CSVDoc::SubView::closeEvent (QCloseEvent *event) +{ + // update title bars of view and subviews + if(mParent) + mParent->updateSubViewIndicies(this); +} diff --git a/apps/opencs/view/doc/subview.hpp b/apps/opencs/view/doc/subview.hpp index 733a75bb0..6a3ddd8bd 100644 --- a/apps/opencs/view/doc/subview.hpp +++ b/apps/opencs/view/doc/subview.hpp @@ -18,11 +18,14 @@ namespace CSMWorld namespace CSVDoc { + class View; + class SubView : public QDockWidget { Q_OBJECT CSMWorld::UniversalId mUniversalId; + View *mParent; // not implemented SubView (const SubView&); @@ -44,6 +47,12 @@ namespace CSVDoc virtual void useHint (const std::string& hint); ///< Default implementation: ignored + void setParent(View *parent) { mParent = parent; } + + private: + + void closeEvent (QCloseEvent *event); + signals: void focusId (const CSMWorld::UniversalId& universalId, const std::string& hint); diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index e77b995fc..b2317d77b 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -297,7 +297,7 @@ void CSVDoc::View::setupUi() setupDebugMenu(); } -void CSVDoc::View::updateTitle() +void CSVDoc::View::updateTitle(const std::string subview) { std::ostringstream stream; @@ -309,9 +309,37 @@ void CSVDoc::View::updateTitle() if (mViewTotal>1) stream << " [" << (mViewIndex+1) << "/" << mViewTotal << "]"; + if (subview != "") + stream << " - " << subview; + setWindowTitle (stream.str().c_str()); } +void CSVDoc::View::updateSubViewIndicies(SubView *view) +{ + if(view && mSubViews.contains(view)) + mSubViews.removeOne(view); + + if(mSubViews.size() == 1) + { + mSubViews.at(0)->setTitleBarWidget(new QWidget(this)); + updateTitle(mSubViews.at(0)->getUniversalId().getTypeName().c_str()); + } + else + { + updateTitle(); + if(mSubViews.size() > 1) + { + foreach(SubView * sb, mSubViews) + { + QWidget * tb = sb->titleBarWidget(); + if(tb) delete tb; + sb->setTitleBarWidget(0); + } + } + } +} + void CSVDoc::View::updateActions() { bool editing = !(mDocument->getState() & CSMDoc::State_Locked); @@ -421,11 +449,20 @@ void CSVDoc::View::updateProgress (int current, int max, int type, int threads) void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::string& hint) { - /// \todo add an user setting for limiting the number of sub views per top level view. Automatically open a new top level view if this - /// number is exceeded + CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); - /// \todo if the sub view limit setting is one, the sub view title bar should be hidden and the text in the main title bar 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))); + + if(mSubViews.size() >= maxSubView) // create a new top level view + { + mViewManager.addView(mDocument, id, hint); + + return; + } /// \todo add an user setting to reuse sub views (on a per document basis or on a per top level view basis) @@ -439,16 +476,29 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin view = mSubViewFactory.makeSubView (id, *mDocument); } assert(view); + view->setParent(this); + mSubViews.append(view); // only after assert if (!hint.empty()) view->useHint (hint); - int minWidth = 325; // default value if none found - if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width")) - minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt(); + int minWidth = 325; // default value to use if none found + if(userSettings.hasSettingDefinitions("SubView/minimum width")) + minWidth = userSettings.settingValue("SubView/minimum width").toInt(); else - CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth")); + userSettings.setDefinitions("SubView/minimum width", (QStringList() << QString(minWidth))); view->setMinimumWidth(minWidth); +#if 0 + if(mSubViews.size() == 1) // remove subview title and add to the main window + { + updateTitle(id.getTypeName().c_str()); + // FIXME: search area broken + view->setTitleBarWidget(new QWidget(this)); + } + else +#endif + updateSubViewIndicies(); + view->setStatusBar (mShowStatusBar->isChecked()); // NOTE: only required if show status bar setting should be applied to existing // window diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp index e7c813c5c..eab274a59 100644 --- a/apps/opencs/view/doc/view.hpp +++ b/apps/opencs/view/doc/view.hpp @@ -35,6 +35,7 @@ namespace CSVDoc CSMDoc::Document *mDocument; int mViewIndex; int mViewTotal; + QList mSubViews; QAction *mUndo; QAction *mRedo; QAction *mSave; @@ -74,7 +75,7 @@ namespace CSVDoc void setupUi(); - void updateTitle(); + void updateTitle(const std::string subview = ""); void updateActions(); @@ -113,6 +114,9 @@ namespace CSVDoc /// Function called by view manager when user preferences are updated void updateEditorSetting (const QString &, const QString &); + // called when subviews are added or removed + void updateSubViewIndicies(SubView *view = 0); + signals: void newGameRequest(); diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index d5e5e7027..39cd7eeda 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -9,6 +9,7 @@ #include "../../model/doc/documentmanager.hpp" #include "../../model/doc/document.hpp" #include "../../model/world/columns.hpp" +#include "../../model/world/universalid.hpp" #include "../world/util.hpp" #include "../world/enumdelegate.hpp" @@ -161,6 +162,14 @@ CSVDoc::View *CSVDoc::ViewManager::addView (CSMDoc::Document *document) return view; } +CSVDoc::View *CSVDoc::ViewManager::addView (CSMDoc::Document *document, const CSMWorld::UniversalId& id, const std::string& hint) +{ + View* view = addView(document); + view->addSubView(id, hint); + + return view; +} + int CSVDoc::ViewManager::countViews (const CSMDoc::Document *document) const { int count = 0; diff --git a/apps/opencs/view/doc/viewmanager.hpp b/apps/opencs/view/doc/viewmanager.hpp index 61b807960..d703b430a 100644 --- a/apps/opencs/view/doc/viewmanager.hpp +++ b/apps/opencs/view/doc/viewmanager.hpp @@ -18,6 +18,11 @@ namespace CSVWorld class CommandDelegateFactoryCollection; } +namespace CSMWorld +{ + class UniversalId; +} + namespace CSVDoc { class View; @@ -52,6 +57,8 @@ namespace CSVDoc View *addView (CSMDoc::Document *document); ///< The ownership of the returned view is not transferred. + View *addView (CSMDoc::Document *document, const CSMWorld::UniversalId& id, const std::string& hint); + int countViews (const CSMDoc::Document *document) const; ///< Return number of views for \a document. diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index 561eccc5c..e328384e8 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -305,6 +305,11 @@ void CSVSettings::Dialog::buildPages() else sbMinSubViewWidth->setValue(325); + if(model()->hasSettingDefinitions("SubView/max subviews")) + sbMaxSubViews->setValue(model()->settingValue("SubView/max subview").toInt()); + else + sbMaxSubViews->setValue(3); + SettingWindow::createPages (); foreach (Page *page, SettingWindow::pages()) @@ -385,6 +390,8 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) // subview model()->setDefinitions("SubView/minimum width", QStringList(QString::number(sbMinSubViewWidth->value()))); + model()->setDefinitions("SubView/max subviews", + QStringList(QString::number(sbMaxSubViews->value()))); saveSettings(); } diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 2aafdeb00..95c10367a 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -128,10 +128,13 @@ - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + 1 + @@ -386,7 +389,7 @@ sbWidth sbHeight cbStatusBar - spinBox_max_subviews + sbMaxSubViews sbMinSubViewWidth checkBox_reuse_subview cbOverride From d41230a0c56b6ea9054f7fbccc31c3500352c00f Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 23 Sep 2014 20:51:14 +1000 Subject: [PATCH 26/48] Tweak the look of the recordfilterbox. Keep titlebar if floating. --- apps/opencs/view/doc/view.cpp | 23 ++++++++------------- apps/opencs/view/filter/recordfilterbox.cpp | 2 +- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index b2317d77b..6c04ac322 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -322,8 +322,11 @@ void CSVDoc::View::updateSubViewIndicies(SubView *view) if(mSubViews.size() == 1) { - mSubViews.at(0)->setTitleBarWidget(new QWidget(this)); - updateTitle(mSubViews.at(0)->getUniversalId().getTypeName().c_str()); + if(!mSubViews.at(0)->isFloating()) + { + mSubViews.at(0)->setTitleBarWidget(new QWidget(this)); + updateTitle(mSubViews.at(0)->getUniversalId().getTypeName().c_str()); + } } else { @@ -471,7 +474,8 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin if(std::find(referenceables.begin(), referenceables.end(), id.getType()) != referenceables.end()) { view = mSubViewFactory.makeSubView (CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Referenceable, id.getId()), *mDocument); - } else + } + else { view = mSubViewFactory.makeSubView (id, *mDocument); } @@ -488,17 +492,6 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin userSettings.setDefinitions("SubView/minimum width", (QStringList() << QString(minWidth))); view->setMinimumWidth(minWidth); -#if 0 - if(mSubViews.size() == 1) // remove subview title and add to the main window - { - updateTitle(id.getTypeName().c_str()); - // FIXME: search area broken - view->setTitleBarWidget(new QWidget(this)); - } - else -#endif - updateSubViewIndicies(); - view->setStatusBar (mShowStatusBar->isChecked()); // NOTE: only required if show status bar setting should be applied to existing // window @@ -511,6 +504,8 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin mSubViewWindow.addDockWidget (Qt::TopDockWidgetArea, view); + updateSubViewIndicies(); + connect (view, SIGNAL (focusId (const CSMWorld::UniversalId&, const std::string&)), this, SLOT (addSubView (const CSMWorld::UniversalId&, const std::string&))); diff --git a/apps/opencs/view/filter/recordfilterbox.cpp b/apps/opencs/view/filter/recordfilterbox.cpp index ef2aeb4d3..97490d508 100644 --- a/apps/opencs/view/filter/recordfilterbox.cpp +++ b/apps/opencs/view/filter/recordfilterbox.cpp @@ -11,7 +11,7 @@ CSVFilter::RecordFilterBox::RecordFilterBox (CSMWorld::Data& data, QWidget *pare { QHBoxLayout *layout = new QHBoxLayout (this); - layout->setContentsMargins (0, 0, 0, 0); + layout->setContentsMargins (0, 6, 5, 0); QLabel *label = new QLabel("Record Filter", this); label->setIndent(2); From 67503c93b29839ab37929616a7d2f60d3241ddd9 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Tue, 23 Sep 2014 22:33:49 +1000 Subject: [PATCH 27/48] Added some scenewidget user settings but noticed during testing that the spinbox view resets the value if enter key is pressed. --- apps/opencs/model/settings/usersettings.cpp | 51 +++++++++++++++++++++ apps/opencs/view/render/scenewidget.cpp | 26 +++++++++-- 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 82f4bc750..e4cbac3c3 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -208,6 +208,57 @@ sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makePropertysetDefaultValue(4); + fastFactor->setEditorSetting(false); + fastFactor->setColumnSpan (1); + fastFactor->setMinimum (1); // FIXME: this function appears to be broken + fastFactor->setMaximum (100); // FIXME: not sure what the max value should be + fastFactor->setWidgetWidth (10); + fastFactor->setViewLocation(1, 2); + Setting *ffText = createSetting (Type_Undefined, page, "ffText"); + ffText->setSpecialValueText("Fast Factor"); // hack to place text labels + ffText->setEditorSetting(false); + ffText->setSerializable (false); + ffText->setColumnSpan (1); + ffText->setWidgetWidth (10); + ffText->setViewLocation(1, 1); + + Setting *farClipDist = createSetting (Type_SpinBox, page, "far clip distance"); + farClipDist->setDefaultValue(300000); + farClipDist->setEditorSetting(false); + farClipDist->setColumnSpan (1); + farClipDist->setMinimum (0); + farClipDist->setMaximum (1000000); // FIXME: not sure what the max value should be + farClipDist->setWidgetWidth (10); + farClipDist->setViewLocation(2, 2); + Setting *fcText = createSetting (Type_Undefined, page, "fcText"); + fcText->setSpecialValueText("Far Clip Distance"); // hack to place text labels + fcText->setEditorSetting(false); + fcText->setSerializable (false); + fcText->setColumnSpan (1); + fcText->setWidgetWidth (10); + fcText->setViewLocation(2, 1); + + Setting *timerStart = createSetting (Type_SpinBox, page, "timer start"); + timerStart->setDefaultValue(20); + timerStart->setEditorSetting(false); + timerStart->setColumnSpan (1); + timerStart->setMinimum (0); + timerStart->setMaximum (100); // FIXME: not sure what the max value should be + timerStart->setWidgetWidth (10); + timerStart->setViewLocation(3, 2); + Setting *tsText = createSetting (Type_Undefined, page, "tsText"); + tsText->setSpecialValueText("Timer Start"); // hack to place text labels + tsText->setEditorSetting(false); + tsText->setSerializable (false); + tsText->setColumnSpan (1); + tsText->setWidgetWidth (10); + tsText->setViewLocation(3, 1); + } + #if 0 page = "Window Size"; { diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 1a720ff33..8605f5d0f 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -13,6 +13,7 @@ #include #include "../widget/scenetoolmode.hpp" +#include "../../model/settings/usersettings.hpp" #include "navigation.hpp" #include "lighting.hpp" @@ -27,7 +28,7 @@ namespace CSVRender , mKeyForward (false), mKeyBackward (false), mKeyLeft (false), mKeyRight (false) , mKeyRollLeft (false), mKeyRollRight (false) , mFast (false), mDragging (false), mMod1 (false) - , mFastFactor (4) /// \todo make this configurable + , mFastFactor (4) , mDefaultAmbient (0, 0, 0, 0), mHasDefaultAmbient (false) { setAttribute(Qt::WA_PaintOnScreen); @@ -44,7 +45,20 @@ namespace CSVRender mCamera->setPosition (300, 0, 0); mCamera->lookAt (0, 0, 0); mCamera->setNearClipDistance (0.1); - mCamera->setFarClipDistance (300000); ///< \todo make this configurable + + 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))); + 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))); + mCamera->roll (Ogre::Degree (90)); setLighting (&mLightingDay); @@ -52,7 +66,13 @@ namespace CSVRender QTimer *timer = new QTimer (this); connect (timer, SIGNAL (timeout()), this, SLOT (update())); - timer->start (20); ///< \todo make this configurable + + 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))); + timer->start (timerStart); /// \todo make shortcut configurable QShortcut *focusToolbar = new QShortcut (Qt::Key_T, this, 0, 0, Qt::WidgetWithChildrenShortcut); From 970f3609c9df83ae6bae5962a9943f9df0d53543 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 24 Sep 2014 09:33:19 +1000 Subject: [PATCH 28/48] Fixed spinbox issue with integer entry via keyboard. Removed shader settings as per feedback comments. --- apps/opencs/editor.cpp | 37 ++++++++++---- apps/opencs/model/settings/usersettings.cpp | 55 ++------------------- apps/opencs/view/settings/spinbox.cpp | 2 +- 3 files changed, 31 insertions(+), 63 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 25e65b7ee..bdc61a5fe 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -314,20 +314,37 @@ std::auto_ptr CS::Editor::setupGraphics() factory->loadAllFiles(); - sh::Factory::getInstance().setGlobalSetting ("fog", - mUserSettings.settingValue("shader/fog").toStdString()); + std::string fog("true"); // default if setting does not exist + if(mUserSettings.hasSettingDefinitions("Shader/fog")) + fog = mUserSettings.settingValue("Shader/fog").toStdString(); + else + mUserSettings.setDefinitions("Shader/fog", (QStringList() << QString(fog.c_str()))); + sh::Factory::getInstance().setGlobalSetting ("fog", fog); - sh::Factory::getInstance().setGlobalSetting ("shadows", - mUserSettings.settingValue("shader/shadows").toStdString()); + std::string shadows("false"); + if(mUserSettings.hasSettingDefinitions("Shader/shadows")) + shadows = mUserSettings.settingValue("Shader/shadows").toStdString(); + else + mUserSettings.setDefinitions("Shader/shadows", (QStringList() << QString(shadows.c_str()))); + sh::Factory::getInstance().setGlobalSetting ("shadows", shadows); - sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", - mUserSettings.settingValue("shader/shadows_pssm").toStdString()); + 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()))); + sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", shadows_pssm); - sh::Factory::getInstance ().setGlobalSetting ("render_refraction", - mUserSettings.settingValue("shader/render_refraction").toStdString()); - sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", - mUserSettings.settingValue("shader/viewproj_fix").toStdString()); + 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()))); + sh::Factory::getInstance ().setGlobalSetting ("render_refraction", render_refraction); + + // internal setting - may be switched on or off by the use of shader configurations + sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false"); sh::Factory::getInstance ().setGlobalSetting ("num_lights", mUserSettings.settingValue("shader/num_lights").toStdString()); diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index e4cbac3c3..95da7d150 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -59,36 +59,6 @@ void UserSettings::buildSettingModelDefaults() { QString section = "Group1"; - Setting *fog = createSetting (Type_CheckBox, page, "fog"); - fog->setDeclaredValues(QStringList() << "true" << "false"); - fog->setDefaultValue("true"); - fog->setEditorSetting(true); - fog->setSpecialValueText("Enable Fog"); - fog->setWidgetWidth(15); - fog->setColumnSpan (2); - fog->setStyleSheet ("QGroupBox { border: 0px; spacing: 5; }"); - fog->setViewLocation(1, 1); - - Setting *shadows = createSetting (Type_CheckBox, page, "shadows"); - shadows->setDeclaredValues(QStringList() << "true" << "false"); - shadows->setDefaultValue("false"); - shadows->setEditorSetting(true); - shadows->setSpecialValueText("Enable Shadows"); - shadows->setWidgetWidth(15); - shadows->setColumnSpan (2); - shadows->setStyleSheet ("QGroupBox { border: 0px; }"); - shadows->setViewLocation(2, 1); - - Setting *shadows_pssm = createSetting (Type_CheckBox, page, "shadows_pssm"); - shadows_pssm->setDeclaredValues(QStringList() << "true" << "false"); - shadows_pssm->setDefaultValue("false"); - shadows_pssm->setEditorSetting(true); - shadows_pssm->setSpecialValueText("Enable PSSM Shadows"); - shadows_pssm->setWidgetWidth(15); - shadows_pssm->setColumnSpan (2); - shadows_pssm->setStyleSheet ("QGroupBox { border: 0px; spacing: 5; }"); - shadows_pssm->setViewLocation(3, 1); - Setting *numLights = createSetting (Type_SpinBox, page, "num lights"); numLights->setDefaultValue(8); numLights->setEditorSetting(true); @@ -97,34 +67,15 @@ void UserSettings::buildSettingModelDefaults() numLights->setMaximum (100); // FIXME: not sure what the max value should be numLights->setWidgetWidth (10); numLights->setSpecialValueText ("Nothing!"); // text to display when value is 0 - numLights->setViewLocation(4, 2); + numLights->setViewLocation(1, 2); Setting *nlText = createSetting (Type_Undefined, page, "nlText"); nlText->setSpecialValueText("Num Lights"); // hack to place text labels nlText->setEditorSetting(false); nlText->setSerializable (false); nlText->setColumnSpan (1); nlText->setWidgetWidth (10); - nlText->setViewLocation(4, 1); - - Setting *renderRefraction = createSetting (Type_CheckBox, page, "renderRefraction"); - renderRefraction->setDeclaredValues(QStringList() << "true" << "false"); - renderRefraction->setDefaultValue("false"); - renderRefraction->setEditorSetting(true); - renderRefraction->setSpecialValueText("Enable Render Refraction"); - renderRefraction->setWidgetWidth(20); - renderRefraction->setColumnSpan (2); - renderRefraction->setStyleSheet ("QGroupBox { border: 0px; }"); - renderRefraction->setViewLocation(5, 1); - - Setting *viewproj_fix = createSetting (Type_CheckBox, page, "viewproj_fix"); - viewproj_fix->setDeclaredValues(QStringList() << "true" << "false"); - viewproj_fix->setDefaultValue("false"); - viewproj_fix->setEditorSetting(true); - viewproj_fix->setSpecialValueText("View Proj Fix"); - viewproj_fix->setWidgetWidth(20); - viewproj_fix->setColumnSpan (2); - viewproj_fix->setStyleSheet ("QGroupBox { border: 0px; }"); - viewproj_fix->setViewLocation(6, 1); + nlText->setViewLocation(1, 1); + Setting *simpleWater = createSetting (Type_CheckBox, page, "simple_water"); simpleWater->setDeclaredValues(QStringList() << "true" << "false"); diff --git a/apps/opencs/view/settings/spinbox.cpp b/apps/opencs/view/settings/spinbox.cpp index 4b1447f8f..c70fc36d1 100644 --- a/apps/opencs/view/settings/spinbox.cpp +++ b/apps/opencs/view/settings/spinbox.cpp @@ -24,7 +24,7 @@ QString CSVSettings::SpinBox::textFromValue(int val) const int CSVSettings::SpinBox::valueFromText(const QString &text) const { if (mValueList.isEmpty()) - return -1; + return text.toInt(); // TODO: assumed integer, untested error handling for alpha types if (mValueList.contains (text)) return mValueList.indexOf(text); From 3f9b73812b4a8a823f28631614d1492df6060776 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 24 Sep 2014 11:55:22 +1000 Subject: [PATCH 29/48] Minor fixes and workarounds. --- apps/opencs/model/settings/usersettings.cpp | 14 ++++++++------ apps/opencs/view/settings/dialog.cpp | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 95da7d150..42fd897b2 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -94,7 +94,6 @@ void UserSettings::buildSettingModelDefaults() waterEnabled->setMinimum (0); waterEnabled->setMaximum (100.00); // FIXME: not sure what the max value should be waterEnabled->setWidgetWidth (10); - //waterEnabled->setStyleSheet("QGroupBox { border:2px; padding 2px; margin: 2px;} QGroupBox::title { text: \"test\" }"); waterEnabled->setViewLocation(2, 6); Setting *weText = createSetting (Type_Undefined, page, "weText"); weText->setSpecialValueText("Water Enabled"); @@ -113,7 +112,7 @@ void UserSettings::buildSettingModelDefaults() waterLevel->setWidgetWidth (10); waterLevel->setViewLocation(3, 6); Setting *wlText = createSetting (Type_Undefined, page, "wlText"); - wlText->setSpecialValueText("Water Level"); // hack to place text labels + wlText->setSpecialValueText("Water Level"); wlText->setEditorSetting(false); wlText->setSerializable (false); wlText->setColumnSpan (1); @@ -129,7 +128,7 @@ void UserSettings::buildSettingModelDefaults() waterTimer->setWidgetWidth (10); waterTimer->setViewLocation(4, 6); Setting *wtText = createSetting (Type_Undefined, page, "wtText"); - wtText->setSpecialValueText("Water Timer"); // hack to place text labels + wtText->setSpecialValueText("Water Timer"); wtText->setEditorSetting(false); wtText->setSerializable (false); wtText->setColumnSpan (1); @@ -165,7 +164,10 @@ sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makePropertysetDefaultValue(4); fastFactor->setEditorSetting(false); fastFactor->setColumnSpan (1); - fastFactor->setMinimum (1); // FIXME: this function appears to be broken + // FIXME: setMinimum or setSpecialVlueText appears to be broken, possibly due + // to there being an empty string default for special value text. + fastFactor->setMinimum (1); + fastFactor->setSpecialValueText("1"); // workaround for above fastFactor->setMaximum (100); // FIXME: not sure what the max value should be fastFactor->setWidgetWidth (10); fastFactor->setViewLocation(1, 2); @@ -186,7 +188,7 @@ sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makePropertysetWidgetWidth (10); farClipDist->setViewLocation(2, 2); Setting *fcText = createSetting (Type_Undefined, page, "fcText"); - fcText->setSpecialValueText("Far Clip Distance"); // hack to place text labels + fcText->setSpecialValueText("Far Clip Distance"); fcText->setEditorSetting(false); fcText->setSerializable (false); fcText->setColumnSpan (1); @@ -202,7 +204,7 @@ sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makePropertysetWidgetWidth (10); timerStart->setViewLocation(3, 2); Setting *tsText = createSetting (Type_Undefined, page, "tsText"); - tsText->setSpecialValueText("Timer Start"); // hack to place text labels + tsText->setSpecialValueText("Timer Start"); tsText->setEditorSetting(false); tsText->setSerializable (false); tsText->setColumnSpan (1); diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index e328384e8..7d2b8f0a5 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -306,7 +306,7 @@ void CSVSettings::Dialog::buildPages() sbMinSubViewWidth->setValue(325); if(model()->hasSettingDefinitions("SubView/max subviews")) - sbMaxSubViews->setValue(model()->settingValue("SubView/max subview").toInt()); + sbMaxSubViews->setValue(model()->settingValue("SubView/max subviews").toInt()); else sbMaxSubViews->setValue(3); From fdf375fb4d21d19373e2be16b4ddba3069804c8f Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 24 Sep 2014 13:49:19 +1000 Subject: [PATCH 30/48] Reusing subviews implemented. --- apps/opencs/view/doc/view.cpp | 30 +++++++++++++++++++++++++--- apps/opencs/view/settings/dialog.cpp | 7 +++++++ files/ui/settingstab.ui | 4 ++-- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 6c04ac322..baa3a3608 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -454,6 +454,33 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin { CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); + const std::vector referenceables(CSMWorld::UniversalId::listReferenceableTypes()); + 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"))); + if(reuse) + { + foreach(SubView *sb, mSubViews) + { + if((isReferenceable && (CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Referenceable, id.getId()) == CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Referenceable, sb->getUniversalId().getId()))) + || (!isReferenceable && (id == sb->getUniversalId()))) + { + sb->setFocus(Qt::OtherFocusReason); // FIXME: focus not quite working + return; + } + } + } + + // User setting for limiting the number of sub views per top level view. + // Automatically open a new top level view if this number is exceeded + // + // 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(); @@ -467,9 +494,6 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin return; } - /// \todo add an user setting to reuse sub views (on a per document basis or on a per top level view basis) - - const std::vector referenceables(CSMWorld::UniversalId::listReferenceableTypes()); SubView *view = NULL; if(std::find(referenceables.begin(), referenceables.end(), id.getType()) != referenceables.end()) { diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index 7d2b8f0a5..f2d38bab9 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -310,6 +310,8 @@ void CSVSettings::Dialog::buildPages() else sbMaxSubViews->setValue(3); + cbReuseSubView->setChecked(model()->settingValue("SubView/reuse") == "true"); + SettingWindow::createPages (); foreach (Page *page, SettingWindow::pages()) @@ -393,6 +395,11 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) 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(); } diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index 95c10367a..e44a51f5a 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -161,7 +161,7 @@ - + Reuse Subviews @@ -391,7 +391,7 @@ cbStatusBar sbMaxSubViews sbMinSubViewWidth - checkBox_reuse_subview + cbReuseSubView cbOverride cmbRenderSys cbVsync From 66852d5392fff015acab5081eea9a3284ec2fbd2 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 24 Sep 2014 22:41:49 +1000 Subject: [PATCH 31/48] Code cleanup and revert incorrect settings. --- apps/opencs/editor.cpp | 13 +- apps/opencs/model/settings/usersettings.cpp | 122 +----- apps/opencs/view/doc/view.cpp | 11 - apps/opencs/view/doc/viewmanager.cpp | 7 - apps/opencs/view/doc/viewmanager.hpp | 2 - apps/opencs/view/settings/dialog.cpp | 73 +--- apps/opencs/view/settings/dialog.hpp | 6 - apps/opencs/view/settings/frame.cpp | 5 +- files/ui/settingstab.ui | 404 ++++++++------------ 9 files changed, 183 insertions(+), 460 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index bdc61a5fe..960e54e88 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -314,7 +314,14 @@ std::auto_ptr CS::Editor::setupGraphics() factory->loadAllFiles(); - std::string fog("true"); // default if setting does not exist + 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"))); + sh::Factory::getInstance ().setShadersEnabled (shaders); + + std::string fog("true"); if(mUserSettings.hasSettingDefinitions("Shader/fog")) fog = mUserSettings.settingValue("Shader/fog").toStdString(); else @@ -323,7 +330,7 @@ std::auto_ptr CS::Editor::setupGraphics() std::string shadows("false"); if(mUserSettings.hasSettingDefinitions("Shader/shadows")) - shadows = mUserSettings.settingValue("Shader/shadows").toStdString(); + shadows = shaders? mUserSettings.settingValue("Shader/shadows").toStdString() : "false"; else mUserSettings.setDefinitions("Shader/shadows", (QStringList() << QString(shadows.c_str()))); sh::Factory::getInstance().setGlobalSetting ("shadows", shadows); @@ -347,7 +354,7 @@ std::auto_ptr CS::Editor::setupGraphics() sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false"); sh::Factory::getInstance ().setGlobalSetting ("num_lights", - mUserSettings.settingValue("shader/num_lights").toStdString()); + mUserSettings.settingValue("Objects/num_lights").toStdString()); /// \todo add more configurable shiny settings diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 42fd897b2..44473c03d 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -55,7 +55,7 @@ void UserSettings::buildSettingModelDefaults() { QString page; - page = "Shader"; + page = "Objects"; { QString section = "Group1"; @@ -66,96 +66,17 @@ void UserSettings::buildSettingModelDefaults() numLights->setMinimum (0); numLights->setMaximum (100); // FIXME: not sure what the max value should be numLights->setWidgetWidth (10); - numLights->setSpecialValueText ("Nothing!"); // text to display when value is 0 numLights->setViewLocation(1, 2); - Setting *nlText = createSetting (Type_Undefined, page, "nlText"); - nlText->setSpecialValueText("Num Lights"); // hack to place text labels - nlText->setEditorSetting(false); - nlText->setSerializable (false); - nlText->setColumnSpan (1); - nlText->setWidgetWidth (10); - nlText->setViewLocation(1, 1); - - - Setting *simpleWater = createSetting (Type_CheckBox, page, "simple_water"); - simpleWater->setDeclaredValues(QStringList() << "true" << "false"); - simpleWater->setDefaultValue("false"); - simpleWater->setEditorSetting(true); - simpleWater->setSpecialValueText("Enable Simple Water"); - simpleWater->setWidgetWidth(25); - simpleWater->setColumnSpan (3); - simpleWater->setStyleSheet ("QGroupBox { border: 0px; }"); - simpleWater->setViewLocation(1, 5); - - Setting *waterEnabled = createSetting (Type_DoubleSpinBox, page, "waterEnabled"); - waterEnabled->setDefaultValue(0.00); - waterEnabled->setEditorSetting(true); - waterEnabled->setColumnSpan (1); - waterEnabled->setMinimum (0); - waterEnabled->setMaximum (100.00); // FIXME: not sure what the max value should be - waterEnabled->setWidgetWidth (10); - waterEnabled->setViewLocation(2, 6); - Setting *weText = createSetting (Type_Undefined, page, "weText"); - weText->setSpecialValueText("Water Enabled"); - weText->setEditorSetting(false); - weText->setSerializable (false); - weText->setColumnSpan (1); - weText->setWidgetWidth (10); - weText->setViewLocation(2, 5); - - Setting *waterLevel = createSetting (Type_DoubleSpinBox, page, "waterLevel"); - waterLevel->setDefaultValue(0.00); - waterLevel->setEditorSetting(true); - waterLevel->setColumnSpan (1); - waterLevel->setMinimum (0); - waterLevel->setMaximum (100.00); // FIXME: not sure what the max value should be - waterLevel->setWidgetWidth (10); - waterLevel->setViewLocation(3, 6); - Setting *wlText = createSetting (Type_Undefined, page, "wlText"); - wlText->setSpecialValueText("Water Level"); - wlText->setEditorSetting(false); - wlText->setSerializable (false); - wlText->setColumnSpan (1); - wlText->setWidgetWidth (10); - wlText->setViewLocation(3, 5); - - Setting *waterTimer = createSetting (Type_DoubleSpinBox, page, "waterTimer"); - waterTimer->setDefaultValue(0.00); - waterTimer->setEditorSetting(true); - waterTimer->setColumnSpan (1); - waterTimer->setMinimum (0); - waterTimer->setMaximum (100.00); // FIXME: not sure what the max value should be - waterTimer->setWidgetWidth (10); - waterTimer->setViewLocation(4, 6); - Setting *wtText = createSetting (Type_Undefined, page, "wtText"); - wtText->setSpecialValueText("Water Timer"); - wtText->setEditorSetting(false); - wtText->setSerializable (false); - wtText->setColumnSpan (1); - wtText->setWidgetWidth (10); - wtText->setViewLocation(4, 5); - - - Setting *spaceText = createSetting (Type_Undefined, page, "spaceText"); - spaceText->setSpecialValueText(" "); - spaceText->setEditorSetting(false); - spaceText->setSerializable (false); - spaceText->setColumnSpan (1); - spaceText->setWidgetWidth (5); - spaceText->setViewLocation(3, 4); - Setting *spaceText2 = createSetting (Type_Undefined, page, "spaceText2"); - spaceText2->setSpecialValueText(" "); - spaceText2->setEditorSetting(false); - spaceText2->setSerializable (false); - spaceText2->setColumnSpan (1); - spaceText2->setWidgetWidth (5); - spaceText2->setViewLocation(3, 7); -#if 0 -sh::Factory::getInstance ().setSharedParameter ("windDir_windSpeed", sh::makeProperty(new sh::Vector3(0.5, -0.8, 0.2))); -sh::Factory::getInstance ().setSharedParameter ("waterSunFade_sunHeight", sh::makeProperty(new sh::Vector2(1, 0.6))); -sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makeProperty (new sh::Vector4(0,0,0,0))); -#endif + Setting *shaders = createSetting (Type_CheckBox, page, "shaders"); + shaders->setDeclaredValues(QStringList() << "true" << "false"); + shaders->setDefaultValue("true"); + shaders->setEditorSetting(true); + shaders->setSpecialValueText("Enable Shaders"); + shaders->setWidgetWidth(25); + shaders->setColumnSpan (3); + shaders->setStyleSheet ("QGroupBox { border: 0px; }"); + shaders->setViewLocation(2, 1); } page = "Scene"; @@ -171,13 +92,6 @@ sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makePropertysetMaximum (100); // FIXME: not sure what the max value should be fastFactor->setWidgetWidth (10); fastFactor->setViewLocation(1, 2); - Setting *ffText = createSetting (Type_Undefined, page, "ffText"); - ffText->setSpecialValueText("Fast Factor"); // hack to place text labels - ffText->setEditorSetting(false); - ffText->setSerializable (false); - ffText->setColumnSpan (1); - ffText->setWidgetWidth (10); - ffText->setViewLocation(1, 1); Setting *farClipDist = createSetting (Type_SpinBox, page, "far clip distance"); farClipDist->setDefaultValue(300000); @@ -187,13 +101,6 @@ sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makePropertysetMaximum (1000000); // FIXME: not sure what the max value should be farClipDist->setWidgetWidth (10); farClipDist->setViewLocation(2, 2); - Setting *fcText = createSetting (Type_Undefined, page, "fcText"); - fcText->setSpecialValueText("Far Clip Distance"); - fcText->setEditorSetting(false); - fcText->setSerializable (false); - fcText->setColumnSpan (1); - fcText->setWidgetWidth (10); - fcText->setViewLocation(2, 1); Setting *timerStart = createSetting (Type_SpinBox, page, "timer start"); timerStart->setDefaultValue(20); @@ -203,13 +110,6 @@ sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makePropertysetMaximum (100); // FIXME: not sure what the max value should be timerStart->setWidgetWidth (10); timerStart->setViewLocation(3, 2); - Setting *tsText = createSetting (Type_Undefined, page, "tsText"); - tsText->setSpecialValueText("Timer Start"); - tsText->setEditorSetting(false); - tsText->setSerializable (false); - tsText->setColumnSpan (1); - tsText->setWidgetWidth (10); - tsText->setViewLocation(3, 1); } #if 0 @@ -251,6 +151,7 @@ sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makePropertysetEditorSetting (true); ritd->setEditorSetting (true); } -#endif page = "Proxy Selection Test"; { diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index baa3a3608..3a62aeafb 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -376,9 +376,6 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to hide(); resize (width.toInt() - (frameGeometry().width() - geometry().width()), height.toInt() - (frameGeometry().height() - geometry().height())); - // start at the centre of the screen - QPoint screenCenter = QApplication::desktop()->screenGeometry().center(); - move(screenCenter - QPoint(frameGeometry().width()/2, frameGeometry().height()/2)); mSubViewWindow.setDockOptions (QMainWindow::AllowNestedDocks); @@ -517,14 +514,6 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin view->setMinimumWidth(minWidth); 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); diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index 39cd7eeda..2b46eecd2 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -401,13 +401,6 @@ 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 d703b430a..cdd5ac768 100644 --- a/apps/opencs/view/doc/viewmanager.hpp +++ b/apps/opencs/view/doc/viewmanager.hpp @@ -81,8 +81,6 @@ 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/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index f2d38bab9..7648813bf 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -87,27 +87,12 @@ QStringList getAvailableResolutions() Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); for(;it != renderOpt.end(); ++it) { - if(it->first == "Rendering Device" ) - { - if(it->second.possibleValues.empty()) - { - return result; // FIXME: add error message - } - // Store Available Rendering Devices - Ogre::StringVector::iterator iter = it->second.possibleValues.begin(); - for(;iter != it->second.possibleValues.end(); ++iter) - { - std::cout << "rd: " << *iter << std::endl; // FIXME: debug - } - } if(it->first == "Video Mode" ) { if(it->second.possibleValues.empty()) { return result; // FIXME: add error message } - // FIXME: how to default to the current value? - std::cout << "vm current: " << it->second.currentValue << std::endl; // FIXME: debug // Store Available Resolutions Ogre::StringVector::iterator iter = it->second.possibleValues.begin(); for(; iter != it->second.possibleValues.end(); ++iter) @@ -138,7 +123,7 @@ QStringList getAvailableResolutions() CSVSettings::Dialog::Dialog(QTabWidget *parent) - : /*mStackedWidget (0),*/ mDebugMode (false), SettingWindow (parent) + : mDebugMode (false), SettingWindow (parent) { setObjectName(QString::fromUtf8 ("User Settings")); @@ -151,12 +136,8 @@ CSVSettings::Dialog::Dialog(QTabWidget *parent) connect(cbOverride, SIGNAL(toggled(bool)), this, SLOT(slotOverrideToggled(bool))); connect(cmbRenderSys, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(slotRendererChanged(const QString&))); - // to update the checkbox on the view menu - connect(cbStatusBar, SIGNAL(toggled(bool)), this, SIGNAL (toggleStatusBar(bool))); displayGroup_Window->installEventFilter(this); - - setupDialog(); } bool CSVSettings::Dialog::eventFilter(QObject *target, QEvent *event) @@ -185,19 +166,6 @@ void CSVSettings::Dialog::slotRendererChanged(const QString &renderer) cmbShaderLang->clear(); cmbShaderLang->addItems(model()->getShaderLanguageByRenderer(renderer)); - - if(model()->settingValue("Video/use settings.cfg") == "true") - { - labRenderSys->setEnabled(false); - cmbRenderSys->setEnabled(false); - labAntiAlias->setEnabled(false); - cmbAntiAlias->setEnabled(false); - //cbVsync->setEnabled(false); - labShaderLang->setEnabled(false); - cmbShaderLang->setEnabled(false); - } - else - cbOverride->setChecked(false); } void CSVSettings::Dialog::slotOverrideToggled(bool checked) @@ -208,7 +176,6 @@ void CSVSettings::Dialog::slotOverrideToggled(bool checked) cmbRenderSys->setEnabled(false); labAntiAlias->setEnabled(false); cmbAntiAlias->setEnabled(false); - //cbVsync->setEnabled(false); labShaderLang->setEnabled(false); cmbShaderLang->setEnabled(false); } @@ -218,16 +185,11 @@ void CSVSettings::Dialog::slotOverrideToggled(bool checked) cmbRenderSys->setEnabled(true); labAntiAlias->setEnabled(true); cmbAntiAlias->setEnabled(true); - //cbVsync->setEnabled(true); labShaderLang->setEnabled(true); cmbShaderLang->setEnabled(true); } } -void CSVSettings::Dialog::setupDialog() -{ -} - void CSVSettings::Dialog::buildPages() { int index = -1; @@ -238,7 +200,6 @@ void CSVSettings::Dialog::buildPages() // Ogre renderer cmbRenderSys->clear(); cmbRenderSys->addItems(model()->getOgreRenderers()); - //slotRendererChanged(Ogre::Root::getSingleton().getRenderSystem()->getName().c_str()); // antialiasing QString antialiasing = model()->settingValue("Video/antialiasing"); @@ -246,11 +207,6 @@ void CSVSettings::Dialog::buildPages() if(index != -1) cmbAntiAlias->setCurrentIndex(index); - // vsync - //cbVsync->setChecked(model()->settingValue("Video/vsync") == "true"); - cbVsync->setChecked(false); // disable vsync option for now - cbVsync->setEnabled(false); // disable vsync option for now - // shader lang QString shaderlang = model()->settingValue("General/shader mode"); index = cmbShaderLang->findData(shaderlang, Qt::DisplayRole); @@ -288,17 +244,6 @@ void CSVSettings::Dialog::buildPages() // status bar cbStatusBar->setChecked(model()->settingValue("Display/show statusbar") == "true"); - // display format - QString recStat = model()->settingValue("Display Format/Record Status Display"); - index = cmbRecStatus->findData(recStat, Qt::DisplayRole); - if(index != -1) - cmbRecStatus->setCurrentIndex(index); - - QString refIdType = model()->settingValue("Display Format/Referenceable ID Type Display"); - index = cmbRefIdType->findData(refIdType, Qt::DisplayRole); - if(index != -1) - cmbRefIdType->setCurrentIndex(index); - // subview if(model()->hasSettingDefinitions("SubView/minimum width")) sbMinSubViewWidth->setValue(model()->settingValue("SubView/minimum width").toInt()); @@ -341,20 +286,9 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) model()->setDefinitions("Video/render system", QStringList(cmbRenderSys->currentText())); - // vsync - if(cbVsync->isChecked()) - model()->setDefinitions("Video/vsync", QStringList("true")); - else - model()->setDefinitions("Video/vsync", QStringList("false")); - // antialiasing model()->setDefinitions("Video/antialiasing", QStringList(cmbAntiAlias->currentText())); -#if 0 - QRegExp reAA("^\\D*(\\d+)\\D*"); - if(reAA.indexIn(cmbAntiAlias->currentText()) > -1) - model()->setDefinitions("Video/antialiasing", QStringList(reAA.cap(1))); -#endif // shader lang (no group means "General" group) model()->setDefinitions("shader mode", @@ -384,11 +318,6 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event) else model()->setDefinitions("Display/show statusbar", QStringList("false")); - // display format - model()->setDefinitions("Display Format/Record Status Display", - QStringList(cmbRecStatus->currentText())); - model()->setDefinitions("Display Format/Referenceable ID Type Display", - QStringList(cmbRefIdType->currentText())); // subview model()->setDefinitions("SubView/minimum width", QStringList(QString::number(sbMinSubViewWidth->value()))); diff --git a/apps/opencs/view/settings/dialog.hpp b/apps/opencs/view/settings/dialog.hpp index e2e93d8a1..cfe48b618 100644 --- a/apps/opencs/view/settings/dialog.hpp +++ b/apps/opencs/view/settings/dialog.hpp @@ -31,8 +31,6 @@ namespace CSVSettings { /// Settings are written on close void closeEvent (QCloseEvent *event); - void setupDialog(); - bool eventFilter(QObject *target, QEvent *event); private: @@ -47,10 +45,6 @@ namespace CSVSettings { void slotOverrideToggled(bool checked); void slotRendererChanged(const QString &renderer); - - signals: - - void toggleStatusBar(bool checked); // FIXME: maybe not needed }; } #endif // CSVSETTINGS_DIALOG_H diff --git a/apps/opencs/view/settings/frame.cpp b/apps/opencs/view/settings/frame.cpp index c39eba890..a3df2a993 100644 --- a/apps/opencs/view/settings/frame.cpp +++ b/apps/opencs/view/settings/frame.cpp @@ -3,7 +3,7 @@ #include const QString CSVSettings::Frame::sInvisibleBoxStyle = - QString::fromUtf8("Frame { border:2px; padding 2px; margin: 2px;}"); + QString::fromUtf8("Frame { border:2px; padding: 2px; margin: 2px;}"); CSVSettings::Frame::Frame (bool isVisible, const QString &title, QWidget *parent) @@ -16,8 +16,7 @@ CSVSettings::Frame::Frame (bool isVisible, const QString &title, if (!isVisible) { // must be Page, not a View - //setStyleSheet (sInvisibleBoxStyle); - setStyleSheet("QGroupBox { border:0px; }"); + setStyleSheet (sInvisibleBoxStyle); mLayout->setContentsMargins(10, 15, 10, 15); } diff --git a/files/ui/settingstab.ui b/files/ui/settingstab.ui index e44a51f5a..0a94348d1 100644 --- a/files/ui/settingstab.ui +++ b/files/ui/settingstab.ui @@ -20,161 +20,51 @@ Display Settings - + 10 - 10 + 200 371 - 81 + 79 - Display Format + Subviews - + - 10 - 20 - 351 - 48 + 240 + 21 + 102 + 17 - - - - - Record Status: - - - - - - - - Text Only - - - - - Icon Only - - - - - Icon and Text - - - - - - - - Referenceable ID Type: - - - - - - - - Text Only - - - - - Icon Only - - - - - Icon and Text - - - - - + + Show Status Bar + + + + + + 240 + 49 + 101 + 17 + + + + Reuse Subviews + - - - - - 9 - 160 - 371 - 101 - - - - Subviews - - - - - - 21 - 180 - 351 - 71 - - - - - - - Max Number of Subviews: - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1 - - - - - - - Min Subview Width: - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 50 - - - 20000 - - - 5 - - - - - - - Reuse Subviews - - - - 10 - 100 - 201 + 140 + 211 51 @@ -189,7 +79,7 @@ 10 20 - 181 + 191 22 @@ -205,7 +95,7 @@ 0 0 - 181 + 191 22 @@ -242,7 +132,7 @@ 0 0 - 181 + 191 22 @@ -250,153 +140,177 @@ - + - 240 - 120 - 102 + 21 + 29 + 231 17 - Show Status Bar + Use Render System Settings from OpenMW + + + true - displayGroup_Subviews - layoutWidget_Subviews - displayGroup_Window - displayGroup_DisplayFormat - cbStatusBar - - - - Video Settings - - + + + + 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 - 26 - 351 - 129 + 220 + 191 + 48 - - - - - Use Render System Settings from OpenMW - - - true - - - - - + + + - Rendering Subsystem + Max Number of Subviews: - - - - false + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - Antialiasing + + 1 - - + + - Vertical Sync + Min Subview Width: - - - - Shader Language + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - 16777215 - 2 - + + 50 - - color: rgb(215, 215, 215); + + 20000 - - Qt::Horizontal + + 5 - - - - 10 - 8 - 371 - 156 - - - - Render System - - - - - - 9 - 169 - 371 - 101 - - - - title - - displayGroup_Render - layoutWidget_Render - groupBox + displayGroup_Subviews + displayGroup_Window + cbOverride + layoutWidget_2 - cmbRecStatus - cmbRefIdType + cbOverride + cmbRenderSys + cmbShaderLang + cmbAntiAlias sbWidth sbHeight - cbStatusBar sbMaxSubViews sbMinSubViewWidth + cbStatusBar cbReuseSubView - cbOverride - cmbRenderSys - cbVsync - cmbAntiAlias - cmbShaderLang cmbStdWinSize From 31fb160376e710ad917e38a7add9b0b690012934 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 25 Sep 2014 06:59:04 +1000 Subject: [PATCH 32/48] More cleanup. --- apps/opencs/view/settings/dialog.hpp | 2 -- apps/opencs/view/world/previewsubview.cpp | 2 +- apps/opencs/view/world/regionmapsubview.cpp | 2 +- apps/opencs/view/world/scenesubview.cpp | 4 ++-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/apps/opencs/view/settings/dialog.hpp b/apps/opencs/view/settings/dialog.hpp index cfe48b618..47422feb4 100644 --- a/apps/opencs/view/settings/dialog.hpp +++ b/apps/opencs/view/settings/dialog.hpp @@ -14,8 +14,6 @@ namespace CSVSettings { { Q_OBJECT - //QListWidget *mPageListWidget; - //ResizeableStackedWidget *mStackedWidget; bool mDebugMode; public: diff --git a/apps/opencs/view/world/previewsubview.cpp b/apps/opencs/view/world/previewsubview.cpp index 316f7c71e..1e106c69f 100644 --- a/apps/opencs/view/world/previewsubview.cpp +++ b/apps/opencs/view/world/previewsubview.cpp @@ -63,4 +63,4 @@ void CSVWorld::PreviewSubView::referenceableIdChanged (const std::string& id) setWindowTitle ("Preview: Reference to "); else setWindowTitle (("Preview: Reference to " + id).c_str()); -} +} \ No newline at end of file diff --git a/apps/opencs/view/world/regionmapsubview.cpp b/apps/opencs/view/world/regionmapsubview.cpp index 411e24e75..a7675a4a6 100644 --- a/apps/opencs/view/world/regionmapsubview.cpp +++ b/apps/opencs/view/world/regionmapsubview.cpp @@ -24,4 +24,4 @@ void CSVWorld::RegionMapSubView::editRequest (const CSMWorld::UniversalId& id, const std::string& hint) { focusId (id, hint); -} +} \ No newline at end of file diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index 699bf81f6..52bd47b54 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -9,7 +9,7 @@ #include #include "../../model/doc/document.hpp" -#include "../../model/settings/usersettings.hpp" + #include "../../model/world/cellselection.hpp" #include "../filter/filterbox.hpp" @@ -254,4 +254,4 @@ void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceW mScene->selectDefaultNavigationMode(); setFocusProxy (mScene); -} +} \ No newline at end of file From 61bab6b1f1b6b2b8bec9b47989f04da1cb1b3b18 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 25 Sep 2014 08:15:07 +1000 Subject: [PATCH 33/48] 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 | 356 ++++---------------- 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, 108 insertions(+), 692 deletions(-) delete mode 100644 files/ui/settingstab.ui diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index ad04b8a37..7094f8799 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 960e54e88..57b0707aa 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 44473c03d..a4655f7bf 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 dfefb131a..01e50739f 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 3a62aeafb..2ff00a535 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 8605f5d0f..ff1765f35 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 7648813bf..56bc1fdfe 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() -{ - 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; -} +#include +#include +#include -QString getAspect(int x, int y) -{ - 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"); - - return QString(QString::number(xaspect) + ":" + QString::number(yaspect)); -} +#include +#include -QString getCurrentOgreResolution() +CSVSettings::Dialog::Dialog(QMainWindow *parent) + : mStackedWidget (0), mDebugMode (false), SettingWindow (parent) { - 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 + setWindowTitle(QString::fromUtf8 ("User Settings")); + + setupDialog(); + + connect (mPageListWidget, + SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)), + this, + SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*))); } -bool customCompare(const QString &s1, const QString &s2) +void CSVSettings::Dialog::slotChangePage + (QListWidgetItem *cur, QListWidgetItem *prev) { - int x1, x2, y1, y2; - QRegExp re("^(\\d+) x (\\d+)"); - - 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(); - } + mStackedWidget->changePage + (mPageListWidget->row (cur), mPageListWidget->row (prev)); - if(x1 == x2) - return y1 > y2; - else - return x1 > x2; + layout()->activate(); + setFixedSize(minimumSizeHint()); } -QStringList getAvailableResolutions() +void CSVSettings::Dialog::setupDialog() { - // store available rendering devices and available resolutions - QStringList result; + //create central widget with it's layout and immediate children + QWidget *centralWidget = new QGroupBox (this); - 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; -} + centralWidget->setLayout (new QHBoxLayout()); + centralWidget->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Preferred); + setCentralWidget (centralWidget); + setDockOptions (QMainWindow::AllowNestedDocks); + buildPageListWidget (centralWidget); + buildStackedWidget (centralWidget); } - -CSVSettings::Dialog::Dialog(QTabWidget *parent) - : mDebugMode (false), SettingWindow (parent) +void CSVSettings::Dialog::buildPages() { - setObjectName(QString::fromUtf8 ("User Settings")); + SettingWindow::createPages (); - setupUi(this); + QFontMetrics fm (QApplication::font()); - // Set the maximum res we can set in windowed mode - QRect res = getMaximumResolution(); - sbWidth->setMaximum(res.width()); - sbHeight->setMaximum(res.height()); + foreach (Page *page, SettingWindow::pages()) + { + QString pageName = page->objectName(); - connect(cbOverride, SIGNAL(toggled(bool)), this, SLOT(slotOverrideToggled(bool))); - connect(cmbRenderSys, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(slotRendererChanged(const QString&))); + int textWidth = fm.width(pageName); - displayGroup_Window->installEventFilter(this); -} + new QListWidgetItem (pageName, mPageListWidget); + mPageListWidget->setFixedWidth (textWidth + 50); -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; - } + mStackedWidget->addWidget (&dynamic_cast(*(page))); } - return QTabWidget::eventFilter(target, event); + resize (mStackedWidget->sizeHint()); } -void CSVSettings::Dialog::slotRendererChanged(const QString &renderer) +void CSVSettings::Dialog::buildPageListWidget (QWidget *centralWidget) { - cmbAntiAlias->clear(); - cmbAntiAlias->addItems(model()->getOgreOptions(QString("FSAA"), renderer)); + mPageListWidget = new QListWidget (centralWidget); + mPageListWidget->setMinimumWidth(50); + mPageListWidget->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Expanding); - cmbShaderLang->clear(); - cmbShaderLang->addItems(model()->getShaderLanguageByRenderer(renderer)); -} + mPageListWidget->setSelectionBehavior (QAbstractItemView::SelectItems); -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); - } + centralWidget->layout()->addWidget(mPageListWidget); } -void CSVSettings::Dialog::buildPages() +void CSVSettings::Dialog::buildStackedWidget (QWidget *centralWidget) { - 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); + mStackedWidget = new ResizeableStackedWidget (centralWidget); - // 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 (); - - 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(); - } + 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 47422feb4..b0e12c461 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 d9bc890b1..7cdf2bded 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 024873ae0..2266f130d 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 0a94348d1..000000000 --- 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 - - - - From 127f9bb30d4f3081538a3e823c84188741767a97 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 25 Sep 2014 09:16:10 +1000 Subject: [PATCH 34/48] Fix reverting to wrong version. --- apps/opencs/view/settings/dialog.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index 56bc1fdfe..72a022c9d 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -114,8 +114,20 @@ void CSVSettings::Dialog::show() setViewValues(); } - QPoint screenCenter = QApplication::desktop()->screenGeometry().center(); - - move (screenCenter - geometry().center()); + 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)); + } QWidget::show(); } From d5c8ff7d7384352d2be0277cff8e4ed1fdd776d5 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 25 Sep 2014 18:15:34 +1000 Subject: [PATCH 35/48] More removal. --- apps/opencs/editor.cpp | 3 +-- apps/opencs/model/settings/usersettings.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 57b0707aa..a8e5287e4 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -278,8 +278,7 @@ std::auto_ptr CS::Editor::setupGraphics() else antialiasing = "0"; params.insert(std::make_pair("FSAA", antialiasing)); - std::string vsync = mUserSettings.settingValue("Video/vsync").toStdString() == "true" ? "true" : "false"; - params.insert(std::make_pair("vsync", vsync)); + params.insert(std::make_pair("vsync", "false")); params.insert(std::make_pair("hidden", "true")); #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE params.insert(std::make_pair("macAPI", "cocoa")); diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index a4655f7bf..90758bdb0 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -424,9 +424,9 @@ void UserSettings::loadSettings (const QString &fileName) mSettingDefinitions->setValue("shader mode", shader); //no group means "General" group } - // check if override entry exists (default: override) + // check if override entry exists (default: disabled) if(!mSettingDefinitions->childGroups().contains("Video", Qt::CaseInsensitive)) - mSettingDefinitions->setValue("Video/use settings.cfg", "true"); + mSettingDefinitions->setValue("Video/use settings.cfg", "false"); } QStringList UserSettings::getOgreRenderers() From 111a35bc382fa7df3ef01c4ffcbf83e5e92471fe Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 26 Sep 2014 07:16:34 +1000 Subject: [PATCH 36/48] More strip back. --- apps/opencs/editor.cpp | 2 - apps/opencs/model/settings/setting.cpp | 13 +- apps/opencs/model/settings/setting.hpp | 5 +- apps/opencs/model/settings/support.hpp | 14 +- apps/opencs/model/settings/usersettings.cpp | 247 +++++++------------- apps/opencs/model/settings/usersettings.hpp | 4 - 6 files changed, 88 insertions(+), 197 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index a8e5287e4..290dc8732 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -55,8 +55,6 @@ 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/model/settings/setting.cpp b/apps/opencs/model/settings/setting.cpp index c29b0e2dd..404ec58f7 100644 --- a/apps/opencs/model/settings/setting.cpp +++ b/apps/opencs/model/settings/setting.cpp @@ -2,7 +2,7 @@ #include "support.hpp" CSMSettings::Setting::Setting(SettingType typ, const QString &settingName, - const QString &pageName, const QString §ion) + const QString &pageName) : mIsEditorSetting (false) { buildDefaultSetting(); @@ -17,7 +17,6 @@ CSMSettings::Setting::Setting(SettingType typ, const QString &settingName, setProperty (Property_SettingType, QVariant (settingType).toString()); setProperty (Property_Page, pageName); setProperty (Property_Name, settingName); - setProperty (Property_Section, section); } void CSMSettings::Setting::buildDefaultSetting() @@ -195,16 +194,6 @@ QString CSMSettings::Setting::page() const return property (Property_Page).at(0); } -void CSMSettings::Setting::setSection (const QString &value) -{ - setProperty (Property_Section, value); -} - -QString CSMSettings::Setting::section() const -{ - return property (Property_Section).at(0); -} - void CSMSettings::Setting::setStyleSheet (const QString &value) { setProperty (Property_StyleSheet, value); diff --git a/apps/opencs/model/settings/setting.hpp b/apps/opencs/model/settings/setting.hpp index b8c72c4bc..0068fd158 100644 --- a/apps/opencs/model/settings/setting.hpp +++ b/apps/opencs/model/settings/setting.hpp @@ -30,7 +30,7 @@ namespace CSMSettings public: explicit Setting(SettingType typ, const QString &settingName, - const QString &pageName, const QString §ion = QString()); + const QString &pageName); void addProxy (const Setting *setting, const QStringList &vals); void addProxy (const Setting *setting, const QList &list); @@ -80,9 +80,6 @@ namespace CSMSettings void setPage (const QString &value); QString page() const; - void setSection (const QString &value); - QString section() const; - void setStyleSheet (const QString &value); QString styleSheet() const; diff --git a/apps/opencs/model/settings/support.hpp b/apps/opencs/model/settings/support.hpp index 8c82b17a6..1e122a214 100644 --- a/apps/opencs/model/settings/support.hpp +++ b/apps/opencs/model/settings/support.hpp @@ -35,14 +35,13 @@ namespace CSMSettings Property_TickInterval = 19, Property_TicksAbove = 20, Property_TicksBelow = 21, - Property_Section = 22, - Property_StyleSheet = 23, + Property_StyleSheet = 22, //Stringlists should always be the last items - Property_DefaultValues = 24, - Property_DeclaredValues = 25, - Property_DefinedValues = 26, - Property_Proxies = 27 + Property_DefaultValues = 23, + Property_DeclaredValues = 24, + Property_DefinedValues = 25, + Property_Proxies = 26 }; ///Basic setting widget types. @@ -108,7 +107,7 @@ namespace CSMSettings "is_multi_line", "widget_width", "view_row", "view_column", "delimiter", "is_serializable","column_span", "row_span", "minimum", "maximum", "special_value_text", "prefix", "suffix", "single_step", "wrapping", - "tick_interval", "ticks_above", "ticks_below", "section", "stylesheet", + "tick_interval", "ticks_above", "ticks_below", "stylesheet", "defaults", "declarations", "definitions", "proxies" }; @@ -137,7 +136,6 @@ namespace CSMSettings "1", //tick interval "false", //ticks above "true", //ticks below - "", //Section "", //StyleSheet "", //default values "", //declared values diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 90758bdb0..b70154ef9 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -5,12 +5,8 @@ #include #include -#include - #include -#include - #include "setting.hpp" #include "support.hpp" #include @@ -32,12 +28,9 @@ namespace boost } /* namespace boost */ #endif /* (BOOST_VERSION <= 104600) */ -namespace CSMSettings -{ - -UserSettings *UserSettings::mUserSettingsInstance = 0; +CSMSettings::UserSettings *CSMSettings::UserSettings::mUserSettingsInstance = 0; -UserSettings::UserSettings (const Files::ConfigurationManager& configurationManager) + CSMSettings::UserSettings::UserSettings (const Files::ConfigurationManager& configurationManager) : mCfgMgr (configurationManager) , mSettingDefinitions(NULL) , mSettingCfgDefinitions(NULL) @@ -51,13 +44,13 @@ UserSettings::UserSettings (const Files::ConfigurationManager& configurationMana mSettingCfgDefinitions = new QSettings(QSettings::IniFormat, QSettings::UserScope, "", QString(), this); } -void UserSettings::buildSettingModelDefaults() +void CSMSettings::UserSettings::buildSettingModelDefaults() { - QString page; + QString section; - page = "Objects"; + section = "Objects"; { - Setting *numLights = createSetting (Type_SpinBox, page, "num lights"); + Setting *numLights = createSetting (Type_SpinBox, section, "num lights"); numLights->setDefaultValue(8); numLights->setEditorSetting(true); numLights->setColumnSpan (1); @@ -66,7 +59,7 @@ void UserSettings::buildSettingModelDefaults() numLights->setWidgetWidth (10); numLights->setViewLocation(1, 2); - Setting *shaders = createSetting (Type_CheckBox, page, "shaders"); + Setting *shaders = createSetting (Type_CheckBox, section, "shaders"); shaders->setDeclaredValues(QStringList() << "true" << "false"); shaders->setDefaultValue("true"); shaders->setEditorSetting(true); @@ -77,9 +70,9 @@ void UserSettings::buildSettingModelDefaults() shaders->setViewLocation(2, 1); } - page = "Scene"; + section = "Scene"; { - Setting *fastFactor = createSetting (Type_SpinBox, page, "fast factor"); + Setting *fastFactor = createSetting (Type_SpinBox, section, "fast factor"); fastFactor->setDefaultValue(4); fastFactor->setEditorSetting(false); fastFactor->setColumnSpan (1); @@ -91,7 +84,7 @@ void UserSettings::buildSettingModelDefaults() fastFactor->setWidgetWidth (10); fastFactor->setViewLocation(1, 2); - Setting *farClipDist = createSetting (Type_SpinBox, page, "far clip distance"); + Setting *farClipDist = createSetting (Type_SpinBox, section, "far clip distance"); farClipDist->setDefaultValue(300000); farClipDist->setEditorSetting(false); farClipDist->setColumnSpan (1); @@ -100,7 +93,7 @@ void UserSettings::buildSettingModelDefaults() farClipDist->setWidgetWidth (10); farClipDist->setViewLocation(2, 2); - Setting *timerStart = createSetting (Type_SpinBox, page, "timer start"); + Setting *timerStart = createSetting (Type_SpinBox, section, "timer start"); timerStart->setDefaultValue(20); timerStart->setEditorSetting(false); timerStart->setColumnSpan (1); @@ -110,10 +103,43 @@ void UserSettings::buildSettingModelDefaults() timerStart->setViewLocation(3, 2); } - page = "Window Size"; + section = "SubView"; { - Setting *width = createSetting (Type_LineEdit, page, "Width"); - Setting *height = createSetting (Type_LineEdit, page, "Height"); + Setting *maxSubView = createSetting (Type_SpinBox, section, "max subviews"); + maxSubView->setDefaultValue(3); + maxSubView->setEditorSetting(false); + maxSubView->setColumnSpan (1); + maxSubView->setMinimum (1); + maxSubView->setSpecialValueText("1"); // workaround for setMinimum + maxSubView->setMaximum (100); // FIXME: not sure what the max value should be + maxSubView->setWidgetWidth (10); + maxSubView->setViewLocation(1, 2); + + Setting *minWidth = createSetting (Type_SpinBox, section, "minimum width"); + minWidth->setDefaultValue(325); + minWidth->setEditorSetting(false); + minWidth->setColumnSpan (1); + minWidth->setMinimum (50); + maxSubView->setSpecialValueText("50"); // workaround for setMinimum + minWidth->setMaximum (10000); // FIXME: not sure what the max value should be + minWidth->setWidgetWidth (10); + minWidth->setViewLocation(2, 2); + + Setting *reuse = createSetting (Type_CheckBox, section, "reuse"); + reuse->setDeclaredValues(QStringList() << "true" << "false"); + reuse->setDefaultValue("true"); + reuse->setEditorSetting(true); + reuse->setSpecialValueText("Reuse SubView"); + reuse->setWidgetWidth(25); + reuse->setColumnSpan (3); + reuse->setStyleSheet ("QGroupBox { border: 0px; }"); + reuse->setViewLocation(3, 2); + } + + section = "Window Size"; + { + Setting *width = createSetting (Type_LineEdit, section, "Width"); + Setting *height = createSetting (Type_LineEdit, section, "Height"); width->setWidgetWidth (5); height->setWidgetWidth (8); @@ -130,7 +156,7 @@ void UserSettings::buildSettingModelDefaults() /* *Create the proxy setting for predefined values */ - Setting *preDefined = createSetting (Type_ComboBox, page, + Setting *preDefined = createSetting (Type_ComboBox, section, "Pre-Defined"); preDefined->setDeclaredValues (QStringList() << "640 x 480" @@ -149,7 +175,7 @@ void UserSettings::buildSettingModelDefaults() ); } - page = "Display Format"; + section = "Display Format"; { QString defaultValue = "Icon and Text"; @@ -157,10 +183,10 @@ void UserSettings::buildSettingModelDefaults() << defaultValue << "Icon Only" << "Text Only"; Setting *rsd = createSetting (Type_RadioButton, - page, "Record Status Display"); + section, "Record Status Display"); Setting *ritd = createSetting (Type_RadioButton, - page, "Referenceable ID Type Display"); + section, "Referenceable ID Type Display"); rsd->setDeclaredValues (values); ritd->setDeclaredValues (values); @@ -169,7 +195,7 @@ void UserSettings::buildSettingModelDefaults() ritd->setEditorSetting (true); } - page = "Proxy Selection Test"; + section = "Proxy Selection Test"; { /****************************************************************** * There are three types of values: @@ -197,30 +223,30 @@ void UserSettings::buildSettingModelDefaults() //create setting objects, specifying the basic widget type, //the page name, and the view name - Setting *masterBoolean = createSetting (Type_RadioButton, page, + Setting *masterBoolean = createSetting (Type_RadioButton, section, "Master Proxy"); - Setting *slaveBoolean = createSetting (Type_CheckBox, page, + Setting *slaveBoolean = createSetting (Type_CheckBox, section, "Proxy Checkboxes"); - Setting *slaveSingleText = createSetting (Type_LineEdit, page, + Setting *slaveSingleText = createSetting (Type_LineEdit, section, "Proxy TextBox 1"); - Setting *slaveMultiText = createSetting (Type_LineEdit, page, + Setting *slaveMultiText = createSetting (Type_LineEdit, section, "ProxyTextBox 2"); - Setting *slaveAlphaSpinbox = createSetting (Type_SpinBox, page, + Setting *slaveAlphaSpinbox = createSetting (Type_SpinBox, section, "Alpha Spinbox"); - Setting *slaveIntegerSpinbox = createSetting (Type_SpinBox, page, + Setting *slaveIntegerSpinbox = createSetting (Type_SpinBox, section, "Int Spinbox"); Setting *slaveDoubleSpinbox = createSetting (Type_DoubleSpinBox, - page, "Double Spinbox"); + section, "Double Spinbox"); - Setting *slaveSlider = createSetting (Type_Slider, page, "Slider"); + Setting *slaveSlider = createSetting (Type_Slider, section, "Slider"); - Setting *slaveDial = createSetting (Type_Dial, page, "Dial"); + Setting *slaveDial = createSetting (Type_Dial, section, "Dial"); //set declared values for selected views masterBoolean->setDeclaredValues (QStringList() @@ -343,12 +369,12 @@ void UserSettings::buildSettingModelDefaults() } } -UserSettings::~UserSettings() +CSMSettings::UserSettings::~UserSettings() { mUserSettingsInstance = 0; } -void UserSettings::loadSettings (const QString &fileName) +void CSMSettings::UserSettings::loadSettings (const QString &fileName) { QString userFilePath = QString::fromUtf8 (mCfgMgr.getUserConfigPath().string().c_str()); @@ -375,128 +401,13 @@ void UserSettings::loadSettings (const QString &fileName) mSettingDefinitions = new QSettings (QSettings::IniFormat, QSettings::UserScope, "opencs", QString(), this); - // prepare to use the settings from settings.cfg - const std::string localdefault = mCfgMgr.getLocalPath().string() + "/settings-default.cfg"; - const std::string globaldefault = mCfgMgr.getGlobalPath().string() + "/settings-default.cfg"; - - Settings::Manager settings; - // prefer local - if (boost::filesystem::exists(localdefault)) - settings.loadDefault(localdefault); - else if (boost::filesystem::exists(globaldefault)) - settings.loadDefault(globaldefault); - else - std::cerr<< "No default settings file found! Make sure the file \"settings-default.cfg\" was properly installed."<< std::endl; - - // load user settings if they exist, otherwise just load the default settings as user settings - const std::string settingspath = mCfgMgr.getUserConfigPath().string() + "/settings.cfg"; - if (boost::filesystem::exists(settingspath)) - settings.loadUser(settingspath); - else if (boost::filesystem::exists(localdefault)) - settings.loadUser(localdefault); - else if (boost::filesystem::exists(globaldefault)) - settings.loadUser(globaldefault); - - std::string renderSystem = settings.getString("render system", "Video"); - if(renderSystem == "") - { -#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 - renderSystem = "Direct3D9 Rendering Subsystem"; -#else - renderSystem = "OpenGL Rendering Subsystem"; -#endif - } - mSettingCfgDefinitions->setValue("Video/render system", renderSystem.c_str()); - - std::string currShader = settings.getString("shader mode", "General"); - // can't call Ogre::Root at this point as it hasn't been initialised - QString rend = renderSystem.c_str(); - bool openGL = rend.contains(QRegExp("^OpenGL", Qt::CaseInsensitive)); - bool glES = rend.contains(QRegExp("^OpenGL ES", Qt::CaseInsensitive)); - - // force shader language based on render system - if(currShader == "" - || (openGL && currShader == "hlsl") - || (!openGL && currShader == "glsl") - || (glES && currShader != "glsles")) - { - QString shader = openGL ? (glES ? "glsles" : "glsl") : "hlsl"; - mSettingDefinitions->setValue("shader mode", shader); //no group means "General" group - } - // check if override entry exists (default: disabled) if(!mSettingDefinitions->childGroups().contains("Video", Qt::CaseInsensitive)) mSettingDefinitions->setValue("Video/use settings.cfg", "false"); } -QStringList UserSettings::getOgreRenderers() -{ - if(mOgreRenderers.empty()) - { - Ogre::RenderSystemList renderers = Ogre::Root::getSingleton().getAvailableRenderers(); - Ogre::RenderSystemList::iterator it = renderers.begin(); - for(; it != renderers.end(); ++it) - mOgreRenderers.append((*it)->getName().c_str()); - } - - return mOgreRenderers; -} - -QStringList UserSettings::getOgreOptions(const QString &key, const QString &renderer) -{ - QStringList result; - - Ogre::RenderSystem *rend = Ogre::Root::getSingleton().getRenderSystemByName(renderer.toStdString()); - if(!rend) - return result; - - Ogre::ConfigOptionMap& renderOpt = rend->getConfigOptions(); - Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); - - uint row = 0; - for(; it != renderOpt.end(); ++it, ++row) - { - Ogre::StringVector::iterator opt_it = it->second.possibleValues.begin(); - uint idx = 0; - - for(; opt_it != it->second.possibleValues.end(); ++opt_it, ++idx) - { - if(strcmp (key.toStdString().c_str(), it->first.c_str()) == 0) - { - result << ((key == "FSAA") ? QString("MSAA ") : QString("")) - + QString::fromStdString((*opt_it).c_str()).simplified(); - } - } - } - - // Sort ascending - qSort(result.begin(), result.end(), naturalSortLessThanCI); - - // Replace the zero option with Off - int index = result.indexOf("MSAA 0"); - - if(index != -1) - result.replace(index, QObject::tr("Off")); - - return result; -} - -QStringList UserSettings::getShaderLanguageByRenderer(const QString &renderer) -{ - QStringList result; - - if(renderer == "Direct3D9 Rendering Subsystem") - result.append("HLSL"); - else if(renderer == "OpenGL Rendering Subsystem") - result.append("GLSL"); - else if(renderer.contains(QRegExp("^OpenGL ES", Qt::CaseInsensitive))) - result.append("GLSLES"); - - return result; -} - // if the key is not found create one with a defaut value -QString UserSettings::setting(const QString &viewKey, const QStringList &list) +QString CSMSettings::UserSettings::setting(const QString &viewKey, const QStringList &list) { if(mSettingDefinitions->contains(viewKey)) return settingValue(viewKey); @@ -509,22 +420,23 @@ QString UserSettings::setting(const QString &viewKey, const QStringList &list) return QString(); } -bool UserSettings::hasSettingDefinitions (const QString &viewKey) const +bool CSMSettings::UserSettings::hasSettingDefinitions (const QString &viewKey) const { return (mSettingDefinitions->contains (viewKey)); } -void UserSettings::setDefinitions (const QString &key, const QStringList &list) +void CSMSettings::UserSettings::setDefinitions + (const QString &key, const QStringList &list) { mSettingDefinitions->setValue (key, list); } -void UserSettings::saveDefinitions() const +void CSMSettings::UserSettings::saveDefinitions() const { mSettingDefinitions->sync(); } -QString UserSettings::settingValue (const QString &settingKey) +QString CSMSettings::UserSettings::settingValue (const QString &settingKey) { QStringList defs; @@ -552,20 +464,22 @@ QString UserSettings::settingValue (const QString &settingKey) return defs.at(0); } -UserSettings& UserSettings::instance() +CSMSettings::UserSettings& CSMSettings::UserSettings::instance() { assert(mUserSettingsInstance); return *mUserSettingsInstance; } -void UserSettings::updateUserSetting(const QString &settingKey, const QStringList &list) +void CSMSettings::UserSettings::updateUserSetting(const QString &settingKey, + const QStringList &list) { mSettingDefinitions->setValue (settingKey ,list); emit userSettingUpdated (settingKey, list); } -Setting *UserSettings::findSetting (const QString &pageName, const QString &settingName) +CSMSettings::Setting *CSMSettings::UserSettings::findSetting + (const QString &pageName, const QString &settingName) { foreach (Setting *setting, mSettings) { @@ -578,7 +492,8 @@ Setting *UserSettings::findSetting (const QString &pageName, const QString &sett return 0; } -void UserSettings::removeSetting (const QString &pageName, const QString &settingName) +void CSMSettings::UserSettings::removeSetting + (const QString &pageName, const QString &settingName) { if (mSettings.isEmpty()) return; @@ -599,7 +514,7 @@ void UserSettings::removeSetting (const QString &pageName, const QString &settin } } -SettingPageMap UserSettings::settingPageMap() const +CSMSettings::SettingPageMap CSMSettings::UserSettings::settingPageMap() const { SettingPageMap pageMap; @@ -609,8 +524,8 @@ SettingPageMap UserSettings::settingPageMap() const return pageMap; } -Setting *UserSettings::createSetting - (SettingType typ, const QString &page, const QString &name) +CSMSettings::Setting *CSMSettings::UserSettings::createSetting + (CSMSettings::SettingType typ, const QString &page, const QString &name) { //get list of all settings for the current setting name if (findSetting (page, name)) @@ -629,12 +544,10 @@ Setting *UserSettings::createSetting return setting; } -QStringList UserSettings::definitions (const QString &viewKey) const +QStringList CSMSettings::UserSettings::definitions (const QString &viewKey) const { if (mSettingDefinitions->contains (viewKey)) return mSettingDefinitions->value (viewKey).toStringList(); return QStringList(); } - -} diff --git a/apps/opencs/model/settings/usersettings.hpp b/apps/opencs/model/settings/usersettings.hpp index 01e50739f..e2851c9ac 100644 --- a/apps/opencs/model/settings/usersettings.hpp +++ b/apps/opencs/model/settings/usersettings.hpp @@ -35,7 +35,6 @@ namespace CSMSettings { QSettings *mSettingDefinitions; QSettings *mSettingCfgDefinitions; QList mSettings; - QStringList mOgreRenderers; public: @@ -78,9 +77,6 @@ namespace CSMSettings { ///Save any unsaved changes in the QSettings object void saveDefinitions() const; - 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: From a1c0ec2feb996b236b2a3d21447e1c027e72acf6 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 26 Sep 2014 11:26:33 +1000 Subject: [PATCH 37/48] Repair collateral damage from a purging session gone out of control. --- apps/opencs/editor.cpp | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 290dc8732..a753b0988 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -259,8 +259,15 @@ int CS::Editor::run() std::auto_ptr CS::Editor::setupGraphics() { - std::string rendersystem = mUserSettings.settingValue("Video/render system").toStdString(); - Ogre::Root::getSingleton().setRenderSystem(Ogre::Root::getSingleton().getRenderSystemByName(rendersystem)); + std::string renderer = +#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 + "Direct3D9 Rendering Subsystem"; +#else + "OpenGL Rendering Subsystem"; +#endif + std::string renderSystem = mUserSettings.setting("Video/render system", QStringList() << renderer.c_str()).toStdString(); + + Ogre::Root::getSingleton().setRenderSystem(Ogre::Root::getSingleton().getRenderSystemByName(renderSystem)); Ogre::Root::getSingleton().initialise(false); @@ -295,8 +302,21 @@ std::auto_ptr CS::Editor::setupGraphics() std::auto_ptr factory (new sh::Factory (platform)); - std::string shLang = mUserSettings.settingValue("General/shader mode").toStdString(); - //std::string shLang = mUserSettings.getShaderLanguageByRenderer(rendersystem.c_str()).at(0).toStdString(); + QString shLang = mUserSettings.settingValue("General/shader mode"); + QString rend = renderSystem.c_str(); + bool openGL = rend.contains(QRegExp("^OpenGL", Qt::CaseInsensitive)); + bool glES = rend.contains(QRegExp("^OpenGL ES", Qt::CaseInsensitive)); + + // force shader language based on render system + if(shLang == "" + || (openGL && shLang == "hlsl") + || (!openGL && shLang == "glsl") + || (glES && shLang != "glsles")) + { + shLang = openGL ? (glES ? "glsles" : "glsl") : "hlsl"; + //no group means "General" group in the "ini" file standard + mUserSettings.setDefinitions("shader mode", (QStringList() << shLang)); + } enum sh::Language lang; if(shLang == "glsl") lang = sh::Language_GLSL; else if(shLang == "glsles") lang = sh::Language_GLSLES; @@ -317,6 +337,7 @@ std::auto_ptr CS::Editor::setupGraphics() std::string fog = mUserSettings.setting("Shader/fog", (QStringList() << QString("true"))).toStdString(); sh::Factory::getInstance().setGlobalSetting ("fog", fog); + std::string shadows = mUserSettings.setting("Shader/shadows", (QStringList() << QString("false"))).toStdString(); sh::Factory::getInstance().setGlobalSetting ("shadows", shadows); From 8e71f092c5b525745b0c9f61607f3028b29d0afc Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 26 Sep 2014 12:36:55 +1000 Subject: [PATCH 38/48] Comment out setMinimum which is broken. --- apps/opencs/model/settings/usersettings.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index b70154ef9..d28512e12 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -76,9 +76,9 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() fastFactor->setDefaultValue(4); fastFactor->setEditorSetting(false); fastFactor->setColumnSpan (1); - // FIXME: setMinimum or setSpecialVlueText appears to be broken, possibly due + // FIXME: setMinimum or setSpecialValueText appears to be broken, possibly due // to there being an empty string default for special value text. - fastFactor->setMinimum (1); + //fastFactor->setMinimum (1); fastFactor->setSpecialValueText("1"); // workaround for above fastFactor->setMaximum (100); // FIXME: not sure what the max value should be fastFactor->setWidgetWidth (10); @@ -109,7 +109,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() maxSubView->setDefaultValue(3); maxSubView->setEditorSetting(false); maxSubView->setColumnSpan (1); - maxSubView->setMinimum (1); + //maxSubView->setMinimum (1); maxSubView->setSpecialValueText("1"); // workaround for setMinimum maxSubView->setMaximum (100); // FIXME: not sure what the max value should be maxSubView->setWidgetWidth (10); @@ -119,8 +119,8 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() minWidth->setDefaultValue(325); minWidth->setEditorSetting(false); minWidth->setColumnSpan (1); - minWidth->setMinimum (50); - maxSubView->setSpecialValueText("50"); // workaround for setMinimum + //minWidth->setMinimum (50); + minWidth->setSpecialValueText("50"); // workaround for setMinimum minWidth->setMaximum (10000); // FIXME: not sure what the max value should be minWidth->setWidgetWidth (10); minWidth->setViewLocation(2, 2); From a25cffc2420382254295dcfd17b1abee840baf48 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 28 Sep 2014 10:17:54 +1000 Subject: [PATCH 39/48] Fixed default value not being set for spinbox. Changed the default value of max subviews to 256. Simplified the call signature to get settings & set an initial value. Fixed missing settings for num_lights. --- apps/opencs/editor.cpp | 16 ++++---- apps/opencs/model/settings/usersettings.cpp | 43 +++++++++------------ apps/opencs/model/settings/usersettings.hpp | 2 +- apps/opencs/view/doc/view.cpp | 8 ++-- apps/opencs/view/render/scenewidget.cpp | 6 +-- apps/opencs/view/settings/rangeview.cpp | 2 + 6 files changed, 36 insertions(+), 41 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index a753b0988..de3e23965 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -265,7 +265,7 @@ std::auto_ptr CS::Editor::setupGraphics() #else "OpenGL Rendering Subsystem"; #endif - std::string renderSystem = mUserSettings.setting("Video/render system", QStringList() << renderer.c_str()).toStdString(); + std::string renderSystem = mUserSettings.setting("Video/render system", renderer.c_str()).toStdString(); Ogre::Root::getSingleton().setRenderSystem(Ogre::Root::getSingleton().getRenderSystemByName(renderSystem)); @@ -331,27 +331,27 @@ std::auto_ptr CS::Editor::setupGraphics() factory->loadAllFiles(); - bool shaders = mUserSettings.setting("Objects/shaders", (QStringList() << QString("true"))) == "true" ? true : false; + bool shaders = mUserSettings.setting("Objects/shaders", QString("true")) == "true" ? true : false; sh::Factory::getInstance ().setShadersEnabled (shaders); - std::string fog = mUserSettings.setting("Shader/fog", (QStringList() << QString("true"))).toStdString(); + std::string fog = mUserSettings.setting("Shader/fog", QString("true")).toStdString(); sh::Factory::getInstance().setGlobalSetting ("fog", fog); - std::string shadows = mUserSettings.setting("Shader/shadows", (QStringList() << QString("false"))).toStdString(); + std::string shadows = mUserSettings.setting("Shader/shadows", QString("false")).toStdString(); sh::Factory::getInstance().setGlobalSetting ("shadows", shadows); - std::string shadows_pssm = mUserSettings.setting("Shader/shadows_pssm", (QStringList() << QString("false"))).toStdString(); + std::string shadows_pssm = mUserSettings.setting("Shader/shadows_pssm", QString("false")).toStdString(); sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", shadows_pssm); - std::string render_refraction = mUserSettings.setting("Shader/render_refraction", (QStringList() << QString("false"))).toStdString(); + std::string render_refraction = mUserSettings.setting("Shader/render_refraction", 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 sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false"); - sh::Factory::getInstance ().setGlobalSetting ("num_lights", - mUserSettings.settingValue("Objects/num_lights").toStdString()); + std::string num_lights = mUserSettings.setting("Objects/num_lights", QString("8")).toStdString(); + sh::Factory::getInstance ().setGlobalSetting ("num_lights", num_lights); /// \todo add more configurable shiny settings diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index d28512e12..97c9431e1 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -50,11 +50,11 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() section = "Objects"; { - Setting *numLights = createSetting (Type_SpinBox, section, "num lights"); + Setting *numLights = createSetting (Type_SpinBox, section, "num_lights"); numLights->setDefaultValue(8); numLights->setEditorSetting(true); numLights->setColumnSpan (1); - numLights->setMinimum (0); + numLights->setMinimum (2); numLights->setMaximum (100); // FIXME: not sure what the max value should be numLights->setWidgetWidth (10); numLights->setViewLocation(1, 2); @@ -74,19 +74,16 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() { Setting *fastFactor = createSetting (Type_SpinBox, section, "fast factor"); fastFactor->setDefaultValue(4); - fastFactor->setEditorSetting(false); + fastFactor->setEditorSetting(true); fastFactor->setColumnSpan (1); - // FIXME: setMinimum or setSpecialValueText appears to be broken, possibly due - // to there being an empty string default for special value text. - //fastFactor->setMinimum (1); - fastFactor->setSpecialValueText("1"); // workaround for above + fastFactor->setMinimum (1); fastFactor->setMaximum (100); // FIXME: not sure what the max value should be fastFactor->setWidgetWidth (10); fastFactor->setViewLocation(1, 2); Setting *farClipDist = createSetting (Type_SpinBox, section, "far clip distance"); farClipDist->setDefaultValue(300000); - farClipDist->setEditorSetting(false); + farClipDist->setEditorSetting(true); farClipDist->setColumnSpan (1); farClipDist->setMinimum (0); farClipDist->setMaximum (1000000); // FIXME: not sure what the max value should be @@ -95,7 +92,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() Setting *timerStart = createSetting (Type_SpinBox, section, "timer start"); timerStart->setDefaultValue(20); - timerStart->setEditorSetting(false); + timerStart->setEditorSetting(true); timerStart->setColumnSpan (1); timerStart->setMinimum (0); timerStart->setMaximum (100); // FIXME: not sure what the max value should be @@ -106,12 +103,11 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() section = "SubView"; { Setting *maxSubView = createSetting (Type_SpinBox, section, "max subviews"); - maxSubView->setDefaultValue(3); + maxSubView->setDefaultValue(256); maxSubView->setEditorSetting(false); maxSubView->setColumnSpan (1); - //maxSubView->setMinimum (1); - maxSubView->setSpecialValueText("1"); // workaround for setMinimum - maxSubView->setMaximum (100); // FIXME: not sure what the max value should be + maxSubView->setMinimum (1); + maxSubView->setMaximum (256); // FIXME: not sure what the max value should be maxSubView->setWidgetWidth (10); maxSubView->setViewLocation(1, 2); @@ -119,8 +115,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() minWidth->setDefaultValue(325); minWidth->setEditorSetting(false); minWidth->setColumnSpan (1); - //minWidth->setMinimum (50); - minWidth->setSpecialValueText("50"); // workaround for setMinimum + minWidth->setMinimum (50); minWidth->setMaximum (10000); // FIXME: not sure what the max value should be minWidth->setWidgetWidth (10); minWidth->setViewLocation(2, 2); @@ -128,7 +123,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() Setting *reuse = createSetting (Type_CheckBox, section, "reuse"); reuse->setDeclaredValues(QStringList() << "true" << "false"); reuse->setDefaultValue("true"); - reuse->setEditorSetting(true); + reuse->setEditorSetting(false); reuse->setSpecialValueText("Reuse SubView"); reuse->setWidgetWidth(25); reuse->setColumnSpan (3); @@ -147,8 +142,8 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() width->setDefaultValues (QStringList() << "1024"); height->setDefaultValues (QStringList() << "768"); - width->setEditorSetting (true); - height->setEditorSetting (true); + width->setEditorSetting (false); + height->setEditorSetting (false); height->setViewLocation (2,2); width->setViewLocation (2,1); @@ -191,8 +186,8 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() rsd->setDeclaredValues (values); ritd->setDeclaredValues (values); - rsd->setEditorSetting (true); - ritd->setEditorSetting (true); + rsd->setEditorSetting (false); + ritd->setEditorSetting (false); } section = "Proxy Selection Test"; @@ -407,14 +402,14 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName) } // if the key is not found create one with a defaut value -QString CSMSettings::UserSettings::setting(const QString &viewKey, const QStringList &list) +QString CSMSettings::UserSettings::setting(const QString &viewKey, const QString &value) { if(mSettingDefinitions->contains(viewKey)) return settingValue(viewKey); - else if(!list.empty()) + else if(value != QString()) { - mSettingDefinitions->setValue (viewKey, list); - return list.at(0); + mSettingDefinitions->setValue (viewKey, QStringList() << value); + return value; } return QString(); diff --git a/apps/opencs/model/settings/usersettings.hpp b/apps/opencs/model/settings/usersettings.hpp index e2851c9ac..0aabd66e5 100644 --- a/apps/opencs/model/settings/usersettings.hpp +++ b/apps/opencs/model/settings/usersettings.hpp @@ -77,7 +77,7 @@ namespace CSMSettings { ///Save any unsaved changes in the QSettings object void saveDefinitions() const; - QString setting(const QString &viewKey, const QStringList &list = QStringList()); + QString setting(const QString &viewKey, const QString &value = QString()); private: diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 2ff00a535..744865f1c 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -456,7 +456,7 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin // User setting to reuse sub views (on a per top level view basis) bool reuse = - userSettings.setting("SubView/reuse", (QStringList() << QString("true"))) == "true" ? true : false; + userSettings.setting("SubView/reuse", QString("true")) == "true" ? true : false; if(reuse) { foreach(SubView *sb, mSubViews) @@ -475,8 +475,7 @@ 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 = - userSettings.setting("SubView/max subviews", (QStringList() << QString("3"))).toInt(); + int maxSubView = userSettings.setting("SubView/max subviews", QString("256")).toInt(); if(mSubViews.size() >= maxSubView) // create a new top level view { mViewManager.addView(mDocument, id, hint); @@ -499,8 +498,7 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin if (!hint.empty()) view->useHint (hint); - int minWidth = - userSettings.setting("SubView/minimum width", (QStringList() << QString("325"))).toInt(); + int minWidth = userSettings.setting("SubView/minimum width", 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 ff1765f35..cdf55a9eb 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -48,10 +48,10 @@ namespace CSVRender CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); - int farClipDist = userSettings.setting("Scene/far clip distance", (QStringList() << QString("300000"))).toInt(); + int farClipDist = userSettings.setting("Scene/far clip distance", QString("300000")).toInt(); mCamera->setFarClipDistance (farClipDist); - mFastFactor = userSettings.setting("Scene/fast factor", (QStringList() << QString("4"))).toInt(); + mFastFactor = userSettings.setting("Scene/fast factor", QString("4")).toInt(); mCamera->roll (Ogre::Degree (90)); @@ -61,7 +61,7 @@ namespace CSVRender connect (timer, SIGNAL (timeout()), this, SLOT (update())); - int timerStart = userSettings.setting("Scene/timer start", (QStringList() << QString("20"))).toInt(); + int timerStart = userSettings.setting("Scene/timer start", QString("20")).toInt(); timer->start (timerStart); /// \todo make shortcut configurable diff --git a/apps/opencs/view/settings/rangeview.cpp b/apps/opencs/view/settings/rangeview.cpp index 606ad4939..49cc170e1 100644 --- a/apps/opencs/view/settings/rangeview.cpp +++ b/apps/opencs/view/settings/rangeview.cpp @@ -129,6 +129,8 @@ void CSVSettings::RangeView::buildSpinBox (CSMSettings::Setting *setting) mRangeWidget->setProperty ("wrapping", setting->wrapping()); dynamic_cast (mRangeWidget)->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); + if(setting->type() == CSMSettings::Type_SpinBox) + dynamic_cast (mRangeWidget)->setValue (setting->defaultValues().at(0).toInt()); // FIXME: can there be more than one? } void CSVSettings::RangeView::slotUpdateView (int value) From 9902e08773bb38ea846a44dc25dd9f36be04ee6c Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 28 Sep 2014 11:05:27 +1000 Subject: [PATCH 40/48] Apply sh::Factory settings immediately. --- apps/opencs/model/settings/usersettings.cpp | 29 +++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 97c9431e1..2e5aaad42 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -12,6 +12,8 @@ #include #include +#include + /** * Workaround for problems with whitespaces in paths in older versions of Boost library */ @@ -104,7 +106,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() { Setting *maxSubView = createSetting (Type_SpinBox, section, "max subviews"); maxSubView->setDefaultValue(256); - maxSubView->setEditorSetting(false); + maxSubView->setEditorSetting(true); maxSubView->setColumnSpan (1); maxSubView->setMinimum (1); maxSubView->setMaximum (256); // FIXME: not sure what the max value should be @@ -113,7 +115,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() Setting *minWidth = createSetting (Type_SpinBox, section, "minimum width"); minWidth->setDefaultValue(325); - minWidth->setEditorSetting(false); + minWidth->setEditorSetting(true); minWidth->setColumnSpan (1); minWidth->setMinimum (50); minWidth->setMaximum (10000); // FIXME: not sure what the max value should be @@ -123,7 +125,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() Setting *reuse = createSetting (Type_CheckBox, section, "reuse"); reuse->setDeclaredValues(QStringList() << "true" << "false"); reuse->setDefaultValue("true"); - reuse->setEditorSetting(false); + reuse->setEditorSetting(true); reuse->setSpecialValueText("Reuse SubView"); reuse->setWidgetWidth(25); reuse->setColumnSpan (3); @@ -142,8 +144,8 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() width->setDefaultValues (QStringList() << "1024"); height->setDefaultValues (QStringList() << "768"); - width->setEditorSetting (false); - height->setEditorSetting (false); + width->setEditorSetting (true); + height->setEditorSetting (true); height->setViewLocation (2,2); width->setViewLocation (2,1); @@ -186,8 +188,8 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() rsd->setDeclaredValues (values); ritd->setDeclaredValues (values); - rsd->setEditorSetting (false); - ritd->setEditorSetting (false); + rsd->setEditorSetting (true); + ritd->setEditorSetting (true); } section = "Proxy Selection Test"; @@ -470,7 +472,18 @@ void CSMSettings::UserSettings::updateUserSetting(const QString &settingKey, { mSettingDefinitions->setValue (settingKey ,list); - emit userSettingUpdated (settingKey, list); + if(settingKey == "Objects/num_lights" + && mSettingDefinitions->value(settingKey).toString() != list.at(0)) + { + sh::Factory::getInstance ().setGlobalSetting ("num_lights", list.at(0).toStdString()); + } + else if(settingKey == "Objects/shaders" + && mSettingDefinitions->value(settingKey).toString() != list.at(0)) + { + sh::Factory::getInstance ().setShadersEnabled (list.at(0) == "true" ? true : false); + } + + emit userSettingUpdated (settingKey, list); // TODO: isn't this circular? } CSMSettings::Setting *CSMSettings::UserSettings::findSetting From 8a0ff17c22891c036b92a484ce493bd4825169af Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 28 Sep 2014 14:08:14 +1000 Subject: [PATCH 41/48] Update SceneWidget when relevant user settings change. --- apps/opencs/view/render/scenewidget.cpp | 6 ++++++ apps/opencs/view/render/scenewidget.hpp | 4 ++++ apps/opencs/view/world/scenesubview.cpp | 9 ++++++++- apps/opencs/view/world/scenesubview.hpp | 8 ++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index cdf55a9eb..1b0b578f6 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -397,4 +397,10 @@ namespace CSVRender else if (mode=="bright") setLighting (&mLightingBright); } + + void SceneWidget::updateUserSetting (const QString &key, const QStringList &list) + { + if(key.contains(QRegExp("^\\b(Objects|Shader|Scene)", Qt::CaseInsensitive))) + flagAsModified(); + } } diff --git a/apps/opencs/view/render/scenewidget.hpp b/apps/opencs/view/render/scenewidget.hpp index 9f79aee17..f28504c2d 100644 --- a/apps/opencs/view/render/scenewidget.hpp +++ b/apps/opencs/view/render/scenewidget.hpp @@ -110,6 +110,10 @@ namespace CSVRender LightingNight mLightingNight; LightingBright mLightingBright; + public slots: + + void updateUserSetting (const QString &key, const QStringList &list); + private slots: void update(); diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index 52bd47b54..d10eebb30 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -247,6 +247,8 @@ void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceW mToolbar = toolbar; connect (mScene, SIGNAL (focusToolbarRequest()), mToolbar, SLOT (setFocus())); + connect (this, SIGNAL (updateSceneUserSetting(const QString &, const QStringList &)), + mScene, SLOT (updateUserSetting(const QString &, const QStringList &))); connect (mToolbar, SIGNAL (focusSceneRequest()), mScene, SLOT (setFocus())); mLayout->addWidget (mToolbar, 0); @@ -254,4 +256,9 @@ void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceW mScene->selectDefaultNavigationMode(); setFocusProxy (mScene); -} \ No newline at end of file +} + +void CSVWorld::SceneSubView::updateUserSetting (const QString &key, const QStringList &list) +{ + emit updateSceneUserSetting(key, list); +} diff --git a/apps/opencs/view/world/scenesubview.hpp b/apps/opencs/view/world/scenesubview.hpp index b9dcdd6a3..c0905f0d6 100644 --- a/apps/opencs/view/world/scenesubview.hpp +++ b/apps/opencs/view/world/scenesubview.hpp @@ -82,6 +82,14 @@ namespace CSVWorld void cellSelectionChanged (const CSMWorld::UniversalId& id); void handleDrop(const std::vector& data); + + public slots: + + void updateUserSetting (const QString &, const QStringList &); + + signals: + + void updateSceneUserSetting (const QString &, const QStringList &); }; } From 303b0ee8c6c4e5ca6fab15dfdd08af3757de96c4 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 28 Sep 2014 15:43:33 +1000 Subject: [PATCH 42/48] Update scenewidget when antialiasing settings change. --- apps/opencs/model/settings/usersettings.cpp | 13 +++++- apps/opencs/view/render/scenewidget.cpp | 44 ++++++++++++++++++++- apps/opencs/view/settings/rangeview.cpp | 4 +- 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 2e5aaad42..bc197ab48 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -192,6 +192,17 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() ritd->setEditorSetting (true); } + section = "Video"; + { + QString defaultValue = "None"; + QStringList values = QStringList() + << defaultValue << "MSAA 2" << "MSAA 4" << "MSAA 8" << "MSAA 16"; + Setting *antialiasing = createSetting (Type_SpinBox, section, "antialiasing"); + antialiasing->setDeclaredValues (values); + antialiasing->setEditorSetting (true); + antialiasing->setWidgetWidth(15); + } + section = "Proxy Selection Test"; { /****************************************************************** @@ -483,7 +494,7 @@ void CSMSettings::UserSettings::updateUserSetting(const QString &settingKey, sh::Factory::getInstance ().setShadersEnabled (list.at(0) == "true" ? true : false); } - emit userSettingUpdated (settingKey, list); // TODO: isn't this circular? + emit userSettingUpdated (settingKey, list); } CSMSettings::Setting *CSMSettings::UserSettings::findSetting diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 1b0b578f6..c399fca6b 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -128,7 +128,16 @@ namespace CSVRender params.insert(std::make_pair("externalWindowHandle", windowHandle.str())); params.insert(std::make_pair("title", windowTitle.str())); - params.insert(std::make_pair("FSAA", "0")); // TODO setting + + std::string antialiasing = + CSMSettings::UserSettings::instance().settingValue("Video/antialiasing").toStdString(); + if(antialiasing == "MSAA 16") antialiasing = "16"; + else if(antialiasing == "MSAA 8") antialiasing = "8"; + else if(antialiasing == "MSAA 4") antialiasing = "4"; + else if(antialiasing == "MSAA 2") antialiasing = "2"; + else antialiasing = "0"; + params.insert(std::make_pair("FSAA", antialiasing)); + params.insert(std::make_pair("vsync", "false")); // TODO setting #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE params.insert(std::make_pair("macAPI", "cocoa")); @@ -402,5 +411,38 @@ namespace CSVRender { if(key.contains(QRegExp("^\\b(Objects|Shader|Scene)", Qt::CaseInsensitive))) flagAsModified(); + + // minimise unnecessary ogre window creation by updating only when there is a change + if(key == "Video/antialiasing") + { + std::string result; + + Ogre::ConfigOptionMap& renderOpt = + Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); + + Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); + + for(; it != renderOpt.end(); ++it) + { + if(it->first == "FSAA") + result = it->second.currentValue; + } + + QString antialiasing = "0"; + if(!list.empty()) + { + antialiasing = list.at(0); + + if(antialiasing == "MSAA 16") antialiasing = "16"; + else if(antialiasing == "MSAA 8") antialiasing = "8"; + else if(antialiasing == "MSAA 4") antialiasing = "4"; + else if(antialiasing == "MSAA 2") antialiasing = "2"; + } + + if(result != antialiasing.toStdString()) + { + updateOgreWindow(); + } + } } } diff --git a/apps/opencs/view/settings/rangeview.cpp b/apps/opencs/view/settings/rangeview.cpp index 49cc170e1..6b47b1cac 100644 --- a/apps/opencs/view/settings/rangeview.cpp +++ b/apps/opencs/view/settings/rangeview.cpp @@ -129,8 +129,8 @@ void CSVSettings::RangeView::buildSpinBox (CSMSettings::Setting *setting) mRangeWidget->setProperty ("wrapping", setting->wrapping()); dynamic_cast (mRangeWidget)->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); - if(setting->type() == CSMSettings::Type_SpinBox) - dynamic_cast (mRangeWidget)->setValue (setting->defaultValues().at(0).toInt()); // FIXME: can there be more than one? + if(setting->type() == CSMSettings::Type_SpinBox && setting->declaredValues().isEmpty()) + dynamic_cast (mRangeWidget)->setValue (setting->defaultValues().at(0).toInt()); } void CSVSettings::RangeView::slotUpdateView (int value) From 6e8977348a07ff3c67c8e98834886dfca5e0579b Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 28 Sep 2014 19:43:26 +1000 Subject: [PATCH 43/48] Check the FSAA setting of windows rather than system value. --- apps/opencs/view/render/scenewidget.cpp | 31 ++++++------------------- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index c399fca6b..9ff9ac4db 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -415,34 +415,17 @@ namespace CSVRender // minimise unnecessary ogre window creation by updating only when there is a change if(key == "Video/antialiasing") { - std::string result; - - Ogre::ConfigOptionMap& renderOpt = - Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions(); - - Ogre::ConfigOptionMap::iterator it = renderOpt.begin(); - - for(; it != renderOpt.end(); ++it) - { - if(it->first == "FSAA") - result = it->second.currentValue; - } - - QString antialiasing = "0"; + unsigned int aa = mWindow->getFSAA(); + unsigned int antialiasing = 0; if(!list.empty()) { - antialiasing = list.at(0); - - if(antialiasing == "MSAA 16") antialiasing = "16"; - else if(antialiasing == "MSAA 8") antialiasing = "8"; - else if(antialiasing == "MSAA 4") antialiasing = "4"; - else if(antialiasing == "MSAA 2") antialiasing = "2"; + if(list.at(0) == "MSAA 16") antialiasing = 16; + else if(list.at(0) == "MSAA 8") antialiasing = 8; + else if(list.at(0) == "MSAA 4") antialiasing = 4; + else if(list.at(0) == "MSAA 2") antialiasing = 2; } - - if(result != antialiasing.toStdString()) - { + if(aa != antialiasing) updateOgreWindow(); - } } } } From f0c739b7634b90aee464f71cf5fd1d5f71afee67 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 29 Sep 2014 06:27:54 +1000 Subject: [PATCH 44/48] Apply camera setting changes immediately. Remove current value check for shader setting changes. --- apps/opencs/model/settings/usersettings.cpp | 10 ++++------ apps/opencs/view/render/scenewidget.cpp | 8 +++++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index bc197ab48..156bff22a 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -83,7 +83,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() fastFactor->setWidgetWidth (10); fastFactor->setViewLocation(1, 2); - Setting *farClipDist = createSetting (Type_SpinBox, section, "far clip distance"); + Setting *farClipDist = createSetting (Type_DoubleSpinBox, section, "far clip distance"); farClipDist->setDefaultValue(300000); farClipDist->setEditorSetting(true); farClipDist->setColumnSpan (1); @@ -483,15 +483,13 @@ void CSMSettings::UserSettings::updateUserSetting(const QString &settingKey, { mSettingDefinitions->setValue (settingKey ,list); - if(settingKey == "Objects/num_lights" - && mSettingDefinitions->value(settingKey).toString() != list.at(0)) + if(settingKey == "Objects/num_lights" && !list.empty()) { sh::Factory::getInstance ().setGlobalSetting ("num_lights", list.at(0).toStdString()); } - else if(settingKey == "Objects/shaders" - && mSettingDefinitions->value(settingKey).toString() != list.at(0)) + else if(settingKey == "Objects/shaders" && !list.empty()) { - sh::Factory::getInstance ().setShadersEnabled (list.at(0) == "true" ? true : false); + sh::Factory::getInstance ().setShadersEnabled (list.at(0).toStdString() == "true" ? true : false); } emit userSettingUpdated (settingKey, list); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 9ff9ac4db..3ca2a171c 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -48,7 +48,7 @@ namespace CSVRender CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); - int farClipDist = userSettings.setting("Scene/far clip distance", QString("300000")).toInt(); + float farClipDist = userSettings.setting("Scene/far clip distance", QString("300000")).toFloat(); mCamera->setFarClipDistance (farClipDist); mFastFactor = userSettings.setting("Scene/fast factor", QString("4")).toInt(); @@ -412,6 +412,12 @@ namespace CSVRender if(key.contains(QRegExp("^\\b(Objects|Shader|Scene)", Qt::CaseInsensitive))) flagAsModified(); + if(key == "Objects/far clip distance" && !list.empty()) + { + if(mCamera->getFarClipDistance() != list.at(0).toFloat()) + mCamera->setFarClipDistance(list.at(0).toFloat()); + } + // minimise unnecessary ogre window creation by updating only when there is a change if(key == "Video/antialiasing") { From 54c77cf875e3238119d477c452b7abaabf7d45f2 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 29 Sep 2014 06:39:44 +1000 Subject: [PATCH 45/48] Silence clang warnings. --- apps/opencs/view/settings/booleanview.cpp | 2 +- apps/opencs/view/settings/rangeview.cpp | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/opencs/view/settings/booleanview.cpp b/apps/opencs/view/settings/booleanview.cpp index 58b822179..29f9775af 100644 --- a/apps/opencs/view/settings/booleanview.cpp +++ b/apps/opencs/view/settings/booleanview.cpp @@ -43,7 +43,7 @@ CSVSettings::BooleanView::BooleanView (CSMSettings::Setting *setting, break; } - if(mType != CSMSettings::Type_CheckBox || mButtons.empty()) + if(button && (mType != CSMSettings::Type_CheckBox || mButtons.empty())) { connect (button, SIGNAL (clicked (bool)), this, SLOT (slotToggled (bool))); diff --git a/apps/opencs/view/settings/rangeview.cpp b/apps/opencs/view/settings/rangeview.cpp index 6b47b1cac..c96df9859 100644 --- a/apps/opencs/view/settings/rangeview.cpp +++ b/apps/opencs/view/settings/rangeview.cpp @@ -36,8 +36,11 @@ CSVSettings::RangeView::RangeView (CSMSettings::Setting *setting, break; } - mRangeWidget->setFixedWidth (widgetWidth (setting->widgetWidth())); - mRangeWidget->setObjectName (setting->name()); + if(mRangeWidget) + { + mRangeWidget->setFixedWidth (widgetWidth (setting->widgetWidth())); + mRangeWidget->setObjectName (setting->name()); + } addWidget (mRangeWidget); } @@ -75,13 +78,16 @@ void CSVSettings::RangeView::buildSlider (CSMSettings::Setting *setting) break; } - mRangeWidget->setProperty ("minimum", setting->minimum()); - mRangeWidget->setProperty ("maximum", setting->maximum()); - mRangeWidget->setProperty ("tracking", false); - mRangeWidget->setProperty ("singleStep", setting->singleStep()); + if(mRangeWidget) + { + mRangeWidget->setProperty ("minimum", setting->minimum()); + mRangeWidget->setProperty ("maximum", setting->maximum()); + mRangeWidget->setProperty ("tracking", false); + mRangeWidget->setProperty ("singleStep", setting->singleStep()); - connect (mRangeWidget, SIGNAL (valueChanged (int)), - this, SLOT (slotUpdateView (int))); + connect (mRangeWidget, SIGNAL (valueChanged (int)), + this, SLOT (slotUpdateView (int))); + } } void CSVSettings::RangeView::buildSpinBox (CSMSettings::Setting *setting) From 7675df60bab0f9e4a384ffc774903a8deb3b9673 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 29 Sep 2014 08:17:51 +1000 Subject: [PATCH 46/48] Fix far clip distance (again), workaround for broken settings minimum value. --- apps/opencs/model/settings/usersettings.cpp | 5 ++++- apps/opencs/view/render/scenewidget.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 156bff22a..11fdc54f4 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -56,7 +56,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() numLights->setDefaultValue(8); numLights->setEditorSetting(true); numLights->setColumnSpan (1); - numLights->setMinimum (2); + numLights->setMinimum (0); numLights->setMaximum (100); // FIXME: not sure what the max value should be numLights->setWidgetWidth (10); numLights->setViewLocation(1, 2); @@ -79,6 +79,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() fastFactor->setEditorSetting(true); fastFactor->setColumnSpan (1); fastFactor->setMinimum (1); + fastFactor->setSpecialValueText ("1"); // FIXME: workaround fastFactor->setMaximum (100); // FIXME: not sure what the max value should be fastFactor->setWidgetWidth (10); fastFactor->setViewLocation(1, 2); @@ -109,6 +110,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() maxSubView->setEditorSetting(true); maxSubView->setColumnSpan (1); maxSubView->setMinimum (1); + maxSubView->setSpecialValueText ("1"); maxSubView->setMaximum (256); // FIXME: not sure what the max value should be maxSubView->setWidgetWidth (10); maxSubView->setViewLocation(1, 2); @@ -118,6 +120,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() minWidth->setEditorSetting(true); minWidth->setColumnSpan (1); minWidth->setMinimum (50); + minWidth->setSpecialValueText ("50"); minWidth->setMaximum (10000); // FIXME: not sure what the max value should be minWidth->setWidgetWidth (10); minWidth->setViewLocation(2, 2); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 3ca2a171c..2b2c8ade0 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -412,7 +412,7 @@ namespace CSVRender if(key.contains(QRegExp("^\\b(Objects|Shader|Scene)", Qt::CaseInsensitive))) flagAsModified(); - if(key == "Objects/far clip distance" && !list.empty()) + if(key == "Scene/far clip distance" && !list.empty()) { if(mCamera->getFarClipDistance() != list.at(0).toFloat()) mCamera->setFarClipDistance(list.at(0).toFloat()); From 517a797a3ed219632ee1240f32b3d078d0e04f40 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 2 Oct 2014 07:00:15 +1000 Subject: [PATCH 47/48] Remove seemingly unnecessary clearFocus() call (thanks scrawl for help). Fix saving window size on linux. --- apps/opencs/view/doc/view.cpp | 14 ++++++++++++-- apps/opencs/view/settings/settingwindow.cpp | 6 +----- apps/opencs/view/settings/settingwindow.hpp | 2 -- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 744865f1c..8edeeaec7 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -33,12 +33,22 @@ void CSVDoc::View::closeEvent (QCloseEvent *event) else { // save window size first + int width = 0; + int height = 0; + +#ifdef Q_WS_WIN + width = frameGeometry().width(); + height = frameGeometry().height(); +#else + width = geometry().width(); + height = geometry().height(); +#endif CSMSettings::UserSettings::instance().setDefinitions( "Window Size/Width", - QStringList(QString::number(frameGeometry().width()))); + QStringList(QString::number(width))); CSMSettings::UserSettings::instance().setDefinitions( "Window Size/Height", - QStringList(QString::number(frameGeometry().height()))); + QStringList(QString::number(height))); CSMSettings::UserSettings::instance().saveDefinitions(); // closeRequest() returns true if last document diff --git a/apps/opencs/view/settings/settingwindow.cpp b/apps/opencs/view/settings/settingwindow.cpp index 7cdf2bded..590b6f7a5 100644 --- a/apps/opencs/view/settings/settingwindow.cpp +++ b/apps/opencs/view/settings/settingwindow.cpp @@ -19,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)); @@ -129,7 +129,3 @@ void CSVSettings::SettingWindow::saveSettings() mModel->saveDefinitions(); } -void CSVSettings::SettingWindow::closeEvent (QCloseEvent *event) -{ - QApplication::focusWidget()->clearFocus(); -} diff --git a/apps/opencs/view/settings/settingwindow.hpp b/apps/opencs/view/settings/settingwindow.hpp index 2266f130d..11bceee96 100644 --- a/apps/opencs/view/settings/settingwindow.hpp +++ b/apps/opencs/view/settings/settingwindow.hpp @@ -36,8 +36,6 @@ namespace CSVSettings { protected: - virtual void closeEvent (QCloseEvent *event); - ///construct the pages to be displayed in the dialog void createPages(); From 115841d31dab16380b3114e0c97bfc629299535e Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 3 Oct 2014 05:59:24 +1000 Subject: [PATCH 48/48] Do not save window size on exit. --- apps/opencs/view/doc/view.cpp | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 8edeeaec7..73beee60c 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -32,25 +32,6 @@ void CSVDoc::View::closeEvent (QCloseEvent *event) event->ignore(); else { - // save window size first - int width = 0; - int height = 0; - -#ifdef Q_WS_WIN - width = frameGeometry().width(); - height = frameGeometry().height(); -#else - width = geometry().width(); - height = geometry().height(); -#endif - CSMSettings::UserSettings::instance().setDefinitions( - "Window Size/Width", - QStringList(QString::number(width))); - CSMSettings::UserSettings::instance().setDefinitions( - "Window Size/Height", - QStringList(QString::number(height))); - CSMSettings::UserSettings::instance().saveDefinitions(); - // closeRequest() returns true if last document mViewManager.removeDocAndView(mDocument); }