mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
refactor:delete invalid code
This commit is contained in:
parent
68b45bbf4b
commit
552a61f4ea
@ -1,419 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
|
||||||
*
|
|
||||||
* Author: sbw <sbw@sbw.so>
|
|
||||||
*
|
|
||||||
* Maintainer: sbw <sbw@sbw.so>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "dockitemcontroller.h"
|
|
||||||
#include "item/appitem.h"
|
|
||||||
#include "item/stretchitem.h"
|
|
||||||
#include "item/launcheritem.h"
|
|
||||||
#include "item/pluginsitem.h"
|
|
||||||
#include "item/traypluginitem.h"
|
|
||||||
#include "util/docksettings.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QGSettings>
|
|
||||||
|
|
||||||
DockItemController *DockItemController::INSTANCE = nullptr;
|
|
||||||
|
|
||||||
DockItemController *DockItemController::instance(QObject *parent)
|
|
||||||
{
|
|
||||||
if (!INSTANCE)
|
|
||||||
INSTANCE = new DockItemController(parent);
|
|
||||||
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QList<QPointer<DockItem>> DockItemController::itemList() const
|
|
||||||
{
|
|
||||||
return m_itemList;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QList<PluginsItemInterface *> DockItemController::pluginList() const
|
|
||||||
{
|
|
||||||
return m_pluginsInter->pluginsMap().keys();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DockItemController::appIsOnDock(const QString &appDesktop) const
|
|
||||||
{
|
|
||||||
return m_appInter->IsOnDock(appDesktop);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DockItemController::itemIsInContainer(DockItem * const item) const
|
|
||||||
{
|
|
||||||
return m_containerItem->contains(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemController::setDropping(const bool dropping)
|
|
||||||
{
|
|
||||||
m_containerItem->setDropping(dropping);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemController::startLoadPlugins() const
|
|
||||||
{
|
|
||||||
QGSettings gsetting("com.deepin.dde.dock", "/com/deepin/dde/dock/");
|
|
||||||
|
|
||||||
QTimer::singleShot(gsetting.get("delay-plugins-time").toUInt(), m_pluginsInter, &DockPluginsController::startLoader);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemController::refershItemsIcon()
|
|
||||||
{
|
|
||||||
for (auto item : m_itemList)
|
|
||||||
{
|
|
||||||
item->refershIcon();
|
|
||||||
item->update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemController::updatePluginsItemOrderKey()
|
|
||||||
{
|
|
||||||
Q_ASSERT(sender() == m_updatePluginsOrderTimer);
|
|
||||||
|
|
||||||
int index = 0;
|
|
||||||
for (auto item : m_itemList)
|
|
||||||
{
|
|
||||||
DockItem::ItemType tyep = item->itemType();
|
|
||||||
if (item.isNull() || (tyep != DockItem::Plugins && tyep != DockItem::TrayPlugin))
|
|
||||||
continue;
|
|
||||||
static_cast<PluginsItem *>(item.data())->setItemSortKey(++index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemController::itemMove(DockItem * const moveItem, DockItem * const replaceItem)
|
|
||||||
{
|
|
||||||
Q_ASSERT(moveItem != replaceItem);
|
|
||||||
|
|
||||||
const DockItem::ItemType moveType = moveItem->itemType();
|
|
||||||
const DockItem::ItemType replaceType = replaceItem->itemType();
|
|
||||||
|
|
||||||
// app move
|
|
||||||
if (moveType == DockItem::App || moveType == DockItem::Placeholder)
|
|
||||||
if (replaceType != DockItem::App && replaceType != DockItem::Stretch)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// plugins move
|
|
||||||
if (moveType == DockItem::Plugins || moveType == DockItem::TrayPlugin)
|
|
||||||
if (replaceType != DockItem::Plugins && replaceType != DockItem::TrayPlugin)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const int moveIndex = m_itemList.indexOf(moveItem);
|
|
||||||
const int replaceIndex = replaceType == DockItem::Stretch ?
|
|
||||||
// disable insert after placeholder item
|
|
||||||
m_itemList.indexOf(replaceItem) - 1 :
|
|
||||||
m_itemList.indexOf(replaceItem);
|
|
||||||
|
|
||||||
m_itemList.removeAt(moveIndex);
|
|
||||||
m_itemList.insert(replaceIndex, moveItem);
|
|
||||||
emit itemMoved(moveItem, replaceIndex);
|
|
||||||
|
|
||||||
// update plugins sort key if order changed
|
|
||||||
if (moveType == DockItem::Plugins || replaceType == DockItem::Plugins
|
|
||||||
|| moveType == DockItem::TrayPlugin || replaceType == DockItem::TrayPlugin)
|
|
||||||
m_updatePluginsOrderTimer->start();
|
|
||||||
|
|
||||||
// for app move, index 0 is launcher item, need to pass it.
|
|
||||||
if (moveType == DockItem::App && replaceType == DockItem::App)
|
|
||||||
m_appInter->MoveEntry(moveIndex - 1, replaceIndex - 1);
|
|
||||||
|
|
||||||
refreshFSTItemSpliterVisible();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemController::itemDroppedIntoContainer(DockItem * const item)
|
|
||||||
{
|
|
||||||
Q_ASSERT(item->itemType() == DockItem::Plugins || item->itemType() == DockItem::TrayPlugin);
|
|
||||||
|
|
||||||
PluginsItem *pi = static_cast<PluginsItem *>(item);
|
|
||||||
|
|
||||||
if (!pi->allowContainer())
|
|
||||||
return;
|
|
||||||
if (m_containerItem->contains(item))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// qDebug() << "drag into container" << item;
|
|
||||||
|
|
||||||
// remove from main panel
|
|
||||||
emit itemRemoved(item);
|
|
||||||
m_itemList.removeOne(item);
|
|
||||||
|
|
||||||
// add to container
|
|
||||||
pi->setInContainer(true);
|
|
||||||
m_containerItem->addItem(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemController::itemDragOutFromContainer(DockItem * const item)
|
|
||||||
{
|
|
||||||
// qDebug() << "drag out from container" << item;
|
|
||||||
|
|
||||||
// remove from container
|
|
||||||
m_containerItem->removeItem(item);
|
|
||||||
|
|
||||||
// insert to panel
|
|
||||||
switch (item->itemType())
|
|
||||||
{
|
|
||||||
case DockItem::Plugins:
|
|
||||||
case DockItem::TrayPlugin:
|
|
||||||
static_cast<PluginsItem *>(item)->setInContainer(false);
|
|
||||||
pluginItemInserted(static_cast<PluginsItem *>(item));
|
|
||||||
break;
|
|
||||||
default: Q_UNREACHABLE();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemController::placeholderItemAdded(PlaceholderItem *item, DockItem *position)
|
|
||||||
{
|
|
||||||
const int pos = m_itemList.indexOf(position);
|
|
||||||
|
|
||||||
m_itemList.insert(pos, item);
|
|
||||||
|
|
||||||
emit itemInserted(pos, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemController::placeholderItemDocked(const QString &appDesktop, DockItem *position)
|
|
||||||
{
|
|
||||||
m_appInter->RequestDock(appDesktop, m_itemList.indexOf(position) - 1).waitForFinished();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemController::placeholderItemRemoved(PlaceholderItem *item)
|
|
||||||
{
|
|
||||||
emit itemRemoved(item);
|
|
||||||
|
|
||||||
m_itemList.removeOne(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
// refresh right spliter visible of fashion tray plugin item
|
|
||||||
void DockItemController::refreshFSTItemSpliterVisible()
|
|
||||||
{
|
|
||||||
if (DockSettings::Instance().displayMode() != Dock::DisplayMode::Fashion) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < m_itemList.size(); ++i) {
|
|
||||||
if (m_itemList.at(i)->itemType() == DockItem::ItemType::TrayPlugin) {
|
|
||||||
static_cast<TrayPluginItem *>(m_itemList.at(i).data())
|
|
||||||
->setRightSplitVisible(i != (m_itemList.size() - 1));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DockItemController::DockItemController(QObject *parent)
|
|
||||||
: QObject(parent),
|
|
||||||
m_updatePluginsOrderTimer(new QTimer(this)),
|
|
||||||
m_appInter(new DBusDock("com.deepin.dde.daemon.Dock", "/com/deepin/dde/daemon/Dock", QDBusConnection::sessionBus(), this)),
|
|
||||||
m_pluginsInter(new DockPluginsController(this)),
|
|
||||||
m_placeholderItem(new StretchItem),
|
|
||||||
m_containerItem(new ContainerItem)
|
|
||||||
{
|
|
||||||
// m_placeholderItem->hide();
|
|
||||||
|
|
||||||
m_updatePluginsOrderTimer->setSingleShot(true);
|
|
||||||
m_updatePluginsOrderTimer->setInterval(1000);
|
|
||||||
|
|
||||||
m_itemList.append(new LauncherItem);
|
|
||||||
for (auto entry : m_appInter->entries())
|
|
||||||
{
|
|
||||||
AppItem *it = new AppItem(entry);
|
|
||||||
|
|
||||||
connect(it, &AppItem::requestActivateWindow, m_appInter, &DBusDock::ActivateWindow, Qt::QueuedConnection);
|
|
||||||
connect(it, &AppItem::requestPreviewWindow, m_appInter, &DBusDock::PreviewWindow);
|
|
||||||
connect(it, &AppItem::requestCancelPreview, m_appInter, &DBusDock::CancelPreviewWindow);
|
|
||||||
|
|
||||||
m_itemList.append(it);
|
|
||||||
}
|
|
||||||
m_itemList.append(m_placeholderItem);
|
|
||||||
m_itemList.append(m_containerItem);
|
|
||||||
|
|
||||||
connect(m_updatePluginsOrderTimer, &QTimer::timeout, this, &DockItemController::updatePluginsItemOrderKey);
|
|
||||||
|
|
||||||
connect(m_appInter, &DBusDock::EntryAdded, this, &DockItemController::appItemAdded);
|
|
||||||
connect(m_appInter, &DBusDock::EntryRemoved, this, static_cast<void (DockItemController::*)(const QString &)>(&DockItemController::appItemRemoved), Qt::QueuedConnection);
|
|
||||||
connect(m_appInter, &DBusDock::ServiceRestarted, this, &DockItemController::reloadAppItems);
|
|
||||||
|
|
||||||
connect(m_pluginsInter, &DockPluginsController::pluginItemInserted, this, &DockItemController::pluginItemInserted, Qt::QueuedConnection);
|
|
||||||
connect(m_pluginsInter, &DockPluginsController::pluginItemRemoved, this, &DockItemController::pluginItemRemoved, Qt::QueuedConnection);
|
|
||||||
connect(m_pluginsInter, &DockPluginsController::pluginItemUpdated, this, &DockItemController::itemUpdated, Qt::QueuedConnection);
|
|
||||||
connect(m_pluginsInter, &DockPluginsController::fashionTraySizeChanged, this, &DockItemController::fashionTraySizeChanged, Qt::QueuedConnection);
|
|
||||||
|
|
||||||
QMetaObject::invokeMethod(this, "refershItemsIcon", Qt::QueuedConnection);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemController::appItemAdded(const QDBusObjectPath &path, const int index)
|
|
||||||
{
|
|
||||||
// the first index is launcher item
|
|
||||||
int insertIndex = 1;
|
|
||||||
|
|
||||||
// -1 for append to app list end
|
|
||||||
if (index != -1)
|
|
||||||
{
|
|
||||||
insertIndex += index;
|
|
||||||
} else {
|
|
||||||
for (auto item : m_itemList)
|
|
||||||
if (item->itemType() == DockItem::App)
|
|
||||||
++insertIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
AppItem *item = new AppItem(path);
|
|
||||||
|
|
||||||
connect(item, &AppItem::requestActivateWindow, m_appInter, &DBusDock::ActivateWindow, Qt::QueuedConnection);
|
|
||||||
connect(item, &AppItem::requestPreviewWindow, m_appInter, &DBusDock::PreviewWindow);
|
|
||||||
connect(item, &AppItem::requestCancelPreview, m_appInter, &DBusDock::CancelPreviewWindow);
|
|
||||||
|
|
||||||
m_itemList.insert(insertIndex, item);
|
|
||||||
emit itemInserted(insertIndex, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemController::appItemRemoved(const QString &appId)
|
|
||||||
{
|
|
||||||
for (int i(0); i != m_itemList.size(); ++i)
|
|
||||||
{
|
|
||||||
if (m_itemList[i]->itemType() != DockItem::App)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
AppItem *app = static_cast<AppItem *>(m_itemList[i].data());
|
|
||||||
if (!app) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!app->isValid() || app->appId() == appId) {
|
|
||||||
appItemRemoved(app);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemController::appItemRemoved(AppItem *appItem)
|
|
||||||
{
|
|
||||||
emit itemRemoved(appItem);
|
|
||||||
m_itemList.removeOne(appItem);
|
|
||||||
appItem->deleteLater();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemController::pluginItemInserted(PluginsItem *item)
|
|
||||||
{
|
|
||||||
// check item is in container
|
|
||||||
if (item->allowContainer() && item->isInContainer())
|
|
||||||
{
|
|
||||||
emit itemManaged(item);
|
|
||||||
return itemDroppedIntoContainer(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
// find first plugins item position
|
|
||||||
int firstPluginPosition = -1;
|
|
||||||
for (int i(0); i != m_itemList.size(); ++i)
|
|
||||||
{
|
|
||||||
DockItem::ItemType type = m_itemList[i]->itemType();
|
|
||||||
if (type != DockItem::Plugins && type != DockItem::TrayPlugin)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
firstPluginPosition = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (firstPluginPosition == -1)
|
|
||||||
firstPluginPosition = m_itemList.size();
|
|
||||||
|
|
||||||
// find insert position
|
|
||||||
int insertIndex = 0;
|
|
||||||
const int itemSortKey = item->itemSortKey();
|
|
||||||
if (itemSortKey == -1 || firstPluginPosition == -1)
|
|
||||||
{
|
|
||||||
insertIndex = m_itemList.size();
|
|
||||||
}
|
|
||||||
else if (itemSortKey == 0)
|
|
||||||
{
|
|
||||||
insertIndex = firstPluginPosition;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
insertIndex = m_itemList.size();
|
|
||||||
for (int i(firstPluginPosition + 1); i != m_itemList.size() + 1; ++i)
|
|
||||||
{
|
|
||||||
PluginsItem *pItem = static_cast<PluginsItem *>(m_itemList[i - 1].data());
|
|
||||||
Q_ASSERT(pItem);
|
|
||||||
|
|
||||||
const int sortKey = pItem->itemSortKey();
|
|
||||||
if (sortKey != -1 && itemSortKey > sortKey)
|
|
||||||
continue;
|
|
||||||
insertIndex = i - 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_itemList.insert(insertIndex, item);
|
|
||||||
emit itemInserted(insertIndex, item);
|
|
||||||
|
|
||||||
refreshFSTItemSpliterVisible();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemController::pluginItemRemoved(PluginsItem *item)
|
|
||||||
{
|
|
||||||
item->hidePopup();
|
|
||||||
|
|
||||||
if (m_containerItem->contains(item))
|
|
||||||
m_containerItem->removeItem(item);
|
|
||||||
else
|
|
||||||
emit itemRemoved(item);
|
|
||||||
|
|
||||||
m_itemList.removeOne(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemController::reloadAppItems()
|
|
||||||
{
|
|
||||||
// remove old item
|
|
||||||
for (auto item : m_itemList)
|
|
||||||
if (item->itemType() == DockItem::App)
|
|
||||||
appItemRemoved(static_cast<AppItem *>(item.data()));
|
|
||||||
|
|
||||||
// append new item
|
|
||||||
for (auto path : m_appInter->entries())
|
|
||||||
appItemAdded(path, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemController::sortPluginItems()
|
|
||||||
{
|
|
||||||
int firstPluginIndex = -1;
|
|
||||||
for (int i(0); i != m_itemList.size(); ++i)
|
|
||||||
{
|
|
||||||
DockItem::ItemType type = m_itemList[i]->itemType();
|
|
||||||
if (type == DockItem::Plugins || type == DockItem::TrayPlugin)
|
|
||||||
{
|
|
||||||
firstPluginIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (firstPluginIndex == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
std::sort(m_itemList.begin() + firstPluginIndex, m_itemList.end(), [](DockItem *a, DockItem *b) -> bool {
|
|
||||||
PluginsItem *pa = static_cast<PluginsItem *>(a);
|
|
||||||
PluginsItem *pb = static_cast<PluginsItem *>(b);
|
|
||||||
|
|
||||||
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 itemMoved(m_itemList[i], i);
|
|
||||||
}
|
|
@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
|
||||||
*
|
|
||||||
* Author: sbw <sbw@sbw.so>
|
|
||||||
*
|
|
||||||
* Maintainer: sbw <sbw@sbw.so>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef DOCKITEMCONTROLLER_H
|
|
||||||
#define DOCKITEMCONTROLLER_H
|
|
||||||
|
|
||||||
#include "dockpluginscontroller.h"
|
|
||||||
#include "pluginsiteminterface.h"
|
|
||||||
#include "item/dockitem.h"
|
|
||||||
#include "item/stretchitem.h"
|
|
||||||
#include "item/appitem.h"
|
|
||||||
#include "item/placeholderitem.h"
|
|
||||||
#include "item/containeritem.h"
|
|
||||||
|
|
||||||
#include <com_deepin_dde_daemon_dock.h>
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
using DBusDock = com::deepin::dde::daemon::Dock;
|
|
||||||
|
|
||||||
class DockItemController : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
static DockItemController *instance(QObject *parent = nullptr);
|
|
||||||
|
|
||||||
const QList<QPointer<DockItem> > itemList() const;
|
|
||||||
const QList<PluginsItemInterface *> pluginList() const;
|
|
||||||
bool appIsOnDock(const QString &appDesktop) const;
|
|
||||||
bool itemIsInContainer(DockItem * const item) const;
|
|
||||||
void setDropping(const bool dropping);
|
|
||||||
void startLoadPlugins() const;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void itemInserted(const int index, DockItem *item) const;
|
|
||||||
void itemRemoved(DockItem *item) const;
|
|
||||||
void itemMoved(DockItem *item, const int index) const;
|
|
||||||
void itemManaged(DockItem *item) const;
|
|
||||||
void itemUpdated(DockItem *item) const;
|
|
||||||
void fashionTraySizeChanged(const QSize &traySize) const;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void refershItemsIcon();
|
|
||||||
void sortPluginItems();
|
|
||||||
void updatePluginsItemOrderKey();
|
|
||||||
void itemMove(DockItem * const moveItem, DockItem * const replaceItem);
|
|
||||||
void itemDroppedIntoContainer(DockItem * const item);
|
|
||||||
void itemDragOutFromContainer(DockItem * const item);
|
|
||||||
void placeholderItemAdded(PlaceholderItem *item, DockItem *position);
|
|
||||||
void placeholderItemDocked(const QString &appDesktop, DockItem *position);
|
|
||||||
void placeholderItemRemoved(PlaceholderItem *item);
|
|
||||||
void refreshFSTItemSpliterVisible();
|
|
||||||
|
|
||||||
private:
|
|
||||||
explicit DockItemController(QObject *parent = nullptr);
|
|
||||||
void appItemAdded(const QDBusObjectPath &path, const int index);
|
|
||||||
void appItemRemoved(const QString &appId);
|
|
||||||
void appItemRemoved(AppItem *appItem);
|
|
||||||
void pluginItemInserted(PluginsItem *item);
|
|
||||||
void pluginItemRemoved(PluginsItem *item);
|
|
||||||
void reloadAppItems();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QTimer *m_updatePluginsOrderTimer;
|
|
||||||
DBusDock *m_appInter;
|
|
||||||
DockPluginsController *m_pluginsInter;
|
|
||||||
StretchItem *m_placeholderItem;
|
|
||||||
ContainerItem *m_containerItem;
|
|
||||||
|
|
||||||
static DockItemController *INSTANCE;
|
|
||||||
|
|
||||||
QList<QPointer<DockItem>> m_itemList;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DOCKITEMCONTROLLER_H
|
|
@ -21,12 +21,10 @@
|
|||||||
|
|
||||||
#include "dockitemmanager.h"
|
#include "dockitemmanager.h"
|
||||||
#include "item/appitem.h"
|
#include "item/appitem.h"
|
||||||
#include "item/stretchitem.h"
|
|
||||||
#include "item/launcheritem.h"
|
#include "item/launcheritem.h"
|
||||||
#include "item/pluginsitem.h"
|
#include "item/pluginsitem.h"
|
||||||
#include "item/traypluginitem.h"
|
#include "item/traypluginitem.h"
|
||||||
#include "util/docksettings.h"
|
#include "util/docksettings.h"
|
||||||
#include "item/showdesktopitem.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QGSettings>
|
#include <QGSettings>
|
||||||
@ -38,7 +36,6 @@ DockItemManager::DockItemManager(QObject *parent)
|
|||||||
, m_updatePluginsOrderTimer(new QTimer(this))
|
, m_updatePluginsOrderTimer(new QTimer(this))
|
||||||
, m_appInter(new DBusDock("com.deepin.dde.daemon.Dock", "/com/deepin/dde/daemon/Dock", QDBusConnection::sessionBus(), this))
|
, m_appInter(new DBusDock("com.deepin.dde.daemon.Dock", "/com/deepin/dde/daemon/Dock", QDBusConnection::sessionBus(), this))
|
||||||
, m_pluginsInter(new DockPluginsController(this))
|
, m_pluginsInter(new DockPluginsController(this))
|
||||||
, m_containerItem(new ContainerItem)
|
|
||||||
{
|
{
|
||||||
//固定区域:启动器
|
//固定区域:启动器
|
||||||
m_itemList.append(new LauncherItem);
|
m_itemList.append(new LauncherItem);
|
||||||
@ -101,16 +98,6 @@ bool DockItemManager::appIsOnDock(const QString &appDesktop) const
|
|||||||
return m_appInter->IsOnDock(appDesktop);
|
return m_appInter->IsOnDock(appDesktop);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DockItemManager::itemIsInContainer(DockItem *const item) const
|
|
||||||
{
|
|
||||||
return m_containerItem->contains(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemManager::setDropping(const bool dropping)
|
|
||||||
{
|
|
||||||
m_containerItem->setDropping(dropping);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemManager::startLoadPlugins() const
|
void DockItemManager::startLoadPlugins() const
|
||||||
{
|
{
|
||||||
QGSettings gsetting("com.deepin.dde.dock", "/com/deepin/dde/dock/");
|
QGSettings gsetting("com.deepin.dde.dock", "/com/deepin/dde/dock/");
|
||||||
@ -155,7 +142,7 @@ void DockItemManager::itemMoved(DockItem *const sourceItem, DockItem *const targ
|
|||||||
|
|
||||||
// app move
|
// app move
|
||||||
if (moveType == DockItem::App || moveType == DockItem::Placeholder)
|
if (moveType == DockItem::App || moveType == DockItem::Placeholder)
|
||||||
if (replaceType != DockItem::App && replaceType != DockItem::Stretch)
|
if (replaceType != DockItem::App)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// plugins move
|
// plugins move
|
||||||
@ -164,10 +151,7 @@ void DockItemManager::itemMoved(DockItem *const sourceItem, DockItem *const targ
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const int moveIndex = m_itemList.indexOf(sourceItem);
|
const int moveIndex = m_itemList.indexOf(sourceItem);
|
||||||
const int replaceIndex = replaceType == DockItem::Stretch ?
|
const int replaceIndex = m_itemList.indexOf(targetItem);
|
||||||
// disable insert after placeholder item
|
|
||||||
m_itemList.indexOf(targetItem) - 1 :
|
|
||||||
m_itemList.indexOf(targetItem);
|
|
||||||
|
|
||||||
m_itemList.removeAt(moveIndex);
|
m_itemList.removeAt(moveIndex);
|
||||||
m_itemList.insert(replaceIndex, sourceItem);
|
m_itemList.insert(replaceIndex, sourceItem);
|
||||||
@ -190,44 +174,6 @@ void DockItemManager::itemAdded(const QString &appDesktop, int idx)
|
|||||||
m_appInter->RequestDock(appDesktop, idx);
|
m_appInter->RequestDock(appDesktop, idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DockItemManager::itemDroppedIntoContainer(DockItem *const item)
|
|
||||||
{
|
|
||||||
Q_ASSERT(item->itemType() == DockItem::Plugins || item->itemType() == DockItem::TrayPlugin);
|
|
||||||
|
|
||||||
PluginsItem *pi = static_cast<PluginsItem *>(item);
|
|
||||||
|
|
||||||
if (!pi->allowContainer())
|
|
||||||
return;
|
|
||||||
if (m_containerItem->contains(item))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// remove from main panel
|
|
||||||
emit itemRemoved(item);
|
|
||||||
m_itemList.removeOne(item);
|
|
||||||
|
|
||||||
// add to container
|
|
||||||
pi->setInContainer(true);
|
|
||||||
m_containerItem->addItem(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DockItemManager::itemDragOutFromContainer(DockItem *const item)
|
|
||||||
{
|
|
||||||
// qDebug() << "drag out from container" << item;
|
|
||||||
|
|
||||||
// remove from container
|
|
||||||
m_containerItem->removeItem(item);
|
|
||||||
|
|
||||||
// insert to panel
|
|
||||||
switch (item->itemType()) {
|
|
||||||
case DockItem::Plugins:
|
|
||||||
case DockItem::TrayPlugin:
|
|
||||||
static_cast<PluginsItem *>(item)->setInContainer(false);
|
|
||||||
pluginItemInserted(static_cast<PluginsItem *>(item));
|
|
||||||
break;
|
|
||||||
default: Q_UNREACHABLE();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// refresh right spliter visible of fashion tray plugin item
|
// refresh right spliter visible of fashion tray plugin item
|
||||||
void DockItemManager::refreshFSTItemSpliterVisible()
|
void DockItemManager::refreshFSTItemSpliterVisible()
|
||||||
{
|
{
|
||||||
@ -296,11 +242,6 @@ void DockItemManager::pluginItemInserted(PluginsItem *item)
|
|||||||
{
|
{
|
||||||
manageItem(item);
|
manageItem(item);
|
||||||
|
|
||||||
// check item is in container
|
|
||||||
if (item->allowContainer() && item->isInContainer()) {
|
|
||||||
return itemDroppedIntoContainer(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
// find first plugins item position
|
// find first plugins item position
|
||||||
int firstPluginPosition = -1;
|
int firstPluginPosition = -1;
|
||||||
for (int i(0); i != m_itemList.size(); ++i) {
|
for (int i(0); i != m_itemList.size(); ++i) {
|
||||||
@ -350,10 +291,7 @@ void DockItemManager::pluginItemRemoved(PluginsItem *item)
|
|||||||
{
|
{
|
||||||
item->hidePopup();
|
item->hidePopup();
|
||||||
|
|
||||||
if (m_containerItem->contains(item))
|
emit itemRemoved(item);
|
||||||
m_containerItem->removeItem(item);
|
|
||||||
else
|
|
||||||
emit itemRemoved(item);
|
|
||||||
|
|
||||||
m_itemList.removeOne(item);
|
m_itemList.removeOne(item);
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,8 @@
|
|||||||
#include "dockpluginscontroller.h"
|
#include "dockpluginscontroller.h"
|
||||||
#include "pluginsiteminterface.h"
|
#include "pluginsiteminterface.h"
|
||||||
#include "item/dockitem.h"
|
#include "item/dockitem.h"
|
||||||
#include "item/stretchitem.h"
|
|
||||||
#include "item/appitem.h"
|
#include "item/appitem.h"
|
||||||
#include "item/placeholderitem.h"
|
#include "item/placeholderitem.h"
|
||||||
#include "item/containeritem.h"
|
|
||||||
|
|
||||||
#include <com_deepin_dde_daemon_dock.h>
|
#include <com_deepin_dde_daemon_dock.h>
|
||||||
|
|
||||||
@ -46,8 +44,6 @@ public:
|
|||||||
const QList<QPointer<DockItem> > itemList() const;
|
const QList<QPointer<DockItem> > itemList() const;
|
||||||
const QList<PluginsItemInterface *> pluginList() const;
|
const QList<PluginsItemInterface *> pluginList() const;
|
||||||
bool appIsOnDock(const QString &appDesktop) const;
|
bool appIsOnDock(const QString &appDesktop) const;
|
||||||
bool itemIsInContainer(DockItem *const item) const;
|
|
||||||
void setDropping(const bool dropping);
|
|
||||||
void startLoadPlugins() const;
|
void startLoadPlugins() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -64,8 +60,6 @@ public slots:
|
|||||||
void updatePluginsItemOrderKey();
|
void updatePluginsItemOrderKey();
|
||||||
void itemMoved(DockItem *const sourceItem, DockItem *const targetItem);
|
void itemMoved(DockItem *const sourceItem, DockItem *const targetItem);
|
||||||
void itemAdded(const QString &appDesktop, int idx);
|
void itemAdded(const QString &appDesktop, int idx);
|
||||||
void itemDroppedIntoContainer(DockItem *const item);
|
|
||||||
void itemDragOutFromContainer(DockItem *const item);
|
|
||||||
void refreshFSTItemSpliterVisible();
|
void refreshFSTItemSpliterVisible();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -82,8 +76,6 @@ private:
|
|||||||
QTimer *m_updatePluginsOrderTimer;
|
QTimer *m_updatePluginsOrderTimer;
|
||||||
DBusDock *m_appInter;
|
DBusDock *m_appInter;
|
||||||
DockPluginsController *m_pluginsInter;
|
DockPluginsController *m_pluginsInter;
|
||||||
StretchItem *m_placeholderItem;
|
|
||||||
ContainerItem *m_containerItem;
|
|
||||||
|
|
||||||
static DockItemManager *INSTANCE;
|
static DockItemManager *INSTANCE;
|
||||||
|
|
||||||
|
@ -1,91 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
|
||||||
*
|
|
||||||
* Author: sbw <sbw@sbw.so>
|
|
||||||
*
|
|
||||||
* Maintainer: sbw <sbw@sbw.so>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "constants.h"
|
|
||||||
#include "containerwidget.h"
|
|
||||||
#include "item/pluginsitem.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QDragEnterEvent>
|
|
||||||
|
|
||||||
#define ITEM_HEIGHT 30
|
|
||||||
#define ITEM_WIDTH 30
|
|
||||||
|
|
||||||
ContainerWidget::ContainerWidget(QWidget *parent)
|
|
||||||
: QWidget(parent),
|
|
||||||
|
|
||||||
m_centralLayout(new QHBoxLayout)
|
|
||||||
{
|
|
||||||
m_centralLayout->addStretch();
|
|
||||||
m_centralLayout->setSpacing(0);
|
|
||||||
m_centralLayout->setMargin(0);
|
|
||||||
|
|
||||||
setLayout(m_centralLayout);
|
|
||||||
setFixedHeight(ITEM_HEIGHT);
|
|
||||||
setFixedWidth(ITEM_WIDTH);
|
|
||||||
setAcceptDrops(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContainerWidget::addWidget(QWidget * const w)
|
|
||||||
{
|
|
||||||
w->setParent(this);
|
|
||||||
w->setFixedSize(ITEM_WIDTH, ITEM_HEIGHT);
|
|
||||||
m_centralLayout->addWidget(w);
|
|
||||||
m_itemList.append(w);
|
|
||||||
|
|
||||||
setFixedWidth(ITEM_WIDTH * std::max(1, m_itemList.size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContainerWidget::removeWidget(QWidget * const w)
|
|
||||||
{
|
|
||||||
m_centralLayout->removeWidget(w);
|
|
||||||
m_itemList.removeOne(w);
|
|
||||||
|
|
||||||
setFixedWidth(ITEM_WIDTH * std::max(1, m_itemList.size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
int ContainerWidget::itemCount() const
|
|
||||||
{
|
|
||||||
return m_itemList.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ContainerWidget::allowDragEnter(QDragEnterEvent *e)
|
|
||||||
{
|
|
||||||
if (!e->mimeData()->hasFormat(DOCK_PLUGIN_MIME))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
PluginsItem *pi = static_cast<PluginsItem *>(e->source());
|
|
||||||
if (pi && pi->allowContainer())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContainerWidget::dragEnterEvent(QDragEnterEvent *e)
|
|
||||||
{
|
|
||||||
if (allowDragEnter(e))
|
|
||||||
return e->accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContainerWidget::mousePressEvent(QMouseEvent *e)
|
|
||||||
{
|
|
||||||
e->ignore();
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
|
||||||
*
|
|
||||||
* Author: sbw <sbw@sbw.so>
|
|
||||||
*
|
|
||||||
* Maintainer: sbw <sbw@sbw.so>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef CONTAINERWIDGET_H
|
|
||||||
#define CONTAINERWIDGET_H
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QHBoxLayout>
|
|
||||||
|
|
||||||
class ContainerWidget : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit ContainerWidget(QWidget *parent = 0);
|
|
||||||
|
|
||||||
void addWidget(QWidget * const w);
|
|
||||||
void removeWidget(QWidget * const w);
|
|
||||||
int itemCount() const;
|
|
||||||
|
|
||||||
inline bool contains(QWidget *w) const { return m_itemList.contains(w); }
|
|
||||||
bool allowDragEnter(QDragEnterEvent *e);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void dragEnterEvent(QDragEnterEvent *e);
|
|
||||||
void mousePressEvent(QMouseEvent *e);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QHBoxLayout *m_centralLayout;
|
|
||||||
|
|
||||||
QList<QWidget *> m_itemList;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CONTAINERWIDGET_H
|
|
@ -1,136 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
|
||||||
*
|
|
||||||
* Author: sbw <sbw@sbw.so>
|
|
||||||
*
|
|
||||||
* Maintainer: sbw <sbw@sbw.so>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "containeritem.h"
|
|
||||||
|
|
||||||
#include <QPainter>
|
|
||||||
|
|
||||||
ContainerItem::ContainerItem(QWidget *parent)
|
|
||||||
: DockItem(parent),
|
|
||||||
m_dropping(false),
|
|
||||||
m_popupTips(new TipsWidget(this)),
|
|
||||||
m_containerWidget(new ContainerWidget(this))
|
|
||||||
{
|
|
||||||
m_containerWidget->setVisible(false);
|
|
||||||
m_popupTips->setText(tr("Click to display hidden icon"));
|
|
||||||
m_popupTips->setVisible(false);
|
|
||||||
m_popupTips->setObjectName("ContainerItem");
|
|
||||||
|
|
||||||
setAcceptDrops(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContainerItem::setDropping(const bool dropping)
|
|
||||||
{
|
|
||||||
if (dropping)
|
|
||||||
showPopupApplet(m_containerWidget);
|
|
||||||
// else
|
|
||||||
// hidePopup();
|
|
||||||
|
|
||||||
m_dropping = dropping;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContainerItem::addItem(DockItem * const item)
|
|
||||||
{
|
|
||||||
m_containerWidget->addWidget(item);
|
|
||||||
item->setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContainerItem::removeItem(DockItem * const item)
|
|
||||||
{
|
|
||||||
m_containerWidget->removeWidget(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ContainerItem::contains(DockItem * const item)
|
|
||||||
{
|
|
||||||
if (m_containerWidget->contains(item))
|
|
||||||
{
|
|
||||||
// reset parent to container.
|
|
||||||
if (item->parent() != m_containerWidget)
|
|
||||||
item->setParent(m_containerWidget);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContainerItem::refershIcon()
|
|
||||||
{
|
|
||||||
QPixmap icon;
|
|
||||||
const auto ratio = devicePixelRatioF();
|
|
||||||
const QSize s = QSize(16, 16) * ratio;
|
|
||||||
switch (DockPosition)
|
|
||||||
{
|
|
||||||
case Top: icon = QIcon(":/icons/resources/arrow-down.svg").pixmap(s); break;
|
|
||||||
case Left: icon = QIcon(":/icons/resources/arrow-right.svg").pixmap(s); break;
|
|
||||||
case Bottom: icon = QIcon(":/icons/resources/arrow-up.svg").pixmap(s); break;
|
|
||||||
case Right: icon = QIcon(":/icons/resources/arrow-left.svg").pixmap(s); break;
|
|
||||||
default: Q_UNREACHABLE();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_icon = icon;
|
|
||||||
m_icon.setDevicePixelRatio(ratio);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContainerItem::dragEnterEvent(QDragEnterEvent *e)
|
|
||||||
{
|
|
||||||
if (m_containerWidget->allowDragEnter(e))
|
|
||||||
return e->accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContainerItem::dragMoveEvent(QDragMoveEvent *e)
|
|
||||||
{
|
|
||||||
Q_UNUSED(e);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContainerItem::paintEvent(QPaintEvent *e)
|
|
||||||
{
|
|
||||||
DockItem::paintEvent(e);
|
|
||||||
|
|
||||||
if (!m_containerWidget->itemCount() && !m_dropping)
|
|
||||||
return;
|
|
||||||
|
|
||||||
QPainter painter(this);
|
|
||||||
painter.drawPixmap(rect().center() - m_icon.rect().center() / m_icon.devicePixelRatioF(), m_icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContainerItem::mouseReleaseEvent(QMouseEvent *e)
|
|
||||||
{
|
|
||||||
if (e->button() == Qt::LeftButton && m_containerWidget->itemCount())
|
|
||||||
return showPopupApplet(m_containerWidget);
|
|
||||||
|
|
||||||
return DockItem::mouseReleaseEvent(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize ContainerItem::sizeHint() const
|
|
||||||
{
|
|
||||||
return QSize(24, 24);
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *ContainerItem::popupTips()
|
|
||||||
{
|
|
||||||
if (m_containerWidget->itemCount())
|
|
||||||
return m_popupTips;
|
|
||||||
else
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
|
||||||
*
|
|
||||||
* Author: sbw <sbw@sbw.so>
|
|
||||||
*
|
|
||||||
* Maintainer: sbw <sbw@sbw.so>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef CONTAINERITEM_H
|
|
||||||
#define CONTAINERITEM_H
|
|
||||||
|
|
||||||
#include "dockitem.h"
|
|
||||||
#include "components/containerwidget.h"
|
|
||||||
#include "../widgets/tipswidget.h"
|
|
||||||
|
|
||||||
#include <QPixmap>
|
|
||||||
|
|
||||||
class ContainerItem : public DockItem
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit ContainerItem(QWidget *parent = 0);
|
|
||||||
|
|
||||||
inline ItemType itemType() const {return Container;}
|
|
||||||
|
|
||||||
void setDropping(const bool dropping);
|
|
||||||
void addItem(DockItem * const item);
|
|
||||||
void removeItem(DockItem * const item);
|
|
||||||
bool contains(DockItem * const item);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void refershIcon();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void dragEnterEvent(QDragEnterEvent *e);
|
|
||||||
void dragMoveEvent(QDragMoveEvent *e);
|
|
||||||
void paintEvent(QPaintEvent *e);
|
|
||||||
void mouseReleaseEvent(QMouseEvent *e);
|
|
||||||
QSize sizeHint() const;
|
|
||||||
QWidget *popupTips();
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool m_dropping;
|
|
||||||
TipsWidget *m_popupTips;
|
|
||||||
ContainerWidget *m_containerWidget;
|
|
||||||
QPixmap m_icon;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CONTAINERITEM_H
|
|
@ -150,10 +150,6 @@ void DockItem::mousePressEvent(QMouseEvent *e)
|
|||||||
hideNonModel();
|
hideNonModel();
|
||||||
|
|
||||||
if (e->button() == Qt::RightButton) {
|
if (e->button() == Qt::RightButton) {
|
||||||
if (itemType() == ItemType::Container) {
|
|
||||||
// ignore this event to MainPanel/MainWindow to show context menu of MainWindow
|
|
||||||
return e->ignore();
|
|
||||||
}
|
|
||||||
if (perfectIconRect().contains(e->pos())) {
|
if (perfectIconRect().contains(e->pos())) {
|
||||||
return showContextMenu();
|
return showContextMenu();
|
||||||
}
|
}
|
||||||
|
@ -43,10 +43,8 @@ public:
|
|||||||
enum ItemType {
|
enum ItemType {
|
||||||
Launcher,
|
Launcher,
|
||||||
App,
|
App,
|
||||||
Stretch,
|
|
||||||
Plugins,
|
Plugins,
|
||||||
FixedPlugin,
|
FixedPlugin,
|
||||||
Container,
|
|
||||||
Placeholder,
|
Placeholder,
|
||||||
TrayPlugin,
|
TrayPlugin,
|
||||||
};
|
};
|
||||||
|
@ -37,12 +37,11 @@
|
|||||||
QPoint PluginsItem::MousePressPoint = QPoint();
|
QPoint PluginsItem::MousePressPoint = QPoint();
|
||||||
|
|
||||||
PluginsItem::PluginsItem(PluginsItemInterface *const pluginInter, const QString &itemKey, QWidget *parent)
|
PluginsItem::PluginsItem(PluginsItemInterface *const pluginInter, const QString &itemKey, QWidget *parent)
|
||||||
: DockItem(parent),
|
: DockItem(parent)
|
||||||
m_pluginInter(pluginInter),
|
, m_pluginInter(pluginInter)
|
||||||
m_centralWidget(m_pluginInter->itemWidget(itemKey)),
|
, m_centralWidget(m_pluginInter->itemWidget(itemKey))
|
||||||
m_itemKey(itemKey),
|
, m_itemKey(itemKey)
|
||||||
m_dragging(false),
|
, m_dragging(false)
|
||||||
m_hover(false)
|
|
||||||
, m_gsettings(nullptr)
|
, m_gsettings(nullptr)
|
||||||
{
|
{
|
||||||
qDebug() << "load plugins item: " << pluginInter->pluginName() << itemKey << m_centralWidget;
|
qDebug() << "load plugins item: " << pluginInter->pluginName() << itemKey << m_centralWidget;
|
||||||
@ -94,27 +93,6 @@ void PluginsItem::detachPluginWidget()
|
|||||||
widget->setParent(nullptr);
|
widget->setParent(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PluginsItem::allowContainer() const
|
|
||||||
{
|
|
||||||
if (DockDisplayMode == Dock::Fashion)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return m_pluginInter->itemAllowContainer(m_itemKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PluginsItem::isInContainer() const
|
|
||||||
{
|
|
||||||
if (DockDisplayMode == Dock::Fashion)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return m_pluginInter->itemIsInContainer(m_itemKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PluginsItem::setInContainer(const bool container)
|
|
||||||
{
|
|
||||||
m_pluginInter->setItemIsInContainer(m_itemKey, container);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString PluginsItem::pluginName() const
|
QString PluginsItem::pluginName() const
|
||||||
{
|
{
|
||||||
return m_pluginInter->pluginName();
|
return m_pluginInter->pluginName();
|
||||||
@ -201,7 +179,7 @@ void PluginsItem::mousePressEvent(QMouseEvent *e)
|
|||||||
m_hover = false;
|
m_hover = false;
|
||||||
update();
|
update();
|
||||||
|
|
||||||
if (!isInContainer() && PopupWindow->isVisible())
|
if (PopupWindow->isVisible())
|
||||||
hideNonModel();
|
hideNonModel();
|
||||||
|
|
||||||
if (e->button() == Qt::LeftButton)
|
if (e->button() == Qt::LeftButton)
|
||||||
@ -310,9 +288,6 @@ void PluginsItem::invokedMenuItem(const QString &itemId, const bool checked)
|
|||||||
|
|
||||||
void PluginsItem::showPopupWindow(QWidget *const content, const bool model)
|
void PluginsItem::showPopupWindow(QWidget *const content, const bool model)
|
||||||
{
|
{
|
||||||
if (isInContainer())
|
|
||||||
return;
|
|
||||||
|
|
||||||
DockItem::showPopupWindow(content, model);
|
DockItem::showPopupWindow(content, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,15 +31,13 @@ class PluginsItem : public DockItem
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PluginsItem(PluginsItemInterface *const pluginInter, const QString &itemKey, QWidget *parent = 0);
|
explicit PluginsItem(PluginsItemInterface *const pluginInter, const QString &itemKey, QWidget *parent = nullptr);
|
||||||
~PluginsItem();
|
~PluginsItem() override;
|
||||||
|
|
||||||
int itemSortKey() const;
|
int itemSortKey() const;
|
||||||
void setItemSortKey(const int order) const;
|
void setItemSortKey(const int order) const;
|
||||||
void detachPluginWidget();
|
void detachPluginWidget();
|
||||||
|
|
||||||
bool allowContainer() const;
|
|
||||||
bool isInContainer() const;
|
|
||||||
void setInContainer(const bool container);
|
void setInContainer(const bool container);
|
||||||
|
|
||||||
QString pluginName() const;
|
QString pluginName() const;
|
||||||
@ -53,7 +51,7 @@ public:
|
|||||||
|
|
||||||
QWidget *centralWidget() const;
|
QWidget *centralWidget() const;
|
||||||
|
|
||||||
virtual void setDraging(bool bDrag);
|
virtual void setDraging(bool bDrag) override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void refershIcon() override;
|
void refershIcon() override;
|
||||||
@ -85,7 +83,6 @@ private:
|
|||||||
|
|
||||||
const QString m_itemKey;
|
const QString m_itemKey;
|
||||||
bool m_dragging;
|
bool m_dragging;
|
||||||
bool m_hover;
|
|
||||||
|
|
||||||
static QPoint MousePressPoint;
|
static QPoint MousePressPoint;
|
||||||
QGSettings *m_gsettings;
|
QGSettings *m_gsettings;
|
||||||
|
@ -1,100 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
|
||||||
*
|
|
||||||
* Author: listenerri <listenerri@gmail.com>
|
|
||||||
*
|
|
||||||
* Maintainer: listenerri <listenerri@gmail.com>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "showdesktopitem.h"
|
|
||||||
#include "constants.h"
|
|
||||||
|
|
||||||
#include <QLayout>
|
|
||||||
#include <QProcess>
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QMouseEvent>
|
|
||||||
|
|
||||||
ShowDesktopItem::ShowDesktopItem(QWidget *parent)
|
|
||||||
: DockItem(parent)
|
|
||||||
, m_isHovered(false)
|
|
||||||
, m_isPressed(false)
|
|
||||||
{
|
|
||||||
setAccessibleName("ShowDesktop");
|
|
||||||
}
|
|
||||||
|
|
||||||
ShowDesktopItem::~ShowDesktopItem()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShowDesktopItem::enterEvent(QEvent *event)
|
|
||||||
{
|
|
||||||
m_isHovered = true;
|
|
||||||
update();
|
|
||||||
|
|
||||||
DockItem::enterEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShowDesktopItem::leaveEvent(QEvent *event)
|
|
||||||
{
|
|
||||||
m_isHovered = false;
|
|
||||||
update();
|
|
||||||
|
|
||||||
DockItem::leaveEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShowDesktopItem::mousePressEvent(QMouseEvent *event)
|
|
||||||
{
|
|
||||||
if (event->button() != Qt::LeftButton) {
|
|
||||||
return DockItem::mousePressEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_isPressed = true;
|
|
||||||
update();
|
|
||||||
|
|
||||||
QProcess::startDetached("/usr/lib/deepin-daemon/desktop-toggle");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShowDesktopItem::mouseReleaseEvent(QMouseEvent *event)
|
|
||||||
{
|
|
||||||
if (event->button() != Qt::LeftButton) {
|
|
||||||
return DockItem::mouseReleaseEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_isPressed = false;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShowDesktopItem::paintEvent(QPaintEvent *event)
|
|
||||||
{
|
|
||||||
Q_UNUSED(event)
|
|
||||||
|
|
||||||
QPainter painter(this);
|
|
||||||
QRect destRect = rect();
|
|
||||||
|
|
||||||
if (width() < height()) {
|
|
||||||
destRect = destRect.marginsRemoved(QMargins(0, 1, 0, 1));
|
|
||||||
} else {
|
|
||||||
destRect = destRect.marginsRemoved(QMargins(1, 0, 1, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_isPressed) {
|
|
||||||
painter.fillRect(destRect, "#2ca7f8");
|
|
||||||
} else if (m_isHovered) {
|
|
||||||
painter.fillRect(destRect, QColor(255, 255, 255, 51));
|
|
||||||
} else {
|
|
||||||
painter.fillRect(destRect, QColor(255, 255, 255, 26));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
|
||||||
*
|
|
||||||
* Author: listenerri <listenerri@gmail.com>
|
|
||||||
*
|
|
||||||
* Maintainer: listenerri <listenerri@gmail.com>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SHOWDESKTOPITEM_H
|
|
||||||
#define SHOWDESKTOPITEM_H
|
|
||||||
|
|
||||||
#include "dockitem.h"
|
|
||||||
|
|
||||||
class ShowDesktopItem : public DockItem
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit ShowDesktopItem(QWidget *parent = nullptr);
|
|
||||||
virtual ~ShowDesktopItem() override;
|
|
||||||
inline ItemType itemType() const override
|
|
||||||
{
|
|
||||||
return Launcher;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void enterEvent(QEvent *event) Q_DECL_OVERRIDE;
|
|
||||||
void leaveEvent(QEvent *event) Q_DECL_OVERRIDE;
|
|
||||||
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
|
||||||
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
|
||||||
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool m_isHovered;
|
|
||||||
bool m_isPressed;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SHOWDESKTOPITEM_H
|
|
@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
|
||||||
*
|
|
||||||
* Author: sbw <sbw@sbw.so>
|
|
||||||
*
|
|
||||||
* Maintainer: sbw <sbw@sbw.so>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "stretchitem.h"
|
|
||||||
|
|
||||||
#include <QPaintEvent>
|
|
||||||
|
|
||||||
StretchItem::StretchItem(QWidget *parent)
|
|
||||||
: DockItem(parent)
|
|
||||||
{
|
|
||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
||||||
setMinimumSize(0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StretchItem::mousePressEvent(QMouseEvent *e)
|
|
||||||
{
|
|
||||||
QWidget::mousePressEvent(e);
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
|
||||||
*
|
|
||||||
* Author: sbw <sbw@sbw.so>
|
|
||||||
*
|
|
||||||
* Maintainer: sbw <sbw@sbw.so>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef STRETCHITEM_H
|
|
||||||
#define STRETCHITEM_H
|
|
||||||
|
|
||||||
#include "dockitem.h"
|
|
||||||
|
|
||||||
class StretchItem : public DockItem
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit StretchItem(QWidget *parent = 0);
|
|
||||||
|
|
||||||
inline ItemType itemType() const {return Stretch;}
|
|
||||||
|
|
||||||
private:
|
|
||||||
void mousePressEvent(QMouseEvent *e);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // STRETCHITEM_H
|
|
@ -161,7 +161,7 @@ PluginsItemInterface::PluginType MultitaskingPlugin::type()
|
|||||||
return PluginType::Fixed;
|
return PluginType::Fixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultitaskingPlugin::updateBatteryVisible()
|
void MultitaskingPlugin::updateVisible()
|
||||||
{
|
{
|
||||||
if (pluginIsDisable())
|
if (pluginIsDisable())
|
||||||
m_proxyInter->itemRemoved(this, PLUGIN_KEY);
|
m_proxyInter->itemRemoved(this, PLUGIN_KEY);
|
||||||
@ -181,7 +181,7 @@ void MultitaskingPlugin::loadPlugin()
|
|||||||
|
|
||||||
m_proxyInter->itemAdded(this, pluginName());
|
m_proxyInter->itemAdded(this, pluginName());
|
||||||
|
|
||||||
updateBatteryVisible();
|
updateVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultitaskingPlugin::refreshPluginItemsVisible()
|
void MultitaskingPlugin::refreshPluginItemsVisible()
|
||||||
@ -193,6 +193,6 @@ void MultitaskingPlugin::refreshPluginItemsVisible()
|
|||||||
loadPlugin();
|
loadPlugin();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
updateBatteryVisible();
|
updateVisible();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ public:
|
|||||||
PluginType type() override;
|
PluginType type() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateBatteryVisible();
|
void updateVisible();
|
||||||
void loadPlugin();
|
void loadPlugin();
|
||||||
void refreshPluginItemsVisible();
|
void refreshPluginItemsVisible();
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ bool ShowDesktopPlugin::pluginIsDisable()
|
|||||||
|
|
||||||
const QString ShowDesktopPlugin::itemCommand(const QString &itemKey)
|
const QString ShowDesktopPlugin::itemCommand(const QString &itemKey)
|
||||||
{
|
{
|
||||||
if (itemKey == POWER_KEY)
|
if (itemKey == pluginName())
|
||||||
QProcess::startDetached("/usr/lib/deepin-daemon/desktop-toggle");
|
QProcess::startDetached("/usr/lib/deepin-daemon/desktop-toggle");
|
||||||
|
|
||||||
return QString();
|
return QString();
|
||||||
@ -91,7 +91,7 @@ const QString ShowDesktopPlugin::itemCommand(const QString &itemKey)
|
|||||||
|
|
||||||
const QString ShowDesktopPlugin::itemContextMenu(const QString &itemKey)
|
const QString ShowDesktopPlugin::itemContextMenu(const QString &itemKey)
|
||||||
{
|
{
|
||||||
if (itemKey != POWER_KEY) {
|
if (itemKey != pluginName()) {
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ void ShowDesktopPlugin::invokedMenuItem(const QString &itemKey, const QString &m
|
|||||||
|
|
||||||
void ShowDesktopPlugin::refreshIcon(const QString &itemKey)
|
void ShowDesktopPlugin::refreshIcon(const QString &itemKey)
|
||||||
{
|
{
|
||||||
if (itemKey == POWER_KEY) {
|
if (itemKey == pluginName()) {
|
||||||
m_showDesktopWidget->refreshIcon();
|
m_showDesktopWidget->refreshIcon();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,12 +161,12 @@ PluginsItemInterface::PluginType ShowDesktopPlugin::type()
|
|||||||
return PluginType::Fixed;
|
return PluginType::Fixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowDesktopPlugin::updateBatteryVisible()
|
void ShowDesktopPlugin::updateVisible()
|
||||||
{
|
{
|
||||||
if (pluginIsDisable())
|
if (pluginIsDisable())
|
||||||
m_proxyInter->itemRemoved(this, POWER_KEY);
|
m_proxyInter->itemRemoved(this, pluginName());
|
||||||
else
|
else
|
||||||
m_proxyInter->itemAdded(this, POWER_KEY);
|
m_proxyInter->itemAdded(this, pluginName());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowDesktopPlugin::loadPlugin()
|
void ShowDesktopPlugin::loadPlugin()
|
||||||
@ -181,18 +181,18 @@ void ShowDesktopPlugin::loadPlugin()
|
|||||||
|
|
||||||
m_proxyInter->itemAdded(this, pluginName());
|
m_proxyInter->itemAdded(this, pluginName());
|
||||||
|
|
||||||
updateBatteryVisible();
|
updateVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowDesktopPlugin::refreshPluginItemsVisible()
|
void ShowDesktopPlugin::refreshPluginItemsVisible()
|
||||||
{
|
{
|
||||||
if (pluginIsDisable()) {
|
if (pluginIsDisable()) {
|
||||||
m_proxyInter->itemRemoved(this, POWER_KEY);
|
m_proxyInter->itemRemoved(this, pluginName());
|
||||||
} else {
|
} else {
|
||||||
if (!m_pluginLoaded) {
|
if (!m_pluginLoaded) {
|
||||||
loadPlugin();
|
loadPlugin();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
updateBatteryVisible();
|
updateVisible();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ public:
|
|||||||
PluginType type() override;
|
PluginType type() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateBatteryVisible();
|
void updateVisible();
|
||||||
void loadPlugin();
|
void loadPlugin();
|
||||||
void refreshPluginItemsVisible();
|
void refreshPluginItemsVisible();
|
||||||
|
|
||||||
|
@ -24,8 +24,6 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#define POWER_KEY "show-desktop"
|
|
||||||
|
|
||||||
class ShowDesktopWidget : public QWidget
|
class ShowDesktopWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -152,31 +152,6 @@ QWidget *TrayPlugin::itemPopupApplet(const QString &itemKey)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TrayPlugin::itemAllowContainer(const QString &itemKey)
|
|
||||||
{
|
|
||||||
Q_UNUSED(itemKey);
|
|
||||||
|
|
||||||
AbstractTrayWidget * const trayWidget = m_trayMap.value(itemKey);
|
|
||||||
|
|
||||||
if (trayWidget && trayWidget->trayTyep() == AbstractTrayWidget::TrayType::SystemTray) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TrayPlugin::itemIsInContainer(const QString &itemKey)
|
|
||||||
{
|
|
||||||
AbstractTrayWidget * const trayWidget = m_trayMap.value(itemKey, nullptr);
|
|
||||||
if (trayWidget == nullptr) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString &key = "container_" + trayWidget->itemKeyForConfig();
|
|
||||||
|
|
||||||
return m_proxyInter->getValue(this, key, false).toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
int TrayPlugin::itemSortKey(const QString &itemKey)
|
int TrayPlugin::itemSortKey(const QString &itemKey)
|
||||||
{
|
{
|
||||||
// 如果是系统托盘图标则调用内部插件的相应接口
|
// 如果是系统托盘图标则调用内部插件的相应接口
|
||||||
@ -216,18 +191,6 @@ void TrayPlugin::setSortKey(const QString &itemKey, const int order)
|
|||||||
m_proxyInter->saveValue(this, key, order);
|
m_proxyInter->saveValue(this, key, order);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrayPlugin::setItemIsInContainer(const QString &itemKey, const bool container)
|
|
||||||
{
|
|
||||||
AbstractTrayWidget * const trayWidget = m_trayMap.value(itemKey, nullptr);
|
|
||||||
if (trayWidget == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString &key = "container_" + trayWidget->itemKeyForConfig();
|
|
||||||
|
|
||||||
m_proxyInter->saveValue(this, key, container);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrayPlugin::refreshIcon(const QString &itemKey)
|
void TrayPlugin::refreshIcon(const QString &itemKey)
|
||||||
{
|
{
|
||||||
if (itemKey == FASHION_MODE_ITEM_KEY) {
|
if (itemKey == FASHION_MODE_ITEM_KEY) {
|
||||||
|
@ -54,11 +54,8 @@ public:
|
|||||||
QWidget *itemWidget(const QString &itemKey) Q_DECL_OVERRIDE;
|
QWidget *itemWidget(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||||
QWidget *itemTipsWidget(const QString &itemKey) Q_DECL_OVERRIDE;
|
QWidget *itemTipsWidget(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||||
QWidget *itemPopupApplet(const QString &itemKey) Q_DECL_OVERRIDE;
|
QWidget *itemPopupApplet(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||||
bool itemAllowContainer(const QString &itemKey) Q_DECL_OVERRIDE;
|
|
||||||
bool itemIsInContainer(const QString &itemKey) Q_DECL_OVERRIDE;
|
|
||||||
int itemSortKey(const QString &itemKey) Q_DECL_OVERRIDE;
|
int itemSortKey(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||||
void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE;
|
void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE;
|
||||||
void setItemIsInContainer(const QString &itemKey, const bool container) Q_DECL_OVERRIDE;
|
|
||||||
void refreshIcon(const QString &itemKey) Q_DECL_OVERRIDE;
|
void refreshIcon(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||||
void pluginSettingsChanged() override;
|
void pluginSettingsChanged() override;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user