feat(ukcc-plugin):增加ukcc设置页插件

This commit is contained in:
iaom 2023-10-12 14:03:43 +08:00
parent f09f7e8ed1
commit 88f92d1ae0
13 changed files with 867 additions and 6 deletions

View File

@ -11,8 +11,8 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick Widgets LinguistTools REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick Widgets LinguistTools REQUIRED)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick Widgets LinguistTools RemoteObjects REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick Widgets LinguistTools RemoteObjects REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(KF5WindowSystem)
@ -48,8 +48,11 @@ set(PROJECT_SOURCES
src/shell.cpp
src/view/panel.cpp
src/log-utils.cpp
src/remote-config.cpp
src/remote-config.h
src/general-config-define.h
)
qt5_generate_repc(PROJECT_SOURCES src/remote-config.rep SOURCE)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
qt_add_executable(${PROJECT_NAME}
@ -77,12 +80,13 @@ target_link_libraries(${PROJECT_NAME}
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Quick
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::RemoteObjects
KF5::WindowSystem
qtsingleapplication
${UKUI_PANEL_EXTERNAL_LIBS}
ukui-panel-framework
)
add_subdirectory(src/ukcc-plugin)
#if(QT_VERSION_MAJOR EQUAL 6)
# qt_import_qml_plugins(${PROJECT_NAME})
# qt_finalize_executable(${PROJECT_NAME})

View File

@ -0,0 +1,52 @@
/*
*
* * 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/>.
* *
* * Authors: iaom <zhangpengfei@kylinos.cn>
*
*/
#ifndef UKUI_PANEL_GENERALCONFIGDEFINE_H
#define UKUI_PANEL_GENERALCONFIGDEFINE_H
#include <QObject>
class GeneralConfigDefine
{
Q_GADGET
public:
//task manager
enum MergeIcons {
Always = 0,
Never
};
//panel
enum PanelLocation {
Bottom = 0,
Left,
Top,
Right
};
enum PanelSizePolicy {
Small = 0,
Medium,
Large,
Custom
};
Q_ENUM(MergeIcons)
Q_ENUM(PanelLocation)
Q_ENUM(PanelSizePolicy)
};
#endif //UKUI_PANEL_GENERALCONFIGDEFINE_H

View File

@ -0,0 +1,99 @@
/*
*
* * 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/>.
* *
* * Authors: iaom <zhangpengfei@kylinos.cn>
*
*/
#include "remote-config.h"
#include <QVariant>
#include "widget-config-loader.h"
RemoteConfig::RemoteConfig(QObject *parent) : RemoteConfigSource(parent)
, m_mergeIcons(GeneralConfigDefine::MergeIcons::Never)
, m_panelLocation(GeneralConfigDefine::PanelLocation::Bottom)
, m_panelSizePolicy(GeneralConfigDefine::PanelSizePolicy::Small)
, m_panelAutoHide(false)
, m_panelLock(false)
{
qRegisterMetaType<GeneralConfigDefine::MergeIcons>("GeneralConfigDefine::MergeIcons");
qRegisterMetaType<GeneralConfigDefine::PanelLocation>("GeneralConfigDefine::PanelLocation");
qRegisterMetaType<GeneralConfigDefine::PanelSizePolicy>("GeneralConfigDefine::PanelSizePolicy");
m_panel0Config = UkuiPanel::ConfigLoader::loadConfig("panel0", "ukui-panel");
m_taskManagerConfig = UkuiPanel::ConfigLoader::loadWidgetConfig("org.ukui.panel.taskManager");
m_mergeIcons = m_taskManagerConfig->getValue(QStringLiteral("mergeIcons")).value<GeneralConfigDefine::MergeIcons>();
m_panelLocation = m_panel0Config->getValue(QStringLiteral("panelLocation")).value<GeneralConfigDefine::PanelLocation>();
m_panelSizePolicy = m_panel0Config->getValue(QStringLiteral("panelSizePolicy")).value<GeneralConfigDefine::PanelSizePolicy>();
m_panelAutoHide = m_panel0Config->getValue(QStringLiteral("panelAutoHide")).toBool();
m_panelLock = m_panel0Config->getValue(QStringLiteral("panelLock")).toBool();
m_panelWidgets = m_panel0Config->getValue(QStringLiteral("widgets")).toStringList();
}
void RemoteConfig::setMergeIcons(GeneralConfigDefine::MergeIcons mergeIcons)
{
if (mergeIcons != m_mergeIcons) {
m_mergeIcons = mergeIcons;
m_taskManagerConfig->setValue(QStringLiteral("mergeIcons"), mergeIcons);
Q_EMIT mergeIconsChanged(m_mergeIcons);
}
}
void RemoteConfig::setPanelLocation(GeneralConfigDefine::PanelLocation panelLocation)
{
if (panelLocation != m_panelLocation) {
m_panelLocation = panelLocation;
m_panel0Config->setValue(QStringLiteral("panelLocation"), panelLocation);
Q_EMIT panelLocationChanged(m_panelLocation);
}
}
void RemoteConfig::setPanelSizePolicy(GeneralConfigDefine::PanelSizePolicy panelSizePolicy)
{
if (panelSizePolicy != m_panelSizePolicy) {
m_panelSizePolicy = panelSizePolicy;
m_panel0Config->setValue(QStringLiteral("panelSizePolicy"), panelSizePolicy);
Q_EMIT panelSizePolicyChanged(m_panelSizePolicy);
}
}
void RemoteConfig::setPanelAutoHide(bool panelAutoHide)
{
if (panelAutoHide != m_panelAutoHide) {
m_panelAutoHide = panelAutoHide;
m_panel0Config->setValue(QStringLiteral("panelAutoHide"), panelAutoHide);
Q_EMIT panelAutoHideChanged(m_panelAutoHide);
}
}
void RemoteConfig::setPanelLock(bool panelLock)
{
if (panelLock != m_panelLock) {
m_panelLock = panelLock;
m_panel0Config->setValue(QStringLiteral("panelLock"), panelLock);
Q_EMIT panelLockChanged(m_panelLock);
}
}
void RemoteConfig::setPanelWidgets(QStringList panelWidgets)
{
if (panelWidgets != m_panelWidgets) {
m_panelWidgets = panelWidgets;
m_panel0Config->setValue(QStringLiteral("widgets"), panelWidgets);
Q_EMIT panelWidgetsChanged(m_panelWidgets);
}
}

61
panel/src/remote-config.h Normal file
View File

@ -0,0 +1,61 @@
/*
*
* * 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/>.
* *
* * Authors: iaom <zhangpengfei@kylinos.cn>
*
*/
#ifndef UKUI_PANEL_REMOTE_CONFIG_H
#define UKUI_PANEL_REMOTE_CONFIG_H
#include "rep_remote-config_source.h"
#include "ini-config.h"
#include "widget-config.h"
class RemoteConfig : public RemoteConfigSource
{
Q_OBJECT
public:
explicit RemoteConfig(QObject *parent = nullptr);
~RemoteConfig() override = default;
GeneralConfigDefine::MergeIcons mergeIcons() const override { return m_mergeIcons; }
GeneralConfigDefine::PanelLocation panelLocation() const override { return m_panelLocation; }
GeneralConfigDefine::PanelSizePolicy panelSizePolicy() const override { return m_panelSizePolicy; }
bool panelAutoHide() const override { return m_panelAutoHide; }
bool panelLock() const override { return m_panelLock; }
QStringList panelWidgets() const override { return m_panelWidgets; }
void setMergeIcons(GeneralConfigDefine::MergeIcons mergeIcons) override;
void setPanelLocation(GeneralConfigDefine::PanelLocation panelLocation) override;
void setPanelSizePolicy(GeneralConfigDefine::PanelSizePolicy panelSizePolicy) override;
void setPanelAutoHide(bool panelAutoHide) override;
void setPanelLock(bool panelLock) override;
void setPanelWidgets(QStringList panelWidgets) override;
private:
GeneralConfigDefine::MergeIcons m_mergeIcons;
GeneralConfigDefine::PanelLocation m_panelLocation;
GeneralConfigDefine::PanelSizePolicy m_panelSizePolicy;
bool m_panelAutoHide;
bool m_panelLock;
QStringList m_panelWidgets;
UkuiPanel::IniConfig *m_panel0Config = nullptr;
UkuiPanel::WidgetConfig *m_taskManagerConfig = nullptr;
};
#endif //UKUI_PANEL_REMOTE_CONFIG_H

View File

@ -0,0 +1,11 @@
#include "general-config-define.h"
#include <QStringList>
class RemoteConfig
{
PROP(GeneralConfigDefine::MergeIcons mergeIcons READWRITE);
PROP(GeneralConfigDefine::PanelLocation panelLocation READWRITE);
PROP(GeneralConfigDefine::PanelSizePolicy panelSizePolicy READWRITE);
PROP(bool panelAutoHide READWRITE);
PROP(bool panelLock READWRITE);
PROP(QStringList panelWidgets READWRITE);
};

View File

@ -10,7 +10,9 @@ using namespace UkuiPanel;
Shell::Shell(QObject *parent) : QObject(parent)
{
m_remoteConfig = new RemoteConfig(this);
m_qroHost.setHostUrl(QUrl(QStringLiteral("local:ukui-panel-config")));
qDebug() << "Init remote status object:" << m_qroHost.enableRemoting<RemoteConfigSourceAPI>(m_remoteConfig);
}
void Shell::start()

View File

@ -4,6 +4,8 @@
#include <QObject>
#include <QMap>
#include <QtRemoteObjects/qremoteobjectnode.h>
#include "remote-config.h"
class QScreen;
@ -20,6 +22,8 @@ public:
private:
QMap<QScreen*, Panel*> m_panels;
RemoteConfig *m_remoteConfig = nullptr;
QRemoteObjectHost m_qroHost;
};
} // UkuiPanel

