diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index b7314426d..b98574c6c 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -12,4 +12,3 @@ add_subdirectory("onboard") add_subdirectory("overlay-warning") add_subdirectory("show-desktop") add_subdirectory("multitasking") -add_subdirectory("notifications") diff --git a/plugins/notifications/CMakeLists.txt b/plugins/notifications/CMakeLists.txt deleted file mode 100644 index 954b8b814..000000000 --- a/plugins/notifications/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ - -set(PLUGIN_NAME "notifications") - -project(${PLUGIN_NAME}) - -# Sources files -file(GLOB_RECURSE SRCS "*.h" "*.cpp" "../../widgets/*.h" "../../widgets/*.cpp") - -find_package(PkgConfig REQUIRED) -find_package(Qt5Widgets REQUIRED) -find_package(Qt5Svg REQUIRED) -find_package(Qt5DBus REQUIRED) -find_package(DtkWidget REQUIRED) - -if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64") - add_definitions("-DDISABLE_POWER_OPTIONS") -endif() - -add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN") -add_library(${PLUGIN_NAME} SHARED ${SRCS} resources.qrc) -set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../system-trays) -target_include_directories(${PLUGIN_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS} - ${Qt5DBus_INCLUDE_DIRS} - ../../interfaces) -target_link_libraries(${PLUGIN_NAME} PRIVATE - ${DtkWidget_LIBRARIES} - ${Qt5Widgets_LIBRARIES} - ${Qt5Svg_LIBRARIES} - ${Qt5DBus_LIBRARIES} -) - -install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins/system-trays) diff --git a/plugins/notifications/notifications.json b/plugins/notifications/notifications.json deleted file mode 100644 index ad498eeb3..000000000 --- a/plugins/notifications/notifications.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "api": "1.1.1" -} diff --git a/plugins/notifications/notificationsplugin.cpp b/plugins/notifications/notificationsplugin.cpp deleted file mode 100644 index 937a024cf..000000000 --- a/plugins/notifications/notificationsplugin.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: sbw - * - * Maintainer: sbw - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "notificationsplugin.h" - -#include -#include -#include - -#define PLUGIN_STATE_KEY "enable" - -NotificationsPlugin::NotificationsPlugin(QObject *parent) - : QObject(parent) - , m_pluginLoaded(false) - , m_tipsLabel(new TipsWidget) -{ - m_tipsLabel->setVisible(false); - getNotifyInterface(); -} - -QDBusInterface *NotificationsPlugin::getNotifyInterface() -{ - if (!m_interface && QDBusConnection::sessionBus().interface()->isServiceRegistered("com.deepin.dde.Notification")) - m_interface = new QDBusInterface("com.deepin.dde.Notification", "/com/deepin/dde/Notification", "com.deepin.dde.Notification"); - - return m_interface; -} - -const QString NotificationsPlugin::pluginName() const -{ - return "notifications"; -} - -const QString NotificationsPlugin::pluginDisplayName() const -{ - return tr("Notifications"); -} - -QWidget *NotificationsPlugin::itemWidget(const QString &itemKey) -{ - Q_UNUSED(itemKey); - - return m_itemWidget; -} - -QWidget *NotificationsPlugin::itemTipsWidget(const QString &itemKey) -{ - Q_UNUSED(itemKey); - - if (!getNotifyInterface()) - return nullptr; - - QDBusMessage msg = m_interface->call("recordCount"); - uint recordCount = msg.arguments()[0].toUInt(); - - if (recordCount) - m_tipsLabel->setText(QString(tr("%1 Notifications")).arg(recordCount)); - else - m_tipsLabel->setText(tr("Notifications")); - - return m_tipsLabel; -} - -void NotificationsPlugin::init(PluginProxyInterface *proxyInter) -{ - m_proxyInter = proxyInter; - - if (!pluginIsDisable()) { - loadPlugin(); - } -} - -void NotificationsPlugin::pluginStateSwitched() -{ - m_proxyInter->saveValue(this, PLUGIN_STATE_KEY, !m_proxyInter->getValue(this, PLUGIN_STATE_KEY, true).toBool()); - - refreshPluginItemsVisible(); -} - -bool NotificationsPlugin::pluginIsDisable() -{ - return !m_proxyInter->getValue(this, PLUGIN_STATE_KEY, true).toBool(); -} - -const QString NotificationsPlugin::itemCommand(const QString &itemKey) -{ - Q_UNUSED(itemKey); - - if (getNotifyInterface()) - m_interface->call("Toggle"); - - return ""; -} - -void NotificationsPlugin::displayModeChanged(const Dock::DisplayMode displayMode) -{ - Q_UNUSED(displayMode); - - if (!pluginIsDisable()) { - m_itemWidget->update(); - } -} - -int NotificationsPlugin::itemSortKey(const QString &itemKey) -{ - Dock::DisplayMode mode = displayMode(); - const QString key = QString("pos_%1_%2").arg(itemKey).arg(mode); - - if (mode == Dock::DisplayMode::Fashion) { - return m_proxyInter->getValue(this, key, 2).toInt(); - } else { - return m_proxyInter->getValue(this, key, 5).toInt(); - } -} - -void NotificationsPlugin::setSortKey(const QString &itemKey, const int order) -{ - const QString key = QString("pos_%1_%2").arg(itemKey).arg(displayMode()); - m_proxyInter->saveValue(this, key, order); -} - -void NotificationsPlugin::pluginSettingsChanged() -{ - refreshPluginItemsVisible(); -} - -void NotificationsPlugin::loadPlugin() -{ - if (m_pluginLoaded) - return; - - m_pluginLoaded = true; - - m_itemWidget = new NotificationsWidget; - - m_proxyInter->itemAdded(this, pluginName()); - displayModeChanged(displayMode()); -} - -bool NotificationsPlugin::checkSwap() -{ - QFile file("/proc/swaps"); - if (file.open(QIODevice::Text | QIODevice::ReadOnly)) { - const QString &body = file.readAll(); - file.close(); - QRegularExpression re("\\spartition\\s"); - QRegularExpressionMatch match = re.match(body); - return match.hasMatch(); - } - - return false; -} - -void NotificationsPlugin::refreshPluginItemsVisible() -{ - if (pluginIsDisable()) { - m_proxyInter->itemRemoved(this, pluginName()); - } else { - if (!m_pluginLoaded) { - loadPlugin(); - return; - } - m_proxyInter->itemAdded(this, pluginName()); - } -} diff --git a/plugins/notifications/notificationsplugin.h b/plugins/notifications/notificationsplugin.h deleted file mode 100644 index 1b3c24103..000000000 --- a/plugins/notifications/notificationsplugin.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: sbw - * - * Maintainer: sbw - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef NOTIFITIONPLUGIN_H -#define NOTIFITIONPLUGIN_H - -#include "pluginsiteminterface.h" -#include "notificationswidget.h" -#include "../widgets/tipswidget.h" - -#include - -class NotificationsPlugin : public QObject, PluginsItemInterface -{ - Q_OBJECT - Q_INTERFACES(PluginsItemInterface) - Q_PLUGIN_METADATA(IID "com.deepin.dock.PluginsItemInterface" FILE "notifications.json") - -public: - explicit NotificationsPlugin(QObject *parent = 0); - - const QString pluginName() const override; - const QString pluginDisplayName() const override; - void init(PluginProxyInterface *proxyInter) override; - void pluginStateSwitched() override; - bool pluginIsAllowDisable() override { return true; } - bool pluginIsDisable() override; - QWidget *itemWidget(const QString &itemKey) override; - QWidget *itemTipsWidget(const QString &itemKey) override; - const QString itemCommand(const QString &itemKey) override; - void displayModeChanged(const Dock::DisplayMode displayMode) override; - int itemSortKey(const QString &itemKey) Q_DECL_OVERRIDE; - void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE; - void pluginSettingsChanged() override; - QDBusInterface *getNotifyInterface(); - -private: - void loadPlugin(); - bool checkSwap(); - void refreshPluginItemsVisible(); - -private: - bool m_pluginLoaded; - QDBusInterface *m_interface = nullptr; - - NotificationsWidget *m_itemWidget; - TipsWidget *m_tipsLabel; -}; - -#endif // NOTIFITIONPLUGIN_H diff --git a/plugins/notifications/notificationswidget.cpp b/plugins/notifications/notificationswidget.cpp deleted file mode 100644 index fbf876eb3..000000000 --- a/plugins/notifications/notificationswidget.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: sbw - * - * Maintainer: sbw - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "notificationswidget.h" - -#include -#include -#include -#include -#include - -#include -#include - -DWIDGET_USE_NAMESPACE; - -NotificationsWidget::NotificationsWidget(QWidget *parent) - : QWidget(parent) -{ - setMouseTracking(true); - setMinimumSize(PLUGIN_BACKGROUND_MIN_SIZE, PLUGIN_BACKGROUND_MIN_SIZE); - - connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, [ = ] { - update(); - }); -} - -void NotificationsWidget::paintEvent(QPaintEvent *e) -{ - Q_UNUSED(e); - - QString iconName = "notification"; - int iconSize = PLUGIN_ICON_MAX_SIZE; - if (height() <= PLUGIN_BACKGROUND_MIN_SIZE && DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) - iconName.append(PLUGIN_MIN_ICON_NAME); - - QPainter painter(this); - const auto ratio = devicePixelRatioF(); - - QPixmap pixmap = QIcon::fromTheme(iconName, QIcon::fromTheme(QString(":/icons/resources/icons/%1").arg(iconName))).pixmap(QSize(iconSize, iconSize) * ratio); - pixmap.setDevicePixelRatio(ratio); - - const QRectF &rf = QRectF(rect()); - const QRectF &rfp = QRectF(pixmap.rect()); - - painter.drawPixmap(rf.center() - rfp.center() / ratio, pixmap); -} - -void NotificationsWidget::resizeEvent(QResizeEvent *event) -{ - QWidget::resizeEvent(event); -} diff --git a/plugins/notifications/notificationswidget.h b/plugins/notifications/notificationswidget.h deleted file mode 100644 index df74806d4..000000000 --- a/plugins/notifications/notificationswidget.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: sbw - * - * Maintainer: sbw - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef NOTIFICATIONSWIDGET_H -#define NOTIFICATIONSWIDGET_H - -#include "constants.h" - -#include -#include - -class NotificationsWidget: public QWidget -{ - Q_OBJECT - -public: - explicit NotificationsWidget(QWidget *parent = 0); - -protected: - void paintEvent(QPaintEvent *e) override; - void resizeEvent(QResizeEvent *event) override; -}; - -#endif // NOTIFICATIONSWIDGET_H diff --git a/plugins/notifications/resources.qrc b/plugins/notifications/resources.qrc deleted file mode 100644 index 4f9274604..000000000 --- a/plugins/notifications/resources.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - resources/icons/notification-dark.svg - resources/icons/notification.svg - - diff --git a/plugins/notifications/resources/icons/notification-dark.svg b/plugins/notifications/resources/icons/notification-dark.svg deleted file mode 100644 index af1c5d3dc..000000000 --- a/plugins/notifications/resources/icons/notification-dark.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/plugins/notifications/resources/icons/notification.svg b/plugins/notifications/resources/icons/notification.svg deleted file mode 100644 index d4d284697..000000000 --- a/plugins/notifications/resources/icons/notification.svg +++ /dev/null @@ -1,3 +0,0 @@ - - -