diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 7094f8799e..be536535e3 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 d3e5c6720f..1887629f90 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 c87e24e77a..4ccc61a021 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 6ccc9ddb02..e655a66a3b 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 0000000000..db7b49a54f --- /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 0000000000..e9bd2d0435 --- /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 7cdf2bded9..c704185532 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 2266f130df..b1f55d67f4 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 0000000000..620e8d0c50 --- /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 + + + + + + + + +