Got window size to work correctly. Started to incorporate parts of previous settings implementation where possible.

deque
cc9cii 10 years ago
parent cb15750e40
commit 9dc4af69c6

@ -99,6 +99,9 @@ opencs_units_noqt (view/tools
opencs_units (view/settings
settingsdialog
settingwindow
dialog
page
view
booleanview
textview

@ -28,7 +28,7 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit)
setupDataFiles (config.first);
CSMSettings::UserSettings::instance().loadSettings ("opencs.ini");
//mSettings.setModel (CSMSettings::UserSettings::instance());
mSettings.setModel (CSMSettings::UserSettings::instance());
ogreInit.init ((mCfgMgr.getUserConfigPath() / "opencsOgre.log").string());

@ -8,6 +8,7 @@
#include <QMdiArea>
#include <QDockWidget>
#include <QtGui/QApplication>
#include <QDesktopWidget>
#include "../../model/doc/document.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
("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);

@ -39,7 +39,7 @@ QRect getMaximumResolution()
return max;
}
QString getCurrentResolution()
QString getCurrentOgreResolution()
{
Ogre::ConfigOptionMap& renderOpt =
Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions();
@ -152,7 +152,7 @@ QStringList getAvailableOptions(const QString &key)
}
CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent)
: /*mDebugMode (false),*/ QTabWidget (parent)
: QTabWidget (parent)
{
setObjectName("User Settings");
@ -163,7 +163,7 @@ CSVSettings::SettingsDialog::SettingsDialog(QTabWidget *parent)
spinBox_x->setMaximum(res.width());
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)));
}
@ -195,7 +195,7 @@ void CSVSettings::SettingsDialog::setViewValues()
//rendererChanged(Ogre::Root::getSingleton().getRenderSystemByName(renderer.toStdString()));
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);
comboBox_rendersystem->setEnabled(false);
@ -209,29 +209,105 @@ void CSVSettings::SettingsDialog::setViewValues()
else
checkBox_override->setChecked(false);
if(CSMSettings::UserSettings::instance().settingValue("Window Size/Width") != "")
{
spinBox_x->setValue(
CSMSettings::UserSettings::instance().settingValue("Window Size/Width").toInt());
}
if(mModel->settingValue("Window Size/Width") != "")
spinBox_x->setValue(mModel->settingValue("Window Size/Width").toInt());
if(CSMSettings::UserSettings::instance().settingValue("Window Size/Height") != "")
{
spinBox_y->setValue(
CSMSettings::UserSettings::instance().settingValue("Window Size/Height").toInt());
}
if(mModel->settingValue("Window Size/Height") != "")
spinBox_y->setValue(mModel->settingValue("Window Size/Height").toInt());
// 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(),
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::MatchStartsWith);
if(index != -1)
comboBox_std_window_size->setCurrentIndex(index);
radioButton_custom_res->setChecked(true);
slotStandardToggled(false);
}
}
slotStandardToggled(radioButton_standard_res->isChecked() ? true : 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)
@ -239,8 +315,9 @@ void CSVSettings::SettingsDialog::closeEvent (QCloseEvent *event)
//SettingWindow::closeEvent() must be called first to ensure
//model is updated
//SettingWindow::closeEvent (event);
QApplication::focusWidget()->clearFocus();
//saveSettings();
saveSettings();
}
void CSVSettings::SettingsDialog::show()

@ -7,35 +7,47 @@
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);
int windowWidth();
int windowHeight();
///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);
///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);
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 rendererChanged();
void slotStandardToggled(bool checked);
};

Loading…
Cancel
Save