mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
Reconstruct app preview
tower:https://tower.im/projects/715dbdd34f694ea08f6de7888b7ffd7d/todos/7a96b7858cfe4b0c9d6362aa51add416/ Change-Id: I6987d52e7b2962807b89cd134169240453dfb35c
This commit is contained in:
parent
fafc17b0d7
commit
6c89c17067
Notes:
Deepin Code Review
2016-06-14 07:19:47 +00:00
Verified+1: <zhaofangfang@linuxdeepin.com> Verified+1: Anonymous Coward #1000004 Code-Review+2: <mr.asianwang@gmail.com> Submitted-by: <mr.asianwang@gmail.com> Submitted-at: Wed, 04 Nov 2015 15:41:27 +0800 Reviewed-on: https://cr.deepin.io/8306 Project: dde/dde-dock Branch: refs/heads/master
@ -57,7 +57,6 @@ HEADERS += \
|
||||
src/widgets/appbackground.h \
|
||||
src/widgets/appicon.h \
|
||||
src/widgets/appitem.h \
|
||||
src/widgets/apppreviews.h \
|
||||
src/widgets/docklayout.h \
|
||||
src/widgets/dockmodel.h \
|
||||
src/widgets/dockview.h \
|
||||
@ -65,10 +64,12 @@ HEADERS += \
|
||||
src/widgets/launcheritem.h \
|
||||
src/widgets/reflectioneffect.h \
|
||||
src/widgets/screenmask.h \
|
||||
src/widgets/windowpreview.h \
|
||||
src/mainwidget.h \
|
||||
src/widgets/previewframe.h \
|
||||
src/controller/signalmanager.h
|
||||
src/controller/signalmanager.h \
|
||||
src/widgets/apppreview/apppreviewloader.h \
|
||||
src/widgets/apppreview/apppreviewscontainer.h \
|
||||
src/widgets/apppreview/apppreviewloaderframe.h \
|
||||
src/widgets/previewwindow.h
|
||||
|
||||
SOURCES += \
|
||||
libs/xcb_misc.cpp \
|
||||
@ -93,7 +94,6 @@ SOURCES += \
|
||||
src/widgets/appbackground.cpp \
|
||||
src/widgets/appicon.cpp \
|
||||
src/widgets/appitem.cpp \
|
||||
src/widgets/apppreviews.cpp \
|
||||
src/widgets/docklayout.cpp \
|
||||
src/widgets/dockmodel.cpp \
|
||||
src/widgets/dockview.cpp \
|
||||
@ -101,8 +101,10 @@ SOURCES += \
|
||||
src/widgets/launcheritem.cpp \
|
||||
src/widgets/reflectioneffect.cpp \
|
||||
src/widgets/screenmask.cpp \
|
||||
src/widgets/windowpreview.cpp \
|
||||
src/main.cpp \
|
||||
src/mainwidget.cpp \
|
||||
src/widgets/previewframe.cpp \
|
||||
src/controller/signalmanager.cpp
|
||||
src/controller/signalmanager.cpp \
|
||||
src/widgets/apppreview/apppreviewloader.cpp \
|
||||
src/widgets/apppreview/apppreviewscontainer.cpp \
|
||||
src/widgets/apppreview/apppreviewloaderframe.cpp \
|
||||
src/widgets/previewwindow.cpp
|
||||
|
@ -47,15 +47,15 @@ QLabel#AppBackgroundActiveLabel {
|
||||
}
|
||||
|
||||
/******************************Item Preview***********************/
|
||||
QPushButton#PreviewCloseButton {
|
||||
QPushButton#AppPreviewLoaderFrameCloseButton {
|
||||
border-image: url(:/images/resources/dark/images/close_normal.png);
|
||||
}
|
||||
|
||||
QPushButton#PreviewCloseButton:hover {
|
||||
QPushButton#AppPreviewLoaderFrameCloseButton:hover {
|
||||
border-image: url(:/images/resources/dark/images/close_hover.png);
|
||||
}
|
||||
|
||||
QPushButton#PreviewCloseButton:pressed {
|
||||
QPushButton#AppPreviewLoaderFrameCloseButton:pressed {
|
||||
border-image: url(:/images/resources/dark/images/close_press.png);
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ QFrame#WindowPreview[isHover="true"] {
|
||||
border-color: rgba(255,255,255,0.5);
|
||||
}
|
||||
|
||||
QLabel#AppPreviewFrameTitle {
|
||||
QLabel#AppPreviewLoaderFrameTitle {
|
||||
border-top-left-radius: 0px;
|
||||
border-bottom-left-radius: 3px;
|
||||
border-top-right-radius: 0px;
|
||||
|
@ -107,14 +107,14 @@ void Panel::initPluginManager()
|
||||
connect(targetItem, &AbstractDockItem::needPreviewShow, this, &Panel::onNeedPreviewShow);
|
||||
connect(targetItem, &AbstractDockItem::needPreviewHide, this, &Panel::onNeedPreviewHide);
|
||||
connect(targetItem, &AbstractDockItem::needPreviewImmediatelyHide, this, &Panel::onNeedPreviewImmediatelyHide);
|
||||
connect(targetItem, &AbstractDockItem::needPreviewUpdate, m_globalPreview, &PreviewFrame::resizeWithContent);
|
||||
connect(targetItem, &AbstractDockItem::needPreviewUpdate, m_globalPreview, &PreviewWindow::resizeWithContent);
|
||||
});
|
||||
connect(m_pluginManager, &DockPluginManager::itemInsert, [=](AbstractDockItem *baseItem, AbstractDockItem *targetItem){
|
||||
m_pluginLayout->insertItem(targetItem, m_pluginLayout->indexOf(baseItem));
|
||||
connect(targetItem, &AbstractDockItem::needPreviewShow, this, &Panel::onNeedPreviewShow);
|
||||
connect(targetItem, &AbstractDockItem::needPreviewHide, this, &Panel::onNeedPreviewHide);
|
||||
connect(targetItem, &AbstractDockItem::needPreviewImmediatelyHide, this, &Panel::onNeedPreviewImmediatelyHide);
|
||||
connect(targetItem, &AbstractDockItem::needPreviewUpdate, m_globalPreview, &PreviewFrame::resizeWithContent);
|
||||
connect(targetItem, &AbstractDockItem::needPreviewUpdate, m_globalPreview, &PreviewWindow::resizeWithContent);
|
||||
});
|
||||
connect(m_pluginManager, &DockPluginManager::itemRemoved, [=](AbstractDockItem* item) {
|
||||
item->setVisible(false);
|
||||
@ -194,19 +194,19 @@ void Panel::initScreenMask()
|
||||
|
||||
void Panel::initGlobalPreview()
|
||||
{
|
||||
m_globalPreview = new PreviewFrame(DArrowRectangle::ArrowBottom);
|
||||
m_globalPreview = new PreviewWindow(DArrowRectangle::ArrowBottom);
|
||||
|
||||
//make sure all app-preview will be destroy to save resources
|
||||
connect(m_globalPreview, &PreviewFrame::showFinish, [=] (QWidget *lastContent) {
|
||||
connect(m_globalPreview, &PreviewWindow::showFinish, [=] (QWidget *lastContent) {
|
||||
if (lastContent) {
|
||||
AppPreviews *tmpFrame = qobject_cast<AppPreviews *>(lastContent);
|
||||
AppPreviewsContainer *tmpFrame = qobject_cast<AppPreviewsContainer *>(lastContent);
|
||||
if (tmpFrame)
|
||||
tmpFrame->clearUpPreview();
|
||||
}
|
||||
});
|
||||
connect(m_globalPreview, &PreviewFrame::hideFinish, [=] (QWidget *lastContent) {
|
||||
connect(m_globalPreview, &PreviewWindow::hideFinish, [=] (QWidget *lastContent) {
|
||||
if (lastContent) {
|
||||
AppPreviews *tmpFrame = qobject_cast<AppPreviews *>(lastContent);
|
||||
AppPreviewsContainer *tmpFrame = qobject_cast<AppPreviewsContainer *>(lastContent);
|
||||
if (tmpFrame)
|
||||
tmpFrame->clearUpPreview();
|
||||
}
|
||||
@ -266,7 +266,7 @@ void Panel::onAppItemAdd(AbstractDockItem *item)
|
||||
connect(item, &AbstractDockItem::needPreviewShow, this, &Panel::onNeedPreviewShow);
|
||||
connect(item, &AbstractDockItem::needPreviewHide, this, &Panel::onNeedPreviewHide);
|
||||
connect(item, &AbstractDockItem::needPreviewImmediatelyHide, this, &Panel::onNeedPreviewImmediatelyHide);
|
||||
connect(item, &AbstractDockItem::needPreviewUpdate, m_globalPreview, &PreviewFrame::resizeWithContent);
|
||||
connect(item, &AbstractDockItem::needPreviewUpdate, m_globalPreview, &PreviewWindow::resizeWithContent);
|
||||
}
|
||||
|
||||
void Panel::onAppItemRemove(const QString &id)
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "widgets/appitem.h"
|
||||
#include "widgets/docklayout.h"
|
||||
#include "widgets/screenmask.h"
|
||||
#include "widgets/previewframe.h"
|
||||
#include "widgets/previewwindow.h"
|
||||
#include "widgets/reflectioneffect.h"
|
||||
#include "panelmenu.h"
|
||||
|
||||
@ -78,7 +78,7 @@ private:
|
||||
void setY(int value); //for hide and show animation
|
||||
|
||||
private:
|
||||
PreviewFrame *m_globalPreview = NULL;
|
||||
PreviewWindow *m_globalPreview = NULL;
|
||||
DBusDockedAppManager *m_ddam = new DBusDockedAppManager(this);
|
||||
DockModeData *m_dockModeData = DockModeData::instance();
|
||||
QPropertyAnimation *m_widthAnimation = NULL;
|
||||
|
@ -25,7 +25,7 @@ AbstractDockItem::AbstractDockItem(QWidget * parent) :
|
||||
{
|
||||
|
||||
this->setAttribute(Qt::WA_TranslucentBackground);
|
||||
m_titlePreview = new PreviewFrame(DArrowRectangle::ArrowBottom);
|
||||
m_titlePreview = new PreviewWindow(DArrowRectangle::ArrowBottom);
|
||||
}
|
||||
|
||||
AbstractDockItem::~AbstractDockItem()
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "dbus/dbusmenu.h"
|
||||
#include "previewframe.h"
|
||||
#include "previewwindow.h"
|
||||
#include "highlighteffect.h"
|
||||
#include "dbus/dbusmenumanager.h"
|
||||
#include "interfaces/dockconstants.h"
|
||||
@ -80,7 +80,7 @@ protected:
|
||||
bool m_moveable = true;
|
||||
bool m_isActived = false;
|
||||
bool m_hoverable = true;
|
||||
PreviewFrame *m_titlePreview = NULL;
|
||||
PreviewWindow *m_titlePreview = NULL;
|
||||
HighlightEffect * m_highlight = NULL;
|
||||
ItemTitleLabel *m_titleLabel = NULL;
|
||||
|
||||
|
@ -190,9 +190,9 @@ void AppItem::initBackground()
|
||||
|
||||
void AppItem::initPreview()
|
||||
{
|
||||
m_preview = new AppPreviews();
|
||||
connect(m_preview,&AppPreviews::requestHide, [=]{hidePreview();});
|
||||
connect(m_preview,&AppPreviews::sizeChanged, this, &AppItem::needPreviewUpdate);
|
||||
m_preview = new AppPreviewsContainer();
|
||||
connect(m_preview,&AppPreviewsContainer::requestHide, [=]{hidePreview();});
|
||||
connect(m_preview,&AppPreviewsContainer::sizeChanged, this, &AppItem::needPreviewUpdate);
|
||||
}
|
||||
|
||||
void AppItem::initAppIcon()
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include <QJsonDocument>
|
||||
|
||||
#include "appicon.h"
|
||||
#include "apppreviews.h"
|
||||
#include "apppreview/apppreviewscontainer.h"
|
||||
#include "appbackground.h"
|
||||
#include "abstractdockitem.h"
|
||||
#include "dbus/dbusentryproxyer.h"
|
||||
@ -97,7 +97,7 @@ private:
|
||||
DBusClientManager *m_clientmanager = NULL;
|
||||
DBusEntryProxyer *m_entryProxyer = NULL;
|
||||
AppBackground * m_appBackground = NULL;
|
||||
AppPreviews *m_preview = NULL;
|
||||
AppPreviewsContainer *m_preview = NULL;
|
||||
AppIcon * m_appIcon = NULL;
|
||||
QLabel * m_appTitle = NULL;
|
||||
QPoint m_lastPressPos;
|
||||
|
@ -17,11 +17,11 @@
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#include "windowpreview.h"
|
||||
#include "apppreviewloader.h"
|
||||
|
||||
static cairo_status_t cairo_write_func (void *widget, const unsigned char *data, unsigned int length)
|
||||
{
|
||||
WindowPreview * wp = (WindowPreview *)widget;
|
||||
AppPreviewLoader * wp = (AppPreviewLoader *)widget;
|
||||
|
||||
wp->imageData.append((const char *) data, length);
|
||||
|
||||
@ -31,7 +31,7 @@ static cairo_status_t cairo_write_func (void *widget, const unsigned char *data,
|
||||
class Monitor : public QAbstractNativeEventFilter
|
||||
{
|
||||
public:
|
||||
Monitor(WindowPreview * wp) :
|
||||
Monitor(AppPreviewLoader * wp) :
|
||||
QAbstractNativeEventFilter(),
|
||||
m_wp(wp)
|
||||
{
|
||||
@ -78,12 +78,12 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
WindowPreview * m_wp;
|
||||
AppPreviewLoader * m_wp;
|
||||
int m_damageEventBase;
|
||||
int m_damage;
|
||||
};
|
||||
|
||||
WindowPreview::WindowPreview(WId sourceWindow, QWidget *parent)
|
||||
AppPreviewLoader::AppPreviewLoader(WId sourceWindow, QWidget *parent)
|
||||
: QFrame(parent),
|
||||
m_sourceWindow(sourceWindow),
|
||||
m_monitor(NULL)
|
||||
@ -97,12 +97,12 @@ WindowPreview::WindowPreview(WId sourceWindow, QWidget *parent)
|
||||
installMonitor();
|
||||
}
|
||||
|
||||
WindowPreview::~WindowPreview()
|
||||
AppPreviewLoader::~AppPreviewLoader()
|
||||
{
|
||||
removeMonitor();
|
||||
}
|
||||
|
||||
void WindowPreview::paintEvent(QPaintEvent *)
|
||||
void AppPreviewLoader::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter;
|
||||
painter.begin(this);
|
||||
@ -116,12 +116,12 @@ void WindowPreview::paintEvent(QPaintEvent *)
|
||||
|
||||
painter.end();
|
||||
}
|
||||
bool WindowPreview::isHover() const
|
||||
bool AppPreviewLoader::isHover() const
|
||||
{
|
||||
return m_isHover;
|
||||
}
|
||||
|
||||
void WindowPreview::setIsHover(bool isHover)
|
||||
void AppPreviewLoader::setIsHover(bool isHover)
|
||||
{
|
||||
m_isHover = isHover;
|
||||
|
||||
@ -131,8 +131,14 @@ void WindowPreview::setIsHover(bool isHover)
|
||||
repaint();
|
||||
}
|
||||
|
||||
void AppPreviewLoader::requestUpdate()
|
||||
{
|
||||
prepareRepaint();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void WindowPreview::installMonitor()
|
||||
|
||||
void AppPreviewLoader::installMonitor()
|
||||
{
|
||||
if (!m_monitor) {
|
||||
m_monitor = new Monitor(this);
|
||||
@ -142,7 +148,7 @@ void WindowPreview::installMonitor()
|
||||
}
|
||||
}
|
||||
|
||||
void WindowPreview::removeMonitor()
|
||||
void AppPreviewLoader::removeMonitor()
|
||||
{
|
||||
if (m_monitor) {
|
||||
QCoreApplication * app = QApplication::instance();
|
||||
@ -153,7 +159,7 @@ void WindowPreview::removeMonitor()
|
||||
}
|
||||
}
|
||||
|
||||
void WindowPreview::prepareRepaint()
|
||||
void AppPreviewLoader::prepareRepaint()
|
||||
{
|
||||
Display *dsp = QX11Info::display();
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef WINDOWPREVIEW_H
|
||||
#define WINDOWPREVIEW_H
|
||||
#ifndef APPPREVIEWLOADER_H
|
||||
#define APPPREVIEWLOADER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QFrame>
|
||||
@ -9,20 +9,21 @@
|
||||
|
||||
class Monitor;
|
||||
class QPaintEvent;
|
||||
class WindowPreview : public QFrame
|
||||
class AppPreviewLoader : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool isHover READ isHover WRITE setIsHover)
|
||||
public:
|
||||
friend class Monitor;
|
||||
|
||||
WindowPreview(WId sourceWindow, QWidget *parent = 0);
|
||||
~WindowPreview();
|
||||
AppPreviewLoader(WId sourceWindow, QWidget *parent = 0);
|
||||
~AppPreviewLoader();
|
||||
|
||||
QByteArray imageData;
|
||||
|
||||
bool isHover() const;
|
||||
void setIsHover(bool isHover);
|
||||
void requestUpdate();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent * event);
|
||||
@ -36,8 +37,8 @@ private:
|
||||
|
||||
void installMonitor();
|
||||
void removeMonitor();
|
||||
|
||||
void prepareRepaint();
|
||||
|
||||
};
|
||||
|
||||
#endif // WINDOWPREVIEW_H
|
||||
#endif // APPPREVIEWLOADER_H
|
201
dde-dock/src/widgets/apppreview/apppreviewloaderframe.cpp
Normal file
201
dde-dock/src/widgets/apppreview/apppreviewloaderframe.cpp
Normal file
@ -0,0 +1,201 @@
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <QEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QDebug>
|
||||
|
||||
#include "apppreviewloader.h"
|
||||
#include "apppreviewloaderframe.h"
|
||||
#include "interfaces/dockconstants.h"
|
||||
|
||||
const int BUTTON_SIZE = Dock::APP_PREVIEW_CLOSEBUTTON_SIZE;
|
||||
const int TITLE_HEIGHT = 25;
|
||||
const int BORDER_WIDTH = 2;
|
||||
|
||||
////////////////////////////////////////
|
||||
/// \\// ///
|
||||
/////////////////////////////////// ///
|
||||
/// //\\ ///
|
||||
/// /// ///
|
||||
/// /// ///
|
||||
/// /// ///
|
||||
/// AppPreviewLoader /// ///
|
||||
/// /// ///
|
||||
/// /// ///
|
||||
/// /// ///
|
||||
/// /// ///
|
||||
////////////////////////////////// ///
|
||||
/// ///
|
||||
/// ////////////////////////////////////
|
||||
PopupFrame::PopupFrame(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
//PopupFrame is a middleware which use for show popup style preview
|
||||
}
|
||||
|
||||
void PopupFrame::mousePressEvent(QMouseEvent *)
|
||||
{
|
||||
emit mousePress();
|
||||
}
|
||||
|
||||
void PopupFrame::leaveEvent(QEvent *)
|
||||
{
|
||||
emit mouseLeave();
|
||||
}
|
||||
|
||||
|
||||
AppPreviewLoaderFrame::AppPreviewLoaderFrame(const QString &title, int xid, QWidget *parent) :
|
||||
QFrame(parent), m_parent(parent), m_inMiniStyle(false),m_canShowTitle(true), m_xid(xid)
|
||||
{
|
||||
this->setFixedSize(Dock::APP_PREVIEW_WIDTH + BUTTON_SIZE / 2, Dock::APP_PREVIEW_HEIGHT + BUTTON_SIZE);
|
||||
|
||||
initPopupWidget();
|
||||
initPreviewLoader(xid);
|
||||
initCloseButton();
|
||||
initTitle(title);
|
||||
}
|
||||
|
||||
AppPreviewLoaderFrame::~AppPreviewLoaderFrame()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AppPreviewLoaderFrame::shrink(const QSize &size, bool miniStyle)
|
||||
{
|
||||
this->setFixedSize(size);
|
||||
m_inMiniStyle = miniStyle;
|
||||
m_canShowTitle = !m_inMiniStyle;
|
||||
|
||||
updatePopWidgetGeometry();
|
||||
updateWidgetsGeometry();
|
||||
}
|
||||
|
||||
void AppPreviewLoaderFrame::enterEvent(QEvent *)
|
||||
{
|
||||
QSize ts(this->width() * 1.4, this->height() * 1.4);
|
||||
if (m_inMiniStyle && (ts.height() < m_parent->height())) {
|
||||
m_popupWidget->setParent(m_parent);
|
||||
m_popupWidget->setFixedSize(ts);
|
||||
QPoint tp = this->mapToParent(QPoint(0, 0));
|
||||
int nx = tp.x() - (m_popupWidget->width() - this->width()) / 2;
|
||||
if (nx < 0)
|
||||
nx = 0;
|
||||
else if (nx + ts.width() > m_parent->width())
|
||||
nx = m_parent->width() - ts.width();
|
||||
m_popupWidget->move(nx, (m_parent->height() - m_popupWidget->height()) / 2);
|
||||
m_popupWidget->show();
|
||||
|
||||
m_canShowTitle = true;
|
||||
}
|
||||
|
||||
m_closeButton->show();
|
||||
m_previewLoader->setIsHover(true);
|
||||
m_previewLoader->requestUpdate();
|
||||
|
||||
updateWidgetsGeometry();
|
||||
}
|
||||
|
||||
void AppPreviewLoaderFrame::initPopupWidget()
|
||||
{
|
||||
m_popupWidget = new PopupFrame(this);
|
||||
//TODO add box-shadow
|
||||
|
||||
connect(m_popupWidget, &PopupFrame::mousePress, [=] {
|
||||
m_popupWidget->setParent(this); //make sure the popupwidget will be delete with this
|
||||
emit requestPreviewActive(m_xid);
|
||||
});
|
||||
connect(m_popupWidget, &PopupFrame::mouseLeave, [=] {
|
||||
m_popupWidget->setFixedSize(this->size());
|
||||
m_popupWidget->setParent(this);
|
||||
m_layout->addWidget(m_popupWidget);
|
||||
|
||||
m_closeButton->hide();
|
||||
m_previewLoader->setIsHover(false);
|
||||
m_canShowTitle = !m_inMiniStyle;
|
||||
|
||||
updateWidgetsGeometry();
|
||||
});
|
||||
|
||||
m_layout = new QHBoxLayout(this);
|
||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||
m_layout->addWidget(m_popupWidget);
|
||||
|
||||
updatePopWidgetGeometry();
|
||||
}
|
||||
|
||||
void AppPreviewLoaderFrame::initTitle(const QString &t)
|
||||
{
|
||||
m_titleLabel = new QLabel(t, m_popupWidget);
|
||||
m_titleLabel->setAlignment(Qt::AlignCenter);
|
||||
m_titleLabel->setObjectName("AppPreviewLoaderFrameTitle");
|
||||
|
||||
updateTitleGeometry();
|
||||
}
|
||||
|
||||
void AppPreviewLoaderFrame::initPreviewLoader(int xid)
|
||||
{
|
||||
m_previewLoader = new AppPreviewLoader(xid, m_popupWidget);
|
||||
|
||||
updatePreviewLoaderGeometry();
|
||||
}
|
||||
|
||||
void AppPreviewLoaderFrame::initCloseButton()
|
||||
{
|
||||
m_closeButton = new QPushButton(m_popupWidget);
|
||||
m_closeButton->setObjectName("AppPreviewLoaderFrameCloseButton");
|
||||
m_closeButton->setFixedSize(BUTTON_SIZE, BUTTON_SIZE);
|
||||
m_closeButton->hide();
|
||||
|
||||
connect(m_closeButton, &QPushButton::clicked, [=]{
|
||||
m_popupWidget->setParent(this); //make sure the popupwidget will be delete with this
|
||||
emit requestPreviewClose(m_xid);
|
||||
this->deleteLater();
|
||||
});
|
||||
|
||||
updateCloseButtonGeometry();
|
||||
}
|
||||
|
||||
void AppPreviewLoaderFrame::updatePopWidgetGeometry()
|
||||
{
|
||||
m_popupWidget->setFixedSize(this->size());
|
||||
}
|
||||
|
||||
void AppPreviewLoaderFrame::updatePreviewLoaderGeometry()
|
||||
{
|
||||
//left:parent.left
|
||||
//leftMargin:0
|
||||
//topMargin==rightMargin==bottomMargin==BUTTON_SIZE / 2
|
||||
//horizontalCenter:parent.horizontalCenter
|
||||
m_previewLoader->setFixedSize(m_popupWidget->width() - BUTTON_SIZE / 2, m_popupWidget->height() - BUTTON_SIZE);
|
||||
m_previewLoader->move(0, BUTTON_SIZE / 2);
|
||||
}
|
||||
|
||||
void AppPreviewLoaderFrame::updateCloseButtonGeometry()
|
||||
{
|
||||
//always in the top-right corner
|
||||
m_closeButton->move(m_popupWidget->width() - BUTTON_SIZE, 0);
|
||||
}
|
||||
|
||||
void AppPreviewLoaderFrame::updateTitleGeometry()
|
||||
{
|
||||
if (m_canShowTitle) {
|
||||
m_titleLabel->setVisible(true);
|
||||
QFontMetrics fm(m_titleLabel->font());
|
||||
m_titleLabel->setText(fm.elidedText(m_titleLabel->text(), Qt::ElideRight, width()));
|
||||
|
||||
m_titleLabel->setFixedSize(m_previewLoader->width() - BORDER_WIDTH * 2, TITLE_HEIGHT);
|
||||
m_titleLabel->move(BORDER_WIDTH, BUTTON_SIZE / 2 + m_previewLoader->height() - TITLE_HEIGHT - BORDER_WIDTH);
|
||||
}
|
||||
else
|
||||
m_titleLabel->setVisible(false);
|
||||
}
|
||||
|
||||
void AppPreviewLoaderFrame::updateWidgetsGeometry()
|
||||
{
|
||||
updatePreviewLoaderGeometry();
|
||||
updateCloseButtonGeometry();
|
||||
updateTitleGeometry();
|
||||
}
|
||||
|
||||
|
65
dde-dock/src/widgets/apppreview/apppreviewloaderframe.h
Normal file
65
dde-dock/src/widgets/apppreview/apppreviewloaderframe.h
Normal file
@ -0,0 +1,65 @@
|
||||
#ifndef APPPREVIEWLOADERFRAME_H
|
||||
#define APPPREVIEWLOADERFRAME_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QFrame>
|
||||
|
||||
class QLabel;
|
||||
class QPushButton;
|
||||
class QHBoxLayout;
|
||||
class AppPreviewLoader;
|
||||
|
||||
class PopupFrame : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PopupFrame(QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
void mousePress();
|
||||
void mouseLeave();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
void leaveEvent(QEvent *);
|
||||
};
|
||||
|
||||
class AppPreviewLoaderFrame : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AppPreviewLoaderFrame(const QString &title, int xid, QWidget *parent=0);
|
||||
~AppPreviewLoaderFrame();
|
||||
void shrink(const QSize &size, bool miniStyle);
|
||||
|
||||
signals:
|
||||
void requestPreviewClose(int xid);
|
||||
void requestPreviewActive(int xid);
|
||||
|
||||
protected:
|
||||
void enterEvent(QEvent *);
|
||||
|
||||
private:
|
||||
void initPopupWidget();
|
||||
void initTitle(const QString &t);
|
||||
void initPreviewLoader(int xid);
|
||||
void initCloseButton();
|
||||
void updatePopWidgetGeometry();
|
||||
void updatePreviewLoaderGeometry();
|
||||
void updateCloseButtonGeometry();
|
||||
void updateTitleGeometry();
|
||||
void updateWidgetsGeometry();
|
||||
|
||||
private:
|
||||
AppPreviewLoader * m_previewLoader;
|
||||
QPushButton *m_closeButton;
|
||||
QHBoxLayout *m_layout;
|
||||
PopupFrame *m_popupWidget; //for show popup preview
|
||||
QWidget *m_parent; //for reparent to make preview show like popup window
|
||||
QLabel *m_titleLabel;
|
||||
bool m_inMiniStyle;
|
||||
bool m_canShowTitle;
|
||||
int m_xid;
|
||||
};
|
||||
|
||||
#endif // APPPREVIEWLOADERFRAME_H
|
132
dde-dock/src/widgets/apppreview/apppreviewscontainer.cpp
Normal file
132
dde-dock/src/widgets/apppreview/apppreviewscontainer.cpp
Normal file
@ -0,0 +1,132 @@
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDebug>
|
||||
|
||||
#include "apppreviewscontainer.h"
|
||||
#include "apppreviewloaderframe.h"
|
||||
#include "interfaces/dockconstants.h"
|
||||
|
||||
const int PREVIEW_PADDING = 5;
|
||||
const int BUTTON_SIZE = Dock::APP_PREVIEW_CLOSEBUTTON_SIZE;
|
||||
const int PREVIEW_HEIGHT = Dock::APP_PREVIEW_HEIGHT;
|
||||
const int PREVIEW_WIDTH = Dock::APP_PREVIEW_WIDTH;
|
||||
const int PREVIEW_MARGIN = Dock::APP_PREVIEW_MARGIN;
|
||||
|
||||
AppPreviewsContainer::AppPreviewsContainer(QWidget *parent) :
|
||||
QWidget(parent), m_isClosing(false)
|
||||
{
|
||||
m_clientManager = new DBusClientManager(this);
|
||||
|
||||
|
||||
m_mainLayout = new QHBoxLayout(this);
|
||||
m_mainLayout->setAlignment(Qt::AlignCenter);
|
||||
m_mainLayout->setContentsMargins(Dock::APP_PREVIEW_CLOSEBUTTON_SIZE / 2, 0, 0, 0);
|
||||
m_mainLayout->setSpacing(PREVIEW_MARGIN - Dock::APP_PREVIEW_CLOSEBUTTON_SIZE / 2);
|
||||
|
||||
resize(PREVIEW_WIDTH,PREVIEW_HEIGHT);
|
||||
}
|
||||
|
||||
void AppPreviewsContainer::addItem(const QString &title, int xid)
|
||||
{
|
||||
if (m_previewMap.keys().indexOf(xid) != -1)
|
||||
return;
|
||||
|
||||
AppPreviewLoaderFrame *f = new AppPreviewLoaderFrame(title, xid, this);
|
||||
connect(f, &AppPreviewLoaderFrame::requestPreviewClose, this, &AppPreviewsContainer::removePreview);
|
||||
connect(f, &AppPreviewLoaderFrame::requestPreviewActive, this, &AppPreviewsContainer::activatePreview);
|
||||
|
||||
m_mainLayout->addWidget(f);
|
||||
|
||||
m_previewMap.insert(xid, f);
|
||||
|
||||
setItemCount(m_previewMap.count());
|
||||
}
|
||||
|
||||
void AppPreviewsContainer::leaveEvent(QEvent *)
|
||||
{
|
||||
if (m_isClosing)
|
||||
m_isClosing = false;
|
||||
}
|
||||
|
||||
void AppPreviewsContainer::removePreview(int xid)
|
||||
{
|
||||
m_isClosing = true;
|
||||
|
||||
m_previewMap.remove(xid);
|
||||
m_mainLayout->removeWidget(qobject_cast<AppPreviewLoaderFrame *>(sender()));
|
||||
sender()->deleteLater();
|
||||
m_clientManager->CloseWindow(xid);
|
||||
|
||||
if (m_mainLayout->count() <= 0)
|
||||
{
|
||||
emit requestHide();
|
||||
return;
|
||||
}
|
||||
|
||||
setItemCount(m_previewMap.count());
|
||||
|
||||
emit sizeChanged();
|
||||
}
|
||||
|
||||
void AppPreviewsContainer::activatePreview(int xid)
|
||||
{
|
||||
m_clientManager->ActiveWindow(xid);
|
||||
|
||||
emit requestHide();
|
||||
}
|
||||
|
||||
void AppPreviewsContainer::clearUpPreview()
|
||||
{
|
||||
QLayoutItem *child;
|
||||
while ((child = m_mainLayout->takeAt(0)) != 0){
|
||||
child->widget()->deleteLater();
|
||||
delete child;
|
||||
}
|
||||
|
||||
m_previewMap.clear();
|
||||
}
|
||||
|
||||
QSize AppPreviewsContainer::getNormalContentSize()
|
||||
{
|
||||
|
||||
int contentWidth = m_mainLayout->count() * (PREVIEW_WIDTH + PREVIEW_MARGIN)
|
||||
+ PREVIEW_MARGIN - PREVIEW_PADDING * 2;
|
||||
int contentHeight = PREVIEW_HEIGHT + PREVIEW_MARGIN*2 - PREVIEW_PADDING * 2;
|
||||
|
||||
return QSize(contentWidth, contentHeight);
|
||||
}
|
||||
|
||||
void AppPreviewsContainer::setItemCount(int count)
|
||||
{
|
||||
QSize frameSize(PREVIEW_WIDTH + BUTTON_SIZE / 2, PREVIEW_HEIGHT + BUTTON_SIZE);
|
||||
QRect dr = QApplication::desktop()->geometry();
|
||||
bool outOfScreen = getNormalContentSize().width() > dr.width();
|
||||
|
||||
//if the total width larger than screen width,scale the preview frame size
|
||||
if (outOfScreen) {
|
||||
int w = (dr.width() - (count + 1) * PREVIEW_MARGIN) / count + BUTTON_SIZE / 2;
|
||||
int h = w * (PREVIEW_HEIGHT + BUTTON_SIZE) / (PREVIEW_WIDTH + BUTTON_SIZE / 2);
|
||||
frameSize = QSize(w, h);
|
||||
}
|
||||
|
||||
foreach (AppPreviewLoaderFrame *frame, m_previewMap.values()) {
|
||||
frame->shrink(frameSize, outOfScreen);
|
||||
}
|
||||
|
||||
int contentWidth = count * (frameSize.width() - BUTTON_SIZE / 2) + (count + 1) * PREVIEW_MARGIN;
|
||||
int contentHeight = PREVIEW_HEIGHT + PREVIEW_MARGIN * 2;
|
||||
|
||||
resize(contentWidth, contentHeight);
|
||||
}
|
||||
|
||||
AppPreviewsContainer::~AppPreviewsContainer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
42
dde-dock/src/widgets/apppreview/apppreviewscontainer.h
Normal file
42
dde-dock/src/widgets/apppreview/apppreviewscontainer.h
Normal file
@ -0,0 +1,42 @@
|
||||
#ifndef APPPREVIEWSCONTAINER_H
|
||||
#define APPPREVIEWSCONTAINER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "dbus/dbusclientmanager.h"
|
||||
|
||||
class QHBoxLayout;
|
||||
class AppPreviewLoaderFrame;
|
||||
|
||||
class AppPreviewsContainer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AppPreviewsContainer(QWidget *parent = 0);
|
||||
~AppPreviewsContainer();
|
||||
|
||||
void addItem(const QString &title,int xid);
|
||||
|
||||
protected:
|
||||
void leaveEvent(QEvent *);
|
||||
|
||||
signals:
|
||||
void requestHide();
|
||||
void sizeChanged();
|
||||
|
||||
public slots:
|
||||
void removePreview(int xid);
|
||||
void activatePreview(int xid);
|
||||
void clearUpPreview();
|
||||
QSize getNormalContentSize();
|
||||
|
||||
private:
|
||||
void setItemCount(int count);
|
||||
|
||||
private:
|
||||
QMap<int, AppPreviewLoaderFrame *> m_previewMap;
|
||||
DBusClientManager *m_clientManager;
|
||||
QHBoxLayout *m_mainLayout;
|
||||
bool m_isClosing;
|
||||
};
|
||||
|
||||
#endif // APPPREVIEWSCONTAINER_H
|
@ -1,159 +0,0 @@
|
||||
#include "apppreviews.h"
|
||||
|
||||
AppPreviewFrame::AppPreviewFrame(const QString &title, int xid, QWidget *parent) :
|
||||
QFrame(parent),xidValue(xid)
|
||||
{
|
||||
addPreview(xid);
|
||||
setTitle(title);
|
||||
addCloseButton();
|
||||
}
|
||||
|
||||
AppPreviewFrame::~AppPreviewFrame()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AppPreviewFrame::addPreview(int xid)
|
||||
{
|
||||
m_preview = new WindowPreview(xid, this);
|
||||
m_preview->resize(Dock::APP_PREVIEW_WIDTH,Dock::APP_PREVIEW_HEIGHT);
|
||||
|
||||
setFixedSize(m_preview->width() + BUTTON_SIZE / 2, m_preview->height() + BUTTON_SIZE);
|
||||
m_preview->move(0, BUTTON_SIZE / 2);
|
||||
}
|
||||
|
||||
void AppPreviewFrame::setTitle(const QString &t)
|
||||
{
|
||||
QLabel *titleLabel = new QLabel(this);
|
||||
titleLabel->setObjectName("AppPreviewFrameTitle");
|
||||
QFontMetrics fm(titleLabel->font());
|
||||
titleLabel->setText(fm.elidedText(t,Qt::ElideRight,width()));
|
||||
titleLabel->setAlignment(Qt::AlignCenter);
|
||||
titleLabel->resize(width() - BUTTON_SIZE / 2, TITLE_HEIGHT);
|
||||
titleLabel->move(0, height() - titleLabel->height() - BUTTON_SIZE / 2);
|
||||
}
|
||||
|
||||
void AppPreviewFrame::mousePressEvent(QMouseEvent *)
|
||||
{
|
||||
emit activate(xidValue);
|
||||
}
|
||||
|
||||
void AppPreviewFrame::enterEvent(QEvent *)
|
||||
{
|
||||
m_preview->setIsHover(true);
|
||||
|
||||
showCloseButton();
|
||||
}
|
||||
|
||||
void AppPreviewFrame::leaveEvent(QEvent *)
|
||||
{
|
||||
m_preview->setIsHover(false);
|
||||
|
||||
hideCloseButton();
|
||||
}
|
||||
|
||||
void AppPreviewFrame::addCloseButton()
|
||||
{
|
||||
m_cb = new QPushButton(this);
|
||||
m_cb->setObjectName("PreviewCloseButton");
|
||||
m_cb->setFixedSize(BUTTON_SIZE, BUTTON_SIZE);
|
||||
m_cb->move(width() - m_cb->width(), 0);
|
||||
m_cb->hide();
|
||||
|
||||
connect(m_cb,&QPushButton::clicked,[=]{close(this->xidValue);});
|
||||
}
|
||||
|
||||
void AppPreviewFrame::showCloseButton()
|
||||
{
|
||||
m_cb->show();
|
||||
}
|
||||
|
||||
void AppPreviewFrame::hideCloseButton()
|
||||
{
|
||||
m_cb->hide();
|
||||
}
|
||||
|
||||
AppPreviews::AppPreviews(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
m_mainLayout = new QHBoxLayout(this);
|
||||
m_mainLayout->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
m_mainLayout->setContentsMargins(20 - PREVIEW_PADDING, 0, 0, 0);
|
||||
m_mainLayout->setSpacing(Dock::APP_PREVIEW_MARGIN - BUTTON_SIZE / 2);
|
||||
setLayout(m_mainLayout);
|
||||
resize(Dock::APP_PREVIEW_WIDTH,Dock::APP_PREVIEW_HEIGHT);
|
||||
}
|
||||
|
||||
void AppPreviews::addItem(const QString &title, int xid)
|
||||
{
|
||||
if (m_xidList.indexOf(xid) != -1)
|
||||
return;
|
||||
m_xidList.append(xid);
|
||||
|
||||
AppPreviewFrame *f = new AppPreviewFrame(title, xid);
|
||||
connect(f,&AppPreviewFrame::close,this,&AppPreviews::removePreview);
|
||||
connect(f,&AppPreviewFrame::activate,this,&AppPreviews::activatePreview);
|
||||
|
||||
m_mainLayout->addWidget(f);
|
||||
|
||||
resize(getContentSize());
|
||||
}
|
||||
|
||||
void AppPreviews::leaveEvent(QEvent *)
|
||||
{
|
||||
if (m_isClosing)
|
||||
m_isClosing = false;
|
||||
}
|
||||
|
||||
void AppPreviews::removePreview(int xid)
|
||||
{
|
||||
m_isClosing = true;
|
||||
m_mainLayout->removeWidget(qobject_cast<AppPreviewFrame *>(sender()));
|
||||
sender()->deleteLater();
|
||||
m_clientManager->CloseWindow(xid);
|
||||
if (m_mainLayout->count() <= 0)
|
||||
{
|
||||
emit requestHide();
|
||||
return;
|
||||
}
|
||||
|
||||
resize(getContentSize());
|
||||
emit sizeChanged();
|
||||
}
|
||||
|
||||
void AppPreviews::activatePreview(int xid)
|
||||
{
|
||||
m_clientManager->ActiveWindow(xid);
|
||||
|
||||
emit requestHide();
|
||||
}
|
||||
|
||||
void AppPreviews::clearUpPreview()
|
||||
{
|
||||
QLayoutItem *child;
|
||||
while ((child = m_mainLayout->takeAt(0)) != 0){
|
||||
child->widget()->deleteLater();
|
||||
delete child;
|
||||
}
|
||||
|
||||
m_xidList.clear();
|
||||
}
|
||||
|
||||
QSize AppPreviews::getContentSize()
|
||||
{
|
||||
|
||||
int contentWidth = m_mainLayout->count() * (Dock::APP_PREVIEW_WIDTH + Dock::APP_PREVIEW_MARGIN)
|
||||
+ Dock::APP_PREVIEW_MARGIN - PREVIEW_PADDING * 2;
|
||||
int contentHeight = Dock::APP_PREVIEW_HEIGHT + Dock::APP_PREVIEW_MARGIN*2 - PREVIEW_PADDING * 2;
|
||||
|
||||
return QSize(contentWidth, contentHeight);
|
||||
}
|
||||
|
||||
AppPreviews::~AppPreviews()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,79 +0,0 @@
|
||||
#ifndef APPPREVIEWS_H
|
||||
#define APPPREVIEWS_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QDebug>
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "windowpreview.h"
|
||||
#include "abstractdockitem.h"
|
||||
#include "dbus/dbusclientmanager.h"
|
||||
#include "interfaces/dockconstants.h"
|
||||
|
||||
class AppPreviewFrame : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AppPreviewFrame(const QString &title,int xid, QWidget *parent=0);
|
||||
~AppPreviewFrame();
|
||||
void addPreview(int xid);
|
||||
void setTitle(const QString &t);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
void enterEvent(QEvent *);
|
||||
void leaveEvent(QEvent *);
|
||||
|
||||
signals:
|
||||
void close(int xid);
|
||||
void activate(int xid);
|
||||
|
||||
private:
|
||||
void addCloseButton();
|
||||
void showCloseButton();
|
||||
void hideCloseButton();
|
||||
|
||||
private:
|
||||
WindowPreview * m_preview = NULL;
|
||||
QPushButton *m_cb = NULL;
|
||||
int xidValue;
|
||||
const int BUTTON_SIZE = Dock::APP_PREVIEW_CLOSEBUTTON_SIZE;
|
||||
const int TITLE_HEIGHT = 25;
|
||||
const int PREVIEW_BORDER_WIDTH = 3;
|
||||
};
|
||||
|
||||
class AppPreviews : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AppPreviews(QWidget *parent = 0);
|
||||
~AppPreviews();
|
||||
|
||||
void addItem(const QString &title,int xid);
|
||||
|
||||
protected:
|
||||
void leaveEvent(QEvent *);
|
||||
|
||||
signals:
|
||||
void requestHide();
|
||||
void sizeChanged();
|
||||
|
||||
public slots:
|
||||
void removePreview(int xid);
|
||||
void activatePreview(int xid);
|
||||
void clearUpPreview();
|
||||
QSize getContentSize();
|
||||
|
||||
private:
|
||||
DBusClientManager *m_clientManager = new DBusClientManager(this);
|
||||
QHBoxLayout *m_mainLayout = NULL;
|
||||
QList<int> m_xidList;
|
||||
bool m_isClosing = false;
|
||||
const int PREVIEW_PADDING = 5;
|
||||
const int BUTTON_SIZE = Dock::APP_PREVIEW_CLOSEBUTTON_SIZE;
|
||||
};
|
||||
|
||||
#endif // APPPREVIEWS_H
|
@ -1,6 +1,6 @@
|
||||
#include "previewframe.h"
|
||||
#include "previewwindow.h"
|
||||
|
||||
PreviewFrame::PreviewFrame(ArrowDirection direction, QWidget *parent) : DArrowRectangle(direction, parent)
|
||||
PreviewWindow::PreviewWindow(ArrowDirection direction, QWidget *parent) : DArrowRectangle(direction, parent)
|
||||
{
|
||||
setWindowFlags(Qt::X11BypassWindowManagerHint | Qt::Tool);
|
||||
setArrowWidth(ARROW_WIDTH);
|
||||
@ -8,23 +8,23 @@ PreviewFrame::PreviewFrame(ArrowDirection direction, QWidget *parent) : DArrowRe
|
||||
|
||||
m_showTimer = new QTimer(this);
|
||||
m_showTimer->setSingleShot(true);
|
||||
connect(m_showTimer, &QTimer::timeout, this, &PreviewFrame::onShowTimerTriggered);
|
||||
connect(m_showTimer, &QTimer::timeout, this, &PreviewWindow::onShowTimerTriggered);
|
||||
|
||||
m_hideTimer = new QTimer(this);
|
||||
m_hideTimer->setSingleShot(true);
|
||||
connect(m_hideTimer, &QTimer::timeout, this, &PreviewFrame::hide);
|
||||
connect(m_hideTimer, &QTimer::timeout, this, &PreviewWindow::hide);
|
||||
|
||||
m_animation = new QPropertyAnimation(this, "arrowPos");
|
||||
m_animation->setDuration(MOVE_ANIMATION_DURATION);
|
||||
m_animation->setEasingCurve(MOVE_ANIMATION_CURVE);
|
||||
}
|
||||
|
||||
PreviewFrame::~PreviewFrame()
|
||||
PreviewWindow::~PreviewWindow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PreviewFrame::showPreview(int x, int y, int interval)
|
||||
void PreviewWindow::showPreview(int x, int y, int interval)
|
||||
{
|
||||
m_hideTimer->stop();
|
||||
|
||||
@ -38,7 +38,7 @@ void PreviewFrame::showPreview(int x, int y, int interval)
|
||||
m_showTimer->start(interval);
|
||||
}
|
||||
|
||||
void PreviewFrame::hidePreview(int interval)
|
||||
void PreviewWindow::hidePreview(int interval)
|
||||
{
|
||||
m_showTimer->stop();
|
||||
|
||||
@ -50,17 +50,17 @@ void PreviewFrame::hidePreview(int interval)
|
||||
m_hideTimer->start(interval);
|
||||
}
|
||||
|
||||
void PreviewFrame::setContent(QWidget *content)
|
||||
void PreviewWindow::setContent(QWidget *content)
|
||||
{
|
||||
m_tmpContent = content;
|
||||
}
|
||||
|
||||
void PreviewFrame::setArrowPos(const QPoint &pos)
|
||||
void PreviewWindow::setArrowPos(const QPoint &pos)
|
||||
{
|
||||
show(pos.x(), pos.y());
|
||||
}
|
||||
|
||||
void PreviewFrame::hide()
|
||||
void PreviewWindow::hide()
|
||||
{
|
||||
|
||||
emit hideFinish(m_lastContent);
|
||||
@ -68,17 +68,17 @@ void PreviewFrame::hide()
|
||||
DArrowRectangle::hide();
|
||||
}
|
||||
|
||||
void PreviewFrame::enterEvent(QEvent *)
|
||||
void PreviewWindow::enterEvent(QEvent *)
|
||||
{
|
||||
m_hideTimer->stop();
|
||||
}
|
||||
|
||||
void PreviewFrame::leaveEvent(QEvent *)
|
||||
void PreviewWindow::leaveEvent(QEvent *)
|
||||
{
|
||||
m_hideTimer->start();
|
||||
}
|
||||
|
||||
void PreviewFrame::onShowTimerTriggered()
|
||||
void PreviewWindow::onShowTimerTriggered()
|
||||
{
|
||||
if (m_lastContent != m_tmpContent)
|
||||
emit showFinish(m_lastContent);
|
@ -1,5 +1,5 @@
|
||||
#ifndef PREVIEWFRAME_H
|
||||
#define PREVIEWFRAME_H
|
||||
#ifndef PREVIEWWINDOW_H
|
||||
#define PREVIEWWINDOW_H
|
||||
|
||||
#include <QTimer>
|
||||
#include <QPropertyAnimation>
|
||||
@ -8,13 +8,13 @@
|
||||
|
||||
DUI_USE_NAMESPACE
|
||||
|
||||
class PreviewFrame : public DArrowRectangle
|
||||
class PreviewWindow : public DArrowRectangle
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QPoint arrowPos READ pos WRITE setArrowPos)
|
||||
public:
|
||||
explicit PreviewFrame(DArrowRectangle::ArrowDirection direction, QWidget *parent = 0);
|
||||
~PreviewFrame();
|
||||
explicit PreviewWindow(DArrowRectangle::ArrowDirection direction, QWidget *parent = 0);
|
||||
~PreviewWindow();
|
||||
|
||||
void showPreview(int x, int y, int interval);
|
||||
void hidePreview(int interval = 0);
|
||||
@ -48,4 +48,4 @@ private:
|
||||
const QEasingCurve MOVE_ANIMATION_CURVE = QEasingCurve::OutCirc;
|
||||
};
|
||||
|
||||
#endif // PREVIEWFRAME_H
|
||||
#endif // PREVIEWWINDOW_H
|
Loading…
x
Reference in New Issue
Block a user