From ba5a27d1542e0dbd922e04044de6dc59523a45bd Mon Sep 17 00:00:00 2001 From: Floris Bos Date: Thu, 20 Jan 2022 17:23:47 +0100 Subject: [PATCH] Change advanced settings button - Change image to button - Add option to randomize OS list entries --- icons/ic_cog_40px.svg | 1 - icons/ic_cog_red.svg | 13 +++++++++++ main.qml | 51 ++++++++++++++++++++++++++++++++++--------- qml.qrc | 1 + 4 files changed, 55 insertions(+), 11 deletions(-) delete mode 100644 icons/ic_cog_40px.svg create mode 100644 icons/ic_cog_red.svg diff --git a/icons/ic_cog_40px.svg b/icons/ic_cog_40px.svg deleted file mode 100644 index c8c447b..0000000 --- a/icons/ic_cog_40px.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/icons/ic_cog_red.svg b/icons/ic_cog_red.svg new file mode 100644 index 0000000..6b868f6 --- /dev/null +++ b/icons/ic_cog_red.svg @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/main.qml b/main.qml index 490c9a2..73ed314 100644 --- a/main.qml +++ b/main.qml @@ -255,16 +255,22 @@ ApplicationWindow { font.family: roboto.name Accessible.onPressAction: clicked() } - Image { - id: customizebutton - source: "icons/ic_cog_40px.svg" - visible: false - MouseArea { - anchors.fill: parent - onClicked: { - optionspopup.openPopup() - } + Button { + Layout.bottomMargin: 25 + padding: 5 + id: customizebutton + onClicked: { + optionspopup.openPopup() + } + Material.background: "#ffffff" + visible: false + Accessible.description: qsTr("Select this button to access advanced settings") + Accessible.onPressAction: clicked() + + contentItem: Image { + source: "icons/ic_cog_red.svg" + fillMode: Image.PreserveAspectFit } } } @@ -1051,6 +1057,29 @@ ApplicationWindow { progressText.text = qsTr("Finalizing...") } + function shuffle(arr) { + for (var i = 0; i < arr.length - 1; i++) { + var j = i + Math.floor(Math.random() * (arr.length - i)); + + var t = arr[j]; + arr[j] = arr[i]; + arr[i] = t; + } + } + + function checkForRandom(list) { + for (var i in list) { + var entry = list[i] + + if ("subitems" in entry) { + checkForRandom(entry["subitems"]) + if ("random" in entry && entry["random"]) { + shuffle(entry["subitems"]) + } + } + } + } + function oslistFromJson(o) { var lang_country = Qt.locale().name if ("os_list_"+lang_country in o) { @@ -1068,7 +1097,9 @@ ApplicationWindow { return false } - return o["os_list"] + var oslist = o["os_list"] + checkForRandom(oslist) + return oslist } function selectNamedOS(name, collection) diff --git a/qml.qrc b/qml.qrc index 89364b9..76390f7 100644 --- a/qml.qrc +++ b/qml.qrc @@ -30,5 +30,6 @@ icons/ic_info_12px.png icons/ic_cog_40px.svg keymap-layouts.txt + icons/ic_cog_red.svg