diff --git a/Source/Tools/CMakeLists.txt b/Source/Tools/CMakeLists.txt
index 9346c6ce91..5698af716c 100644
--- a/Source/Tools/CMakeLists.txt
+++ b/Source/Tools/CMakeLists.txt
@@ -4,8 +4,11 @@ if (NOT MINGW_BUILD)
if (BUILD_FEXCONFIG)
add_subdirectory(FEXConfig/)
- find_package(Qt5 COMPONENTS Qml Quick Widgets)
- if (Qt5_FOUND)
+ find_package(Qt6 COMPONENTS Qml Quick Widgets)
+ if (NOT Qt6_FOUND)
+ find_package(Qt5 COMPONENTS Qml Quick Widgets)
+ endif()
+ if (Qt6_FOUND OR Qt5_FOUND)
add_subdirectory(FEXQonfig/)
endif()
endif()
diff --git a/Source/Tools/FEXQonfig/CMakeLists.txt b/Source/Tools/FEXQonfig/CMakeLists.txt
index 9edf345903..c564ce1b89 100644
--- a/Source/Tools/FEXQonfig/CMakeLists.txt
+++ b/Source/Tools/FEXQonfig/CMakeLists.txt
@@ -1,11 +1,17 @@
set(CMAKE_AUTOMOC ON)
-qt_add_resources(QT_RESOURCES qml.qrc)
add_executable(FEXQonfig)
target_sources(FEXQonfig PRIVATE Main.cpp ConfigModel.h ${QT_RESOURCES})
target_include_directories(FEXQonfig PRIVATE ${CMAKE_SOURCE_DIR}/Source/)
target_link_libraries(FEXQonfig PRIVATE Common)
-target_link_libraries(FEXQonfig PRIVATE Qt5::Qml Qt5::Quick Qt5::Widgets)
+if (Qt6_FOUND)
+ qt_add_resources(QT_RESOURCES qml6.qrc)
+ target_link_libraries(FEXQonfig PRIVATE Qt6::Qml Qt6::Quick Qt6::Widgets)
+else()
+ qt_add_resources(QT_RESOURCES qml5.qrc)
+ target_link_libraries(FEXQonfig PRIVATE Qt5::Qml Qt5::Quick Qt5::Widgets)
+endif()
+target_sources(FEXQonfig PRIVATE ${QT_RESOURCES})
if (CMAKE_BUILD_TYPE MATCHES "RELEASE")
target_link_options(FEXQonfig
diff --git a/Source/Tools/FEXQonfig/main.qml b/Source/Tools/FEXQonfig/main.qml
index d79966e02b..44c111222a 100644
--- a/Source/Tools/FEXQonfig/main.qml
+++ b/Source/Tools/FEXQonfig/main.qml
@@ -1,12 +1,15 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
-import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.15
import FEX.ConfigModel 1.0
import FEX.EnvVarModel 1.0
import FEX.RootFSModel 1.0
+// Qt 6 changed the API of the Dialogs module slightly.
+// The differences are abstracted away in this import:
+import "qrc:/dialogs"
+
ApplicationWindow {
id: root
@@ -43,12 +46,10 @@ ApplicationWindow {
id: openFileDialog
title: qsTr("Open FEX configuration")
nameFilters: [ "Config files(*.json)", "All files(*)" ]
- // TODO: Set default folder to ~/.fex-emu?
- folder: "file:///home/tony/.fex-emu/"
onAccepted: {
- root.selectedConfigFile(fileUrl)
- configFilename = fileUrl
+ root.selectedConfigFile(selectedFile)
+ configFilename = selectedFile
}
}
@@ -56,20 +57,24 @@ ApplicationWindow {
id: confirmCloseDialog
title: qsTr("Save changes")
text: configFilename.toString() === "" ? qsTr("Save changes before quitting?") : qsTr("Save changes to %1 before quitting?").arg(urlToLocalFile(configFilename))
- standardButtons: StandardButton.Save | StandardButton.Discard | StandardButton.Cancel
-
- onAccepted: {
- save(configFilename)
- root.close()
- }
-
- onDiscard: {
- closeConfirmed = true
- root.close()
+ enabledButtons: buttonSave | buttonDiscard | buttonCancel
+
+ onButtonClicked: (button) => {
+ switch (button) {
+ case buttonSave:
+ save(configFilename)
+ root.close()
+ break
+
+ case buttonDiscard:
+ closeConfirmed = true
+ root.close()
+ break
+ }
}
}
- onClosing: {
+ onClosing: (close) => {
if (configDirty) {
close.accepted = closeConfirmed
onTriggered: confirmCloseDialog.open()
@@ -200,13 +205,13 @@ ApplicationWindow {
component ConfigTextFieldForPath: RowLayout {
property string text
property string config
- property bool isFolder: false
+ property bool isFolder: false // TODO: Implement
FileDialog {
id: fileSelectorDialog
onAccepted: {
configDirty = true
- ConfigModel.setString(config, urlToLocalFile(fileUrl))
+ ConfigModel.setString(config, urlToLocalFile(selectedFile))
}
}
diff --git a/Source/Tools/FEXQonfig/qml.qrc b/Source/Tools/FEXQonfig/qml.qrc
deleted file mode 100644
index 3997db9ec7..0000000000
--- a/Source/Tools/FEXQonfig/qml.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- main.qml
-
-
diff --git a/Source/Tools/FEXQonfig/qml5.qrc b/Source/Tools/FEXQonfig/qml5.qrc
new file mode 100644
index 0000000000..4aa2f07978
--- /dev/null
+++ b/Source/Tools/FEXQonfig/qml5.qrc
@@ -0,0 +1,9 @@
+
+
+ main.qml
+
+
+ qt5/FileDialog.qml
+ qt5/MessageDialog.qml
+
+
diff --git a/Source/Tools/FEXQonfig/qml6.qrc b/Source/Tools/FEXQonfig/qml6.qrc
new file mode 100644
index 0000000000..04d1c37706
--- /dev/null
+++ b/Source/Tools/FEXQonfig/qml6.qrc
@@ -0,0 +1,9 @@
+
+
+ main.qml
+
+
+ qt6/FileDialog.qml
+ qt6/MessageDialog.qml
+
+
diff --git a/Source/Tools/FEXQonfig/qt5/FileDialog.qml b/Source/Tools/FEXQonfig/qt5/FileDialog.qml
new file mode 100644
index 0000000000..7e848bd9db
--- /dev/null
+++ b/Source/Tools/FEXQonfig/qt5/FileDialog.qml
@@ -0,0 +1,7 @@
+import QtQuick.Dialogs 1.3 as FromQt
+
+FromQt.FileDialog {
+ property url selectedFile
+
+ onAccepted: selectedFile = fileUrl
+}
diff --git a/Source/Tools/FEXQonfig/qt5/MessageDialog.qml b/Source/Tools/FEXQonfig/qt5/MessageDialog.qml
new file mode 100644
index 0000000000..d61f2beca2
--- /dev/null
+++ b/Source/Tools/FEXQonfig/qt5/MessageDialog.qml
@@ -0,0 +1,17 @@
+import QtQuick.Dialogs 1.3 as FromQt
+
+FromQt.MessageDialog {
+ readonly property int buttonSave: FromQt.Dialog.Save
+ readonly property int buttonDiscard: FromQt.Dialog.Discard
+ readonly property int buttonCancel: FromQt.Dialog.Cancel
+
+ property var enabledButtons
+
+ standardButtons: enabledButtons
+
+ signal buttonClicked(button: int)
+
+ onAccepted: buttonClicked(buttonSave)
+ onDiscard: buttonClicked(buttonDiscard)
+ onRejected: buttonClicked(buttonCancel)
+}
diff --git a/Source/Tools/FEXQonfig/qt6/FileDialog.qml b/Source/Tools/FEXQonfig/qt6/FileDialog.qml
new file mode 100644
index 0000000000..862dd8d1da
--- /dev/null
+++ b/Source/Tools/FEXQonfig/qt6/FileDialog.qml
@@ -0,0 +1,3 @@
+import QtQuick.Dialogs as FromQt
+
+FromQt.FileDialog {}
diff --git a/Source/Tools/FEXQonfig/qt6/MessageDialog.qml b/Source/Tools/FEXQonfig/qt6/MessageDialog.qml
new file mode 100644
index 0000000000..0d77cff537
--- /dev/null
+++ b/Source/Tools/FEXQonfig/qt6/MessageDialog.qml
@@ -0,0 +1,10 @@
+import QtQuick.Dialogs as FromQt
+
+FromQt.MessageDialog {
+ readonly property int buttonSave: MessageDialog.Save
+ readonly property int buttonDiscard: MessageDialog.Discard
+ readonly property int buttonCancel: MessageDialog.Cancel
+
+ property var enabledButtons
+ buttons: enabledButtons
+}