diff --git a/frame/controller/dockitemmanager.cpp b/frame/controller/dockitemmanager.cpp index 56e546a83..ad12b601c 100644 --- a/frame/controller/dockitemmanager.cpp +++ b/frame/controller/dockitemmanager.cpp @@ -333,42 +333,6 @@ void DockItemManager::reloadAppItems() appItemAdded(path, -1); } -// 不同的模式下,插件顺序不一样 -void DockItemManager::sortPluginItems() -{ - int firstPluginIndex = -1; - for (int i(0); i != m_itemList.size(); ++i) { - if (m_itemList[i]->itemType() == DockItem::Plugins) { - firstPluginIndex = i; - break; - } - } - - if (firstPluginIndex == -1) - return; - - std::sort(m_itemList.begin() + firstPluginIndex, m_itemList.end(), [](QPointer a, QPointer b) -> bool { - PluginsItem *pa = static_cast(a.data()); - PluginsItem *pb = static_cast(b.data()); - - const int aKey = pa->itemSortKey(); - const int bKey = pb->itemSortKey(); - - if (bKey == -1) - return true; - if (aKey == -1) - return false; - - return aKey < bKey; - }); - - // reset order - for (int i(firstPluginIndex); i != m_itemList.size(); ++i) { - emit itemRemoved(m_itemList[i]); - emit itemInserted(-1, m_itemList[i]); - } -} - void DockItemManager::manageItem(DockItem *item) { connect(item, &DockItem::requestRefreshWindowVisible, this, &DockItemManager::requestRefershWindowVisible, Qt::UniqueConnection); diff --git a/frame/controller/dockitemmanager.h b/frame/controller/dockitemmanager.h index 15e3735c9..2358f4ca3 100644 --- a/frame/controller/dockitemmanager.h +++ b/frame/controller/dockitemmanager.h @@ -61,7 +61,6 @@ signals: public slots: void refreshItemsIcon(); - void sortPluginItems(); void itemMoved(DockItem *const sourceItem, DockItem *const targetItem); void itemAdded(const QString &appDesktop, int idx); diff --git a/frame/dbus/dbusdockadaptors.h b/frame/dbus/dbusdockadaptors.h index 255751f66..fcb136cdb 100644 --- a/frame/dbus/dbusdockadaptors.h +++ b/frame/dbus/dbusdockadaptors.h @@ -44,7 +44,7 @@ class DBusDockAdaptors: public QDBusAbstractAdaptor "") public: - DBusDockAdaptors(MainWindow *parent); + explicit DBusDockAdaptors(MainWindow *parent); virtual ~DBusDockAdaptors(); MainWindow *parent() const; diff --git a/frame/item/appitem.cpp b/frame/item/appitem.cpp index 36d03424c..1b0923c54 100644 --- a/frame/item/appitem.cpp +++ b/frame/item/appitem.cpp @@ -22,7 +22,6 @@ #include "appitem.h" #include "themeappicon.h" -#include "imagefactory.h" #include "xcb_misc.h" #include "appswingeffectbuilder.h" #include "appspreviewprovider.h" @@ -555,10 +554,11 @@ void AppItem::startDrag() bool AppItem::hasAttention() const { - for (const auto &info : m_windowInfos) - if (info.attention) - return true; - return false; + auto it = std::find_if(m_windowInfos.constBegin(), m_windowInfos.constEnd(), [ = ] (const auto &info) { + return info.attention; + }); + + return (it != m_windowInfos.end()); } QPoint AppItem::appIconPosition() const diff --git a/frame/item/components/appdragwidget.cpp b/frame/item/components/appdragwidget.cpp index a8ecaed7e..9b48b9de5 100644 --- a/frame/item/components/appdragwidget.cpp +++ b/frame/item/components/appdragwidget.cpp @@ -50,6 +50,9 @@ public: } void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) override { + Q_UNUSED(option); + Q_UNUSED(widget); + Q_ASSERT(!m_appPixmap.isNull()); painter->drawPixmap(QPoint(0, 0), m_appPixmap); @@ -373,7 +376,6 @@ void AppDragWidget::enterEvent(QEvent *event) void AppDragWidget::showRemoveTips() { - bool model = true; Dock::Position pos = Dock::Position::Bottom; DockPopupWindow *popup = m_popupWindow; @@ -393,9 +395,9 @@ void AppDragWidget::showRemoveTips() const QPoint p = popupMarkPoint(pos); if (!popup->isVisible()) - QMetaObject::invokeMethod(popup, "show", Qt::QueuedConnection, Q_ARG(QPoint, p), Q_ARG(bool, model)); + QMetaObject::invokeMethod(popup, "show", Qt::QueuedConnection, Q_ARG(QPoint, p), Q_ARG(bool, true)); else - popup->show(p, model); + popup->show(p, true); m_object->setOpacity(0.5); m_animOpacity->setStartValue(0.5); diff --git a/frame/item/components/hoverhighlighteffect.cpp b/frame/item/components/hoverhighlighteffect.cpp deleted file mode 100644 index 6b7e8eda4..000000000 --- a/frame/item/components/hoverhighlighteffect.cpp +++ /dev/null @@ -1,46 +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 "hoverhighlighteffect.h" -#include "imagefactory.h" - -#include -#include - -HoverHighlightEffect::HoverHighlightEffect(QObject *parent) - : QGraphicsEffect(parent) - - , m_highlighting(false) -{ - -} - -void HoverHighlightEffect::draw(QPainter *painter) -{ - const QPixmap pix = sourcePixmap(Qt::DeviceCoordinates); - - if (m_highlighting) - { - painter->drawPixmap(0, 0, ImageFactory::lighterEffect(pix)); - } else { - painter->drawPixmap(0, 0, pix); - } -} diff --git a/frame/item/components/hoverhighlighteffect.h b/frame/item/components/hoverhighlighteffect.h deleted file mode 100644 index 0e50fd2e7..000000000 --- a/frame/item/components/hoverhighlighteffect.h +++ /dev/null @@ -1,43 +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 HOVERHIGHLIGHTEFFECT_H -#define HOVERHIGHLIGHTEFFECT_H - -#include - -class HoverHighlightEffect : public QGraphicsEffect -{ - Q_OBJECT - -public: - explicit HoverHighlightEffect(QObject *parent = nullptr); - - void setHighlighting(const bool highlighting) { m_highlighting = highlighting; } - -protected: - void draw(QPainter *painter); - -private: - bool m_highlighting; -}; - -#endif // HOVERHIGHLIGHTEFFECT_H diff --git a/frame/item/dockitem.cpp b/frame/item/dockitem.cpp index 47e5816ed..7d401742e 100644 --- a/frame/item/dockitem.cpp +++ b/frame/item/dockitem.cpp @@ -20,7 +20,6 @@ */ #include "dockitem.h" -#include "hoverhighlighteffect.h" #include "pluginsitem.h" #include @@ -41,8 +40,6 @@ DockItem::DockItem(QWidget *parent) , m_popupShown(false) , m_tapAndHold(false) , m_draging(false) - //FIXME: 可能是qt的bug,概率性导致崩溃,待修复 -// , m_hoverEffect(new HoverHighlightEffect(this)) , m_popupTipsDelayTimer(new QTimer(this)) , m_popupAdjustDelayTimer(new QTimer(this)) diff --git a/frame/item/dockitem.h b/frame/item/dockitem.h index 8782b2188..cb8af344e 100644 --- a/frame/item/dockitem.h +++ b/frame/item/dockitem.h @@ -24,7 +24,6 @@ #include "constants.h" #include "dockpopupwindow.h" -#include "hoverhighlighteffect.h" #include #include @@ -114,8 +113,6 @@ protected: QMenu m_contextMenu; QPointer m_lastPopupWidget; - //FIXME: 可能是qt的bug,概率性导致崩溃,待修复 -// QPointer m_hoverEffect; QTimer *m_popupTipsDelayTimer; QTimer *m_popupAdjustDelayTimer; diff --git a/frame/item/launcheritem.cpp b/frame/item/launcheritem.cpp index eed4ebfba..6a5429cbf 100644 --- a/frame/item/launcheritem.cpp +++ b/frame/item/launcheritem.cpp @@ -21,7 +21,6 @@ #include "launcheritem.h" #include "themeappicon.h" -#include "imagefactory.h" #include "utils.h" #include diff --git a/frame/item/pluginsitem.cpp b/frame/item/pluginsitem.cpp index 8637f649b..b94d188eb 100644 --- a/frame/item/pluginsitem.cpp +++ b/frame/item/pluginsitem.cpp @@ -22,9 +22,7 @@ #include "constants.h" #include "pluginsitem.h" #include "pluginsiteminterface.h" - #include "utils.h" -#include "imagefactory.h" #include #include diff --git a/frame/main.cpp b/frame/main.cpp index 59f1ab2f2..7865f5462 100644 --- a/frame/main.cpp +++ b/frame/main.cpp @@ -91,10 +91,10 @@ bool IsSaveMode() // 创建默认配置文件,记录段时间内的崩溃次数 if (!QFile::exists(g_cfgPath)) { - QFile file(g_cfgPath); - if (!file.open(QIODevice::WriteOnly)) + QFile cfgFile(g_cfgPath); + if (!cfgFile.open(QIODevice::WriteOnly)) exit(0); - file.close(); + cfgFile.close(); } QSettings settings(g_cfgPath, QSettings::IniFormat); diff --git a/frame/util/abstractpluginscontroller.cpp b/frame/util/abstractpluginscontroller.cpp index a974b6521..7bf452b10 100644 --- a/frame/util/abstractpluginscontroller.cpp +++ b/frame/util/abstractpluginscontroller.cpp @@ -28,6 +28,7 @@ #include #include +#include static const QStringList CompatiblePluginApiList { "1.1.1", @@ -61,8 +62,7 @@ AbstractPluginsController::~AbstractPluginsController() void AbstractPluginsController::saveValue(PluginsItemInterface *const itemInter, const QString &key, const QVariant &value) { // is it necessary? -// refreshPluginSettings(); - int fixedPluginCount(0); // FixPlugin Counts + // refreshPluginSettings(); // save to local cache QJsonObject localObject = m_pluginSettingsObject.value(itemInter->pluginName()).toObject(); @@ -74,6 +74,7 @@ void AbstractPluginsController::saveValue(PluginsItemInterface *const itemInter, remoteObject.insert(itemInter->pluginName(), remoteObjectInter); if (itemInter->type() == PluginsItemInterface::Fixed && key == "enable" && !value.toBool()) { + int fixedPluginCount = 0; // 遍历FixPlugin插件个数 for (auto it(m_pluginsMap.begin()); it != m_pluginsMap.end();) { if (it.key()->type() == PluginsItemInterface::Fixed) { @@ -135,11 +136,11 @@ QObject *AbstractPluginsController::pluginItemAt(PluginsItemInterface *const ite PluginsItemInterface *AbstractPluginsController::pluginInterAt(const QString &itemKey) { - for (auto it = m_pluginsMap.constBegin(); it != m_pluginsMap.constEnd(); ++it) { - for (auto key : it.value().keys()) { - if (key == itemKey) { - return it.key(); - } + QMapIterator> it(m_pluginsMap); + while (it.hasNext()) { + it.next(); + if (it.value().keys().contains(itemKey)) { + return it.key(); } } @@ -147,12 +148,12 @@ PluginsItemInterface *AbstractPluginsController::pluginInterAt(const QString &it } PluginsItemInterface *AbstractPluginsController::pluginInterAt(QObject *destItem) -{ - for (auto it = m_pluginsMap.constBegin(); it != m_pluginsMap.constEnd(); ++it) { - for (auto item : it.value().values()) { - if (item == destItem) { - return it.key(); - } +{ + QMapIterator> it(m_pluginsMap); + while (it.hasNext()) { + it.next(); + if (it.value().values().contains(destItem)) { + return it.key(); } } @@ -163,11 +164,11 @@ void AbstractPluginsController::startLoader(PluginLoader *loader) { connect(loader, &PluginLoader::finished, loader, &PluginLoader::deleteLater, Qt::QueuedConnection); connect(loader, &PluginLoader::pluginFounded, this, [ = ](const QString &pluginFile){ - QPair pair; - pair.first = pluginFile; - pair.second = nullptr; - m_pluginLoadMap.insert(pair, false); - }); + QPair pair; + pair.first = pluginFile; + pair.second = nullptr; + m_pluginLoadMap.insert(pair, false); + }); connect(loader, &PluginLoader::pluginFounded, this, &AbstractPluginsController::loadPlugin, Qt::QueuedConnection); int delay = Utils::SettingValue("com.deepin.dde.dock", "/com/deepin/dde/dock/", "delay-plugins-time", 0).toInt(); @@ -200,9 +201,9 @@ void AbstractPluginsController::loadPlugin(const QString &pluginFile) bool pluginIsValid = true; if (pluginApi.isEmpty() || !CompatiblePluginApiList.contains(pluginApi)) { qDebug() << objectName() - << "plugin api version not matched! expect versions:" << CompatiblePluginApiList - << ", got version:" << pluginApi - << ", the plugin file is:" << pluginFile; + << "plugin api version not matched! expect versions:" << CompatiblePluginApiList + << ", got version:" << pluginApi + << ", the plugin file is:" << pluginFile; pluginIsValid = false; } @@ -240,18 +241,22 @@ void AbstractPluginsController::loadPlugin(const QString &pluginFile) } } - for (auto &pair: m_pluginLoadMap.keys()) { - if (pair.first == pluginFile) { - m_pluginLoadMap.remove(pair); - - QPair newPair; - newPair.first = pluginFile; - newPair.second = interface; - m_pluginLoadMap.insert(newPair, false); + QMapIterator, bool> it(m_pluginLoadMap); + while (it.hasNext()) { + it.next(); + if (it.key().first == pluginFile) { break; } } + if (it.hasNext()) { + m_pluginLoadMap.remove(it.key()); + QPair newPair; + newPair.first = pluginFile; + newPair.second = interface; + m_pluginLoadMap.insert(newPair, false); + } + // 保存 PluginLoader 对象指针 QMap interfaceData; interfaceData["pluginloader"] = pluginLoader; @@ -260,7 +265,7 @@ void AbstractPluginsController::loadPlugin(const QString &pluginFile) if (!dbusService.isEmpty() && !m_dbusDaemonInterface->isServiceRegistered(dbusService).value()) { qDebug() << objectName() << dbusService << "daemon has not started, waiting for signal"; connect(m_dbusDaemonInterface, &QDBusConnectionInterface::serviceOwnerChanged, this, - [ = ](const QString & name, const QString & oldOwner, const QString & newOwner) { + [ = ](const QString & name, const QString & oldOwner, const QString & newOwner) { Q_UNUSED(oldOwner); if (name == dbusService && !newOwner.isEmpty()) { qDebug() << objectName() << dbusService << "daemon started, init plugin and disconnect"; @@ -268,7 +273,7 @@ void AbstractPluginsController::loadPlugin(const QString &pluginFile) disconnect(m_dbusDaemonInterface); } } - ); + ); return; } diff --git a/frame/util/imagefactory.cpp b/frame/util/imagefactory.cpp deleted file mode 100644 index 434a00cce..000000000 --- a/frame/util/imagefactory.cpp +++ /dev/null @@ -1,65 +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 "imagefactory.h" - -#include -#include - -ImageFactory::ImageFactory(QObject *parent) - : QObject(parent) -{ - -} - -QPixmap ImageFactory::lighterEffect(const QPixmap pixmap, const int delta) -{ - if (pixmap.isNull()) { - return pixmap; - } - - QImage image = pixmap.toImage(); - - const int width = image.width(); - const int height = image.height(); - const int bytesPerPixel = image.bytesPerLine() / image.width(); - - for (int i(0); i != height; ++i) - { - uchar *scanLine = image.scanLine(i); - for (int j(0); j != width; ++j) - { - QRgb &rgba = *(QRgb*)scanLine; - if (qAlpha(rgba) == 0xff) { - rgba = QColor::fromRgba(rgba).light(delta).rgba(); -// const QColor hsv = QColor::fromRgba(rgba).toHsv(); -// // check brightness first, color with max brightness processed with lighter will -// // become white like color which will ruin the whole image in general cases. -// if (hsv.value() < 255) { -// rgba = QColor::fromRgba(rgba).lighter(delta).rgba(); -// } - } - scanLine += bytesPerPixel; - } - } - - return QPixmap::fromImage(image); -} diff --git a/frame/util/imagefactory.h b/frame/util/imagefactory.h deleted file mode 100644 index 0cf680f8f..000000000 --- a/frame/util/imagefactory.h +++ /dev/null @@ -1,39 +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 IMAGEFACTORY_H -#define IMAGEFACTORY_H - -#include -#include -#include - -class ImageFactory : public QObject -{ - Q_OBJECT - -public: - explicit ImageFactory(QObject *parent = 0); - - static QPixmap lighterEffect(const QPixmap pixmap, const int delta = 120); -}; - -#endif // IMAGEFACTORY_H diff --git a/frame/util/monitor.cpp b/frame/util/monitor.cpp deleted file mode 100644 index 2d9f988f4..000000000 --- a/frame/util/monitor.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: sbw - * kirigaya - * Hualet - * - * Maintainer: sbw - * kirigaya - * Hualet - * - * 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 "monitor.h" - -Monitor::Monitor(QObject *parent) - : QObject(parent) - , m_x(0) - , m_y(0) - , m_w(0) - , m_h(0) - , m_enable(false) -{ - -} - -void Monitor::setX(const int x) -{ - if (m_x == x) - return; - - m_x = x; - - Q_EMIT geometryChanged(); -} - -void Monitor::setY(const int y) -{ - if (m_y == y) - return; - - m_y = y; - - Q_EMIT geometryChanged(); -} - -void Monitor::setW(const int w) -{ - if (m_w == w) - return; - - m_w = w; - - Q_EMIT geometryChanged(); -} - -void Monitor::setH(const int h) -{ - if (m_h == h) - return; - - m_h = h; - - Q_EMIT geometryChanged(); -} - -void Monitor::setName(const QString &name) -{ - qDebug() << "screen name change from :" << m_name << " to: " << name; - m_name = name; - - Q_EMIT nameChanged(m_name); -} - -void Monitor::setPath(const QString &path) -{ - m_path = path; -} - -bool compareResolution(const Resolution &first, const Resolution &second) -{ - long firstSum = long(first.width()) * first.height(); - long secondSum = long(second.width()) * second.height(); - if (firstSum > secondSum) - return true; - else if (firstSum == secondSum) { - if (first.rate() - second.rate() > 0.000001) - return true; - else - return false; - } else - return false; - -} - -void Monitor::setMonitorEnable(bool enable) -{ - if (m_enable == enable) - return; - - m_enable = enable; - Q_EMIT enableChanged(enable); -} diff --git a/frame/util/monitor.h b/frame/util/monitor.h deleted file mode 100644 index c4d085c08..000000000 --- a/frame/util/monitor.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: sbw - * kirigaya - * Hualet - * - * Maintainer: sbw - * kirigaya - * Hualet - * - * 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 MONITOR_H -#define MONITOR_H -#include "constants.h" - -#include -#include - -#include - -using MonitorInter = com::deepin::daemon::display::Monitor; -using namespace Dock; -class Monitor : public QObject -{ - Q_OBJECT -public: - struct DockPosition { - // 左、上、右、下 - bool leftDock = true; - bool topDock = true; - bool rightDock = true; - bool bottomDock = true; - DockPosition(bool l = true, bool t = true, bool r = true, bool b = true) - { - qDebug() << leftDock << topDock << rightDock << bottomDock; - leftDock = l; - topDock = t; - rightDock = r; - bottomDock = b; - } - - bool docked(const Position &pos) - { - switch (pos) { - case Position::Top: - return topDock; - case Position::Bottom: - return bottomDock; - case Position::Left: - return leftDock; - case Position::Right: - return rightDock; - } - Q_UNREACHABLE(); - } - - void reset() - { - leftDock = true; - topDock = true; - rightDock = true; - bottomDock = true; - } - }; - -public: - explicit Monitor(QObject *parent = nullptr); - - inline int x() const { return m_x; } - inline int y() const { return m_y; } - inline int w() const { return m_w; } - inline int h() const { return m_h; } - inline int left() const { return m_x; } - inline int right() const { return m_x + m_w; } - inline int top() const { return m_y; } - inline int bottom() const { return m_y + m_h; } - inline QPoint topLeft() const { return QPoint(m_x, m_y); } - inline QPoint topRight() const { return QPoint(m_x + m_w, m_y); } - inline QPoint bottomLeft() const { return QPoint(m_x, m_y + m_h); } - inline QPoint bottomRight() const { return QPoint(m_x + m_w, m_y + m_h); } - inline const QRect rect() const { return QRect(m_x, m_y, m_w, m_h); } - - inline const QString name() const { Q_ASSERT(!m_name.isEmpty()); return m_name; } - inline const QString path() const { return m_path; } - inline bool enable() const { return m_enable; } - - inline void setDockPosition(const DockPosition &position) { m_dockPosition = position; } - inline DockPosition &dockPosition() { return m_dockPosition; } - -Q_SIGNALS: - void geometryChanged() const; - void enableChanged(bool enable) const; - void nameChanged(const QString &name) const; - -public Q_SLOTS: - void setX(const int x); - void setY(const int y); - void setW(const int w); - void setH(const int h); - void setName(const QString &name); - void setPath(const QString &path); - void setMonitorEnable(bool enable); - -private: - int m_x; - int m_y; - int m_w; - int m_h; - - QString m_name; - QString m_path; - - bool m_enable; - DockPosition m_dockPosition; -}; - -#endif // MONITOR_H diff --git a/frame/util/multiscreenworker.cpp b/frame/util/multiscreenworker.cpp index 17cdeb9fa..40270ed9e 100644 --- a/frame/util/multiscreenworker.cpp +++ b/frame/util/multiscreenworker.cpp @@ -1199,19 +1199,6 @@ void MultiScreenWorker::changeDockPosition(QString fromScreen, QString toScreen, group->start(QVariantAnimation::DeleteWhenStopped); } -/** - * @brief updateDockScreenName 将任务栏所在屏幕信息进行更新,在任务栏切换屏幕显示后,这里应该被调用 - * @param screenName 目标屏幕 - */ -void MultiScreenWorker::updateDockScreenName(const QString &screenName) -{ - Q_UNUSED(screenName); - - m_ds.updateDockedScreen(screenName); - - qInfo() << "update dock screen: " << m_ds.current(); -} - /** * @brief getValidScreen 获取一个当前任务栏可以停靠的屏幕,优先使用主屏 * @return diff --git a/frame/util/multiscreenworker.h b/frame/util/multiscreenworker.h index 1b42e801c..c5b197044 100644 --- a/frame/util/multiscreenworker.h +++ b/frame/util/multiscreenworker.h @@ -23,7 +23,6 @@ #define MULTISCREENWORKER_H #include "constants.h" -#include "monitor.h" #include "utils.h" #include "dockitem.h" #include "xcb_misc.h" @@ -37,6 +36,7 @@ #include #include +#include #define WINDOWMARGIN ((m_displayMode == Dock::Efficient) ? 0 : 10) #define ANIMATIONTIME 300 @@ -128,7 +128,7 @@ public: RunState_Mask = 0xffffffff, }; - Q_DECLARE_FLAGS(RunStates, RunState) + typedef QFlags RunStates; MultiScreenWorker(QWidget *parent, DWindowManagerHelper *helper); ~MultiScreenWorker(); @@ -223,7 +223,6 @@ private: void tryToShowDock(int eventX, int eventY); void changeDockPosition(QString lastScreen, QString deskScreen, const Position &fromPos, const Position &toPos); - void updateDockScreenName(const QString &screenName); QString getValidScreen(const Position &pos); void resetDockScreen(); diff --git a/frame/window/mainwindow.h b/frame/window/mainwindow.h index 630a445d4..af14952d0 100644 --- a/frame/window/mainwindow.h +++ b/frame/window/mainwindow.h @@ -52,7 +52,8 @@ private: QPoint m_resizePoint; public: - DragWidget(QWidget *parent = nullptr) : QWidget(parent) + explicit DragWidget(QWidget *parent = nullptr) + : QWidget(parent) { setObjectName("DragWidget"); m_dragStatus = false; diff --git a/plugins/bluetooth/componments/adapter.cpp b/plugins/bluetooth/componments/adapter.cpp index 1017a0156..b7aaa2c04 100644 --- a/plugins/bluetooth/componments/adapter.cpp +++ b/plugins/bluetooth/componments/adapter.cpp @@ -72,7 +72,6 @@ void Adapter::addDevice(const QJsonObject &deviceObj) device->setDeviceType(bluetoothDeviceType); m_devices[id] = device; - divideDevice(device); emit deviceAdded(device); } @@ -83,7 +82,6 @@ void Adapter::removeDevice(const QString &deviceId) auto device = const_cast(constDevice); if (device) { m_devices.remove(deviceId); - m_paredDev.remove(deviceId); emit deviceRemoved(device); delete device; } @@ -120,37 +118,6 @@ void Adapter::updateDevice(const QJsonObject &dviceJson) } } -//void Adapter::removeAllDevices() -//{ -// QMapIterator iterator(m_devices); -// while (iterator.hasNext()) { -// iterator.next(); -// auto device = const_cast(iterator.value()); -// if (device) { -// m_devices.remove(device->id()); -// m_paredDev.remove(device->id()); -// delete device; -// } -// } -//} - -const QMap &Adapter::paredDevices() const -{ - return m_paredDev; -} - -//int Adapter::paredDevicesCount() const -//{ -// return m_paredDev.size(); -//} - -void Adapter::divideDevice(const Device *device) -{ - if (device->paired()) { - m_paredDev[device->id()] = device; - } -} - void Adapter::setPowered(bool powered) { if (powered != m_powered) { @@ -186,7 +153,6 @@ void Adapter::initDevicesList(const QJsonDocument &doc) device->setDeviceType(bluetoothDeviceType); m_devices[id] = device; - divideDevice(device); } } diff --git a/plugins/bluetooth/componments/adapter.h b/plugins/bluetooth/componments/adapter.h index 2682350a9..f55625a38 100644 --- a/plugins/bluetooth/componments/adapter.h +++ b/plugins/bluetooth/componments/adapter.h @@ -55,9 +55,6 @@ public: void addDevice(const QJsonObject &deviceObj); void removeDevice(const QString &deviceId); void updateDevice(const QJsonObject &dviceJson); -// void removeAllDevices(); - const QMap &paredDevices() const; -// int paredDevicesCount() const; Q_SIGNALS: void nameChanged(const QString &name) const; @@ -67,9 +64,6 @@ Q_SIGNALS: void poweredChanged(const bool powered) const; void discoveringChanged(const bool discover) const; -private: - void divideDevice(const Device *device); - private: QString m_id; QString m_name; @@ -78,7 +72,6 @@ private: bool m_discover; QMap m_devices; - QMap m_paredDev; }; #endif // ADAPTER_H diff --git a/plugins/bluetooth/componments/adaptersmanager.cpp b/plugins/bluetooth/componments/adaptersmanager.cpp index 328e268f5..3a3e3a813 100644 --- a/plugins/bluetooth/componments/adaptersmanager.cpp +++ b/plugins/bluetooth/componments/adaptersmanager.cpp @@ -35,7 +35,6 @@ AdaptersManager::AdaptersManager(QObject *parent) "/com/deepin/daemon/Bluetooth", QDBusConnection::sessionBus(), this)) - , m_defaultAdapterState(false) { connect(m_bluetoothInter, &DBusBluetooth::AdapterAdded, this, &AdaptersManager::onAddAdapter); connect(m_bluetoothInter, &DBusBluetooth::AdapterRemoved, this, &AdaptersManager::onRemoveAdapter); @@ -78,7 +77,6 @@ AdaptersManager::AdaptersManager(QObject *parent) for (int index = 0; index < arr.size(); index++) { auto *adapter = new Adapter(this); adapterAdd(adapter, arr[index].toObject()); - m_defaultAdapterState |= adapter->powered(); } } @@ -102,11 +100,11 @@ void AdaptersManager::setAdapterPowered(const Adapter *adapter, const bool &powe } }); } else { - QDBusPendingCall call = m_bluetoothInter->ClearUnpairedDevice(); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); + QDBusPendingCall clearUnpairedCall = m_bluetoothInter->ClearUnpairedDevice(); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(clearUnpairedCall, this); connect(watcher, &QDBusPendingCallWatcher::finished, [ = ] { - if (call.isError()) - qWarning() << call.error().message(); + if (clearUnpairedCall.isError()) + qWarning() << clearUnpairedCall.error().message(); }); } } @@ -132,11 +130,6 @@ void AdaptersManager::connectDevice(const Device *device, Adapter *adapter) } } -bool AdaptersManager::defaultAdapterInitPowerState() -{ - return m_defaultAdapterState; -} - int AdaptersManager::adaptersCount() { return m_adapters.size(); diff --git a/plugins/bluetooth/componments/adaptersmanager.h b/plugins/bluetooth/componments/adaptersmanager.h index 38ab42c4a..3d72127df 100644 --- a/plugins/bluetooth/componments/adaptersmanager.h +++ b/plugins/bluetooth/componments/adaptersmanager.h @@ -36,7 +36,6 @@ public: void setAdapterPowered(const Adapter *adapter, const bool &powered); void connectDevice(const Device *device, Adapter *adapter); - bool defaultAdapterInitPowerState(); int adaptersCount(); void adapterRefresh(const Adapter *adapter); void disconnectDevice(Device *device); @@ -62,7 +61,6 @@ private: private: DBusBluetooth *m_bluetoothInter; QMap m_adapters; - bool m_defaultAdapterState; }; #endif // ADAPTERSMANAGER_H diff --git a/plugins/bluetooth/componments/bluetoothadapteritem.cpp b/plugins/bluetooth/componments/bluetoothadapteritem.cpp index 5c3cc9573..255e0ef76 100644 --- a/plugins/bluetooth/componments/bluetoothadapteritem.cpp +++ b/plugins/bluetooth/componments/bluetoothadapteritem.cpp @@ -363,7 +363,7 @@ void BluetoothAdapterItem::setUnnamedDevicesVisible(bool isShow) if (isShow) { // 计算已连接蓝牙设备数 int connectCount = 0; - for (i = m_deviceItems.begin(); i != m_deviceItems.end(); i++) { + for (i = m_deviceItems.begin(); i != m_deviceItems.end(); ++i) { BluetoothDeviceItem *deviceItem = i.value(); if (deviceItem && deviceItem->device() && deviceItem->device()->paired() @@ -372,7 +372,7 @@ void BluetoothAdapterItem::setUnnamedDevicesVisible(bool isShow) } // 显示所有蓝牙设备 - for (i = m_deviceItems.begin(); i != m_deviceItems.end(); i++) { + for (i = m_deviceItems.begin(); i != m_deviceItems.end(); ++i) { BluetoothDeviceItem *deviceItem = i.value(); if (deviceItem && deviceItem->device() && deviceItem->device()->name().isEmpty()) { @@ -388,7 +388,7 @@ void BluetoothAdapterItem::setUnnamedDevicesVisible(bool isShow) } - for (i = m_deviceItems.begin(); i != m_deviceItems.end(); i++) { + for (i = m_deviceItems.begin(); i != m_deviceItems.end(); ++i) { BluetoothDeviceItem *deviceItem = i.value(); // 将名称为空的蓝牙设备过滤,如果蓝牙正在连接或者已连接不过滤 diff --git a/plugins/bluetooth/componments/device.cpp b/plugins/bluetooth/componments/device.cpp index 5a17d72ac..621ec1488 100644 --- a/plugins/bluetooth/componments/device.cpp +++ b/plugins/bluetooth/componments/device.cpp @@ -22,6 +22,7 @@ #include "device.h" +#include #include QMap Device::deviceType2Icon = { @@ -52,18 +53,12 @@ Device::Device(QObject *parent) , m_state(StateUnavailable) , m_connectState(false) { - m_time = static_cast(QDateTime::currentDateTime().toTime_t()); } Device::~Device() { } -void Device::updateDeviceTime() -{ - m_time = static_cast(QDateTime::currentDateTime().toTime_t()); -} - void Device::setId(const QString &id) { m_id = id; @@ -109,22 +104,6 @@ void Device::setConnectState(const bool connectState) } } -void Device::setTrusted(bool trusted) -{ - if (trusted != m_trusted) { - m_trusted = trusted; - Q_EMIT trustedChanged(trusted); - } -} - -void Device::setConnecting(bool connecting) -{ - if (connecting != m_connecting) { - m_connecting = connecting; - Q_EMIT connectingChanged(connecting); - } -} - void Device::setRssi(int rssi) { if (m_rssi != rssi) { diff --git a/plugins/bluetooth/componments/device.h b/plugins/bluetooth/componments/device.h index fd2e05b42..22f53268d 100644 --- a/plugins/bluetooth/componments/device.h +++ b/plugins/bluetooth/componments/device.h @@ -64,10 +64,8 @@ public: void setConnectState(const bool connectState); inline bool trusted() const { return m_trusted; } - void setTrusted(bool trusted); inline bool connecting() const { return m_connecting; } - void setConnecting(bool connecting); inline int rssi() const { return m_rssi; } void setRssi(int rssi); @@ -78,17 +76,12 @@ public: inline QString deviceType() const { return m_deviceType; } void setDeviceType(const QString &deviceType); - inline int deviceTime() const { return m_time; } - void updateDeviceTime(); - Q_SIGNALS: void nameChanged(const QString &name) const; void aliasChanged(const QString &alias) const; void pairedChanged(const bool paired) const; void stateChanged(const State state) const; void connectStateChanged(const bool connectState) const; - void trustedChanged(const bool trusted) const; - void connectingChanged(const bool &connecting) const; void rssiChanged(const int rssi) const; private: @@ -103,7 +96,6 @@ private: bool m_connectState; QString m_adapterId; QString m_deviceType; - int m_time; }; QDebug &operator<<(QDebug &stream, const Device *device); diff --git a/plugins/keyboard-layout/dbusadaptors.h b/plugins/keyboard-layout/dbusadaptors.h index dfe9d6e94..21d0c6c4f 100644 --- a/plugins/keyboard-layout/dbusadaptors.h +++ b/plugins/keyboard-layout/dbusadaptors.h @@ -40,7 +40,7 @@ class DBusAdaptors : public QDBusAbstractAdaptor // "") public: - DBusAdaptors(QObject *parent = nullptr); + explicit DBusAdaptors(QObject *parent = nullptr); ~DBusAdaptors(); public: diff --git a/plugins/network/networkitem.cpp b/plugins/network/networkitem.cpp index 5d9de2714..f87fa00f3 100644 --- a/plugins/network/networkitem.cpp +++ b/plugins/network/networkitem.cpp @@ -519,16 +519,16 @@ QString NetworkItem::getStrengthStateString(int strength) { if (5 >= strength) return "0"; - else if (5 < strength && 30 >= strength) + else if (30 >= strength) return "20"; - else if (30 < strength && 55 >= strength) + else if (55 >= strength) return "40"; - else if (55 < strength && 65 >= strength) + else if (65 >= strength) return "60"; - else if (65 < strength) - return "80"; else - return "0"; + return "80"; + + Q_UNREACHABLE(); } void NetworkItem::wiredsEnable(bool enable) diff --git a/plugins/power/dbus/dbusaccount.h b/plugins/power/dbus/dbusaccount.h index 8227505d0..64ac04af6 100644 --- a/plugins/power/dbus/dbusaccount.h +++ b/plugins/power/dbus/dbusaccount.h @@ -79,7 +79,7 @@ public: { return "com.deepin.daemon.Accounts"; } public: - DBusAccount(QObject *parent = 0); + explicit DBusAccount(QObject *parent = 0); ~DBusAccount(); diff --git a/plugins/shutdown/dbus/dbusaccount.h b/plugins/shutdown/dbus/dbusaccount.h index 8227505d0..64ac04af6 100644 --- a/plugins/shutdown/dbus/dbusaccount.h +++ b/plugins/shutdown/dbus/dbusaccount.h @@ -79,7 +79,7 @@ public: { return "com.deepin.daemon.Accounts"; } public: - DBusAccount(QObject *parent = 0); + explicit DBusAccount(QObject *parent = 0); ~DBusAccount(); diff --git a/plugins/sound/soundapplet.cpp b/plugins/sound/soundapplet.cpp index 0c804d550..5e769be7f 100644 --- a/plugins/sound/soundapplet.cpp +++ b/plugins/sound/soundapplet.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #define SEPARATOR_HEIGHT 2 #define WIDTH 260 @@ -130,45 +131,8 @@ SoundApplet::SoundApplet(QWidget *parent) initUi(); } -///** -// * @brief SoundApplet::setControlBackground 设置音频界面控件背景颜色 -// */ -//void SoundApplet::setControlBackground() -//{ -// QPalette soundAppletBackgroud; -// QPalette listViewBackgroud = m_listView->palette(); -// if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) -// soundAppletBackgroud.setColor(QPalette::Background, QColor(255, 255, 255, 0.03 * 255)); -// else -// soundAppletBackgroud.setColor(QPalette::Background, QColor(0, 0, 0, 0.03 * 255)); - -// this->setAutoFillBackground(true); -// this->setPalette(soundAppletBackgroud); -// listViewBackgroud.setColor(QPalette::Base, Qt::transparent); -// m_listView->setAutoFillBackground(true); -// m_listView->setPalette(listViewBackgroud); -//} - -///** -// * @brief SoundApplet::setItemHoverColor 通过代理方式根据当前主题设置音频列表文字颜色和item选中颜色 -// */ -//void SoundApplet::setItemHoverColor() -//{ -// QPalette hoverBackgroud = m_listView->palette(); -// if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) { -// hoverBackgroud.setColor(QPalette::Normal, QPalette::Highlight, QColor(0, 0, 0, 30)); -// hoverBackgroud.setColor(QPalette::Normal, QPalette::HighlightedText, QColor(0, 0, 0, 255)); -// } else { -// hoverBackgroud.setColor(QPalette::Normal, QPalette::Highlight, QColor(255, 255, 255, 30)); -// hoverBackgroud.setColor(QPalette::Normal, QPalette::HighlightedText, QColor(255, 255, 255, 255)); -// } -// m_listView->setPalette(hoverBackgroud); -// m_listView->setItemDelegate(m_itemDelegate); -//} - void SoundApplet::initUi() { - // setControlBackground(); m_listView->setFrameShape(QFrame::NoFrame); m_listView->setEditTriggers(DListView::NoEditTriggers); m_listView->setSelectionMode(QAbstractItemView::NoSelection); @@ -260,7 +224,7 @@ void SoundApplet::initUi() }); connect(qApp, &QGuiApplication::fontChanged, this, &SoundApplet::updateListHeight); connect(m_volumeSlider, &VolumeSlider::valueChanged, this, &SoundApplet::volumeSliderValueChanged); - connect(m_audioInter, &DBusAudio::DefaultSinkChanged, this, static_cast(&SoundApplet::defaultSinkChanged)); + connect(m_audioInter, &DBusAudio::DefaultSinkChanged, this, &SoundApplet::onDefaultSinkChanged); connect(m_audioInter, &DBusAudio::IncreaseVolumeChanged, this, &SoundApplet::increaseVolumeChanged); connect(m_audioInter, &DBusAudio::PortEnabledChanged, [this](uint cardId, QString portId) { portEnableChange(cardId, portId); @@ -279,7 +243,7 @@ void SoundApplet::initUi() QDBusConnection::sessionBus().connect("com.deepin.daemon.Audio", "/com/deepin/daemon/Audio", "org.freedesktop.DBus.Properties" ,"PropertiesChanged", "sa{sv}as", this, SLOT(haldleDbusSignal(QDBusMessage))); - QMetaObject::invokeMethod(this, "defaultSinkChanged", Qt::QueuedConnection); + QMetaObject::invokeMethod(this, "onDefaultSinkChanged", Qt::QueuedConnection); refreshIcon(); @@ -301,7 +265,7 @@ VolumeSlider *SoundApplet::mainSlider() return m_volumeSlider; } -void SoundApplet::defaultSinkChanged() +void SoundApplet::onDefaultSinkChanged() { //防止手动切换设备,与后端交互时,获取到多个信号,设备切换多次,造成混乱 QThread::msleep(200); @@ -388,7 +352,7 @@ void SoundApplet::cardsChanged(const QString &cards) tmpCardIds.insert(cardId, tmpPorts); } - defaultSinkChanged();//重新获取切换的设备信息 + onDefaultSinkChanged();//重新获取切换的设备信息 enableDevice(true); for (Port *port : m_ports) { @@ -495,10 +459,12 @@ bool SoundApplet::containsPort(const Port *port) Port *SoundApplet::findPort(const QString &portId, const uint &cardId) const { - for (Port *port : m_ports) { - if (port->id() == portId && port->cardId() == cardId) { - return port; - } + auto it = std::find_if(m_ports.begin(), m_ports.end(), [ = ] (Port *p) { + return (p->id() == portId && p->cardId() == cardId); + }); + + if (it != m_ports.end()) { + return *it; } return nullptr; diff --git a/plugins/sound/soundapplet.h b/plugins/sound/soundapplet.h index 64b7518b7..98a78b4b0 100644 --- a/plugins/sound/soundapplet.h +++ b/plugins/sound/soundapplet.h @@ -118,7 +118,7 @@ signals: void defaultSinkChanged(DBusSink *sink) const; private slots: - void defaultSinkChanged(); + void onDefaultSinkChanged(); void onVolumeChanged(double volume); void volumeSliderValueChanged(); void increaseVolumeChanged(); diff --git a/plugins/sound/sounditem.cpp b/plugins/sound/sounditem.cpp index 2cc1e7de5..21392bbbd 100644 --- a/plugins/sound/sounditem.cpp +++ b/plugins/sound/sounditem.cpp @@ -54,7 +54,7 @@ SoundItem::SoundItem(QWidget *parent) m_applet->setVisible(false); - connect(m_applet, static_cast(&SoundApplet::defaultSinkChanged), this, &SoundItem::sinkChanged); + connect(m_applet, &SoundApplet::defaultSinkChanged, this, &SoundItem::sinkChanged); connect(m_applet, &SoundApplet::volumeChanged, this, &SoundItem::refresh, Qt::QueuedConnection); connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, [ = ] { diff --git a/plugins/tray/abstracttraywidget.h b/plugins/tray/abstracttraywidget.h index 8e450f5c9..bda26ed36 100644 --- a/plugins/tray/abstracttraywidget.h +++ b/plugins/tray/abstracttraywidget.h @@ -39,10 +39,8 @@ public: virtual ~AbstractTrayWidget(); virtual QString itemKeyForConfig() = 0; - virtual void setActive(const bool active) = 0; virtual void updateIcon() = 0; virtual void sendClick(uint8_t mouseButton, int x, int y) = 0; - virtual const QImage trayImage() = 0; virtual inline TrayType trayTyep() const { return TrayType::ApplicationTray; } // default is ApplicationTray virtual bool isValid() {return true;} diff --git a/plugins/tray/fashiontray/containers/abstractcontainer.cpp b/plugins/tray/fashiontray/containers/abstractcontainer.cpp index a07996198..95f67bd2a 100644 --- a/plugins/tray/fashiontray/containers/abstractcontainer.cpp +++ b/plugins/tray/fashiontray/containers/abstractcontainer.cpp @@ -29,7 +29,6 @@ AbstractContainer::AbstractContainer(TrayPlugin *trayPlugin, QWidget *parent) , m_currentDraggingWrapper(nullptr) , m_expand(true) , m_dockPosition(Dock::Position::Bottom) -// , m_wrapperSize(QSize(PLUGIN_BACKGROUND_MAX_SIZE, PLUGIN_BACKGROUND_MAX_SIZE)) { setAcceptDrops(true); @@ -230,22 +229,12 @@ int AbstractContainer::itemCount() bool AbstractContainer::containsWrapper(FashionTrayWidgetWrapper *wrapper) { - for (auto w : m_wrapperList) { - if (w == wrapper) { - return true; - } - } - - return false; + return m_wrapperList.contains(wrapper); } bool AbstractContainer::containsWrapperByTrayWidget(AbstractTrayWidget *trayWidget) { - if (wrapperByTrayWidget(trayWidget)) { - return true; - } - - return false; + return wrapperByTrayWidget(trayWidget); } FashionTrayWidgetWrapper *AbstractContainer::wrapperByTrayWidget(AbstractTrayWidget *trayWidget) diff --git a/plugins/tray/fashiontray/fashiontrayitem.cpp b/plugins/tray/fashiontray/fashiontrayitem.cpp index d6c0ad540..66ef67af8 100644 --- a/plugins/tray/fashiontray/fashiontrayitem.cpp +++ b/plugins/tray/fashiontray/fashiontrayitem.cpp @@ -169,8 +169,6 @@ void FashionTrayItem::onExpandChanged(const bool expand) { m_trayPlugin->saveValue(FASHION_MODE_ITEM_KEY, ExpandedKey, expand); -// refreshHoldContainerPosition(); - m_normalContainer->setExpand(expand); m_attentionContainer->setExpand(expand); @@ -292,20 +290,6 @@ void FashionTrayItem::requestResize() resizeTray(); } -void FashionTrayItem::refreshHoldContainerPosition() -{ - m_mainBoxLayout->removeWidget(m_holdContainer); - - int destIndex = 0; - if (m_controlWidget->expanded()) { - destIndex = m_mainBoxLayout->indexOf(m_controlWidget); - } else { - destIndex = m_mainBoxLayout->indexOf(m_attentionContainer); - } - - m_mainBoxLayout->insertWidget(destIndex, m_holdContainer); -} - void FashionTrayItem::onRequireDraggingWrapper() { AbstractContainer *container = dynamic_cast(sender()); diff --git a/plugins/tray/fashiontray/fashiontrayitem.h b/plugins/tray/fashiontray/fashiontrayitem.h index 53aa39550..a3bc1d672 100644 --- a/plugins/tray/fashiontray/fashiontrayitem.h +++ b/plugins/tray/fashiontray/fashiontrayitem.h @@ -77,7 +77,6 @@ private Q_SLOTS: void attentionWrapperToNormalWrapper(); void normalWrapperToAttentionWrapper(FashionTrayWidgetWrapper *wrapper); void requestResize(); - void refreshHoldContainerPosition(); void onRequireDraggingWrapper(); private: diff --git a/plugins/tray/indicatortraywidget.cpp b/plugins/tray/indicatortraywidget.cpp index cc03e53a6..0f5f13d8b 100644 --- a/plugins/tray/indicatortraywidget.cpp +++ b/plugins/tray/indicatortraywidget.cpp @@ -67,21 +67,11 @@ QString IndicatorTrayWidget::itemKeyForConfig() return toIndicatorKey(m_indicatorName); } -void IndicatorTrayWidget::setActive(const bool) -{ - -} - void IndicatorTrayWidget::updateIcon() { } -const QImage IndicatorTrayWidget::trayImage() -{ - return m_label->grab().toImage(); -} - void IndicatorTrayWidget::sendClick(uint8_t buttonIndex, int x, int y) { Q_EMIT clicked(buttonIndex, x, y); @@ -94,11 +84,6 @@ void IndicatorTrayWidget::setPixmapData(const QByteArray &data) m_label->setPixmap(rawPixmap); } -void IndicatorTrayWidget::setPixmapPath(const QString &text) -{ - m_label->setPixmap(QPixmap(text)); -} - void IndicatorTrayWidget::setText(const QString &text) { m_label->setText(text); diff --git a/plugins/tray/indicatortraywidget.h b/plugins/tray/indicatortraywidget.h index 565a01021..05c546573 100644 --- a/plugins/tray/indicatortraywidget.h +++ b/plugins/tray/indicatortraywidget.h @@ -34,16 +34,13 @@ public: ~IndicatorTrayWidget(); QString itemKeyForConfig() override; - void setActive(const bool active) override; void updateIcon() override; - const QImage trayImage() override; void sendClick(uint8_t, int, int) override; static QString toIndicatorKey(const QString &indicatorName) { return QString("indicator:%1").arg(indicatorName); } static bool isIndicatorKey(const QString &itemKey) { return itemKey.startsWith("indicator:"); } public Q_SLOTS: Q_SCRIPTABLE void setPixmapData(const QByteArray &data); - Q_SCRIPTABLE void setPixmapPath(const QString &text); Q_SCRIPTABLE void setText(const QString &text); Q_SIGNALS: diff --git a/plugins/tray/snitraywidget.cpp b/plugins/tray/snitraywidget.cpp index 3a5373be8..6b6c3b26c 100644 --- a/plugins/tray/snitraywidget.cpp +++ b/plugins/tray/snitraywidget.cpp @@ -168,10 +168,6 @@ QString SNITrayWidget::itemKeyForConfig() return QString("sni:%1").arg(key); } -void SNITrayWidget::setActive(const bool active) -{ -} - void SNITrayWidget::updateIcon() { m_updateIconTimer->start(); @@ -200,11 +196,6 @@ void SNITrayWidget::sendClick(uint8_t mouseButton, int x, int y) } } -const QImage SNITrayWidget::trayImage() -{ - return m_pixmap.toImage(); -} - bool SNITrayWidget::isValid() { return m_sniInter->isValid(); diff --git a/plugins/tray/snitraywidget.h b/plugins/tray/snitraywidget.h index a6fcb4932..c8f58d8fe 100644 --- a/plugins/tray/snitraywidget.h +++ b/plugins/tray/snitraywidget.h @@ -56,10 +56,8 @@ public: SNITrayWidget(const QString &sniServicePath, QWidget *parent = Q_NULLPTR); QString itemKeyForConfig() override; - void setActive(const bool active) override; void updateIcon() override; void sendClick(uint8_t mouseButton, int x, int y) override; - const QImage trayImage() override; bool isValid() override; SNITrayWidget::ItemStatus status(); diff --git a/plugins/tray/system-trays/systemtrayitem.cpp b/plugins/tray/system-trays/systemtrayitem.cpp index f7fe9b847..3812e3ad3 100644 --- a/plugins/tray/system-trays/systemtrayitem.cpp +++ b/plugins/tray/system-trays/systemtrayitem.cpp @@ -96,21 +96,11 @@ QString SystemTrayItem::itemKeyForConfig() return m_itemKey; } -void SystemTrayItem::setActive(const bool active) -{ - Q_UNUSED(active); -} - void SystemTrayItem::updateIcon() { m_pluginInter->refreshIcon(m_itemKey); } -const QImage SystemTrayItem::trayImage() -{ - return QImage(); -} - void SystemTrayItem::sendClick(uint8_t mouseButton, int x, int y) { Q_UNUSED(mouseButton); diff --git a/plugins/tray/system-trays/systemtrayitem.h b/plugins/tray/system-trays/systemtrayitem.h index ac1ae1290..e37c84a89 100644 --- a/plugins/tray/system-trays/systemtrayitem.h +++ b/plugins/tray/system-trays/systemtrayitem.h @@ -41,9 +41,7 @@ public: public: QString itemKeyForConfig() override; - void setActive(const bool active) override; void updateIcon() override; - const QImage trayImage() override; void sendClick(uint8_t mouseButton, int x, int y) override; inline TrayType trayTyep() const override { return TrayType::SystemTray; } diff --git a/plugins/tray/trayplugin.h b/plugins/tray/trayplugin.h index 6fd4cf1b6..a8763205f 100644 --- a/plugins/tray/trayplugin.h +++ b/plugins/tray/trayplugin.h @@ -47,7 +47,7 @@ class TrayPlugin : public QObject, PluginsItemInterface Q_PLUGIN_METADATA(IID "com.deepin.dock.PluginsItemInterface" FILE "tray.json") public: - explicit TrayPlugin(QObject *parent = 0); + explicit TrayPlugin(QObject *parent = nullptr); const QString pluginName() const override; void init(PluginProxyInterface *proxyInter) override; diff --git a/plugins/tray/xembedtraywidget.cpp b/plugins/tray/xembedtraywidget.cpp index 16ace4c65..aeced6f42 100644 --- a/plugins/tray/xembedtraywidget.cpp +++ b/plugins/tray/xembedtraywidget.cpp @@ -109,11 +109,6 @@ QString XEmbedTrayWidget::itemKeyForConfig() return QString("window:%1").arg(getAppNameForWindow(m_windowId)); } -const QImage XEmbedTrayWidget::trayImage() -{ - return m_image; -} - void XEmbedTrayWidget::showEvent(QShowEvent *e) { QWidget::showEvent(e); @@ -387,12 +382,6 @@ bool XEmbedTrayWidget::isXEmbedKey(const QString &itemKey) return itemKey.startsWith("window:"); } -void XEmbedTrayWidget::setActive(const bool active) -{ - m_active = active; - m_updateTimer->start(); -} - void XEmbedTrayWidget::refershIconImage() { const auto ratio = devicePixelRatioF(); diff --git a/plugins/tray/xembedtraywidget.h b/plugins/tray/xembedtraywidget.h index 8173ca88e..7813275bf 100644 --- a/plugins/tray/xembedtraywidget.h +++ b/plugins/tray/xembedtraywidget.h @@ -37,8 +37,6 @@ public: QString itemKeyForConfig() override; void updateIcon() override; - void setActive(const bool active) override; - const QImage trayImage() override; void sendClick(uint8_t mouseButton, int x, int y) override; static QString getWindowProperty(quint32 winId, QString propName); diff --git a/tests/controller/ut_dockitemmanager.cpp b/tests/controller/ut_dockitemmanager.cpp index 4368d224a..07b35ee65 100644 --- a/tests/controller/ut_dockitemmanager.cpp +++ b/tests/controller/ut_dockitemmanager.cpp @@ -72,7 +72,6 @@ TEST_F(Test_DockItemManager, get_method_test) TEST_F(Test_DockItemManager, refreshItemsIcon_test) { manager->refreshItemsIcon(); - manager->sortPluginItems(); } TEST_F(Test_DockItemManager, cover_test) diff --git a/tests/item/components/ut_hoverhighlighteffect.cpp b/tests/item/components/ut_hoverhighlighteffect.cpp deleted file mode 100644 index 8c0e24235..000000000 --- a/tests/item/components/ut_hoverhighlighteffect.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. - * - * Author: fanpengcheng - * - * Maintainer: fanpengcheng - * - * 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 -#include -#include -#include -#include - -#include - -#define private public -#include "hoverhighlighteffect.h" -#undef private - -class Test_HoverHighlightEffect : public ::testing::Test -{ -public: - virtual void SetUp() override; - virtual void TearDown() override; - -public: - HoverHighlightEffect *effect = nullptr; -}; - -void Test_HoverHighlightEffect::SetUp() -{ - effect = new HoverHighlightEffect(); -} - -void Test_HoverHighlightEffect::TearDown() -{ - delete effect; - effect = nullptr; -} - -TEST_F(Test_HoverHighlightEffect, test) -{ - effect->setHighlighting(true); - ASSERT_EQ(effect->m_highlighting, true) ; - effect->setHighlighting(false); - ASSERT_EQ(effect->m_highlighting, false) ; -} diff --git a/tests/util/ut_imagefactory.cpp b/tests/util/ut_imagefactory.cpp deleted file mode 100644 index 39314b9c9..000000000 --- a/tests/util/ut_imagefactory.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. - * - * Author: fanpengcheng - * - * Maintainer: fanpengcheng - * - * 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 -#include -#include -#include - -#include - -#include "imagefactory.h" - -class Test_ImageFactory : public QObject, public ::testing::Test -{ -public: - virtual void SetUp() override; - virtual void TearDown() override; - -public: - ImageFactory *factory = nullptr; -}; - -void Test_ImageFactory::SetUp() -{ - factory = new ImageFactory(); -} - -void Test_ImageFactory::TearDown() -{ - delete factory; - factory = nullptr; -} - -TEST_F(Test_ImageFactory, factory_test) -{ - QPixmap pix(":/res/all_settings_on.png"); - // 以下是无效值,应该屏蔽才对 - factory->lighterEffect(pix, -1); - factory->lighterEffect(pix, 256); - - // 传入空的pixmap对象 - QPixmap emptyPix; - factory->lighterEffect(emptyPix, 150); -} diff --git a/tests/util/ut_monitor.cpp b/tests/util/ut_monitor.cpp deleted file mode 100644 index 896521953..000000000 --- a/tests/util/ut_monitor.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. - * - * Author: chenjun - * - * Maintainer: chenjun - * - * 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 -#include -#include - -#include - -#include "monitor.h" - -//因为GTest不能断言自定义结构数据,需要重载<<和==操作符 -std::ostream & operator<<(std::ostream & os, const Monitor::DockPosition & dockPosition) { - return os << "leftDock = " - << dockPosition.leftDock - << " rightDock = " - << dockPosition.rightDock - << "topDock = " - << dockPosition.topDock - << " bottomDock = " - << dockPosition.bottomDock; -} - -bool operator==(const Monitor::DockPosition & p1, const Monitor::DockPosition & p2) { - return p1.leftDock == p2.leftDock && p1.rightDock == p2.rightDock && p1.topDock == p2.topDock && p1.bottomDock == p2.bottomDock; -} - -class Test_Monitor : public ::testing::Test -{ -public: - virtual void SetUp() override; - virtual void TearDown() override; - -public: - Monitor *monitor = nullptr; -}; - -void Test_Monitor::SetUp() -{ - monitor = new Monitor(); -} - -void Test_Monitor::TearDown() -{ - delete monitor; - monitor = nullptr; -} - -TEST_F(Test_Monitor, monitor_test) -{ - ASSERT_NE(monitor, nullptr); - - int x = 10; - int y = 10; - int w = 100; - int h = 100; - - monitor->setX(x); - QCOMPARE(monitor->x(), x); - monitor->setX(x); - - monitor->setY(y); - QCOMPARE(monitor->y(), y); - monitor->setY(y); - - monitor->setW(w); - QCOMPARE(monitor->w(), w); - monitor->setW(w); - - monitor->setH(h); - QCOMPARE(monitor->h(), h); - monitor->setH(h); - - QCOMPARE(monitor->left(), x); - QCOMPARE(monitor->right(), x + w); - QCOMPARE(monitor->top(), y); - QCOMPARE(monitor->bottom(), y + h); - - QCOMPARE(monitor->topLeft(), QPoint(x, y)); - QCOMPARE(monitor->topRight(), QPoint(x + w, y)); - QCOMPARE(monitor->bottomLeft(), QPoint(x, y + h)); - QCOMPARE(monitor->bottomRight(), QPoint(x + w, y + h)); - QCOMPARE(monitor->rect(), QRect(x, y, w, h)); - - QString name = "MonitorTestName"; - monitor->setName(name); - QCOMPARE(monitor->name(), name); - - QString path = "testPath"; - monitor->setPath(path); - QCOMPARE(monitor->path(), path); - - bool monitorEnable = true; - monitor->setMonitorEnable(monitorEnable); - QCOMPARE(monitor->enable(), monitorEnable); - monitor->setMonitorEnable(monitorEnable); - - Monitor::DockPosition dockPosition; - dockPosition.leftDock = true; - dockPosition.rightDock = true; - dockPosition.topDock = true; - dockPosition.bottomDock = true; - monitor->setDockPosition(dockPosition); - QCOMPARE(monitor->dockPosition(), dockPosition); -} - -TEST_F(Test_Monitor, dockPosition_test) -{ - monitor->setDockPosition(Monitor::DockPosition(false, false, false, false)); - ASSERT_FALSE(monitor->dockPosition().docked(Position::Top)); - ASSERT_FALSE(monitor->dockPosition().docked(Position::Bottom)); - ASSERT_FALSE(monitor->dockPosition().docked(Position::Left)); - ASSERT_FALSE(monitor->dockPosition().docked(Position::Right)); - - monitor->dockPosition().reset(); - ASSERT_TRUE(monitor->dockPosition().docked(Position::Top)); - ASSERT_TRUE(monitor->dockPosition().docked(Position::Bottom)); - ASSERT_TRUE(monitor->dockPosition().docked(Position::Left)); - ASSERT_TRUE(monitor->dockPosition().docked(Position::Right)); -}