feat(config/shell/ukcc-plugin/taskmanager)任务栏支持设置仅在主屏显示或在所有屏都显示
This commit is contained in:
parent
5fe6499a2d
commit
d2a4873175
|
@ -31,6 +31,7 @@ RemoteConfig::RemoteConfig(QObject *parent) : RemoteConfigSource(parent)
|
|||
, m_panelAutoHide(false)
|
||||
, m_panelLock(false)
|
||||
, m_taskBarIconsShowedOn(GeneralConfigDefine::TaskBarIconsShowedOn::PanelWhereWindowIsOpen)
|
||||
, m_showPanelOnAllScreens(true)
|
||||
{
|
||||
qRegisterMetaType<GeneralConfigDefine::MergeIcons>("GeneralConfigDefine::MergeIcons");
|
||||
qRegisterMetaType<GeneralConfigDefine::PanelLocation>("GeneralConfigDefine::PanelLocation");
|
||||
|
@ -44,7 +45,6 @@ RemoteConfig::RemoteConfig(QObject *parent) : RemoteConfigSource(parent)
|
|||
|
||||
m_taskBarIconsShowedOn = m_taskManagerConfig->getValue(QStringLiteral("taskBarIconsShowedOn")).value<GeneralConfigDefine::TaskBarIconsShowedOn>();
|
||||
|
||||
connect(m_mainViewConfig, &UkuiQuick::Config::configChanged, this, &RemoteConfig::onPanelConfigChanged);
|
||||
connect(m_taskManagerConfig, &UkuiQuick::Config::configChanged, this, &RemoteConfig::onTaskManagerConfigChanged);
|
||||
connect(m_systemTrayConfig, &UkuiQuick::Config::configChanged, this, &RemoteConfig::onSystemTrayConfigChanged);
|
||||
|
||||
|
@ -56,6 +56,9 @@ RemoteConfig::RemoteConfig(QObject *parent) : RemoteConfigSource(parent)
|
|||
break;
|
||||
}
|
||||
}
|
||||
m_showPanelOnAllScreens = m_panelConfig->getValue(QStringLiteral("showPanelOnAllScreens")).toBool();
|
||||
connect(m_panelConfig, &UkuiQuick::Config::configChanged, this, &RemoteConfig::onPanelConfigChanged);
|
||||
|
||||
if (m_mainViewConfig) {
|
||||
updatePanelLocation();
|
||||
m_disabledWidgets = m_mainViewConfig->getValue(QStringLiteral("disabledWidgets")).toStringList();
|
||||
|
@ -195,7 +198,13 @@ void RemoteConfig::onPanelViewConfigChanged(const QString &key)
|
|||
|
||||
void RemoteConfig::onPanelConfigChanged(const QString &key)
|
||||
{
|
||||
|
||||
if (key == "showPanelOnAllScreens") {
|
||||
bool value = m_panelConfig->getValue(QStringLiteral("showPanelOnAllScreens")).toBool();
|
||||
if(value != m_showPanelOnAllScreens) {
|
||||
m_showPanelOnAllScreens = value;
|
||||
Q_EMIT showPanelOnAllScreensChanged(m_showPanelOnAllScreens);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RemoteConfig::onTaskManagerConfigChanged(const QString &key)
|
||||
|
@ -280,3 +289,14 @@ void RemoteConfig::setTaskBarIconsShowedOn(GeneralConfigDefine::TaskBarIconsShow
|
|||
Q_EMIT taskBarIconsShowedOnChanged(m_taskBarIconsShowedOn);
|
||||
}
|
||||
}
|
||||
|
||||
void RemoteConfig::setShowPanelOnAllScreens(bool showPanelOnAllScreens)
|
||||
{
|
||||
if (showPanelOnAllScreens != m_showPanelOnAllScreens) {
|
||||
m_showPanelOnAllScreens = showPanelOnAllScreens;
|
||||
if(m_panelConfig) {
|
||||
m_panelConfig->setValue(QStringLiteral("showPanelOnAllScreens"), showPanelOnAllScreens);
|
||||
}
|
||||
Q_EMIT showPanelOnAllScreensChanged(m_showPanelOnAllScreens);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
QStringList disabledWidgets() const override;
|
||||
QStringList trayIconsInhibited() const override {return m_trayIconsInhibited; }
|
||||
GeneralConfigDefine::TaskBarIconsShowedOn taskBarIconsShowedOn() const override { return m_taskBarIconsShowedOn; };
|
||||
bool showPanelOnAllScreens() const override { return m_showPanelOnAllScreens; }
|
||||
|
||||
void setMergeIcons(GeneralConfigDefine::MergeIcons mergeIcons) override;
|
||||
void setPanelLocation(GeneralConfigDefine::PanelLocation panelLocation) override;
|
||||
|
@ -52,6 +53,7 @@ public:
|
|||
void setPanelWidgets(QStringList panelWidgets) override;
|
||||
void setTrayIconsInhibited(QStringList trayIconsInhibited) override;
|
||||
void setTaskBarIconsShowedOn(GeneralConfigDefine::TaskBarIconsShowedOn taskBarIconsShowedOn) override;
|
||||
void setShowPanelOnAllScreens(bool showPanelOnAllScreens) override;
|
||||
|
||||
public Q_SLOTS:
|
||||
void disableWidget(const QString &id, bool disable) override;
|
||||
|
@ -73,6 +75,8 @@ private:
|
|||
QStringList m_trayIconsInhibited;
|
||||
|
||||
GeneralConfigDefine::TaskBarIconsShowedOn m_taskBarIconsShowedOn;
|
||||
bool m_showPanelOnAllScreens;
|
||||
|
||||
UkuiQuick::Config *m_panelConfig = nullptr;
|
||||
UkuiQuick::Config *m_mainViewConfig = nullptr;
|
||||
UkuiQuick::Config *m_taskManagerConfig = nullptr;
|
||||
|
|
|
@ -30,6 +30,7 @@ class RemoteConfig
|
|||
PROP(QStringList disabledWidgets READONLY);
|
||||
PROP(QStringList trayIconsInhibited READWRITE);
|
||||
PROP(GeneralConfigDefine::TaskBarIconsShowedOn taskBarIconsShowedOn READWRITE);
|
||||
PROP(bool showPanelOnAllScreens READWRITE);
|
||||
|
||||
SLOT(disableWidget(const QString &id, bool disable))
|
||||
};
|
||||
|
|
|
@ -37,20 +37,29 @@ Shell::Shell(QObject *parent) : QObject(parent)
|
|||
|
||||
void Shell::start()
|
||||
{
|
||||
//在创建任务栏之前读配置文件
|
||||
initPanelConfig();
|
||||
|
||||
Screen *primary = m_screenManager->primaryScreen();
|
||||
auto panel = new Panel(primary, "panel0");
|
||||
m_panels.insert(primary, panel);
|
||||
for(Screen * screen : m_screenManager->screens()) {
|
||||
if(screen != primary) {
|
||||
panel = new Panel(screen, QString("panel%1").arg(m_panels.size()));
|
||||
m_panels.insert(screen, panel);
|
||||
//如果设置为在所有屏幕上显示任务栏再创建副屏的任务栏,否则不创建
|
||||
if(m_showPanelOnAllScreens) {
|
||||
for(Screen * screen : m_screenManager->screens()) {
|
||||
if(screen != primary) {
|
||||
panel = new Panel(screen, QString("panel%1").arg(m_panels.size()));
|
||||
m_panels.insert(screen, panel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initRemoteConfig();
|
||||
initDbus();
|
||||
initRemoteConfig();
|
||||
|
||||
connect(m_screenManager, &ScreensManager::screenAdded, this, [&](Screen *screen){
|
||||
if(!m_showPanelOnAllScreens) {
|
||||
return;
|
||||
}
|
||||
if(!m_panels.contains(screen)) {
|
||||
panel = new Panel(screen, QString("panel%1").arg(m_panels.size()));
|
||||
m_panels.insert(screen, panel);
|
||||
|
@ -61,6 +70,15 @@ void Shell::start()
|
|||
delete m_panels.take(screen);
|
||||
}
|
||||
});
|
||||
//主屏变化时,如果为只在主屏上显示任务栏,将主屏任务栏重新setscreen
|
||||
connect(m_screenManager, &ScreensManager::primaryScreenChanged, this, [&](Screen *screen){
|
||||
if(!m_showPanelOnAllScreens) {
|
||||
auto panel = m_panels.first();
|
||||
m_panels.clear();
|
||||
panel->setPanelScreen(screen);
|
||||
m_panels.insert(screen, panel);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Shell::initRemoteConfig()
|
||||
|
@ -99,3 +117,57 @@ void Shell::onTabletModeChanged(bool isTabletMode)
|
|||
panel->setVisible(!m_isTabletMode);
|
||||
}
|
||||
}
|
||||
|
||||
void Shell::initPanelConfig()
|
||||
{
|
||||
if(!m_panelConfig) {
|
||||
m_panelConfig = UkuiQuick::ConfigLoader::getConfig("panel", UkuiQuick::ConfigLoader::Local, "ukui-panel");
|
||||
}
|
||||
if(m_panelConfig->contains("showPanelOnAllScreens")) {
|
||||
m_showPanelOnAllScreens = m_panelConfig->getValue(QStringLiteral("showPanelOnAllScreens")).toBool();
|
||||
} else {
|
||||
m_showPanelOnAllScreens = true;
|
||||
m_panelConfig->setValue(QStringLiteral("showPanelOnAllScreens"), m_showPanelOnAllScreens);
|
||||
}
|
||||
connect(m_panelConfig, &UkuiQuick::Config::configChanged, this, [&](QString key) {
|
||||
if(key == "showPanelOnAllScreens") {
|
||||
auto value = m_panelConfig->getValue(QStringLiteral("showPanelOnAllScreens")).toBool();
|
||||
if(value == m_showPanelOnAllScreens) {
|
||||
return;
|
||||
}
|
||||
m_showPanelOnAllScreens = value;
|
||||
if (!m_configDataChange) {
|
||||
m_configDataChange = true;
|
||||
auto ev = new QEvent(QEvent::UpdateRequest);
|
||||
QCoreApplication::postEvent(this, ev);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bool Shell::event(QEvent* e)
|
||||
{
|
||||
if (e->type() == QEvent::UpdateRequest) {
|
||||
//是否在所有屏幕上显示任务栏,变为true时
|
||||
//创建副屏的任务栏
|
||||
if(m_showPanelOnAllScreens) {
|
||||
for(Screen * screen : m_screenManager->screens()) {
|
||||
if(!m_panels.contains(screen)) {
|
||||
auto panel = new Panel(screen, QString("panel%1").arg(m_panels.size()));
|
||||
m_panels.insert(screen, panel);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//是否在所有屏幕上显示任务栏,变为false时
|
||||
//删除不是主屏任务栏的所有任务栏
|
||||
for(Screen * screen : m_screenManager->screens()) {
|
||||
if(m_panels.contains(screen) && screen != m_screenManager->primaryScreen()) {
|
||||
delete m_panels.take(screen);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_configDataChange = false;
|
||||
e->accept();
|
||||
}
|
||||
return QObject::event(e);
|
||||
}
|
||||
|
|
|
@ -39,13 +39,15 @@ class Shell : public QObject
|
|||
public:
|
||||
explicit Shell(QObject *parent=nullptr);
|
||||
void start();
|
||||
|
||||
protected:
|
||||
bool event(QEvent* e);
|
||||
private Q_SLOTS:
|
||||
void onTabletModeChanged(bool);
|
||||
|
||||
private:
|
||||
void initRemoteConfig();
|
||||
void initDbus();
|
||||
void initPanelConfig();
|
||||
|
||||
private:
|
||||
bool m_isTabletMode {false};
|
||||
|
@ -53,6 +55,10 @@ private:
|
|||
RemoteConfig *m_remoteConfig = nullptr;
|
||||
QRemoteObjectHost m_qroHost;
|
||||
ScreensManager *m_screenManager = nullptr;
|
||||
//是否在所有屏幕上显示任务栏
|
||||
bool m_showPanelOnAllScreens = true;
|
||||
UkuiQuick::Config *m_panelConfig = nullptr;
|
||||
bool m_configDataChange = false;
|
||||
};
|
||||
|
||||
} // UkuiPanel
|
||||
|
|
|
@ -202,6 +202,23 @@ void PanelUkccPlugin::initUI()
|
|||
m_panelLockLayout->addWidget(m_panelLock);
|
||||
m_vLayout1->addWidget(m_panelLockFrame);
|
||||
|
||||
//show panel on all screens
|
||||
m_showPanelOnAllScreensFrame = new QFrame(m_frame1);
|
||||
m_showPanelOnAllScreensFrame->setFixedHeight(56);
|
||||
m_showPanelOnAllScreensLayout = new QHBoxLayout(m_showPanelOnAllScreensFrame);
|
||||
m_showPanelOnAllScreensLayout->setContentsMargins(16, 0, 16, 0);
|
||||
m_showPanelOnAllScreensLabel = new QLabel(m_showPanelOnAllScreensFrame);
|
||||
m_showPanelOnAllScreensLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
//~ contents_path /Panel/Show panel on all screens
|
||||
m_showPanelOnAllScreensLabel->setText(tr("Show panel on all screens"));
|
||||
m_showPanelOnAllScreens = new kdk::KSwitchButton(m_showPanelOnAllScreensFrame);
|
||||
m_showPanelOnAllScreens->setFixedSize(48,24);
|
||||
m_showPanelOnAllScreens->setEnabled(false);
|
||||
m_showPanelOnAllScreensLayout->addWidget(m_showPanelOnAllScreensLabel);
|
||||
m_showPanelOnAllScreensLayout->addWidget(m_showPanelOnAllScreens);
|
||||
m_vLayout1->addWidget(m_showPanelOnAllScreensFrame);
|
||||
m_vLayout1->addWidget(setLine(m_frame1));
|
||||
|
||||
//taskmanager icons showed on
|
||||
m_iconsShowedOnFrame = new QFrame(m_frame1);
|
||||
m_iconsShowedOnFrame->setFixedHeight(56);
|
||||
|
@ -209,7 +226,7 @@ void PanelUkccPlugin::initUI()
|
|||
m_iconsShowedOnLayout->setContentsMargins(16, 0, 16, 0);
|
||||
m_iconsShowedOnLabel = new QLabel(m_iconsShowedOnFrame);
|
||||
m_iconsShowedOnLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
m_iconsShowedOnLabel->setText(tr("When using mutiple screens, show window icons on"));
|
||||
m_iconsShowedOnLabel->setText(tr("When existing multiple panels, show window icons on"));
|
||||
m_iconsShowedOn = new QComboBox(m_iconsShowedOnFrame);
|
||||
m_iconsShowedOn->setEnabled(false);
|
||||
m_iconsShowedOn->setMinimumWidth(320);
|
||||
|
@ -356,6 +373,21 @@ void PanelUkccPlugin::initData()
|
|||
connect(m_configReplica, &RemoteConfigReplica::taskBarIconsShowedOnChanged, m_iconsShowedOn, &QComboBox::setCurrentIndex, Qt::UniqueConnection);
|
||||
m_iconsShowedOn->setEnabled(true);
|
||||
|
||||
//show panel on all screens
|
||||
m_showPanelOnAllScreens->setChecked(m_configReplica->showPanelOnAllScreens());
|
||||
connect(m_showPanelOnAllScreens, &kdk::KSwitchButton::stateChanged, m_configReplica, &RemoteConfigReplica::setShowPanelOnAllScreens);
|
||||
connect(m_configReplica, &RemoteConfigReplica::showPanelOnAllScreensChanged, this, [&](bool showPanelOnAllScreens) {
|
||||
m_showPanelOnAllScreens->setChecked(showPanelOnAllScreens);
|
||||
//不在所有屏幕显示任务栏时,将任务栏图标选项设置为在主屏和打开了窗口的任务栏显示
|
||||
if(!showPanelOnAllScreens) {
|
||||
if(m_iconsShowedOn->currentIndex() == GeneralConfigDefine::TaskBarIconsShowedOn::PanelWhereWindowIsOpen) {
|
||||
m_iconsShowedOn->setCurrentIndex(GeneralConfigDefine::TaskBarIconsShowedOn::AllPanels);
|
||||
}
|
||||
}
|
||||
m_iconsShowedOn->setEnabled(showPanelOnAllScreens);
|
||||
}, Qt::UniqueConnection);
|
||||
m_showPanelOnAllScreens->setEnabled(true);
|
||||
|
||||
m_showTaskView->setChecked(!m_configReplica->disabledWidgets().contains(QStringLiteral("org.ukui.panel.taskView")));
|
||||
connect(m_configReplica, &RemoteConfigReplica::disabledWidgetsChanged, m_showTaskView, [this] (const QStringList& list) {
|
||||
m_showTaskView->setChecked(!list.contains(QStringLiteral("org.ukui.panel.taskView")));
|
||||
|
@ -414,6 +446,9 @@ void PanelUkccPlugin::sourceStateChanged(QRemoteObjectReplica::State state, QRem
|
|||
m_panelLock->disconnect(m_configReplica);
|
||||
m_showTaskView->setEnabled(false);
|
||||
m_showTaskView->disconnect(this);
|
||||
m_showPanelOnAllScreens->disconnect(m_configReplica);
|
||||
m_showPanelOnAllScreens->disconnect(this);
|
||||
m_showPanelOnAllScreens->setEnabled(false);
|
||||
for(const QString &id : m_systemTrayIconId) {
|
||||
auto button = m_frame3->findChild<SwitchButton *>(id, Qt::FindDirectChildrenOnly);
|
||||
if(button) {
|
||||
|
|
|
@ -94,6 +94,12 @@ private:
|
|||
QLabel *m_panelLockLabel = nullptr;
|
||||
kdk::KSwitchButton *m_panelLock = nullptr;
|
||||
|
||||
//show panel on all screens
|
||||
QFrame *m_showPanelOnAllScreensFrame = nullptr;
|
||||
QHBoxLayout *m_showPanelOnAllScreensLayout = nullptr;
|
||||
QLabel *m_showPanelOnAllScreensLabel = nullptr;
|
||||
kdk::KSwitchButton *m_showPanelOnAllScreens = nullptr;
|
||||
|
||||
//icons showed on witch panel
|
||||
QFrame *m_iconsShowedOnFrame = nullptr;
|
||||
QHBoxLayout *m_iconsShowedOnLayout = nullptr;
|
||||
|
|
|
@ -100,8 +100,8 @@
|
|||
<translation>搜索</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>When using mutiple screens, show window icons on</source>
|
||||
<translation>多个显示器时,任务栏上的图标显示在</translation>
|
||||
<source>When existing multiple panels, show window icons on</source>
|
||||
<translation>多个任务栏时,任务栏上的图标显示在</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>All panels</source>
|
||||
|
@ -115,6 +115,11 @@
|
|||
<source>Panel where window is open</source>
|
||||
<translation>仅显示在打开了窗口的任务栏</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Show panel on all screens</source>
|
||||
<translation>在所有显示器上显示任务栏</translation>
|
||||
<extra-contents_path>/Panel/Show panel on all screens</extra-contents_path>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SwitchButton</name>
|
||||
|
|
|
@ -46,6 +46,10 @@ TaskManagerFilterModel::TaskManagerFilterModel(QObject *parent) : QSortFilterPro
|
|||
}
|
||||
});
|
||||
}
|
||||
//主屏改变时,发送事件,更新数据
|
||||
connect(qApp, &QGuiApplication::primaryScreenChanged, this, [&]() {
|
||||
m_sourceModel->requestDataChange();
|
||||
});
|
||||
}
|
||||
|
||||
void TaskManagerFilterModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||
|
@ -110,6 +114,7 @@ void TaskManagerFilterModel::setScreen(QScreen *screen)
|
|||
{
|
||||
m_screen = screen;
|
||||
invalidateFilter();
|
||||
m_sourceModel->requestDataChange();
|
||||
}
|
||||
|
||||
bool TaskManagerFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||
|
|
Loading…
Reference in New Issue