mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
fix: Merge branch 'maintain/5.1' into uos
将maintain/5.1分支合并到uos分支 Log: 合并分支 Change-Id: Ia6ac5b17514990864fc845f0a64fe67ad3bc78b6
This commit is contained in:
commit
d384a81594
@ -1,6 +0,0 @@
|
|||||||
[https://www.transifex.com]
|
|
||||||
api_hostname = https://api.transifex.com
|
|
||||||
hostname = https://www.transifex.com
|
|
||||||
password = 1/fed29a347a3f79abfe438d15d1af9dceac2ba39d
|
|
||||||
username = api
|
|
||||||
|
|
@ -57,10 +57,12 @@ using namespace Dock;
|
|||||||
AppSnapshot::AppSnapshot(const WId wid, QWidget *parent)
|
AppSnapshot::AppSnapshot(const WId wid, QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_wid(wid)
|
, m_wid(wid)
|
||||||
|
, m_isWidowHidden(false)
|
||||||
, m_title(new TipsWidget)
|
, m_title(new TipsWidget)
|
||||||
, m_waitLeaveTimer(new QTimer(this))
|
, m_waitLeaveTimer(new QTimer(this))
|
||||||
, m_closeBtn2D(new DIconButton(this))
|
, m_closeBtn2D(new DIconButton(this))
|
||||||
, m_wmHelper(DWindowManagerHelper::instance())
|
, m_wmHelper(DWindowManagerHelper::instance())
|
||||||
|
, m_dockDaemonInter(new DockDaemonInter("com.deepin.dde.daemon.Dock", "/com/deepin/dde/daemon/Dock", QDBusConnection::sessionBus(), this))
|
||||||
{
|
{
|
||||||
m_closeBtn2D->setFixedSize(24, 24);
|
m_closeBtn2D->setFixedSize(24, 24);
|
||||||
m_closeBtn2D->setIconSize(QSize(24, 24));
|
m_closeBtn2D->setIconSize(QSize(24, 24));
|
||||||
@ -85,6 +87,13 @@ AppSnapshot::AppSnapshot(const WId wid, QWidget *parent)
|
|||||||
QTimer::singleShot(1, this, &AppSnapshot::compositeChanged);
|
QTimer::singleShot(1, this, &AppSnapshot::compositeChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppSnapshot::setWindowState()
|
||||||
|
{
|
||||||
|
if (m_isWidowHidden) {
|
||||||
|
m_dockDaemonInter->MinimizeWindow(m_wid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AppSnapshot::closeWindow() const
|
void AppSnapshot::closeWindow() const
|
||||||
{
|
{
|
||||||
const auto display = QX11Info::display();
|
const auto display = QX11Info::display();
|
||||||
@ -118,6 +127,7 @@ void AppSnapshot::setWindowInfo(const WindowInfo &info)
|
|||||||
QFontMetrics fm(m_title->font());
|
QFontMetrics fm(m_title->font());
|
||||||
QString strTtile = m_title->fontMetrics().elidedText(m_windowInfo.title, Qt::ElideRight, width() - m_closeBtn2D->width());
|
QString strTtile = m_title->fontMetrics().elidedText(m_windowInfo.title, Qt::ElideRight, width() - m_closeBtn2D->width());
|
||||||
m_title->setText(strTtile);
|
m_title->setText(strTtile);
|
||||||
|
getWindowState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppSnapshot::dragEnterEvent(QDragEnterEvent *e)
|
void AppSnapshot::dragEnterEvent(QDragEnterEvent *e)
|
||||||
@ -348,3 +358,39 @@ QRect AppSnapshot::rectRemovedShadow(const QImage &qimage, unsigned char *prop_t
|
|||||||
return QRect(0, 0, qimage.width(), qimage.height());
|
return QRect(0, 0, qimage.width(), qimage.height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppSnapshot::getWindowState()
|
||||||
|
{
|
||||||
|
Atom actual_type;
|
||||||
|
int actual_format;
|
||||||
|
unsigned long i, num_items, bytes_after;
|
||||||
|
unsigned char *properties = nullptr;
|
||||||
|
|
||||||
|
m_isWidowHidden = false;
|
||||||
|
|
||||||
|
const auto display = QX11Info::display();
|
||||||
|
Atom atom_prop = XInternAtom(display, "_NET_WM_STATE", true);
|
||||||
|
if (!atom_prop) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status status = XGetWindowProperty(display, m_wid, atom_prop, 0, LONG_MAX, False, AnyPropertyType, &actual_type, &actual_format, &num_items, &bytes_after, &properties);
|
||||||
|
if (status != Success) {
|
||||||
|
qDebug() << "Fail to get window state";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Atom *atoms = reinterpret_cast<Atom *>(properties);
|
||||||
|
for(i = 0; i < num_items; ++i) {
|
||||||
|
const char *atomName = XGetAtomName(display, atoms[i]);
|
||||||
|
|
||||||
|
if (strcmp(atomName, "_NET_WM_STATE_HIDDEN") == 0) {
|
||||||
|
m_isWidowHidden = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (properties) {
|
||||||
|
XFree(properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <DIconButton>
|
#include <DIconButton>
|
||||||
#include <DWindowManagerHelper>
|
#include <DWindowManagerHelper>
|
||||||
|
|
||||||
|
#include <com_deepin_dde_daemon_dock.h>
|
||||||
#include <com_deepin_dde_daemon_dock_entry.h>
|
#include <com_deepin_dde_daemon_dock_entry.h>
|
||||||
|
|
||||||
DWIDGET_USE_NAMESPACE
|
DWIDGET_USE_NAMESPACE
|
||||||
@ -41,6 +42,8 @@ struct SHMInfo;
|
|||||||
struct _XImage;
|
struct _XImage;
|
||||||
typedef _XImage XImage;
|
typedef _XImage XImage;
|
||||||
|
|
||||||
|
using DockDaemonInter = com::deepin::dde::daemon::Dock;
|
||||||
|
|
||||||
namespace Dock {
|
namespace Dock {
|
||||||
class TipsWidget;
|
class TipsWidget;
|
||||||
}
|
}
|
||||||
@ -59,6 +62,7 @@ public:
|
|||||||
inline const QImage snapshot() const { return m_snapshot; }
|
inline const QImage snapshot() const { return m_snapshot; }
|
||||||
inline const QRectF snapshotGeometry() const { return m_snapshotSrcRect; }
|
inline const QRectF snapshotGeometry() const { return m_snapshotSrcRect; }
|
||||||
inline const QString title() const { return m_windowInfo.title; }
|
inline const QString title() const { return m_windowInfo.title; }
|
||||||
|
void setWindowState();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void entered(const WId wid) const;
|
void entered(const WId wid) const;
|
||||||
@ -82,13 +86,14 @@ private:
|
|||||||
SHMInfo *getImageDSHM();
|
SHMInfo *getImageDSHM();
|
||||||
XImage *getImageXlib();
|
XImage *getImageXlib();
|
||||||
QRect rectRemovedShadow(const QImage &qimage, unsigned char *prop_to_return_gtk);
|
QRect rectRemovedShadow(const QImage &qimage, unsigned char *prop_to_return_gtk);
|
||||||
|
void getWindowState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const WId m_wid;
|
const WId m_wid;
|
||||||
WindowInfo m_windowInfo;
|
WindowInfo m_windowInfo;
|
||||||
|
|
||||||
bool m_closeAble;
|
bool m_closeAble;
|
||||||
|
bool m_isWidowHidden;
|
||||||
QImage m_snapshot;
|
QImage m_snapshot;
|
||||||
QRectF m_snapshotSrcRect;
|
QRectF m_snapshotSrcRect;
|
||||||
|
|
||||||
@ -96,6 +101,7 @@ private:
|
|||||||
QTimer *m_waitLeaveTimer;
|
QTimer *m_waitLeaveTimer;
|
||||||
DIconButton *m_closeBtn2D;
|
DIconButton *m_closeBtn2D;
|
||||||
DWindowManagerHelper *m_wmHelper;
|
DWindowManagerHelper *m_wmHelper;
|
||||||
|
DockDaemonInter *m_dockDaemonInter;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APPSNAPSHOT_H
|
#endif // APPSNAPSHOT_H
|
||||||
|
@ -186,6 +186,7 @@ void FloatingPreview::hideEvent(QHideEvent *event)
|
|||||||
{
|
{
|
||||||
if (m_tracked) {
|
if (m_tracked) {
|
||||||
m_tracked->setContentsMargins(0, 0, 0, 0);
|
m_tracked->setContentsMargins(0, 0, 0, 0);
|
||||||
|
m_tracked->setWindowState();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget::hideEvent(event);
|
QWidget::hideEvent(event);
|
||||||
|
@ -241,6 +241,7 @@ void PreviewContainer::previewEntered(const WId wid)
|
|||||||
AppSnapshot *preSnap = m_floatingPreview->trackedWindow();
|
AppSnapshot *preSnap = m_floatingPreview->trackedWindow();
|
||||||
if (preSnap && preSnap != snap) {
|
if (preSnap && preSnap != snap) {
|
||||||
preSnap->setContentsMargins(0, 0, 0, 0);
|
preSnap->setContentsMargins(0, 0, 0, 0);
|
||||||
|
preSnap->setWindowState();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentWId = wid;
|
m_currentWId = wid;
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include "window/mainwindow.h"
|
#include "window/mainwindow.h"
|
||||||
#include "window/accessible.h"
|
#include "window/accessible.h"
|
||||||
|
#include "dbus/dbusdockadaptors.h"
|
||||||
|
#include "util/utils.h"
|
||||||
#include "util/themeappicon.h"
|
#include "util/themeappicon.h"
|
||||||
#include "controller/dockitemmanager.h"
|
#include "controller/dockitemmanager.h"
|
||||||
#include "util/dockapplication.h"
|
#include "util/dockapplication.h"
|
||||||
@ -29,15 +31,16 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QGSettings>
|
||||||
|
|
||||||
|
#include <DApplication>
|
||||||
#include <DLog>
|
#include <DLog>
|
||||||
#include <DDBusSender>
|
#include <DDBusSender>
|
||||||
#include <DGuiApplicationHelper>
|
#include <DGuiApplicationHelper>
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "dbus/dbusdockadaptors.h"
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <sys/mman.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
@ -203,6 +206,13 @@ int main(int argc, char *argv[])
|
|||||||
app.setAttribute(Qt::AA_EnableHighDpiScaling, true);
|
app.setAttribute(Qt::AA_EnableHighDpiScaling, true);
|
||||||
app.setAttribute(Qt::AA_UseHighDpiPixmaps, false);
|
app.setAttribute(Qt::AA_UseHighDpiPixmaps, false);
|
||||||
|
|
||||||
|
if (Utils::isSettingConfigured("com.deepin.dde.dock.icbc", "/com/deepin/dde/dock/icbc/", "already-clear")) {
|
||||||
|
QGSettings clear_setting("com.deepin.dde.dock.icbc", "/com/deepin/dde/dock/icbc/");
|
||||||
|
clear_setting.set("already-clear", false);
|
||||||
|
QGSettings apps_setting("com.deepin.dde.dock", "/com/deepin/dde/dock/");
|
||||||
|
apps_setting.set("docked-apps", QStringList());
|
||||||
|
system("killall dde-session-daemon");
|
||||||
|
}
|
||||||
QAccessible::installFactory(accessibleFactory);
|
QAccessible::installFactory(accessibleFactory);
|
||||||
|
|
||||||
// load dde-network-utils translator
|
// load dde-network-utils translator
|
||||||
|
@ -256,8 +256,12 @@ void MainPanelControl::addTrayAreaItem(int index, QWidget *wdg)
|
|||||||
|
|
||||||
void MainPanelControl::addPluginAreaItem(int index, QWidget *wdg)
|
void MainPanelControl::addPluginAreaItem(int index, QWidget *wdg)
|
||||||
{
|
{
|
||||||
m_pluginLayout->insertWidget(index, wdg, 0, Qt::AlignCenter);
|
//因为日期时间插件和其他插件的大小有异,为了方便设置边距,在插件区域布局再添加一层布局设置边距
|
||||||
resizeDockIcon();
|
//因此在处理插件图标时,需要通过两层布局判断是否为需要的插件,例如拖动插件位置等判断
|
||||||
|
QBoxLayout * boxLayout = new QBoxLayout(QBoxLayout::LeftToRight);
|
||||||
|
boxLayout->addWidget(wdg, 0, Qt::AlignCenter);
|
||||||
|
m_pluginLayout->insertLayout(index, boxLayout, 0);
|
||||||
|
resizeDockIcon();;
|
||||||
m_pluginAreaWidget->adjustSize();
|
m_pluginAreaWidget->adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +282,16 @@ void MainPanelControl::removeTrayAreaItem(QWidget *wdg)
|
|||||||
|
|
||||||
void MainPanelControl::removePluginAreaItem(QWidget *wdg)
|
void MainPanelControl::removePluginAreaItem(QWidget *wdg)
|
||||||
{
|
{
|
||||||
m_pluginLayout->removeWidget(wdg);
|
//因为日期时间插件大小和其他插件有异,为了方便设置边距,各插件中增加一层布局
|
||||||
|
//因此remove插件图标时,需要从多的一层布局中取widget进行判断是否需要移除的插件
|
||||||
|
for (int i = 0; i < m_pluginLayout->count(); ++i) {
|
||||||
|
QLayoutItem *layoutItem = m_pluginLayout->itemAt(i);
|
||||||
|
QLayout *boxLayout = layoutItem->layout();
|
||||||
|
if (boxLayout && boxLayout->itemAt(0)->widget() == wdg) {
|
||||||
|
boxLayout->removeWidget(wdg);
|
||||||
|
m_pluginLayout->removeItem(layoutItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanelControl::resizeEvent(QResizeEvent *event)
|
void MainPanelControl::resizeEvent(QResizeEvent *event)
|
||||||
@ -378,9 +391,17 @@ void MainPanelControl::moveItem(DockItem *sourceItem, DockItem *targetItem)
|
|||||||
int idx = -1;
|
int idx = -1;
|
||||||
if (targetItem->itemType() == DockItem::App)
|
if (targetItem->itemType() == DockItem::App)
|
||||||
idx = m_appAreaSonLayout->indexOf(targetItem);
|
idx = m_appAreaSonLayout->indexOf(targetItem);
|
||||||
else if (targetItem->itemType() == DockItem::Plugins)
|
else if (targetItem->itemType() == DockItem::Plugins){
|
||||||
idx = m_pluginLayout->indexOf(targetItem);
|
//因为日期时间插件大小和其他插件大小有异,为了设置边距,在各插件中增加了一层布局
|
||||||
else if (targetItem->itemType() == DockItem::FixedPlugin)
|
//因此有拖动图标时,需要从多的一层布局中判断是否相同插件而获取插件位置顺序
|
||||||
|
for (int i = 0; i < m_pluginLayout->count(); ++i) {
|
||||||
|
QLayout *layout = m_pluginLayout->itemAt(i)->layout();
|
||||||
|
if (layout && layout->itemAt(0)->widget() == targetItem) {
|
||||||
|
idx = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (targetItem->itemType() == DockItem::FixedPlugin)
|
||||||
idx = m_fixedAreaLayout->indexOf(targetItem);
|
idx = m_fixedAreaLayout->indexOf(targetItem);
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
@ -738,22 +759,21 @@ DockItem *MainPanelControl::dropTargetItem(DockItem *sourceItem, QPoint point)
|
|||||||
|
|
||||||
for (int i = 0 ; i < parentLayout->count(); ++i) {
|
for (int i = 0 ; i < parentLayout->count(); ++i) {
|
||||||
QLayoutItem *layoutItem = parentLayout->itemAt(i);
|
QLayoutItem *layoutItem = parentLayout->itemAt(i);
|
||||||
DockItem *dockItem = qobject_cast<DockItem *>(layoutItem->widget());
|
|
||||||
|
DockItem *dockItem = nullptr;
|
||||||
|
if (parentWidget == m_pluginAreaWidget) {
|
||||||
|
QLayout *layout = layoutItem->layout();
|
||||||
|
if (layout) {
|
||||||
|
dockItem = qobject_cast<DockItem *>(layout->itemAt(0)->widget());
|
||||||
|
}
|
||||||
|
} else{
|
||||||
|
dockItem = qobject_cast<DockItem *>(layoutItem->widget());
|
||||||
|
}
|
||||||
|
|
||||||
if (!dockItem)
|
if (!dockItem)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QRect rect;
|
QRect rect(dockItem->pos(), dockItem->size());
|
||||||
|
|
||||||
rect.setTopLeft(dockItem->pos());
|
|
||||||
if (dockItem->itemType() == DockItem::Plugins) {
|
|
||||||
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
|
|
||||||
rect.setSize(QSize(PLUGIN_MAX_SIZE, height()));
|
|
||||||
} else {
|
|
||||||
rect.setSize(QSize(width(), PLUGIN_MAX_SIZE));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
rect.setSize(dockItem->size());
|
|
||||||
}
|
|
||||||
if (rect.contains(point)) {
|
if (rect.contains(point)) {
|
||||||
targetItem = dockItem;
|
targetItem = dockItem;
|
||||||
break;
|
break;
|
||||||
@ -889,31 +909,39 @@ void MainPanelControl::paintEvent(QPaintEvent *event)
|
|||||||
|
|
||||||
void MainPanelControl::resizeDockIcon()
|
void MainPanelControl::resizeDockIcon()
|
||||||
{
|
{
|
||||||
if (!m_tray)
|
|
||||||
return;
|
|
||||||
// 插件有点特殊,因为会引入第三方的插件,并不会受dock的缩放影响,我们只能限制我们自己的插件,否则会导致显示错误。
|
// 插件有点特殊,因为会引入第三方的插件,并不会受dock的缩放影响,我们只能限制我们自己的插件,否则会导致显示错误。
|
||||||
// 以下是受控制的插件
|
// 以下是受控制的插件
|
||||||
PluginsItem *trashPlugin = nullptr;
|
PluginsItem *trashPlugin = nullptr;
|
||||||
PluginsItem *shutdownPlugin = nullptr;
|
PluginsItem *shutdownPlugin = nullptr;
|
||||||
PluginsItem *keyboardPlugin = nullptr;
|
PluginsItem *keyboardPlugin = nullptr;
|
||||||
PluginsItem *notificationPlugin = nullptr;
|
PluginsItem *notificationPlugin = nullptr;
|
||||||
|
|
||||||
|
//因为日期时间大小和其他插件大小有异,为了设置边距,在各插件中增加了一层布局
|
||||||
|
//因此需要通过多一层布局来获取各插件
|
||||||
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
||||||
PluginsItem *w = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
|
QLayout *layout = m_pluginLayout->itemAt(i)->layout();
|
||||||
if (w->pluginName() == "trash") {
|
if (layout) {
|
||||||
trashPlugin = w;
|
PluginsItem *w = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
|
||||||
} else if (w->pluginName() == "shutdown") {
|
if (w) {
|
||||||
shutdownPlugin = w;
|
if (w->pluginName() == "trash") {
|
||||||
} else if (w->pluginName() == "onboard") {
|
trashPlugin = w;
|
||||||
keyboardPlugin = w;
|
} else if (w->pluginName() == "shutdown") {
|
||||||
} else if (w->pluginName() == "notifications") {
|
shutdownPlugin = w;
|
||||||
notificationPlugin = w;
|
} else if (w->pluginName() == "onboard") {
|
||||||
|
keyboardPlugin = w;
|
||||||
|
} else if (w->pluginName() == "notifications") {
|
||||||
|
notificationPlugin = w;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 总宽度
|
// 总宽度
|
||||||
int totalLength = ((m_position == Position::Top) || (m_position == Position::Bottom)) ? width() : height();
|
int totalLength = ((m_position == Position::Top) || (m_position == Position::Bottom)) ? width() : height();
|
||||||
// 减去托盘间隔区域
|
// 减去托盘间隔区域
|
||||||
totalLength -= (m_tray->trayVisableItemCount() + 1) * 10;
|
if (m_tray) {
|
||||||
|
totalLength -= (m_tray->trayVisableItemCount() + 1) * 10;
|
||||||
|
}
|
||||||
// 减去3个分割线的宽度
|
// 减去3个分割线的宽度
|
||||||
totalLength -= 3 * SPLITER_SIZE;
|
totalLength -= 3 * SPLITER_SIZE;
|
||||||
|
|
||||||
@ -938,7 +966,12 @@ void MainPanelControl::resizeDockIcon()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// 参与计算的插件的个数(包含托盘和插件,垃圾桶,关机,屏幕键盘)
|
// 参与计算的插件的个数(包含托盘和插件,垃圾桶,关机,屏幕键盘)
|
||||||
int pluginCount = m_tray->trayVisableItemCount() + (trashPlugin ? 1 : 0) + (shutdownPlugin ? 1 : 0) + (keyboardPlugin ? 1 : 0) + (notificationPlugin ? 1 : 0);
|
int pluginCount = 0;
|
||||||
|
if (m_tray) {
|
||||||
|
pluginCount = m_tray->trayVisableItemCount() + (trashPlugin ? 1 : 0) + (shutdownPlugin ? 1 : 0) + (keyboardPlugin ? 1 : 0) + (notificationPlugin ? 1 : 0);
|
||||||
|
} else {
|
||||||
|
pluginCount = (trashPlugin ? 1 : 0) + (shutdownPlugin ? 1 : 0) + (keyboardPlugin ? 1 : 0) + (notificationPlugin ? 1 : 0);
|
||||||
|
}
|
||||||
// icon个数
|
// icon个数
|
||||||
int iconCount = m_fixedAreaLayout->count() + m_appAreaSonLayout->count() + pluginCount;
|
int iconCount = m_fixedAreaLayout->count() + m_appAreaSonLayout->count() + pluginCount;
|
||||||
// 余数
|
// 余数
|
||||||
@ -979,8 +1012,10 @@ void MainPanelControl::resizeDockIcon()
|
|||||||
|
|
||||||
void MainPanelControl::calcuDockIconSize(int w, int h, PluginsItem *trashPlugin, PluginsItem *shutdownPlugin, PluginsItem *keyboardPlugin, PluginsItem *notificationPlugin)
|
void MainPanelControl::calcuDockIconSize(int w, int h, PluginsItem *trashPlugin, PluginsItem *shutdownPlugin, PluginsItem *keyboardPlugin, PluginsItem *notificationPlugin)
|
||||||
{
|
{
|
||||||
|
int appItemSize = qMin(w, h);
|
||||||
|
|
||||||
for (int i = 0; i < m_fixedAreaLayout->count(); ++i) {
|
for (int i = 0; i < m_fixedAreaLayout->count(); ++i) {
|
||||||
m_fixedAreaLayout->itemAt(i)->widget()->setFixedSize(w, h);
|
m_fixedAreaLayout->itemAt(i)->widget()->setFixedSize(appItemSize, appItemSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_position == Dock::Position::Top || m_position == Dock::Position::Bottom) {
|
if (m_position == Dock::Position::Top || m_position == Dock::Position::Bottom) {
|
||||||
@ -994,7 +1029,7 @@ void MainPanelControl::calcuDockIconSize(int w, int h, PluginsItem *trashPlugin,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < m_appAreaSonLayout->count(); ++i) {
|
for (int i = 0; i < m_appAreaSonLayout->count(); ++i) {
|
||||||
m_appAreaSonLayout->itemAt(i)->widget()->setFixedSize(w, h);
|
m_appAreaSonLayout->itemAt(i)->widget()->setFixedSize(appItemSize, appItemSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 托盘上每个图标大小
|
// 托盘上每个图标大小
|
||||||
@ -1011,58 +1046,83 @@ void MainPanelControl::calcuDockIconSize(int w, int h, PluginsItem *trashPlugin,
|
|||||||
if (tray_item_size < 20)
|
if (tray_item_size < 20)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_tray->centralWidget()->setProperty("iconSize", tray_item_size);
|
if (m_tray) {
|
||||||
|
m_tray->centralWidget()->setProperty("iconSize", tray_item_size);
|
||||||
// 插件
|
|
||||||
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
|
|
||||||
if (shutdownPlugin)
|
|
||||||
shutdownPlugin->setFixedSize(tray_item_size, h - 20);
|
|
||||||
if (keyboardPlugin)
|
|
||||||
keyboardPlugin->setFixedSize(tray_item_size, h - 20);
|
|
||||||
if (notificationPlugin)
|
|
||||||
notificationPlugin->setFixedSize(tray_item_size, h - 20);
|
|
||||||
if (trashPlugin)
|
|
||||||
trashPlugin->setFixedSize(tray_item_size, h - 20);
|
|
||||||
} else {
|
|
||||||
if (shutdownPlugin)
|
|
||||||
shutdownPlugin->setFixedSize(w - 20, tray_item_size);
|
|
||||||
if (keyboardPlugin)
|
|
||||||
keyboardPlugin->setFixedSize(w - 20, tray_item_size);
|
|
||||||
if (notificationPlugin)
|
|
||||||
notificationPlugin->setFixedSize(w - 20, tray_item_size);
|
|
||||||
if (trashPlugin)
|
|
||||||
trashPlugin->setFixedSize(w - 20, tray_item_size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shutdownPlugin)
|
||||||
|
shutdownPlugin->setFixedSize(tray_item_size, tray_item_size);
|
||||||
|
if (keyboardPlugin)
|
||||||
|
keyboardPlugin->setFixedSize(tray_item_size, tray_item_size);
|
||||||
|
if (notificationPlugin)
|
||||||
|
notificationPlugin->setFixedSize(tray_item_size, tray_item_size);
|
||||||
|
if (trashPlugin)
|
||||||
|
trashPlugin->setFixedSize(tray_item_size, tray_item_size);
|
||||||
|
|
||||||
|
//因为日期时间大小和其他插件大小有异,为了设置边距,在各插件中增加了一层布局
|
||||||
|
//因此需要通过多一层布局来获取各插件
|
||||||
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
|
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
|
||||||
// 三方插件
|
// 三方插件
|
||||||
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
||||||
PluginsItem *pItem = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
|
QLayout *layout = m_pluginLayout->itemAt(i)->layout();
|
||||||
if (pItem != trashPlugin && pItem != shutdownPlugin && pItem != keyboardPlugin && pItem !=notificationPlugin) {
|
if (layout) {
|
||||||
if (pItem->pluginName() == "datetime"){
|
PluginsItem *pItem = static_cast<PluginsItem *>(layout->itemAt(0)->widget());
|
||||||
pItem->setFixedSize(pItem->sizeHint().width(), h);
|
if (pItem && pItem != trashPlugin && pItem != shutdownPlugin && pItem != keyboardPlugin && pItem !=notificationPlugin) {
|
||||||
} else if (pItem->pluginName() == "AiAssistant"){
|
if (pItem->pluginName() == "datetime") {
|
||||||
pItem->setFixedSize(tray_item_size, h - 20);
|
pItem->setFixedSize(pItem->sizeHint().width(), h);
|
||||||
} else {
|
} else {
|
||||||
pItem->setFixedSize(pItem->sizeHint().width(), h - 20);
|
pItem->setFixedSize(tray_item_size, tray_item_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 三方插件
|
// 三方插件
|
||||||
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
||||||
PluginsItem *pItem = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
|
QLayout *layout = m_pluginLayout->itemAt(i)->layout();
|
||||||
if (pItem != trashPlugin && pItem != shutdownPlugin && pItem != keyboardPlugin && pItem !=notificationPlugin) {
|
if (layout) {
|
||||||
if (pItem->pluginName() == "datetime"){
|
PluginsItem *pItem = static_cast<PluginsItem *>(layout->itemAt(0)->widget());
|
||||||
pItem->setFixedSize(w, pItem->sizeHint().height());
|
if (pItem && pItem != trashPlugin && pItem != shutdownPlugin && pItem != keyboardPlugin && pItem !=notificationPlugin) {
|
||||||
} else if (pItem->pluginName() == "AiAssistant"){
|
if (pItem->pluginName() == "datetime") {
|
||||||
pItem->setFixedSize(w - 20, tray_item_size);
|
pItem->setFixedSize(w, pItem->sizeHint().height());
|
||||||
} else {
|
} else {
|
||||||
pItem->setFixedSize(w - 20, pItem->sizeHint().height());
|
pItem->setFixedSize(tray_item_size, tray_item_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int appTopAndBottomMargin = 0;
|
||||||
|
int appLeftAndRightMargin = 0;
|
||||||
|
|
||||||
|
int trayTopAndBottomMargin = 0;
|
||||||
|
int trayLeftAndRightMargin = 0;
|
||||||
|
|
||||||
|
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
|
||||||
|
appTopAndBottomMargin = (m_fixedAreaWidget->height() - appItemSize) / 2;
|
||||||
|
trayTopAndBottomMargin = (m_trayAreaWidget->height() - tray_item_size) / 2;
|
||||||
|
} else {
|
||||||
|
appLeftAndRightMargin = (m_fixedAreaWidget->width() - appItemSize) / 2;
|
||||||
|
trayLeftAndRightMargin = (m_trayAreaWidget->width() - tray_item_size) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_fixedAreaLayout->setContentsMargins(appLeftAndRightMargin, appTopAndBottomMargin, appLeftAndRightMargin, appTopAndBottomMargin);
|
||||||
|
m_appAreaSonLayout->setContentsMargins(appLeftAndRightMargin, appTopAndBottomMargin, appLeftAndRightMargin, appTopAndBottomMargin);
|
||||||
|
m_trayAreaLayout->setContentsMargins(trayLeftAndRightMargin, trayTopAndBottomMargin, trayLeftAndRightMargin, trayTopAndBottomMargin);
|
||||||
|
|
||||||
|
//因为日期时间插件大小和其他插件大小有异,需要单独设置各插件的边距
|
||||||
|
//而不对日期时间插件设置边距
|
||||||
|
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
||||||
|
QLayout *layout = m_pluginLayout->itemAt(i)->layout();
|
||||||
|
if (layout) {
|
||||||
|
PluginsItem *pItem = static_cast<PluginsItem *>(layout->itemAt(0)->widget());
|
||||||
|
|
||||||
|
if (pItem && pItem->pluginName() != "datetime") {
|
||||||
|
layout->setContentsMargins(trayLeftAndRightMargin, trayTopAndBottomMargin, trayLeftAndRightMargin, trayTopAndBottomMargin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanelControl::getTrayVisableItemCount()
|
void MainPanelControl::getTrayVisableItemCount()
|
||||||
|
@ -24,8 +24,12 @@
|
|||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
#include <QGSettings>
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
|
#define ICBC_CONF_FILE "/etc/deepin/icbc.conf"
|
||||||
|
|
||||||
inline QPixmap renderSVG(const QString &path, const QSize &size, const qreal devicePixelRatio) {
|
inline QPixmap renderSVG(const QString &path, const QSize &size, const qreal devicePixelRatio) {
|
||||||
QImageReader reader;
|
QImageReader reader;
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
@ -81,6 +85,18 @@ inline QScreen * screenAtByScaled(const QPoint &point) {
|
|||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool isSettingConfigured(const QString& id, const QString& path, const QString& keyName) {
|
||||||
|
if (!QGSettings::isSchemaInstalled(id.toUtf8())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
QGSettings setting(id.toUtf8(), path.toUtf8());
|
||||||
|
QVariant v = setting.get(keyName);
|
||||||
|
if (!v.isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return v.toBool();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // UTILS
|
#endif // UTILS
|
||||||
|
@ -13,20 +13,24 @@ find_package(Qt5DBus REQUIRED)
|
|||||||
find_package(DtkWidget REQUIRED)
|
find_package(DtkWidget REQUIRED)
|
||||||
pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)
|
pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)
|
||||||
|
|
||||||
|
pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)
|
||||||
|
pkg_check_modules(QGSettings REQUIRED gsettings-qt)
|
||||||
|
|
||||||
add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
|
add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
|
||||||
add_library(${PLUGIN_NAME} SHARED ${SRCS} datetime.qrc)
|
add_library(${PLUGIN_NAME} SHARED ${SRCS} datetime.qrc)
|
||||||
set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../)
|
set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../)
|
||||||
target_include_directories(${PLUGIN_NAME} PUBLIC
|
target_include_directories(${PLUGIN_NAME} PUBLIC
|
||||||
${DtkWidget_INCLUDE_DIRS}
|
${DtkWidget_INCLUDE_DIRS}
|
||||||
${DFrameworkDBus_INCLUDE_DIRS}
|
${DFrameworkDBus_INCLUDE_DIRS}
|
||||||
../../interfaces ${Qt5DBus_INCLUDE_DIRS}
|
${QGSettings_INCLUDE_DIRS}
|
||||||
)
|
../../interfaces)
|
||||||
target_link_libraries(${PLUGIN_NAME} PRIVATE
|
target_link_libraries(${PLUGIN_NAME} PRIVATE
|
||||||
${Qt5DBus_LIBRARIES}
|
${Qt5DBus_LIBRARIES}
|
||||||
${DtkWidget_LIBRARIES}
|
${DtkWidget_LIBRARIES}
|
||||||
${Qt5Widgets_LIBRARIES}
|
${Qt5Widgets_LIBRARIES}
|
||||||
${Qt5Svg_LIBRARIES}
|
${Qt5Svg_LIBRARIES}
|
||||||
${DFrameworkDBus_LIBRARIES}
|
${DFrameworkDBus_LIBRARIES}
|
||||||
|
${QGSettings_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins)
|
install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins)
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "datetimeplugin.h"
|
#include "datetimeplugin.h"
|
||||||
#include "../../widgets/tipswidget.h"
|
#include "../../widgets/tipswidget.h"
|
||||||
|
#include "../../frame/util/utils.h"
|
||||||
|
|
||||||
#include <DDBusSender>
|
#include <DDBusSender>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
@ -159,11 +160,13 @@ const QString DatetimePlugin::itemContextMenu(const QString &itemKey)
|
|||||||
settings["isActive"] = true;
|
settings["isActive"] = true;
|
||||||
items.push_back(settings);
|
items.push_back(settings);
|
||||||
|
|
||||||
QMap<QString, QVariant> open;
|
if (!QFile::exists(ICBC_CONF_FILE)) {
|
||||||
open["itemId"] = "open";
|
QMap<QString, QVariant> open;
|
||||||
open["itemText"] = tr("Time settings");
|
open["itemId"] = "open";
|
||||||
open["isActive"] = true;
|
open["itemText"] = tr("Time settings");
|
||||||
items.push_back(open);
|
open["isActive"] = true;
|
||||||
|
items.push_back(open);
|
||||||
|
}
|
||||||
|
|
||||||
QMap<QString, QVariant> menu;
|
QMap<QString, QVariant> menu;
|
||||||
menu["items"] = items;
|
menu["items"] = items;
|
||||||
|
@ -16,6 +16,7 @@ find_package(DtkWidget REQUIRED)
|
|||||||
|
|
||||||
pkg_check_modules(DDE-Network-Utils REQUIRED dde-network-utils)
|
pkg_check_modules(DDE-Network-Utils REQUIRED dde-network-utils)
|
||||||
pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)
|
pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)
|
||||||
|
pkg_check_modules(QGSettings REQUIRED gsettings-qt)
|
||||||
|
|
||||||
add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
|
add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
|
||||||
add_library(${PLUGIN_NAME} SHARED ${SRCS} network.qrc)
|
add_library(${PLUGIN_NAME} SHARED ${SRCS} network.qrc)
|
||||||
@ -23,6 +24,7 @@ set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../syst
|
|||||||
target_include_directories(${PLUGIN_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS}
|
target_include_directories(${PLUGIN_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS}
|
||||||
${Qt5DBus_INCLUDE_DIRS}
|
${Qt5DBus_INCLUDE_DIRS}
|
||||||
${DFrameworkDBus_INCLUDE_DIRS}
|
${DFrameworkDBus_INCLUDE_DIRS}
|
||||||
|
${QGSettings_INCLUDE_DIRS}
|
||||||
${DDE-Network-Utils_INCLUDE_DIRS}
|
${DDE-Network-Utils_INCLUDE_DIRS}
|
||||||
../../interfaces
|
../../interfaces
|
||||||
../../frame)
|
../../frame)
|
||||||
@ -31,6 +33,7 @@ target_link_libraries(${PLUGIN_NAME} PRIVATE
|
|||||||
${Qt5Widgets_LIBRARIES}
|
${Qt5Widgets_LIBRARIES}
|
||||||
${Qt5Svg_LIBRARIES}
|
${Qt5Svg_LIBRARIES}
|
||||||
${Qt5DBus_LIBRARIES}
|
${Qt5DBus_LIBRARIES}
|
||||||
|
${QGSettings_LIBRARIES}
|
||||||
${DDE-Network-Utils_LIBRARIES}
|
${DDE-Network-Utils_LIBRARIES}
|
||||||
${DFrameworkDBus_LIBRARIES}
|
${DFrameworkDBus_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
@ -20,10 +20,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "deviceitem.h"
|
#include "deviceitem.h"
|
||||||
|
#include "../frame/util/utils.h"
|
||||||
|
|
||||||
#include <DDBusSender>
|
#include <DDBusSender>
|
||||||
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
#include <QGSettings>
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
using namespace dde::network;
|
using namespace dde::network;
|
||||||
|
|
||||||
@ -62,11 +65,13 @@ const QString DeviceItem::itemContextMenu()
|
|||||||
enable["isActive"] = true;
|
enable["isActive"] = true;
|
||||||
items.push_back(enable);
|
items.push_back(enable);
|
||||||
|
|
||||||
QMap<QString, QVariant> settings;
|
if (!QFile::exists(ICBC_CONF_FILE)) {
|
||||||
settings["itemId"] = "settings";
|
QMap<QString, QVariant> settings;
|
||||||
settings["itemText"] = tr("Network settings");
|
settings["itemId"] = "settings";
|
||||||
settings["isActive"] = true;
|
settings["itemText"] = tr("Network settings");
|
||||||
items.push_back(settings);
|
settings["isActive"] = true;
|
||||||
|
items.push_back(settings);
|
||||||
|
}
|
||||||
|
|
||||||
QMap<QString, QVariant> menu;
|
QMap<QString, QVariant> menu;
|
||||||
menu["items"] = items;
|
menu["items"] = items;
|
||||||
|
@ -13,6 +13,7 @@ find_package(Qt5DBus REQUIRED)
|
|||||||
find_package(DtkWidget REQUIRED)
|
find_package(DtkWidget REQUIRED)
|
||||||
|
|
||||||
pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)
|
pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)
|
||||||
|
pkg_check_modules(QGSettings REQUIRED gsettings-qt)
|
||||||
|
|
||||||
add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
|
add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
|
||||||
add_library(${PLUGIN_NAME} SHARED ${SRCS} power.qrc)
|
add_library(${PLUGIN_NAME} SHARED ${SRCS} power.qrc)
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "powerplugin.h"
|
#include "powerplugin.h"
|
||||||
#include "dbus/dbusaccount.h"
|
#include "dbus/dbusaccount.h"
|
||||||
#include "../widgets/tipswidget.h"
|
#include "../widgets/tipswidget.h"
|
||||||
|
#include "../frame/util/utils.h"
|
||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QGSettings>
|
#include <QGSettings>
|
||||||
@ -121,11 +122,13 @@ const QString PowerPlugin::itemContextMenu(const QString &itemKey)
|
|||||||
QList<QVariant> items;
|
QList<QVariant> items;
|
||||||
items.reserve(6);
|
items.reserve(6);
|
||||||
|
|
||||||
QMap<QString, QVariant> power;
|
if (!QFile::exists(ICBC_CONF_FILE)) {
|
||||||
power["itemId"] = "power";
|
QMap<QString, QVariant> power;
|
||||||
power["itemText"] = tr("Power settings");
|
power["itemId"] = "power";
|
||||||
power["isActive"] = true;
|
power["itemText"] = tr("Power settings");
|
||||||
items.push_back(power);
|
power["isActive"] = true;
|
||||||
|
items.push_back(power);
|
||||||
|
}
|
||||||
|
|
||||||
QMap<QString, QVariant> menu;
|
QMap<QString, QVariant> menu;
|
||||||
menu["items"] = items;
|
menu["items"] = items;
|
||||||
|
@ -15,18 +15,21 @@ find_package(DtkWidget REQUIRED)
|
|||||||
#if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
|
#if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
|
||||||
# add_definitions("-DDISABLE_POWER_OPTIONS")
|
# add_definitions("-DDISABLE_POWER_OPTIONS")
|
||||||
#endif()
|
#endif()
|
||||||
|
pkg_check_modules(QGSettings REQUIRED gsettings-qt)
|
||||||
|
|
||||||
add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
|
add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
|
||||||
add_library(${PLUGIN_NAME} SHARED ${SRCS} shutdown.qrc)
|
add_library(${PLUGIN_NAME} SHARED ${SRCS} shutdown.qrc)
|
||||||
set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../)
|
set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../)
|
||||||
target_include_directories(${PLUGIN_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS}
|
target_include_directories(${PLUGIN_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS}
|
||||||
${Qt5DBus_INCLUDE_DIRS}
|
${Qt5DBus_INCLUDE_DIRS}
|
||||||
|
${QGSettings_INCLUDE_DIRS}
|
||||||
../../interfaces)
|
../../interfaces)
|
||||||
target_link_libraries(${PLUGIN_NAME} PRIVATE
|
target_link_libraries(${PLUGIN_NAME} PRIVATE
|
||||||
${DtkWidget_LIBRARIES}
|
${DtkWidget_LIBRARIES}
|
||||||
${Qt5Widgets_LIBRARIES}
|
${Qt5Widgets_LIBRARIES}
|
||||||
${Qt5Svg_LIBRARIES}
|
${Qt5Svg_LIBRARIES}
|
||||||
${Qt5DBus_LIBRARIES}
|
${Qt5DBus_LIBRARIES}
|
||||||
|
${QGSettings_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins)
|
install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins)
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "shutdownplugin.h"
|
#include "shutdownplugin.h"
|
||||||
#include "dbus/dbusaccount.h"
|
#include "dbus/dbusaccount.h"
|
||||||
|
#include "../frame/util/utils.h"
|
||||||
#include "../widgets/tipswidget.h"
|
#include "../widgets/tipswidget.h"
|
||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
@ -161,21 +162,23 @@ const QString ShutdownPlugin::itemContextMenu(const QString &itemKey)
|
|||||||
logout["isActive"] = true;
|
logout["isActive"] = true;
|
||||||
items.push_back(logout);
|
items.push_back(logout);
|
||||||
|
|
||||||
if (DBusAccount().userList().count() > 1) {
|
if (!QFile::exists(ICBC_CONF_FILE)) {
|
||||||
QMap<QString, QVariant> switchUser;
|
if (DBusAccount().userList().count() > 1) {
|
||||||
switchUser["itemId"] = "SwitchUser";
|
QMap<QString, QVariant> switchUser;
|
||||||
switchUser["itemText"] = tr("Switch account");
|
switchUser["itemId"] = "SwitchUser";
|
||||||
switchUser["isActive"] = true;
|
switchUser["itemText"] = tr("Switch account");
|
||||||
items.push_back(switchUser);
|
switchUser["isActive"] = true;
|
||||||
}
|
items.push_back(switchUser);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_POWER_OPTIONS
|
#ifndef DISABLE_POWER_OPTIONS
|
||||||
QMap<QString, QVariant> power;
|
QMap<QString, QVariant> power;
|
||||||
power["itemId"] = "power";
|
power["itemId"] = "power";
|
||||||
power["itemText"] = tr("Power settings");
|
power["itemText"] = tr("Power settings");
|
||||||
power["isActive"] = true;
|
power["isActive"] = true;
|
||||||
items.push_back(power);
|
items.push_back(power);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
QMap<QString, QVariant> menu;
|
QMap<QString, QVariant> menu;
|
||||||
menu["items"] = items;
|
menu["items"] = items;
|
||||||
@ -192,11 +195,22 @@ void ShutdownPlugin::invokedMenuItem(const QString &itemKey, const QString &menu
|
|||||||
|
|
||||||
if (menuId == "power")
|
if (menuId == "power")
|
||||||
QProcess::startDetached("dbus-send --print-reply --dest=com.deepin.dde.ControlCenter /com/deepin/dde/ControlCenter com.deepin.dde.ControlCenter.ShowModule \"string:power\"");
|
QProcess::startDetached("dbus-send --print-reply --dest=com.deepin.dde.ControlCenter /com/deepin/dde/ControlCenter com.deepin.dde.ControlCenter.ShowModule \"string:power\"");
|
||||||
else if (menuId == "Lock")
|
else if (menuId == "Lock") {
|
||||||
QProcess::startDetached("dbus-send", QStringList() << "--print-reply"
|
if (QFile::exists(ICBC_CONF_FILE)) {
|
||||||
<< "--dest=com.deepin.dde.lockFront"
|
QDBusMessage send = QDBusMessage::createMethodCall("com.deepin.dde.lockFront", "/com/deepin/dde/lockFront", "com.deepin.dde.lockFront", "SwitchTTYAndShow");
|
||||||
<< "/com/deepin/dde/lockFront"
|
QDBusConnection conn = QDBusConnection::connectToBus("unix:path=/run/user/1000/bus","unix:path=/run/user/1000/bus");
|
||||||
<< QString("com.deepin.dde.lockFront.Show"));
|
QDBusMessage reply = conn.call(send);
|
||||||
|
#ifdef QT_DEBUG
|
||||||
|
qInfo()<<"----------"<<reply;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} else {
|
||||||
|
QProcess::startDetached("dbus-send", QStringList() << "--print-reply"
|
||||||
|
<< "--dest=com.deepin.dde.lockFront"
|
||||||
|
<< "/com/deepin/dde/lockFront"
|
||||||
|
<< QString("com.deepin.dde.lockFront.Show"));
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
QProcess::startDetached("dbus-send", QStringList() << "--print-reply"
|
QProcess::startDetached("dbus-send", QStringList() << "--print-reply"
|
||||||
<< "--dest=com.deepin.dde.shutdownFront"
|
<< "--dest=com.deepin.dde.shutdownFront"
|
||||||
|
@ -19,25 +19,29 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sounditem.h"
|
|
||||||
#include "constants.h"
|
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
#include <QGSettings>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
#include <DApplication>
|
#include <DApplication>
|
||||||
#include <DDBusSender>
|
#include <DDBusSender>
|
||||||
|
#include <DGuiApplicationHelper>
|
||||||
|
|
||||||
|
DWIDGET_USE_NAMESPACE
|
||||||
|
DGUI_USE_NAMESPACE
|
||||||
|
|
||||||
|
#include "sounditem.h"
|
||||||
|
#include "constants.h"
|
||||||
#include "../widgets/tipswidget.h"
|
#include "../widgets/tipswidget.h"
|
||||||
#include "../frame/util/imageutil.h"
|
#include "../frame/util/imageutil.h"
|
||||||
#include <DGuiApplicationHelper>
|
#include "../frame/util/utils.h"
|
||||||
|
|
||||||
// menu actions
|
// menu actions
|
||||||
#define MUTE "mute"
|
#define MUTE "mute"
|
||||||
#define SETTINGS "settings"
|
#define SETTINGS "settings"
|
||||||
|
|
||||||
DWIDGET_USE_NAMESPACE
|
|
||||||
DGUI_USE_NAMESPACE
|
|
||||||
|
|
||||||
using namespace Dock;
|
using namespace Dock;
|
||||||
SoundItem::SoundItem(QWidget *parent)
|
SoundItem::SoundItem(QWidget *parent)
|
||||||
@ -88,11 +92,17 @@ const QString SoundItem::contextMenu() const
|
|||||||
open["isActive"] = true;
|
open["isActive"] = true;
|
||||||
items.push_back(open);
|
items.push_back(open);
|
||||||
|
|
||||||
QMap<QString, QVariant> settings;
|
if (!QFile::exists(ICBC_CONF_FILE)) {
|
||||||
settings["itemId"] = SETTINGS;
|
QMap<QString, QVariant> settings;
|
||||||
settings["itemText"] = tr("Sound settings");
|
settings["itemId"] = SETTINGS;
|
||||||
settings["isActive"] = true;
|
settings["itemText"] = tr("Sound settings");
|
||||||
items.push_back(settings);
|
settings["isActive"] = true;
|
||||||
|
items.push_back(settings);
|
||||||
|
#ifdef QT_DEBUG
|
||||||
|
qInfo() << "----------icbc sound setting.";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QMap<QString, QVariant> menu;
|
QMap<QString, QVariant> menu;
|
||||||
menu["items"] = items;
|
menu["items"] = items;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user