aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2017-10-05 11:48:12 +0200
committerMitch Curtis <mitch.curtis@qt.io>2017-10-06 07:50:19 +0000
commit66f292062276364252897f33346acb5528b45067 (patch)
treeb105bd1dcb0d95073e21a8197cb0a16b4ec63de6
parent3a5e3f3c83ec9e891ee9e9ee0b4df9f2dbef81f1 (diff)
Improve testbench
- Add a "Fix Custom Assets" action with shortcut - Organize the settings dialog into groups so it's easier to see which options are Imagine-only. Change-Id: I20fe7ba63b3bf7770f6ca553780c47f021217ea2 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
-rw-r--r--tests/manual/testbench/README.md3
-rw-r--r--tests/manual/testbench/SettingsDialog.qml474
-rw-r--r--tests/manual/testbench/assetfixer.cpp2
-rw-r--r--tests/manual/testbench/testbench.qml49
4 files changed, 292 insertions, 236 deletions
diff --git a/tests/manual/testbench/README.md b/tests/manual/testbench/README.md
index 2d7fa54a..bd434de6 100644
--- a/tests/manual/testbench/README.md
+++ b/tests/manual/testbench/README.md
@@ -29,6 +29,7 @@ The "Copy Palette Settings To Clipboard" button in the settings dialog can be us
| Name | Shortcut | Shortcut (Mac) | Description |
|-------------------|--------------|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| Use Custom Assets | Ctrl+Shift+C | ⌘+Shift+C | If using the Imagine style, toggles between the default assets and the user's custom assets. Custom assets are specified in the settings dialog. |
-| Reload Assets | Ctrl+Shift+R | ⌘+R | If using the Imagine style, reloads the assets from disk. This is usually done automatically. |
+| Fix Custom Assets | Ctrl+Shift+X | ⌘+Shift+X | If using the Imagine style, manually fixes the assets. This is done automatically when "Automatically Fix Custom Assets" checkbox is checked. |
+| Reload Assets | Ctrl+R | ⌘+R | If using the Imagine style, reloads the assets from disk. This is usually done automatically. |
| Search/Filter | Ctrl+F | ⌘+F | Filter the controls that are shown. Case-sensitive. |
| Quit | Ctrl+Q | ⌘+Q | Quit the application. |
diff --git a/tests/manual/testbench/SettingsDialog.qml b/tests/manual/testbench/SettingsDialog.qml
index 2bc3ddec..ef38c496 100644
--- a/tests/manual/testbench/SettingsDialog.qml
+++ b/tests/manual/testbench/SettingsDialog.qml
@@ -67,13 +67,13 @@ Dialog {
property alias imaginePathTextField: imaginePathTextField
property alias customImagineStyleCheckBox: customImagineStyleCheckBox
- property alias fixImagineAssetsCheckBox: fixImagineAssetsCheckBox
+ property alias autoFixImagineAssetsCheckBox: autoFixImagineAssetsCheckBox
onAboutToShow: {
styleComboBox.currentIndex = styleComboBox.styleIndex
customImagineStyleCheckBox.checked = settings.useCustomImaginePath
imaginePathTextField.text = settings.imaginePath
- fixImagineAssetsCheckBox.checked = settings.fixImagineAssets
+ autoFixImagineAssetsCheckBox.checked = settings.autoFixImagineAssets
updatePaletteSettingsControls(paletteSettings)
}
@@ -82,7 +82,7 @@ Dialog {
settings.style = styleComboBox.displayText
settings.useCustomImaginePath = customImagineStyleCheckBox.checked
settings.imaginePath = imaginePathTextField.text
- settings.fixImagineAssets = fixImagineAssetsCheckBox.checked
+ settings.autoFixImagineAssets = autoFixImagineAssetsCheckBox.checked
paletteSettings.useCustomPalette = useCustomPaletteCheckBox.checked
paletteSettings.window = windowColorEditor.color
@@ -158,249 +158,279 @@ Dialog {
contentItem: Flickable {
contentWidth: settingsDialog.availableWidth
- contentHeight: contentGridLayout.implicitHeight
+ contentHeight: contentLayout.implicitHeight
flickableDirection: Qt.Vertical
clip: true
- GridLayout {
- id: contentGridLayout
- columns: 2
+ ColumnLayout {
+ id: contentLayout
anchors.fill: parent
- Label {
- text: "Style:"
- }
-
- ComboBox {
- id: styleComboBox
- model: availableStyles
-
- property int styleIndex: -1
-
- Component.onCompleted: {
- styleIndex = find(settings.style, Qt.MatchFixedString)
- if (styleIndex !== -1)
- currentIndex = styleIndex
- }
-
- Layout.fillWidth: true
- }
-
- Item {
+ GroupBox {
+ title: qsTr("General")
Layout.fillWidth: true
- }
- Label {
- text: "Restart required"
- color: "#e41e25"
- opacity: styleComboBox.currentIndex !== styleComboBox.styleIndex ? 1.0 : 0.0
- Layout.topMargin: 12
- Layout.maximumHeight: styleComboBox.currentIndex !== styleComboBox.styleIndex ? implicitHeight : 0
- }
+ GridLayout {
+ columns: 2
- CheckBox {
- id: customImagineStyleCheckBox
- text: qsTr("Use Custom Imagine Style Assets")
- enabled: usingImagineStyle
+ Label {
+ text: "Style:"
+ }
- Layout.columnSpan: 2
- }
+ ComboBox {
+ id: styleComboBox
+ model: availableStyles
- Label {
- text: "Imagine Style Assets Path"
- enabled: usingImagineStyle && customImagineStyleCheckBox.checked
- }
+ property int styleIndex: -1
- TextField {
- id: imaginePathTextField
- text: settings.imaginePath
- enabled: usingImagineStyle && customImagineStyleCheckBox.checked
+ Component.onCompleted: {
+ styleIndex = find(settings.style, Qt.MatchFixedString)
+ if (styleIndex !== -1)
+ currentIndex = styleIndex
+ }
- Layout.preferredWidth: 200
- Layout.fillWidth: true
+ Layout.fillWidth: true
+ }
- ToolTip {
- text: "Path to a folder that contains Imagine style image assets"
- visible: imaginePathTextField.hovered
- delay: 500
- parent: imaginePathTextField
+ Item {
+ Layout.fillWidth: true
+ }
- Imagine.path: defaultImaginePath
+ Label {
+ text: "Restart required"
+ color: "#e41e25"
+ opacity: styleComboBox.currentIndex !== styleComboBox.styleIndex ? 1.0 : 0.0
+ Layout.topMargin: 12
+ Layout.maximumHeight: styleComboBox.currentIndex !== styleComboBox.styleIndex ? implicitHeight : 0
+ }
}
}
- Item {
+ GroupBox {
+ title: qsTr("Imagine Style")
+ visible: usingImagineStyle
Layout.fillWidth: true
- }
-
- Label {
- text: directoryValidator.errorMessage
- color: "#e41e25"
- opacity: !directoryValidator.valid ? 1.0 : 0.0
- elide: Label.ElideMiddle
- Layout.topMargin: !directoryValidator.valid ? 12 : 0
- Layout.maximumHeight: !directoryValidator.valid ? implicitHeight : 0
-
- Layout.fillWidth: true
- }
-
- CheckBox {
- id: fixImagineAssetsCheckBox
- text: "Fix Imagine Style Assets"
- enabled: usingImagineStyle && customImagineStyleCheckBox.checked
-
Layout.columnSpan: 2
- ToolTip {
- text: "If set, custom Imagine style assets will be modified to be compliant"
- visible: fixImagineAssetsCheckBox.hovered
- delay: 500
- parent: imaginePathTextField
-
- Imagine.path: defaultImaginePath
+ GridLayout {
+ columns: 2
+ anchors.fill: parent
+
+ CheckBox {
+ id: customImagineStyleCheckBox
+ text: qsTr("Use Custom Assets")
+ enabled: usingImagineStyle
+
+ Layout.columnSpan: 2
+ }
+
+ Label {
+ text: "Asset Path"
+ enabled: usingImagineStyle && customImagineStyleCheckBox.checked
+ }
+
+ TextField {
+ id: imaginePathTextField
+ text: settings.imaginePath
+ enabled: usingImagineStyle && customImagineStyleCheckBox.checked
+
+ Layout.preferredWidth: 200
+ Layout.fillWidth: true
+
+ ToolTip {
+ text: "Path to a folder that contains Imagine style image assets"
+ visible: imaginePathTextField.hovered
+ delay: 500
+ parent: imaginePathTextField
+
+ Imagine.path: defaultImaginePath
+ }
+ }
+
+ Item {
+ Layout.fillWidth: true
+ }
+
+ Label {
+ text: directoryValidator.errorMessage
+ color: "#e41e25"
+ opacity: !directoryValidator.valid ? 1.0 : 0.0
+ elide: Label.ElideMiddle
+ Layout.topMargin: !directoryValidator.valid ? 12 : 0
+ Layout.maximumHeight: !directoryValidator.valid ? implicitHeight : 0
+
+ Layout.fillWidth: true
+ }
+
+ CheckBox {
+ id: autoFixImagineAssetsCheckBox
+ text: "Automatically Fix Custom Assets"
+ enabled: usingImagineStyle && customImagineStyleCheckBox.checked
+
+ Layout.columnSpan: 2
+
+ ToolTip {
+ text: "If set, custom Imagine style assets will be modified to be compliant whenever they have changed on disk"
+ visible: autoFixImagineAssetsCheckBox.hovered
+ delay: 500
+ parent: imaginePathTextField
+
+ Imagine.path: defaultImaginePath
+ }
+ }
}
}
- CheckBox {
- id: useCustomPaletteCheckBox
- text: qsTr("Use Custom Palette")
-
- Layout.topMargin: 12
- }
-
- ColorEditor {
- id: windowColorEditor
- labelText: qsTr("Window")
- toolTipText: qsTr("A general background color.")
- enabled: useCustomPaletteCheckBox.checked
- }
-
- ColorEditor {
- id: windowTextColorEditor
- labelText: qsTr("WindowText")
- toolTipText: qsTr("A general foreground color.")
- enabled: useCustomPaletteCheckBox.checked
- }
-
- ColorEditor {
- id: baseColorEditor
- labelText: qsTr("Base")
- toolTipText: qsTr("Used mostly as the background color for text editor controls and items views. It is usually white or another light color.")
- enabled: useCustomPaletteCheckBox.checked
- }
-
- ColorEditor {
- id: textColorEditor
- labelText: qsTr("Text")
- toolTipText: qsTr("The foreground color used with Base. This is usually the same as the WindowText, in which case it must provide good contrast with Window and Base.")
- enabled: useCustomPaletteCheckBox.checked
- }
-
- ColorEditor {
- id: buttonColorEditor
- labelText: qsTr("Button")
- toolTipText: qsTr("The general button background color. This background can be different from Window as some styles require a different background color for buttons.")
- enabled: useCustomPaletteCheckBox.checked
- }
-
- ColorEditor {
- id: buttonTextColorEditor
- labelText: qsTr("ButtonText")
- toolTipText: qsTr("A foreground color used with the Button color.")
- enabled: useCustomPaletteCheckBox.checked
- }
-
- ColorEditor {
- id: brightTextColorEditor
- labelText: qsTr("BrightText")
- toolTipText: qsTr("A text color that is very different from WindowText, and contrasts well with e.g. Dark. Typically used for text that needs to be drawn where Text, WindowText or ButtonText would give poor contrast, such as on highlighted buttons.")
- enabled: useCustomPaletteCheckBox.checked
- }
-
- ColorEditor {
- id: toolTipBaseColorEditor
- labelText: qsTr("ToolTipBase")
- toolTipText: qsTr("Used as the background color for tooltips.")
- enabled: useCustomPaletteCheckBox.checked
- }
-
- ColorEditor {
- id: toolTipTextColorEditor
- labelText: qsTr("ToolTipText")
- toolTipText: qsTr("Used as the foreground color for tooltips.")
- enabled: useCustomPaletteCheckBox.checked
- }
-
- ColorEditor {
- id: lightColorEditor
- labelText: qsTr("Light")
- toolTipText: qsTr("Lighter than Button.")
- enabled: useCustomPaletteCheckBox.checked
- }
-
- ColorEditor {
- id: midlightColorEditor
- labelText: qsTr("Midlight")
- toolTipText: qsTr("Between Button and Light.")
- enabled: useCustomPaletteCheckBox.checked
- }
-
- ColorEditor {
- id: darkColorEditor
- labelText: qsTr("Dark")
- toolTipText: qsTr("Darker than Button.")
- enabled: useCustomPaletteCheckBox.checked
- }
-
- ColorEditor {
- id: midColorEditor
- labelText: qsTr("Mid")
- toolTipText: qsTr("Between Button and Dark.")
- enabled: useCustomPaletteCheckBox.checked
- }
-
- ColorEditor {
- id: shadowColorEditor
- labelText: qsTr("Shadow")
- toolTipText: qsTr("A very dark color.")
- enabled: useCustomPaletteCheckBox.checked
- }
-
- ColorEditor {
- id: highlightColorEditor
- labelText: qsTr("Highlight")
- toolTipText: qsTr("A color to indicate a selected item or the current item.")
- enabled: useCustomPaletteCheckBox.checked
- }
-
- ColorEditor {
- id: linkColorEditor
- labelText: qsTr("Link")
- toolTipText: qsTr("A text color used for hyperlinks.")
- enabled: useCustomPaletteCheckBox.checked
- }
-
- ColorEditor {
- id: highlightedTextColorEditor
- labelText: qsTr("HighlightedText")
- toolTipText: qsTr("A text color that contrasts with Highlight.")
- enabled: useCustomPaletteCheckBox.checked
- }
-
- Button {
- text: qsTr("Copy Palette Settings To Clipboard")
- onClicked: clipboard.copy(paletteSettingsMap())
-
- Layout.columnSpan: 2
- Layout.alignment: Qt.AlignRight
- }
-
- Button {
- text: qsTr("Import Palette Settings From Clipboard")
- onClicked: updatePaletteSettingsControls(clipboard.paste())
+ GroupBox {
+ title: qsTr("Palette")
+ Layout.fillWidth: true
- Layout.columnSpan: 2
- Layout.alignment: Qt.AlignRight
+ GridLayout {
+ columns: 2
+ anchors.fill: parent
+
+ CheckBox {
+ id: useCustomPaletteCheckBox
+ text: qsTr("Use Custom Palette")
+ }
+
+ ColorEditor {
+ id: windowColorEditor
+ labelText: qsTr("Window")
+ toolTipText: qsTr("A general background color.")
+ enabled: useCustomPaletteCheckBox.checked
+ }
+
+ ColorEditor {
+ id: windowTextColorEditor
+ labelText: qsTr("WindowText")
+ toolTipText: qsTr("A general foreground color.")
+ enabled: useCustomPaletteCheckBox.checked
+ }
+
+ ColorEditor {
+ id: baseColorEditor
+ labelText: qsTr("Base")
+ toolTipText: qsTr("Used mostly as the background color for text editor controls and items views. It is usually white or another light color.")
+ enabled: useCustomPaletteCheckBox.checked
+ }
+
+ ColorEditor {
+ id: textColorEditor
+ labelText: qsTr("Text")
+ toolTipText: qsTr("The foreground color used with Base. This is usually the same as the WindowText, in which case it must provide good contrast with Window and Base.")
+ enabled: useCustomPaletteCheckBox.checked
+ }
+
+ ColorEditor {
+ id: buttonColorEditor
+ labelText: qsTr("Button")
+ toolTipText: qsTr("The general button background color. This background can be different from Window as some styles require a different background color for buttons.")
+ enabled: useCustomPaletteCheckBox.checked
+ }
+
+ ColorEditor {
+ id: buttonTextColorEditor
+ labelText: qsTr("ButtonText")
+ toolTipText: qsTr("A foreground color used with the Button color.")
+ enabled: useCustomPaletteCheckBox.checked
+ }
+
+ ColorEditor {
+ id: brightTextColorEditor
+ labelText: qsTr("BrightText")
+ toolTipText: qsTr("A text color that is very different from WindowText, and contrasts well with e.g. Dark. Typically used for text that needs to be drawn where Text, WindowText or ButtonText would give poor contrast, such as on highlighted buttons.")
+ enabled: useCustomPaletteCheckBox.checked
+ }
+
+ ColorEditor {
+ id: toolTipBaseColorEditor
+ labelText: qsTr("ToolTipBase")
+ toolTipText: qsTr("Used as the background color for tooltips.")
+ enabled: useCustomPaletteCheckBox.checked
+ }
+
+ ColorEditor {
+ id: toolTipTextColorEditor
+ labelText: qsTr("ToolTipText")
+ toolTipText: qsTr("Used as the foreground color for tooltips.")
+ enabled: useCustomPaletteCheckBox.checked
+ }
+
+ ColorEditor {
+ id: lightColorEditor
+ labelText: qsTr("Light")
+ toolTipText: qsTr("Lighter than Button.")
+ enabled: useCustomPaletteCheckBox.checked
+ }
+
+ ColorEditor {
+ id: midlightColorEditor
+ labelText: qsTr("Midlight")
+ toolTipText: qsTr("Between Button and Light.")
+ enabled: useCustomPaletteCheckBox.checked
+ }
+
+ ColorEditor {
+ id: darkColorEditor
+ labelText: qsTr("Dark")
+ toolTipText: qsTr("Darker than Button.")
+ enabled: useCustomPaletteCheckBox.checked
+ }
+
+ ColorEditor {
+ id: midColorEditor
+ labelText: qsTr("Mid")
+ toolTipText: qsTr("Between Button and Dark.")
+ enabled: useCustomPaletteCheckBox.checked
+ }
+
+ ColorEditor {
+ id: shadowColorEditor
+ labelText: qsTr("Shadow")
+ toolTipText: qsTr("A very dark color.")
+ enabled: useCustomPaletteCheckBox.checked
+ }
+
+ ColorEditor {
+ id: highlightColorEditor
+ labelText: qsTr("Highlight")
+ toolTipText: qsTr("A color to indicate a selected item or the current item.")
+ enabled: useCustomPaletteCheckBox.checked
+ }
+
+ ColorEditor {
+ id: linkColorEditor
+ labelText: qsTr("Link")
+ toolTipText: qsTr("A text color used for hyperlinks.")
+ enabled: useCustomPaletteCheckBox.checked
+ }
+
+ ColorEditor {
+ id: highlightedTextColorEditor
+ labelText: qsTr("HighlightedText")
+ toolTipText: qsTr("A text color that contrasts with Highlight.")
+ enabled: useCustomPaletteCheckBox.checked
+ }
+
+ Button {
+ text: qsTr("Copy Palette Settings To Clipboard")
+ enabled: useCustomPaletteCheckBox.checked
+ onClicked: clipboard.copy(paletteSettingsMap())
+
+ Layout.columnSpan: 2
+ Layout.alignment: Qt.AlignRight
+ }
+
+ Button {
+ text: qsTr("Import Palette Settings From Clipboard")
+ enabled: useCustomPaletteCheckBox.checked
+ onClicked: updatePaletteSettingsControls(clipboard.paste())
+
+ Layout.columnSpan: 2
+ Layout.alignment: Qt.AlignRight
+ }
+ }
}
Item {
diff --git a/tests/manual/testbench/assetfixer.cpp b/tests/manual/testbench/assetfixer.cpp
index 1f914e71..4813dac5 100644
--- a/tests/manual/testbench/assetfixer.cpp
+++ b/tests/manual/testbench/assetfixer.cpp
@@ -521,7 +521,7 @@ void AssetFixer::clearImageCache()
void AssetFixer::fixAssets()
{
- if (!mShouldWatch || !mShouldFix || !mComponentComplete || mAssetDirectory.isEmpty() || !isAssetDirectoryValid(mAssetDirectory))
+ if (!mShouldFix || !mComponentComplete || mAssetDirectory.isEmpty() || !isAssetDirectoryValid(mAssetDirectory))
return;
QDir assetDir(mAssetDirectory);
diff --git a/tests/manual/testbench/testbench.qml b/tests/manual/testbench/testbench.qml
index d9bf0fe5..5b051460 100644
--- a/tests/manual/testbench/testbench.qml
+++ b/tests/manual/testbench/testbench.qml
@@ -90,6 +90,14 @@ ApplicationWindow {
}
Action {
+ id: fixAssetsAction
+ text: qsTr("Fix Custom Assets")
+ shortcut: "Ctrl+Shift+X"
+ enabled: usingImagineStyle
+ onTriggered: assetFixer.manualFix()
+ }
+
+ Action {
id: useCustomAssetsAction
text: qsTr("Use Custom Assets")
shortcut: "Ctrl+Shift+C"
@@ -123,7 +131,7 @@ ApplicationWindow {
property bool useCustomImaginePath
property string imaginePath
- property bool fixImagineAssets
+ property bool autoFixImagineAssets
property alias imagineDirLastModified: assetFixer.assetDirectoryLastModified
Component.onCompleted: settingsLoaded = true
@@ -213,6 +221,10 @@ ApplicationWindow {
action: useCustomAssetsAction
}
+ MenuItem {
+ action: fixAssetsAction
+ }
+
MenuSeparator {}
MenuItem {
@@ -258,12 +270,14 @@ ApplicationWindow {
// AssetFixer needs the settings in order to check the last modified time of the asset directory.
// Also, wait until the UI has been rendered for the first time so that we can show our busy indicators, etc.
shouldWatch: usingImagineStyle && settings.useCustomImaginePath && settingsLoaded && initialUiRenderDelayTimer.hasRun
- shouldFix: shouldWatch && settings.fixImagineAssets
+ shouldFix: (shouldWatch && settings.autoFixImagineAssets) || manuallyFixing
- onFixSuggested: fixEmUp()
+ onFixSuggested: autoFix()
onDelayedFixSuggested: assetFixerFileSystemDelayTimer.restart()
onReloadSuggested: reloadAssets()
+ property bool manuallyFixing: false
+
function reloadAssets() {
console.log(brief, "Reloading assets...")
// Clear the model, otherwise ListView will keep the old items around
@@ -274,22 +288,32 @@ ApplicationWindow {
assetReloadNextFrameTimer.start()
}
- function fixEmUp() {
+ function autoFix() {
// This is a bit of a hack, but I can't think of a nice way to solve it.
// The problem is that shouldWatch becomes true, causing startWatching() to be called.
// If a fix is suggested as a result of that, this function is called.
// However, the shouldFix binding hasn't been updated yet, so even though shouldWatch
- // and settings.fixImagineAssets are both true (the properties that make up its binding),
+ // and settings.autoFixImagineAssets are both true (the properties that make up its binding),
// the if check below fails. So, we check for that case with effectiveShouldFix.
- var effectiveShouldFix = shouldWatch && settings.fixImagineAssets;
+ var effectiveShouldFix = shouldWatch && settings.autoFixImagineAssets;
if (shouldWatch && effectiveShouldFix && assetDirectory.length > 0) {
- // Disable image caching if it hasn't already been done.
- assetFixer.clearImageCache()
-
- busyIndicatorRow.visible = true
- assetFixerAnimationDelayTimer.start()
+ fixEmUp();
}
}
+
+ function manualFix() {
+ fixEmUp(true);
+ }
+
+ function fixEmUp(manually) {
+ assetFixer.manuallyFixing = !!manually
+
+ // Disable image caching if it hasn't already been done.
+ assetFixer.clearImageCache()
+
+ busyIndicatorRow.visible = true
+ assetFixerAnimationDelayTimer.start()
+ }
}
// The controls' assets don't always "reload" if the path is cleared and then set in the same frame,
@@ -327,7 +351,7 @@ ApplicationWindow {
infoToolTip.open()
}
}
- onTriggered: assetFixer.fixEmUp()
+ onTriggered: assetFixer.autoFix()
}
// Gives the BusyIndicator animation a chance to start.
@@ -337,6 +361,7 @@ ApplicationWindow {
onTriggered: {
assetFixer.fixAssets()
busyIndicatorRow.visible = false
+ assetFixer.manuallyFixing = false
}
}