View File

@ -0,0 +1,53 @@
cmake_minimum_required(VERSION 3.14)
project(panel-ukcc-plugin)
set(VERSION_MAJOR 1)
set(VERSION_MINOR 0)
set(VERSION_MICRO 0)
set(PANEL_UKCC_PLUGIN_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO})
find_package(PkgConfig REQUIRED)
set(UKCC_PLUGIN_PC_PKGS kysdk-qtwidgets)
foreach(PC_LIB IN ITEMS ${UKCC_PLUGIN_PC_PKGS})
pkg_check_modules(${PC_LIB} REQUIRED ${PC_LIB})
if(${${PC_LIB}_FOUND})
include_directories(${${PC_LIB}_INCLUDE_DIRS})
link_directories(${${PC_LIB}_LIBRARY_DIRS})
list(APPEND UKCC_PLUGIN_EXTERNAL_LIBS PkgConfig::${PC_LIB})
endif()
endforeach()
file(GLOB UKCC_PLUGIN_TS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts)
qt5_create_translation(UKCC_PLUGIN_QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${UKCC_PLUGIN_TS_FILES})
set(UKCC_PLUGIN_SRC
panel-ukcc-plugin.cpp
panel-ukcc-plugin.h
../general-config-define.h
)
qt5_generate_repc(UKCC_PLUGIN_SRC ../remote-config.rep REPLICA)
add_library(panel-ukcc-plugin MODULE
${UKCC_PLUGIN_SRC}
${UKCC_PLUGIN_QM_FILES}
)
set(TRANSLATIONS_INSTALL_PATH /usr/share/ukui-panel/panel-ukcc-plugin/translations/)
target_compile_definitions(panel-ukcc-plugin PRIVATE
VERSION="${PANEL_UKCC_PLUGIN_VERSION}"
TRANSLATIONS_INSTALL_PATH="${TRANSLATIONS_INSTALL_PATH}"
)
target_link_libraries(panel-ukcc-plugin PRIVATE
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::RemoteObjects
ukcc
${UKCC_PLUGIN_PC_PKGS}
)
install(TARGETS panel-ukcc-plugin
DESTINATION /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/ukui-control-center)
install(FILES
${UKCC_PLUGIN_TS_FILES}
${UKCC_PLUGIN_QM_FILES}
DESTINATION ${TRANSLATIONS_INSTALL_PATH})

