1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-21 11:39:44 +00:00

use index instead of string manipulation

This commit is contained in:
Sebastian Wick 2013-06-23 21:56:27 +02:00
parent 357974a429
commit 20e591fe18
2 changed files with 8 additions and 14 deletions

View file

@ -43,7 +43,7 @@ GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, GraphicsSettings &g
connect(rendererComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged(const QString&))); connect(rendererComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged(const QString&)));
connect(fullScreenCheckBox, SIGNAL(stateChanged(int)), this, SLOT(slotFullScreenChanged(int))); connect(fullScreenCheckBox, SIGNAL(stateChanged(int)), this, SLOT(slotFullScreenChanged(int)));
connect(standardRadioButton, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool))); connect(standardRadioButton, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool)));
connect(screenComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(screenChanged(const QString&))); connect(screenComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(screenChanged(int)));
} }
@ -168,7 +168,7 @@ bool GraphicsPage::setupSDL()
for (int i = 0; i < displays; i++) for (int i = 0; i < displays; i++)
{ {
screenComboBox->addItem(QString("Screen ") + QString::number(i + 1)); screenComboBox->addItem(QString(tr("Screen ")) + QString::number(i + 1));
} }
return true; return true;
@ -196,9 +196,7 @@ bool GraphicsPage::loadSettings()
QString resolution = width + QString(" x ") + height; QString resolution = width + QString(" x ") + height;
QString screen = mGraphicsSettings.value(QString("Video/screen")); QString screen = mGraphicsSettings.value(QString("Video/screen"));
int screenIndex = screenComboBox->findText(QString("Screen ") + screen); screenComboBox->setCurrentIndex(screen.toInt());
if (screenIndex != -1)
screenComboBox->setCurrentIndex(screenIndex);
int resIndex = resolutionComboBox->findText(resolution, Qt::MatchStartsWith); int resIndex = resolutionComboBox->findText(resolution, Qt::MatchStartsWith);
@ -239,10 +237,7 @@ void GraphicsPage::saveSettings()
mGraphicsSettings.setValue(QString("Video/resolution y"), QString::number(customHeightSpinBox->value())); mGraphicsSettings.setValue(QString("Video/resolution y"), QString::number(customHeightSpinBox->value()));
} }
QRegExp screenRe(QString(".*(\\d+)")); mGraphicsSettings.setValue(QString("Video/screen"), QString::number(screenComboBox->currentIndex()));
if (screenRe.exactMatch(screenComboBox->currentText())) {
mGraphicsSettings.setValue(QString("Video/screen"), screenRe.cap(1));
}
} }
QStringList GraphicsPage::getAvailableOptions(const QString &key, Ogre::RenderSystem *renderer) QStringList GraphicsPage::getAvailableOptions(const QString &key, Ogre::RenderSystem *renderer)
@ -349,12 +344,11 @@ void GraphicsPage::rendererChanged(const QString &renderer)
antiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem)); antiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem));
} }
void GraphicsPage::screenChanged(const QString &screen) void GraphicsPage::screenChanged(int screen)
{ {
QRegExp screenRe(QString(".*(\\d+)")); if (screen >= 0) {
if (screenRe.exactMatch(screen)) {
resolutionComboBox->clear(); resolutionComboBox->clear();
resolutionComboBox->addItems(getAvailableResolutions(screenRe.cap(1).toInt() - 1)); resolutionComboBox->addItems(getAvailableResolutions(screen));
} }
} }

View file

@ -34,7 +34,7 @@ public:
public slots: public slots:
void rendererChanged(const QString &renderer); void rendererChanged(const QString &renderer);
void screenChanged(const QString &screen); void screenChanged(int screen);
private slots: private slots:
void slotFullScreenChanged(int state); void slotFullScreenChanged(int state);