Made more progress. Grey out disabled settings.

This commit is contained in:
cc9cii 2014-09-16 19:50:25 +10:00
parent ffaca7a875
commit d679e0e012
8 changed files with 304 additions and 76 deletions

View file

@ -98,9 +98,7 @@ opencs_units_noqt (view/tools
) )
opencs_units (view/settings opencs_units (view/settings
settingwindow
settingsdialog settingsdialog
page
view view
booleanview booleanview
textview textview

View file

@ -283,8 +283,10 @@ std::auto_ptr<sh::Factory> CS::Editor::setupGraphics()
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
params.insert(std::make_pair("macAPI", "cocoa")); params.insert(std::make_pair("macAPI", "cocoa"));
#endif #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, &params); //Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, fullscreen, &params);
Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, false, &params);
hiddenWindow->setActive(false); hiddenWindow->setActive(false);
sh::OgrePlatform* platform = sh::OgrePlatform* platform =

View file

@ -377,8 +377,9 @@ QString CSMSettings::UserSettings::settingValue (const QString &settingKey)
QStringList defs; QStringList defs;
// check if video settings are overriden // check if video settings are overriden
if(settingKey.contains(QRegExp("^\\b(Video)", Qt::CaseInsensitive)) && if(settingKey.contains(QRegExp("^Video\\b", Qt::CaseInsensitive)) &&
mSettingDefinitions->value("Video/use settings.cfg") == "true") mSettingDefinitions->value("Video/use settings.cfg") == "true" &&
settingKey.contains(QRegExp("^Video/\\brender|antialiasing|vsync|fullscreen\\b", Qt::CaseInsensitive)))
{ {
if (!mSettingCfgDefinitions->contains (settingKey)) if (!mSettingCfgDefinitions->contains (settingKey))
return QString(); return QString();

View file

@ -8,6 +8,8 @@
#include "../../model/settings/usersettings.hpp" #include "../../model/settings/usersettings.hpp"
//#include "ui_settingstab.h"
#include "page.hpp" #include "page.hpp"
#include <QApplication> #include <QApplication>
@ -20,15 +22,157 @@
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QStandardItem> #include <QStandardItem>
#include <OgreRoot.h>
CSVSettings::SettingsDialog::SettingsDialog(QMainWindow *parent) #include <boost/math/common_factor.hpp>
: /*mStackedWidget (0),*/ mDebugMode (false), SettingWindow (parent) #include <QMessageBox>
//#include <QTranslator>
#include <QDesktopWidget>
namespace
{ {
setWindowTitle(QString::fromUtf8 ("User Settings")); // 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;
}
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())
{
QMessageBox msgBox;
msgBox.setWindowTitle(QObject::tr("Error retrieving rendering device"));
msgBox.setIcon(QMessageBox::Critical);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setText(QObject::tr("<br><b>Ogre Rendering Device empty<./b><br><br>"));
msgBox.exec();
return result;
}
//std::cout << "rd current: " << it->second.currentValue << std::endl; // FIXME: debug
// Store Available Rendering Devices
std::vector<std::string>::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("<br><b>Ogre Video Modes empty.</b><br><br>"));
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<std::string>::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); 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, //connect (mPageListWidget,
//SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)), //SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
@ -36,6 +180,7 @@ CSVSettings::SettingsDialog::SettingsDialog(QMainWindow *parent)
//SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*))); //SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*)));
} }
// FIXME: don't need this one, as we don't use pages
void CSVSettings::SettingsDialog::slotChangePage void CSVSettings::SettingsDialog::slotChangePage
(QListWidgetItem *cur, QListWidgetItem *prev) (QListWidgetItem *cur, QListWidgetItem *prev)
{ {
@ -46,6 +191,7 @@ void CSVSettings::SettingsDialog::slotChangePage
setFixedSize(minimumSizeHint()); setFixedSize(minimumSizeHint());
} }
// FIXME: don't need this one since we use setupUi
void CSVSettings::SettingsDialog::setupDialog() void CSVSettings::SettingsDialog::setupDialog()
{ {
//create central widget with it's layout and immediate children //create central widget with it's layout and immediate children
@ -62,8 +208,8 @@ void CSVSettings::SettingsDialog::setupDialog()
void CSVSettings::SettingsDialog::buildPages() void CSVSettings::SettingsDialog::buildPages()
{ {
SettingWindow::createPages ();
#if 0 #if 0
SettingWindow::createPages ();
QFontMetrics fm (QApplication::font()); QFontMetrics fm (QApplication::font());
@ -117,10 +263,62 @@ void CSVSettings::SettingsDialog::show()
//buildPages(); //buildPages();
//setViewValues(); //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);
move (screenCenter - geometry().center()); }
else
checkBox_override->setChecked(false);
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(); QWidget::show();
} }

View file

@ -1,7 +1,7 @@
#ifndef CSVSETTINGS_SETTINGSDIALOG_H #ifndef CSVSETTINGS_SETTINGSDIALOG_H
#define CSVSETTINGS_SETTINGSDIALOG_H #define CSVSETTINGS_SETTINGSDIALOG_H
#include "settingwindow.hpp" //#include "settingwindow.hpp"
//#include "resizeablestackedwidget.hpp" //#include "resizeablestackedwidget.hpp"
#include <QStandardItem> #include <QStandardItem>
@ -11,11 +11,17 @@
//class QListWidget; //class QListWidget;
class QListWidgetItem; class QListWidgetItem;
#if 0
namespace Ui {
class TabWidget;
}
#endif
namespace CSVSettings { namespace CSVSettings {
//class Page; //class Page;
class SettingsDialog : public SettingWindow, private Ui::TabWidget class SettingsDialog : public QTabWidget, private Ui::TabWidget
{ {
Q_OBJECT Q_OBJECT
@ -25,7 +31,7 @@ namespace CSVSettings {
public: public:
/*explicit*/ SettingsDialog (QMainWindow *parent = 0); /*explicit*/ SettingsDialog (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.

View file

@ -9,7 +9,7 @@
#include "view.hpp" #include "view.hpp"
CSVSettings::SettingWindow::SettingWindow(QWidget *parent) CSVSettings::SettingWindow::SettingWindow(QWidget *parent)
: QTabWidget(parent) : QMainWindow(parent)
{} {}
void CSVSettings::SettingWindow::createPages() void CSVSettings::SettingWindow::createPages()

View file

@ -18,7 +18,7 @@ namespace CSVSettings {
typedef QList <Page *> PageList; typedef QList <Page *> PageList;
class SettingWindow : public QTabWidget class SettingWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT

View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>400</width>
<height>300</height> <height>313</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -24,13 +24,13 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>20</x> <x>20</x>
<y>181</y> <y>188</y>
<width>351</width> <width>351</width>
<height>71</height> <height>81</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_Screen"> <layout class="QGridLayout" name="gridLayout_Screen">
<item row="1" column="1"> <item row="2" column="1">
<widget class="QRadioButton" name="radioButton_standard_res"> <widget class="QRadioButton" name="radioButton_standard_res">
<property name="text"> <property name="text">
<string>Standard:</string> <string>Standard:</string>
@ -43,7 +43,7 @@
</attribute> </attribute>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_Resolution"> <widget class="QLabel" name="label_Resolution">
<property name="text"> <property name="text">
<string>Resolution</string> <string>Resolution</string>
@ -57,7 +57,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="3" column="1">
<widget class="QRadioButton" name="radioButton_custom_res"> <widget class="QRadioButton" name="radioButton_custom_res">
<property name="text"> <property name="text">
<string>Custom;</string> <string>Custom;</string>
@ -67,17 +67,7 @@
</attribute> </attribute>
</widget> </widget>
</item> </item>
<item row="1" column="2" colspan="2"> <item row="3" column="2">
<widget class="QComboBox" name="comboBox_std_window_size">
<property name="minimumSize">
<size>
<width>180</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QSpinBox" name="spinBox_x"> <widget class="QSpinBox" name="spinBox_x">
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
@ -87,9 +77,32 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="3"> <item row="3" column="3">
<widget class="QSpinBox" name="spinBox_y"/> <widget class="QSpinBox" name="spinBox_y"/>
</item> </item>
<item row="2" column="2" colspan="2">
<widget class="QComboBox" name="comboBox_std_window_size">
<property name="minimumSize">
<size>
<width>180</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="Line" name="line_2">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>2</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QGroupBox" name="renderGroup"> <widget class="QGroupBox" name="renderGroup">
@ -98,7 +111,7 @@
<x>10</x> <x>10</x>
<y>8</y> <y>8</y>
<width>371</width> <width>371</width>
<height>153</height> <height>156</height>
</rect> </rect>
</property> </property>
<property name="title"> <property name="title">
@ -109,9 +122,9 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>165</y> <y>170</y>
<width>371</width> <width>371</width>
<height>99</height> <height>108</height>
</rect> </rect>
</property> </property>
<property name="title"> <property name="title">
@ -121,21 +134,15 @@
<widget class="QWidget" name="layoutWidget"> <widget class="QWidget" name="layoutWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>21</x> <x>20</x>
<y>26</y> <y>26</y>
<width>351</width> <width>351</width>
<height>125</height> <height>129</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2"> <item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox_override"> <widget class="QCheckBox" name="checkBox_override">
<property name="minimumSize">
<size>
<width>0</width>
<height>22</height>
</size>
</property>
<property name="text"> <property name="text">
<string>Use Render System Settings from OpenMW</string> <string>Use Render System Settings from OpenMW</string>
</property> </property>
@ -144,14 +151,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_RenderingSubsystem"> <widget class="QLabel" name="label_RenderingSubsystem">
<property name="text"> <property name="text">
<string>Rendering Subsystem</string> <string>Rendering Subsystem</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="2" column="1">
<widget class="QComboBox" name="comboBox_rendersystem"> <widget class="QComboBox" name="comboBox_rendersystem">
<property name="editable"> <property name="editable">
<bool>false</bool> <bool>false</bool>
@ -168,21 +175,42 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="4" column="0">
<widget class="QCheckBox" name="checkBox_vsync">
<property name="text">
<string>Vertical Sync</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_Antialiasing"> <widget class="QLabel" name="label_Antialiasing">
<property name="text"> <property name="text">
<string>Antialiasing</string> <string>Antialiasing</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="0">
<widget class="QCheckBox" name="checkBox_vsync">
<property name="text">
<string>Vertical Sync</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_ShaderLanguage">
<property name="text">
<string>Shader Language</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="comboBox_shaderlanguage">
<item>
<property name="text">
<string>HLSL</string>
</property>
</item>
<item>
<property name="text">
<string>CG</string>
</property>
</item>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="comboBox_antialiasing"> <widget class="QComboBox" name="comboBox_antialiasing">
<item> <item>
<property name="text"> <property name="text">
@ -211,25 +239,20 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_ShaderLanguage"> <widget class="Line" name="line">
<property name="text"> <property name="maximumSize">
<string>Shader Language</string> <size>
<width>16777215</width>
<height>2</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(215, 215, 215);</string>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property> </property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="comboBox_shaderlanguage">
<item>
<property name="text">
<string>HLSL</string>
</property>
</item>
<item>
<property name="text">
<string>CG</string>
</property>
</item>
</widget> </widget>
</item> </item>
</layout> </layout>