View File

@ -0,0 +1,310 @@
/*
*
* * 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/>.
* *
* * Authors: iaom <zhangpengfei@kylinos.cn>
*
*/
#include "panel-ukcc-plugin.h"
#include <QTranslator>
#include <QApplication>
#include "general-config-define.h"
PanelUkccPlugin::PanelUkccPlugin(QObject *parent): QObject(parent)
{
auto translator = new QTranslator(this);
if(!translator->load(TRANSLATIONS_INSTALL_PATH + QLocale::system().name())) {
qWarning() << TRANSLATIONS_INSTALL_PATH + QLocale::system().name() << "load failed";
}
QApplication::installTranslator(translator);
initUI();
connectToSource();
}
QString PanelUkccPlugin::plugini18nName()
{
return tr("Panel");
}
int PanelUkccPlugin::pluginTypes()
{
return PERSONALIZED;
}
QWidget *PanelUkccPlugin::pluginUi()
{
return m_widget;
}
const QString PanelUkccPlugin::name() const
{
return tr("Panel");
}
QString PanelUkccPlugin::translationPath() const
{
return TRANSLATIONS_INSTALL_PATH;
}
bool PanelUkccPlugin::isShowOnHomePage() const
{
return false;
}
QIcon PanelUkccPlugin::icon() const
{
return QIcon::fromTheme("ukui-panel-symbolic");
}
bool PanelUkccPlugin::isEnable() const
{
return true;
}
void PanelUkccPlugin::connectToSource()
{
qDebug() << "panel ukcc plugin connect to source:" << m_qroNode.connectToNode(QUrl(QStringLiteral("local:ukui-panel-config")));
m_configReplica = m_qroNode.acquire<RemoteConfigReplica>();
connect(m_configReplica, &QRemoteObjectReplica::initialized, this, &PanelUkccPlugin::initData);
connect(m_configReplica, &QRemoteObjectReplica::stateChanged, this, &PanelUkccPlugin::sourceStateChanged);
}
void PanelUkccPlugin::initUI()
{
m_widget = new QWidget;
// main page
m_mainLayout = new QVBoxLayout(m_widget);
m_mainLayout->setSpacing(8);
m_mainLayout->setContentsMargins(0, 0, 0, 0);
// panel
m_titleLabel1 = new TitleLabel(m_widget);
m_titleLabel1->setText(tr("Panel"));
m_mainLayout->addWidget(m_titleLabel1);
m_frame1 = new QFrame(m_widget);
m_frame1->setFrameShape(QFrame::Shape::Box);
m_vLayout1 = new QVBoxLayout(m_frame1);
m_vLayout1->setContentsMargins(0, 0, 0, 0);
m_vLayout1->setSpacing(0);
//merge icons
m_mergeIconsFrame = new QFrame(m_frame1);
m_mergeIconsFrame->setFixedHeight(56);
m_mergeIconsLayout = new QHBoxLayout(m_mergeIconsFrame);
m_mergeIconsLayout->setContentsMargins(16, 0, 16, 0);
m_mergeIconsLabel = new QLabel(m_mergeIconsFrame);
m_mergeIconsLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_mergeIconsLabel->setText(tr("Merge icons on the taskbar"));
m_mergeIcons = new QComboBox(m_mergeIconsFrame);
m_mergeIcons->setEnabled(false);
m_mergeIcons->setMinimumWidth(320);
m_mergeIcons->addItem(tr("Always"), GeneralConfigDefine::MergeIcons::Always);
m_mergeIcons->addItem(tr("Never"), GeneralConfigDefine::MergeIcons::Never);
m_mergeIconsLayout->addWidget(m_mergeIconsLabel);
m_mergeIconsLayout->addWidget(m_mergeIcons);
m_vLayout1->addWidget(m_mergeIconsFrame);
m_vLayout1->addWidget(setLine(m_frame1));
//panel location
m_panelLocationFrame = new QFrame(m_frame1);
m_panelLocationFrame->setFixedHeight(56);
m_panelLocationLayout = new QHBoxLayout(m_panelLocationFrame);
m_panelLocationLayout->setContentsMargins(16, 0, 16, 0);
m_panelLocationLabel = new QLabel(m_panelLocationFrame);
m_panelLocationLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_panelLocationLabel->setText(tr("Panel location"));
m_panelLocation = new QComboBox(m_panelLocationFrame);
m_panelLocation->setEnabled(false);
m_panelLocation->setMinimumWidth(320);
m_panelLocation->addItem(tr("Bottom"), GeneralConfigDefine::PanelLocation::Bottom);
m_panelLocation->addItem(tr("Left"), GeneralConfigDefine::PanelLocation::Left);
m_panelLocation->addItem(tr("Top"), GeneralConfigDefine::PanelLocation::Top);
m_panelLocation->addItem(tr("Right"), GeneralConfigDefine::PanelLocation::Right);
m_panelLocationLayout->addWidget(m_panelLocationLabel);
m_panelLocationLayout->addWidget(m_panelLocation);
m_vLayout1->addWidget(m_panelLocationFrame);
m_vLayout1->addWidget(setLine(m_frame1));
//panel size
m_panelSizePolicyFrame = new QFrame(m_frame1);
m_panelSizePolicyFrame->setFixedHeight(56);
m_panelSizePolicyLayout = new QHBoxLayout(m_panelSizePolicyFrame);
m_panelSizePolicyLayout->setContentsMargins(16, 0, 16, 0);
m_panelSizePolicyLabel = new QLabel(m_panelSizePolicyFrame);
m_panelSizePolicyLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_panelSizePolicyLabel->setText(tr("Panel size"));
m_panelSizePolicy = new QComboBox(m_panelSizePolicyFrame);
m_panelSizePolicy->setEnabled(false);
m_panelSizePolicy->setMinimumWidth(320);
m_panelSizePolicy->addItem(tr("Small"), GeneralConfigDefine::PanelSizePolicy::Small);
m_panelSizePolicy->addItem(tr("Medium"), GeneralConfigDefine::PanelSizePolicy::Medium);
m_panelSizePolicy->addItem(tr("Large"), GeneralConfigDefine::PanelSizePolicy::Large);
m_panelSizePolicy->addItem(tr("Custom"), GeneralConfigDefine::PanelSizePolicy::Custom);
m_panelSizePolicyLayout->addWidget(m_panelSizePolicyLabel);
m_panelSizePolicyLayout->addWidget(m_panelSizePolicy);
m_vLayout1->addWidget(m_panelSizePolicyFrame);
m_vLayout1->addWidget(setLine(m_frame1));
//panel auto hide
m_panelAutoHideFrame = new QFrame(m_frame1);
m_panelAutoHideFrame->setFixedHeight(56);
m_panelAutoHideLayout = new QHBoxLayout(m_panelAutoHideFrame);
m_panelAutoHideLayout->setContentsMargins(16, 0, 16, 0);
m_panelAutoHideLabel = new QLabel(m_panelAutoHideFrame);
m_panelAutoHideLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_panelAutoHideLabel->setText(tr("Panel auto hide"));
m_panelAutoHide = new kdk::KSwitchButton(m_panelAutoHideFrame);
m_panelAutoHide->setFixedSize(48,24);
// m_panelAutoHide->setCheckable(false);
m_panelAutoHide->setEnabled(false);
m_panelAutoHideLayout->addWidget(m_panelAutoHideLabel);
m_panelAutoHideLayout->addWidget(m_panelAutoHide);
m_vLayout1->addWidget(m_panelAutoHideFrame);
m_vLayout1->addWidget(setLine(m_frame1));
//panel lock
m_panelLockFrame = new QFrame(m_frame1);
m_panelLockFrame->setFixedHeight(56);
m_panelLockLayout = new QHBoxLayout(m_panelLockFrame);
m_panelLockLayout->setContentsMargins(16, 0, 16, 0);
m_panelLockLabel = new QLabel(m_panelLockFrame);
m_panelLockLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_panelLockLabel->setText(tr("Panel lock"));
m_panelLock = new kdk::KSwitchButton(m_panelLockFrame);
m_panelLock->setFixedSize(48,24);
// m_panelLock->setCheckable(false);
m_panelLock->setEnabled(false);
m_panelLockLayout->addWidget(m_panelLockLabel);
m_panelLockLayout->addWidget(m_panelLock);
m_vLayout1->addWidget(m_panelLockFrame);
m_mainLayout->addWidget(m_frame1);
m_mainLayout->addSpacerItem(new QSpacerItem(40, 40, QSizePolicy::Fixed));
//widgets showed on panel
m_titleLabel2 = new TitleLabel(m_widget);
m_titleLabel2->setText(tr("Widgets always showed on panel"));
m_mainLayout->addWidget(m_titleLabel2);
m_frame2 = new QFrame(m_widget);
m_frame2->setFixedHeight(56);
m_frame2->setFrameShape(QFrame::Box);
m_vLayout2 = new QVBoxLayout(m_frame2);
m_vLayout2->setContentsMargins(0, 0, 0, 0);
m_vLayout2->setSpacing(0);
//task view
m_showTaskViewFrame = new QFrame(m_frame2);
m_showTaskViewFrame->setFixedHeight(56);
m_showTaskViewLayout = new QHBoxLayout(m_showTaskViewFrame);
m_showTaskViewLayout->setContentsMargins(16, 0, 16, 0);
m_showTaskViewLabel = new QLabel(m_showTaskViewFrame);
m_showTaskViewLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_showTaskViewLabel->setText(tr("Task view"));
m_showTaskView = new kdk::KSwitchButton(m_showTaskViewFrame);
m_showTaskView->setFixedSize(48,24);
// m_showTaskView->setCheckable(false);
m_showTaskView->setEnabled(false);
m_showTaskViewLayout->addWidget(m_showTaskViewLabel);
m_showTaskViewLayout->addWidget(m_showTaskView);
m_vLayout2->addWidget(m_showTaskViewFrame);
m_mainLayout->addWidget(m_frame2);
m_mainLayout->addStretch();
}
QFrame *PanelUkccPlugin::setLine(QFrame *parent)
{
auto line = new QFrame(parent);
line->setFixedHeight(1);
line->setLineWidth(0);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
return line;
}
void PanelUkccPlugin::initData()
{
m_mergeIcons->setCurrentIndex(m_configReplica->mergeIcons());
connect(m_mergeIcons, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [&](int index){
m_configReplica->setMergeIcons(static_cast<GeneralConfigDefine::MergeIcons>(index));
});
connect(m_configReplica, &RemoteConfigReplica::mergeIconsChanged, m_mergeIcons, &QComboBox::setCurrentIndex, Qt::UniqueConnection);
m_mergeIcons->setEnabled(true);
m_panelLocation->setCurrentIndex(m_configReplica->panelLocation());
connect(m_panelLocation, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [&](int index){
m_configReplica->setPanelLocation(static_cast<GeneralConfigDefine::PanelLocation>(index));
});
connect(m_configReplica, &RemoteConfigReplica::panelLocationChanged, m_panelLocation, &QComboBox::setCurrentIndex, Qt::UniqueConnection);
m_panelLocation->setEnabled(true);
m_panelSizePolicy->setCurrentIndex(m_configReplica->panelSizePolicy());
connect(m_panelSizePolicy, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [&](int index){
m_configReplica->setPanelSizePolicy(static_cast<GeneralConfigDefine::PanelSizePolicy>(index));
});
connect(m_configReplica, &RemoteConfigReplica::panelSizePolicyChanged, m_panelSizePolicy, &QComboBox::setCurrentIndex, Qt::UniqueConnection);
m_panelSizePolicy->setEnabled(true);
m_panelAutoHide->setChecked(m_configReplica->panelAutoHide());
connect(m_panelAutoHide, &kdk::KSwitchButton::stateChanged, m_configReplica, &RemoteConfigReplica::setPanelAutoHide);
connect(m_configReplica, &RemoteConfigReplica::panelAutoHideChanged, m_panelAutoHide, &kdk::KSwitchButton::setChecked, Qt::UniqueConnection);
m_panelAutoHide->setEnabled(true);
m_panelLock->setChecked(m_configReplica->panelAutoHide());
connect(m_panelLock, &kdk::KSwitchButton::stateChanged, m_configReplica, &RemoteConfigReplica::setPanelLock);
connect(m_configReplica, &RemoteConfigReplica::panelLocationChanged, m_panelLock, &kdk::KSwitchButton::setChecked, Qt::UniqueConnection);
m_panelLock->setEnabled(true);
m_showTaskView->setChecked(m_configReplica->panelWidgets().contains(QStringLiteral("org.ukui.panel.taskView")));
connect(m_showTaskView, &kdk::KSwitchButton::stateChanged, this, [&](bool show){
QStringList widgets = m_configReplica->panelWidgets();
if(show && !widgets.contains(QStringLiteral("org.ukui.panel.taskView"))) {
m_configReplica->setPanelWidgets(widgets << QStringLiteral("org.ukui.panel.taskView"));
} else if (!show && widgets.contains(QStringLiteral("org.ukui.panel.taskView"))) {
widgets.removeAll(QStringLiteral("org.ukui.panel.taskView"));
m_configReplica->setPanelWidgets(widgets);
}
});
m_showTaskView->setEnabled(true);
}
void PanelUkccPlugin::sourceStateChanged(QRemoteObjectReplica::State state, QRemoteObjectReplica::State oldState)
{
qDebug() << "PanelUkccPlugin sourceStateChanged" << state;
if(state == QRemoteObjectReplica::State::Suspect && oldState == QRemoteObjectReplica::State::Valid) {
qWarning() << "Error occurs after remote object initialized";
m_mergeIcons->setEnabled(false);
// m_mergeIcons->disconnect(); //fk ky-sdk
m_mergeIcons->disconnect(this);
m_panelLocation->setEnabled(false);
m_panelLocation->disconnect();
m_panelSizePolicy->setEnabled(false);
m_panelSizePolicy->disconnect(this);
m_panelAutoHide->setEnabled(false);
m_panelAutoHide->disconnect(this);
m_panelLock->setEnabled(false);
m_panelLock->disconnect(this);
m_showTaskView->setEnabled(false);
m_showTaskView->disconnect(this);
}
}

