Skip to content

Commit

Permalink
Added workaround for QTBUG-119198 (Disabled menu item indistinguishable
Browse files Browse the repository at this point in the history
from enabled one)
  • Loading branch information
enz committed Apr 25, 2024
1 parent 106fe24 commit 3f6b6ff
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 53 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Version 25.0-dev (master)
in current position after program startup.
* Don't support magic MIME type detection on Unix anymore, which was
not reliable anyway and not working if installed via Flatpak.
* Added workaround for QTBUG-119198 (Disabled menu item indistinguishable
from enabled one)
* Compile QML sources into executable, which avoids problems of
QML cache sometimes not being updated if installed via Flatpak.

Expand Down
4 changes: 2 additions & 2 deletions pentobi/BoardContextMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ PentobiMenu {
qsTr("Move Annotation (%1)").arg(annotation)
}

MenuItem {
PentobiMenuItem {
enabled: moveNumber !== gameModel.moveNumber && ! isRated
text: qsTr("Go to Move %1").arg(moveNumber)
onTriggered: gameModel.gotoMove(moveNumber)
}
MenuItem {
PentobiMenuItem {
id: itemAnnotation

onTriggered: {
Expand Down
1 change: 1 addition & 0 deletions pentobi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ qt_add_qml_module(pentobi
PentobiDialog.qml
PentobiDialogButtonBox.qml
PentobiMenu.qml
PentobiMenuItem.qml
PentobiToolBar.qml
PieceBase.qml
PieceCallisto.qml
Expand Down
5 changes: 5 additions & 0 deletions pentobi/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ ApplicationWindow {
|| analyzeGameModel.isRunning
property bool showToolBar: true

// Enable workaround for QTBUG-119198 (Disabled menu item indistinguishable
// from enabled one)
property bool workaroundQtBug119198:
palette.buttonText == palette.disabled.buttonText

minimumWidth: isDesktop ? 481 : 240
minimumHeight: isDesktop ? 303 : 301
color: theme.colorBackground
Expand Down
8 changes: 4 additions & 4 deletions pentobi/MenuComputer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import QtQuick.Controls
PentobiMenu {
title: qsTr("Computer")

MenuItem {
PentobiMenuItem {
action: actionComputerSettings
}
MenuItem {
PentobiMenuItem {
action: actionPlay
}
MenuItem {
PentobiMenuItem {
action: actionPlaySingle
}
MenuItem {
PentobiMenuItem {
action: actionStop
}
}
22 changes: 11 additions & 11 deletions pentobi/MenuEdit.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "Main.js" as Logic
PentobiMenu {
title: qsTr("Edit")

MenuItem {
PentobiMenuItem {
text: qsTr("Annotation…")
enabled: gameModel.moveNumber > 0
onTriggered: {
Expand All @@ -20,54 +20,54 @@ PentobiMenu {
}
}
MenuSeparator { }
MenuItem {
PentobiMenuItem {
text: qsTr("Make Main Variation")
enabled: ! gameModel.isMainVar && ! isRated
onTriggered: {
gameModel.makeMainVar()
Logic.showTemporaryMessage(qsTr("Made main variation"))
}
}
MenuItem {
PentobiMenuItem {
//: Short for Move Variation Up
text: qsTr("Variation Up")
enabled: gameModel.hasPrevVar && ! isRated
onTriggered: Logic.moveUpVar()
}
MenuItem {
PentobiMenuItem {
//: Short for Move Variation Down
text: qsTr("Variation Down")
enabled: gameModel.hasNextVar && ! isRated
onTriggered: Logic.moveDownVar()
}
MenuItem {
PentobiMenuItem {
text: qsTr("Delete Variations")
enabled: gameModel.hasVariations && ! isRated
onTriggered: Logic.deleteAllVar()
}
MenuSeparator { }
MenuItem {
PentobiMenuItem {
text: qsTr("Truncate")
enabled: gameModel.canGoBackward && ! isRated
onTriggered: Logic.truncate()
}
MenuItem {
PentobiMenuItem {
text: qsTr("Truncate Children")
enabled: gameModel.canGoForward && ! isRated
onTriggered: Logic.truncateChildren()
}
MenuItem {
PentobiMenuItem {
text: qsTr("Keep Position")
enabled: ! gameModel.isBoardEmpty && (gameModel.canGoBackward || gameModel.canGoForward) && ! isRated
onTriggered: Logic.keepOnlyPosition()
}
MenuItem {
PentobiMenuItem {
text: qsTr("Keep Subtree")
enabled: gameModel.canGoBackward && gameModel.canGoForward && ! isRated
onTriggered: Logic.keepOnlySubtree()
}
MenuSeparator { }
MenuItem {
PentobiMenuItem {
text: qsTr("Setup Mode")
checkable: true
enabled: ! gameModel.canGoBackward && ! gameModel.canGoForward
Expand All @@ -83,7 +83,7 @@ PentobiMenu {
}
}
}
MenuItem {
PentobiMenuItem {
text: qsTr("Next Color")
enabled: ! isRated
onTriggered: {
Expand Down
22 changes: 11 additions & 11 deletions pentobi/MenuGame.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,45 @@ import "Main.js" as Logic
PentobiMenu {
title: qsTr("Game")

MenuItem {
PentobiMenuItem {
action: actionNew
}
MenuItem {
PentobiMenuItem {
action: actionNewRated
}
MenuSeparator { }
Action {
PentobiMenuItem {
text: qsTr("Game Variant…")
onTriggered: gameVariantDialog.open()
}
MenuItem {
PentobiMenuItem {
action: actionGameInfo
}
MenuSeparator { }
MenuItem {
PentobiMenuItem {
action: actionUndo
}
MenuItem {
PentobiMenuItem {
action: actionFindMove
}
MenuSeparator { }
MenuItem {
PentobiMenuItem {
action: actionOpen
}
MenuRecentFiles { }
MenuItem {
PentobiMenuItem {
action: actionSave
enabled: actionSave.enabled && gameModel.file !== ""
}
MenuItem {
PentobiMenuItem {
action: actionSaveAs
}
Action {
PentobiMenuItem {
text: qsTr("Export Image…")
onTriggered: exportImageDialog.open()
}
MenuSeparator { }
MenuItem {
PentobiMenuItem {
action: actionQuit
}
}
8 changes: 4 additions & 4 deletions pentobi/MenuGo.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ import QtQuick.Controls
PentobiMenu {
title: qsTr("Go")

MenuItem {
PentobiMenuItem {
action: actionGotoMove
}
MenuItem {
PentobiMenuItem {
action: actionBackToMainVar
}
MenuItem {
PentobiMenuItem {
action: actionBeginningOfBranch
}
MenuSeparator { }
MenuItem {
PentobiMenuItem {
action: actionNextComment
}
}
4 changes: 2 additions & 2 deletions pentobi/MenuHelp.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import QtQuick.Controls
PentobiMenu {
title: qsTr("Help")

MenuItem {
PentobiMenuItem {
action: actionHelp
}
Action {
PentobiMenuItem {
text: qsTr("About Pentobi")
onTriggered: aboutDialog.open()
}
Expand Down
20 changes: 10 additions & 10 deletions pentobi/MenuRecentFiles.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,63 +29,63 @@ PentobiMenu {
}

// Instantiator in Menu doesn't work reliably with Qt 5.11 or 5.12.0 alpha
MenuItem {
PentobiMenuItem {
visible: recentFiles.entries.length > 0
// Invisible menu item still use space in Qt 5.11
height: visible ? implicitHeight : 0
text: getText(recentFiles.entries, 0)
onTriggered: openFile(0)
}
MenuItem {
PentobiMenuItem {
visible: recentFiles.entries.length > 1
height: visible ? implicitHeight : 0
text: getText(recentFiles.entries, 1)
onTriggered: openFile(1)
}
MenuItem {
PentobiMenuItem {
visible: recentFiles.entries.length > 2
height: visible ? implicitHeight : 0
text: getText(recentFiles.entries, 2)
onTriggered: openFile(2)
}
MenuItem {
PentobiMenuItem {
visible: recentFiles.entries.length > 3
height: visible ? implicitHeight : 0
text: getText(recentFiles.entries, 3)
onTriggered: openFile(3)
}
MenuItem {
PentobiMenuItem {
visible: recentFiles.entries.length > 4
height: visible ? implicitHeight : 0
text: getText(recentFiles.entries, 4)
onTriggered: openFile(4)
}
MenuItem {
PentobiMenuItem {
visible: recentFiles.entries.length > 5
height: visible ? implicitHeight : 0
text: getText(recentFiles.entries, 5)
onTriggered: openFile(5)
}
MenuItem {
PentobiMenuItem {
visible: recentFiles.entries.length > 6
height: visible ? implicitHeight : 0
text: getText(recentFiles.entries, 6)
onTriggered: openFile(6)
}
MenuItem {
PentobiMenuItem {
visible: recentFiles.entries.length > 7
height: visible ? implicitHeight : 0
text: getText(recentFiles.entries, 7)
onTriggered: openFile(7)
}
MenuItem {
PentobiMenuItem {
visible: recentFiles.entries.length > 8
height: visible ? implicitHeight : 0
text: getText(recentFiles.entries, 8)
onTriggered: openFile(8)
}
MenuSeparator { }
Action {
PentobiMenuItem {
//: Menu item for clearing the recent files list
text: qsTr("Clear List")
// recentFiles.clear() must be called after menu is closed because it
Expand Down
8 changes: 4 additions & 4 deletions pentobi/MenuTools.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ import "Main.js" as Logic
PentobiMenu {
title: qsTr("Tools")

MenuItem {
PentobiMenuItem {
text: qsTr("Rating")
onTriggered: Logic.rating()
}
Action {
PentobiMenuItem {
enabled: ! isRated && ratingModel.numberGames > 0
text: qsTr("Clear Rating")
onTriggered: Logic.clearRating()
}
MenuSeparator { }
Action {
PentobiMenuItem {
enabled: ! isRated && (gameModel.canGoBackward || gameModel.canGoForward)
text: qsTr("Analyze Game…")
onTriggered: analyzeDialog.open()
}
Action {
PentobiMenuItem {
enabled: analyzeGameModel.elements.length !== 0
text: qsTr("Clear Analysis")
onTriggered: {
Expand Down
8 changes: 4 additions & 4 deletions pentobi/MenuView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import QtQuick.Window
PentobiMenu {
title: qsTr("View")

Action {
PentobiMenuItem {
text: qsTr("Appearance")
onTriggered: appearanceDialog.open()
}
MenuItem {
PentobiMenuItem {
visible: isDesktop
// Invisible menu item still use space in Qt 5.11
height: visible ? implicitHeight : 0
Expand All @@ -23,10 +23,10 @@ PentobiMenu {
checked: rootWindow.showToolBar
onTriggered: rootWindow.showToolBar = checked
}
MenuItem {
PentobiMenuItem {
action: actionComment
}
MenuItem {
PentobiMenuItem {
action: actionFullscreen
}
}
14 changes: 14 additions & 0 deletions pentobi/PentobiMenuItem.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//-----------------------------------------------------------------------------
/** @file pentobi/PentobiMenuItem.qml
@author Markus Enzenberger
@copyright GNU General Public License version 3 or later */
//-----------------------------------------------------------------------------

import QtQuick
import QtQuick.Controls

MenuItem {
// Add extra transparency as a workaround for QTBUG-119198 (Disabled menu
// item indistinguishable from enabled one).
opacity: workaroundQtBug119198 && ! enabled ? 0.65 : 1
}
2 changes: 1 addition & 1 deletion pentobi/RatingDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ PentobiDialog {

relativeWidth: 14

MenuItem {
PentobiMenuItem {
text: qsTr("Open Game %1").arg(
ratingModel.getGameNumber(menu.row - 1))
onTriggered: {
Expand Down

0 comments on commit 3f6b6ff

Please sign in to comment.