Skip to content

Commit

Permalink
more window fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Odizinne committed Feb 22, 2025
1 parent 35155fe commit ea1401f
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 54 deletions.
10 changes: 2 additions & 8 deletions qml/GameState.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ QtObject {
property int flaggedCount: 0
property int firstClickIndex: -1
property bool gameStarted: false
property int gridSizeX: 8
property int gridSizeY: 8
property int gridSizeX: 9
property int gridSizeY: 9
property int mineCount: 10
property var mines: []
property var numbers: []
Expand Down Expand Up @@ -50,12 +50,6 @@ QtObject {
if (SteamIntegration.initialized && Retr0MineSettings.flagSkinIndex === 3) return "qrc:/icons/flag3.png"
else return "qrc:/icons/flag.png"
}
signal gridSizeChanged()
signal cellSizeUpdated()

onGridSizeXChanged: gridSizeChanged()
onGridSizeYChanged: gridSizeChanged()
onCellSizeChanged: cellSizeUpdated()

function getDifficultyLevel() {
if (GameState.gridSizeX === 9 && GameState.gridSizeY === 9 && GameState.mineCount === 10) {
Expand Down
69 changes: 41 additions & 28 deletions qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,32 @@ ApplicationWindow {
}
}

Connections {
target: GameState
function onGridSizeXChanged() {
if (root.visibility === ApplicationWindow.Windowed) {
root.minimumWidth = root.getInitialWidth()
root.width = root.minimumWidth
}
}

function onGridSizeYChanged() {
if (root.visibility === ApplicationWindow.Windowed) {
root.minimumHeight = root.getInitialHeight()
root.height = root.minimumHeight
}
}
}

onVisibilityChanged: function(visibility) {
if (visibility === Window.Windowed) {
// First update minimum constraints
minimumWidth = getInitialWidth()
minimumHeight = getInitialHeight()

// Then set the actual size
width = minimumWidth
height = minimumHeight

// Center window if it would be too large
if (height >= Screen.desktopAvailableHeight * 0.9 ||
width >= Screen.desktopAvailableWidth * 0.9) {
width >= Screen.desktopAvailableWidth * 0.9) {
x = Screen.width / 2 - width / 2
y = Screen.height / 2 - height / 2
}
Expand Down Expand Up @@ -149,22 +162,22 @@ ApplicationWindow {
id: numberFont
source: switch (Retr0MineSettings.fontIndex) {
case 0:
"qrc:/fonts/FiraSans-SemiBold.ttf"
break
"qrc:/fonts/FiraSans-SemiBold.ttf"
break
case 1:
"qrc:/fonts/NotoSerif-Regular.ttf"
break
"qrc:/fonts/NotoSerif-Regular.ttf"
break
case 2:
"qrc:/fonts/SpaceMono-Regular.ttf"
break
"qrc:/fonts/SpaceMono-Regular.ttf"
break
case 3:
"qrc:/fonts/Orbitron-Regular.ttf"
break
"qrc:/fonts/Orbitron-Regular.ttf"
break
case 4:
"qrc:/fonts/PixelifySans-Regular.ttf"
break
"qrc:/fonts/PixelifySans-Regular.ttf"
break
default:
"qrc:/fonts/FiraSans-Bold.ttf"
"qrc:/fonts/FiraSans-Bold.ttf"
}
}

Expand Down Expand Up @@ -241,7 +254,7 @@ ApplicationWindow {
visible: policy === ScrollBar.AlwaysOn && !MainWindow.isFluent
active: !MainWindow.isFluent
policy: (GameState.cellSize + GameState.cellSpacing) * GameState.gridSizeY > gameArea.height ?
ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
}

ScrollBar {
Expand All @@ -254,7 +267,7 @@ ApplicationWindow {
visible: policy === ScrollBar.AlwaysOn && !MainWindow.isFluent
active: !MainWindow.isFluent
policy: (GameState.cellSize + GameState.cellSpacing) * GameState.gridSizeX > gameArea.width ?
ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
}

TempScrollBar {
Expand All @@ -267,7 +280,7 @@ ApplicationWindow {
visible: policy === ScrollBar.AlwaysOn && MainWindow.isFluent
active: MainWindow.isFluent
policy: (GameState.cellSize + GameState.cellSpacing) * GameState.gridSizeY > gameArea.height ?
ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
}

TempScrollBar {
Expand All @@ -280,7 +293,7 @@ ApplicationWindow {
visible: policy === ScrollBar.AlwaysOn && MainWindow.isFluent
active: MainWindow.isFluent
policy: (GameState.cellSize + GameState.cellSpacing) * GameState.gridSizeX > gameArea.width ?
ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
}

ScrollBar.vertical: MainWindow.isFluent ? fluentVerticalScrollBar : defaultVerticalScrollBar
Expand Down Expand Up @@ -350,18 +363,18 @@ ApplicationWindow {

function getInitialWidth() {
if (root.visibility === ApplicationWindow.Windowed) {
// Always calculate the proper width based on grid size
return Math.min((GameState.cellSize + GameState.cellSpacing) * GameState.gridSizeX + 24,
Screen.desktopAvailableWidth * 0.9)
}
// Always calculate the proper width based on grid size
return Math.min((GameState.cellSize + GameState.cellSpacing) * GameState.gridSizeX + 24,
Screen.desktopAvailableWidth * 0.9)
}
}

function getInitialHeight() {
if (root.visibility === ApplicationWindow.Windowed) {
// Always calculate the proper height based on grid size
return Math.min((GameState.cellSize + GameState.cellSpacing) * GameState.gridSizeY + 74,
Screen.desktopAvailableHeight * 0.9)
}
// Always calculate the proper height based on grid size
return Math.min((GameState.cellSize + GameState.cellSpacing) * GameState.gridSizeY + 74,
Screen.desktopAvailableHeight * 0.9)
}
}
}

18 changes: 9 additions & 9 deletions translations/retr0mine_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
</message>
<message>
<location filename="../qml/SettingsPage.qml" line="147"/>
<location filename="../qml/SettingsPage.qml" line="958"/>
<location filename="../qml/SettingsPage.qml" line="962"/>
<source>Language</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -327,23 +327,23 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/SettingsPage.qml" line="999"/>
<location filename="../qml/SettingsPage.qml" line="1003"/>
<source>Application will restart on change
Current game will be saved and restored</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/SettingsPage.qml" line="1021"/>
<location filename="../qml/SettingsPage.qml" line="1025"/>
<source>Color scheme</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/SettingsPage.qml" line="1027"/>
<location filename="../qml/SettingsPage.qml" line="1031"/>
<source>Dark</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/SettingsPage.qml" line="1027"/>
<location filename="../qml/SettingsPage.qml" line="1031"/>
<source>Light</source>
<translation type="unfinished"></translation>
</message>
Expand All @@ -363,7 +363,7 @@ Current game will be saved and restored</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/SettingsPage.qml" line="927"/>
<location filename="../qml/SettingsPage.qml" line="931"/>
<source>High contrast flags</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -393,13 +393,13 @@ Current game will be saved and restored</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/SettingsPage.qml" line="994"/>
<location filename="../qml/SettingsPage.qml" line="998"/>
<source>Style</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/SettingsPage.qml" line="964"/>
<location filename="../qml/SettingsPage.qml" line="1027"/>
<location filename="../qml/SettingsPage.qml" line="968"/>
<location filename="../qml/SettingsPage.qml" line="1031"/>
<source>System</source>
<translation type="unfinished"></translation>
</message>
Expand Down
18 changes: 9 additions & 9 deletions translations/retr0mine_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@
</message>
<message>
<location filename="../qml/SettingsPage.qml" line="147"/>
<location filename="../qml/SettingsPage.qml" line="958"/>
<location filename="../qml/SettingsPage.qml" line="962"/>
<source>Language</source>
<translation>Langue</translation>
</message>
Expand Down Expand Up @@ -384,24 +384,24 @@ Désactivé: Génère des grilles plus prévisibles</translation>
<translation type="vanished">Chiffres uniquement</translation>
</message>
<message>
<location filename="../qml/SettingsPage.qml" line="999"/>
<location filename="../qml/SettingsPage.qml" line="1003"/>
<source>Application will restart on change
Current game will be saved and restored</source>
<translation>L&apos;application redémarrera après le changement
La partie en cours sera sauvegardée et restaurée</translation>
</message>
<message>
<location filename="../qml/SettingsPage.qml" line="1021"/>
<location filename="../qml/SettingsPage.qml" line="1025"/>
<source>Color scheme</source>
<translation>Thème</translation>
</message>
<message>
<location filename="../qml/SettingsPage.qml" line="1027"/>
<location filename="../qml/SettingsPage.qml" line="1031"/>
<source>Dark</source>
<translation>Sombre</translation>
</message>
<message>
<location filename="../qml/SettingsPage.qml" line="1027"/>
<location filename="../qml/SettingsPage.qml" line="1031"/>
<source>Light</source>
<translation>Clair</translation>
</message>
Expand All @@ -421,7 +421,7 @@ La partie en cours sera sauvegardée et restaurée</translation>
<translation>Atténuer les cellules résolues</translation>
</message>
<message>
<location filename="../qml/SettingsPage.qml" line="927"/>
<location filename="../qml/SettingsPage.qml" line="931"/>
<source>High contrast flags</source>
<translation>Drapeaux contrastés</translation>
</message>
Expand Down Expand Up @@ -451,13 +451,13 @@ La partie en cours sera sauvegardée et restaurée</translation>
<translation>Très grand</translation>
</message>
<message>
<location filename="../qml/SettingsPage.qml" line="994"/>
<location filename="../qml/SettingsPage.qml" line="998"/>
<source>Style</source>
<translation>Style</translation>
</message>
<message>
<location filename="../qml/SettingsPage.qml" line="964"/>
<location filename="../qml/SettingsPage.qml" line="1027"/>
<location filename="../qml/SettingsPage.qml" line="968"/>
<location filename="../qml/SettingsPage.qml" line="1031"/>
<source>System</source>
<translation>Système</translation>
</message>
Expand Down

0 comments on commit ea1401f

Please sign in to comment.