View File

@ -0,0 +1,111 @@
/*
*
* * 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/>.
* *
* * Authors: iaom <zhangpengfei@kylinos.cn>
*
*/
#ifndef UKUI_PANEL_PANEL_UKCC_PLUGIN_H
#define UKUI_PANEL_PANEL_UKCC_PLUGIN_H
#include <QObject>
#include <QVBoxLayout>
#include <QtRemoteObjects/qremoteobjectnode.h>
#include <ukcc/interface/interface.h>
#include <ukcc/interface/interface.h>
#include <ukcc/widgets/titlelabel.h>
#include <ukcc/widgets/comboxframe.h>
#include <ukcc/widgets/fixlabel.h>
#include <kswitchbutton.h>
#include "rep_remote-config_replica.h"
class PanelUkccPlugin : public QObject, public CommonInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.ukcc.CommonInterface")
Q_INTERFACES(CommonInterface)
public:
explicit PanelUkccPlugin(QObject *parent = nullptr);
QString plugini18nName() Q_DECL_OVERRIDE;
int pluginTypes() Q_DECL_OVERRIDE;
QWidget * pluginUi() Q_DECL_OVERRIDE;
const QString name() const Q_DECL_OVERRIDE;
QString translationPath() const Q_DECL_OVERRIDE;
bool isShowOnHomePage() const Q_DECL_OVERRIDE;
QIcon icon() const Q_DECL_OVERRIDE;
bool isEnable() const Q_DECL_OVERRIDE;
private:
void initUI();
QFrame * setLine(QFrame *parent = nullptr);
void connectToSource();
void initData();
void sourceStateChanged(QRemoteObjectReplica::State state, QRemoteObjectReplica::State oldState);
QRemoteObjectNode m_qroNode;
RemoteConfigReplica *m_configReplica = nullptr;
//main page
QWidget *m_widget = nullptr;
//"panel"
QVBoxLayout *m_mainLayout = nullptr;
TitleLabel *m_titleLabel1 = nullptr;
QFrame *m_frame1 = nullptr;
QVBoxLayout *m_vLayout1 = nullptr;
//merge icons
QFrame *m_mergeIconsFrame = nullptr;
QHBoxLayout *m_mergeIconsLayout = nullptr;
QLabel *m_mergeIconsLabel = nullptr;
QComboBox *m_mergeIcons = nullptr;
//panel location
QFrame *m_panelLocationFrame = nullptr;
QHBoxLayout *m_panelLocationLayout = nullptr;
QLabel *m_panelLocationLabel = nullptr;
QComboBox *m_panelLocation= nullptr;
//panel size
QFrame *m_panelSizePolicyFrame = nullptr;
QHBoxLayout *m_panelSizePolicyLayout = nullptr;
QLabel *m_panelSizePolicyLabel = nullptr;
QComboBox *m_panelSizePolicy = nullptr;
//panel auto hide
QFrame *m_panelAutoHideFrame = nullptr;
QHBoxLayout *m_panelAutoHideLayout = nullptr;
QLabel *m_panelAutoHideLabel = nullptr;
kdk::KSwitchButton *m_panelAutoHide = nullptr;
//panel lock
QFrame *m_panelLockFrame = nullptr;
QHBoxLayout *m_panelLockLayout = nullptr;
QLabel *m_panelLockLabel = nullptr;
kdk::KSwitchButton *m_panelLock = nullptr;
//"widgets showed on panel"
TitleLabel *m_titleLabel2{};
QFrame *m_frame2{};
QVBoxLayout *m_vLayout2{};
QHBoxLayout *m_widgetsShowedLayout = nullptr;
//task view
QFrame *m_showTaskViewFrame = nullptr;
QHBoxLayout *m_showTaskViewLayout = nullptr;
QLabel *m_showTaskViewLabel = nullptr;
kdk::KSwitchButton *m_showTaskView = nullptr;
};
#endif //UKUI_PANEL_PANEL_UKCC_PLUGIN_H

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN">
<context>
<name>PanelUkccPlugin</name>
<message>
<source>Panel</source>
<translation></translation>
</message>
<message>
<source>Merge icons on the taskbar</source>
<translation></translation>
</message>
<message>
<source>Always</source>
<translation></translation>
</message>
<message>
<source>Never</source>
<translation></translation>
</message>
<message>
<source>Panel location</source>
<translation></translation>
</message>
<message>
<source>Bottom</source>
<translation></translation>
</message>
<message>
<source>Left</source>
<translation></translation>
</message>
<message>
<source>Top</source>
<translation></translation>
</message>
<message>
<source>Right</source>
<translation></translation>
</message>
<message>
<source>Panel size</source>
<translation></translation>
</message>
<message>
<source>Small</source>
<translation></translation>
</message>
<message>
<source>Medium</source>
<translation></translation>
</message>
<message>
<source>Large</source>
<translation></translation>
</message>
<message>
<source>Custom</source>
<translation></translation>
</message>
<message>
<source>Panel auto hide</source>
<translation></translation>
</message>
<message>
<source>Panel lock</source>
<translation></translation>
</message>
<message>
<source>Widgets always showed on panel</source>
<translation></translation>
</message>
<message>
<source>Task view</source>
<translation></translation>
</message>
</context>
</TS>

View File

@ -1,6 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN">
<context>
<name>PanelUkccPlugin</name>
<message>
<source>Panel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Merge icons on the taskbar</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Always</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Never</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Panel location</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bottom</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Top</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Right</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Panel size</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Small</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Medium</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Large</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Custom</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Panel auto hide</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Panel lock</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Widgets always showed on panel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Task view</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>

View File

@ -92,7 +92,7 @@ void UkuiTaskManager::Private::loadSettings()
{
//TODO兼容老版本配置文件
if (!m_settings) {
m_settings = UkuiPanel::ConfigLoader::loadWidgetConfig("ukui-task-manager")->settings();
m_settings = UkuiPanel::ConfigLoader::loadWidgetConfig("org.ukui.panel.taskManager")->settings();
}
m_settings->beginGroup(QUICK_LAUNCHER);
for (const QString &index: m_settings->allKeys()) {