diff --git a/CMakeLists.txt b/CMakeLists.txt
index f624bf7..3e37549 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -95,17 +95,13 @@ set(SOURCE_FILES
src/commons.h src/commons.cpp
src/menu-dbus-service.cpp src/menu-dbus-service.h
src/ukui-menu-application.cpp src/ukui-menu-application.h
- src/settings/settings.cpp src/settings/settings.h
- src/uiconfig/theme-palette.cpp src/uiconfig/theme-palette.h
src/windows/menu-main-window.cpp src/windows/menu-main-window.h
- src/appdata/app-data-manager.cpp src/appdata/app-data-manager.h
- src/appdata/app-icon-provider.cpp src/appdata/app-icon-provider.h
+ src/settings/settings.cpp src/settings/settings.h
+ src/settings/user-config.cpp src/settings/user-config.h
src/utils/power-button.cpp src/utils/power-button.h
src/utils/app-manager.cpp src/utils/app-manager.h
src/utils/event-track.cpp src/utils/event-track.h
src/utils/sidebar-button-utils.cpp src/utils/sidebar-button-utils.h
- src/items/theme-icon.h src/items/theme-icon.cpp
- src/settings/user-config.cpp src/settings/user-config.h
src/extension/menu-extension-plugin.cpp src/extension/menu-extension-plugin.h
src/extension/menu-extension-loader.cpp src/extension/menu-extension-loader.h
src/extension/widget-extension.cpp src/extension/widget-extension.h
diff --git a/qml/AppControls2/FolderIcon.qml b/qml/AppControls2/FolderIcon.qml
index 3473e13..eb2e679 100644
--- a/qml/AppControls2/FolderIcon.qml
+++ b/qml/AppControls2/FolderIcon.qml
@@ -18,16 +18,18 @@
import QtQuick 2.12
import org.ukui.menu.core 1.0
+import org.ukui.quick.items 1.0 as UkuiItems
+import org.ukui.quick.platform 1.0 as Platform
-StyleBackground {
+UkuiItems.StyleBackground {
property alias icons: iconGrid.icons
property alias rows: iconGrid.rows
property alias columns: iconGrid.columns
property alias padding: iconGrid.padding
property alias spacing: iconGrid.spacing
- paletteRole: Palette.Text
- useStyleTransparent: false
+ paletteRole: Platform.Theme.Text
+ useStyleTransparency: false
Grid {
id: iconGrid
diff --git a/qml/AppControls2/FolderItem.qml b/qml/AppControls2/FolderItem.qml
index 20dfbc8..8e6e9d6 100644
--- a/qml/AppControls2/FolderItem.qml
+++ b/qml/AppControls2/FolderItem.qml
@@ -2,8 +2,8 @@ import QtQuick 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.5
import org.ukui.menu.core 1.0
-import org.ukui.quick.platform 1.0 as Platform
import org.ukui.quick.items 1.0 as UkuiItems
+import org.ukui.quick.platform 1.0 as Platform
MouseArea {
id: control
@@ -35,7 +35,7 @@ MouseArea {
when: control.activeFocus
PropertyChanges {
target: controlBase
- borderColor: Palette.Highlight
+ borderColor: Platform.Theme.Highlight
border.width: 2
}
}
@@ -111,20 +111,23 @@ MouseArea {
}
function updateTextInputColor() {
- color = themePalette.paletteColor(Palette.Text);
- selectionColor = themePalette.paletteColor(Palette.Highlight);
+ color = Platform.Theme.text();
+ selectionColor = Platform.Theme.highlight();
}
onEditingFinished: {
modelManager.getAppModel().renameFolder(id, text);
textChange.editStatusEnd();
}
+
+ Platform.Theme.onPaletteChanged: {
+ updateTextInputColor();
+ }
+
Component.onCompleted: {
updateTextInputColor();
- themePalette.styleColorChanged.connect(updateTextInputColor);
forceActiveFocus();
}
- Component.onDestruction: themePalette.styleColorChanged.disconnect(updateTextInputColor);
}
MouseArea {
diff --git a/qml/AppControls2/IconLabel.qml b/qml/AppControls2/IconLabel.qml
index a4e2245..1e0f3bb 100644
--- a/qml/AppControls2/IconLabel.qml
+++ b/qml/AppControls2/IconLabel.qml
@@ -1,7 +1,7 @@
import QtQuick 2.0
import org.ukui.menu.core 1.0
-import org.ukui.quick.platform 1.0 as Platform
import org.ukui.quick.items 1.0 as UkuiItems
+import org.ukui.quick.platform 1.0 as Platform
Item {
id: root
diff --git a/qml/AppControls2/RoundButton.qml b/qml/AppControls2/RoundButton.qml
index 7ee2d08..74c8ac7 100644
--- a/qml/AppControls2/RoundButton.qml
+++ b/qml/AppControls2/RoundButton.qml
@@ -1,6 +1,9 @@
import QtQuick 2.15
import org.ukui.menu.core 1.0
+import org.ukui.quick.items 1.0 as UkuiItems
+import org.ukui.quick.platform 1.0 as Platform
+
MouseArea {
id: buttonMouseArea
hoverEnabled: true
@@ -8,26 +11,27 @@ MouseArea {
property alias highlight: themeIcon.highLight
property alias autoHighLight: themeIcon.autoHighLight
- StyleBackground {
+ UkuiItems.StyleBackground {
id: buttonBase
- useStyleTransparent: false
- paletteRole: mainWindow.isFullScreen ? Palette.Light : Palette.Text
+ useStyleTransparency: false
+ paletteRole: mainWindow.isFullScreen ? Platform.Theme.Light : Platform.Theme.Text
anchors.fill: parent
radius: height / 2
alpha: buttonMouseArea.containsPress ? 0.20 : buttonMouseArea.containsMouse ? 0.16 : 0.10
}
- ThemeIcon {
+ UkuiItems.Icon {
id: themeIcon
anchors.centerIn: parent
width: 16; height: width
source: buttonIcon
+ mode: UkuiItems.Icon.AutoHighlight
}
states: State {
when: buttonMouseArea.activeFocus
PropertyChanges {
target: buttonBase
- borderColor: Palette.Highlight
+ borderColor: Platform.Theme.Highlight
border.width: 2
}
}
diff --git a/qml/AppControls2/ScrollBar.qml b/qml/AppControls2/ScrollBar.qml
index 4fe5a4a..aaf3ced 100644
--- a/qml/AppControls2/ScrollBar.qml
+++ b/qml/AppControls2/ScrollBar.qml
@@ -1,6 +1,8 @@
import QtQuick 2.0
import QtQuick.Controls 2.5
import org.ukui.menu.core 1.0
+import org.ukui.quick.items 1.0 as UkuiItems
+import org.ukui.quick.platform 1.0 as Platform
ScrollBar {
id: control
@@ -14,10 +16,10 @@ ScrollBar {
}
}
- contentItem: StyleBackground {
+ contentItem: UkuiItems.StyleBackground {
radius: width / 2
- useStyleTransparent: false
- paletteRole: Palette.Text
+ useStyleTransparency: false
+ paletteRole: Platform.Theme.Text
alpha: control.pressed ? 0.28 : control.hovered ? 0.18 : 0.10
opacity: ((control.policy === ScrollBar.AlwaysOn || control.size < 1.0 ) && control.visual) ? 1.0 : 0.0
}
diff --git a/qml/AppControls2/StyleBackground.qml b/qml/AppControls2/StyleBackground.qml
deleted file mode 100644
index e74d019..0000000
--- a/qml/AppControls2/StyleBackground.qml
+++ /dev/null
@@ -1,57 +0,0 @@
-import QtQuick 2.12
-import org.ukui.menu.core 1.0
-
-Rectangle {
- property bool useStyleTransparent: true
- property int paletteRole: Palette.Base
- property int paletteGroup: Palette.Active
- property int borderColor: Palette.Base
- property real alpha: 1.0
- property real borderAlpha: 1.0
-
- clip: true
- border.width: 0
-
- function updateColor() {
- if (useStyleTransparent) {
- color = themePalette.paletteColorWithTransparency(paletteRole, paletteGroup)
- } else {
- color = themePalette.paletteColorWithCustomTransparency(paletteRole, paletteGroup, alpha)
- }
- }
-
- function updateBorderColor() {
- border.color = themePalette.paletteColorWithCustomTransparency(borderColor, Palette.Active, borderAlpha)
- }
-
- Component.onCompleted: {
- updateColor()
- updateBorderColor()
- themePalette.styleColorChanged.connect(updateColor)
- themePalette.styleColorChanged.connect(updateBorderColor)
- }
- Component.onDestruction: {
- themePalette.styleColorChanged.disconnect(updateColor)
- themePalette.styleColorChanged.disconnect(updateBorderColor)
- }
-
- onUseStyleTransparentChanged: {
- updateColor()
- }
- onPaletteRoleChanged: {
- updateColor()
- }
- onPaletteGroupChanged: {
- updateColor()
- }
- onAlphaChanged: {
- updateColor()
- }
- onBorderAlphaChanged: {
- updateBorderColor()
- }
- onBorderColorChanged: {
- updateBorderColor()
- }
-}
-
diff --git a/qml/AppControls2/StyleText.qml b/qml/AppControls2/StyleText.qml
deleted file mode 100644
index f549a81..0000000
--- a/qml/AppControls2/StyleText.qml
+++ /dev/null
@@ -1,33 +0,0 @@
-import QtQuick 2.0
-import org.ukui.menu.core 1.0
-
-Text {
- property int paletteRole: Palette.Text
- property real alpha: 1
- property real systemFontSize: 10
- property real textUltra: 2*systemFontSize
-
- font.pointSize: systemFontSize
- function updateColor() {
- color = themePalette.paletteColorWithCustomTransparency(paletteRole, Palette.Active, alpha);
- }
- function updateFont() {
- font = themePalette.systemFont();
- }
- Component.onCompleted: {
- updateColor();
- updateFont();
- themePalette.styleColorChanged.connect(updateColor);
- themePalette.systemFontChanged.connect(updateFont);
- }
- Component.onDestruction: {
- themePalette.styleColorChanged.disconnect(updateColor);
- themePalette.systemFontChanged.disconnect(updateFont);
- }
- onPaletteRoleChanged: {
- updateColor();
- }
- onAlphaChanged: {
- updateColor();
- }
-}
diff --git a/qml/AppControls2/qmldir b/qml/AppControls2/qmldir
index 4961582..7b54dd4 100644
--- a/qml/AppControls2/qmldir
+++ b/qml/AppControls2/qmldir
@@ -1,6 +1,4 @@
module AppControls2
-StyleBackground 1.0 StyleBackground.qml
-StyleText 1.0 StyleText.qml
ScrollBar 1.0 ScrollBar.qml
AppItem 1.0 AppItem.qml
FolderItem 1.0 FolderItem.qml
diff --git a/qml/AppUI/AppPage.qml b/qml/AppUI/AppPage.qml
index b63aaf9..9a5ea0f 100644
--- a/qml/AppUI/AppPage.qml
+++ b/qml/AppUI/AppPage.qml
@@ -24,10 +24,6 @@ Item {
property alias search: appPageSearch
property alias content: appPageContent
- AppPageBackend {
- id: appPageBackend
- }
-
ColumnLayout {
anchors.fill: parent
anchors.topMargin: 12
@@ -39,7 +35,6 @@ Item {
Layout.fillWidth: true
Layout.preferredHeight: 40
focusToPageContent: appPageContent
- backend: appPageBackend
}
AppPageContent {
@@ -47,7 +42,6 @@ Item {
Layout.fillWidth: true
Layout.fillHeight: true
activeFocusOnTab: false
- backend: appPageBackend
}
}
}
diff --git a/qml/AppUI/AppPageContent.qml b/qml/AppUI/AppPageContent.qml
index db6a853..3de8c24 100644
--- a/qml/AppUI/AppPageContent.qml
+++ b/qml/AppUI/AppPageContent.qml
@@ -23,8 +23,6 @@ import AppControls2 1.0 as AppControls2
import org.ukui.menu.core 1.0
Item {
- id: root
- property AppPageBackend backend: null
property bool isAppListShow: appList.visible
function resetFocus() {
@@ -43,7 +41,7 @@ Item {
id: appListHeader
Layout.fillWidth: true
Layout.preferredHeight: 48
- header: backend.appModel.header
+ header: AppPageBackend.appModel.header
}
Item {
@@ -54,7 +52,7 @@ Item {
id: appList
anchors.fill: parent
visible: true
- model: backend.appModel
+ model: AppPageBackend.appModel
view.onContentYChanged: {
if (view.contentY <= 0) {
diff --git a/qml/AppUI/AppPageSearch.qml b/qml/AppUI/AppPageSearch.qml
index 3c272e0..7bc80df 100644
--- a/qml/AppUI/AppPageSearch.qml
+++ b/qml/AppUI/AppPageSearch.qml
@@ -6,8 +6,6 @@ import org.ukui.quick.items 1.0 as UkuiItems
import org.ukui.menu.utils 1.0
Item {
- id: root
- property AppPageBackend backend: null
property Item focusToPageContent
property bool inputStatus: false
@@ -23,12 +21,11 @@ Item {
visible: true
onTextChanged: {
if (text === "") {
- root.backend.group = PluginGroup.Display;
+ AppPageBackend.group = PluginGroup.Display;
inputStatus = false;
} else {
- root.backend.group = PluginGroup.Search;
- // appPageHeaderUtils.startSearch(text);
- root.backend.startSearch(text);
+ AppPageBackend.group = PluginGroup.Search;
+ AppPageBackend.startSearch(text);
inputStatus = true;
}
}
diff --git a/qml/AppUI/EditText.qml b/qml/AppUI/EditText.qml
index c3d3afd..122e1d3 100644
--- a/qml/AppUI/EditText.qml
+++ b/qml/AppUI/EditText.qml
@@ -92,20 +92,19 @@ Item {
contain.editStatus = false;
}
- property int textColor: isFullScreen ? Palette.HighlightedText : Palette.Text
function updateTextInputColor() {
- color = themePalette.paletteColor(textColor);
- selectionColor = themePalette.paletteColor(Palette.Highlight);
+ color = isFullScreenFolder ? Platform.Theme.highlightedText() : Platform.Theme.text();
+ selectionColor = Platform.Theme.highlight();
+ }
+
+ Platform.Theme.onPaletteChanged: {
+ updateTextInputColor();
}
Component.onCompleted: {
updateTextInputColor();
- themePalette.styleColorChanged.connect(updateTextInputColor);
forceActiveFocus();
}
-
- Component.onDestruction: themePalette.styleColorChanged.disconnect(updateTextInputColor);
-
}
MouseArea {
@@ -117,12 +116,11 @@ Item {
anchors.verticalCenter: parent.verticalCenter
visible: textEdit.activeFocus
- ThemeIcon {
+ UkuiItems.Icon {
anchors.centerIn: parent
width: 16; height: width
- source: "image://appicon/edit-clear-symbolic"
- highLight: isFullScreenFolder
- autoHighLight: !isFullScreenFolder
+ source: "image://theme/edit-clear-symbolic"
+ mode: isFullScreenFolder ? UkuiItems.Icon.Highlight : UkuiItems.Icon.AutoHighlight
}
onClicked: {
diff --git a/qml/AppUI/FullScreenContent.qml b/qml/AppUI/FullScreenContent.qml
index 4d539f5..f313b40 100644
--- a/qml/AppUI/FullScreenContent.qml
+++ b/qml/AppUI/FullScreenContent.qml
@@ -233,7 +233,7 @@ RowLayout {
when: dropArea.activeFocus
PropertyChanges {
target: controlBase
- borderColor: Palette.Highlight
+ borderColor: Platform.Theme.Highlight
border.width: 2
}
}
@@ -261,11 +261,11 @@ RowLayout {
ToolTip.delay: 500
ToolTip.text: name
ToolTip.visible: iconText.truncated && containsMouse
- AppControls2.StyleBackground {
+ UkuiItems.StyleBackground {
id: controlBase
anchors.fill: parent
- useStyleTransparent: false
- paletteRole: Palette.Light
+ useStyleTransparency: false
+ paletteRole: Platform.Theme.Light
radius: 16
alpha: appItem.isSelect ? 0.00 : parent.containsPress ? 0.25 : parent.containsMouse ? 0.15 : 0.00
Item {
@@ -275,11 +275,11 @@ RowLayout {
height: 108
width: 108
- AppControls2.StyleBackground {
+ UkuiItems.StyleBackground {
id: imageBase
anchors.fill: parent
- paletteRole: Palette.Text
- useStyleTransparent: false
+ paletteRole: Platform.Theme.Text
+ useStyleTransparency: false
alpha: 0.25
radius: 24
visible: false
@@ -294,7 +294,7 @@ RowLayout {
}
}
- AppControls2.StyleText {
+ UkuiItems.StyleText {
id: iconText
visible: !appItem.isSelect
width: parent.width
@@ -304,7 +304,7 @@ RowLayout {
anchors.horizontalCenter: parent.horizontalCenter
text: name
elide: Text.ElideRight
- paletteRole: Palette.HighlightedText
+ paletteRole: Platform.Theme.HighlightedText
}
}
@@ -363,10 +363,10 @@ RowLayout {
ToolTip.delay: 500
ToolTip.text: name
ToolTip.visible: folderText.truncated && containsMouse
- AppControls2.StyleBackground {
+ UkuiItems.StyleBackground {
anchors.fill: parent
- useStyleTransparent: false
- paletteRole: Palette.Light
+ useStyleTransparency: false
+ paletteRole: Platform.Theme.Light
radius: 16
alpha: parent.containsPress ? 0.25 : parent.containsMouse ? 0.15 : 0.00
@@ -378,10 +378,10 @@ RowLayout {
anchors.top: parent.top
anchors.topMargin: 14
- AppControls2.StyleBackground {
+ UkuiItems.StyleBackground {
anchors.fill: parent
- paletteRole: Palette.Text
- useStyleTransparent: false
+ paletteRole: Platform.Theme.Text
+ useStyleTransparency: false
alpha: 0.25
radius: 24
visible: folderItem.isSelect
@@ -399,7 +399,7 @@ RowLayout {
}
}
- AppControls2.StyleText {
+ UkuiItems.StyleText {
id: folderText
anchors.bottom: parent.bottom
anchors.bottomMargin: 20
@@ -408,7 +408,7 @@ RowLayout {
anchors.horizontalCenter: parent.horizontalCenter
elide: Text.ElideRight
text: name
- paletteRole: Palette.HighlightedText
+ paletteRole: Platform.Theme.HighlightedText
}
}
diff --git a/qml/AppUI/FullScreenUI.qml b/qml/AppUI/FullScreenUI.qml
index e990009..fd47b2f 100644
--- a/qml/AppUI/FullScreenUI.qml
+++ b/qml/AppUI/FullScreenUI.qml
@@ -29,10 +29,6 @@ UkuiItems.StyleBackground {
anchors.fill: parent
z: 10
- AppPageBackend {
- id: appPageBackend
- }
-
// 两行三列
GridLayout {
anchors.fill: parent
@@ -59,7 +55,7 @@ UkuiItems.StyleBackground {
id: actionsItem
anchors.centerIn: parent
height: parent.height
- actions: appPageBackend.appModel.header.actions
+ actions: AppPageBackend.appModel.header.actions
visible: count > 0
}
}
@@ -80,10 +76,10 @@ UkuiItems.StyleBackground {
onTextChanged: {
if (text === "") {
- appPageBackend.group = PluginGroup.Display;
+ AppPageBackend.group = PluginGroup.Display;
} else {
- appPageBackend.group = PluginGroup.Search;
- appPageBackend.startSearch(text);
+ AppPageBackend.group = PluginGroup.Search;
+ AppPageBackend.startSearch(text);
}
}
}
@@ -121,7 +117,7 @@ UkuiItems.StyleBackground {
Layout.fillWidth: true
Layout.fillHeight: true
- sourceModel: appPageBackend.appModel
+ sourceModel: AppPageBackend.appModel
}
}
}
diff --git a/qml/AppUI/SearchInputBar.qml b/qml/AppUI/SearchInputBar.qml
index 5f2434f..7b1f566 100644
--- a/qml/AppUI/SearchInputBar.qml
+++ b/qml/AppUI/SearchInputBar.qml
@@ -117,17 +117,21 @@ UkuiItems.StyleBackground {
Keys.onReturnPressed: changeFocusToListView()
//字体选中跟随主题高亮
- property int textColor: mainWindow.isFullScreen ? Palette.HighlightedText : Palette.Text
+ property bool isFullScreen: mainWindow.isFullScreen
+ onIsFullScreenChanged: updateTextInputColor()
+
function updateTextInputColor() {
- color = themePalette.paletteColor(textColor)
- selectionColor = themePalette.paletteColor(Palette.Highlight)
+ color = isFullScreen ? Platform.Theme.highlightedText() : Platform.Theme.text();
+ selectionColor = Platform.Theme.highlight();
}
+
+ Platform.Theme.onPaletteChanged: {
+ updateTextInputColor();
+ }
+
Component.onCompleted: {
updateTextInputColor();
- themePalette.styleColorChanged.connect(updateTextInputColor);
}
- onTextColorChanged: updateTextInputColor()
- Component.onDestruction: themePalette.styleColorChanged.disconnect(updateTextInputColor)
}
UkuiItems.Button {
diff --git a/qml/AppUI/WidgetPage.qml b/qml/AppUI/WidgetPage.qml
index c601716..8f921d8 100644
--- a/qml/AppUI/WidgetPage.qml
+++ b/qml/AppUI/WidgetPage.qml
@@ -32,6 +32,7 @@ Item {
ColumnLayout {
anchors.fill: parent
anchors.topMargin: 12
+ anchors.bottomMargin: 5
spacing: 5
Item {
@@ -70,10 +71,10 @@ Item {
// 插件信息
UkuiItems.StyleBackground {
useStyleTransparency: false
- paletteRole: Palette.Highlight
+ paletteRole: Platform.Theme.Highlight
alpha: 0
radius: Platform.Theme.minRadius
- borderColor: Palette.Highlight
+ borderColor: Platform.Theme.Highlight
border.width: activeFocus ? 2 : 0
property var extensionData: model.data
diff --git a/qml/main.qml b/qml/main.qml
index 1a2aab4..e7e6308 100644
--- a/qml/main.qml
+++ b/qml/main.qml
@@ -20,6 +20,7 @@ import QtQuick 2.12
import AppUI 1.0 as AppUI
import AppControls2 1.0 as AppControls2
import org.ukui.menu.core 1.0
+import org.ukui.quick.items 1.0 as UkuiItems
Item {
id: root
@@ -102,7 +103,7 @@ Item {
}
}
- AppControls2.StyleBackground {
+ UkuiItems.StyleBackground {
id: backgroundMask
// 初始状态默认为normalScreen
x: 0; y: 0
diff --git a/qml/qml.qrc b/qml/qml.qrc
index 63c9dab..378958b 100644
--- a/qml/qml.qrc
+++ b/qml/qml.qrc
@@ -19,8 +19,6 @@
AppControls2/qmldir
AppControls2/App.qml
AppControls2/ScrollBar.qml
- AppControls2/StyleBackground.qml
- AppControls2/StyleText.qml
AppControls2/IconLabel.qml
AppControls2/AppItem.qml
AppControls2/LabelItem.qml
diff --git a/src/extension/context-menu-manager.cpp b/src/extension/context-menu-manager.cpp
index bb264e2..fa2b7ab 100755
--- a/src/extension/context-menu-manager.cpp
+++ b/src/extension/context-menu-manager.cpp
@@ -17,8 +17,8 @@
*/
#include "context-menu-manager.h"
-#include "app-data-manager.h"
#include "menu-extension-loader.h"
+#include "basic-app-model.h"
#include
#include
@@ -57,7 +57,7 @@ ContextMenuManager::~ContextMenuManager()
void ContextMenuManager::showMenu(const QString &appid, const MenuInfo::Location location, const QString &lid, const QPoint &point)
{
DataEntity app;
- if (AppDataManager::instance()->getApp(appid, app)) {
+ if (BasicAppModel::instance()->getAppById(appid, app)) {
showMenu(app, location, lid, point);
}
}
diff --git a/src/extension/favorite/favorite-context-menu.cpp b/src/extension/favorite/favorite-context-menu.cpp
index 9ec2205..d09ce71 100644
--- a/src/extension/favorite/favorite-context-menu.cpp
+++ b/src/extension/favorite/favorite-context-menu.cpp
@@ -17,10 +17,10 @@
*/
#include "favorite-context-menu.h"
-#include "favorite-folder-helper.h"
-#include "app-data-manager.h"
-#include "favorites-model.h"
#include "event-track.h"
+#include "basic-app-model.h"
+#include "favorites-model.h"
+#include "favorite-folder-helper.h"
namespace UkuiMenu {
@@ -54,6 +54,7 @@ FavoriteContextMenu::actions(const DataEntity &data, QMenu *parent, const MenuIn
list << new QAction(QObject::tr("Fix to favorite"), parent);
QObject::connect(list.last(), &QAction::triggered, parent, [data] {
FavoritesModel::instance().addAppToFavorites(data.id());
+ //BasicAppModel::instance()->databaseInterface()->fixAppToFavorite(data.id(), 1);
EventTrack::instance()->sendDefaultEvent("fix_to_favorite", "Right-click Menu");
});
@@ -61,6 +62,7 @@ FavoriteContextMenu::actions(const DataEntity &data, QMenu *parent, const MenuIn
list << new QAction(QObject::tr("Remove from favorite"), parent);
QObject::connect(list.last(), &QAction::triggered, parent, [data] {
FavoritesModel::instance().removeAppFromFavorites(data.id());
+ BasicAppModel::instance()->databaseInterface()->fixAppToFavorite(data.id(), 0);
EventTrack::instance()->sendDefaultEvent("remove_from_favorite", "Right-click Menu");
});
}
diff --git a/src/extension/favorite/favorite-folder-helper.cpp b/src/extension/favorite/favorite-folder-helper.cpp
index b0d2d7c..c3a2ad7 100644
--- a/src/extension/favorite/favorite-folder-helper.cpp
+++ b/src/extension/favorite/favorite-folder-helper.cpp
@@ -18,10 +18,9 @@
#include "favorite-folder-helper.h"
#include "app-data-manager.h"
-#include "model-manager.h"
-#include "app-model.h"
#include "event-track.h"
#include "favorites-config.h"
+#include "basic-app-model.h"
#include
#include
@@ -344,7 +343,7 @@ QStringList FavoriteFolderHelper::folderIcon(const FavoritesFolder &folder)
int count = qMin(folder.apps.count(), FOLDER_MAX_ICON_NUM);
for (int i = 0; i < count; ++i) {
- if (AppDataManager::instance()->getApp(folder.apps.at(i), app)) {
+ if (BasicAppModel::instance()->getAppById(folder.apps.at(i), app)) {
icons.append(app.icon());
}
}
diff --git a/src/extension/menu/app-menu-plugin.cpp b/src/extension/menu/app-menu-plugin.cpp
index f1bd012..e50ef39 100644
--- a/src/extension/menu/app-menu-plugin.cpp
+++ b/src/extension/menu/app-menu-plugin.cpp
@@ -17,10 +17,10 @@
*/
#include "app-menu-plugin.h"
-#include "app-data-manager.h"
#include "settings.h"
#include "app-manager.h"
#include "../context-menu-extension.h"
+#include "basic-app-model.h"
#include
#include
@@ -91,7 +91,7 @@ void AppContentMenu::addToTop(QObject *parent, const QString &appId, const int &
QString actionName = (appTop == 0) ? QObject::tr("Fixed to all applications") : QObject::tr("Unfixed from all applications");
list << new QAction(actionName, parent);
QObject::connect(list.last(), &QAction::triggered, parent, [appId, appTop] {
- AppDataManager::instance()->fixToTop(appId, appTop);
+ BasicAppModel::instance()->databaseInterface()->fixAppToTop(appId, appTop);
});
}
diff --git a/src/items/theme-icon.cpp b/src/items/theme-icon.cpp
deleted file mode 100644
index 91acf09..0000000
--- a/src/items/theme-icon.cpp
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Copyright (C) 2023, KylinSoft Co., Ltd.
- *
- * 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 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * Authors: hxf
- *
- */
-
-#include "theme-icon.h"
-#include "settings.h"
-#include "app-icon-provider.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#define COLOR_DIFFERENCE 10
-using namespace UkuiMenu;
-
-QColor ThemeIcon::symbolicColor = QColor(31, 32, 34, 192);
-
-ThemeIcon::ThemeIcon(QQuickItem *parent) : QQuickPaintedItem(parent)
-{
- connect(GlobalSetting::instance(), &GlobalSetting::styleChanged, this, [this] (const GlobalSetting::Key& key) {
- if (key == GlobalSetting::StyleName) {
- checkThemeName();
- }
- });
- connect(this, &ThemeIcon::widthChanged, this, &ThemeIcon::onSizeChanged);
- connect(this, &ThemeIcon::heightChanged, this, &ThemeIcon::onSizeChanged);
-}
-
-void ThemeIcon::checkThemeName()
-{
- if (!m_autoHighlight) {
- return;
- }
- m_highLight = (GlobalSetting::instance()->get(GlobalSetting::StyleName).toString() != UKUI_STYLE_VALUE_LIGHT);
- update();
-}
-
-void ThemeIcon::loadPixmapBySource(const QString &source)
-{
- QSize size;
- m_pixmap = UkuiMenu::AppIconProvider::getPixmap(source, &size, QSize(width(), height()));
- if (m_pixmap.isNull()) {
- return;
- }
- m_isPureColor = isPixmapPureColor(m_pixmap);
-}
-
-void ThemeIcon::paint(QPainter *painter)
-{
- //默认居中绘制
- QRect rect(0, 0, static_cast(width()), static_cast(height()));
-
- QPixmap pixmap = m_pixmap;
-
- painter->save();
- //抗锯齿,平滑过渡
- painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
-
- if (m_disabled) {
- QPainter p(&pixmap);
- p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
- p.setCompositionMode(QPainter::CompositionMode_SourceIn);
- p.fillRect(pixmap.rect(), QGuiApplication::palette().color(QPalette::Disabled, QPalette::ButtonText));
-
- } else if (m_highLight && (m_isPureColor || m_forceHighlight)) {
- QPainter p(&pixmap);
- p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
- p.setCompositionMode(QPainter::CompositionMode_SourceIn);
- p.fillRect(pixmap.rect(), QGuiApplication::palette().color(QPalette::HighlightedText));
- }
-
- if (m_radius > 0) {
- int radius = qMin(m_radius, qMin((rect.height() / 2), (rect.width() / 2)));
- QPainterPath path;
- path.addRoundedRect(rect, radius, radius);
- painter->setClipPath(path);
- }
-
- painter->drawPixmap(rect, pixmap, pixmap.rect());
- painter->restore();
-}
-
-QString ThemeIcon::getSource()
-{
- return m_source;
-}
-
-void ThemeIcon::setSource(const QString &source)
-{
- if (source.isEmpty()) {
- qWarning() << "ThemeIcon: source is empty!";
- return;
- }
-
- QString prefix("image://appicon/");
- m_source = source;
- if (m_source.startsWith(prefix)) {
- m_source = m_source.mid(prefix.size());
- }
- loadPixmapBySource(m_source);
- checkThemeName();
- update();
-}
-
-QString ThemeIcon::getFallBack()
-{
- return m_fallback;
-}
-
-void ThemeIcon::setFallBack(const QString &fallback)
-{
- if (fallback.isEmpty()) {
- qWarning() << "ThemeIcon: fallback is empty!";
- return;
- }
-
- m_fallback = fallback;
- if (m_pixmap.isNull()) {
- setSource(fallback);
- }
-}
-
-bool ThemeIcon::isHighLight() const
-{
- return m_highLight;
-}
-
-void ThemeIcon::setHighLight(bool highLight)
-{
-// qDebug() << "set high-light" << highLight;
- m_highLight = highLight;
- update();
-}
-
-bool ThemeIcon::isForceHighlight() const
-{
- return m_forceHighlight;
-}
-
-void ThemeIcon::setForceHighLight(bool force)
-{
- m_forceHighlight = force;
- update();
-}
-
-bool ThemeIcon::disable() const
-{
- return m_disabled;
-}
-
-void ThemeIcon::setDisable(bool disable)
-{
- m_disabled = disable;
- update();
-}
-
-//copy from ukui-platform-theme
-bool ThemeIcon::isPixmapPureColor(const QPixmap &pixmap)
-{
- if (pixmap.isNull()) {
- qWarning("pixmap is null!");
- return false;
- }
- QImage image = pixmap.toImage();
-
- QVector vector;
- int total_red = 0;
- int total_green = 0;
- int total_blue = 0;
- bool pure = true;
- for (int y = 0; y < image.height(); ++y) {
- for (int x = 0; x < image.width(); ++x) {
- if (image.pixelColor(x, y).alphaF() > 0.3) {
- QColor color = image.pixelColor(x, y);
- vector << color;
- total_red += color.red();
- total_green += color.green();
- total_blue += color.blue();
- int dr = qAbs(color.red() - symbolicColor.red());
- int dg = qAbs(color.green() - symbolicColor.green());
- int db = qAbs(color.blue() - symbolicColor.blue());
- if (dr > COLOR_DIFFERENCE || dg > COLOR_DIFFERENCE || db > COLOR_DIFFERENCE)
- pure = false;
- }
- }
- }
-
- if (pure)
- return true;
-
- qreal squareRoot_red = 0;
- qreal squareRoot_green = 0;
- qreal squareRoot_blue = 0;
- qreal average_red = total_red / vector.count();
- qreal average_green = total_green / vector.count();
- qreal average_blue = total_blue / vector.count();
- for (QColor color : vector) {
- squareRoot_red += (color.red() - average_red) * (color.red() - average_red);
- squareRoot_green += (color.green() - average_green) * (color.green() - average_green);
- squareRoot_blue += (color.blue() - average_blue) * (color.blue() - average_blue);
- }
-
- qreal arithmeticSquareRoot_red = qSqrt(squareRoot_red / vector.count());
- qreal arithmeticSquareRoot_green = qSqrt(squareRoot_green / vector.count());
- qreal arithmeticSquareRoot_blue = qSqrt(squareRoot_blue / vector.count());
-
- return arithmeticSquareRoot_red < 2.0 && arithmeticSquareRoot_green < 2.0 && arithmeticSquareRoot_blue < 2.0;
-}
-
-void ThemeIcon::onSizeChanged()
-{
- if ((width() != 0) && (height() != 0) && (!m_source.isEmpty())) {
- loadPixmapBySource(m_source);
- }
- update();
-}
-
-int ThemeIcon::radius()
-{
- return m_radius;
-}
-
-void ThemeIcon::setRadius(int radius)
-{
- m_radius = radius < 0 ? 0 : radius;
-}
-
-bool ThemeIcon::autoHighLight() const
-{
- return m_autoHighlight;
-}
-
-void ThemeIcon::setAutoHighLight(bool autoHighlight)
-{
- m_autoHighlight = autoHighlight;
- checkThemeName();
-}
diff --git a/src/items/theme-icon.h b/src/items/theme-icon.h
deleted file mode 100644
index 42ca4d0..0000000
--- a/src/items/theme-icon.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2023, KylinSoft Co., Ltd.
- *
- * 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 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * Authors: hxf
- *
- */
-
-#ifndef UKUI_MENU_THEME_ICON_H
-#define UKUI_MENU_THEME_ICON_H
-
-#include
-#include
-
-namespace UkuiMenu {
-
-class ThemeIcon : public QQuickPaintedItem
-{
- Q_OBJECT
- Q_PROPERTY(bool disable READ disable WRITE setDisable)
- Q_PROPERTY(bool autoHighLight READ autoHighLight WRITE setAutoHighLight)
- Q_PROPERTY(bool highLight READ isHighLight WRITE setHighLight)
- Q_PROPERTY(bool forceHighlight READ isForceHighlight WRITE setForceHighLight)
- Q_PROPERTY(int radius READ radius WRITE setRadius)
- Q_PROPERTY(QString source READ getSource WRITE setSource)
- Q_PROPERTY(QString fallback READ getFallBack WRITE setFallBack)
-
-public:
- explicit ThemeIcon(QQuickItem *parent = nullptr);
-
- void paint(QPainter *painter) override;
- QString getSource();
- void setSource(const QString &source);
-
- QString getFallBack();
- void setFallBack(const QString &fallback);
-
- bool isHighLight() const;
- void setHighLight(bool highLight);
-
- bool autoHighLight() const;
- void setAutoHighLight(bool autoHighlight);
-
- bool isForceHighlight() const;
- void setForceHighLight(bool force);
-
- bool disable() const;
- void setDisable(bool disable);
-
- int radius();
- void setRadius(int radius);
-
-private:
- void checkThemeName();
- void loadPixmapBySource(const QString &source);
- static bool isPixmapPureColor(const QPixmap &pixmap);
-
-private Q_SLOTS:
- void onSizeChanged();
-private:
- bool m_disabled = false;
- bool m_highLight = false;
- bool m_forceHighlight = false;
- bool m_autoHighlight = true;
- bool m_isPureColor = true;
- int m_radius = 0;
- QString m_source;
- QString m_fallback;
- QPixmap m_pixmap;
-
- static QColor symbolicColor;
-
-};
-
-}
-
-#endif // UKUI_MENU_THEME_ICON_H
diff --git a/src/libappdata/app-category-plugin.cpp b/src/libappdata/app-category-plugin.cpp
index 4d8c900..5ca5aba 100644
--- a/src/libappdata/app-category-plugin.cpp
+++ b/src/libappdata/app-category-plugin.cpp
@@ -22,6 +22,7 @@
#include "combined-list-model.h"
#include "app-category-model.h"
#include "recently-installed-model.h"
+#include "event-track.h"
#include
#include
@@ -48,12 +49,20 @@ AppCategoryPlugin::AppCategoryPlugin(QObject *parent) : AppListPluginInterface(p
categoryAction->setChecked(true);
firstLatterAction->setChecked(false);
setTitle(categoryAction->text());
+
+ QMap map;
+ map.insert(QStringLiteral("viewName"), QStringLiteral("category"));
+ EventTrack::instance()->sendClickEvent("switch_app_view", "AppView", map);
});
connect(firstLatterAction, &QAction::triggered, this, [=] {
categoryModel->setMode(AppCategoryModel::FirstLatter);
categoryAction->setChecked(false);
firstLatterAction->setChecked(true);
setTitle(firstLatterAction->text());
+
+ QMap map;
+ map.insert(QStringLiteral("viewName"), QStringLiteral("letter"));
+ EventTrack::instance()->sendClickEvent("switch_app_view", "AppView", map);
});
m_actions.append(categoryAction);
diff --git a/src/libappdata/app-database-interface.cpp b/src/libappdata/app-database-interface.cpp
index a8d0f26..b1d6be0 100644
--- a/src/libappdata/app-database-interface.cpp
+++ b/src/libappdata/app-database-interface.cpp
@@ -26,7 +26,7 @@
#include
#include
-#define APP_ICON_PREFIX "image://appicon/"
+#define APP_ICON_PREFIX "image://theme/"
namespace UkuiMenu {
@@ -330,6 +330,7 @@ bool AppDatabaseWorkerPrivate::getApp(const QString &appid, DataEntity &app)
}
// ====== AppDatabaseInterface ====== //
+// TODO: 多线程
AppDatabaseInterface::AppDatabaseInterface(QObject *parent) : QObject(parent), d(new AppDatabaseWorkerPrivate(this))
{
diff --git a/src/libappdata/app-page-backend.cpp b/src/libappdata/app-page-backend.cpp
index 3c615c8..65c9335 100644
--- a/src/libappdata/app-page-backend.cpp
+++ b/src/libappdata/app-page-backend.cpp
@@ -28,6 +28,12 @@
namespace UkuiMenu {
+AppPageBackend *AppPageBackend::instance()
+{
+ static AppPageBackend backend;
+ return &backend;
+}
+
AppPageBackend::AppPageBackend(QObject *parent) : QObject(parent), m_appModel(new AppListModel(this))
{
auto searchPlugin = new AppSearchPlugin(this);
diff --git a/src/libappdata/app-page-backend.h b/src/libappdata/app-page-backend.h
index 613114c..9f4c3db 100644
--- a/src/libappdata/app-page-backend.h
+++ b/src/libappdata/app-page-backend.h
@@ -54,7 +54,7 @@ class AppPageBackend : public QObject
Q_PROPERTY(QAbstractItemModel *appModel READ appModel NOTIFY appModelChanged)
Q_PROPERTY(UkuiMenu::AppListPluginGroup::Group group READ group WRITE setGroup NOTIFY groupChanged)
public:
- explicit AppPageBackend(QObject *parent = nullptr);
+ static AppPageBackend *instance();
// 开始菜单主要功能,显示应用列表
AppListModel *appModel() const;
@@ -68,6 +68,7 @@ Q_SIGNALS:
void groupChanged();
private:
+ explicit AppPageBackend(QObject *parent = nullptr);
void switchGroup();
private:
diff --git a/src/libappdata/app-search-plugin.cpp b/src/libappdata/app-search-plugin.cpp
index ee59541..fefcdac 100644
--- a/src/libappdata/app-search-plugin.cpp
+++ b/src/libappdata/app-search-plugin.cpp
@@ -104,7 +104,7 @@ void AppSearchPluginPrivate::run()
app.setType(DataType::Normal);
app.setId(result.getValue(UkuiSearch::SearchProperty::ApplicationDesktopPath).toString());
app.setName(result.getValue(UkuiSearch::SearchProperty::ApplicationLocalName).toString());
- app.setIcon("image://appicon/" + result.getValue(UkuiSearch::SearchProperty::ApplicationIconName).toString());
+ app.setIcon("image://theme/" + result.getValue(UkuiSearch::SearchProperty::ApplicationIconName).toString());
Q_EMIT this->searchedOne(app);
}
diff --git a/src/libappdata/basic-app-model.cpp b/src/libappdata/basic-app-model.cpp
index ecd2ca9..0c4662e 100644
--- a/src/libappdata/basic-app-model.cpp
+++ b/src/libappdata/basic-app-model.cpp
@@ -162,6 +162,10 @@ void BasicAppModel::onAppDeleted(const QStringList &apps)
int BasicAppModel::indexOfApp(const QString &appid) const
{
+ if (appid.isEmpty()) {
+ return -1;
+ }
+
auto it = std::find_if(m_apps.constBegin(), m_apps.constEnd(), [&appid] (const DataEntity &app) {
return app.id() == appid;
});
@@ -183,4 +187,15 @@ DataEntity BasicAppModel::appOfIndex(int row) const
return m_apps.at(row);
}
+bool BasicAppModel::getAppById(const QString &appid, DataEntity &app) const
+{
+ int idx = indexOfApp(appid);
+ if (idx < 0) {
+ return false;
+ }
+
+ app = m_apps.at(idx);
+ return true;
+}
+
} // UkuiMenu
diff --git a/src/libappdata/basic-app-model.h b/src/libappdata/basic-app-model.h
index 511c898..8e4f998 100644
--- a/src/libappdata/basic-app-model.h
+++ b/src/libappdata/basic-app-model.h
@@ -42,6 +42,7 @@ public:
const AppDatabaseInterface *databaseInterface() const;
DataEntity appOfIndex(int row) const;
int indexOfApp(const QString &appid) const;
+ bool getAppById(const QString &appid, DataEntity &app) const;
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
diff --git a/src/utils/app-page-header-utils.cpp b/src/model/app-page-header-utils.cpp
similarity index 100%
rename from src/utils/app-page-header-utils.cpp
rename to src/model/app-page-header-utils.cpp
diff --git a/src/utils/app-page-header-utils.h b/src/model/app-page-header-utils.h
similarity index 100%
rename from src/utils/app-page-header-utils.h
rename to src/model/app-page-header-utils.h
diff --git a/src/uiconfig/theme-palette.cpp b/src/uiconfig/theme-palette.cpp
deleted file mode 100644
index 257d947..0000000
--- a/src/uiconfig/theme-palette.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
- *
- * 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 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * Authors: hxf
- *
- */
-
-#include "theme-palette.h"
-
-#include
-#include
-#include
-
-using namespace UkuiMenu;
-
-static ThemePalette *globalInstance = nullptr;
-
-ThemePalette *ThemePalette::getInstance()
-{
- if (!globalInstance) {
- globalInstance = new ThemePalette(nullptr);
- }
- return globalInstance;
-}
-
-ThemePalette::ThemePalette(QObject *parent) : QObject(parent)
-{
- initStyleSetting();
- connect(qGuiApp, &QGuiApplication::paletteChanged, this, [=] {
- Q_EMIT styleColorChanged();
- });
- connect(qGuiApp, &QGuiApplication::fontChanged, this, [=] {
- Q_EMIT systemFontChanged();
- });
-}
-
-QColor ThemePalette::paletteColor(Palette::ColorRole colorRole, Palette::ColorGroup colorGroup) const
-{
- switch (colorRole) {
- default:
- case Palette::Window:
- return window(colorGroup);
- case Palette::WindowText:
- return windowText(colorGroup);
- case Palette::Base:
- return base(colorGroup);
- case Palette::Text:
- return text(colorGroup);
- case Palette::BrightText:
- return brightText(colorGroup);
- case Palette::AlternateBase:
- return alternateBase(colorGroup);
- case Palette::Button:
- return button(colorGroup);
- case Palette::ButtonText:
- return buttonText(colorGroup);
- case Palette::Light:
- return light(colorGroup);
- case Palette::MidLight:
- return midLight(colorGroup);
- case Palette::Dark:
- return dark(colorGroup);
- case Palette::Mid:
- return mid(colorGroup);
- case Palette::Shadow:
- return shadow(colorGroup);
- case Palette::Highlight:
- return highlight(colorGroup);
- case Palette::HighlightedText:
- return highlightedText(colorGroup);
- }
-}
-
-QColor
-ThemePalette::paletteColorWithCustomTransparency(Palette::ColorRole colorRole, Palette::ColorGroup colorGroup,
- qreal alphaF) const
-{
- QColor color = paletteColor(colorRole, colorGroup);
- color.setAlphaF(alphaF);
- return color;
-}
-
-QColor
-ThemePalette::paletteColorWithTransparency(Palette::ColorRole colorRole, Palette::ColorGroup colorGroup) const
-{
- QColor color = paletteColor(colorRole, colorGroup);
- color.setAlphaF(m_transparency);
- return color;
-}
-
-QColor ThemePalette::window(Palette::ColorGroup colorGroup) const
-{
- return QGuiApplication::palette().color(switchColorGroup(colorGroup), QPalette::Window);
-}
-
-QColor ThemePalette::windowText(Palette::ColorGroup colorGroup) const
-{
- return QGuiApplication::palette().color(switchColorGroup(colorGroup), QPalette::WindowText);
-}
-
-QColor ThemePalette::text(Palette::ColorGroup colorGroup) const
-{
- return QGuiApplication::palette().color(switchColorGroup(colorGroup), QPalette::Text);
-}
-
-QColor ThemePalette::brightText(Palette::ColorGroup colorGroup) const
-{
- return QGuiApplication::palette().color(switchColorGroup(colorGroup), QPalette::BrightText);
-}
-
-QColor ThemePalette::base(Palette::ColorGroup colorGroup) const
-{
- return QGuiApplication::palette().color(switchColorGroup(colorGroup), QPalette::Base);
-}
-
-QColor ThemePalette::alternateBase(Palette::ColorGroup colorGroup) const
-{
- return QGuiApplication::palette().color(switchColorGroup(colorGroup), QPalette::AlternateBase);
-}
-
-QColor ThemePalette::button(Palette::ColorGroup colorGroup) const
-{
- return QGuiApplication::palette().color(switchColorGroup(colorGroup), QPalette::Button);
-}
-
-QColor ThemePalette::buttonText(Palette::ColorGroup colorGroup) const
-{
- return QGuiApplication::palette().color(switchColorGroup(colorGroup), QPalette::ButtonText);
-}
-
-QColor ThemePalette::light(Palette::ColorGroup colorGroup) const
-{
- return QGuiApplication::palette().color(switchColorGroup(colorGroup), QPalette::Light);
-}
-
-QColor ThemePalette::midLight(Palette::ColorGroup colorGroup) const
-{
- return QGuiApplication::palette().color(switchColorGroup(colorGroup), QPalette::Midlight);
-}
-
-QColor ThemePalette::dark(Palette::ColorGroup colorGroup) const
-{
- return QGuiApplication::palette().color(switchColorGroup(colorGroup), QPalette::Dark);
-}
-
-QColor ThemePalette::mid(Palette::ColorGroup colorGroup) const
-{
- return QGuiApplication::palette().color(switchColorGroup(colorGroup), QPalette::Mid);
-}
-
-QColor ThemePalette::shadow(Palette::ColorGroup colorGroup) const
-{
- return QGuiApplication::palette().color(switchColorGroup(colorGroup), QPalette::Shadow);
-}
-
-QColor ThemePalette::highlight(Palette::ColorGroup colorGroup) const
-{
- return QGuiApplication::palette().color(switchColorGroup(colorGroup), QPalette::Highlight);
-}
-
-QColor ThemePalette::highlightedText(Palette::ColorGroup colorGroup) const
-{
- return QGuiApplication::palette().color(switchColorGroup(colorGroup), QPalette::HighlightedText);
-}
-
-QColor ThemePalette::separator(Palette::ColorGroup colorGroup) const
-{
- return QGuiApplication::palette().color(switchColorGroup(colorGroup), QPalette::Window);
-}
-
-QPalette::ColorGroup ThemePalette::switchColorGroup(Palette::ColorGroup colorGroup)
-{
- switch (colorGroup) {
- default:
- case Palette::Active:
- return QPalette::Active;
- case Palette::Disabled:
- return QPalette::Disabled;
- case Palette::Inactive:
- return QPalette::Inactive;
- }
-}
-
-void ThemePalette::initStyleSetting()
-{
- GlobalSetting *setting = GlobalSetting::instance();
- m_transparency = setting->get(GlobalSetting::Transparency).toReal();
- m_fontSize = setting->get(GlobalSetting::SystemFontSize).toReal();
- connect(setting, &GlobalSetting::styleChanged, this, &ThemePalette::styleChangedSlot);
- connect(setting, &GlobalSetting::styleChanged, this, &ThemePalette::systemFontSizeChangedSlot);
-}
-
-void ThemePalette::styleChangedSlot(const GlobalSetting::Key& key)
-{
- if (key & GlobalSetting::Transparency) {
- m_transparency = GlobalSetting::instance()->get(GlobalSetting::Transparency).toReal();
- }
-
- Q_EMIT styleColorChanged();
-}
-
-void ThemePalette::systemFontSizeChangedSlot(const GlobalSetting::Key &key)
-{
- if (key & GlobalSetting::SystemFontSize) {
- m_fontSize = GlobalSetting::instance()->get(GlobalSetting::SystemFontSize).toReal();
- }
-
- Q_EMIT systemFontSizeChanged();
-}
-
-qreal ThemePalette::systemFontSize() const
-{
- return m_fontSize;
-}
-
-QFont ThemePalette::systemFont()
-{
- return QGuiApplication::font();
-}
diff --git a/src/uiconfig/theme-palette.h b/src/uiconfig/theme-palette.h
deleted file mode 100644
index 54a4f13..0000000
--- a/src/uiconfig/theme-palette.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2022, KylinSoft Co., Ltd.
- *
- * 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 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * Authors: hxf
- *
- */
-
-#ifndef UKUI_SIDEBAR_THEME_PALETTE_H
-#define UKUI_SIDEBAR_THEME_PALETTE_H
-
-#include
-#include
-#include
-#include "settings.h"
-
-namespace UkuiMenu {
-
-class Palette {
- Q_GADGET
-public:
- // Warning 警告: 谨防 qt版本更新后,删除,增加或者调整调色板的枚举值
- enum ColorGroup {
- Active, Disabled, Inactive
- };
-
- Q_ENUM(ColorGroup)
-
- enum ColorRole {
- Window, WindowText, Base, BrightText, Text, AlternateBase,
- Button, ButtonText, Light, MidLight, Dark, Mid, Shadow,
- Highlight, HighlightedText
- };
-
- Q_ENUM(ColorRole)
-};
-
-class ThemePalette : public QObject {
- Q_OBJECT
-public:
- static ThemePalette *getInstance();
-
- /**
- * 根据调色板的枚举值,获取主题调色板的颜色
- * @param colorRole
- * @return
- */
- Q_INVOKABLE QColor
- paletteColor(Palette::ColorRole colorRole, Palette::ColorGroup colorGroup = Palette::Active) const;
-
- /**
- * 获取自定义透明度的颜色
- * @param colorRole
- * @return
- */
- Q_INVOKABLE QColor
- paletteColorWithCustomTransparency(Palette::ColorRole colorRole, Palette::ColorGroup colorGroup,
- qreal alphaF) const;
-
- /**
- * 获取带有主题透明度的颜色
- * @param colorRole
- * @return
- */
- Q_INVOKABLE QColor paletteColorWithTransparency(Palette::ColorRole colorRole,
- Palette::ColorGroup colorGroup = Palette::Active) const;
-
- Q_INVOKABLE QColor window(Palette::ColorGroup colorGroup = Palette::Active) const;
- Q_INVOKABLE QColor windowText(Palette::ColorGroup colorGroup = Palette::Active) const;
- Q_INVOKABLE QColor base(Palette::ColorGroup colorGroup = Palette::Active) const;
- Q_INVOKABLE QColor text(Palette::ColorGroup colorGroup = Palette::Active) const;
- Q_INVOKABLE QColor brightText(Palette::ColorGroup colorGroup = Palette::Active) const;
- Q_INVOKABLE QColor alternateBase(Palette::ColorGroup colorGroup = Palette::Active) const;
- Q_INVOKABLE QColor button(Palette::ColorGroup colorGroup = Palette::Active) const;
- Q_INVOKABLE QColor buttonText(Palette::ColorGroup colorGroup = Palette::Active) const;
- Q_INVOKABLE QColor light(Palette::ColorGroup colorGroup = Palette::Active) const;
- Q_INVOKABLE QColor midLight(Palette::ColorGroup colorGroup = Palette::Active) const;
- Q_INVOKABLE QColor dark(Palette::ColorGroup colorGroup = Palette::Active) const;
- Q_INVOKABLE QColor mid(Palette::ColorGroup colorGroup = Palette::Active) const;
- Q_INVOKABLE QColor shadow(Palette::ColorGroup colorGroup = Palette::Active) const;
- Q_INVOKABLE QColor highlight(Palette::ColorGroup colorGroup = Palette::Active) const;
- Q_INVOKABLE QColor highlightedText(Palette::ColorGroup colorGroup = Palette::Active) const;
- Q_INVOKABLE QColor separator(Palette::ColorGroup colorGroup = Palette::Active) const;
-
- Q_INVOKABLE qreal systemFontSize() const;
- Q_INVOKABLE QFont systemFont();
-
-Q_SIGNALS:
- void styleColorChanged();
- void systemFontChanged();
- void systemFontSizeChanged();
-
-private Q_SLOTS:
- void styleChangedSlot(const GlobalSetting::Key& key);
- void systemFontSizeChangedSlot(const GlobalSetting::Key& key);
-
-private:
- explicit ThemePalette(QObject *parent = nullptr);
- static QPalette::ColorGroup switchColorGroup(Palette::ColorGroup colorGroup);
- void initStyleSetting();
-
-private:
- qreal m_transparency = 1.0;
- qreal m_fontSize = 12;
-};
-
-}
-
-#endif //UKUI_SIDEBAR_THEME_PALETTE_H
diff --git a/src/ukui-menu-application.cpp b/src/ukui-menu-application.cpp
index 07d20f1..e0ca741 100644
--- a/src/ukui-menu-application.cpp
+++ b/src/ukui-menu-application.cpp
@@ -20,16 +20,13 @@
#include "menu-dbus-service.h"
#include "settings.h"
#include "commons.h"
-#include "theme-palette.h"
-#include "app-icon-provider.h"
#include "menu-main-window.h"
#include "power-button.h"
-#include "items/theme-icon.h"
#include "app-manager.h"
#include "context-menu-manager.h"
#include "event-track.h"
#include "sidebar-button-utils.h"
-#include "extension/widget-model.h"
+#include "widget-model.h"
#include "app-page-backend.h"
#include "app-group-model.h"
@@ -66,7 +63,8 @@ void UkuiMenuApplication::registerQmlTypes()
qmlRegisterType(uri, versionMajor, versionMinor, "WidgetModel");
qmlRegisterType(uri, versionMajor, versionMinor, "AppGroupModel");
- qmlRegisterType(uri, versionMajor, versionMinor, "AppPageBackend");
+ //qmlRegisterType(uri, versionMajor, versionMinor, "AppPageBackend");
+ qmlRegisterSingletonInstance(uri, versionMajor, versionMinor, "AppPageBackend", AppPageBackend::instance());
qmlRegisterUncreatableType(uri, versionMajor, versionMinor, "PluginGroup", "Use enums only.");
// commons
@@ -78,11 +76,6 @@ void UkuiMenuApplication::registerQmlTypes()
qmlRegisterUncreatableType(uri, versionMajor, versionMinor, "MenuInfo", "Use enums only.");
// qmlRegisterUncreatableType(uri, versionMajor, versionMinor, "DataEntity", "unknown");
- // vis colors
- qmlRegisterType(uri, versionMajor, versionMinor, "ThemeIcon");
- qRegisterMetaType("Palette::ColorRole");
- qRegisterMetaType("Palette::ColorGroup");
- qmlRegisterUncreatableType(uri, versionMajor, versionMinor, "Palette", "Use enums only.");
qmlRegisterUncreatableType(uri, versionMajor, versionMinor, "EventTrack", "Attached only.");
}
@@ -90,10 +83,8 @@ void UkuiMenuApplication::initQmlEngine()
{
m_engine = new QQmlEngine(this);
m_engine->addImportPath("qrc:/qml");
- m_engine->addImageProvider("appicon", new AppIconProvider());
QQmlContext *context = m_engine->rootContext();
- context->setContextProperty("themePalette", ThemePalette::getInstance());
context->setContextProperty("menuSetting", MenuSetting::instance());
context->setContextProperty("menuManager", ContextMenuManager::instance());
context->setContextProperty("appManager", AppManager::instance());
@@ -124,7 +115,6 @@ void UkuiMenuApplication::loadMenuUI()
}
execCommand(Hide);
-// DataProviderManager::instance()->toUpdate(false);
});
}
@@ -173,8 +163,8 @@ void UkuiMenuApplication::execCommand(Command command)
default:
break;
}
-// bool isShowed = m_mainWindow->isVisible();
-// DataProviderManager::instance()->toUpdate(isShowed);
+
+ // TODO: 发送窗口显示隐藏信号到插件
}
UkuiMenuApplication::~UkuiMenuApplication()
diff --git a/src/utils/app-manager.cpp b/src/utils/app-manager.cpp
index 58d0cff..3a7042d 100644
--- a/src/utils/app-manager.cpp
+++ b/src/utils/app-manager.cpp
@@ -19,7 +19,7 @@
#include
#include "app-manager.h"
-#include "app-data-manager.h"
+#include "basic-app-model.h"
#include
#include
@@ -50,7 +50,6 @@ void AppManager::launchApp(const QString &desktopFilePath)
}
Q_EMIT request(UkuiMenuApplication::Hide);
- AppDataManager::instance()->appLaunch(desktopFilePath);
QDBusMessage message = QDBusMessage::createMethodCall(KYLIN_APP_MANAGER_NAME, KYLIN_APP_MANAGER_PATH, KYLIN_APP_MANAGER_INTERFACE, "LaunchApp");
message << desktopFilePath;
@@ -72,6 +71,8 @@ void AppManager::launchApp(const QString &desktopFilePath)
}
self->deleteLater();
});
+
+ BasicAppModel::instance()->databaseInterface()->updateApLaunchedState(desktopFilePath, true);
}
void AppManager::launchBinaryApp(const QString &app, const QString &args)
@@ -113,13 +114,9 @@ void AppManager::launchAppWithArguments(const QString &desktopFile, const QStrin
});
}
-void AppManager::changeFavoriteState(const QString &desktopFilePath, bool isFavorite)
+void AppManager::changeFavoriteState(const QString &appid, bool isFavorite)
{
- if (isFavorite) {
- Q_EMIT AppDataManager::instance()->fixToFavoriteSignal(desktopFilePath, 0);
- } else {
- Q_EMIT AppDataManager::instance()->fixToFavoriteSignal(desktopFilePath, 1);
- }
+ BasicAppModel::instance()->databaseInterface()->fixAppToFavorite(appid, isFavorite ? 1 : 0);
}
QString AppManager::parseDesktopFile(const QString &desktopFilePath)
diff --git a/src/utils/app-manager.h b/src/utils/app-manager.h
index 29ae7cf..10dbf35 100644
--- a/src/utils/app-manager.h
+++ b/src/utils/app-manager.h
@@ -36,7 +36,7 @@ public:
Q_INVOKABLE void launchApp(const QString &desktopFilePath);
Q_INVOKABLE void launchBinaryApp(const QString &app, const QString &args = QString());
Q_INVOKABLE void launchAppWithArguments(const QString &desktopFile, const QStringList &args, const QString &applicationName);
- Q_INVOKABLE void changeFavoriteState(const QString &desktopFilePath, bool isFavorite);
+ Q_INVOKABLE void changeFavoriteState(const QString &appid, bool isFavorite);
private:
explicit AppManager(QObject *parent = nullptr);
diff --git a/src/windows/menu-main-window.cpp b/src/windows/menu-main-window.cpp
index bba2b34..3dcac22 100644
--- a/src/windows/menu-main-window.cpp
+++ b/src/windows/menu-main-window.cpp
@@ -58,7 +58,6 @@ struct MotifWmHints {
void WindowModule::defineModule(const char *uri, int versionMajor, int versionMinor)
{
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
qmlRegisterRevision(uri, versionMajor, versionMinor);
qmlRegisterRevision(uri, versionMajor, versionMinor);
@@ -74,8 +73,6 @@ void WindowModule::defineModule(const char *uri, int versionMajor, int versionMi
qmlRegisterRevision(uri, versionMajor, versionMinor);
#endif
#endif
-#endif
- qmlRegisterType(uri, versionMajor, versionMinor, "MenuMainWindow");
#endif
}
@@ -139,84 +136,7 @@ void WindowHelper::windowBlur(QWindow *window, bool enable, const QRegion ®io
KWindowEffects::enableBlurBehind(window->winId(), enable, region);
}
-//======MenuMainWindow======//
-MenuMainWindow::MenuMainWindow(QWindow *parent) : QQuickWindow(parent), m_geometryHelper(new WindowGeometryHelper(this))
-{
- init();
- connect(m_geometryHelper, &WindowGeometryHelper::geometryChanged, this, [this] {
- QEvent event(QEvent::Move);
- QCoreApplication::sendEvent(this, &event);
- });
-}
-
-void MenuMainWindow::init()
-{
- setTitle(QCoreApplication::applicationName());
- setColor("transparent");
-
- setFlags(Qt::FramelessWindowHint);
- WindowHelper::setWindowAttribute(this);
-}
-
-void MenuMainWindow::exposeEvent(QExposeEvent *event)
-{
- QQuickWindow::exposeEvent(event);
-}
-
-void MenuMainWindow::showEvent(QShowEvent *event)
-{
- QQuickWindow::showEvent(event);
-}
-
-void MenuMainWindow::focusOutEvent(QFocusEvent *event)
-{
- QQuickWindow::focusOutEvent(event);
-}
-
-bool MenuMainWindow::event(QEvent *event)
-{
- if (event->type() == QEvent::Move || event->type() == QEvent::Resize) {
- updateGeometry();
- return true;
- }
-
- return QQuickWindow::event(event);
-}
-
-bool MenuMainWindow::isFullScreen()
-{
- return m_isFullScreen;
-}
-
-void MenuMainWindow::setFullScreen(bool isFullScreen)
-{
- if (m_isFullScreen == isFullScreen) {
- return;
- }
-
- m_isFullScreen = isFullScreen;
- QEvent event(QEvent::Resize);
- QCoreApplication::sendEvent(this, &event);
-
- Q_EMIT fullScreenChanged();
-}
-
-void MenuMainWindow::updateGeometry()
-{
- QRect rect = m_isFullScreen ? m_geometryHelper->fullScreenGeometry() : m_geometryHelper->normalGeometry();
- if (rect == geometry()) {
- return;
- }
-
- WindowHelper::setWindowGeometry(this, rect);
-
- QQuickItem *item = contentItem();
- if (item) {
- item->setPosition({0, 0});
- item->setSize(size());
- }
-}
-
+// ====== WindowGeometryHelper ====== //
WindowGeometryHelper::WindowGeometryHelper(QObject *parent) : QObject(parent)
{
initPanelSetting();
diff --git a/src/windows/menu-main-window.h b/src/windows/menu-main-window.h
index b541b08..3a4a7d4 100644
--- a/src/windows/menu-main-window.h
+++ b/src/windows/menu-main-window.h
@@ -73,35 +73,6 @@ private:
QRect m_fullScreenGeometry;
};
-class MenuMainWindow : public QQuickWindow
-{
- Q_OBJECT
- Q_PROPERTY(bool isFullScreen READ isFullScreen WRITE setFullScreen NOTIFY fullScreenChanged)
-
-public:
- explicit MenuMainWindow(QWindow *parent = nullptr);
-
- bool isFullScreen();
- void setFullScreen(bool isFullScreen);
-
-Q_SIGNALS:
- void fullScreenChanged();
-
-protected:
- void exposeEvent(QExposeEvent *event) override;
- void showEvent(QShowEvent *event) override;
- void focusOutEvent(QFocusEvent *event) override;
- bool event(QEvent *event) override;
-
-private:
- void init();
- void updateGeometry();
-
-private:
- bool m_isFullScreen{false};
- WindowGeometryHelper *m_geometryHelper{nullptr};
-};
-
class MenuWindow : public QQuickView
{
Q_OBJECT