feat(ukui-menu): Change the style of the classification function button
This commit is contained in:
parent
75c530f9cc
commit
1c86a7a981
|
@ -30,12 +30,6 @@ Item {
|
||||||
property Component content: null
|
property Component content: null
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
function changeToSearch(keyEvent) {
|
|
||||||
if (appPageHeaderRoot.content === null) {
|
|
||||||
loader.item.changeToSearchState(keyEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: loader
|
id: loader
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -50,65 +44,6 @@ Item {
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
Item {
|
|
||||||
id: searchBar
|
|
||||||
width: parent.width; height: 30
|
|
||||||
Component.onCompleted: {
|
|
||||||
visible = false;
|
|
||||||
mainWindow.visibleChanged.connect(searchBarHide);
|
|
||||||
}
|
|
||||||
Component.onDestruction: mainWindow.visibleChanged.disconnect(searchBarHide);
|
|
||||||
|
|
||||||
function searchBarHide() {
|
|
||||||
if (!mainWindow.visible) {
|
|
||||||
root.state = "normal"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.leftMargin: 15
|
|
||||||
anchors.rightMargin: 15
|
|
||||||
spacing: 10
|
|
||||||
|
|
||||||
SearchInputBar {
|
|
||||||
id: searchInputBar
|
|
||||||
property string providerId: ""
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.fillHeight: true
|
|
||||||
radius: 16
|
|
||||||
changeFocusTarget: focusToPageContent
|
|
||||||
onTextChanged: {
|
|
||||||
if (text === "") {
|
|
||||||
pluginSelectMenu.model.reactivateProvider();
|
|
||||||
} else {
|
|
||||||
appPageHeaderUtils.activateProvider(providerId);
|
|
||||||
appPageHeaderUtils.startSearch(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AppControls2.RoundButton {
|
|
||||||
Layout.preferredWidth: parent.height; Layout.preferredHeight: parent.height
|
|
||||||
buttonIcon: "image://appicon/edit-clear-symbolic"
|
|
||||||
activeFocusOnTab: true
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
normalUI.focusToFalse();
|
|
||||||
searchInputBar.clear();
|
|
||||||
root.state = "normal";
|
|
||||||
}
|
|
||||||
Keys.onPressed: {
|
|
||||||
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
|
|
||||||
searchInputBar.clear();
|
|
||||||
root.state = "normal";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: pluginSelectionBar
|
id: pluginSelectionBar
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
@ -125,12 +60,12 @@ Item {
|
||||||
font.bold: true
|
font.bold: true
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginSelectMenu {
|
PluginSelectButton {
|
||||||
id: pluginSelectMenu
|
id: pluginSelectButton
|
||||||
Layout.preferredWidth: childrenRect.width
|
Layout.preferredWidth: 64
|
||||||
Layout.preferredHeight: 32
|
Layout.preferredHeight: 32
|
||||||
Layout.maximumHeight: 32
|
Layout.maximumHeight: 32
|
||||||
Layout.minimumWidth: 32
|
Layout.minimumWidth: 64
|
||||||
Layout.rightMargin: 8
|
Layout.rightMargin: 8
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,15 @@ Item {
|
||||||
clip: true
|
clip: true
|
||||||
property alias searchOpacity: searchInputBar.opacity
|
property alias searchOpacity: searchInputBar.opacity
|
||||||
property alias searchText: searchInputBar.text
|
property alias searchText: searchInputBar.text
|
||||||
|
|
||||||
|
PluginSelectButton {
|
||||||
|
id: pluginSelectButton
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.leftMargin: 72
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
height: 32; width: 64
|
||||||
|
}
|
||||||
|
|
||||||
SearchInputBar {
|
SearchInputBar {
|
||||||
id: searchInputBar
|
id: searchInputBar
|
||||||
width: 372; height: 36
|
width: 372; height: 36
|
||||||
|
@ -18,7 +27,7 @@ Item {
|
||||||
|
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
if (text === "") {
|
if (text === "") {
|
||||||
pluginSelectMenu.model.reactivateProvider();
|
pluginSelectButton.model.reactivateProvider();
|
||||||
} else {
|
} else {
|
||||||
appPageHeaderUtils.model(PluginGroup.Button).reactivateProvider();
|
appPageHeaderUtils.model(PluginGroup.Button).reactivateProvider();
|
||||||
appPageHeaderUtils.startSearch(text);
|
appPageHeaderUtils.startSearch(text);
|
||||||
|
@ -29,15 +38,6 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginSelectMenu {
|
|
||||||
id: pluginSelectMenu
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.rightMargin: 72 // 48+24
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
height: 48; width: 72 // 48+16+8
|
|
||||||
spacing: 8
|
|
||||||
}
|
|
||||||
|
|
||||||
AppControls2.StyleBackground {
|
AppControls2.StyleBackground {
|
||||||
width: 48; height: width
|
width: 48; height: width
|
||||||
radius: 4
|
radius: 4
|
||||||
|
|
|
@ -0,0 +1,121 @@
|
||||||
|
/*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.12
|
||||||
|
import QtQuick.Layouts 1.12
|
||||||
|
import QtQuick.Controls 2.12
|
||||||
|
|
||||||
|
import AppControls2 1.0 as AppControls2
|
||||||
|
import org.ukui.menu.core 1.0
|
||||||
|
import org.ukui.menu.utils 1.0
|
||||||
|
import org.ukui.quick.items 1.0 as UkuiItems
|
||||||
|
|
||||||
|
UkuiItems.StyleBackground {
|
||||||
|
useStyleTransparency: false
|
||||||
|
paletteRole: UkuiItems.Theme.Text
|
||||||
|
radius: childrenRect.width / 2
|
||||||
|
alpha: 0.06
|
||||||
|
|
||||||
|
|
||||||
|
function resetFocus() {
|
||||||
|
if(!mainWindow.isFullScreen) {
|
||||||
|
normalUI.focusToFalse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: pluginSortButtonRoot
|
||||||
|
property int currentId: 0
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.topMargin: 2
|
||||||
|
anchors.bottomMargin: 2
|
||||||
|
anchors.leftMargin: 2
|
||||||
|
anchors.rightMargin: 2
|
||||||
|
property var model: appPageHeaderUtils.model(PluginGroup.SortMenuItem)
|
||||||
|
spacing: 4
|
||||||
|
|
||||||
|
UkuiItems.Button {
|
||||||
|
id: pluginLetterSortButton
|
||||||
|
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.maximumWidth: height
|
||||||
|
activeFocusOnTab: true
|
||||||
|
ToolTip.delay: 500
|
||||||
|
ToolTip.text: qsTr("Letter Sort")
|
||||||
|
ToolTip.visible: containsMouse
|
||||||
|
|
||||||
|
background.radius: width / 2
|
||||||
|
icon.mode: parent.currentId === 0 ? mainWindow.isFullScreen ? UkuiItems.Icon.AutoHighlight : UkuiItems.Icon.Normal : UkuiItems.Icon.Disabled
|
||||||
|
icon.source: pluginSortButtonRoot.model.getProviderIcon(0);
|
||||||
|
background.paletteRole: UkuiItems.Theme.Light
|
||||||
|
background.alpha: parent.currentId === 0 ? 0.7 : 0
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
resetFocus();
|
||||||
|
pluginSortButtonRoot.model.changeProvider(0);
|
||||||
|
}
|
||||||
|
Keys.onPressed: {
|
||||||
|
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
|
||||||
|
pluginSortButtonRoot.model.changeProvider(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UkuiItems.Button {
|
||||||
|
id: pluginCateGoryButton
|
||||||
|
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.maximumWidth: height
|
||||||
|
activeFocusOnTab: true
|
||||||
|
ToolTip.delay: 500
|
||||||
|
ToolTip.text: qsTr("Category")
|
||||||
|
ToolTip.visible: containsMouse
|
||||||
|
|
||||||
|
background.radius: width / 2
|
||||||
|
icon.mode: parent.currentId === 1 ? mainWindow.isFullScreen ? UkuiItems.Icon.AutoHighlight : UkuiItems.Icon.Normal : UkuiItems.Icon.Disabled
|
||||||
|
icon.source: pluginSortButtonRoot.model.getProviderIcon(1);
|
||||||
|
background.paletteRole: UkuiItems.Theme.Light
|
||||||
|
background.alpha: parent.currentId === 1 ? 0.7 : 0
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
resetFocus();
|
||||||
|
pluginSortButtonRoot.model.changeProvider(1);
|
||||||
|
}
|
||||||
|
Keys.onPressed: {
|
||||||
|
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
|
||||||
|
pluginSortButtonRoot.model.changeProvider(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
updateProviderId();
|
||||||
|
pluginSortButtonRoot.model.currentIndexChanged.connect(updateProviderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onDestruction: {
|
||||||
|
pluginSortButtonRoot.model.currentIndexChanged.disconnect(updateProviderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateProviderId() {
|
||||||
|
currentId = pluginSortButtonRoot.model.currentProviderId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,151 +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 <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
import QtQuick 2.12
|
|
||||||
import QtQuick.Layouts 1.12
|
|
||||||
import QtQuick.Controls 2.12
|
|
||||||
|
|
||||||
import AppControls2 1.0 as AppControls2
|
|
||||||
import org.ukui.menu.core 1.0
|
|
||||||
import org.ukui.menu.utils 1.0
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
id: pluginSelectMenuRoot
|
|
||||||
property var model: appPageHeaderUtils.model(PluginGroup.SortMenuItem)
|
|
||||||
spacing: 2
|
|
||||||
function resetFocus() {
|
|
||||||
if(!mainWindow.isFullScreen) {
|
|
||||||
normalUI.focusToFalse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AppControls2.RoundButton {
|
|
||||||
id: pluginSelectButton
|
|
||||||
Layout.fillHeight: true
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.maximumWidth: height
|
|
||||||
activeFocusOnTab: true
|
|
||||||
ToolTip.delay: 500
|
|
||||||
ToolTip.text: qsTr("Switch Sort Type")
|
|
||||||
ToolTip.visible: containsMouse
|
|
||||||
|
|
||||||
highlight: mainWindow.isFullScreen
|
|
||||||
autoHighLight: !mainWindow.isFullScreen
|
|
||||||
buttonIcon: "image://appicon/ukui-selected"
|
|
||||||
onClicked: {
|
|
||||||
resetFocus();
|
|
||||||
pluginSelectMenuRoot.model.autoSwitchProvider();
|
|
||||||
}
|
|
||||||
Keys.onPressed: {
|
|
||||||
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
|
|
||||||
pluginSelectMenuRoot.model.autoSwitchProvider();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: sortMenuMouseArea
|
|
||||||
Layout.alignment: Qt.AlignVCenter
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.fillHeight: true
|
|
||||||
Layout.maximumWidth: 16
|
|
||||||
Layout.maximumHeight: 16
|
|
||||||
ToolTip.delay: 500
|
|
||||||
ToolTip.text: qsTr("Sort Type Options")
|
|
||||||
ToolTip.visible: containsMouse
|
|
||||||
hoverEnabled: true
|
|
||||||
|
|
||||||
activeFocusOnTab: true
|
|
||||||
Keys.onPressed: {
|
|
||||||
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
|
|
||||||
sortMenuClicked();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onClicked: {
|
|
||||||
resetFocus();
|
|
||||||
sortMenuClicked();
|
|
||||||
}
|
|
||||||
function sortMenuClicked() {
|
|
||||||
if(sortMenuSelector.state === "sortMenuClose") {
|
|
||||||
sortMenuSelector.state = "sortMenuOpen";
|
|
||||||
}
|
|
||||||
var pressY = sortMenuMouseArea.mapToGlobal(0, 0).y;
|
|
||||||
var pressX = sortMenuMouseArea.mapToGlobal(0, 0).x;
|
|
||||||
pluginSelectMenuRoot.model.openMenu(pluginSelectButton.height - y - mouseY + 8, pressX, pressY);
|
|
||||||
}
|
|
||||||
|
|
||||||
AppControls2.StyleBackground {
|
|
||||||
anchors.fill: parent
|
|
||||||
useStyleTransparent: false
|
|
||||||
paletteRole: Palette.Highlight
|
|
||||||
alpha: 0
|
|
||||||
borderColor: Palette.Highlight
|
|
||||||
border.width: sortMenuMouseArea.activeFocus ? 2 : 0
|
|
||||||
}
|
|
||||||
|
|
||||||
ThemeIcon {
|
|
||||||
id: sortMenuSelector
|
|
||||||
anchors.fill: parent
|
|
||||||
source: "image://appicon/ukui-up-symbolic"
|
|
||||||
opacity: 0.5
|
|
||||||
highLight: mainWindow.isFullScreen
|
|
||||||
autoHighLight: !mainWindow.isFullScreen
|
|
||||||
state: "sortMenuClose"
|
|
||||||
|
|
||||||
states: [
|
|
||||||
State {
|
|
||||||
name: "sortMenuOpen"
|
|
||||||
PropertyChanges { target: sortMenuSelector; rotation: 0 }
|
|
||||||
},
|
|
||||||
State {
|
|
||||||
name: "sortMenuClose"
|
|
||||||
PropertyChanges { target: sortMenuSelector; rotation: 180 }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
transitions: [
|
|
||||||
Transition {
|
|
||||||
to: "sortMenuOpen"
|
|
||||||
RotationAnimation { duration: 100; direction: RotationAnimation.Counterclockwise}
|
|
||||||
},
|
|
||||||
Transition {
|
|
||||||
to: "sortMenuClose"
|
|
||||||
RotationAnimation { duration: 100; direction: RotationAnimation.Clockwise }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
updateProviderIcon();
|
|
||||||
pluginSelectMenuRoot.model.currentIndexChanged.connect(updateProviderIcon);
|
|
||||||
pluginSelectMenuRoot.model.menuClosed.connect(changeMenuStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onDestruction: {
|
|
||||||
pluginSelectMenuRoot.model.currentIndexChanged.disconnect(updateProviderIcon);
|
|
||||||
pluginSelectMenuRoot.model.menuClosed.disconnect(changeMenuStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateProviderIcon() {
|
|
||||||
pluginSelectButton.buttonIcon = pluginSelectMenuRoot.model.currentProviderIcon();
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeMenuStatus() {
|
|
||||||
sortMenuSelector.state = "sortMenuClose";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,7 +8,7 @@ FullScreenUI 1.0 FullScreenUI.qml
|
||||||
AppPageHeader 1.0 AppPageHeader.qml
|
AppPageHeader 1.0 AppPageHeader.qml
|
||||||
AppListView 1.0 AppListView.qml
|
AppListView 1.0 AppListView.qml
|
||||||
SearchInputBar 1.0 SearchInputBar.qml
|
SearchInputBar 1.0 SearchInputBar.qml
|
||||||
PluginSelectMenu 1.0 PluginSelectMenu.qml
|
PluginSelectButton 1.0 PluginSelectButton.qml
|
||||||
FullScreenHeader 1.0 FullScreenHeader.qml
|
FullScreenHeader 1.0 FullScreenHeader.qml
|
||||||
FullScreenContent 1.0 FullScreenContent.qml
|
FullScreenContent 1.0 FullScreenContent.qml
|
||||||
FullScreenFooter 1.0 FullScreenFooter.qml
|
FullScreenFooter 1.0 FullScreenFooter.qml
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
<file>AppControls2/FolderIcon.qml</file>
|
<file>AppControls2/FolderIcon.qml</file>
|
||||||
<file>AppUI/SelectionPage.qml</file>
|
<file>AppUI/SelectionPage.qml</file>
|
||||||
<file>AppUI/AppPageContent.qml</file>
|
<file>AppUI/AppPageContent.qml</file>
|
||||||
<file>AppUI/PluginSelectMenu.qml</file>
|
<file>AppUI/PluginSelectButton.qml</file>
|
||||||
<file>AppUI/EditText.qml</file>
|
<file>AppUI/EditText.qml</file>
|
||||||
<file>AppUI/FullScreenFolder.qml</file>
|
<file>AppUI/FullScreenFolder.qml</file>
|
||||||
<file>AppUI/AppPageSearch.qml</file>
|
<file>AppUI/AppPageSearch.qml</file>
|
||||||
|
|
|
@ -44,10 +44,6 @@ DataProviderManager::DataProviderManager()
|
||||||
|
|
||||||
void DataProviderManager::initProviders()
|
void DataProviderManager::initProviders()
|
||||||
{
|
{
|
||||||
auto *allProvider = new AllAppDataProvider;
|
|
||||||
connect(this, &DataProviderManager::toUpdate, allProvider, &AllAppDataProvider::update);
|
|
||||||
registerProvider(allProvider);
|
|
||||||
|
|
||||||
auto *search = new AppSearchPlugin;
|
auto *search = new AppSearchPlugin;
|
||||||
connect(this, &DataProviderManager::toUpdate, search, &AppSearchPlugin::update);
|
connect(this, &DataProviderManager::toUpdate, search, &AppSearchPlugin::update);
|
||||||
registerProvider(search);
|
registerProvider(search);
|
||||||
|
@ -60,8 +56,7 @@ void DataProviderManager::initProviders()
|
||||||
connect(this, &DataProviderManager::toUpdate, sort, &AppLetterSortPlugin::update);
|
connect(this, &DataProviderManager::toUpdate, sort, &AppLetterSortPlugin::update);
|
||||||
registerProvider(sort);
|
registerProvider(sort);
|
||||||
|
|
||||||
activateProvider(allProvider->id(), false);
|
activateProvider(sort->id(), false);
|
||||||
allProvider->moveToThread(&m_worker);
|
|
||||||
search->moveToThread(&m_worker);
|
search->moveToThread(&m_worker);
|
||||||
category->moveToThread(&m_worker);
|
category->moveToThread(&m_worker);
|
||||||
sort->moveToThread(&m_worker);
|
sort->moveToThread(&m_worker);
|
||||||
|
|
|
@ -41,7 +41,7 @@ AllAppDataProvider::AllAppDataProvider() : DataProviderPluginIFace()
|
||||||
|
|
||||||
int AllAppDataProvider::index()
|
int AllAppDataProvider::index()
|
||||||
{
|
{
|
||||||
return 0;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AllAppDataProvider::id()
|
QString AllAppDataProvider::id()
|
||||||
|
|
|
@ -33,7 +33,7 @@ AppLetterSortPlugin::AppLetterSortPlugin()
|
||||||
|
|
||||||
int AppLetterSortPlugin::index()
|
int AppLetterSortPlugin::index()
|
||||||
{
|
{
|
||||||
return 2;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AppLetterSortPlugin::id()
|
QString AppLetterSortPlugin::id()
|
||||||
|
|
|
@ -39,12 +39,11 @@ public:
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
void updateCurrentPId(const QString &providerId);
|
void updateCurrentPId(const QString &providerId);
|
||||||
//自动在各个插件之间切换
|
//在各个插件之间切换
|
||||||
Q_INVOKABLE void reactivateProvider();
|
Q_INVOKABLE void reactivateProvider();
|
||||||
Q_INVOKABLE void autoSwitchProvider();
|
Q_INVOKABLE void changeProvider(int i);
|
||||||
Q_INVOKABLE QString currentProviderIcon();
|
Q_INVOKABLE QString getProviderIcon(int i);
|
||||||
|
Q_INVOKABLE int currentProviderId();
|
||||||
Q_INVOKABLE void openMenu(int offset, int mouseX, int mouseY);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void currentIndexChanged();
|
void currentIndexChanged();
|
||||||
|
@ -137,47 +136,19 @@ int ProviderModel::indexOfProvider(const QString &providerId)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProviderModel::autoSwitchProvider()
|
void ProviderModel::changeProvider(int i)
|
||||||
{
|
{
|
||||||
m_currentIndex = (m_currentIndex + 1) % m_providers.size();
|
DataProviderManager::instance()->activateProvider(m_providers.at(i).id);
|
||||||
DataProviderManager::instance()->activateProvider(m_providers.at(m_currentIndex).id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ProviderModel::currentProviderIcon()
|
QString ProviderModel::getProviderIcon(int i)
|
||||||
{
|
{
|
||||||
return data(createIndex(m_currentIndex, 0), Icon).toString();
|
return data(createIndex(i, 0), Icon).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProviderModel::openMenu(int offset, int mouseX, int mouseY)
|
int ProviderModel::currentProviderId()
|
||||||
{
|
{
|
||||||
if (m_menu) {
|
return m_currentIndex;
|
||||||
m_menu.data()->close();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMenu *menu = new QMenu;
|
|
||||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
|
|
||||||
if (m_providers.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const ProviderInfo &info : m_providers) {
|
|
||||||
QAction *action = new QAction(info.name, menu);
|
|
||||||
action->setCheckable(true);
|
|
||||||
connect(action, &QAction::triggered, menu, [info]() {
|
|
||||||
DataProviderManager::instance()->activateProvider(info.id);
|
|
||||||
});
|
|
||||||
menu->addAction(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
menu->actions().at(m_currentIndex)->setChecked(true);
|
|
||||||
int x = mouseX - menu->sizeHint().width();
|
|
||||||
int y = mouseY + offset;
|
|
||||||
|
|
||||||
m_menu = menu;
|
|
||||||
connect(menu, &QMenu::aboutToHide, this, &ProviderModel::menuClosed);
|
|
||||||
menu->popup(QPoint(x, y));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProviderModel::reactivateProvider()
|
void ProviderModel::reactivateProvider()
|
||||||
|
|
Loading…
Reference in New Issue