qt: Add Fix Window Size option menu item
This commit is contained in:
parent
0eaf8d5134
commit
11449d0a0f
|
@ -286,6 +286,7 @@
|
|||
</property>
|
||||
<addaction name="actionSetting_O"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionFixWindowSize"/>
|
||||
<addaction name="actionToolBar_T"/>
|
||||
<addaction name="actionDockBar_D"/>
|
||||
<addaction name="actionMusic_M"/>
|
||||
|
@ -1102,6 +1103,17 @@
|
|||
<string>Options...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFixWindowSize">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fix Window Size</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionToolBar_T">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
|
|
|
@ -130,6 +130,7 @@ void Game::loadSettings()
|
|||
|
||||
setEngineBlack(empty? false : settings->value("Options/blackIsAiPlayer").toBool());
|
||||
setEngineWhite(empty ? true : settings->value("Options/whiteIsAiPlayer").toBool());
|
||||
setFixWindowSize(empty ? false : settings->value("Options/FixWindowSize").toBool());
|
||||
setSound(empty ? true : settings->value("Options/Sound").toBool());
|
||||
setAnimation(empty ? true : settings->value("Options/Animation").toBool());
|
||||
setShuffling(empty ? true : settings->value("Options/Shuffling").toBool());
|
||||
|
@ -438,6 +439,12 @@ void Game::getAiDepthTime(int &time1, int &time2)
|
|||
time2 = aiThread[WHITE]->getTimeLimit();
|
||||
}
|
||||
|
||||
void Game::setFixWindowSize(bool arg) noexcept
|
||||
{
|
||||
fixWindowSize = arg;
|
||||
settings->setValue("Options/FixWindowSize", arg);
|
||||
}
|
||||
|
||||
void Game::setAnimation(bool arg) noexcept
|
||||
{
|
||||
hasAnimation = arg;
|
||||
|
|
|
@ -220,6 +220,9 @@ public slots:
|
|||
void setEngine(Color color, bool enabled = true);
|
||||
void setEngineBlack(bool enabled);
|
||||
void setEngineWhite(bool enabled);
|
||||
|
||||
// Fix Window Size
|
||||
void setFixWindowSize(bool arg) noexcept;
|
||||
|
||||
// Is there a falling animation
|
||||
void setAnimation(bool arg = true) noexcept;
|
||||
|
@ -421,6 +424,11 @@ public:
|
|||
|
||||
void loadSettings();
|
||||
|
||||
bool fixWindowSizeEnabled()
|
||||
{
|
||||
return fixWindowSize;
|
||||
}
|
||||
|
||||
bool soundEnabled()
|
||||
{
|
||||
return hasSound;
|
||||
|
@ -441,6 +449,9 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
// Fix Windows Size
|
||||
bool fixWindowSize;
|
||||
|
||||
// Is there a falling animation
|
||||
bool hasAnimation;
|
||||
|
||||
|
|
|
@ -98,11 +98,6 @@ MillGameWindow::MillGameWindow(QWidget * parent) :
|
|||
const int unith = (deskTopRect.height() - height()) / 2;
|
||||
this->move(unitw, unith);
|
||||
|
||||
#if defined(_DEBUG) || defined(QT_UI_TEST_MODE)
|
||||
this->setFixedWidth(width());
|
||||
this->setFixedHeight(height());
|
||||
#endif
|
||||
|
||||
#ifdef MOBILE_APP_UI
|
||||
// Hide menu bar, toolbar, status bar, etc
|
||||
ui.menuBar->setVisible(false);
|
||||
|
@ -201,6 +196,9 @@ void MillGameWindow::initialize()
|
|||
connect(ui.actionEngine2_R, SIGNAL(toggled(bool)),
|
||||
game, SLOT(setEngineWhite(bool)));
|
||||
|
||||
connect(ui.actionFixWindowSize, SIGNAL(toggled(bool)),
|
||||
game, SLOT(setFixWindowSize(bool)));
|
||||
|
||||
connect(ui.actionSound_S, SIGNAL(toggled(bool)),
|
||||
game, SLOT(setSound(bool)));
|
||||
|
||||
|
@ -347,8 +345,15 @@ void MillGameWindow::initialize()
|
|||
const int screen_iPhone_SE[] = {640, 1136};
|
||||
this->resize(QSize(screen_iPhone_SE[0], screen_iPhone_SE[1]));
|
||||
#else /* MOBILE_APP_UI */
|
||||
const int h = QApplication::desktop()->height();
|
||||
this->resize(QSize(h * 3/4, h * 3/4));
|
||||
|
||||
// Fix window size
|
||||
if (game->fixWindowSizeEnabled()) {
|
||||
setFixedWidth(width());
|
||||
setFixedHeight(height());
|
||||
} else {
|
||||
const int h = QApplication::desktop()->height();
|
||||
this->resize(QSize(h * 3 / 4, h * 3 / 4));
|
||||
}
|
||||
|
||||
ui.pushButton_back->setVisible(false);
|
||||
ui.pushButton_option->setVisible(false);
|
||||
|
@ -374,6 +379,7 @@ void MillGameWindow::initialize()
|
|||
ui.actionEngine1_T->setChecked(game->isAiPlayer[BLACK]);
|
||||
ui.actionEngine2_R->setChecked(game->isAiPlayer[WHITE]);
|
||||
|
||||
ui.actionFixWindowSize->setChecked(game->fixWindowSizeEnabled());
|
||||
ui.actionSound_S->setChecked(game->soundEnabled());
|
||||
ui.actionAnimation_A->setChecked(game->animationEnabled());
|
||||
|
||||
|
|
Loading…
Reference in New Issue