Made more progress. Grey out disabled settings.

deque
cc9cii 10 years ago
parent ffaca7a875
commit d679e0e012

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

@ -283,8 +283,10 @@ std::auto_ptr<sh::Factory> CS::Editor::setupGraphics()
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
params.insert(std::make_pair("macAPI", "cocoa"));
#endif
// FIXME: don't apply the fullscreen here, apply to the editor window
bool fullscreen = mUserSettings.settingValue("Video/fullscreen").toStdString() == "true" ? true : false;
Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, fullscreen, &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);
sh::OgrePlatform* platform =

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

@ -8,6 +8,8 @@
#include "../../model/settings/usersettings.hpp"
//#include "ui_settingstab.h"
#include "page.hpp"
#include <QApplication>
@ -20,15 +22,157 @@
#include <QStandardItemModel>
#include <QStandardItem>
#include <OgreRoot.h>
#include <boost/math/common_factor.hpp>
#include <QMessageBox>
//#include <QTranslator>
#include <QDesktopWidget>
namespace
{
// copied from launcher
QString getAspect(int x, int y)
{
int gcd = boost::math::gcd (x, y);
int xaspect = x / gcd;
int yaspect = y / gcd;
// special case: 8 : 5 is usually referred to as 16:10
if (xaspect == 8 && yaspect == 5)
return QString("16:10");
return QString(QString::number(xaspect) + ":" + QString::number(yaspect));
}
QRect getMaximumResolution()
{
QRect max;
int screens = QApplication::desktop()->screenCount();
for(int i = 0; i < screens; ++i)
{
QRect res = QApplication::desktop()->screenGeometry(i);
if(res.width() > max.width())
max.setWidth(res.width());
if(res.height() > max.height())
max.setHeight(res.height());
}
return max;
}
QString getCurrentResolution()
{
QString result;
Ogre::ConfigOptionMap& renderOpt =
Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions();
Ogre::ConfigOptionMap::iterator it = renderOpt.begin();
for(;it != renderOpt.end(); ++it)
{
if(it->first == "Video Mode" )
{
QRegExp re("^(\\d+) x (\\d+)");
int pos = re.indexIn(it->second.currentValue.c_str(), 0);
if (pos > -1)
{
QString aspect = getAspect(re.cap(1).toInt(), re.cap(2).toInt());
result = re.cap(1) + QString(" x ") + re.cap(2);
if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10"))
{
//result.append(QObject::tr("\t(Wide ") + aspect + ")");
}
else if (aspect == QLatin1String("4:3"))
{
//result.append(QObject::tr("\t(Standard 4:3)"));
}
}
}
}
return result;
}
CSVSettings::SettingsDialog::SettingsDialog(QMainWindow *parent)
: /*mStackedWidget (0),*/ mDebugMode (false), SettingWindow (parent)
QStringList getAvailableResolutions()
{
setWindowTitle(QString::fromUtf8 ("User Settings"));
// store available rendering devices and available resolutions
QStringList result;
Ogre::ConfigOptionMap& renderOpt = Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions();
Ogre::ConfigOptionMap::iterator it = renderOpt.begin();
for(;it != renderOpt.end(); ++it)
{
if(it->first == "Rendering Device" )
{
if(it->second.possibleValues.empty())
{
QMessageBox msgBox;
msgBox.setWindowTitle(QObject::tr("Error retrieving rendering device"));
msgBox.setIcon(QMessageBox::Critical);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setText(QObject::tr("<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);
//setupDialog();
// Set the maximum res we can set in windowed mode
QRect res = getMaximumResolution();
spinBox_x->setMaximum(res.width());
spinBox_y->setMaximum(res.height());
//connect (mPageListWidget,
//SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
@ -36,6 +180,7 @@ CSVSettings::SettingsDialog::SettingsDialog(QMainWindow *parent)
//SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*)));
}
// FIXME: don't need this one, as we don't use pages
void CSVSettings::SettingsDialog::slotChangePage
(QListWidgetItem *cur, QListWidgetItem *prev)
{
@ -46,6 +191,7 @@ void CSVSettings::SettingsDialog::slotChangePage
setFixedSize(minimumSizeHint());
}
// FIXME: don't need this one since we use setupUi
void CSVSettings::SettingsDialog::setupDialog()
{
//create central widget with it's layout and immediate children
@ -62,8 +208,8 @@ void CSVSettings::SettingsDialog::setupDialog()
void CSVSettings::SettingsDialog::buildPages()
{
SettingWindow::createPages ();
#if 0
SettingWindow::createPages ();
QFontMetrics fm (QApplication::font());
@ -117,10 +263,62 @@ void CSVSettings::SettingsDialog::show()
//buildPages();
//setViewValues();
}
//if(
QPoint screenCenter = QApplication::desktop()->screenGeometry().center();
if(CSMSettings::UserSettings::instance().settingValue("Video/use settings.cfg").toStdString() == "true")
{
label_RenderingSubsystem->setEnabled(false);
comboBox_rendersystem->setEnabled(false);
label_Antialiasing->setEnabled(false);
comboBox_antialiasing->setEnabled(false);
checkBox_vsync->setEnabled(false);
label_ShaderLanguage->setEnabled(false);
comboBox_shaderlanguage->setEnabled(false);
}
else
checkBox_override->setChecked(false);
move (screenCenter - geometry().center());
if(CSMSettings::UserSettings::instance().settingValue("Video/fullscreen").toStdString() == "true")
{
checkBox_fullscreen->setChecked(true);
label_Resolution->setEnabled(false);
radioButton_standard_res->setEnabled(false);
radioButton_custom_res->setEnabled(false);
comboBox_std_window_size->setEnabled(false);
spinBox_x->setEnabled(false);
spinBox_y->setEnabled(false);
}
else
{
checkBox_fullscreen->setChecked(false);
}
// update display resolution combo box
// FIXME: update opencs window size
comboBox_std_window_size->clear();
comboBox_std_window_size->addItems(getAvailableResolutions());
int index = comboBox_std_window_size->findData(getCurrentResolution(),
Qt::DisplayRole,
Qt::MatchStartsWith);
if(index != -1)
comboBox_std_window_size->setCurrentIndex(index);
// place the widget and make it visible
QWidget *currView = QApplication::activeWindow();
if(currView)
{
// place at the center of the window with focus
QSize size = currView->size();
move(currView->geometry().x()+(size.width() - frameGeometry().width())/2,
currView->geometry().y()+(size.height() - frameGeometry().height())/2);
}
else
{
// something's gone wrong, place at the center of the screen
QPoint screenCenter = QApplication::desktop()->screenGeometry().center();
move(screenCenter - QPoint(frameGeometry().width()/2,
frameGeometry().height()/2));
}
QWidget::show();
}

@ -1,7 +1,7 @@
#ifndef CSVSETTINGS_SETTINGSDIALOG_H
#define CSVSETTINGS_SETTINGSDIALOG_H
#include "settingwindow.hpp"
//#include "settingwindow.hpp"
//#include "resizeablestackedwidget.hpp"
#include <QStandardItem>
@ -11,11 +11,17 @@
//class QListWidget;
class QListWidgetItem;
#if 0
namespace Ui {
class TabWidget;
}
#endif
namespace CSVSettings {
//class Page;
class SettingsDialog : public SettingWindow, private Ui::TabWidget
class SettingsDialog : public QTabWidget, private Ui::TabWidget
{
Q_OBJECT
@ -25,7 +31,7 @@ namespace CSVSettings {
public:
/*explicit*/ SettingsDialog (QMainWindow *parent = 0);
/*explicit*/ SettingsDialog (QTabWidget *parent = 0);
///Enables setting debug mode. When the dialog opens, a page is created
///which displays the SettingModel's contents in a Tree view.

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

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

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

Loading…
Cancel
Save