Files
ukui-panel/plugin-quicklaunch/quicklaunchbutton.h

150 lines
3.9 KiB
C
Raw Permalink Normal View History

2020-01-17 17:23:40 +08:00
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* Copyright: 2010-2012 Razor team
* Authors:
* Petr Vanek <petr@scribus.info>
* Kuzma Shapran <kuzma.shapran@gmail.com>
*
2020-01-19 10:27:16 +08:00
* Copyright: 2019 Tianjin KYLIN Information Technology Co., Ltd. *
2020-01-17 17:23:40 +08:00
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#ifndef UKUIQUICKLAUNCHBUTTON_H
#define UKUIQUICKLAUNCHBUTTON_H
#include "quicklaunchaction.h"
#include <QMimeData>
#include <QToolButton>
2020-03-08 19:30:50 +08:00
#include "../panel/customstyle.h"
#include <QStyleOption>
2020-08-14 11:19:46 +08:00
#include <QGSettings>
2020-03-08 19:30:50 +08:00
#include <QPainter>
2020-01-17 17:23:40 +08:00
class IUKUIPanelPlugin;
2020-03-08 19:30:50 +08:00
//class CustomStyle;
#include "../panel/ukuicontrolstyle.h"
2020-01-17 17:23:40 +08:00
class QuickLaunchButton : public QToolButton
{
Q_OBJECT
public:
QuickLaunchButton(QuickLaunchAction * act, IUKUIPanelPlugin * plugin, QWidget* parent = 0);
~QuickLaunchButton();
QHash<QString,QString> settingsMap();
QString file_name;
QString file;
QString name;
QString exec;
static QString mimeDataFormat() { return QLatin1String("x-ukui/quicklaunch-button"); }
2020-01-17 17:23:40 +08:00
signals:
void buttonDeleted();
void switchButtons(QuickLaunchButton *from, QuickLaunchButton *to);
void movedLeft();
void movedRight();
protected:
//! Disable that annoying small arrow when there is a menu
/**
* @brief contextMenuEvent
* customContextMenuRequested的方式
* contextMenuEvent函数处理
*/
void contextMenuEvent(QContextMenuEvent*);
/**
* @brief enterEvent leaveEvent
* @param event
* leaveEvent enterEvent仅仅是为了刷新按钮状态
*/
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);
/**
*
*/
void dropEvent(QDropEvent *e);
virtual QMimeData * mimeData();
void dragLeaveEvent(QDragLeaveEvent *e);
void mousePressEvent(QMouseEvent *e);
2020-01-17 17:23:40 +08:00
void mouseMoveEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent* e);
2020-01-17 17:23:40 +08:00
void dragEnterEvent(QDragEnterEvent *e);
void dragMoveEvent(QDragMoveEvent * e);
2020-01-17 17:23:40 +08:00
private:
QuickLaunchAction *mAct;
IUKUIPanelPlugin * mPlugin;
QAction *mDeleteAct;
QAction *mMoveLeftAct;
QAction *mMoveRightAct;
QMenu *mMenu;
2020-01-17 17:23:40 +08:00
QPoint mDragStart;
/**
* @brief The QuickLaunchStatus enum
* Button的状态
*/
enum QuickLaunchStatus{NORMAL, HOVER, PRESS};
QuickLaunchStatus quicklanuchstatus;
/**
* @brief toolbuttonstyle
*
*/
2020-03-08 19:30:50 +08:00
CustomStyle toolbuttonstyle;
/**
* @brief mgsettings
*
*/
2020-08-14 11:19:46 +08:00
QGSettings *mgsettings;
/**
* @brief isComputerOrTrash
* @param urlName
* @return
* 使
*/
QString isComputerOrTrash(QString urlName);
2020-01-17 17:23:40 +08:00
public slots:
void selfRemove();
};
/**
* @brief The ButtonMimeData class
*
*/
2020-01-17 17:23:40 +08:00
class ButtonMimeData: public QMimeData
{
Q_OBJECT
public:
ButtonMimeData():
QMimeData(),
mButton(0)
{
}
QuickLaunchButton *button() const { return mButton; }
void setButton(QuickLaunchButton *button) { mButton = button; }
private:
QuickLaunchButton *mButton;
};
#endif