mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
Merge branch 'dev/refactor-plugins-mouse' into merge-dev/refactor-plugins-mouse
Change-Id: I03089593b793de20d8400449812bfdc9e4e83ecb
This commit is contained in:
commit
fcb2c8563e
Notes:
gerrit
2019-01-07 10:37:46 +08:00
Verified+1: <jenkins@deepin.com> Code-Review+2: listenerri <listenerri@gmail.com> Submitted-by: listenerri <listenerri@gmail.com> Submitted-at: Mon, 07 Jan 2019 10:37:45 +0800 Reviewed-on: https://cr.deepin.io/41122 Project: dde/dde-dock Branch: refs/heads/master
@ -28,8 +28,6 @@
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
|
||||
#define API_VERSION "1.1"
|
||||
|
||||
DockPluginsController::DockPluginsController(
|
||||
DockItemController *itemControllerInter)
|
||||
: QObject(itemControllerInter)
|
||||
@ -94,14 +92,6 @@ void DockPluginsController::itemRemoved(PluginsItemInterface * const itemInter,
|
||||
item->deleteLater();
|
||||
}
|
||||
|
||||
void DockPluginsController::requestContextMenu(PluginsItemInterface * const itemInter, const QString &itemKey)
|
||||
{
|
||||
PluginsItem *item = pluginItemAt(itemInter, itemKey);
|
||||
Q_ASSERT(item);
|
||||
|
||||
item->showContextMenu();
|
||||
}
|
||||
|
||||
void DockPluginsController::requestWindowAutoHide(PluginsItemInterface * const itemInter, const QString &itemKey, const bool autoHide)
|
||||
{
|
||||
PluginsItem *item = pluginItemAt(itemInter, itemKey);
|
||||
@ -118,6 +108,18 @@ void DockPluginsController::requestRefreshWindowVisible(PluginsItemInterface * c
|
||||
Q_EMIT item->requestRefreshWindowVisible();
|
||||
}
|
||||
|
||||
void DockPluginsController::requestSetAppletVisible(PluginsItemInterface * const itemInter, const QString &itemKey, const bool visible)
|
||||
{
|
||||
PluginsItem *item = pluginItemAt(itemInter, itemKey);
|
||||
Q_ASSERT(item);
|
||||
|
||||
if (visible) {
|
||||
item->showPopupApplet(itemInter->itemPopupApplet(itemKey));
|
||||
} else {
|
||||
item->hidePopup();
|
||||
}
|
||||
}
|
||||
|
||||
void DockPluginsController::startLoader()
|
||||
{
|
||||
DockPluginLoader *loader = new DockPluginLoader(this);
|
||||
@ -150,9 +152,9 @@ void DockPluginsController::loadPlugin(const QString &pluginFile)
|
||||
{
|
||||
QPluginLoader *pluginLoader = new QPluginLoader(pluginFile);
|
||||
const auto meta = pluginLoader->metaData().value("MetaData").toObject();
|
||||
if (!meta.contains("api") || meta["api"].toString() != API_VERSION)
|
||||
if (!meta.contains("api") || meta["api"].toString() != DOCK_PLUGIN_API_VERSION)
|
||||
{
|
||||
qWarning() << "plugin api version not matched!" << pluginFile;
|
||||
qWarning() << "plugin api version not matched! expect version:" << DOCK_PLUGIN_API_VERSION << pluginFile;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -45,9 +45,9 @@ public:
|
||||
void itemAdded(PluginsItemInterface * const itemInter, const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void itemUpdate(PluginsItemInterface * const itemInter, const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void itemRemoved(PluginsItemInterface * const itemInter, const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void requestContextMenu(PluginsItemInterface * const itemInter, const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void requestWindowAutoHide(PluginsItemInterface * const itemInter, const QString &itemKey, const bool autoHide) Q_DECL_OVERRIDE;
|
||||
void requestRefreshWindowVisible(PluginsItemInterface * const itemInter, const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void requestSetAppletVisible(PluginsItemInterface * const itemInter, const QString &itemKey, const bool visible) Q_DECL_OVERRIDE;
|
||||
void saveValue(PluginsItemInterface *const itemInter, const QString &itemKey, const QVariant &value) Q_DECL_OVERRIDE;
|
||||
const QVariant getValue(PluginsItemInterface *const itemInter, const QString &itemKey, const QVariant& failback = QVariant()) Q_DECL_OVERRIDE;
|
||||
|
||||
|
@ -321,19 +321,11 @@ void AppItem::mousePressEvent(QMouseEvent *e)
|
||||
m_updateIconGeometryTimer->stop();
|
||||
hidePopup();
|
||||
|
||||
if (e->button() == Qt::RightButton)
|
||||
{
|
||||
if (perfectIconRect().contains(e->pos()))
|
||||
{
|
||||
QMetaObject::invokeMethod(this, "showContextMenu", Qt::QueuedConnection);
|
||||
return;
|
||||
} else {
|
||||
return QWidget::mousePressEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (e->button() == Qt::LeftButton)
|
||||
MousePressPos = e->pos();
|
||||
|
||||
// context menu will handle in DockItem
|
||||
DockItem::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void AppItem::mouseMoveEvent(QMouseEvent *e)
|
||||
|
@ -150,8 +150,13 @@ void DockItem::mousePressEvent(QMouseEvent *e)
|
||||
// ignore this event to MainPanel/MainWindow to show context menu of MainWindow
|
||||
return e->ignore();
|
||||
}
|
||||
return showContextMenu();
|
||||
if (perfectIconRect().contains(e->pos())) {
|
||||
return showContextMenu();
|
||||
}
|
||||
}
|
||||
|
||||
// same as e->ignore above
|
||||
QWidget::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void DockItem::enterEvent(QEvent *e)
|
||||
|
@ -62,6 +62,9 @@ public:
|
||||
public slots:
|
||||
virtual void refershIcon() {}
|
||||
|
||||
void showPopupApplet(QWidget * const applet);
|
||||
void hidePopup();
|
||||
|
||||
signals:
|
||||
void dragStarted() const;
|
||||
void itemDropped(QObject *destination, const QPoint &dropPoint) const;
|
||||
@ -79,10 +82,8 @@ protected:
|
||||
const QPoint popupMarkPoint() const;
|
||||
const QPoint topleftPoint() const;
|
||||
|
||||
void hidePopup();
|
||||
void hideNonModel();
|
||||
void popupWindowAccept();
|
||||
void showPopupApplet(QWidget * const applet);
|
||||
virtual void showPopupWindow(QWidget * const content, const bool model = false);
|
||||
virtual void showHoverTips();
|
||||
virtual void invokedMenuItem(const QString &itemId, const bool checked);
|
||||
|
@ -163,7 +163,8 @@ void PluginsItem::mousePressEvent(QMouseEvent *e)
|
||||
if (e->button() == Qt::LeftButton)
|
||||
MousePressPoint = e->pos();
|
||||
|
||||
QWidget::mousePressEvent(e);
|
||||
// context menu will handle in DockItem
|
||||
DockItem::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void PluginsItem::mouseMoveEvent(QMouseEvent *e)
|
||||
|
@ -27,6 +27,7 @@
|
||||
namespace Dock {
|
||||
|
||||
#define DOCK_PLUGIN_MIME "dock/plugin"
|
||||
#define DOCK_PLUGIN_API_VERSION "1.1.1"
|
||||
|
||||
#define PROP_DISPLAY_MODE "DisplayMode"
|
||||
///
|
||||
|
@ -61,11 +61,13 @@ public:
|
||||
/// \brief requestContextMenu
|
||||
/// request show context menu
|
||||
///
|
||||
virtual void requestContextMenu(PluginsItemInterface * const itemInter, const QString &itemKey) = 0;
|
||||
//virtual void requestContextMenu(PluginsItemInterface * const itemInter, const QString &itemKey) = 0;
|
||||
|
||||
virtual void requestWindowAutoHide(PluginsItemInterface * const itemInter, const QString &itemKey, const bool autoHide) = 0;
|
||||
virtual void requestRefreshWindowVisible(PluginsItemInterface * const itemInter, const QString &itemKey) = 0;
|
||||
|
||||
virtual void requestSetAppletVisible(PluginsItemInterface * const itemInter, const QString &itemKey, const bool visible) = 0;
|
||||
|
||||
///
|
||||
/// \brief saveValue
|
||||
/// save module config to .config/deepin/dde-dock.conf
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"api": "1.1"
|
||||
"api": "1.1.1"
|
||||
}
|
||||
|
@ -42,8 +42,7 @@ DatetimePlugin::DatetimePlugin(QObject *parent)
|
||||
|
||||
m_centralWidget = new DatetimeWidget;
|
||||
|
||||
connect(m_centralWidget, &DatetimeWidget::requestContextMenu, [this] { m_proxyInter->requestContextMenu(this, QString()); });
|
||||
connect(m_centralWidget, &DatetimeWidget::requestUpdateGeometry, [this] { m_proxyInter->itemUpdate(this, QString()); });
|
||||
connect(m_centralWidget, &DatetimeWidget::requestUpdateGeometry, [this] { m_proxyInter->itemUpdate(this, pluginName()); });
|
||||
|
||||
connect(m_refershTimer, &QTimer::timeout, this, &DatetimePlugin::updateCurrentTimeString);
|
||||
}
|
||||
@ -73,7 +72,7 @@ void DatetimePlugin::init(PluginProxyInterface *proxyInter)
|
||||
}
|
||||
|
||||
if (!pluginIsDisable())
|
||||
m_proxyInter->itemAdded(this, QString());
|
||||
m_proxyInter->itemAdded(this, pluginName());
|
||||
}
|
||||
|
||||
void DatetimePlugin::pluginStateSwitched()
|
||||
@ -81,9 +80,9 @@ void DatetimePlugin::pluginStateSwitched()
|
||||
m_proxyInter->saveValue(this, PLUGIN_STATE_KEY, pluginIsDisable());
|
||||
|
||||
if (!pluginIsDisable())
|
||||
m_proxyInter->itemAdded(this, QString());
|
||||
m_proxyInter->itemAdded(this, pluginName());
|
||||
else
|
||||
m_proxyInter->itemRemoved(this, QString());
|
||||
m_proxyInter->itemRemoved(this, pluginName());
|
||||
}
|
||||
|
||||
bool DatetimePlugin::pluginIsDisable()
|
||||
|
@ -186,21 +186,6 @@ void DatetimeWidget::paintEvent(QPaintEvent *e)
|
||||
painter.drawPixmap(rect().center() - m_cachedIcon.rect().center() / ratio, m_cachedIcon);
|
||||
}
|
||||
|
||||
void DatetimeWidget::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->button() != Qt::RightButton)
|
||||
return QWidget::mousePressEvent(e);
|
||||
|
||||
const QPoint p(e->pos() - rect().center());
|
||||
if (p.manhattanLength() < std::min(width(), height()) * 0.8 * 0.5)
|
||||
{
|
||||
emit requestContextMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
QWidget::mousePressEvent(e);
|
||||
}
|
||||
|
||||
const QPixmap DatetimeWidget::loadSvg(const QString &fileName, const QSize size)
|
||||
{
|
||||
const auto ratio = qApp->devicePixelRatio();
|
||||
|
@ -35,7 +35,6 @@ public:
|
||||
|
||||
signals:
|
||||
void requestUpdateGeometry() const;
|
||||
void requestContextMenu() const;
|
||||
|
||||
public slots:
|
||||
void set24HourFormat(const bool value);
|
||||
@ -44,7 +43,6 @@ private:
|
||||
QSize sizeHint() const;
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
|
||||
const QPixmap loadSvg(const QString &fileName, const QSize size);
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"api": "1.1"
|
||||
"api": "1.1.1"
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"api": "1.1"
|
||||
"api": "1.1.1"
|
||||
}
|
||||
|
@ -393,5 +393,7 @@ void WirelessList::onActivateApFailed(const QString &apPath, const QString &uuid
|
||||
.arg(QString("network"))
|
||||
.arg(QString(QJsonDocument(m_editConnectionData).toJson()))
|
||||
.call();
|
||||
|
||||
Q_EMIT requestSetAppletVisible(false);
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ signals:
|
||||
void requestActiveAP(const QString &devPath, const QString &apPath, const QString &uuid) const;
|
||||
void requestDeactiveAP(const QString &devPath) const;
|
||||
void requestWirelessScan();
|
||||
void requestSetAppletVisible(const bool visible) const;
|
||||
|
||||
private slots:
|
||||
void loadAPList();
|
||||
|
@ -46,7 +46,6 @@ public:
|
||||
virtual void invokeMenuItem(const QString &menuId);
|
||||
|
||||
signals:
|
||||
void requestContextMenu() const;
|
||||
void requestSetDeviceEnable(const QString &path, const bool enable) const;
|
||||
|
||||
protected:
|
||||
|
@ -87,21 +87,6 @@ void WiredItem::resizeEvent(QResizeEvent *e)
|
||||
m_delayTimer->start();
|
||||
}
|
||||
|
||||
void WiredItem::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->button() != Qt::RightButton)
|
||||
return QWidget::mousePressEvent(e);
|
||||
|
||||
const QPoint p(e->pos() - rect().center());
|
||||
if (p.manhattanLength() < std::min(width(), height()) * 0.8 * 0.5)
|
||||
{
|
||||
emit requestContextMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
return QWidget::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void WiredItem::refreshIcon()
|
||||
{
|
||||
m_delayTimer->start();
|
||||
|
@ -44,7 +44,6 @@ public:
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
void mousePressEvent(QMouseEvent *e) override;
|
||||
|
||||
private slots:
|
||||
void refreshIcon() override;
|
||||
|
@ -125,21 +125,6 @@ void WirelessItem::resizeEvent(QResizeEvent *e)
|
||||
m_icons.clear();
|
||||
}
|
||||
|
||||
void WirelessItem::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->button() != Qt::RightButton)
|
||||
return e->ignore();
|
||||
|
||||
const QPoint p(e->pos() - rect().center());
|
||||
if (p.manhattanLength() < std::min(width(), height()) * 0.8 * 0.5)
|
||||
{
|
||||
emit requestContextMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
return QWidget::mousePressEvent(e);
|
||||
}
|
||||
|
||||
const QPixmap WirelessItem::iconPix(const Dock::DisplayMode displayMode, const int size)
|
||||
{
|
||||
if (m_device.isNull()) {
|
||||
@ -248,6 +233,7 @@ void WirelessItem::init()
|
||||
connect(m_APList, &WirelessList::requestActiveAP, this, &WirelessItem::requestActiveAP);
|
||||
connect(m_APList, &WirelessList::requestDeactiveAP, this, &WirelessItem::requestDeactiveAP);
|
||||
connect(m_APList, &WirelessList::requestWirelessScan, this, &WirelessItem::requestWirelessScan);
|
||||
connect(m_APList, &WirelessList::requestSetAppletVisible, this, &WirelessItem::requestSetAppletVisible);
|
||||
|
||||
QTimer::singleShot(0, this, [=]() {
|
||||
m_refreshTimer->start();
|
||||
|
@ -52,6 +52,7 @@ public Q_SLOTS:
|
||||
Q_SIGNALS:
|
||||
void requestActiveAP(const QString &devPath, const QString &apPath, const QString &uuid) const;
|
||||
void requestDeactiveAP(const QString &devPath) const;
|
||||
void requestSetAppletVisible(const bool visible) const;
|
||||
void feedSecret(const QString &connectionPath, const QString &settingName, const QString &password, const bool autoConnect);
|
||||
void cancelSecret(const QString &connectionPath, const QString &settingName);
|
||||
void queryActiveConnInfo();
|
||||
@ -63,7 +64,6 @@ protected:
|
||||
bool eventFilter(QObject *o, QEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
|
||||
private:
|
||||
const QPixmap iconPix(const Dock::DisplayMode displayMode, const int size);
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"api": "1.1",
|
||||
"api": "1.1.1",
|
||||
"depends-daemon-dbus-service": "com.deepin.daemon.Network"
|
||||
}
|
||||
|
@ -214,6 +214,9 @@ void NetworkPlugin::onDeviceListChanged(const QList<NetworkDevice *> devices)
|
||||
connect(static_cast<WirelessItem *>(item), &WirelessItem::queryConnectionSession,
|
||||
m_networkWorker, &NetworkWorker::queryConnectionSession);
|
||||
|
||||
connect(static_cast<WirelessItem *>(item), &WirelessItem::requestSetAppletVisible,
|
||||
this, &NetworkPlugin::onItemRequestSetAppletVisible);
|
||||
|
||||
m_networkWorker->queryAccessPoints(path);
|
||||
m_networkWorker->requestWirelessScan();
|
||||
break;
|
||||
@ -227,7 +230,6 @@ void NetworkPlugin::onDeviceListChanged(const QList<NetworkDevice *> devices)
|
||||
connect(device, &dde::network::NetworkDevice::enableChanged,
|
||||
m_delayRefreshTimer, static_cast<void (QTimer:: *)()>(&QTimer::start));
|
||||
|
||||
connect(item, &DeviceItem::requestContextMenu, this, &NetworkPlugin::contextMenuRequested);
|
||||
connect(item, &DeviceItem::requestSetDeviceEnable, m_networkWorker, &NetworkWorker::setDeviceEnable);
|
||||
connect(m_networkModel, &NetworkModel::connectivityChanged, item, &DeviceItem::refreshIcon);
|
||||
}
|
||||
@ -320,10 +322,10 @@ void NetworkPlugin::loadPlugin()
|
||||
onDeviceListChanged(m_networkModel->devices());
|
||||
}
|
||||
|
||||
void NetworkPlugin::contextMenuRequested()
|
||||
void NetworkPlugin::onItemRequestSetAppletVisible(const bool visible)
|
||||
{
|
||||
DeviceItem *item = qobject_cast<DeviceItem *>(sender());
|
||||
Q_ASSERT(item);
|
||||
|
||||
m_proxyInter->requestContextMenu(this, item->path());
|
||||
m_proxyInter->requestSetAppletVisible(this, item->path(), visible);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public:
|
||||
private slots:
|
||||
void onDeviceListChanged(const QList<dde::network::NetworkDevice *> devices);
|
||||
void refreshWiredItemVisible();
|
||||
void contextMenuRequested();
|
||||
void onItemRequestSetAppletVisible(const bool visible);
|
||||
|
||||
private:
|
||||
DeviceItem *itemByPath(const QString &path);
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"api": "1.1"
|
||||
"api": "1.1.1"
|
||||
}
|
||||
|
@ -28,8 +28,7 @@
|
||||
#include <QIcon>
|
||||
|
||||
OnboardItem::OnboardItem(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
m_hover(false)
|
||||
: QWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
@ -60,33 +59,6 @@ void OnboardItem::paintEvent(QPaintEvent *e)
|
||||
painter.drawPixmap(rect().center() - pixmap.rect().center() / qApp->devicePixelRatio(), pixmap);
|
||||
}
|
||||
|
||||
void OnboardItem::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->button() != Qt::RightButton)
|
||||
return QWidget::mousePressEvent(e);
|
||||
|
||||
const QPoint p(e->pos() - rect().center());
|
||||
if (p.manhattanLength() < std::min(width(), height()) * 0.8 * 0.5)
|
||||
{
|
||||
emit requestContextMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
return QWidget::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void OnboardItem::enterEvent(QEvent *e)
|
||||
{
|
||||
e->accept();
|
||||
m_hover = true;
|
||||
}
|
||||
|
||||
void OnboardItem::leaveEvent(QEvent *e)
|
||||
{
|
||||
e->accept();
|
||||
m_hover = false;
|
||||
}
|
||||
|
||||
const QPixmap OnboardItem::loadSvg(const QString &fileName, const QSize &size) const
|
||||
{
|
||||
const auto ratio = qApp->devicePixelRatio();
|
||||
|
@ -33,21 +33,14 @@ class OnboardItem : public QWidget
|
||||
public:
|
||||
explicit OnboardItem(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void requestContextMenu() const;
|
||||
|
||||
protected:
|
||||
QSize sizeHint() const;
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void enterEvent(QEvent *e);
|
||||
void leaveEvent(QEvent *e);
|
||||
|
||||
private:
|
||||
const QPixmap loadSvg(const QString &fileName, const QSize &size) const;
|
||||
|
||||
private:
|
||||
bool m_hover;
|
||||
Dock::DisplayMode m_displayMode;
|
||||
};
|
||||
|
||||
|
@ -151,11 +151,6 @@ void OnboardPlugin::setSortKey(const QString &itemKey, const int order)
|
||||
m_proxyInter->saveValue(this, key, order);
|
||||
}
|
||||
|
||||
void OnboardPlugin::requestContextMenu()
|
||||
{
|
||||
m_proxyInter->requestContextMenu(this, pluginName());
|
||||
}
|
||||
|
||||
void OnboardPlugin::loadPlugin()
|
||||
{
|
||||
if (m_pluginLoaded) {
|
||||
@ -167,8 +162,6 @@ void OnboardPlugin::loadPlugin()
|
||||
|
||||
m_onboardItem = new OnboardItem;
|
||||
|
||||
connect(m_onboardItem, &OnboardItem::requestContextMenu, this, &OnboardPlugin::requestContextMenu);
|
||||
|
||||
m_proxyInter->itemAdded(this, pluginName());
|
||||
displayModeChanged(displayMode());
|
||||
}
|
||||
|
@ -56,7 +56,6 @@ public:
|
||||
void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
void requestContextMenu();
|
||||
void loadPlugin();
|
||||
|
||||
private:
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"api": "1.1"
|
||||
"api": "1.1.1"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"api": "1.1",
|
||||
"api": "1.1.1",
|
||||
"depends-daemon-dbus-service": "com.deepin.daemon.Power"
|
||||
}
|
||||
|
@ -181,11 +181,6 @@ void PowerPlugin::updateBatteryVisible()
|
||||
m_proxyInter->itemAdded(this, POWER_KEY);
|
||||
}
|
||||
|
||||
void PowerPlugin::requestContextMenu(const QString &itemKey)
|
||||
{
|
||||
m_proxyInter->requestContextMenu(this, itemKey);
|
||||
}
|
||||
|
||||
void PowerPlugin::loadPlugin()
|
||||
{
|
||||
if (m_pluginLoaded) {
|
||||
@ -199,7 +194,6 @@ void PowerPlugin::loadPlugin()
|
||||
m_powerInter = new DBusPower(this);
|
||||
|
||||
connect(m_powerInter, &DBusPower::BatteryPercentageChanged, this, &PowerPlugin::updateBatteryVisible);
|
||||
connect(m_powerStatusWidget, &PowerStatusWidget::requestContextMenu, this, &PowerPlugin::requestContextMenu);
|
||||
|
||||
updateBatteryVisible();
|
||||
}
|
||||
|
@ -58,7 +58,6 @@ public:
|
||||
|
||||
private:
|
||||
void updateBatteryVisible();
|
||||
void requestContextMenu(const QString &itemKey);
|
||||
void loadPlugin();
|
||||
|
||||
private:
|
||||
|
@ -60,21 +60,6 @@ void PowerStatusWidget::paintEvent(QPaintEvent *e)
|
||||
painter.drawPixmap(rf.center() - rfp.center() / ratio, icon);
|
||||
}
|
||||
|
||||
void PowerStatusWidget::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->button() == Qt::LeftButton)
|
||||
return QWidget::mousePressEvent(e);
|
||||
|
||||
const QPoint p(e->pos() - rect().center());
|
||||
if (p.manhattanLength() < std::min(width(), height()) * 0.8 * 0.5)
|
||||
{
|
||||
emit requestContextMenu(POWER_KEY);
|
||||
return;
|
||||
}
|
||||
|
||||
return QWidget::mousePressEvent(e);
|
||||
}
|
||||
|
||||
QPixmap PowerStatusWidget::getBatteryIcon()
|
||||
{
|
||||
const BatteryPercentageMap data = m_powerInter->batteryPercentage();
|
||||
|
@ -43,7 +43,6 @@ signals:
|
||||
protected:
|
||||
QSize sizeHint() const;
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
|
||||
private:
|
||||
QPixmap getBatteryIcon();
|
||||
|
@ -28,8 +28,7 @@
|
||||
#include <QIcon>
|
||||
|
||||
PluginWidget::PluginWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
m_hover(false)
|
||||
: QWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
@ -60,33 +59,6 @@ void PluginWidget::paintEvent(QPaintEvent *e)
|
||||
painter.drawPixmap(rect().center() - pixmap.rect().center() / qApp->devicePixelRatio(), pixmap);
|
||||
}
|
||||
|
||||
void PluginWidget::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->button() != Qt::RightButton)
|
||||
return QWidget::mousePressEvent(e);
|
||||
|
||||
const QPoint p(e->pos() - rect().center());
|
||||
if (p.manhattanLength() < std::min(width(), height()) * 0.8 * 0.5)
|
||||
{
|
||||
emit requestContextMenu(QString("shutdown"));
|
||||
return;
|
||||
}
|
||||
|
||||
return QWidget::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void PluginWidget::enterEvent(QEvent *e)
|
||||
{
|
||||
e->accept();
|
||||
m_hover = true;
|
||||
}
|
||||
|
||||
void PluginWidget::leaveEvent(QEvent *e)
|
||||
{
|
||||
e->accept();
|
||||
m_hover = false;
|
||||
}
|
||||
|
||||
const QPixmap PluginWidget::loadSvg(const QString &fileName, const QSize &size) const
|
||||
{
|
||||
const auto ratio = qApp->devicePixelRatio();
|
||||
|
@ -33,21 +33,14 @@ class PluginWidget : public QWidget
|
||||
public:
|
||||
explicit PluginWidget(QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
void requestContextMenu(const QString &itemKey) const;
|
||||
|
||||
protected:
|
||||
QSize sizeHint() const;
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void enterEvent(QEvent *e);
|
||||
void leaveEvent(QEvent *e);
|
||||
|
||||
private:
|
||||
const QPixmap loadSvg(const QString &fileName, const QSize &size) const;
|
||||
|
||||
private:
|
||||
bool m_hover;
|
||||
Dock::DisplayMode m_displayMode;
|
||||
};
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"api": "1.1"
|
||||
"api": "1.1.1"
|
||||
}
|
||||
|
@ -208,11 +208,6 @@ void ShutdownPlugin::setSortKey(const QString &itemKey, const int order)
|
||||
m_proxyInter->saveValue(this, key, order);
|
||||
}
|
||||
|
||||
void ShutdownPlugin::requestContextMenu(const QString &itemKey)
|
||||
{
|
||||
m_proxyInter->requestContextMenu(this, itemKey);
|
||||
}
|
||||
|
||||
void ShutdownPlugin::loadPlugin()
|
||||
{
|
||||
if (m_pluginLoaded) {
|
||||
@ -224,8 +219,6 @@ void ShutdownPlugin::loadPlugin()
|
||||
|
||||
m_shutdownWidget = new PluginWidget;
|
||||
|
||||
connect(m_shutdownWidget, &PluginWidget::requestContextMenu, this, &ShutdownPlugin::requestContextMenu);
|
||||
|
||||
m_proxyInter->itemAdded(this, pluginName());
|
||||
displayModeChanged(displayMode());
|
||||
}
|
||||
|
@ -56,7 +56,6 @@ public:
|
||||
void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
void requestContextMenu(const QString &itemKey);
|
||||
void loadPlugin();
|
||||
|
||||
private:
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"api": "1.1",
|
||||
"api": "1.1.1",
|
||||
"depends-daemon-dbus-service": "com.deepin.daemon.Audio"
|
||||
}
|
||||
|
@ -123,22 +123,6 @@ void SoundItem::resizeEvent(QResizeEvent *e)
|
||||
refreshIcon();
|
||||
}
|
||||
|
||||
void SoundItem::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->button() != Qt::RightButton)
|
||||
return QWidget::mousePressEvent(e);
|
||||
|
||||
const QPoint p(e->pos() - rect().center());
|
||||
if (p.manhattanLength() < std::min(width(), height()) * 0.8 * 0.5)
|
||||
{
|
||||
e->accept();
|
||||
emit requestContextMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
return QWidget::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void SoundItem::wheelEvent(QWheelEvent *e)
|
||||
{
|
||||
QWheelEvent *event = new QWheelEvent(e->pos(), e->delta(), e->buttons(), e->modifiers());
|
||||
|
@ -51,7 +51,6 @@ signals:
|
||||
protected:
|
||||
QSize sizeHint() const;
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void wheelEvent(QWheelEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
|
@ -45,7 +45,6 @@ void SoundPlugin::init(PluginProxyInterface *proxyInter)
|
||||
m_proxyInter = proxyInter;
|
||||
|
||||
m_soundItem = new SoundItem;
|
||||
connect(m_soundItem, &SoundItem::requestContextMenu, [this] { m_proxyInter->requestContextMenu(this, SOUND_KEY); });
|
||||
|
||||
if (!pluginIsDisable())
|
||||
m_proxyInter->itemAdded(this, SOUND_KEY);
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"api": "1.1"
|
||||
"api": "1.1.1"
|
||||
}
|
||||
|
@ -38,8 +38,6 @@ TrashPlugin::TrashPlugin(QObject *parent)
|
||||
m_tipsLabel->setObjectName("trash");
|
||||
m_tipsLabel->setStyleSheet("color:white;"
|
||||
"padding: 0 3px;");
|
||||
|
||||
connect(m_trashWidget, &TrashWidget::requestContextMenu, this, &TrashPlugin::showContextMenu);
|
||||
}
|
||||
|
||||
const QString TrashPlugin::pluginName() const
|
||||
@ -145,8 +143,3 @@ void TrashPlugin::displayModeChanged(const Dock::DisplayMode displayMode)
|
||||
else
|
||||
m_proxyInter->itemRemoved(this, pluginName());
|
||||
}
|
||||
|
||||
void TrashPlugin::showContextMenu()
|
||||
{
|
||||
m_proxyInter->requestContextMenu(this, pluginName());
|
||||
}
|
||||
|
@ -57,9 +57,6 @@ public:
|
||||
void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE;
|
||||
void displayModeChanged(const Dock::DisplayMode displayMode) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
void showContextMenu();
|
||||
|
||||
private:
|
||||
TrashWidget *m_trashWidget;
|
||||
QLabel *m_tipsLabel;
|
||||
|
@ -180,15 +180,6 @@ void TrashWidget::resizeEvent(QResizeEvent *e)
|
||||
updateIcon();
|
||||
}
|
||||
|
||||
void TrashWidget::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
const QPoint dis = e->pos() - rect().center();
|
||||
if (e->button() != Qt::RightButton || dis.manhattanLength() > std::min(width(), height()) * 0.8 * 0.5)
|
||||
return QWidget::mousePressEvent(e);
|
||||
|
||||
emit requestContextMenu();
|
||||
}
|
||||
|
||||
void TrashWidget::updateIcon()
|
||||
{
|
||||
const Dock::DisplayMode displayMode = qApp->property(PROP_DISPLAY_MODE).value<Dock::DisplayMode>();
|
||||
|
@ -58,7 +58,6 @@ protected:
|
||||
void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE;
|
||||
void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
|
||||
void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
|
||||
void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
|
||||
|
||||
private slots:
|
||||
void removeApp(const QString &appKey);
|
||||
|
@ -63,6 +63,8 @@ void AbstractTrayWidget::mouseReleaseEvent(QMouseEvent *e)
|
||||
m_lastMouseReleaseData.second = e->button();
|
||||
|
||||
m_handleMouseReleaseTimer->start();
|
||||
|
||||
QWidget::mouseReleaseEvent(e);
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,7 +44,6 @@ FashionTrayWidgetWrapper::FashionTrayWidgetWrapper(const QString &itemKey, Abstr
|
||||
setAcceptDrops(true);
|
||||
|
||||
m_absTrayWidget->setVisible(true);
|
||||
m_absTrayWidget->installEventFilter(this);
|
||||
|
||||
m_layout->setSpacing(0);
|
||||
m_layout->setMargin(0);
|
||||
@ -93,19 +92,6 @@ void FashionTrayWidgetWrapper::paintEvent(QPaintEvent *event)
|
||||
painter.fillPath(path, color);
|
||||
}
|
||||
|
||||
bool FashionTrayWidgetWrapper::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (watched == m_absTrayWidget) {
|
||||
if (event->type() == QEvent::Type::MouseButtonPress) {
|
||||
mousePressEvent(static_cast<QMouseEvent *>(event));
|
||||
} else if (event->type() == QEvent::Type::MouseButtonRelease) {
|
||||
mouseReleaseEvent(static_cast<QMouseEvent *>(event));
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void FashionTrayWidgetWrapper::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::MouseButton::LeftButton) {
|
||||
|
@ -49,7 +49,6 @@ Q_SIGNALS:
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
||||
bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE;
|
||||
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||
void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||
|
@ -194,6 +194,15 @@ void SystemTrayItem::mousePressEvent(QMouseEvent *event)
|
||||
m_popupTipsDelayTimer->stop();
|
||||
hideNonModel();
|
||||
|
||||
if (event->button() == Qt::RightButton) {
|
||||
const QPoint p(event->pos() - rect().center());
|
||||
if (p.manhattanLength() < std::min(width(), height()) * 0.8 * 0.5)
|
||||
{
|
||||
showContextMenu();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AbstractTrayWidget::mousePressEvent(event);
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,9 @@ public:
|
||||
void detachPluginWidget();
|
||||
void showContextMenu();
|
||||
|
||||
void showPopupApplet(QWidget * const applet);
|
||||
void hidePopup();
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event) Q_DECL_OVERRIDE;
|
||||
void enterEvent(QEvent *event) Q_DECL_OVERRIDE;
|
||||
@ -68,10 +71,8 @@ protected:
|
||||
const QPoint popupMarkPoint() const;
|
||||
const QPoint topleftPoint() const;
|
||||
|
||||
void hidePopup();
|
||||
void hideNonModel();
|
||||
void popupWindowAccept();
|
||||
void showPopupApplet(QWidget * const applet);
|
||||
|
||||
virtual void showPopupWindow(QWidget * const content, const bool model = false);
|
||||
virtual void showHoverTips();
|
||||
|
@ -26,8 +26,6 @@
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
|
||||
#define API_VERSION "1.1"
|
||||
|
||||
SystemTraysController::SystemTraysController(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_dbusDaemonInterface(QDBusConnection::sessionBus().interface())
|
||||
@ -83,14 +81,6 @@ void SystemTraysController::itemRemoved(PluginsItemInterface * const itemInter,
|
||||
item->deleteLater();
|
||||
}
|
||||
|
||||
void SystemTraysController::requestContextMenu(PluginsItemInterface * const itemInter, const QString &itemKey)
|
||||
{
|
||||
SystemTrayItem *item = pluginItemAt(itemInter, itemKey);
|
||||
Q_ASSERT(item);
|
||||
|
||||
item->showContextMenu();
|
||||
}
|
||||
|
||||
void SystemTraysController::requestWindowAutoHide(PluginsItemInterface * const itemInter, const QString &itemKey, const bool autoHide)
|
||||
{
|
||||
SystemTrayItem *item = pluginItemAt(itemInter, itemKey);
|
||||
@ -107,6 +97,18 @@ void SystemTraysController::requestRefreshWindowVisible(PluginsItemInterface * c
|
||||
Q_EMIT item->requestRefershWindowVisible();
|
||||
}
|
||||
|
||||
void SystemTraysController::requestSetAppletVisible(PluginsItemInterface * const itemInter, const QString &itemKey, const bool visible)
|
||||
{
|
||||
SystemTrayItem *item = pluginItemAt(itemInter, itemKey);
|
||||
Q_ASSERT(item);
|
||||
|
||||
if (visible) {
|
||||
item->showPopupApplet(itemInter->itemPopupApplet(itemKey));
|
||||
} else {
|
||||
item->hidePopup();
|
||||
}
|
||||
}
|
||||
|
||||
void SystemTraysController::startLoader()
|
||||
{
|
||||
SystemTrayLoader *loader = new SystemTrayLoader(this);
|
||||
@ -139,9 +141,9 @@ void SystemTraysController::loadPlugin(const QString &pluginFile)
|
||||
{
|
||||
QPluginLoader *pluginLoader = new QPluginLoader(pluginFile);
|
||||
const auto meta = pluginLoader->metaData().value("MetaData").toObject();
|
||||
if (!meta.contains("api") || meta["api"].toString() != API_VERSION)
|
||||
if (!meta.contains("api") || meta["api"].toString() != DOCK_PLUGIN_API_VERSION)
|
||||
{
|
||||
qWarning() << "plugin api version not matched!" << pluginFile;
|
||||
qWarning() << "plugin api version not matched! expect version:" << DOCK_PLUGIN_API_VERSION << pluginFile;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -42,9 +42,9 @@ public:
|
||||
void itemAdded(PluginsItemInterface * const itemInter, const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void itemUpdate(PluginsItemInterface * const itemInter, const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void itemRemoved(PluginsItemInterface * const itemInter, const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void requestContextMenu(PluginsItemInterface * const itemInter, const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void requestWindowAutoHide(PluginsItemInterface * const itemInter, const QString &itemKey, const bool autoHide) Q_DECL_OVERRIDE;
|
||||
void requestRefreshWindowVisible(PluginsItemInterface * const itemInter, const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void requestSetAppletVisible(PluginsItemInterface * const itemInter, const QString &itemKey, const bool visible) Q_DECL_OVERRIDE;
|
||||
void saveValue(PluginsItemInterface *const itemInter, const QString &key, const QVariant &value) Q_DECL_OVERRIDE;
|
||||
const QVariant getValue(PluginsItemInterface *const itemInter, const QString &key, const QVariant& failback = QVariant()) Q_DECL_OVERRIDE;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"api": "1.1",
|
||||
"api": "1.1.1",
|
||||
"depends-daemon-dbus-service": "com.deepin.dde.TrayManager"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user