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;
|
2020-03-25 21:42:25 +08:00
|
|
|
|
#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;
|
2020-12-24 10:56:48 +08:00
|
|
|
|
QString file;
|
|
|
|
|
|
QString name;
|
|
|
|
|
|
QString exec;
|
2020-08-08 15:05:34 +08:00
|
|
|
|
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
|
2021-01-09 15:03:44 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief contextMenuEvent
|
|
|
|
|
|
* 右键菜单选项,从customContextMenuRequested的方式
|
|
|
|
|
|
* 改为用contextMenuEvent函数处理
|
|
|
|
|
|
*/
|
|
|
|
|
|
void contextMenuEvent(QContextMenuEvent*);
|
2021-01-21 10:18:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief enterEvent leaveEvent
|
|
|
|
|
|
* @param event
|
|
|
|
|
|
* leaveEvent 和 enterEvent仅仅是为了刷新按钮状态
|
|
|
|
|
|
*/
|
2021-01-09 15:03:44 +08:00
|
|
|
|
void enterEvent(QEvent *event);
|
|
|
|
|
|
void leaveEvent(QEvent *event);
|
2021-01-21 10:18:11 +08:00
|
|
|
|
|
2021-01-09 15:03:44 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 以下是拖拽相关函数
|
|
|
|
|
|
*/
|
|
|
|
|
|
void dropEvent(QDropEvent *e);
|
|
|
|
|
|
virtual QMimeData * mimeData();
|
|
|
|
|
|
void dragLeaveEvent(QDragLeaveEvent *e);
|
2020-08-06 20:54:51 +08:00
|
|
|
|
void mousePressEvent(QMouseEvent *e);
|
2020-01-17 17:23:40 +08:00
|
|
|
|
void mouseMoveEvent(QMouseEvent *e);
|
2020-08-06 20:35:27 +08:00
|
|
|
|
void mouseReleaseEvent(QMouseEvent* e);
|
2020-01-17 17:23:40 +08:00
|
|
|
|
void dragEnterEvent(QDragEnterEvent *e);
|
2020-08-06 20:54:51 +08:00
|
|
|
|
void dragMoveEvent(QDragMoveEvent * e);
|
2020-01-17 17:23:40 +08:00
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
QuickLaunchAction *mAct;
|
|
|
|
|
|
IUKUIPanelPlugin * mPlugin;
|
|
|
|
|
|
QAction *mDeleteAct;
|
|
|
|
|
|
QAction *mMoveLeftAct;
|
|
|
|
|
|
QAction *mMoveRightAct;
|
2021-01-09 15:03:44 +08:00
|
|
|
|
QMenu *mMenu;
|
2020-01-17 17:23:40 +08:00
|
|
|
|
QPoint mDragStart;
|
2021-01-21 10:18:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief The QuickLaunchStatus enum
|
|
|
|
|
|
* 快速启动栏Button的状态
|
|
|
|
|
|
*/
|
2020-03-01 11:55:30 +08:00
|
|
|
|
enum QuickLaunchStatus{NORMAL, HOVER, PRESS};
|
|
|
|
|
|
QuickLaunchStatus quicklanuchstatus;
|
2021-01-21 10:18:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief toolbuttonstyle
|
|
|
|
|
|
* 弃用接口,等待删除
|
|
|
|
|
|
*/
|
2020-03-08 19:30:50 +08:00
|
|
|
|
CustomStyle toolbuttonstyle;
|
2021-01-21 10:18:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief mgsettings
|
|
|
|
|
|
* 弃用,等待删除
|
|
|
|
|
|
*/
|
2020-08-14 11:19:46 +08:00
|
|
|
|
QGSettings *mgsettings;
|
2021-01-21 10:18:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief isComputerOrTrash
|
|
|
|
|
|
* @param urlName
|
|
|
|
|
|
* @return
|
|
|
|
|
|
* 未使用的接口
|
|
|
|
|
|
*/
|
2020-12-24 10:56:48 +08:00
|
|
|
|
QString isComputerOrTrash(QString urlName);
|
2020-01-17 17:23:40 +08:00
|
|
|
|
public slots:
|
|
|
|
|
|
void selfRemove();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2021-01-21 10:18:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @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
|