From a4ecb0b114d54ad6bb3334ca9c69eb021fadc7a3 Mon Sep 17 00:00:00 2001 From: Vasily Date: Sat, 2 Feb 2019 15:38:34 +0100 Subject: [PATCH] Convert images to use .qrc file, move images All images have been moved to the /img/ folder in order to fully separate qml from images. The .qrc file allows qml to use the images by appending the qrc:/ prefix before the abstract path to the image. Note that the .qrc file is also check at compile time, which further enhances the confidence the lack of errors. Some of the images are not used in the QML, but instead directly passed through to the OpenVR API. These have not been added to the .qrc file. --- advancedSettings.pro | 22 +++++++----------- src/overlaycontroller.cpp | 6 ++--- .../outline_play_pause_white_24dp.svg | 0 .../outline_skip_next_white_24dp.svg | 0 .../outline_skip_previous_white_24dp.svg | 0 .../media_keys/outline_stop_white_24dp.svg | 0 .../audio/microphone}/mic_off.svg | 0 .../audio/microphone}/mic_on.svg | 0 .../audio/microphone}/ptt_notification.png | Bin .../audio/microphone}/ptt_notification.svg | 0 .../audio/speaker}/speaker_off.svg | 0 .../audio/speaker}/speaker_on.svg | 0 src/res/{ => img/battery}/battery_0.png | Bin src/res/{ => img/battery}/battery_1.png | Bin src/res/{ => img/battery}/battery_2.png | Bin src/res/{ => img/battery}/battery_3.png | Bin src/res/{ => img/battery}/battery_4.png | Bin src/res/{ => img/battery}/battery_5.png | Bin src/res/{ => img/icons}/thumbicon.png | Bin src/res/qml/RootPage.qml | 2 +- .../device_selector/MicVolumeSlider.qml | 2 +- .../device_selector/MirrorVolumeSlider.qml | 2 +- src/res/qml/common/MyStackViewPage.qml | 2 +- src/res/qml/common/MyToggleButton.qml | 2 +- .../media_keys/MediaControllerKeys.qml | 8 +++---- src/res/resources.qrc | 18 ++++++++++++-- src/tabcontrollers/AudioTabController.cpp | 3 ++- src/tabcontrollers/UtilitiesTabController.cpp | 2 +- 28 files changed, 40 insertions(+), 29 deletions(-) rename src/res/{qml/utilities_page => img/audio}/media_keys/outline_play_pause_white_24dp.svg (100%) rename src/res/{qml/utilities_page => img/audio}/media_keys/outline_skip_next_white_24dp.svg (100%) rename src/res/{qml/utilities_page => img/audio}/media_keys/outline_skip_previous_white_24dp.svg (100%) rename src/res/{qml/utilities_page => img/audio}/media_keys/outline_stop_white_24dp.svg (100%) rename src/res/{qml/audio_page => img/audio/microphone}/mic_off.svg (100%) rename src/res/{qml/audio_page => img/audio/microphone}/mic_on.svg (100%) rename src/res/{qml => img/audio/microphone}/ptt_notification.png (100%) rename src/res/{qml => img/audio/microphone}/ptt_notification.svg (100%) rename src/res/{qml/audio_page => img/audio/speaker}/speaker_off.svg (100%) rename src/res/{qml/audio_page => img/audio/speaker}/speaker_on.svg (100%) rename src/res/{ => img/battery}/battery_0.png (100%) rename src/res/{ => img/battery}/battery_1.png (100%) rename src/res/{ => img/battery}/battery_2.png (100%) rename src/res/{ => img/battery}/battery_3.png (100%) rename src/res/{ => img/battery}/battery_4.png (100%) rename src/res/{ => img/battery}/battery_5.png (100%) rename src/res/{ => img/icons}/thumbicon.png (100%) diff --git a/advancedSettings.pro b/advancedSettings.pro index e93c00d..21ad4a9 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -118,19 +118,15 @@ unix:DESTDIR = bin/linux/AdvancedSettings DISTFILES += \ src/res/sounds/alarm01.wav \ - src/res/qml/ptt_notification.png \ - src/res/battery_0.png \ - src/res/battery_1.png \ - src/res/battery_2.png \ - src/res/battery_3.png \ - src/res/battery_4.png \ - src/res/battery_5.png \ - src/res/thumbicon.png \ - src/res/qml/mic_off.svg \ - src/res/qml/mic_on.svg \ - src/res/qml/ptt_notification.svg \ - src/res/qml/speaker_off.svg \ - src/res/qml/speaker_on.svg \ + src/res/img/audio/microphone/ptt_notification.png \ + src/res/img/audio/microphone/ptt_notification.svg \ + src/res/img/battery/battery_0.png \ + src/res/img/battery/battery_1.png \ + src/res/img/battery/battery_2.png \ + src/res/img/battery/battery_3.png \ + src/res/img/battery/battery_4.png \ + src/res/img/battery/battery_5.png \ + src/res/img/icons/thumbicon.png \ src/res/qml/qmldir \ src/res/qml/AccessibilityPage.qml \ src/res/qml/audio_page/* \ diff --git a/src/overlaycontroller.cpp b/src/overlaycontroller.cpp index 7b00181..f75fa09 100644 --- a/src/overlaycontroller.cpp +++ b/src/overlaycontroller.cpp @@ -332,9 +332,9 @@ void OverlayController::SetWidget( QQuickItem* quickItem, m_ulOverlayHandle, vr::VROverlayFlags_SendVRSmoothScrollEvents, true ); - QString thumbIconPath - = QStandardPaths::locate( QStandardPaths::AppDataLocation, - QStringLiteral( "res/thumbicon.png" ) ); + QString thumbIconPath = QStandardPaths::locate( + QStandardPaths::AppDataLocation, + QStringLiteral( "res/img/icons/thumbicon.png" ) ); if ( QFile::exists( thumbIconPath ) ) { vr::VROverlay()->SetOverlayFromFile( diff --git a/src/res/qml/utilities_page/media_keys/outline_play_pause_white_24dp.svg b/src/res/img/audio/media_keys/outline_play_pause_white_24dp.svg similarity index 100% rename from src/res/qml/utilities_page/media_keys/outline_play_pause_white_24dp.svg rename to src/res/img/audio/media_keys/outline_play_pause_white_24dp.svg diff --git a/src/res/qml/utilities_page/media_keys/outline_skip_next_white_24dp.svg b/src/res/img/audio/media_keys/outline_skip_next_white_24dp.svg similarity index 100% rename from src/res/qml/utilities_page/media_keys/outline_skip_next_white_24dp.svg rename to src/res/img/audio/media_keys/outline_skip_next_white_24dp.svg diff --git a/src/res/qml/utilities_page/media_keys/outline_skip_previous_white_24dp.svg b/src/res/img/audio/media_keys/outline_skip_previous_white_24dp.svg similarity index 100% rename from src/res/qml/utilities_page/media_keys/outline_skip_previous_white_24dp.svg rename to src/res/img/audio/media_keys/outline_skip_previous_white_24dp.svg diff --git a/src/res/qml/utilities_page/media_keys/outline_stop_white_24dp.svg b/src/res/img/audio/media_keys/outline_stop_white_24dp.svg similarity index 100% rename from src/res/qml/utilities_page/media_keys/outline_stop_white_24dp.svg rename to src/res/img/audio/media_keys/outline_stop_white_24dp.svg diff --git a/src/res/qml/audio_page/mic_off.svg b/src/res/img/audio/microphone/mic_off.svg similarity index 100% rename from src/res/qml/audio_page/mic_off.svg rename to src/res/img/audio/microphone/mic_off.svg diff --git a/src/res/qml/audio_page/mic_on.svg b/src/res/img/audio/microphone/mic_on.svg similarity index 100% rename from src/res/qml/audio_page/mic_on.svg rename to src/res/img/audio/microphone/mic_on.svg diff --git a/src/res/qml/ptt_notification.png b/src/res/img/audio/microphone/ptt_notification.png similarity index 100% rename from src/res/qml/ptt_notification.png rename to src/res/img/audio/microphone/ptt_notification.png diff --git a/src/res/qml/ptt_notification.svg b/src/res/img/audio/microphone/ptt_notification.svg similarity index 100% rename from src/res/qml/ptt_notification.svg rename to src/res/img/audio/microphone/ptt_notification.svg diff --git a/src/res/qml/audio_page/speaker_off.svg b/src/res/img/audio/speaker/speaker_off.svg similarity index 100% rename from src/res/qml/audio_page/speaker_off.svg rename to src/res/img/audio/speaker/speaker_off.svg diff --git a/src/res/qml/audio_page/speaker_on.svg b/src/res/img/audio/speaker/speaker_on.svg similarity index 100% rename from src/res/qml/audio_page/speaker_on.svg rename to src/res/img/audio/speaker/speaker_on.svg diff --git a/src/res/battery_0.png b/src/res/img/battery/battery_0.png similarity index 100% rename from src/res/battery_0.png rename to src/res/img/battery/battery_0.png diff --git a/src/res/battery_1.png b/src/res/img/battery/battery_1.png similarity index 100% rename from src/res/battery_1.png rename to src/res/img/battery/battery_1.png diff --git a/src/res/battery_2.png b/src/res/img/battery/battery_2.png similarity index 100% rename from src/res/battery_2.png rename to src/res/img/battery/battery_2.png diff --git a/src/res/battery_3.png b/src/res/img/battery/battery_3.png similarity index 100% rename from src/res/battery_3.png rename to src/res/img/battery/battery_3.png diff --git a/src/res/battery_4.png b/src/res/img/battery/battery_4.png similarity index 100% rename from src/res/battery_4.png rename to src/res/img/battery/battery_4.png diff --git a/src/res/battery_5.png b/src/res/img/battery/battery_5.png similarity index 100% rename from src/res/battery_5.png rename to src/res/img/battery/battery_5.png diff --git a/src/res/thumbicon.png b/src/res/img/icons/thumbicon.png similarity index 100% rename from src/res/thumbicon.png rename to src/res/img/icons/thumbicon.png diff --git a/src/res/qml/RootPage.qml b/src/res/qml/RootPage.qml index 257eaed..8f59a1b 100644 --- a/src/res/qml/RootPage.qml +++ b/src/res/qml/RootPage.qml @@ -344,7 +344,7 @@ MyStackViewPage { Layout.leftMargin: 12 checkable: true contentItem: Image { - source: parent.checked ? "audio_page/mic_off.svg" : "audio_page/mic_on.svg" + source: parent.checked ? "qrc:/microphone/off" : "qrc:/microphone/on" sourceSize.width: 32 sourceSize.height: 32 anchors.fill: parent diff --git a/src/res/qml/audio_page/device_selector/MicVolumeSlider.qml b/src/res/qml/audio_page/device_selector/MicVolumeSlider.qml index ce0a684..a9971a6 100644 --- a/src/res/qml/audio_page/device_selector/MicVolumeSlider.qml +++ b/src/res/qml/audio_page/device_selector/MicVolumeSlider.qml @@ -61,7 +61,7 @@ ColumnLayout { Layout.leftMargin: 12 checkable: true contentItem: Image { - source: parent.checked ? "../mic_off.svg" : "../mic_on.svg" + source: parent.checked ? "qrc:/microphone/off" : "qrc:/microphone/on" sourceSize.width: 32 sourceSize.height: 32 anchors.fill: parent diff --git a/src/res/qml/audio_page/device_selector/MirrorVolumeSlider.qml b/src/res/qml/audio_page/device_selector/MirrorVolumeSlider.qml index 7add052..b90199a 100644 --- a/src/res/qml/audio_page/device_selector/MirrorVolumeSlider.qml +++ b/src/res/qml/audio_page/device_selector/MirrorVolumeSlider.qml @@ -62,7 +62,7 @@ ColumnLayout { Layout.leftMargin: 12 checkable: true contentItem: Image { - source: parent.checked ? "../speaker_off.svg" : "../speaker_on.svg" + source: parent.checked ? "qrc:/speaker/off" : "qrc:/speaker/on" sourceSize.width: 32 sourceSize.height: 32 anchors.fill: parent diff --git a/src/res/qml/common/MyStackViewPage.qml b/src/res/qml/common/MyStackViewPage.qml index 0690393..02a741a 100644 --- a/src/res/qml/common/MyStackViewPage.qml +++ b/src/res/qml/common/MyStackViewPage.qml @@ -26,7 +26,7 @@ Rectangle { enabled: headerShowBackButton opacity: headerShowBackButton ? 1.0 : 0.0 contentItem: Image { - source: "qrc:/common/back-arrow" + source: "qrc:/common/backarrow" sourceSize.width: 50 sourceSize.height: 50 anchors.fill: parent diff --git a/src/res/qml/common/MyToggleButton.qml b/src/res/qml/common/MyToggleButton.qml index 7c2e418..99126d5 100644 --- a/src/res/qml/common/MyToggleButton.qml +++ b/src/res/qml/common/MyToggleButton.qml @@ -31,7 +31,7 @@ CheckBox { height: 28 x: (parent.width - width) / 2 y: (parent.height - height) / 2 - source: "qrc:/common/box-checkmark" + source: "qrc:/common/box_checkmark" sourceSize.width: width sourceSize.height: height visible: parent.parent.checked diff --git a/src/res/qml/utilities_page/media_keys/MediaControllerKeys.qml b/src/res/qml/utilities_page/media_keys/MediaControllerKeys.qml index a22c4ae..14b6ffc 100644 --- a/src/res/qml/utilities_page/media_keys/MediaControllerKeys.qml +++ b/src/res/qml/utilities_page/media_keys/MediaControllerKeys.qml @@ -25,10 +25,10 @@ GroupBox { } RowLayout { - property string playPauseButtonPath: "outline_play_pause_white_24dp.svg" - property string stopButtonPath: "outline_stop_white_24dp.svg" - property string previousButtonPath: "outline_skip_previous_white_24dp.svg" - property string nextButtonPath: "outline_skip_next_white_24dp.svg" + property string playPauseButtonPath: "qrc:/media_keys/play_pause" + property string stopButtonPath: "qrc:/media_keys/stop" + property string previousButtonPath: "qrc:/media_keys/previous" + property string nextButtonPath: "qrc:/media_keys/next" MediaButton { id: previousSongButton diff --git a/src/res/resources.qrc b/src/res/resources.qrc index b13f6f9..6fb7946 100644 --- a/src/res/resources.qrc +++ b/src/res/resources.qrc @@ -1,6 +1,20 @@ - img/common/backarrow.svg - img/common/check.svg + img/common/backarrow.svg + img/common/check.svg + + + img/audio/microphone/mic_on.svg + img/audio/microphone/mic_off.svg + + + img/audio/speaker/speaker_on.svg + img/audio/speaker/speaker_off.svg + + + img/audio/media_keys/outline_play_pause_white_24dp.svg + img/audio/media_keys/outline_skip_next_white_24dp.svg + img/audio/media_keys/outline_skip_previous_white_24dp.svg + img/audio/media_keys/outline_stop_white_24dp.svg \ No newline at end of file diff --git a/src/tabcontrollers/AudioTabController.cpp b/src/tabcontrollers/AudioTabController.cpp index 6e30b62..9dcfedf 100644 --- a/src/tabcontrollers/AudioTabController.cpp +++ b/src/tabcontrollers/AudioTabController.cpp @@ -72,7 +72,8 @@ void AudioTabController::initStage2( OverlayController* var_parent, { QString notifIconPath = QStandardPaths::locate( QStandardPaths::AppDataLocation, - QStringLiteral( "/res/qml/ptt_notification.png" ) ); + QStringLiteral( + "/res/img/audio/microphone/ptt_notification.png" ) ); if ( QFile::exists( notifIconPath ) ) { vr::VROverlay()->SetOverlayFromFile( diff --git a/src/tabcontrollers/UtilitiesTabController.cpp b/src/tabcontrollers/UtilitiesTabController.cpp index 0296873..f4effb0 100644 --- a/src/tabcontrollers/UtilitiesTabController.cpp +++ b/src/tabcontrollers/UtilitiesTabController.cpp @@ -274,7 +274,7 @@ void UtilitiesTabController::modAlarmTimeMinute( int value, bool notify ) QString getBatteryIconPath( int batteryState ) { - QString batteryPrefix = "/res/battery_"; + QString batteryPrefix = "/res/img/battery/battery_"; return QStandardPaths::locate( QStandardPaths::AppDataLocation, batteryPrefix + QString::number( batteryState ) + ".png" );