mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 11:23:51 +00:00
Got window size to work correctly. Started to incorporate parts of previous settings implementation where possible.
This commit is contained in:
parent
cb15750e40
commit
9dc4af69c6
5 changed files with 126 additions and 26 deletions
|
@ -99,6 +99,9 @@ opencs_units_noqt (view/tools
|
||||||
|
|
||||||
opencs_units (view/settings
|
opencs_units (view/settings
|
||||||
settingsdialog
|
settingsdialog
|
||||||
|
settingwindow
|
||||||
|
dialog
|
||||||
|
page
|
||||||
view
|
view
|
||||||
booleanview
|
booleanview
|
||||||
textview
|
textview
|
||||||
|
|
|
@ -28,7 +28,7 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit)
|
||||||
setupDataFiles (config.first);
|
setupDataFiles (config.first);
|
||||||
|
|
||||||
CSMSettings::UserSettings::instance().loadSettings ("opencs.ini");
|
CSMSettings::UserSettings::instance().loadSettings ("opencs.ini");
|
||||||
//mSettings.setModel (CSMSettings::UserSettings::instance());
|
mSettings.setModel (CSMSettings::UserSettings::instance());
|
||||||
|
|
||||||
ogreInit.init ((mCfgMgr.getUserConfigPath() / "opencsOgre.log").string());
|
ogreInit.init ((mCfgMgr.getUserConfigPath() / "opencsOgre.log").string());
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <QMdiArea>
|
#include <QMdiArea>
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
#include <QtGui/QApplication>
|
#include <QtGui/QApplication>
|
||||||
|
#include <QDesktopWidget>
|
||||||
|
|
||||||
#include "../../model/doc/document.hpp"
|
#include "../../model/doc/document.hpp"
|
||||||
#include "../../model/settings/usersettings.hpp"
|
#include "../../model/settings/usersettings.hpp"
|
||||||
|
@ -325,7 +326,14 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to
|
||||||
QString height = CSMSettings::UserSettings::instance().settingValue
|
QString height = CSMSettings::UserSettings::instance().settingValue
|
||||||
("Window Size/Height");
|
("Window Size/Height");
|
||||||
|
|
||||||
resize (width.toInt(), height.toInt());
|
// trick to get the window decorations and their sizes
|
||||||
|
show();
|
||||||
|
hide();
|
||||||
|
resize (width.toInt() - (frameGeometry().width() - geometry().width()),
|
||||||
|
height.toInt() - (frameGeometry().height() - geometry().height()));
|
||||||
|
// start at the centre of the screen
|
||||||
|
QPoint screenCenter = QApplication::desktop()->screenGeometry().center();
|
||||||
|
move(screenCenter - QPoint(frameGeometry().width()/2, frameGeometry().height()/2));
|
||||||
|
|
||||||
mSubViewWindow.setDockOptions (QMainWindow::AllowNestedDocks);
|
mSubViewWindow.setDockOptions (QMainWindow::AllowNestedDocks);
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ QRect getMaximumResolution()
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getCurrentResolution()
|
QString getCurrentOgreResolution()
|
||||||
{
|
{
|
||||||
Ogre::ConfigOptionMap& renderOpt =
|
Ogre::ConfigOptionMap& renderOpt =
|
||||||
Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions();
|
Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions();
|
||||||
|
@ -152,7 +152,7 @@ QStringList getAvailableOptions(const QString &key)
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent)
|
CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent)
|
||||||
: /*mDebugMode (false),*/ QTabWidget (parent)
|
: QTabWidget (parent)
|
||||||
{
|
{
|
||||||
setObjectName("User Settings");
|
setObjectName("User Settings");
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent)
|
||||||
spinBox_x->setMaximum(res.width());
|
spinBox_x->setMaximum(res.width());
|
||||||
spinBox_y->setMaximum(res.height());
|
spinBox_y->setMaximum(res.height());
|
||||||
|
|
||||||
connect(comboBox_rendersystem, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged(const QString&)));
|
connect(comboBox_rendersystem, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged()));
|
||||||
connect(radioButton_standard_res, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool)));
|
connect(radioButton_standard_res, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ void CSVSettings::SettingsDialog::setViewValues()
|
||||||
//rendererChanged(Ogre::Root::getSingleton().getRenderSystemByName(renderer.toStdString()));
|
//rendererChanged(Ogre::Root::getSingleton().getRenderSystemByName(renderer.toStdString()));
|
||||||
rendererChanged(); // setup antialiasing options
|
rendererChanged(); // setup antialiasing options
|
||||||
|
|
||||||
if(CSMSettings::UserSettings::instance().settingValue("Video/use settings.cfg") == "true")
|
if(mModel->settingValue("Video/use settings.cfg") == "true")
|
||||||
{
|
{
|
||||||
label_RenderingSubsystem->setEnabled(false);
|
label_RenderingSubsystem->setEnabled(false);
|
||||||
comboBox_rendersystem->setEnabled(false);
|
comboBox_rendersystem->setEnabled(false);
|
||||||
|
@ -209,29 +209,105 @@ void CSVSettings::SettingsDialog::setViewValues()
|
||||||
else
|
else
|
||||||
checkBox_override->setChecked(false);
|
checkBox_override->setChecked(false);
|
||||||
|
|
||||||
if(CSMSettings::UserSettings::instance().settingValue("Window Size/Width") != "")
|
if(mModel->settingValue("Window Size/Width") != "")
|
||||||
{
|
spinBox_x->setValue(mModel->settingValue("Window Size/Width").toInt());
|
||||||
spinBox_x->setValue(
|
|
||||||
CSMSettings::UserSettings::instance().settingValue("Window Size/Width").toInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(CSMSettings::UserSettings::instance().settingValue("Window Size/Height") != "")
|
if(mModel->settingValue("Window Size/Height") != "")
|
||||||
{
|
spinBox_y->setValue(mModel->settingValue("Window Size/Height").toInt());
|
||||||
spinBox_y->setValue(
|
|
||||||
CSMSettings::UserSettings::instance().settingValue("Window Size/Height").toInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
// update display resolution combo box
|
// update display resolution combo box
|
||||||
// FIXME: update opencs window size
|
|
||||||
comboBox_std_window_size->clear();
|
comboBox_std_window_size->clear();
|
||||||
comboBox_std_window_size->addItems(getAvailableResolutions());
|
comboBox_std_window_size->addItems(getAvailableResolutions());
|
||||||
int index = comboBox_std_window_size->findData(getCurrentResolution(),
|
|
||||||
|
QString currRes = mModel->settingValue("Window Size/Width") + " x " +
|
||||||
|
mModel->settingValue("Window Size/Height");
|
||||||
|
|
||||||
|
int index = comboBox_std_window_size->findData(currRes,
|
||||||
|
Qt::DisplayRole,
|
||||||
|
Qt::MatchStartsWith);
|
||||||
|
if(index != -1)
|
||||||
|
{
|
||||||
|
// show the values in ini file
|
||||||
|
comboBox_std_window_size->setCurrentIndex(index);
|
||||||
|
slotStandardToggled(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// show what's in Ogre instead
|
||||||
|
index = comboBox_std_window_size->findData(getCurrentOgreResolution(),
|
||||||
Qt::DisplayRole,
|
Qt::DisplayRole,
|
||||||
Qt::MatchStartsWith);
|
Qt::MatchStartsWith);
|
||||||
if(index != -1)
|
if(index != -1)
|
||||||
comboBox_std_window_size->setCurrentIndex(index);
|
comboBox_std_window_size->setCurrentIndex(index);
|
||||||
|
|
||||||
slotStandardToggled(radioButton_standard_res->isChecked() ? true : false);
|
radioButton_custom_res->setChecked(true);
|
||||||
|
slotStandardToggled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVSettings::SettingsDialog::saveSettings()
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
//setting the definition in the model automatically syncs with the file
|
||||||
|
foreach (const Page *page, mPages)
|
||||||
|
{
|
||||||
|
foreach (const View *view, page->views())
|
||||||
|
{
|
||||||
|
if (!view->serializable())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
mModel->setDefinitions (view->viewKey(), view->selectedValues());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
mModel->saveDefinitions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVSettings::SettingsDialog::createConnections
|
||||||
|
(const QList <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)
|
void CSVSettings::SettingsDialog::closeEvent (QCloseEvent *event)
|
||||||
|
@ -239,8 +315,9 @@ void CSVSettings::SettingsDialog::closeEvent (QCloseEvent *event)
|
||||||
//SettingWindow::closeEvent() must be called first to ensure
|
//SettingWindow::closeEvent() must be called first to ensure
|
||||||
//model is updated
|
//model is updated
|
||||||
//SettingWindow::closeEvent (event);
|
//SettingWindow::closeEvent (event);
|
||||||
|
QApplication::focusWidget()->clearFocus();
|
||||||
|
|
||||||
//saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVSettings::SettingsDialog::show()
|
void CSVSettings::SettingsDialog::show()
|
||||||
|
|
|
@ -7,35 +7,47 @@
|
||||||
|
|
||||||
class QListWidgetItem;
|
class QListWidgetItem;
|
||||||
|
|
||||||
|
namespace CSMSettings
|
||||||
|
{
|
||||||
|
class Setting;
|
||||||
|
class UserSettings;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSVSettings {
|
namespace CSVSettings {
|
||||||
|
|
||||||
class SettingsDialog : public QTabWidget, private Ui::TabWidget
|
class SettingsDialog : public QTabWidget, private Ui::TabWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
CSMSettings::UserSettings *mModel;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SettingsDialog (QTabWidget *parent = 0);
|
SettingsDialog (QTabWidget *parent = 0);
|
||||||
|
|
||||||
int windowWidth();
|
///set the model the view uses (instance of UserSettings)
|
||||||
int windowHeight();
|
void setModel (CSMSettings::UserSettings &model) { mModel = &model; }
|
||||||
|
|
||||||
///Enables setting debug mode. When the dialog opens, a page is created
|
|
||||||
///which displays the SettingModel's contents in a Tree view.
|
|
||||||
//void enableDebugMode (bool state, QStandardItemModel *model = 0);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
///save settings from the GUI to file
|
||||||
|
void saveSettings();
|
||||||
|
|
||||||
/// Settings are written on close
|
/// Settings are written on close
|
||||||
void closeEvent (QCloseEvent *event);
|
void closeEvent (QCloseEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
///sets the defined values for the views that have been created
|
||||||
void setViewValues();
|
void setViewValues();
|
||||||
|
|
||||||
|
///create connections between settings (used for proxy settings)
|
||||||
|
void createConnections (const QList <CSMSettings::Setting *> &list);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void show();
|
void show();
|
||||||
|
|
||||||
void rendererChanged();
|
void rendererChanged();
|
||||||
void slotStandardToggled(bool checked);
|
void slotStandardToggled(bool checked);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue