mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +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)
|
||||
: QWidget(parent)
|
||||
, m_wid(wid)
|
||||
, m_isWidowHidden(false)
|
||||
, m_title(new TipsWidget)
|
||||
, m_waitLeaveTimer(new QTimer(this))
|
||||
, m_closeBtn2D(new DIconButton(this))
|
||||
, 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->setIconSize(QSize(24, 24));
|
||||
@ -85,6 +87,13 @@ AppSnapshot::AppSnapshot(const WId wid, QWidget *parent)
|
||||
QTimer::singleShot(1, this, &AppSnapshot::compositeChanged);
|
||||
}
|
||||
|
||||
void AppSnapshot::setWindowState()
|
||||
{
|
||||
if (m_isWidowHidden) {
|
||||
m_dockDaemonInter->MinimizeWindow(m_wid);
|
||||
}
|
||||
}
|
||||
|
||||
void AppSnapshot::closeWindow() const
|
||||
{
|
||||
const auto display = QX11Info::display();
|
||||
@ -118,6 +127,7 @@ void AppSnapshot::setWindowInfo(const WindowInfo &info)
|
||||
QFontMetrics fm(m_title->font());
|
||||
QString strTtile = m_title->fontMetrics().elidedText(m_windowInfo.title, Qt::ElideRight, width() - m_closeBtn2D->width());
|
||||
m_title->setText(strTtile);
|
||||
getWindowState();
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
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 <DWindowManagerHelper>
|
||||
|
||||
#include <com_deepin_dde_daemon_dock.h>
|
||||
#include <com_deepin_dde_daemon_dock_entry.h>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
@ -41,6 +42,8 @@ struct SHMInfo;
|
||||
struct _XImage;
|
||||
typedef _XImage XImage;
|
||||
|
||||
using DockDaemonInter = com::deepin::dde::daemon::Dock;
|
||||
|
||||
namespace Dock {
|
||||
class TipsWidget;
|
||||
}
|
||||
@ -59,6 +62,7 @@ public:
|
||||
inline const QImage snapshot() const { return m_snapshot; }
|
||||
inline const QRectF snapshotGeometry() const { return m_snapshotSrcRect; }
|
||||
inline const QString title() const { return m_windowInfo.title; }
|
||||
void setWindowState();
|
||||
|
||||
signals:
|
||||
void entered(const WId wid) const;
|
||||
@ -82,13 +86,14 @@ private:
|
||||
SHMInfo *getImageDSHM();
|
||||
XImage *getImageXlib();
|
||||
QRect rectRemovedShadow(const QImage &qimage, unsigned char *prop_to_return_gtk);
|
||||
void getWindowState();
|
||||
|
||||
private:
|
||||
const WId m_wid;
|
||||
WindowInfo m_windowInfo;
|
||||
|
||||
bool m_closeAble;
|
||||
|
||||
bool m_isWidowHidden;
|
||||
QImage m_snapshot;
|
||||
QRectF m_snapshotSrcRect;
|
||||
|
||||
@ -96,6 +101,7 @@ private:
|
||||
QTimer *m_waitLeaveTimer;
|
||||
DIconButton *m_closeBtn2D;
|
||||
DWindowManagerHelper *m_wmHelper;
|
||||
DockDaemonInter *m_dockDaemonInter;
|
||||
};
|
||||
|
||||
#endif // APPSNAPSHOT_H
|
||||
|
@ -186,6 +186,7 @@ void FloatingPreview::hideEvent(QHideEvent *event)
|
||||
{
|
||||
if (m_tracked) {
|
||||
m_tracked->setContentsMargins(0, 0, 0, 0);
|
||||
m_tracked->setWindowState();
|
||||
}
|
||||
|
||||
QWidget::hideEvent(event);
|
||||
|
@ -241,6 +241,7 @@ void PreviewContainer::previewEntered(const WId wid)
|
||||
AppSnapshot *preSnap = m_floatingPreview->trackedWindow();
|
||||
if (preSnap && preSnap != snap) {
|
||||
preSnap->setContentsMargins(0, 0, 0, 0);
|
||||
preSnap->setWindowState();
|
||||
}
|
||||
|
||||
m_currentWId = wid;
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include "window/mainwindow.h"
|
||||
#include "window/accessible.h"
|
||||
#include "dbus/dbusdockadaptors.h"
|
||||
#include "util/utils.h"
|
||||
#include "util/themeappicon.h"
|
||||
#include "controller/dockitemmanager.h"
|
||||
#include "util/dockapplication.h"
|
||||
@ -29,15 +31,16 @@
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
#include <QDateTime>
|
||||
#include <QGSettings>
|
||||
|
||||
#include <DApplication>
|
||||
#include <DLog>
|
||||
#include <DDBusSender>
|
||||
#include <DGuiApplicationHelper>
|
||||
|
||||
#include <unistd.h>
|
||||
#include "dbus/dbusdockadaptors.h"
|
||||
#include <string>
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <execinfo.h>
|
||||
@ -203,6 +206,13 @@ int main(int argc, char *argv[])
|
||||
app.setAttribute(Qt::AA_EnableHighDpiScaling, true);
|
||||
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);
|
||||
|
||||
// load dde-network-utils translator
|
||||
|
@ -256,8 +256,12 @@ void MainPanelControl::addTrayAreaItem(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();
|
||||
}
|
||||
|
||||
@ -278,7 +282,16 @@ void MainPanelControl::removeTrayAreaItem(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)
|
||||
@ -378,9 +391,17 @@ void MainPanelControl::moveItem(DockItem *sourceItem, DockItem *targetItem)
|
||||
int idx = -1;
|
||||
if (targetItem->itemType() == DockItem::App)
|
||||
idx = m_appAreaSonLayout->indexOf(targetItem);
|
||||
else if (targetItem->itemType() == DockItem::Plugins)
|
||||
idx = m_pluginLayout->indexOf(targetItem);
|
||||
else if (targetItem->itemType() == DockItem::FixedPlugin)
|
||||
else if (targetItem->itemType() == DockItem::Plugins){
|
||||
//因为日期时间插件大小和其他插件大小有异,为了设置边距,在各插件中增加了一层布局
|
||||
//因此有拖动图标时,需要从多的一层布局中判断是否相同插件而获取插件位置顺序
|
||||
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);
|
||||
else
|
||||
return;
|
||||
@ -738,22 +759,21 @@ DockItem *MainPanelControl::dropTargetItem(DockItem *sourceItem, QPoint point)
|
||||
|
||||
for (int i = 0 ; i < parentLayout->count(); ++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)
|
||||
continue;
|
||||
|
||||
QRect rect;
|
||||
|
||||
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());
|
||||
}
|
||||
QRect rect(dockItem->pos(), dockItem->size());
|
||||
if (rect.contains(point)) {
|
||||
targetItem = dockItem;
|
||||
break;
|
||||
@ -889,31 +909,39 @@ void MainPanelControl::paintEvent(QPaintEvent *event)
|
||||
|
||||
void MainPanelControl::resizeDockIcon()
|
||||
{
|
||||
if (!m_tray)
|
||||
return;
|
||||
// 插件有点特殊,因为会引入第三方的插件,并不会受dock的缩放影响,我们只能限制我们自己的插件,否则会导致显示错误。
|
||||
// 以下是受控制的插件
|
||||
PluginsItem *trashPlugin = nullptr;
|
||||
PluginsItem *shutdownPlugin = nullptr;
|
||||
PluginsItem *keyboardPlugin = nullptr;
|
||||
PluginsItem *notificationPlugin = nullptr;
|
||||
|
||||
//因为日期时间大小和其他插件大小有异,为了设置边距,在各插件中增加了一层布局
|
||||
//因此需要通过多一层布局来获取各插件
|
||||
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
||||
PluginsItem *w = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
|
||||
if (w->pluginName() == "trash") {
|
||||
trashPlugin = w;
|
||||
} else if (w->pluginName() == "shutdown") {
|
||||
shutdownPlugin = w;
|
||||
} else if (w->pluginName() == "onboard") {
|
||||
keyboardPlugin = w;
|
||||
} else if (w->pluginName() == "notifications") {
|
||||
notificationPlugin = w;
|
||||
QLayout *layout = m_pluginLayout->itemAt(i)->layout();
|
||||
if (layout) {
|
||||
PluginsItem *w = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
|
||||
if (w) {
|
||||
if (w->pluginName() == "trash") {
|
||||
trashPlugin = w;
|
||||
} else if (w->pluginName() == "shutdown") {
|
||||
shutdownPlugin = 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();
|
||||
// 减去托盘间隔区域
|
||||
totalLength -= (m_tray->trayVisableItemCount() + 1) * 10;
|
||||
if (m_tray) {
|
||||
totalLength -= (m_tray->trayVisableItemCount() + 1) * 10;
|
||||
}
|
||||
// 减去3个分割线的宽度
|
||||
totalLength -= 3 * SPLITER_SIZE;
|
||||
|
||||
@ -938,7 +966,12 @@ void MainPanelControl::resizeDockIcon()
|
||||
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个数
|
||||
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)
|
||||
{
|
||||
int appItemSize = qMin(w, h);
|
||||
|
||||
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) {
|
||||
@ -994,7 +1029,7 @@ void MainPanelControl::calcuDockIconSize(int w, int h, PluginsItem *trashPlugin,
|
||||
}
|
||||
|
||||
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)
|
||||
return;
|
||||
|
||||
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 (m_tray) {
|
||||
m_tray->centralWidget()->setProperty("iconSize", 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)) {
|
||||
// 三方插件
|
||||
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
||||
PluginsItem *pItem = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
|
||||
if (pItem != trashPlugin && pItem != shutdownPlugin && pItem != keyboardPlugin && pItem !=notificationPlugin) {
|
||||
if (pItem->pluginName() == "datetime"){
|
||||
pItem->setFixedSize(pItem->sizeHint().width(), h);
|
||||
} else if (pItem->pluginName() == "AiAssistant"){
|
||||
pItem->setFixedSize(tray_item_size, h - 20);
|
||||
} else {
|
||||
pItem->setFixedSize(pItem->sizeHint().width(), h - 20);
|
||||
QLayout *layout = m_pluginLayout->itemAt(i)->layout();
|
||||
if (layout) {
|
||||
PluginsItem *pItem = static_cast<PluginsItem *>(layout->itemAt(0)->widget());
|
||||
if (pItem && pItem != trashPlugin && pItem != shutdownPlugin && pItem != keyboardPlugin && pItem !=notificationPlugin) {
|
||||
if (pItem->pluginName() == "datetime") {
|
||||
pItem->setFixedSize(pItem->sizeHint().width(), h);
|
||||
} else {
|
||||
pItem->setFixedSize(tray_item_size, tray_item_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 三方插件
|
||||
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
||||
PluginsItem *pItem = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
|
||||
if (pItem != trashPlugin && pItem != shutdownPlugin && pItem != keyboardPlugin && pItem !=notificationPlugin) {
|
||||
if (pItem->pluginName() == "datetime"){
|
||||
pItem->setFixedSize(w, pItem->sizeHint().height());
|
||||
} else if (pItem->pluginName() == "AiAssistant"){
|
||||
pItem->setFixedSize(w - 20, tray_item_size);
|
||||
} else {
|
||||
pItem->setFixedSize(w - 20, pItem->sizeHint().height());
|
||||
QLayout *layout = m_pluginLayout->itemAt(i)->layout();
|
||||
if (layout) {
|
||||
PluginsItem *pItem = static_cast<PluginsItem *>(layout->itemAt(0)->widget());
|
||||
if (pItem && pItem != trashPlugin && pItem != shutdownPlugin && pItem != keyboardPlugin && pItem !=notificationPlugin) {
|
||||
if (pItem->pluginName() == "datetime") {
|
||||
pItem->setFixedSize(w, pItem->sizeHint().height());
|
||||
} else {
|
||||
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()
|
||||
|
@ -24,8 +24,12 @@
|
||||
#include <QImageReader>
|
||||
#include <QApplication>
|
||||
#include <QScreen>
|
||||
#include <QGSettings>
|
||||
|
||||
namespace Utils {
|
||||
|
||||
#define ICBC_CONF_FILE "/etc/deepin/icbc.conf"
|
||||
|
||||
inline QPixmap renderSVG(const QString &path, const QSize &size, const qreal devicePixelRatio) {
|
||||
QImageReader reader;
|
||||
QPixmap pixmap;
|
||||
@ -81,6 +85,18 @@ inline QScreen * screenAtByScaled(const QPoint &point) {
|
||||
|
||||
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
|
||||
|
@ -13,20 +13,24 @@ find_package(Qt5DBus 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_library(${PLUGIN_NAME} SHARED ${SRCS} datetime.qrc)
|
||||
set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../)
|
||||
target_include_directories(${PLUGIN_NAME} PUBLIC
|
||||
${DtkWidget_INCLUDE_DIRS}
|
||||
${DFrameworkDBus_INCLUDE_DIRS}
|
||||
../../interfaces ${Qt5DBus_INCLUDE_DIRS}
|
||||
)
|
||||
target_include_directories(${PLUGIN_NAME} PUBLIC
|
||||
${DtkWidget_INCLUDE_DIRS}
|
||||
${DFrameworkDBus_INCLUDE_DIRS}
|
||||
${QGSettings_INCLUDE_DIRS}
|
||||
../../interfaces)
|
||||
target_link_libraries(${PLUGIN_NAME} PRIVATE
|
||||
${Qt5DBus_LIBRARIES}
|
||||
${DtkWidget_LIBRARIES}
|
||||
${Qt5Widgets_LIBRARIES}
|
||||
${Qt5Svg_LIBRARIES}
|
||||
${DFrameworkDBus_LIBRARIES}
|
||||
${QGSettings_LIBRARIES}
|
||||
)
|
||||
|
||||
install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins)
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "datetimeplugin.h"
|
||||
#include "../../widgets/tipswidget.h"
|
||||
#include "../../frame/util/utils.h"
|
||||
|
||||
#include <DDBusSender>
|
||||
#include <QLabel>
|
||||
@ -159,11 +160,13 @@ const QString DatetimePlugin::itemContextMenu(const QString &itemKey)
|
||||
settings["isActive"] = true;
|
||||
items.push_back(settings);
|
||||
|
||||
QMap<QString, QVariant> open;
|
||||
open["itemId"] = "open";
|
||||
open["itemText"] = tr("Time settings");
|
||||
open["isActive"] = true;
|
||||
items.push_back(open);
|
||||
if (!QFile::exists(ICBC_CONF_FILE)) {
|
||||
QMap<QString, QVariant> open;
|
||||
open["itemId"] = "open";
|
||||
open["itemText"] = tr("Time settings");
|
||||
open["isActive"] = true;
|
||||
items.push_back(open);
|
||||
}
|
||||
|
||||
QMap<QString, QVariant> menu;
|
||||
menu["items"] = items;
|
||||
|
@ -16,6 +16,7 @@ find_package(DtkWidget REQUIRED)
|
||||
|
||||
pkg_check_modules(DDE-Network-Utils REQUIRED dde-network-utils)
|
||||
pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)
|
||||
pkg_check_modules(QGSettings REQUIRED gsettings-qt)
|
||||
|
||||
add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
|
||||
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}
|
||||
${Qt5DBus_INCLUDE_DIRS}
|
||||
${DFrameworkDBus_INCLUDE_DIRS}
|
||||
${QGSettings_INCLUDE_DIRS}
|
||||
${DDE-Network-Utils_INCLUDE_DIRS}
|
||||
../../interfaces
|
||||
../../frame)
|
||||
@ -31,6 +33,7 @@ target_link_libraries(${PLUGIN_NAME} PRIVATE
|
||||
${Qt5Widgets_LIBRARIES}
|
||||
${Qt5Svg_LIBRARIES}
|
||||
${Qt5DBus_LIBRARIES}
|
||||
${QGSettings_LIBRARIES}
|
||||
${DDE-Network-Utils_LIBRARIES}
|
||||
${DFrameworkDBus_LIBRARIES}
|
||||
)
|
||||
|
@ -20,10 +20,13 @@
|
||||
*/
|
||||
|
||||
#include "deviceitem.h"
|
||||
#include "../frame/util/utils.h"
|
||||
|
||||
#include <DDBusSender>
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QGSettings>
|
||||
#include <QFile>
|
||||
|
||||
using namespace dde::network;
|
||||
|
||||
@ -62,11 +65,13 @@ const QString DeviceItem::itemContextMenu()
|
||||
enable["isActive"] = true;
|
||||
items.push_back(enable);
|
||||
|
||||
QMap<QString, QVariant> settings;
|
||||
settings["itemId"] = "settings";
|
||||
settings["itemText"] = tr("Network settings");
|
||||
settings["isActive"] = true;
|
||||
items.push_back(settings);
|
||||
if (!QFile::exists(ICBC_CONF_FILE)) {
|
||||
QMap<QString, QVariant> settings;
|
||||
settings["itemId"] = "settings";
|
||||
settings["itemText"] = tr("Network settings");
|
||||
settings["isActive"] = true;
|
||||
items.push_back(settings);
|
||||
}
|
||||
|
||||
QMap<QString, QVariant> menu;
|
||||
menu["items"] = items;
|
||||
|
@ -13,6 +13,7 @@ find_package(Qt5DBus REQUIRED)
|
||||
find_package(DtkWidget REQUIRED)
|
||||
|
||||
pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)
|
||||
pkg_check_modules(QGSettings REQUIRED gsettings-qt)
|
||||
|
||||
add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
|
||||
add_library(${PLUGIN_NAME} SHARED ${SRCS} power.qrc)
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "powerplugin.h"
|
||||
#include "dbus/dbusaccount.h"
|
||||
#include "../widgets/tipswidget.h"
|
||||
#include "../frame/util/utils.h"
|
||||
|
||||
#include <QIcon>
|
||||
#include <QGSettings>
|
||||
@ -121,11 +122,13 @@ const QString PowerPlugin::itemContextMenu(const QString &itemKey)
|
||||
QList<QVariant> items;
|
||||
items.reserve(6);
|
||||
|
||||
QMap<QString, QVariant> power;
|
||||
power["itemId"] = "power";
|
||||
power["itemText"] = tr("Power settings");
|
||||
power["isActive"] = true;
|
||||
items.push_back(power);
|
||||
if (!QFile::exists(ICBC_CONF_FILE)) {
|
||||
QMap<QString, QVariant> power;
|
||||
power["itemId"] = "power";
|
||||
power["itemText"] = tr("Power settings");
|
||||
power["isActive"] = true;
|
||||
items.push_back(power);
|
||||
}
|
||||
|
||||
QMap<QString, QVariant> menu;
|
||||
menu["items"] = items;
|
||||
|
@ -15,18 +15,21 @@ find_package(DtkWidget REQUIRED)
|
||||
#if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
|
||||
# add_definitions("-DDISABLE_POWER_OPTIONS")
|
||||
#endif()
|
||||
pkg_check_modules(QGSettings REQUIRED gsettings-qt)
|
||||
|
||||
add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
|
||||
add_library(${PLUGIN_NAME} SHARED ${SRCS} shutdown.qrc)
|
||||
set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../)
|
||||
target_include_directories(${PLUGIN_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS}
|
||||
${Qt5DBus_INCLUDE_DIRS}
|
||||
${QGSettings_INCLUDE_DIRS}
|
||||
../../interfaces)
|
||||
target_link_libraries(${PLUGIN_NAME} PRIVATE
|
||||
${DtkWidget_LIBRARIES}
|
||||
${Qt5Widgets_LIBRARIES}
|
||||
${Qt5Svg_LIBRARIES}
|
||||
${Qt5DBus_LIBRARIES}
|
||||
${QGSettings_LIBRARIES}
|
||||
)
|
||||
|
||||
install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins)
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "shutdownplugin.h"
|
||||
#include "dbus/dbusaccount.h"
|
||||
#include "../frame/util/utils.h"
|
||||
#include "../widgets/tipswidget.h"
|
||||
|
||||
#include <QIcon>
|
||||
@ -161,21 +162,23 @@ const QString ShutdownPlugin::itemContextMenu(const QString &itemKey)
|
||||
logout["isActive"] = true;
|
||||
items.push_back(logout);
|
||||
|
||||
if (DBusAccount().userList().count() > 1) {
|
||||
QMap<QString, QVariant> switchUser;
|
||||
switchUser["itemId"] = "SwitchUser";
|
||||
switchUser["itemText"] = tr("Switch account");
|
||||
switchUser["isActive"] = true;
|
||||
items.push_back(switchUser);
|
||||
}
|
||||
if (!QFile::exists(ICBC_CONF_FILE)) {
|
||||
if (DBusAccount().userList().count() > 1) {
|
||||
QMap<QString, QVariant> switchUser;
|
||||
switchUser["itemId"] = "SwitchUser";
|
||||
switchUser["itemText"] = tr("Switch account");
|
||||
switchUser["isActive"] = true;
|
||||
items.push_back(switchUser);
|
||||
}
|
||||
|
||||
#ifndef DISABLE_POWER_OPTIONS
|
||||
QMap<QString, QVariant> power;
|
||||
power["itemId"] = "power";
|
||||
power["itemText"] = tr("Power settings");
|
||||
power["isActive"] = true;
|
||||
items.push_back(power);
|
||||
QMap<QString, QVariant> power;
|
||||
power["itemId"] = "power";
|
||||
power["itemText"] = tr("Power settings");
|
||||
power["isActive"] = true;
|
||||
items.push_back(power);
|
||||
#endif
|
||||
}
|
||||
|
||||
QMap<QString, QVariant> menu;
|
||||
menu["items"] = items;
|
||||
@ -192,11 +195,22 @@ void ShutdownPlugin::invokedMenuItem(const QString &itemKey, const QString &menu
|
||||
|
||||
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\"");
|
||||
else if (menuId == "Lock")
|
||||
QProcess::startDetached("dbus-send", QStringList() << "--print-reply"
|
||||
<< "--dest=com.deepin.dde.lockFront"
|
||||
<< "/com/deepin/dde/lockFront"
|
||||
<< QString("com.deepin.dde.lockFront.Show"));
|
||||
else if (menuId == "Lock") {
|
||||
if (QFile::exists(ICBC_CONF_FILE)) {
|
||||
QDBusMessage send = QDBusMessage::createMethodCall("com.deepin.dde.lockFront", "/com/deepin/dde/lockFront", "com.deepin.dde.lockFront", "SwitchTTYAndShow");
|
||||
QDBusConnection conn = QDBusConnection::connectToBus("unix:path=/run/user/1000/bus","unix:path=/run/user/1000/bus");
|
||||
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
|
||||
QProcess::startDetached("dbus-send", QStringList() << "--print-reply"
|
||||
<< "--dest=com.deepin.dde.shutdownFront"
|
||||
|
@ -19,25 +19,29 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "sounditem.h"
|
||||
#include "constants.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QIcon>
|
||||
#include <QMouseEvent>
|
||||
#include <QGSettings>
|
||||
#include <QApplication>
|
||||
|
||||
#include <DApplication>
|
||||
#include <DDBusSender>
|
||||
#include <DGuiApplicationHelper>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
DGUI_USE_NAMESPACE
|
||||
|
||||
#include "sounditem.h"
|
||||
#include "constants.h"
|
||||
#include "../widgets/tipswidget.h"
|
||||
#include "../frame/util/imageutil.h"
|
||||
#include <DGuiApplicationHelper>
|
||||
#include "../frame/util/utils.h"
|
||||
|
||||
// menu actions
|
||||
#define MUTE "mute"
|
||||
#define SETTINGS "settings"
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
DGUI_USE_NAMESPACE
|
||||
|
||||
using namespace Dock;
|
||||
SoundItem::SoundItem(QWidget *parent)
|
||||
@ -88,11 +92,17 @@ const QString SoundItem::contextMenu() const
|
||||
open["isActive"] = true;
|
||||
items.push_back(open);
|
||||
|
||||
QMap<QString, QVariant> settings;
|
||||
settings["itemId"] = SETTINGS;
|
||||
settings["itemText"] = tr("Sound settings");
|
||||
settings["isActive"] = true;
|
||||
items.push_back(settings);
|
||||
if (!QFile::exists(ICBC_CONF_FILE)) {
|
||||
QMap<QString, QVariant> settings;
|
||||
settings["itemId"] = SETTINGS;
|
||||
settings["itemText"] = tr("Sound settings");
|
||||
settings["isActive"] = true;
|
||||
items.push_back(settings);
|
||||
#ifdef QT_DEBUG
|
||||
qInfo() << "----------icbc sound setting.";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> menu;
|
||||
menu["items"] = items;
|
||||
|
Loading…
x
Reference in New Issue
Block a user