mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
Integrated into the original settings design, except using tabs rather than list & stacked widgets. Works but visuals need updating.
This commit is contained in:
parent
5dfcd2ed01
commit
dbd1ab05d3
@ -98,7 +98,6 @@ opencs_units_noqt (view/tools
|
|||||||
)
|
)
|
||||||
|
|
||||||
opencs_units (view/settings
|
opencs_units (view/settings
|
||||||
settingsdialog
|
|
||||||
settingwindow
|
settingwindow
|
||||||
dialog
|
dialog
|
||||||
page
|
page
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "view/doc/filedialog.hpp"
|
#include "view/doc/filedialog.hpp"
|
||||||
#include "view/doc/newgame.hpp"
|
#include "view/doc/newgame.hpp"
|
||||||
|
|
||||||
#include "view/settings/settingsdialog.hpp"
|
#include "view/settings/dialog.hpp"
|
||||||
|
|
||||||
namespace OgreInit
|
namespace OgreInit
|
||||||
{
|
{
|
||||||
@ -46,7 +46,7 @@ namespace CS
|
|||||||
CSVDoc::ViewManager mViewManager;
|
CSVDoc::ViewManager mViewManager;
|
||||||
CSVDoc::StartupDialogue mStartup;
|
CSVDoc::StartupDialogue mStartup;
|
||||||
CSVDoc::NewGameDialogue mNewGame;
|
CSVDoc::NewGameDialogue mNewGame;
|
||||||
CSVSettings::SettingsDialog mSettings;
|
CSVSettings::Dialog mSettings;
|
||||||
CSVDoc::FileDialog mFileDialog;
|
CSVDoc::FileDialog mFileDialog;
|
||||||
boost::filesystem::path mLocal;
|
boost::filesystem::path mLocal;
|
||||||
boost::filesystem::path mResources;
|
boost::filesystem::path mResources;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "support.hpp"
|
#include "support.hpp"
|
||||||
|
|
||||||
CSMSettings::Setting::Setting(SettingType typ, const QString &settingName,
|
CSMSettings::Setting::Setting(SettingType typ, const QString &settingName,
|
||||||
const QString &pageName)
|
const QString &pageName, const QString §ion)
|
||||||
: mIsEditorSetting (false)
|
: mIsEditorSetting (false)
|
||||||
{
|
{
|
||||||
buildDefaultSetting();
|
buildDefaultSetting();
|
||||||
@ -17,6 +17,7 @@ CSMSettings::Setting::Setting(SettingType typ, const QString &settingName,
|
|||||||
setProperty (Property_SettingType, QVariant (settingType).toString());
|
setProperty (Property_SettingType, QVariant (settingType).toString());
|
||||||
setProperty (Property_Page, pageName);
|
setProperty (Property_Page, pageName);
|
||||||
setProperty (Property_Name, settingName);
|
setProperty (Property_Name, settingName);
|
||||||
|
setProperty (Property_Section, section);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMSettings::Setting::buildDefaultSetting()
|
void CSMSettings::Setting::buildDefaultSetting()
|
||||||
@ -194,6 +195,16 @@ QString CSMSettings::Setting::page() const
|
|||||||
return property (Property_Page).at(0);
|
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)
|
void CSMSettings::Setting::setPrefix (const QString &value)
|
||||||
{
|
{
|
||||||
setProperty (Property_Prefix, value);
|
setProperty (Property_Prefix, value);
|
||||||
|
@ -30,7 +30,7 @@ namespace CSMSettings
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
explicit Setting(SettingType typ, const QString &settingName,
|
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 QStringList &vals);
|
||||||
void addProxy (const Setting *setting, const QList <QStringList> &list);
|
void addProxy (const Setting *setting, const QList <QStringList> &list);
|
||||||
@ -80,6 +80,9 @@ namespace CSMSettings
|
|||||||
void setPage (const QString &value);
|
void setPage (const QString &value);
|
||||||
QString page() const;
|
QString page() const;
|
||||||
|
|
||||||
|
void setSection (const QString &value);
|
||||||
|
QString section() const;
|
||||||
|
|
||||||
void setPrefix (const QString &value);
|
void setPrefix (const QString &value);
|
||||||
QString prefix() const;
|
QString prefix() const;
|
||||||
|
|
||||||
|
@ -35,12 +35,13 @@ namespace CSMSettings
|
|||||||
Property_TickInterval = 19,
|
Property_TickInterval = 19,
|
||||||
Property_TicksAbove = 20,
|
Property_TicksAbove = 20,
|
||||||
Property_TicksBelow = 21,
|
Property_TicksBelow = 21,
|
||||||
|
Property_Section = 22,
|
||||||
|
|
||||||
//Stringlists should always be the last items
|
//Stringlists should always be the last items
|
||||||
Property_DefaultValues = 22,
|
Property_DefaultValues = 23,
|
||||||
Property_DeclaredValues = 23,
|
Property_DeclaredValues = 24,
|
||||||
Property_DefinedValues = 24,
|
Property_DefinedValues = 25,
|
||||||
Property_Proxies = 25
|
Property_Proxies = 26
|
||||||
};
|
};
|
||||||
|
|
||||||
///Basic setting widget types.
|
///Basic setting widget types.
|
||||||
@ -106,7 +107,7 @@ namespace CSMSettings
|
|||||||
"is_multi_line", "widget_width", "view_row", "view_column", "delimiter",
|
"is_multi_line", "widget_width", "view_row", "view_column", "delimiter",
|
||||||
"is_serializable","column_span", "row_span", "minimum", "maximum",
|
"is_serializable","column_span", "row_span", "minimum", "maximum",
|
||||||
"special_value_text", "prefix", "suffix", "single_step", "wrapping",
|
"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"
|
"defaults", "declarations", "definitions", "proxies"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -135,6 +136,7 @@ namespace CSMSettings
|
|||||||
"1", //tick interval
|
"1", //tick interval
|
||||||
"false", //ticks above
|
"false", //ticks above
|
||||||
"true", //ticks below
|
"true", //ticks below
|
||||||
|
"", //Section
|
||||||
"", //default values
|
"", //default values
|
||||||
"", //declared values
|
"", //declared values
|
||||||
"", //defined values
|
"", //defined values
|
||||||
|
@ -32,9 +32,12 @@ namespace boost
|
|||||||
} /* namespace boost */
|
} /* namespace boost */
|
||||||
#endif /* (BOOST_VERSION <= 104600) */
|
#endif /* (BOOST_VERSION <= 104600) */
|
||||||
|
|
||||||
CSMSettings::UserSettings *CSMSettings::UserSettings::mUserSettingsInstance = 0;
|
namespace CSMSettings
|
||||||
|
{
|
||||||
|
|
||||||
CSMSettings::UserSettings::UserSettings (const Files::ConfigurationManager& configurationManager)
|
UserSettings *UserSettings::mUserSettingsInstance = 0;
|
||||||
|
|
||||||
|
UserSettings::UserSettings (const Files::ConfigurationManager& configurationManager)
|
||||||
: mCfgMgr (configurationManager)
|
: mCfgMgr (configurationManager)
|
||||||
, mSettingDefinitions(NULL)
|
, mSettingDefinitions(NULL)
|
||||||
, mSettingCfgDefinitions(NULL)
|
, mSettingCfgDefinitions(NULL)
|
||||||
@ -48,9 +51,138 @@ CSMSettings::UserSettings::UserSettings (const Files::ConfigurationManager& conf
|
|||||||
mSettingCfgDefinitions = new QSettings(QSettings::IniFormat, QSettings::UserScope, "", QString(), this);
|
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 *width = createSetting (Type_LineEdit, section, "Width");
|
||||||
Setting *height = createSetting (Type_LineEdit, section, "Height");
|
Setting *height = createSetting (Type_LineEdit, section, "Height");
|
||||||
@ -283,12 +415,12 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMSettings::UserSettings::~UserSettings()
|
UserSettings::~UserSettings()
|
||||||
{
|
{
|
||||||
mUserSettingsInstance = 0;
|
mUserSettingsInstance = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMSettings::UserSettings::loadSettings (const QString &fileName)
|
void UserSettings::loadSettings (const QString &fileName)
|
||||||
{
|
{
|
||||||
QString userFilePath = QString::fromUtf8
|
QString userFilePath = QString::fromUtf8
|
||||||
(mCfgMgr.getUserConfigPath().string().c_str());
|
(mCfgMgr.getUserConfigPath().string().c_str());
|
||||||
@ -369,7 +501,7 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName)
|
|||||||
mSettingDefinitions->setValue("Video/use settings.cfg", "true");
|
mSettingDefinitions->setValue("Video/use settings.cfg", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CSMSettings::UserSettings::getOgreRenderers()
|
QStringList UserSettings::getOgreRenderers()
|
||||||
{
|
{
|
||||||
if(mOgreRenderers.empty())
|
if(mOgreRenderers.empty())
|
||||||
{
|
{
|
||||||
@ -382,7 +514,7 @@ QStringList CSMSettings::UserSettings::getOgreRenderers()
|
|||||||
return mOgreRenderers;
|
return mOgreRenderers;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CSMSettings::UserSettings::getOgreOptions(const QString &key, const QString &renderer)
|
QStringList UserSettings::getOgreOptions(const QString &key, const QString &renderer)
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
|
|
||||||
@ -421,7 +553,7 @@ QStringList CSMSettings::UserSettings::getOgreOptions(const QString &key, const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CSMSettings::UserSettings::getShaderLanguageByRenderer(const QString &renderer)
|
QStringList UserSettings::getShaderLanguageByRenderer(const QString &renderer)
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
|
|
||||||
@ -435,24 +567,22 @@ QStringList CSMSettings::UserSettings::getShaderLanguageByRenderer(const QString
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSMSettings::UserSettings::hasSettingDefinitions
|
bool UserSettings::hasSettingDefinitions (const QString &viewKey) const
|
||||||
(const QString &viewKey) const
|
|
||||||
{
|
{
|
||||||
return (mSettingDefinitions->contains (viewKey));
|
return (mSettingDefinitions->contains (viewKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMSettings::UserSettings::setDefinitions
|
void UserSettings::setDefinitions (const QString &key, const QStringList &list)
|
||||||
(const QString &key, const QStringList &list)
|
|
||||||
{
|
{
|
||||||
mSettingDefinitions->setValue (key, list);
|
mSettingDefinitions->setValue (key, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMSettings::UserSettings::saveDefinitions() const
|
void UserSettings::saveDefinitions() const
|
||||||
{
|
{
|
||||||
mSettingDefinitions->sync();
|
mSettingDefinitions->sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CSMSettings::UserSettings::settingValue (const QString &settingKey)
|
QString UserSettings::settingValue (const QString &settingKey)
|
||||||
{
|
{
|
||||||
QStringList defs;
|
QStringList defs;
|
||||||
|
|
||||||
@ -480,22 +610,20 @@ QString CSMSettings::UserSettings::settingValue (const QString &settingKey)
|
|||||||
return defs.at(0);
|
return defs.at(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMSettings::UserSettings& CSMSettings::UserSettings::instance()
|
UserSettings& UserSettings::instance()
|
||||||
{
|
{
|
||||||
assert(mUserSettingsInstance);
|
assert(mUserSettingsInstance);
|
||||||
return *mUserSettingsInstance;
|
return *mUserSettingsInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMSettings::UserSettings::updateUserSetting(const QString &settingKey,
|
void UserSettings::updateUserSetting(const QString &settingKey, const QStringList &list)
|
||||||
const QStringList &list)
|
|
||||||
{
|
{
|
||||||
mSettingDefinitions->setValue (settingKey ,list);
|
mSettingDefinitions->setValue (settingKey ,list);
|
||||||
|
|
||||||
emit userSettingUpdated (settingKey, list);
|
emit userSettingUpdated (settingKey, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMSettings::Setting *CSMSettings::UserSettings::findSetting
|
Setting *UserSettings::findSetting (const QString &pageName, const QString &settingName)
|
||||||
(const QString &pageName, const QString &settingName)
|
|
||||||
{
|
{
|
||||||
foreach (Setting *setting, mSettings)
|
foreach (Setting *setting, mSettings)
|
||||||
{
|
{
|
||||||
@ -508,8 +636,7 @@ CSMSettings::Setting *CSMSettings::UserSettings::findSetting
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMSettings::UserSettings::removeSetting
|
void UserSettings::removeSetting (const QString &pageName, const QString &settingName)
|
||||||
(const QString &pageName, const QString &settingName)
|
|
||||||
{
|
{
|
||||||
if (mSettings.isEmpty())
|
if (mSettings.isEmpty())
|
||||||
return;
|
return;
|
||||||
@ -530,7 +657,7 @@ void CSMSettings::UserSettings::removeSetting
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMSettings::SettingPageMap CSMSettings::UserSettings::settingPageMap() const
|
SettingPageMap UserSettings::settingPageMap() const
|
||||||
{
|
{
|
||||||
SettingPageMap pageMap;
|
SettingPageMap pageMap;
|
||||||
|
|
||||||
@ -540,8 +667,8 @@ CSMSettings::SettingPageMap CSMSettings::UserSettings::settingPageMap() const
|
|||||||
return pageMap;
|
return pageMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMSettings::Setting *CSMSettings::UserSettings::createSetting
|
Setting *UserSettings::createSetting
|
||||||
(CSMSettings::SettingType typ, const QString &page, const QString &name)
|
(SettingType typ, const QString &page, const QString &name)
|
||||||
{
|
{
|
||||||
//get list of all settings for the current setting name
|
//get list of all settings for the current setting name
|
||||||
if (findSetting (page, name))
|
if (findSetting (page, name))
|
||||||
@ -560,10 +687,12 @@ CSMSettings::Setting *CSMSettings::UserSettings::createSetting
|
|||||||
return setting;
|
return setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CSMSettings::UserSettings::definitions (const QString &viewKey) const
|
QStringList UserSettings::definitions (const QString &viewKey) const
|
||||||
{
|
{
|
||||||
if (mSettingDefinitions->contains (viewKey))
|
if (mSettingDefinitions->contains (viewKey))
|
||||||
return mSettingDefinitions->value (viewKey).toStringList();
|
return mSettingDefinitions->value (viewKey).toStringList();
|
||||||
|
|
||||||
return QStringList();
|
return QStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,39 +1,233 @@
|
|||||||
#include "dialog.hpp"
|
#include "dialog.hpp"
|
||||||
|
|
||||||
#include <QListWidgetItem>
|
//#include <QListWidgetItem>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QDesktopWidget>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QStackedWidget>
|
//#include <QStackedWidget>
|
||||||
#include <QtGui>
|
//#include <QtGui>
|
||||||
|
|
||||||
#include "../../model/settings/usersettings.hpp"
|
#include "../../model/settings/usersettings.hpp"
|
||||||
|
|
||||||
#include "page.hpp"
|
#include "page.hpp"
|
||||||
|
|
||||||
#include <QApplication>
|
//#include <QApplication>
|
||||||
|
|
||||||
#include <QSplitter>
|
//#include <QSplitter>
|
||||||
|
|
||||||
#include <QTreeView>
|
//#include <QTreeView>
|
||||||
#include <QListView>
|
//#include <QListView>
|
||||||
#include <QTableView>
|
//#include <QTableView>
|
||||||
|
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QStandardItem>
|
#include <QStandardItem>
|
||||||
|
|
||||||
CSVSettings::Dialog::Dialog(QMainWindow *parent)
|
#include <OgreRoot.h>
|
||||||
: mStackedWidget (0), mDebugMode (false), SettingWindow (parent)
|
#include <boost/math/common_factor.hpp>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
QRect getMaximumResolution()
|
||||||
{
|
{
|
||||||
setWindowTitle(QString::fromUtf8 ("User Settings"));
|
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()
|
||||||
|
{
|
||||||
|
// 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();
|
setupDialog();
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// FIXME: delete - don't need this for tabs
|
||||||
connect (mPageListWidget,
|
connect (mPageListWidget,
|
||||||
SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
|
SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
|
||||||
this,
|
this,
|
||||||
SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*)));
|
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
|
void CSVSettings::Dialog::slotChangePage
|
||||||
(QListWidgetItem *cur, QListWidgetItem *prev)
|
(QListWidgetItem *cur, QListWidgetItem *prev)
|
||||||
{
|
{
|
||||||
@ -43,9 +237,11 @@ void CSVSettings::Dialog::slotChangePage
|
|||||||
layout()->activate();
|
layout()->activate();
|
||||||
setFixedSize(minimumSizeHint());
|
setFixedSize(minimumSizeHint());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void CSVSettings::Dialog::setupDialog()
|
void CSVSettings::Dialog::setupDialog()
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
//create central widget with it's layout and immediate children
|
//create central widget with it's layout and immediate children
|
||||||
QWidget *centralWidget = new QGroupBox (this);
|
QWidget *centralWidget = new QGroupBox (this);
|
||||||
|
|
||||||
@ -56,29 +252,112 @@ void CSVSettings::Dialog::setupDialog()
|
|||||||
|
|
||||||
buildPageListWidget (centralWidget);
|
buildPageListWidget (centralWidget);
|
||||||
buildStackedWidget (centralWidget);
|
buildStackedWidget (centralWidget);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVSettings::Dialog::buildPages()
|
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 ();
|
SettingWindow::createPages ();
|
||||||
|
|
||||||
QFontMetrics fm (QApplication::font());
|
//QFontMetrics fm (QApplication::font());
|
||||||
|
|
||||||
foreach (Page *page, SettingWindow::pages())
|
foreach (Page *page, SettingWindow::pages())
|
||||||
{
|
{
|
||||||
QString pageName = page->objectName();
|
QString pageName = page->objectName();
|
||||||
|
|
||||||
int textWidth = fm.width(pageName);
|
//int textWidth = fm.width(pageName);
|
||||||
|
|
||||||
new QListWidgetItem (pageName, mPageListWidget);
|
// each page is added as a tab to Ui::TabWiget
|
||||||
mPageListWidget->setFixedWidth (textWidth + 50);
|
addTab(page, page->objectName());
|
||||||
|
|
||||||
mStackedWidget->addWidget (&dynamic_cast<QWidget &>(*(page)));
|
// add section and views to the page
|
||||||
|
buildTabPage(page);
|
||||||
|
page->showWidgets();
|
||||||
|
|
||||||
|
//new QListWidgetItem (pageName, mPageListWidget);
|
||||||
|
//mPageListWidget->setFixedWidth (textWidth + 50);
|
||||||
|
|
||||||
|
//mStackedWidget->addWidget (&dynamic_cast<QWidget &>(*(page)));
|
||||||
}
|
}
|
||||||
|
|
||||||
resize (mStackedWidget->sizeHint());
|
//resize (mStackedWidget->sizeHint());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// FIXME: delete - not required, using tabs instead
|
||||||
void CSVSettings::Dialog::buildPageListWidget (QWidget *centralWidget)
|
void CSVSettings::Dialog::buildPageListWidget (QWidget *centralWidget)
|
||||||
{
|
{
|
||||||
mPageListWidget = new QListWidget (centralWidget);
|
mPageListWidget = new QListWidget (centralWidget);
|
||||||
@ -96,6 +375,7 @@ void CSVSettings::Dialog::buildStackedWidget (QWidget *centralWidget)
|
|||||||
|
|
||||||
centralWidget->layout()->addWidget (mStackedWidget);
|
centralWidget->layout()->addWidget (mStackedWidget);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void CSVSettings::Dialog::closeEvent (QCloseEvent *event)
|
void CSVSettings::Dialog::closeEvent (QCloseEvent *event)
|
||||||
{
|
{
|
||||||
@ -103,6 +383,67 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event)
|
|||||||
//model is updated
|
//model is updated
|
||||||
SettingWindow::closeEvent (event);
|
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();
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,28 +2,30 @@
|
|||||||
#define CSVSETTINGS_DIALOG_H
|
#define CSVSETTINGS_DIALOG_H
|
||||||
|
|
||||||
#include "settingwindow.hpp"
|
#include "settingwindow.hpp"
|
||||||
#include "resizeablestackedwidget.hpp"
|
//#include "resizeablestackedwidget.hpp"
|
||||||
#include <QStandardItem>
|
#include <QStandardItem>
|
||||||
|
|
||||||
class QStackedWidget;
|
//class QStackedWidget;
|
||||||
class QListWidget;
|
//class QListWidget;
|
||||||
class QListWidgetItem;
|
//class QListWidgetItem;
|
||||||
|
|
||||||
|
#include "ui_settingstab.h"
|
||||||
|
|
||||||
namespace CSVSettings {
|
namespace CSVSettings {
|
||||||
|
|
||||||
class Page;
|
class Page;
|
||||||
|
|
||||||
class Dialog : public SettingWindow
|
class Dialog : public SettingWindow, private Ui::TabWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
QListWidget *mPageListWidget;
|
//QListWidget *mPageListWidget;
|
||||||
ResizeableStackedWidget *mStackedWidget;
|
//ResizeableStackedWidget *mStackedWidget;
|
||||||
bool mDebugMode;
|
bool mDebugMode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit Dialog (QMainWindow *parent = 0);
|
explicit Dialog (QTabWidget *parent = 0);
|
||||||
|
|
||||||
///Enables setting debug mode. When the dialog opens, a page is created
|
///Enables setting debug mode. When the dialog opens, a page is created
|
||||||
///which displays the SettingModel's contents in a Tree view.
|
///which displays the SettingModel's contents in a Tree view.
|
||||||
@ -39,8 +41,8 @@ namespace CSVSettings {
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
void buildPages();
|
void buildPages();
|
||||||
void buildPageListWidget (QWidget *centralWidget);
|
//void buildPageListWidget (QWidget *centralWidget);
|
||||||
void buildStackedWidget (QWidget *centralWidget);
|
//void buildStackedWidget (QWidget *centralWidget);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
@ -48,7 +50,13 @@ namespace CSVSettings {
|
|||||||
|
|
||||||
private slots:
|
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
|
#endif // CSVSETTINGS_DIALOG_H
|
||||||
|
@ -1,486 +0,0 @@
|
|||||||
#include "settingsdialog.hpp"
|
|
||||||
|
|
||||||
#include <boost/math/common_factor.hpp>
|
|
||||||
#include <OgreRoot.h>
|
|
||||||
|
|
||||||
#include <QDesktopWidget>
|
|
||||||
|
|
||||||
#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<QWidget *>(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 <CSMSettings::Setting *> &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 <QStringList> 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();
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
#ifndef CSVSETTINGS_SETTINGSDIALOG_H
|
|
||||||
#define CSVSETTINGS_SETTINGSDIALOG_H
|
|
||||||
|
|
||||||
#include <QStandardItem>
|
|
||||||
|
|
||||||
#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 <CSMSettings::Setting *> &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
|
|
@ -1,15 +1,19 @@
|
|||||||
|
#include "settingwindow.hpp"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
//#include <QDesktopWidget>
|
||||||
|
//#include <QLineEdit>
|
||||||
|
//#include <QRadioButton>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "../../model/settings/setting.hpp"
|
#include "../../model/settings/setting.hpp"
|
||||||
#include "../../model/settings/connector.hpp"
|
#include "../../model/settings/connector.hpp"
|
||||||
#include "../../model/settings/usersettings.hpp"
|
#include "../../model/settings/usersettings.hpp"
|
||||||
#include "settingwindow.hpp"
|
|
||||||
#include "page.hpp"
|
#include "page.hpp"
|
||||||
#include "view.hpp"
|
#include "view.hpp"
|
||||||
|
|
||||||
CSVSettings::SettingWindow::SettingWindow(QWidget *parent)
|
CSVSettings::SettingWindow::SettingWindow(QTabWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QTabWidget(parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void CSVSettings::SettingWindow::createPages()
|
void CSVSettings::SettingWindow::createPages()
|
||||||
@ -19,7 +23,7 @@ void CSVSettings::SettingWindow::createPages()
|
|||||||
QList <CSMSettings::Setting *> connectedSettings;
|
QList <CSMSettings::Setting *> connectedSettings;
|
||||||
|
|
||||||
foreach (const QString &pageName, pageMap.keys())
|
foreach (const QString &pageName, pageMap.keys())
|
||||||
{
|
{
|
||||||
QList <CSMSettings::Setting *> pageSettings = pageMap.value (pageName);
|
QList <CSMSettings::Setting *> pageSettings = pageMap.value (pageName);
|
||||||
|
|
||||||
mPages.append (new Page (pageName, pageSettings, this));
|
mPages.append (new Page (pageName, pageSettings, this));
|
||||||
@ -37,6 +41,162 @@ void CSVSettings::SettingWindow::createPages()
|
|||||||
createConnections(connectedSettings);
|
createConnections(connectedSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVSettings::SettingWindow::buildTabPage(Page* tab)
|
||||||
|
{
|
||||||
|
CSMSettings::SettingPageMap pageMap = mModel->settingPageMap();
|
||||||
|
QList <CSMSettings::Setting *> 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<CSMSettings::Setting*> 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<QLabel*> (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<QWidget &>(*(page)));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void CSVSettings::SettingWindow::createConnections
|
void CSVSettings::SettingWindow::createConnections
|
||||||
(const QList <CSMSettings::Setting *> &list)
|
(const QList <CSMSettings::Setting *> &list)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef CSVSETTINGS_SETTINGWINDOW_HPP
|
#ifndef CSVSETTINGS_SETTINGWINDOW_HPP
|
||||||
#define CSVSETTINGS_SETTINGWINDOW_HPP
|
#define CSVSETTINGS_SETTINGWINDOW_HPP
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QTabWidget>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
#include "../../model/settings/support.hpp"
|
#include "../../model/settings/support.hpp"
|
||||||
@ -18,7 +18,7 @@ namespace CSVSettings {
|
|||||||
|
|
||||||
typedef QList <Page *> PageList;
|
typedef QList <Page *> PageList;
|
||||||
|
|
||||||
class SettingWindow : public QMainWindow
|
class SettingWindow : public QTabWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ namespace CSVSettings {
|
|||||||
CSMSettings::UserSettings *mModel;
|
CSMSettings::UserSettings *mModel;
|
||||||
|
|
||||||
public:
|
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
|
///retrieve a reference to a view based on it's page and setting name
|
||||||
View *findView (const QString &pageName, const QString &setting);
|
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
|
///sets the defined values for the views that have been created
|
||||||
void setViewValues();
|
void setViewValues();
|
||||||
|
|
||||||
|
void buildTabPage(Page* tab);
|
||||||
|
CSMSettings::UserSettings *model() { return mModel; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
///create connections between settings (used for proxy settings)
|
///create connections between settings (used for proxy settings)
|
||||||
|
@ -145,7 +145,7 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Display Format</string>
|
<string>Display Format</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="layoutWidget">
|
<widget class="QWidget" name="layoutWidget_DisplayFormat">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
@ -223,7 +223,7 @@
|
|||||||
<string>Subviews</string>
|
<string>Subviews</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="layoutWidget2">
|
<widget class="QWidget" name="layoutWidget_Subviews">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>21</x>
|
<x>21</x>
|
||||||
@ -291,37 +291,73 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Window Size</string>
|
<string>Window Size</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="layoutWidget">
|
<widget class="QStackedWidget" name="stackedWidget">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>20</y>
|
<y>20</y>
|
||||||
<width>171</width>
|
<width>171</width>
|
||||||
<height>22</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_4">
|
<property name="currentIndex">
|
||||||
<item row="0" column="0">
|
<number>0</number>
|
||||||
<widget class="QSpinBox" name="sbWidth">
|
</property>
|
||||||
<property name="maximumSize">
|
<widget class="QWidget" name="page">
|
||||||
<size>
|
<property name="enabled">
|
||||||
<width>186</width>
|
<bool>true</bool>
|
||||||
<height>16777215</height>
|
</property>
|
||||||
</size>
|
<widget class="QWidget" name="displayGroup_WindowSize">
|
||||||
</property>
|
<property name="geometry">
|
||||||
<property name="alignment">
|
<rect>
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<x>0</x>
|
||||||
</property>
|
<y>0</y>
|
||||||
</widget>
|
<width>171</width>
|
||||||
</item>
|
<height>22</height>
|
||||||
<item row="0" column="1">
|
</rect>
|
||||||
<widget class="QSpinBox" name="sbHeight">
|
</property>
|
||||||
<property name="alignment">
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<item row="0" column="0">
|
||||||
</property>
|
<widget class="QSpinBox" name="sbWidth">
|
||||||
</widget>
|
<property name="maximumSize">
|
||||||
</item>
|
<size>
|
||||||
</layout>
|
<width>186</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QSpinBox" name="sbHeight">
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="page_2">
|
||||||
|
<widget class="QComboBox" name="cmbStdWinSize">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>171</width>
|
||||||
|
<height>22</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QCheckBox" name="cbStatusBar">
|
<widget class="QCheckBox" name="cbStatusBar">
|
||||||
@ -340,27 +376,9 @@
|
|||||||
<zorder>displayGroup_Window</zorder>
|
<zorder>displayGroup_Window</zorder>
|
||||||
<zorder>displayGroup_DisplayFormat</zorder>
|
<zorder>displayGroup_DisplayFormat</zorder>
|
||||||
<zorder>displayGroup_Subviews</zorder>
|
<zorder>displayGroup_Subviews</zorder>
|
||||||
<zorder>layoutWidget2</zorder>
|
<zorder>displayGroup_WindowSize</zorder>
|
||||||
<zorder>cbStatusBar</zorder>
|
<zorder>cbStatusBar</zorder>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="MiscSettings">
|
|
||||||
<attribute name="title">
|
|
||||||
<string>Misc Settings</string>
|
|
||||||
</attribute>
|
|
||||||
<widget class="QComboBox" name="cmbStdWinSize">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>70</x>
|
|
||||||
<y>100</y>
|
|
||||||
<width>69</width>
|
|
||||||
<height>22</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user