Skip to content

Commit

Permalink
Important colors can now be set by the user; refactored quick setting…
Browse files Browse the repository at this point in the history
…s manager
  • Loading branch information
PhilInTheGaps committed Nov 13, 2023
1 parent 617e662 commit daa4f22
Show file tree
Hide file tree
Showing 93 changed files with 1,193 additions and 729 deletions.
2 changes: 1 addition & 1 deletion .qmllint.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ControlsSanity=disable
Deprecated=warning
DuplicatePropertyBinding=warning
DuplicatedName=warning
ImportFailure=warning
ImportFailure=info
IncompatibleType=warning
InheritanceCycle=warning
InvalidLintDirective=warning
Expand Down
10 changes: 6 additions & 4 deletions app/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "filesystem/file.h"
#include "logger.h"
#include "services/nextcloud/nextcloud.h"
#include "settings/quicksettingsmanager.h"
#include "settings/quick/settingsmanager.h"
#include "tools/audio/thumbnails/audiothumbnailprovider.h"
#include "updates/version.h"
#include <QFontDatabase>
Expand All @@ -20,6 +20,7 @@
#include <thirdparty/sentry-native/include/sentry.h>

using namespace Qt::Literals::StringLiterals;
using namespace Common::Settings;

Q_LOGGING_CATEGORY(gmMain, "gm.main")

Expand Down Expand Up @@ -54,7 +55,7 @@ void initTranslations(QTranslator &translator, QQmlEngine &engine)

updateTranslation(translator);

