Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • alcroito/qt-ui-viewer
  • design-studio/design-viewer/qt-ui-viewer
2 results
Show changes
Showing
with 126 additions and 10 deletions
......@@ -3,6 +3,7 @@
#include "settings.h"
#include <QDir>
#include <QFile>
#include <QJsonDocument>
#include <QStandardPaths>
......@@ -10,8 +11,9 @@
/*
Example of a settings.json file:
{
"autoScale": true
"deviceUuid": "1234567890"
"autoScale": true,
"deviceUuid": "1234567890",
"keepScreenOn": false
}
*/
......@@ -20,12 +22,31 @@ Settings::Settings()
QStandardPaths::writableLocation(QStandardPaths::ConfigLocation).append("/settings.json"))
{
qDebug() << "Settings path:" << m_settingsPath;
const QDir dir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
if (!dir.exists()) {
qWarning() << "Settings directory does not exist. Creating one.";
dir.mkpath(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
}
if (!loadSettings()) {
qDebug() << "Failed to load settings. Applying default ones.";
applyDefaultSettings();
}
}
bool Settings::clearSettings()
{
const auto backup = m_settings;
m_settings = QJsonObject();
const bool rV = saveSettings();
if (rV)
applyDefaultSettings();
else
m_settings = backup;
return rV;
}
void Settings::applyDefaultSettings()
{
m_settings["autoScale"] = true;
......@@ -73,6 +94,12 @@ void Settings::setDeviceUuid(const QString &deviceUuid)
saveSettings();
}
void Settings::setKeepScreenOn(const bool &enabled)
{
m_settings["keepScreenOn"] = enabled;
saveSettings();
}
QString Settings::deviceUuid() const
{
return m_settings["deviceUuid"].toString();
......@@ -82,3 +109,8 @@ bool Settings::autoScaleProject() const
{
return m_settings["autoScale"].toBool();
}
bool Settings::keepScreenOn() const
{
return m_settings["keepScreenOn"].toBool();
}
......@@ -10,11 +10,15 @@ class Settings
public:
Settings();
bool clearSettings();
void setAutoScaleProject(const bool &enabled);
void setDeviceUuid(const QString &deviceUuid);
void setKeepScreenOn(const bool &enabled);
bool autoScaleProject() const;
QString deviceUuid() const;
bool keepScreenOn() const;
private:
QJsonObject m_settings;
......
src/images/appicon.png

49.4 KiB

<svg width="256" height="256" viewBox="0 0 256 256" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_674_15)">
<path d="M0 32V256H224L256 224V0H32L0 32Z" fill="url(#paint0_linear_674_15)"/>
<path d="M51.046 175.993C51.046 187.179 56.733 192.772 68.107 192.772C79.481 192.772 85.168 187.179 85.168 175.993V112.12H104.626V175.57C104.626 187.32 101.571 195.968 95.461 201.514C89.445 206.966 80.327 209.692 68.107 209.692C55.887 209.692 46.722 206.966 40.612 201.514C34.596 195.968 31.588 187.32 31.588 175.57V112.12H51.046V175.993ZM173.758 112.12H194.203L171.925 208H135.97L113.692 112.12H134.137L150.775 191.08H157.12L173.758 112.12Z" fill="#2CDE85"/>
</g>
<defs>
<linearGradient id="paint0_linear_674_15" x1="-2.26125e-06" y1="208.5" x2="256" y2="48.5" gradientUnits="userSpaceOnUse">
<stop stop-color="#0F7080"/>
<stop offset="1" stop-color="#01525F"/>
</linearGradient>
<clipPath id="clip0_674_15">
<rect width="256" height="256" fill="white"/>
</clipPath>
</defs>
</svg>
set(TARGET_NAME ${PROJECT_NAME}_test)
find_package(Qt6 REQUIRED COMPONENTS Test Core Quick Gui Multimedia WebSockets)
find_package(Qt6 REQUIRED COMPONENTS Test Core Quick Gui Widgets Multimedia WebSockets)
enable_testing(true)
qt_add_executable(${TARGET_NAME}
tst_settings.cpp tst_settings.h
tst_dsmanager.cpp tst_dsmanager.h
tst_projectmanager.cpp tst_projectmanager.h
mock_ds.cpp mock_ds.h
main.cpp
)
......@@ -12,15 +15,24 @@ add_test(NAME ${TARGET_NAME} COMMAND qtuiviewer_test)
target_link_libraries(
${TARGET_NAME}
PRIVATE
Qt::Test Qt::Core Qt::Quick Qt::Gui Qt::Multimedia Qt::WebSockets
Qt::Test Qt::Core Qt::Quick Qt::Gui Qt::Multimedia Qt::WebSockets Qt::Widgets
qtuiviewerlib
)
qt_add_resources(${TARGET_NAME} "resources"
PREFIX
"/"
FILES
"data/test_project/test_project_success.qmlrc"
"data/test_project/test_project_fail.qmlrc"
)
set_target_properties(${TARGET_NAME} PROPERTIES QT_ANDROID_PACKAGE_NAME "io.qt.qtdesignviewer.test")
set_property(TARGET ${TARGET_NAME}
APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/android
)
set_property(TARGET ${TARGET_NAME} PROPERTY QT_ANDROID_EXTRA_LIBS
${ANDROID_OPENSSL_PATH}/libcrypto_3.so
${ANDROID_OPENSSL_PATH}/libssl_3.so
set_property(TARGET ${TARGET_NAME}
APPEND PROPERTY QT_ANDROID_EXTRA_LIBS
${ANDROID_OPENSSL_PATH}/libcrypto_3.so
${ANDROID_OPENSSL_PATH}/libssl_3.so
)
<?xml version="1.0"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.qt.qtdesignviewer.test"
android:installLocation="auto" android:versionCode="1" android:versionName="1">
<!-- %%INSERT_PERMISSIONS -->
<!-- %%INSERT_FEATURES -->
<supports-screens android:anyDensity="true" android:largeScreens="true"
android:normalScreens="true" android:smallScreens="true" />
<application android:icon="@mipmap/app_icon" android:debuggable="true"
<application android:icon="@mipmap/ic_launcher" android:debuggable="true"
android:name="org.qtproject.qt.android.bindings.QtApplication"
android:extractNativeLibs="true"
android:hardwareAccelerated="true" android:label="Qt UI Viewer Test"
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<group android:scaleX="0.99"
android:scaleY="0.99"
android:translateX="0.54"
android:translateY="0.54">
<path
android:pathData="M0,13.5V108H94.5L108,94.5V0H13.5L0,13.5Z">
<aapt:attr name="android:fillColor">
<gradient
android:startX="104.99"
android:startY="-26.62"
android:endX="11.55"
android:endY="126.08"
android:type="linear">
<item android:offset="0.14" android:color="#FF014B57"/>
<item android:offset="1" android:color="#FF0F7080"/>
</gradient>
</aapt:attr>
</path>
</group>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<group android:scaleX="0.66"
android:scaleY="0.66"
android:translateX="17.37"
android:translateY="17.04">
<group>
<clip-path
android:pathData="M0.25,0.13h107.75v107.75h-107.75z"/>
<path
android:pathData="M28.84,62.54C28.84,67.29 31.25,69.66 36.08,69.66C40.91,69.66 43.33,67.29 43.33,62.54V35.42H51.59V62.36C51.59,67.35 50.29,71.02 47.69,73.37C45.14,75.69 41.27,76.84 36.08,76.84C30.89,76.84 27,75.69 24.41,73.37C21.85,71.02 20.58,67.35 20.58,62.36V35.42H28.84V62.54ZM82.13,35.42H90.81L81.35,76.13H66.09L56.63,35.42H65.31L72.38,68.94H75.07L82.13,35.42Z"
android:fillColor="#2CDE85"/>
</group>
</group>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>
\ No newline at end of file
tests/android/res/mipmap-hdpi/app_icon.png

4.36 KiB

tests/android/res/mipmap-hdpi/ic_launcher.webp

2.04 KiB

tests/android/res/mipmap-hdpi/ic_launcher_round.webp

3.5 KiB

tests/android/res/mipmap-ldpi/app_icon.png

798 B

tests/android/res/mipmap-mdpi/app_icon.png

1.72 KiB

tests/android/res/mipmap-mdpi/ic_launcher.webp

1.4 KiB

tests/android/res/mipmap-mdpi/ic_launcher_round.webp

2.29 KiB

tests/android/res/mipmap-xhdpi/app_icon.png

6.22 KiB

tests/android/res/mipmap-xhdpi/ic_launcher.webp

2.62 KiB

tests/android/res/mipmap-xhdpi/ic_launcher_round.webp

4.84 KiB