2016-06-03 16:06:11 +08:00
|
|
|
#include "appitem.h"
|
|
|
|
|
2016-06-14 16:01:01 +08:00
|
|
|
#include "util/themeappicon.h"
|
2016-06-27 20:16:35 +08:00
|
|
|
#include "util/imagefactory.h"
|
2016-07-22 14:59:43 +08:00
|
|
|
#include "xcb/xcb_misc.h"
|
2016-06-14 16:01:01 +08:00
|
|
|
|
2016-06-03 16:06:11 +08:00
|
|
|
#include <QPainter>
|
2016-06-07 14:40:45 +08:00
|
|
|
#include <QDrag>
|
|
|
|
#include <QMouseEvent>
|
2017-03-28 16:52:38 +08:00
|
|
|
#include <QApplication>
|
2016-06-03 16:06:11 +08:00
|
|
|
|
2016-06-07 14:40:45 +08:00
|
|
|
#define APP_DRAG_THRESHOLD 20
|
|
|
|
|
2016-06-21 17:24:03 +08:00
|
|
|
int AppItem::IconBaseSize;
|
2016-06-15 16:17:51 +08:00
|
|
|
QPoint AppItem::MousePressPos;
|
2016-06-06 14:57:07 +08:00
|
|
|
|
2016-06-03 16:06:11 +08:00
|
|
|
AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
2016-08-08 09:52:05 +08:00
|
|
|
: DockItem(parent),
|
2016-07-18 14:13:36 +08:00
|
|
|
m_appNameTips(new QLabel(this)),
|
2017-03-28 15:44:13 +08:00
|
|
|
m_appPreviewTips(new PreviewContainer(this)),
|
2016-06-07 16:01:37 +08:00
|
|
|
m_itemEntry(new DBusDockEntry(entry.path(), this)),
|
2016-07-12 16:33:01 +08:00
|
|
|
m_draging(false),
|
2016-09-08 15:53:51 +08:00
|
|
|
m_launchingEffects(0.0),
|
2016-07-12 16:33:01 +08:00
|
|
|
m_horizontalIndicator(QPixmap(":/indicator/resources/indicator.png")),
|
|
|
|
m_verticalIndicator(QPixmap(":/indicator/resources/indicator_ver.png")),
|
|
|
|
m_activeHorizontalIndicator(QPixmap(":/indicator/resources/indicator_active.png")),
|
2016-07-22 14:59:43 +08:00
|
|
|
m_activeVerticalIndicator(QPixmap(":/indicator/resources/indicator_active_ver.png")),
|
2016-09-08 15:53:51 +08:00
|
|
|
m_updateIconGeometryTimer(new QTimer(this)),
|
|
|
|
m_launchingEffectsTimer(new QTimer(this))
|
2016-06-03 16:06:11 +08:00
|
|
|
{
|
2016-07-20 15:17:41 +08:00
|
|
|
setAccessibleName(m_itemEntry->name());
|
2016-06-23 14:45:57 +08:00
|
|
|
setAcceptDrops(true);
|
2016-06-06 14:28:28 +08:00
|
|
|
|
2016-06-14 11:22:19 +08:00
|
|
|
m_id = m_itemEntry->id();
|
2016-06-23 14:28:47 +08:00
|
|
|
m_active = m_itemEntry->active();
|
2016-06-06 14:28:28 +08:00
|
|
|
|
2016-07-28 10:59:21 +08:00
|
|
|
m_appNameTips->setObjectName(m_itemEntry->name());
|
2016-07-18 14:13:36 +08:00
|
|
|
m_appNameTips->setVisible(false);
|
|
|
|
m_appNameTips->setStyleSheet("color:white;"
|
2017-03-29 10:48:42 +08:00
|
|
|
"padding:0px 3px;");
|
2016-07-18 14:13:36 +08:00
|
|
|
|
2016-07-22 14:59:43 +08:00
|
|
|
m_updateIconGeometryTimer->setInterval(500);
|
|
|
|
m_updateIconGeometryTimer->setSingleShot(true);
|
|
|
|
|
2016-09-08 15:53:51 +08:00
|
|
|
m_launchingEffectsTimer->setInterval(3000);
|
|
|
|
m_launchingEffectsTimer->setSingleShot(true);
|
|
|
|
|
2016-06-23 14:28:47 +08:00
|
|
|
connect(m_itemEntry, &DBusDockEntry::ActiveChanged, this, &AppItem::activeChanged);
|
2016-06-15 11:20:05 +08:00
|
|
|
connect(m_itemEntry, &DBusDockEntry::TitlesChanged, this, &AppItem::updateTitle);
|
2017-03-13 08:02:33 +08:00
|
|
|
connect(m_itemEntry, &DBusDockEntry::IconChanged, this, &AppItem::refershIcon);
|
2016-06-14 11:22:19 +08:00
|
|
|
connect(m_itemEntry, &DBusDockEntry::ActiveChanged, this, static_cast<void (AppItem::*)()>(&AppItem::update));
|
2016-06-14 16:01:01 +08:00
|
|
|
|
2017-03-28 16:52:38 +08:00
|
|
|
connect(m_appPreviewTips, &PreviewContainer::requestActivateWindow, this, &AppItem::requestActivateWindow);
|
|
|
|
|
2016-07-22 14:59:43 +08:00
|
|
|
connect(m_updateIconGeometryTimer, &QTimer::timeout, this, &AppItem::updateWindowIconGeometries);
|
|
|
|
|
2016-06-15 11:20:05 +08:00
|
|
|
updateTitle();
|
2017-03-13 08:02:33 +08:00
|
|
|
refershIcon();
|
2016-06-14 11:22:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const QString AppItem::appId() const
|
|
|
|
{
|
|
|
|
return m_id;
|
2016-06-03 16:06:11 +08:00
|
|
|
}
|
|
|
|
|
2016-07-22 14:59:43 +08:00
|
|
|
// Update _NET_WM_ICON_GEOMETRY property for windows that every item
|
|
|
|
// that manages, so that WM can do proper animations for specific
|
|
|
|
// window behaviors like minimization.
|
|
|
|
void AppItem::updateWindowIconGeometries()
|
|
|
|
{
|
|
|
|
QRect rect(mapToGlobal(QPoint(0, 0)),
|
|
|
|
mapToGlobal(QPoint(width(),height())));
|
|
|
|
|
|
|
|
if (rect != m_lastGlobalGeometry) {
|
|
|
|
QList<quint32> winIds = m_titles.keys();
|
|
|
|
for (quint32 winId : winIds) {
|
|
|
|
XcbMisc::instance()->set_window_icon_geometry(winId, rect);
|
|
|
|
}
|
|
|
|
m_lastGlobalGeometry = rect;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-21 17:24:03 +08:00
|
|
|
void AppItem::setIconBaseSize(const int size)
|
|
|
|
{
|
|
|
|
IconBaseSize = size;
|
|
|
|
}
|
|
|
|
|
|
|
|
int AppItem::iconBaseSize()
|
|
|
|
{
|
|
|
|
return IconBaseSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
int AppItem::itemBaseWidth()
|
|
|
|
{
|
2016-06-23 14:28:47 +08:00
|
|
|
if (DockDisplayMode == Dock::Fashion)
|
|
|
|
return itemBaseHeight() * 1.1;
|
|
|
|
else
|
|
|
|
return itemBaseHeight() * 1.4;
|
2016-06-21 17:24:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int AppItem::itemBaseHeight()
|
|
|
|
{
|
2016-07-11 17:17:32 +08:00
|
|
|
if (DockDisplayMode == Efficient)
|
|
|
|
return IconBaseSize * 1.2;
|
|
|
|
else
|
|
|
|
return IconBaseSize * 1.5;
|
2016-06-21 17:24:03 +08:00
|
|
|
}
|
|
|
|
|
2016-06-03 16:06:11 +08:00
|
|
|
void AppItem::paintEvent(QPaintEvent *e)
|
|
|
|
{
|
|
|
|
DockItem::paintEvent(e);
|
|
|
|
|
2016-06-23 14:28:47 +08:00
|
|
|
if (m_draging)
|
2016-06-07 16:01:37 +08:00
|
|
|
return;
|
|
|
|
|
2016-06-03 16:06:11 +08:00
|
|
|
QPainter painter(this);
|
2016-06-21 19:25:30 +08:00
|
|
|
if (!painter.isActive())
|
|
|
|
return;
|
2016-09-08 15:53:51 +08:00
|
|
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
|
|
|
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
|
2016-06-21 19:25:30 +08:00
|
|
|
|
|
|
|
const QRect itemRect = rect();
|
2016-06-06 14:28:28 +08:00
|
|
|
|
2016-06-14 16:01:01 +08:00
|
|
|
// draw background
|
2016-07-11 17:17:32 +08:00
|
|
|
QRect backgroundRect = itemRect;
|
|
|
|
if (DockDisplayMode == Efficient)
|
|
|
|
{
|
|
|
|
switch (DockPosition)
|
|
|
|
{
|
|
|
|
case Top:
|
|
|
|
case Bottom:
|
2016-08-09 14:51:03 +08:00
|
|
|
// backgroundRect = itemRect;//.marginsRemoved(QMargins(2, 0, 2, 0));
|
|
|
|
// backgroundRect = itemRect.marginsRemoved(QMargins(0, 1, 0, 1));
|
2016-07-11 17:17:32 +08:00
|
|
|
case Left:
|
|
|
|
case Right:
|
2016-08-09 14:51:03 +08:00
|
|
|
backgroundRect = itemRect.marginsRemoved(QMargins(1, 1, 1, 1));
|
|
|
|
// backgroundRect = itemRect.marginsRemoved(QMargins(1, 0, 1, 0));
|
2016-07-11 17:17:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-23 14:28:47 +08:00
|
|
|
if (DockDisplayMode == Efficient)
|
2016-06-23 10:50:26 +08:00
|
|
|
{
|
2016-06-23 14:28:47 +08:00
|
|
|
if (m_active)
|
2016-06-23 10:50:26 +08:00
|
|
|
{
|
2016-07-11 17:17:32 +08:00
|
|
|
painter.fillRect(backgroundRect, QColor(44, 167, 248, 255 * 0.3));
|
2016-06-23 14:28:47 +08:00
|
|
|
|
2016-07-11 17:17:32 +08:00
|
|
|
const int activeLineWidth = itemRect.height() > 50 ? 4 : 2;
|
2016-06-23 14:28:47 +08:00
|
|
|
QRect activeRect = backgroundRect;
|
|
|
|
switch (DockPosition)
|
|
|
|
{
|
|
|
|
case Top: activeRect.setBottom(activeRect.top() + activeLineWidth); break;
|
|
|
|
case Bottom: activeRect.setTop(activeRect.bottom() - activeLineWidth); break;
|
|
|
|
case Left: activeRect.setRight(activeRect.left() + activeLineWidth); break;
|
|
|
|
case Right: activeRect.setLeft(activeRect.right() - activeLineWidth); break;
|
|
|
|
}
|
|
|
|
|
2016-07-11 17:17:32 +08:00
|
|
|
painter.fillRect(activeRect, QColor(44, 167, 248, 255));
|
2016-06-23 14:28:47 +08:00
|
|
|
}
|
|
|
|
else if (!m_titles.isEmpty())
|
2016-07-11 17:17:32 +08:00
|
|
|
painter.fillRect(backgroundRect, QColor(255, 255, 255, 255 * 0.2));
|
2016-06-23 14:28:47 +08:00
|
|
|
// else
|
|
|
|
// painter.fillRect(backgroundRect, Qt::gray);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!m_titles.isEmpty())
|
|
|
|
{
|
2016-07-12 16:33:01 +08:00
|
|
|
QPoint p;
|
|
|
|
QPixmap pixmap;
|
|
|
|
QPixmap activePixmap;
|
2016-06-23 14:28:47 +08:00
|
|
|
switch (DockPosition)
|
|
|
|
{
|
|
|
|
case Top:
|
2016-07-12 16:33:01 +08:00
|
|
|
pixmap = m_horizontalIndicator;
|
|
|
|
activePixmap = m_activeHorizontalIndicator;
|
|
|
|
p.setX((itemRect.width() - pixmap.width()) / 2);
|
|
|
|
p.setY(1);
|
2016-06-23 14:28:47 +08:00
|
|
|
break;
|
|
|
|
case Bottom:
|
2016-07-12 16:33:01 +08:00
|
|
|
pixmap = m_horizontalIndicator;
|
|
|
|
activePixmap = m_activeHorizontalIndicator;
|
|
|
|
p.setX((itemRect.width() - pixmap.width()) / 2);
|
|
|
|
p.setY(itemRect.height() - pixmap.height() - 1);
|
2016-06-23 14:28:47 +08:00
|
|
|
break;
|
|
|
|
case Left:
|
2016-07-12 16:33:01 +08:00
|
|
|
pixmap = m_verticalIndicator;
|
|
|
|
activePixmap = m_activeVerticalIndicator;
|
|
|
|
p.setX(1);
|
|
|
|
p.setY((itemRect.height() - pixmap.height()) / 2);
|
2016-06-23 14:28:47 +08:00
|
|
|
break;
|
|
|
|
case Right:
|
2016-07-12 16:33:01 +08:00
|
|
|
pixmap = m_verticalIndicator;
|
|
|
|
activePixmap = m_activeVerticalIndicator;
|
|
|
|
p.setX(itemRect.width() - pixmap.width() - 1);
|
|
|
|
p.setY((itemRect.height() - pixmap.height()) / 2);
|
2016-06-23 14:28:47 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-07-12 16:33:01 +08:00
|
|
|
if (m_active)
|
|
|
|
painter.drawPixmap(p, activePixmap);
|
|
|
|
else
|
|
|
|
painter.drawPixmap(p, pixmap);
|
2016-06-23 10:50:26 +08:00
|
|
|
}
|
|
|
|
}
|
2016-06-06 14:28:28 +08:00
|
|
|
|
2016-06-27 20:16:35 +08:00
|
|
|
// icon
|
2016-06-28 13:58:41 +08:00
|
|
|
const QPixmap pixmap = DockDisplayMode == Efficient ? m_smallIcon : m_largeIcon;
|
2016-09-08 15:53:51 +08:00
|
|
|
// icon pos
|
|
|
|
QPointF iconPos = itemRect.center() - pixmap.rect().center();
|
|
|
|
const bool launching = m_launchingEffectsTimer->isActive();
|
|
|
|
|
|
|
|
// add launching effects
|
|
|
|
if (launching)
|
|
|
|
{
|
|
|
|
const double power = 3.0;
|
2016-09-20 17:22:18 +08:00
|
|
|
const double multiple = 1.25;
|
2016-09-08 15:53:51 +08:00
|
|
|
const double offset = std::pow(std::sin(m_launchingEffects) * multiple, power);
|
2016-09-20 17:22:18 +08:00
|
|
|
m_launchingEffects += 0.0008;
|
2016-09-08 15:53:51 +08:00
|
|
|
|
|
|
|
switch (DockPosition)
|
|
|
|
{
|
|
|
|
case Left:
|
|
|
|
case Right: iconPos.setX(iconPos.x() + offset); break;
|
|
|
|
case Top:
|
|
|
|
case Bottom: iconPos.setY(iconPos.y() + offset); break;
|
|
|
|
default:;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-19 10:19:38 +08:00
|
|
|
// draw ligher/normal icon
|
2016-09-08 15:53:51 +08:00
|
|
|
if (launching || !m_hover)
|
|
|
|
painter.drawPixmap(iconPos, pixmap);
|
2016-08-19 10:19:38 +08:00
|
|
|
else
|
2016-09-08 15:53:51 +08:00
|
|
|
painter.drawPixmap(iconPos, ImageFactory::lighterEffect(pixmap));
|
2016-07-22 14:59:43 +08:00
|
|
|
|
2016-09-08 15:53:51 +08:00
|
|
|
if (launching)
|
|
|
|
update();
|
|
|
|
else
|
|
|
|
// Update the window icon geometry when the icon is changed.
|
|
|
|
m_updateIconGeometryTimer->start();
|
2016-06-03 16:06:11 +08:00
|
|
|
}
|
2016-06-06 14:28:28 +08:00
|
|
|
|
|
|
|
void AppItem::mouseReleaseEvent(QMouseEvent *e)
|
|
|
|
{
|
2017-02-15 16:34:30 +08:00
|
|
|
if (e->button() == Qt::MiddleButton) {
|
|
|
|
m_itemEntry->NewInstance();
|
|
|
|
} else if (e->button() == Qt::LeftButton) {
|
2017-03-28 16:52:38 +08:00
|
|
|
// const QPoint distance = MousePressPos - e->pos();
|
|
|
|
// if (distance.manhattanLength() > APP_DRAG_THRESHOLD)
|
|
|
|
// return;
|
2016-09-08 15:53:51 +08:00
|
|
|
|
2017-03-29 09:44:46 +08:00
|
|
|
#ifdef QT_DEBUG
|
2017-03-28 15:44:13 +08:00
|
|
|
const int windowCount = m_titles.size();
|
|
|
|
if (windowCount < 2)
|
|
|
|
m_itemEntry->Activate();
|
|
|
|
else
|
2017-03-28 16:52:38 +08:00
|
|
|
togglePreview();
|
2017-03-29 09:44:46 +08:00
|
|
|
#else
|
|
|
|
m_itemEntry->Activate();
|
|
|
|
#endif
|
2016-09-08 15:53:51 +08:00
|
|
|
|
2017-03-28 15:44:13 +08:00
|
|
|
// if (!m_titles.isEmpty())
|
|
|
|
// return;
|
2016-09-08 15:53:51 +08:00
|
|
|
|
2017-02-15 16:34:30 +08:00
|
|
|
// start launching effects
|
|
|
|
//m_launchingEffects = 0.0;
|
|
|
|
//m_launchingEffectsTimer->start();
|
|
|
|
//update();
|
|
|
|
}
|
2016-06-07 14:40:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AppItem::mousePressEvent(QMouseEvent *e)
|
|
|
|
{
|
2016-08-09 10:58:47 +08:00
|
|
|
m_updateIconGeometryTimer->stop();
|
2017-03-28 16:52:38 +08:00
|
|
|
// hidePopup();
|
2016-08-09 10:58:47 +08:00
|
|
|
|
2016-06-22 11:02:52 +08:00
|
|
|
if (e->button() == Qt::RightButton)
|
|
|
|
{
|
|
|
|
if (perfectIconRect().contains(e->pos()))
|
2016-08-10 10:15:03 +08:00
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(this, "showContextMenu", Qt::QueuedConnection);
|
|
|
|
return;
|
|
|
|
} else
|
2016-06-22 11:02:52 +08:00
|
|
|
return QWidget::mousePressEvent(e);
|
|
|
|
}
|
2016-06-15 16:17:51 +08:00
|
|
|
|
|
|
|
if (e->button() == Qt::LeftButton)
|
|
|
|
MousePressPos = e->pos();
|
2016-06-07 14:40:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AppItem::mouseMoveEvent(QMouseEvent *e)
|
|
|
|
{
|
2016-06-14 15:17:25 +08:00
|
|
|
e->accept();
|
|
|
|
|
2016-06-07 14:40:45 +08:00
|
|
|
// handle drag
|
|
|
|
if (e->buttons() != Qt::LeftButton)
|
|
|
|
return;
|
|
|
|
|
2016-06-15 16:17:51 +08:00
|
|
|
const QPoint distance = e->pos() - MousePressPos;
|
2016-06-07 14:40:45 +08:00
|
|
|
if (distance.manhattanLength() < APP_DRAG_THRESHOLD)
|
|
|
|
return;
|
|
|
|
|
|
|
|
startDrag();
|
|
|
|
}
|
|
|
|
|
2016-08-30 16:34:02 +08:00
|
|
|
void AppItem::wheelEvent(QWheelEvent *e)
|
|
|
|
{
|
|
|
|
QWidget::wheelEvent(e);
|
|
|
|
|
|
|
|
m_itemEntry->PresentWindows();
|
|
|
|
}
|
|
|
|
|
2016-06-15 11:20:05 +08:00
|
|
|
void AppItem::resizeEvent(QResizeEvent *e)
|
|
|
|
{
|
|
|
|
DockItem::resizeEvent(e);
|
|
|
|
|
2017-03-13 08:02:33 +08:00
|
|
|
refershIcon();
|
2016-06-15 11:20:05 +08:00
|
|
|
}
|
|
|
|
|
2016-06-23 14:45:57 +08:00
|
|
|
void AppItem::dragEnterEvent(QDragEnterEvent *e)
|
|
|
|
{
|
2016-06-23 15:30:06 +08:00
|
|
|
// ignore drag from panel
|
|
|
|
if (e->source())
|
|
|
|
return;
|
|
|
|
|
2016-07-18 17:10:15 +08:00
|
|
|
// ignore request dock event
|
|
|
|
if (e->mimeData()->formats().contains("RequestDock"))
|
|
|
|
return e->ignore();
|
|
|
|
|
2016-06-23 15:30:06 +08:00
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppItem::dropEvent(QDropEvent *e)
|
|
|
|
{
|
|
|
|
QStringList uriList;
|
2017-02-27 15:04:49 +08:00
|
|
|
for (auto uri : e->mimeData()->urls()) {
|
|
|
|
uriList << uri.toEncoded();
|
|
|
|
}
|
2016-06-23 15:30:06 +08:00
|
|
|
|
2017-02-27 15:04:49 +08:00
|
|
|
qDebug() << "accept drop event with URIs: " << uriList;
|
2016-06-23 15:30:06 +08:00
|
|
|
m_itemEntry->HandleDragDrop(uriList);
|
2016-06-23 14:45:57 +08:00
|
|
|
}
|
|
|
|
|
2016-06-15 16:17:51 +08:00
|
|
|
void AppItem::invokedMenuItem(const QString &itemId, const bool checked)
|
|
|
|
{
|
2016-06-21 10:12:43 +08:00
|
|
|
Q_UNUSED(checked);
|
|
|
|
|
|
|
|
m_itemEntry->HandleMenuItem(itemId);
|
2016-06-15 16:17:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const QString AppItem::contextMenu() const
|
|
|
|
{
|
|
|
|
return m_itemEntry->menu();
|
|
|
|
}
|
|
|
|
|
2016-07-18 14:13:36 +08:00
|
|
|
QWidget *AppItem::popupTips()
|
|
|
|
{
|
2016-07-18 17:10:15 +08:00
|
|
|
if (m_draging)
|
|
|
|
return nullptr;
|
2016-07-18 14:13:36 +08:00
|
|
|
|
2016-07-19 15:11:28 +08:00
|
|
|
if (!m_titles.isEmpty())
|
|
|
|
{
|
|
|
|
const quint32 currentWindow = m_itemEntry->currentWindow();
|
|
|
|
Q_ASSERT(m_titles.contains(currentWindow));
|
|
|
|
m_appNameTips->setText(m_titles[currentWindow]);
|
|
|
|
} else {
|
|
|
|
m_appNameTips->setText(m_itemEntry->name());
|
|
|
|
}
|
2016-07-18 14:13:36 +08:00
|
|
|
|
|
|
|
return m_appNameTips;
|
|
|
|
}
|
|
|
|
|
2016-06-07 14:40:45 +08:00
|
|
|
void AppItem::startDrag()
|
|
|
|
{
|
2016-06-07 16:01:37 +08:00
|
|
|
m_draging = true;
|
|
|
|
update();
|
|
|
|
|
2016-08-09 16:50:48 +08:00
|
|
|
const QPixmap dragPix = DockDisplayMode == Dock::Fashion ? m_largeIcon : m_smallIcon;
|
|
|
|
|
2016-06-07 14:40:45 +08:00
|
|
|
QDrag *drag = new QDrag(this);
|
2016-08-09 16:50:48 +08:00
|
|
|
drag->setPixmap(dragPix);
|
|
|
|
drag->setHotSpot(dragPix.rect().center());
|
2016-06-07 14:40:45 +08:00
|
|
|
drag->setMimeData(new QMimeData);
|
|
|
|
|
2016-06-20 14:28:25 +08:00
|
|
|
emit dragStarted();
|
2016-06-07 14:40:45 +08:00
|
|
|
const Qt::DropAction result = drag->exec(Qt::MoveAction);
|
2016-06-21 19:25:30 +08:00
|
|
|
Q_UNUSED(result);
|
2016-06-20 16:46:53 +08:00
|
|
|
|
|
|
|
// drag out of dock panel
|
|
|
|
if (!drag->target())
|
|
|
|
m_itemEntry->RequestUndock();
|
2016-06-07 16:01:37 +08:00
|
|
|
|
|
|
|
m_draging = false;
|
2016-06-20 15:42:31 +08:00
|
|
|
setVisible(true);
|
2016-06-07 16:01:37 +08:00
|
|
|
update();
|
2016-06-06 14:28:28 +08:00
|
|
|
}
|
|
|
|
|
2016-06-15 11:20:05 +08:00
|
|
|
void AppItem::updateTitle()
|
2016-06-06 14:28:28 +08:00
|
|
|
{
|
2016-06-14 15:01:27 +08:00
|
|
|
m_titles = m_itemEntry->titles();
|
|
|
|
|
|
|
|
update();
|
2016-06-06 14:28:28 +08:00
|
|
|
}
|
2016-06-14 16:01:01 +08:00
|
|
|
|
2017-03-13 08:02:33 +08:00
|
|
|
void AppItem::refershIcon()
|
2016-06-14 16:01:01 +08:00
|
|
|
{
|
|
|
|
const QString icon = m_itemEntry->icon();
|
2016-06-23 14:28:47 +08:00
|
|
|
const int iconSize = qMin(width(), height());
|
|
|
|
|
2016-07-11 17:17:32 +08:00
|
|
|
if (DockDisplayMode == Efficient)
|
|
|
|
{
|
|
|
|
m_smallIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.7);
|
|
|
|
m_largeIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.9);
|
|
|
|
} else {
|
|
|
|
m_smallIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.6);
|
|
|
|
m_largeIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.8);
|
|
|
|
}
|
2017-03-13 08:02:33 +08:00
|
|
|
|
|
|
|
update();
|
2016-06-23 14:28:47 +08:00
|
|
|
}
|
2016-06-14 16:01:01 +08:00
|
|
|
|
2016-06-23 14:28:47 +08:00
|
|
|
void AppItem::activeChanged()
|
|
|
|
{
|
|
|
|
m_active = !m_active;
|
2016-06-14 16:01:01 +08:00
|
|
|
}
|
2017-03-28 15:44:13 +08:00
|
|
|
|
2017-03-28 16:52:38 +08:00
|
|
|
void AppItem::togglePreview()
|
2017-03-28 15:44:13 +08:00
|
|
|
{
|
2017-03-28 16:52:38 +08:00
|
|
|
if (PopupWindow->isVisible())
|
|
|
|
return hidePopup();
|
|
|
|
|
|
|
|
m_appPreviewTips->updateLayoutDirection(DockPosition);
|
2017-03-28 15:44:13 +08:00
|
|
|
m_appPreviewTips->setWindowInfos(m_titles);
|
|
|
|
|
2017-03-28 16:52:38 +08:00
|
|
|
qApp->processEvents();
|
|
|
|
|
|
|
|
showPopupApplet(m_appPreviewTips);
|
2017-03-28 15:44:13 +08:00
|
|
|
}
|