QObject::connect(QuickSettingsManager::instance(), &QuickSettingsManager::languageChanged, &translator,
QObject::connect(Quick::SettingsManager::instance(), &Quick::SettingsManager::languageChanged, &translator,
[&translator, &engine]() {
updateTranslation(translator);
engine.retranslate();
Expand All @@ -75,9 +76,10 @@ void setPalette()
palette.setColor(QPalette::ColorRole::AlternateBase, "#343a43"_L1);
palette.setColor(QPalette::ColorRole::Window, "#2e2e2e"_L1);
palette.setColor(QPalette::ColorRole::WindowText, "#f6f7f8"_L1);
palette.setColor(QPalette::ColorRole::Button, "#8f9aa9"_L1); // 3f4957
palette.setColor(QPalette::ColorRole::Button, "#8f9aa9"_L1);
palette.setColor(QPalette::ColorRole::ButtonText, "#f6f7f8"_L1);
palette.setColor(QPalette::ColorRole::Light, "#ebedef"_L1);
palette.setColor(QPalette::ColorRole::Light,
"#1f1f1f"_L1); // same a dark so that qt dialogs still look ok, was #ebedef before
palette.setColor(QPalette::ColorRole::Midlight, "#d5dade"_L1);
palette.setColor(QPalette::ColorRole::Mid, "#bfc6cd"_L1);
palette.setColor(QPalette::ColorRole::Dark, "#1f1f1f"_L1);
Expand Down
6 changes: 5 additions & 1 deletion app/ui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ qt_add_qml_module(gm-companion-ui
src
OPTIONAL_IMPORTS
Style
DEPENDENCIES
QtQuick
QML_FILES
Main.qml
Sizes.qml
Expand Down Expand Up @@ -168,4 +170,6 @@ target_link_libraries(gm-companion-ui
common
commonplugin
qml-icon-fonts
qml-icon-fontsplugin)
qml-icon-fontsplugin
Qt6::Qml
Qt6::Quick)
1 change: 1 addition & 0 deletions app/ui/CustomComponents/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ qt_add_qml_module(gm-companion-ui-cc
QML_FILES
CustomButton.qml
CustomComboBox.qml
CustomColorButton.qml
CustomMenuItem.qml
CustomRadioButton.qml
CustomScrollLabel.qml
Expand Down
37 changes: 37 additions & 0 deletions app/ui/CustomComponents/CustomColorButton.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import QtQuick
import IconFonts

Rectangle {
id: root

property bool enableReset: false

signal clicked
signal resetClicked

implicitWidth: 100
implicitHeight: 40

color: "blue"

border.width: mouse_area.containsMouse ? 1 : 0
border.color: mouse_area.pressed ? CCColors.buttonPressed : palette.button

MouseArea {
id: mouse_area
anchors.fill: parent
hoverEnabled: true

onClicked: root.clicked()
}

CustomButton {
visible: root.enableReset
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom

iconText: FontAwesome.rotateLeft
onClicked: root.resetClicked()
}
}
3 changes: 2 additions & 1 deletion app/ui/CustomComponents/CustomToolBar.qml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import QtQuick
import IconFonts
import common

Rectangle {
id: root
Expand Down Expand Up @@ -62,7 +63,7 @@ Rectangle {
Text {
visible: !root.isSaved
text: FontAwesome.asterisk
color: "darkred"
color: SettingsManager.colors.error
font.family: FontAwesome.fontSolid.family
font.styleName: FontAwesome.fontSolid.styleName
anchors.right: parent.right
Expand Down
25 changes: 11 additions & 14 deletions app/ui/Main.qml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pragma ComponentBehavior: Bound

import QtQuick
import QtQuick.Controls
import IconFonts
Expand Down Expand Up @@ -62,7 +61,7 @@ ApplicationWindow {
target: UpdateManager

function onUpdateAvailable() {
update_dialog.open()
update_dialog.open();
}
}

Expand All @@ -76,12 +75,11 @@ ApplicationWindow {

Component.onCompleted: {
if (SettingsManager.checkForUpdates) {
UpdateManager.checkForUpdates()
UpdateManager.checkForUpdates();
}

if (!SettingsManager.has("crashReports", "Telemetry")) {
console.debug("CrashReports preference has not been set.")
new_settings_dialog.open()
console.debug("CrashReports preference has not been set.");
new_settings_dialog.open();
}
}

Expand Down Expand Up @@ -143,7 +141,7 @@ ApplicationWindow {
onClicked: setTool()

function setTool() {
root.currentToolIndex = index
root.currentToolIndex = index;
}
}
}
Expand All @@ -156,17 +154,17 @@ ApplicationWindow {

toolName: qsTr("Messages")
faIcon: FontAwesome.circleExclamation
altColor: "orange"
altColor: SettingsManager.colors.warning
useAltColor: MessageManager.hasNewErrors

visible: message_dialog.hasMessages

onClicked: {
if (message_dialog.opened) {
message_dialog.close()
message_dialog.close();
} else {
message_dialog.open()
MessageManager.markAllAsRead()
message_dialog.open();
MessageManager.markAllAsRead();
}
}
}
Expand All @@ -179,7 +177,7 @@ ApplicationWindow {
faIcon: FontAwesome.gear

onClicked: {
root.currentToolIndex = -1
root.currentToolIndex = -1;
}
}
}
Expand All @@ -191,8 +189,7 @@ ApplicationWindow {
anchors.bottom: parent.bottom
anchors.right: parent.right
asynchronous: true
source: root.currentToolIndex
< 0 ? "tools/Settings.qml" : root.tools[root.currentToolIndex].source
source: root.currentToolIndex < 0 ? "tools/Settings.qml" : root.tools[root.currentToolIndex].source
active: true

onLoaded: splash.close()
Expand Down
4 changes: 2 additions & 2 deletions app/ui/Style/ComboBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ T.ComboBox {

contentItem: TextField {
leftPadding: !control.mirrored ? 12 : control.editable && activeFocus ? 3 : 1
rightPadding: control.mirrored ? 12 : control.editable && activeFocus ? 3 : 1
rightPadding: control.mirrored ? 12 : control.editable && activeFocus ? 3 : 12
topPadding: 6 - control.padding
bottomPadding: 6 - control.padding
text: control.editable ? control.editText : control.displayText
Expand Down Expand Up @@ -86,7 +86,7 @@ T.ComboBox {
topMargin: 5
bottomMargin: 5
padding: 0
modal: control && control.model && control.model.length
modal: control && control.model && control.model.length > 0
transformOrigin: Item.Top

enter: Transition {
Expand Down
54 changes: 26 additions & 28 deletions app/ui/common/TreeViewItem.qml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pragma ComponentBehavior: Bound

import QtQuick
import QtQuick.Controls
import CustomComponents
Expand All @@ -17,8 +16,7 @@ CustomButton {

anchors.right: parent ? parent.right : undefined
anchors.left: parent ? parent.left : undefined
anchors.leftMargin: modelData ? modelData.depth * 5 + (!modelData.canToggle
&& itemIcon === "" ? 22 : 0) : 0
anchors.leftMargin: modelData ? modelData.depth * 5 + (!modelData.canToggle && itemIcon === "" ? 22 : 0) : 0

iconText: modelData && modelData.canToggle ? (modelData.isOpen ? FontAwesome.caretDown : FontAwesome.caretRight) : itemIcon

Expand All @@ -27,12 +25,12 @@ CustomButton {
mainRow.spacing: checkbox.visible ? checkbox.width + 10 : 10

onClicked: {
modelData.toggle()
modelData.toggle();
}

onRightClicked: {
if (contextMenu) {
contextMenu.open()
contextMenu.open();
}
}

Expand All @@ -49,14 +47,14 @@ CustomButton {
checkState: {
switch (root.modelData ? root.modelData.isChecked : 0) {
case 0:
Qt.Unchecked
break
Qt.Unchecked;
break;
case 1:
Qt.PartiallyChecked
break
Qt.PartiallyChecked;
break;
case 2:
Qt.Checked
break
Qt.Checked;
break;
}
}

Expand All @@ -67,7 +65,7 @@ CustomButton {
anchors.fill: parent

onClicked: {
root.modelData.isChecked = root.modelData.isChecked < 2 ? 2 : 0
root.modelData.isChecked = root.modelData.isChecked < 2 ? 2 : 0;
}
}
}
Expand All @@ -81,12 +79,12 @@ CustomButton {
modal: true

onOpened: {
rename_field.selectAll()
rename_field.forceActiveFocus()
rename_field.selectAll();
rename_field.forceActiveFocus();
}

onAccepted: {
root.modelData.rename(rename_field.text)
root.modelData.rename(rename_field.text);
}

contentItem: TextField {
Expand All @@ -96,7 +94,7 @@ CustomButton {
padding: 0

onAccepted: {
rename_dialog.accept()
rename_dialog.accept();
}
}
}
Expand All @@ -111,12 +109,12 @@ CustomButton {
modal: true

onOpened: {
name_field.selectAll()
name_field.forceActiveFocus()
name_field.selectAll();
name_field.forceActiveFocus();
}

onAccepted: {
root.modelData.create(new_thing_dialog.type, name_field.text)
root.modelData.create(new_thing_dialog.type, name_field.text);
}

contentItem: TextField {
Expand All @@ -125,7 +123,7 @@ CustomButton {
placeholderText: qsTr("Name")

onAccepted: {
new_thing_dialog.accept()
new_thing_dialog.accept();
}
}
}
Expand All @@ -140,7 +138,7 @@ CustomButton {
modal: true

onAccepted: {
root.modelData.remove()
root.modelData.remove();
}

contentItem: Item {
Expand All @@ -156,7 +154,7 @@ CustomButton {
width: parent.width / 2 - 5

onClicked: {
delete_dialog.accept()
delete_dialog.accept();
}
}

Expand Down Expand Up @@ -198,21 +196,21 @@ CustomButton {
text: qsTr("New") + " " + modelData + " ..."

onTriggered: {
new_thing_dialog.title = text
new_thing_dialog.type = modelData
new_thing_dialog.y = y
new_thing_dialog.open()
new_thing_dialog.title = text;
new_thing_dialog.type = modelData;
new_thing_dialog.y = y;
new_thing_dialog.open();
}
}
}

CustomMenuItem {
id: delete_item
text: qsTr("Delete")
textColor: "darkred"
textColor: SettingsManager.colors.error

onTriggered: {
delete_dialog.open()
delete_dialog.open();
}
}
}
Expand Down
Loading

0 comments on commit daa4f22

Please sign in to comment.