mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
feat:add DockItemManager data to MainPanelControl
This commit is contained in:
parent
1f7d63dae4
commit
b92759d379
@ -53,8 +53,6 @@ void DockPluginsController::itemAdded(PluginsItemInterface * const itemInter, co
|
||||
item = new PluginsItem(itemInter, itemKey);
|
||||
}
|
||||
|
||||
item->setVisible(false);
|
||||
|
||||
mPluginsMap[itemInter][itemKey] = item;
|
||||
|
||||
emit pluginItemInserted(item);
|
||||
@ -128,7 +126,8 @@ void DockPluginsController::startLoader()
|
||||
loadSystemPlugins();
|
||||
}
|
||||
|
||||
void DockPluginsController::loadLocalPlugins() {
|
||||
void DockPluginsController::loadLocalPlugins()
|
||||
{
|
||||
QString pluginsDir(QString("%1/.local/lib/dde-dock/plugins/").arg(QDir::homePath()));
|
||||
|
||||
if (!QDir(pluginsDir).exists()) {
|
||||
@ -140,7 +139,8 @@ void DockPluginsController::loadLocalPlugins() {
|
||||
AbstractPluginsController::startLoader(new PluginLoader(pluginsDir, this));
|
||||
}
|
||||
|
||||
void DockPluginsController::loadSystemPlugins() {
|
||||
void DockPluginsController::loadSystemPlugins()
|
||||
{
|
||||
QString pluginsDir(qApp->applicationDirPath() + "/../plugins");
|
||||
if (!QDir(pluginsDir).exists()) {
|
||||
pluginsDir = "/usr/lib/dde-dock/plugins";
|
||||
|
@ -45,8 +45,7 @@ DockItem::DockItem(QWidget *parent)
|
||||
|
||||
m_menuManagerInter(new DBusMenuManager(this))
|
||||
{
|
||||
if (PopupWindow.isNull())
|
||||
{
|
||||
if (PopupWindow.isNull()) {
|
||||
DockPopupWindow *arrowRectangle = new DockPopupWindow(nullptr);
|
||||
arrowRectangle->setShadowBlurRadius(20);
|
||||
arrowRectangle->setRadius(6);
|
||||
@ -69,6 +68,13 @@ DockItem::DockItem(QWidget *parent)
|
||||
connect(m_popupAdjustDelayTimer, &QTimer::timeout, this, &DockItem::updatePopupPosition, Qt::QueuedConnection);
|
||||
|
||||
grabGesture(Qt::TapAndHoldGesture);
|
||||
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
}
|
||||
|
||||
QSize DockItem::sizeHint() const
|
||||
{
|
||||
return QSize(50, 50);
|
||||
}
|
||||
|
||||
DockItem::~DockItem()
|
||||
@ -104,10 +110,8 @@ void DockItem::gestureEvent(QGestureEvent *event)
|
||||
|
||||
bool DockItem::event(QEvent *event)
|
||||
{
|
||||
if (m_popupShown)
|
||||
{
|
||||
switch (event->type())
|
||||
{
|
||||
if (m_popupShown) {
|
||||
switch (event->type()) {
|
||||
case QEvent::Paint:
|
||||
if (!m_popupAdjustDelayTimer->isActive())
|
||||
m_popupAdjustDelayTimer->start();
|
||||
@ -213,8 +217,7 @@ void DockItem::showContextMenu()
|
||||
QDBusPendingReply<QDBusObjectPath> result = m_menuManagerInter->RegisterMenu();
|
||||
|
||||
result.waitForFinished();
|
||||
if (result.isError())
|
||||
{
|
||||
if (result.isError()) {
|
||||
qWarning() << result.error();
|
||||
return;
|
||||
}
|
||||
@ -227,8 +230,7 @@ void DockItem::showContextMenu()
|
||||
menuObject.insert("isDockMenu", QJsonValue(true));
|
||||
menuObject.insert("menuJsonContent", QJsonValue(menuJson));
|
||||
|
||||
switch (DockPosition)
|
||||
{
|
||||
switch (DockPosition) {
|
||||
case Top: menuObject.insert("direction", "top"); break;
|
||||
case Bottom: menuObject.insert("direction", "bottom"); break;
|
||||
case Left: menuObject.insert("direction", "left"); break;
|
||||
@ -285,8 +287,7 @@ void DockItem::showPopupWindow(QWidget * const content, const bool model)
|
||||
if (lastContent)
|
||||
lastContent->setVisible(false);
|
||||
|
||||
switch (DockPosition)
|
||||
{
|
||||
switch (DockPosition) {
|
||||
case Top: popup->setArrowDirection(DockPopupWindow::ArrowTop); break;
|
||||
case Bottom: popup->setArrowDirection(DockPopupWindow::ArrowBottom); break;
|
||||
case Left: popup->setArrowDirection(DockPopupWindow::ArrowLeft); break;
|
||||
@ -357,8 +358,7 @@ const QPoint DockItem::popupMarkPoint() const
|
||||
|
||||
const QRect r = rect();
|
||||
const int offset = 2;
|
||||
switch (DockPosition)
|
||||
{
|
||||
switch (DockPosition) {
|
||||
case Top: p += QPoint(r.width() / 2, r.height() + offset); break;
|
||||
case Bottom: p += QPoint(r.width() / 2, 0 - offset); break;
|
||||
case Left: p += QPoint(r.width() + offset, r.height() / 2); break;
|
||||
|
@ -59,6 +59,8 @@ public:
|
||||
|
||||
inline virtual ItemType itemType() const {Q_UNREACHABLE(); return App;}
|
||||
|
||||
QSize sizeHint() const override;
|
||||
|
||||
public slots:
|
||||
virtual void refershIcon() {}
|
||||
|
||||
|
@ -45,8 +45,7 @@ void RegisterDdeSession()
|
||||
QByteArray cookie = qgetenv(envName.toUtf8().data());
|
||||
qunsetenv(envName.toUtf8().data());
|
||||
|
||||
if (!cookie.isEmpty())
|
||||
{
|
||||
if (!cookie.isEmpty()) {
|
||||
QDBusPendingReply<bool> r = DDBusSender()
|
||||
.interface("com.deepin.SessionManager")
|
||||
.path("/com/deepin/SessionManager")
|
||||
@ -109,7 +108,7 @@ int main(int argc, char *argv[])
|
||||
QTimer::singleShot(1, &mw, &MainWindow::launch);
|
||||
|
||||
if (!parser.isSet(disablePlugOption)) {
|
||||
DockItemController::instance()->startLoadPlugins();
|
||||
DockItemManager::instance()->startLoadPlugins();
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
|
@ -50,7 +50,7 @@ private:
|
||||
void updateAppAreaSonWidgetSize();
|
||||
void updateMainPanelLayout();
|
||||
|
||||
private slots:
|
||||
public slots:
|
||||
void itemInserted(const int index, DockItem *item);
|
||||
void itemRemoved(DockItem *item);
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "panel/mainpanelcontrol.h"
|
||||
#include "controller/dockitemmanager.h"
|
||||
#include "util/utils.h"
|
||||
|
||||
#include <QDebug>
|
||||
@ -107,6 +108,9 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
initConnections();
|
||||
|
||||
m_mainPanel->setFixedSize(m_settings->panelSize());
|
||||
|
||||
for (auto item : DockItemManager::instance()->itemList())
|
||||
m_mainPanel->itemInserted(-1, item);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@ -146,8 +150,7 @@ void MainWindow::launch()
|
||||
|
||||
bool MainWindow::event(QEvent *e)
|
||||
{
|
||||
switch (e->type())
|
||||
{
|
||||
switch (e->type()) {
|
||||
case QEvent::Move:
|
||||
if (!e->spontaneous())
|
||||
QTimer::singleShot(1, this, &MainWindow::positionCheck);
|
||||
@ -196,8 +199,7 @@ void MainWindow::mousePressEvent(QMouseEvent *e)
|
||||
|
||||
void MainWindow::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
switch (e->key())
|
||||
{
|
||||
switch (e->key()) {
|
||||
#ifdef QT_DEBUG
|
||||
case Qt::Key_Escape: qApp->quit(); break;
|
||||
#endif
|
||||
@ -337,8 +339,7 @@ void MainWindow::internalMove(const QPoint &p)
|
||||
const auto ratio = devicePixelRatioF();
|
||||
|
||||
const QRect &r = m_settings->primaryRawRect();
|
||||
switch (m_settings->position())
|
||||
{
|
||||
switch (m_settings->position()) {
|
||||
case Left: rp.setX(r.x()); break;
|
||||
case Top: rp.setY(r.y()); break;
|
||||
case Right: rp.setX(r.right() - 1); break;
|
||||
@ -349,10 +350,8 @@ void MainWindow::internalMove(const QPoint &p)
|
||||
if (m_settings->hideMode() != HideMode::KeepShowing &&
|
||||
isHide &&
|
||||
m_panelHideAni->state() == QVariantAnimation::Stopped &&
|
||||
m_panelShowAni->state() == QVariantAnimation::Stopped)
|
||||
{
|
||||
switch (m_settings->position())
|
||||
{
|
||||
m_panelShowAni->state() == QVariantAnimation::Stopped) {
|
||||
switch (m_settings->position()) {
|
||||
case Top:
|
||||
case Bottom:
|
||||
hx = 2;
|
||||
@ -403,6 +402,9 @@ void MainWindow::initConnections()
|
||||
connect(&m_platformWindowHandle, &DPlatformWindowHandle::frameMarginsChanged, m_shadowMaskOptimizeTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
|
||||
|
||||
connect(m_dbusDaemonInterface, &QDBusConnectionInterface::serviceOwnerChanged, this, &MainWindow::onDbusNameOwnerChanged);
|
||||
|
||||
connect(DockItemManager::instance(), &DockItemManager::itemInserted, m_mainPanel, &MainPanelControl::itemInserted, Qt::DirectConnection);
|
||||
connect(DockItemManager::instance(), &DockItemManager::itemRemoved, m_mainPanel, &MainPanelControl::itemRemoved, Qt::DirectConnection);
|
||||
}
|
||||
|
||||
const QPoint MainWindow::x11GetWindowPos()
|
||||
@ -549,8 +551,7 @@ void MainWindow::setStrutPartial()
|
||||
uint strutEnd = 0;
|
||||
|
||||
QRect strutArea(0, 0, maxScreenWidth, maxScreenHeight);
|
||||
switch (side)
|
||||
{
|
||||
switch (side) {
|
||||
case Position::Top:
|
||||
orientation = XcbMisc::OrientationTop;
|
||||
strut = p.y() + s.height() * ratio;
|
||||
@ -596,8 +597,7 @@ void MainWindow::setStrutPartial()
|
||||
// pass if strut area is intersect with other screen
|
||||
int count = 0;
|
||||
const QRect pr = m_settings->primaryRect();
|
||||
for (auto *screen : qApp->screens())
|
||||
{
|
||||
for (auto *screen : qApp->screens()) {
|
||||
const QRect sr = screen->geometry();
|
||||
if (sr == pr)
|
||||
continue;
|
||||
@ -605,8 +605,7 @@ void MainWindow::setStrutPartial()
|
||||
if (sr.intersects(strutArea))
|
||||
++count;
|
||||
}
|
||||
if (count > 0)
|
||||
{
|
||||
if (count > 0) {
|
||||
qWarning() << "strutArea is intersects with another screen.";
|
||||
qWarning() << maxScreenHeight << maxScreenWidth << side << p << s;
|
||||
return;
|
||||
@ -626,12 +625,10 @@ void MainWindow::expand()
|
||||
|
||||
resetPanelEnvironment(true, false);
|
||||
|
||||
if (showAniState != QPropertyAnimation::Running && m_mainPanel->pos() != m_panelShowAni->currentValue())
|
||||
{
|
||||
if (showAniState != QPropertyAnimation::Running && m_mainPanel->pos() != m_panelShowAni->currentValue()) {
|
||||
QPoint startPos(0, 0);
|
||||
const QSize &size = m_settings->windowSize();
|
||||
switch (m_settings->position())
|
||||
{
|
||||
switch (m_settings->position()) {
|
||||
case Top: startPos.setY(-size.height()); break;
|
||||
case Bottom: startPos.setY(size.height()); break;
|
||||
case Left: startPos.setX(-size.width()); break;
|
||||
@ -651,8 +648,7 @@ void MainWindow::narrow(const Position prevPos)
|
||||
const QSize size = m_settings->panelSize();
|
||||
|
||||
QPoint finishPos(0, 0);
|
||||
switch (prevPos)
|
||||
{
|
||||
switch (prevPos) {
|
||||
case Top: finishPos.setY(-size.height()); break;
|
||||
case Bottom: finishPos.setY(size.height()); break;
|
||||
case Left: finishPos.setX(-size.width()); break;
|
||||
@ -687,8 +683,7 @@ void MainWindow::resetPanelEnvironment(const bool visible, const bool resetPosit
|
||||
if (!resetPosition)
|
||||
return;
|
||||
QPoint finishPos(0, 0);
|
||||
switch (position)
|
||||
{
|
||||
switch (position) {
|
||||
case Top: finishPos.setY((visible ? 0 : -r.height())); break;
|
||||
case Bottom: finishPos.setY(visible ? 0 : r.height()); break;
|
||||
case Left: finishPos.setX((visible ? 0 : -r.width())); break;
|
||||
@ -708,8 +703,7 @@ void MainWindow::updatePanelVisible()
|
||||
|
||||
const Dock::HideState state = m_settings->hideState();
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
if (state != Hide)
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user