diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c933383..54338a9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,8 +17,8 @@ on: - develop jobs: - linux-qt5: - uses: lirios/.github/.github/workflows/build-linux-qt5.yml@master + linux-qt6: + uses: lirios/.github/.github/workflows/build-linux-qt6.yml@master with: - dependencies: "solid-devel" - build_dependencies: "cmake-shared qtgsettings libliri aurora-scanner aurora-compositor session" + dependencies: "kf6-solid-devel" + build_dependencies: "cmake-shared qtgsettings libliri session" diff --git a/CMakeLists.txt b/CMakeLists.txt index 9609d8b..8baf395 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10.0) +cmake_minimum_required(VERSION 3.19) project("PowerManager" VERSION "0.9.0" @@ -6,46 +6,44 @@ project("PowerManager" LANGUAGES CXX C ) -## Shared macros and functions: -if(NOT LIRI_LOCAL_ECM) - find_package(LiriCMakeShared "2.0.0" REQUIRED NO_MODULE) - list(APPEND CMAKE_MODULE_PATH "${LCS_MODULE_PATH}") -endif() - -## Set minimum versions required: -set(QT_MIN_VERSION "5.10.0") -set(KF5_MIN_VERSION "5.48.0") - -## Liri specific setup common for all modules: -include(LiriSetup) - ## Only build on the appropriate platforms. if(NOT UNIX OR ANDROID) message(NOTICE "Skipping the build as the condition \"UNIX OR ANDROID\" is not met.") return() endif() +## ECM: +find_package(ECM 5.245.0 REQUIRED NO_MODULE) +list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) + +## Installation directories: +include(KDEInstallDirs) + +## Compiler settings: +set(KDE_SKIP_NULLPTR_WARNINGS_SETTINGS TRUE) +include(KDECompilerSettings NO_POLICY_SCOPE) + +## CMake settings: +include(KDECMakeSettings) + +## QML module: +include(ECMQmlModule) + +## Disable use of C++ API deprecated in Qt 5.15 +add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00) + +## Features: +include(features.cmake) + ## Features: option(LIRI_ENABLE_SYSTEMD "Enable systemd support" ON) add_feature_info("Liri::Systemd" LIRI_ENABLE_SYSTEMD "Enable systemd support") ## Variables: if(LIRI_ENABLE_SYSTEMD) - set(INSTALL_SYSTEMDUSERUNITDIR "${INSTALL_LIBDIR}/systemd/user" CACHE PATH "systemd user unit directory [PREFIX/lib/systemd/user]") + set(INSTALL_SYSTEMDUSERUNITDIR "${KDE_INSTALL_LIBDIR}/systemd/user" CACHE PATH "systemd user unit directory [PREFIX/lib/systemd/user]") endif() -## Find Qt 5: -find_package(Qt5 "${QT_MIN_VERSION}" - CONFIG REQUIRED - COMPONENTS - Core - DBus - Gui - Qml - Quick - LinguistTools -) - ## Add subdirectories: add_subdirectory(data/settings) if(LIRI_ENABLE_SYSTEMD) @@ -54,4 +52,4 @@ endif() add_subdirectory(src/imports/power) add_subdirectory(src/daemon) add_subdirectory(src/settings/power) -add_subdirectory(src/statusarea/power) +#add_subdirectory(src/statusarea/power) diff --git a/README.md b/README.md index d542044..873a186 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Power management support for Liri. ## Dependencies -Qt >= 5.10.0 with at least the following modules is required: +Qt >= 6.7 with at least the following modules is required: * [qtbase](http://code.qt.io/cgit/qt/qtbase.git) * [qtdeclarative](http://code.qt.io/cgit/qt/qtdeclarative.git) @@ -23,8 +23,8 @@ The following modules and their dependencies are required: * [cmake](https://gitlab.kitware.com/cmake/cmake) >= 3.10.0 * [cmake-shared](https://github.com/lirios/cmake-shared.git) >= 1.0.0 - * [fluid](https://github.com/lirios/fluid) >= 1.0.0 - * [qtgsettings](https://github.com/lirios/qtgsettings) >= 1.1.0 + * [fluid](https://github.com/lirios/fluid) >= 2.0.0 + * [qtgsettings](https://github.com/lirios/qtgsettings) >= 2.0.0 * [libliri](https://github.com/lirios/libliri.git) * [solid](http://quickgit.kde.org/?p=solid.git) diff --git a/data/settings/CMakeLists.txt b/data/settings/CMakeLists.txt index f547a28..381aa10 100644 --- a/data/settings/CMakeLists.txt +++ b/data/settings/CMakeLists.txt @@ -1,2 +1,2 @@ file(GLOB _files "*.xml") -install(FILES ${_files} DESTINATION "${INSTALL_DATADIR}/glib-2.0/schemas") +install(FILES ${_files} DESTINATION "${KDE_INSTALL_DATADIR}/glib-2.0/schemas") diff --git a/data/systemd/CMakeLists.txt b/data/systemd/CMakeLists.txt index 3e8f7f2..b53372d 100644 --- a/data/systemd/CMakeLists.txt +++ b/data/systemd/CMakeLists.txt @@ -1,8 +1,4 @@ -if(IS_ABSOLUTE "${INSTALL_LIBEXECDIR}") - set(ABSOLUTE_LIBEXECDIR "${INSTALL_LIBEXECDIR}") -else() - set(ABSOLUTE_LIBEXECDIR "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBEXECDIR}") -endif() +set(LIBEXECDIR "${KDE_INSTALL_LIBEXECDIR}") configure_file( "liri-daemon-power.service.in" "${CMAKE_CURRENT_BINARY_DIR}/liri-daemon-power.service" diff --git a/data/systemd/liri-daemon-power.service.in b/data/systemd/liri-daemon-power.service.in index b57f2eb..2b7079c 100644 --- a/data/systemd/liri-daemon-power.service.in +++ b/data/systemd/liri-daemon-power.service.in @@ -4,6 +4,6 @@ PartOf=liri-daemons.target [Service] Type=dbus -ExecStart=@ABSOLUTE_LIBEXECDIR@/liri-daemon --module=power +ExecStart=@LIBEXECDIR@/liri-daemon --module=power BusName=io.liri.Daemon.Modules.Power Restart=on-failure diff --git a/features.cmake b/features.cmake new file mode 100644 index 0000000..d4b423c --- /dev/null +++ b/features.cmake @@ -0,0 +1,34 @@ +# SPDX-FileCopyrightText: 2024 Pier Luigi Fiorini +# SPDX-License-Identifier: BSD-3-Clause + +## Enable feature summary at the end of the configure run: +include(FeatureSummary) + +## Set minimum versions required: +set(QT_MIN_VERSION "6.7.0") +set(KF6_MIN_VERSION "6.1.0") + +## Find Qt: +find_package(Qt6 "${QT_MIN_VERSION}" + REQUIRED + COMPONENTS + Core + DBus + Gui + Qml + Quick + LinguistTools +) + +# Find Solid: +find_package(KF6Solid "${KF6_MIN_VERSION}" REQUIRED) + +#### Features + +option(LIRI_ENABLE_SYSTEMD "Enable systemd support" ON) +add_feature_info("Liri::Systemd" LIRI_ENABLE_SYSTEMD "Enable systemd support") + +## Features summary: +if(NOT LIRI_SUPERBUILD) + feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES) +endif() diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index c1634f6..7f87020 100644 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -1,7 +1,5 @@ -find_package(KF5Solid "${KF5_MIN_VERSION}" REQUIRED) - -if(NOT TARGET Liri::Qt5GSettings) - find_package(Qt5GSettings REQUIRED) +if(NOT TARGET Liri::Qt6GSettings) + find_package(Qt6GSettings REQUIRED) endif() if(NOT TARGET Liri::Core) find_package(Liri1Core REQUIRED) @@ -16,40 +14,47 @@ if(NOT TARGET Liri::Daemon) find_package(Liri1Daemon REQUIRED) endif() -# Translations -file(GLOB LiriPowerManager_TRANSLATIONS "${CMAKE_CURRENT_SOURCE_DIR}/../../translations/daemon/*_*.ts") -qt5_add_translation(LiriPowerManager_QM_FILES ${LiriPowerManager_TRANSLATIONS}) -install(FILES ${LiriPowerManager_QM_FILES} - DESTINATION "${INSTALL_DATADIR}/liri-power-manager/translations") +qt_add_plugin(LiriDaemonPowerPlugin + CLASS_NAME PowerPlugin + MANUAL_FINALIZATION + batterywatcher.cpp batterywatcher.h + idlewatcher.cpp idlewatcher.h + lidwatcher.cpp lidwatcher.h + plugin.cpp plugin.h + powermanager.cpp powermanager.h + translation.cpp translation.h +) -liri_add_plugin(power - TYPE - liri/daemon - SOURCES - batterywatcher.cpp - batterywatcher.h - idlewatcher.cpp - idlewatcher.h - lidwatcher.cpp - lidwatcher.h - plugin.cpp - plugin.h - powermanager.cpp - powermanager.h - translation.cpp - translation.h - ${LiriPowerManager_QM_FILES} - DEFINES +set_target_properties(LiriDaemonPowerPlugin PROPERTIES + OUTPUT_NAME power +) + +target_compile_definitions(LiriDaemonPowerPlugin + PRIVATE QT_NO_CAST_FROM_ASCII QT_NO_FOREACH - LIBRARIES - Qt5::DBus +) + +target_link_libraries(LiriDaemonPowerPlugin + PRIVATE + Qt6::Core + Qt6::DBus Liri::Daemon - Liri::Qt5GSettings + Liri::Qt6GSettings Liri::Core Liri::LocalDevice Liri::Notifications - KF5::Solid + KF6::Solid ) -liri_finalize_plugin(power) +qt_finalize_target(LiriDaemonPowerPlugin) + +file(GLOB ts_files "${CMAKE_CURRENT_SOURCE_DIR}/../../translations/daemon/liri-power-manager_*.ts") +qt_add_translations(LiriDaemonPowerPlugin + TS_FILES ${ts_files} +) + +install( + TARGETS LiriDaemonPowerPlugin + DESTINATION ${KDE_INSTALL_PLUGINDIR}/liri/daemon +) diff --git a/src/daemon/powermanager.h b/src/daemon/powermanager.h index cdddfd1..6e7ad15 100644 --- a/src/daemon/powermanager.h +++ b/src/daemon/powermanager.h @@ -25,7 +25,7 @@ #include -#include +#include class PowerManager : public QObject { diff --git a/src/daemon/translation.cpp b/src/daemon/translation.cpp index 054cc44..894e60e 100644 --- a/src/daemon/translation.cpp +++ b/src/daemon/translation.cpp @@ -46,16 +46,9 @@ void loadDaemonTranslations() #ifndef QT_NO_TRANSLATION QString locale = QLocale::system().name(); - // Find the translations directory - const QString path = QLatin1String("liri-power-manager/translations"); - const QString translationsDir = - QStandardPaths::locate(QStandardPaths::GenericDataLocation, - path, - QStandardPaths::LocateDirectory); - // Load translations QTranslator *appTranslator = new QTranslator(QCoreApplication::instance()); - if (appTranslator->load(QStringLiteral("%1/liri-power-manager_%2").arg(translationsDir, locale))) { + if (appTranslator->load(QStringLiteral(":/i18n/liri-power-manager_%1").arg(locale))) { QCoreApplication::installTranslator(appTranslator); } else if (locale == QLatin1String("C") || locale.startsWith(QLatin1String("en"))) { diff --git a/src/imports/power/CMakeLists.txt b/src/imports/power/CMakeLists.txt index 6311d06..8da66d2 100644 --- a/src/imports/power/CMakeLists.txt +++ b/src/imports/power/CMakeLists.txt @@ -1,30 +1,32 @@ -find_package(KF5Solid "${KF5_MIN_VERSION}" REQUIRED) - if(NOT TARGET Liri::Core) find_package(Liri1Core REQUIRED) endif() -liri_add_qml_plugin(PowerQmlPlugin - MODULE_PATH - "Liri/Power" - VERSION - "1.0" - OUTPUT_NAME - "powerplugin" - SOURCES - batteriesmodel.cpp - batteriesmodel.h - battery.cpp - battery.h - plugin.cpp - QML_FILES - qmldir - DEFINES +ecm_add_qml_module(PowerQmlPlugin + URI Liri.Power + VERSION 1.0 + CLASS_NAME PowerPlugin + DEPENDENCIES QtQuick +) + +target_sources(PowerQmlPlugin + PRIVATE + batteriesmodel.cpp batteriesmodel.h + battery.cpp battery.h +) + +target_compile_definitions(PowerQmlPlugin + PRIVATE QT_NO_CAST_FROM_ASCII QT_NO_FOREACH - LIBRARIES +) + +target_link_libraries(PowerQmlPlugin + PRIVATE + Qt6::Core + Qt6::Qml Liri::Core - KF5::Solid + KF6::Solid ) -liri_finalize_qml_plugin(PowerQmlPlugin) +ecm_finalize_qml_module(PowerQmlPlugin) diff --git a/src/imports/power/batteriesmodel.cpp b/src/imports/power/batteriesmodel.cpp index 1bb4d57..505c849 100644 --- a/src/imports/power/batteriesmodel.cpp +++ b/src/imports/power/batteriesmodel.cpp @@ -84,7 +84,7 @@ BatteriesModel::BatteriesModel(QObject *parent) Battery *BatteriesModel::primaryBattery() const { - for (auto battery : qAsConst(m_batteries)) { + for (auto battery : std::as_const(m_batteries)) { if (battery->type() == Battery::PrimaryBattery) return battery; } @@ -115,9 +115,6 @@ QHash BatteriesModel::roleNames() const roles.insert(EnergyRateRole, QByteArrayLiteral("energyRate")); roles.insert(VoltageRole, QByteArrayLiteral("voltage")); roles.insert(TemperatureRole, QByteArrayLiteral("temperature")); - roles.insert(IsRecalledRole, QByteArrayLiteral("isRecalled")); - roles.insert(RecallVendorRole, QByteArrayLiteral("recallVendor")); - roles.insert(RecallUrlRole, QByteArrayLiteral("recallUrl")); roles.insert(VendorRole, QByteArrayLiteral("vendor")); roles.insert(ProductRole, QByteArrayLiteral("product")); roles.insert(SerialRole, QByteArrayLiteral("serial")); @@ -142,7 +139,7 @@ QVariant BatteriesModel::data(const QModelIndex &index, int role) const switch (role) { case BatteryRole: - return qVariantFromValue(battery); + return QVariant::fromValue(battery); case UdiRole: return battery->udi(); case NameRole: @@ -182,14 +179,8 @@ QVariant BatteriesModel::data(const QModelIndex &index, int role) const return battery->voltage(); case TemperatureRole: return battery->temperature(); - case IsRecalledRole: - return battery->isRecalled(); - case RecallVendorRole: - return battery->recallVendor(); - case RecallUrlRole: - return battery->recallUrl(); case VendorRole: - return battery->recallVendor(); + return battery->vendor(); case ProductRole: return battery->product(); case SerialRole: @@ -198,3 +189,5 @@ QVariant BatteriesModel::data(const QModelIndex &index, int role) const return QVariant(); } + +#include "moc_batteriesmodel.cpp" diff --git a/src/imports/power/batteriesmodel.h b/src/imports/power/batteriesmodel.h index 36874f9..7496c78 100644 --- a/src/imports/power/batteriesmodel.h +++ b/src/imports/power/batteriesmodel.h @@ -25,6 +25,7 @@ #define BATTERIESMODEL_H #include +#include class Battery; @@ -33,6 +34,8 @@ class BatteriesModel : public QAbstractListModel Q_OBJECT Q_PROPERTY(Battery *primaryBattery READ primaryBattery NOTIFY primaryBatteryChanged) Q_PROPERTY(int count READ rowCount NOTIFY countChanged) + QML_ELEMENT + Q_MOC_INCLUDE("batteriesmodel.h") public: enum Roles { BatteryRole = Qt::UserRole + 1, @@ -55,9 +58,6 @@ class BatteriesModel : public QAbstractListModel EnergyRateRole, VoltageRole, TemperatureRole, - IsRecalledRole, - RecallVendorRole, - RecallUrlRole, VendorRole, ProductRole, SerialRole diff --git a/src/imports/power/battery.cpp b/src/imports/power/battery.cpp index 8fc6204..17f39ba 100644 --- a/src/imports/power/battery.cpp +++ b/src/imports/power/battery.cpp @@ -132,21 +132,6 @@ double Battery::temperature() const return m_battery->temperature(); } -bool Battery::isRecalled() const -{ - return m_battery->isRecalled(); -} - -QString Battery::recallVendor() const -{ - return m_battery->recallVendor(); -} - -QUrl Battery::recallUrl() const -{ - return QUrl(m_battery->recallUrl()); -} - QString Battery::vendor() const { return m_device.vendor(); diff --git a/src/imports/power/battery.h b/src/imports/power/battery.h index c3b1952..e25f59b 100644 --- a/src/imports/power/battery.h +++ b/src/imports/power/battery.h @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -54,12 +55,12 @@ class Battery : public QObject Q_PROPERTY(double energyRate READ energyRate NOTIFY energyRateChanged) Q_PROPERTY(double voltage READ voltage NOTIFY voltageChanged) Q_PROPERTY(double temperature READ temperature NOTIFY temperatureChanged) - Q_PROPERTY(bool recalled READ isRecalled CONSTANT) - Q_PROPERTY(QString recallVendor READ recallVendor CONSTANT) - Q_PROPERTY(QUrl recallUrl READ recallUrl CONSTANT) Q_PROPERTY(QString vendor READ vendor CONSTANT) Q_PROPERTY(QString product READ product CONSTANT) Q_PROPERTY(QString serial READ serial CONSTANT) + QML_ELEMENT + QML_UNCREATABLE("Cannot create Battery object") + Q_MOC_INCLUDE("battery.h") public: enum Type { UnknownBattery, @@ -117,10 +118,6 @@ class Battery : public QObject double temperature() const; - bool isRecalled() const; - QString recallVendor() const; - QUrl recallUrl() const; - QString vendor() const; QString product() const; diff --git a/src/imports/power/plugin.cpp b/src/imports/power/plugin.cpp deleted file mode 100644 index c94fd0b..0000000 --- a/src/imports/power/plugin.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** - * This file is part of Liri. - * - * Copyright (C) 2018 Pier Luigi Fiorini - * - * $BEGIN_LICENSE:LGPLv3+$ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - * - * $END_LICENSE$ - ***************************************************************************/ - -#include - -#include "batteriesmodel.h" -#include "battery.h" - -class PowerPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") -public: - void registerTypes(const char *uri) - { - // @uri Liri.Power - Q_ASSERT(QLatin1String(uri) == QLatin1String("Liri.Power")); - - qmlRegisterType(uri, 1, 0, "BatteriesModel"); - qmlRegisterUncreatableType(uri, 1, 0, "Battery", - QStringLiteral("Cannot create Battery object")); - } -}; - -#include "plugin.moc" diff --git a/src/imports/power/plugins.qmltypes b/src/imports/power/plugins.qmltypes deleted file mode 100644 index d27f908..0000000 --- a/src/imports/power/plugins.qmltypes +++ /dev/null @@ -1,87 +0,0 @@ -import QtQuick.tooling 1.2 - -// This file describes the plugin-supplied types contained in the library. -// It is used for QML tooling purposes only. -// -// This file was auto-generated by: -// 'qmlplugindump -v -noinstantiate -notrelocatable Liri.Power 1.0' - -Module { - dependencies: ["QtQuick 2.8"] - Component { - name: "BatteriesModel" - prototype: "QAbstractListModel" - exports: ["Liri.Power/BatteriesModel 1.0"] - exportMetaObjectRevisions: [0] - Property { name: "primaryBattery"; type: "Battery"; isReadonly: true; isPointer: true } - Property { name: "count"; type: "int"; isReadonly: true } - } - Component { - name: "Battery" - prototype: "QObject" - exports: ["Liri.Power/Battery 1.0"] - isCreatable: false - exportMetaObjectRevisions: [0] - Enum { - name: "Type" - values: { - "UnknownBattery": 0, - "PdaBattery": 1, - "UpsBattery": 2, - "PrimaryBattery": 3, - "MouseBattery": 4, - "KeyboardBattery": 5, - "KeyboardMouseBattery": 6, - "CameraBattery": 7, - "PhoneBattery": 8, - "MonitorBattery": 9 - } - } - Enum { - name: "Technology" - values: { - "UnknownTechnology": 0, - "LithiumIon": 1, - "LithiumPolymer": 2, - "LithiumIronPhosphate": 3, - "LeadAcid": 4, - "NickelCadmium": 5, - "NickelMetalHydride": 6 - } - } - Enum { - name: "ChargeState" - values: { - "Stable": 0, - "Charging": 1, - "Discharging": 2, - "FullyCharged": 3 - } - } - Property { name: "udi"; type: "string"; isReadonly: true } - Property { name: "name"; type: "string"; isReadonly: true } - Property { name: "summary"; type: "string"; isReadonly: true } - Property { name: "iconName"; type: "string"; isReadonly: true } - Property { name: "chargeIconName"; type: "string"; isReadonly: true } - Property { name: "type"; type: "Type"; isReadonly: true } - Property { name: "mouse"; type: "bool"; isReadonly: true } - Property { name: "technology"; type: "Technology"; isReadonly: true } - Property { name: "chargePercent"; type: "int"; isReadonly: true } - Property { name: "capacity"; type: "int"; isReadonly: true } - Property { name: "rechargeable"; type: "bool"; isReadonly: true } - Property { name: "powerSupply"; type: "bool"; isReadonly: true } - Property { name: "chargeState"; type: "ChargeState"; isReadonly: true } - Property { name: "timeToEmpty"; type: "qlonglong"; isReadonly: true } - Property { name: "timeToFull"; type: "qlonglong"; isReadonly: true } - Property { name: "energy"; type: "double"; isReadonly: true } - Property { name: "energyRate"; type: "double"; isReadonly: true } - Property { name: "voltage"; type: "double"; isReadonly: true } - Property { name: "temperature"; type: "double"; isReadonly: true } - Property { name: "recalled"; type: "bool"; isReadonly: true } - Property { name: "recallVendor"; type: "string"; isReadonly: true } - Property { name: "recallUrl"; type: "QUrl"; isReadonly: true } - Property { name: "vendor"; type: "string"; isReadonly: true } - Property { name: "product"; type: "string"; isReadonly: true } - Property { name: "serial"; type: "string"; isReadonly: true } - } -} diff --git a/src/imports/power/qmldir b/src/imports/power/qmldir deleted file mode 100644 index ec85883..0000000 --- a/src/imports/power/qmldir +++ /dev/null @@ -1,4 +0,0 @@ -module Liri.Power -plugin powerplugin -classname PowerPlugin -typeinfo plugins.qmltypes diff --git a/src/settings/power/contents/AutomaticSuspendDialog.qml b/src/settings/power/contents/AutomaticSuspendDialog.qml index afd7af3..83e96c8 100644 --- a/src/settings/power/contents/AutomaticSuspendDialog.qml +++ b/src/settings/power/contents/AutomaticSuspendDialog.qml @@ -21,12 +21,11 @@ * $END_LICENSE$ ***************************************************************************/ -import QtQuick 2.1 -import QtQuick.Layouts 1.0 -import QtQuick.Controls 2.1 -import Fluid.Controls 1.0 as FluidControls +import QtQuick +import QtQuick.Layouts +import Fluid as Fluid -Dialog { +Fluid.Dialog { readonly property bool __hasBatteries: batteriesModel.count > 0 parent: window.contentItem @@ -44,13 +43,13 @@ Dialog { // Row 1 - Label { + Fluid.Label { id: batteryLabel text: qsTr("On Battery Power") visible: __hasBatteries } - Switch { + Fluid.Switch { id: batterySwitch checked: powerSettings.sleepInactiveBatteryType !== "nothing" visible: __hasBatteries @@ -70,7 +69,7 @@ Dialog { Layout.minimumWidth: batteryLabel.width + FluidControls.Units.gu(2) } - Label { + Fluid.Label { enabled: batterySwitch.checked text: qsTr("Delay") visible: __hasBatteries @@ -78,7 +77,7 @@ Dialog { Layout.alignment: Qt.AlignRight } - ComboBox { + Fluid.ComboBox { textRole: "text" enabled: batterySwitch.checked visible: __hasBatteries @@ -124,12 +123,12 @@ Dialog { // Row 3 - Label { + Fluid.Label { id: acLabel text: __hasBatteries ? qsTr("Plugged In") : qsTr("When idle") } - Switch { + Fluid.Switch { id: acSwitch checked: powerSettings.sleepInactiveAcType !== "nothing" onCheckedChanged: { @@ -146,14 +145,14 @@ Dialog { Layout.minimumWidth: acLabel.width + FluidControls.Units.gu(2) } - Label { + Fluid.Label { enabled: acSwitch.checked text: qsTr("Delay") Layout.alignment: Qt.AlignRight } - ComboBox { + Fluid.ComboBox { textRole: "text" enabled: acSwitch.checked model: ListModel { diff --git a/src/settings/power/contents/BatteryListItem.qml b/src/settings/power/contents/BatteryListItem.qml index f52bfb2..97a2f72 100644 --- a/src/settings/power/contents/BatteryListItem.qml +++ b/src/settings/power/contents/BatteryListItem.qml @@ -21,19 +21,18 @@ * $END_LICENSE$ ***************************************************************************/ -import QtQuick 2.1 -import QtQuick.Layouts 1.0 -import QtQuick.Controls 2.0 -import Fluid.Controls 1.0 -import Liri.Power 1.0 +import QtQuick +import QtQuick.Layouts +import Fluid as Fluid +import Liri.Power -ListItem { +Fluid.ListItem { property Battery battery text: battery.summary valueText: qsTr("%1%").arg(battery.chargePercent) - secondaryItem: ProgressBar { + secondaryItem: Fluid.ProgressBar { anchors { left: parent.left right: parent.right diff --git a/src/settings/power/contents/main.qml b/src/settings/power/contents/main.qml index 7717984..c999c15 100644 --- a/src/settings/power/contents/main.qml +++ b/src/settings/power/contents/main.qml @@ -21,15 +21,14 @@ * $END_LICENSE$ ***************************************************************************/ -import QtQuick 2.1 -import QtQuick.Layouts 1.0 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.2 -import Fluid.Controls 1.0 as FluidControls -import Liri.Settings 1.0 -import Liri.Power 1.0 -import Liri.Device 1.0 -import QtGSettings 1.0 +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls.Material +import Fluid as Fluid +import Liri.Settings +import Liri.Power +import Liri.Device +import QtGSettings ModulePage { id: page @@ -56,7 +55,7 @@ ModulePage { id: automaticSuspendDialog } - ScrollView { + Fluid.ScrollView { anchors.fill: parent clip: true @@ -77,9 +76,9 @@ ModulePage { title: qsTr("Power Saving") width: page.width - FluidControls.ListItem { + Fluid.ListItem { text: qsTr("Screen brightness") - secondaryItem: Slider { + secondaryItem: Fluid.Slider { anchors.verticalCenter: parent.verticalCenter width: parent.width from: 0 @@ -89,9 +88,9 @@ ModulePage { visible: false } - FluidControls.ListItem { + Fluid.ListItem { text: qsTr("Keyboard brightness") - secondaryItem: Slider { + secondaryItem: Fluid.Slider { anchors.verticalCenter: parent.verticalCenter width: parent.width from: 0 @@ -101,9 +100,9 @@ ModulePage { visible: false } - FluidControls.ListItem { + Fluid.ListItem { text: qsTr("Dim screen when inactive") - rightItem: Switch { + rightItem: Fluid.Switch { anchors.centerIn: parent checked: powerSettings.idleDim onCheckedChanged: powerSettings.idleDim = checked @@ -111,11 +110,11 @@ ModulePage { visible: batteriesModel.count > 0 } - FluidControls.ListItem { + Fluid.ListItem { text: qsTr("Blank screen") - rightItem: ComboBox { + rightItem: Fluid.ComboBox { anchors.centerIn: parent - width: FluidControls.Units.gu(6) + width: Fluid.Units.gu(6) textRole: "text" model: ListModel { ListElement { text: QT_TR_NOOP("1 minute"); value: 60 } @@ -159,20 +158,20 @@ ModulePage { } } - FluidControls.ListItem { + Fluid.ListItem { text: qsTr("Wi-Fi") subText: qsTr("Turn off Wi-Fi to save power") - rightItem: Switch { + rightItem: Fluid.Switch { anchors.centerIn: parent checked: true } visible: false } - FluidControls.ListItem { + Fluid.ListItem { text: qsTr("Bluetooth") subText: qsTr("Turn off Bluetooth to save power") - rightItem: Switch { + rightItem: Fluid.Switch { anchors.centerIn: parent checked: true } @@ -184,9 +183,9 @@ ModulePage { title: qsTr("Suspend & Power Button") width: page.width - FluidControls.ListItem { + Fluid.ListItem { text: qsTr("Automatic suspend") - rightItem: FluidControls.BodyLabel { + rightItem: Fluid.BodyLabel { anchors.centerIn: parent text: { var batteryOn = powerSettings.sleepInactiveBatteryType === "suspend"; @@ -210,9 +209,9 @@ ModulePage { onClicked: automaticSuspendDialog.open() } - FluidControls.ListItem { + Fluid.ListItem { text: qsTr("When the Power Button is pressed") - rightItem: ComboBox { + rightItem: Fluid.ComboBox { anchors.centerIn: parent textRole: "text" model: ListModel { @@ -242,9 +241,9 @@ ModulePage { } } - FluidControls.ListItem { + Fluid.ListItem { text: qsTr("When the lid is closed") - rightItem: ComboBox { + rightItem: Fluid.ComboBox { anchors.centerIn: parent textRole: "text" model: ListModel { diff --git a/src/statusarea/power/contents/BatteryEntry.qml b/src/statusarea/power/contents/BatteryEntry.qml index 6aa56db..9f241a6 100644 --- a/src/statusarea/power/contents/BatteryEntry.qml +++ b/src/statusarea/power/contents/BatteryEntry.qml @@ -2,20 +2,20 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -import QtQuick 2.15 -import QtQuick.Layouts 1.15 -import QtQuick.Controls 2.15 -import Fluid.Controls 1.0 as FluidControls -import Liri.Power 1.0 +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls +import Fluid as Fluid +import Liri.Power -FluidControls.ListItem { +Fluid.ListItem { property var battery - icon.source: FluidControls.Utils.iconUrl(battery.iconName) + icon.source: Fluid.Utils.iconUrl(battery.iconName) text: battery.summary valueText: qsTr("%1%").arg(battery.chargePercent) - secondaryItem: ProgressBar { + secondaryItem: Fluid.ProgressBar { from: 0 to: 100 value: battery.chargePercent diff --git a/src/statusarea/power/contents/main.qml b/src/statusarea/power/contents/main.qml index 5c0f567..4de8290 100644 --- a/src/statusarea/power/contents/main.qml +++ b/src/statusarea/power/contents/main.qml @@ -2,12 +2,11 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -import QtQuick 2.15 -import QtQuick.Layouts 1.15 -import QtQuick.Controls 2.15 -import Fluid.Controls 1.0 as FluidControls -import Liri.Shell 1.0 as Shell -import Liri.Power 1.0 as Power +import QtQuick +import QtQuick.Layouts +import Fluid as Fluid +import Liri.Shell as Shell +import Liri.Power as Power Shell.StatusAreaExtension { property string powerIconName: batteriesModel.primaryBattery ? batteriesModel.primaryBattery.chargeIconName : "device/battery_unknown" @@ -19,17 +18,17 @@ Shell.StatusAreaExtension { Component { id: pageComponent - Page { + Fluid.Page { padding: 0 header: RowLayout { - ToolButton { - icon.source: FluidControls.Utils.iconUrl("navigation/arrow_back") + Fluid.ToolButton { + icon.source: Fluid.Utils.iconUrl("navigation/arrow_back") onClicked: { popFromMenu(); } } - FluidControls.TitleLabel { + Fluid.TitleLabel { text: qsTr("Power") Layout.alignment: Qt.AlignVCenter @@ -37,11 +36,11 @@ Shell.StatusAreaExtension { } } - ScrollView { + Fluid.ScrollView { anchors.fill: parent clip: true - ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + Fluid.ScrollBar.horizontal.policy: Fluid.ScrollBar.AlwaysOff ListView { model: batteriesModel @@ -56,12 +55,12 @@ Shell.StatusAreaExtension { indicator: Shell.Indicator { title: qsTr("Power") - iconSource: FluidControls.Utils.iconUrl(powerIconName) + iconSource: Fluid.Utils.iconUrl(powerIconName) visible: batteriesModel.count > 0 } - menu: FluidControls.ListItem { - icon.source: FluidControls.Utils.iconUrl(powerIconName) + menu: Fluid.ListItem { + icon.source: Fluid.Utils.iconUrl(powerIconName) text: qsTr("Power") visible: batteriesModel.count > 0 onClicked: {