From 2dc95622a96b84bb8d2c534c98c1d3c4547c78ec Mon Sep 17 00:00:00 2001 From: alex-z Date: Tue, 12 Sep 2023 12:03:45 +0200 Subject: [PATCH] Customize sync progress ProgressBar. Signed-off-by: alex-z --- src/gui/tray/NCProgressBar.qml | 44 ++++++++++++++++++++++++++++++++++ src/gui/tray/SyncStatus.qml | 26 +------------------- 2 files changed, 45 insertions(+), 25 deletions(-) create mode 100644 src/gui/tray/NCProgressBar.qml diff --git a/src/gui/tray/NCProgressBar.qml b/src/gui/tray/NCProgressBar.qml new file mode 100644 index 0000000000000..920d19ad26f9b --- /dev/null +++ b/src/gui/tray/NCProgressBar.qml @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2021 by Oleksandr Zolotov + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License + * for more details. + */ + +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import Style 1.0 + +ProgressBar { + id: control + + background: Rectangle { + implicitWidth: Style.progressBarWidth + implicitHeight: Style.progressBarBackgroundHeight + radius: Style.progressBarRadius + color: Style.progressBarBackgroundColor + border.color: Style.progressBarBackgroundBorderColor + border.width: Style.progressBarBackgroundBorderWidth + } + + contentItem: Item { + implicitWidth: Style.progressBarWidth + implicitHeight: Style.progressBarContentHeight + + Rectangle { + width: control.visualPosition * parent.width + height: parent.height + radius: Style.progressBarRadius + color: Style.progressBarContentColor + border.color: Style.progressBarContentBorderColor + border.width: Style.progressBarContentBorderWidth + } + } +} diff --git a/src/gui/tray/SyncStatus.qml b/src/gui/tray/SyncStatus.qml index d593ad97d171a..bbec0e4eac0d9 100644 --- a/src/gui/tray/SyncStatus.qml +++ b/src/gui/tray/SyncStatus.qml @@ -66,32 +66,8 @@ RowLayout { active: syncStatus.syncing && syncStatus.totalFiles > 0 visible: active - sourceComponent: ProgressBar { + sourceComponent: NCProgressBar { id: syncProgressBar - - // TODO: Rather than setting all these palette colours manually, - // create a custom style and do it for all components globally. - // - // Additionally, we need to override the entire palette when we - // set one palette property, as otherwise we default back to the - // theme palette -- not the parent palette - palette { - text: Style.ncTextColor - windowText: Style.ncTextColor - buttonText: Style.ncTextColor - brightText: Style.ncTextBrightColor - highlight: Style.lightHover - highlightedText: Style.ncTextColor - light: Style.lightHover - midlight: Style.ncSecondaryTextColor - mid: Style.darkerHover - dark: Style.menuBorder - button: Style.buttonBackgroundColor - window: palette.dark // NOTE: Fusion theme uses darker window colour for the border of the progress bar - base: Style.backgroundColor - toolTipBase: Style.backgroundColor - toolTipText: Style.ncTextColor - } value: syncStatus.syncProgress } }