241 lines
6.9 KiB
C++
241 lines
6.9 KiB
C++
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
||
* (c)LGPL2+
|
||
*
|
||
* Copyright: 2011 Razor team
|
||
* 2014 LXQt team
|
||
* Authors:
|
||
* Alexander Sokoloff <sokoloff.a@gmail.com>
|
||
* Maciej Płaza <plaza.maciej@gmail.com>
|
||
* Kuzma Shapran <kuzma.shapran@gmail.com>
|
||
*
|
||
* Copyright: 2019 Tianjin KYLIN Information Technology Co., Ltd. *
|
||
*
|
||
* 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 UKUITASKBAR_H
|
||
#define UKUITASKBAR_H
|
||
|
||
#include "../panel/iukuipanel.h"
|
||
#include "../panel/iukuipanelplugin.h"
|
||
#include "ukuitaskgroup.h"
|
||
#include "ukuitaskbutton.h"
|
||
|
||
#include <QFrame>
|
||
#include <QBoxLayout>
|
||
#include <QMap>
|
||
//#include <lxqt-globalkeys.h>
|
||
#include "../panel/iukuipanel.h"
|
||
#include <KWindowSystem/KWindowSystem>
|
||
#include <KWindowSystem/KWindowInfo>
|
||
#include <KWindowSystem/NETWM>
|
||
#include <QStyleOption>
|
||
#include <QPainter>
|
||
#include <QtDBus/QtDBus>
|
||
#include <QHash>
|
||
#include <QString>
|
||
#include <QVector>
|
||
#include "qlayout.h"
|
||
#include "qlayoutitem.h"
|
||
#include "qlayoutitem.h"
|
||
#include "qgridlayout.h"
|
||
#include <QFileSystemWatcher>
|
||
#include <QtCore/QObject>
|
||
#include <QPushButton>
|
||
#include <QToolButton>
|
||
#include <QScrollArea>
|
||
#include <QScrollBar>
|
||
#include <windowmanager/windowmanager.h>
|
||
|
||
#define DESKTOP_FILE_PATH "/usr/share/applications/"
|
||
#define ANDROID_DESKTOP_FILE_PATH "/.local/share/applications/"
|
||
|
||
QT_BEGIN_NAMESPACE
|
||
class QByteArray;
|
||
template<class T> class QList;
|
||
template<class Key, class Value> class QMap;
|
||
class QString;
|
||
class QStringList;
|
||
class QVariant;
|
||
QT_END_NAMESPACE
|
||
|
||
class XdgDesktopFile;
|
||
class QuickLaunchAction;
|
||
class QSettings;
|
||
class QLabel;
|
||
class QSignalMapper;
|
||
class UKUITaskButton;
|
||
class ElidedButtonStyle;
|
||
|
||
using namespace kdk;
|
||
namespace UKUi {
|
||
class GridLayout;
|
||
}
|
||
|
||
class UKUITaskBar : public QScrollArea
|
||
{
|
||
Q_OBJECT
|
||
|
||
/*
|
||
* 负责与ukui桌面环境应用通信的dbus
|
||
* 在点击任务栏的时候发给其他UKUI DE APP 点击信号
|
||
* 以适应特殊的设计需求以及
|
||
*/
|
||
Q_CLASSINFO("D-Bus Interface", "com.ukui.panel.plugins.taskbar")
|
||
|
||
public:
|
||
explicit UKUITaskBar(IUKUIPanelPlugin *plugin, QWidget* parent = 0);
|
||
virtual ~UKUITaskBar();
|
||
|
||
void realignSdk();
|
||
|
||
Qt::ToolButtonStyle buttonStyle() const { return m_buttonStyle; }
|
||
int showDesktopNum() const { return m_showDesktopNum; }
|
||
bool isGroupingEnabled() const { return m_groupingEnabled; }
|
||
inline IUKUIPanel * panel() const { return m_plugin->panel(); }
|
||
inline IUKUIPanelPlugin * plugin() const { return m_plugin; }
|
||
|
||
///quicklaunch func
|
||
int countOfButtons() const;
|
||
//virtual QLayoutItem *takeAt(int index) = 0;
|
||
void saveSdkSettings();
|
||
void refreshQuickLaunch();
|
||
friend class FilectrlAdaptor;
|
||
QStringList m_ignoreWindow;
|
||
|
||
|
||
signals:
|
||
void buttonStyleRefreshed(Qt::ToolButtonStyle buttonStyle);
|
||
void showOnlySettingChanged();
|
||
void sendToUkuiDEApp(void);
|
||
//quicklaunch
|
||
void refreshIconGeometry();
|
||
|
||
protected:
|
||
void enterEvent(QEvent *);
|
||
void leaveEvent(QEvent *);
|
||
void mousePressEvent(QMouseEvent *);
|
||
void mouseMoveEvent(QMouseEvent *e);
|
||
|
||
private slots:
|
||
|
||
void refreshTaskList();
|
||
void refreshButtonRotation();
|
||
void refreshPlaceholderVisibility();
|
||
void groupSdkBecomeEmptySlot();
|
||
void saveSdkSettingsSlot();
|
||
void onWindowChanged(const WindowId& window);
|
||
void onWindowAdded(const WindowId& window);
|
||
void onWindowRemoved(const WindowId& window);
|
||
void activateSdkTask(int pos);
|
||
void onDesktopChanged();
|
||
|
||
////////////////////////////
|
||
/// quicklaunch slots
|
||
bool checkButton(QuickLaunchAction* action);
|
||
void removeButton(QuickLaunchAction* action);
|
||
void removeButton(QString exec);
|
||
void buttonSdkDeleted();
|
||
void removeFromTaskbar(QString arg);
|
||
void switchButtons(UKUITaskGroup *dst_button, UKUITaskGroup *src_button);
|
||
QString readFile(const QString &filename);
|
||
|
||
void addToTaskbar(QString arg);
|
||
void addSdkToTaskbar(QString arg);
|
||
|
||
void readPanelConfig(bool isTabletMode);
|
||
|
||
void securityControlApps(QString mode);
|
||
|
||
private:
|
||
typedef QMap<WId, UKUITaskGroup*> windowMap_t;
|
||
typedef QMap<qint32, UKUITaskGroup*> windowSdkMap_t;
|
||
|
||
private:
|
||
void addWindow(const WindowId& window);
|
||
void addSdkButton(QuickLaunchAction* action);
|
||
windowSdkMap_t::iterator removeWindow(windowSdkMap_t::iterator pos);
|
||
void buttonMove(UKUITaskGroup * dst, UKUITaskGroup * src, QPoint const & pos);
|
||
void doInitGroupButton(QString sname);
|
||
//黑白名单函数
|
||
void addButtonForQuicklanch(QList<QMap<QString, QVariant> > apps);
|
||
void removeBlackListApp();
|
||
void addWhiteListApp();
|
||
|
||
QString m_mode;
|
||
QDBusInterface *m_interface;
|
||
QStringList m_controlAppList;
|
||
|
||
enum TaskStatus{NORMAL, HOVER, PRESS};
|
||
TaskStatus m_taskStatus;
|
||
|
||
/// quicklaunch parameter
|
||
QVector<UKUITaskGroup*> m_vBtn;
|
||
QGSettings *m_settings;
|
||
|
||
QLabel *m_beginMaskLabel;
|
||
QLabel *m_endMaskLabel;
|
||
QImage *m_maskImg;
|
||
void initMaskUI();
|
||
void setMaskPostion();
|
||
|
||
private:
|
||
QMap<qint32, UKUITaskGroup*> m_knownSdkWindows;
|
||
QList <qint32> m_sdkSwid;
|
||
UKUi::GridLayout *m_layout;
|
||
QSignalMapper *m_signalMapper;
|
||
|
||
// Settings
|
||
Qt::ToolButtonStyle m_buttonStyle;
|
||
int m_buttonWidth;
|
||
int m_buttonHeight;
|
||
|
||
int m_showDesktopNum;
|
||
bool m_autoRotate;
|
||
bool m_groupingEnabled;
|
||
|
||
bool acceptWindow(const WindowId& window) const;
|
||
void setButtonStyle(Qt::ToolButtonStyle buttonStyle);
|
||
void settingsChanged();
|
||
QList<QMap<QString, QVariant> > copyQuicklaunchConfig();
|
||
|
||
void wheelEvent(QWheelEvent* event);
|
||
void changeEvent(QEvent* event);
|
||
void resizeEvent(QResizeEvent *event);
|
||
void directoryUpdated(const QString &path);
|
||
|
||
QFileSystemWatcher *m_fsWatcher;
|
||
QMap<QString, QStringList> m_currentContentsMap; // 当前每个监控的内容目录列表
|
||
QString m_desfktopFilePath =DESKTOP_FILE_PATH;
|
||
QString m_androidDesktopFilePath =QDir::homePath()+ANDROID_DESKTOP_FILE_PATH;
|
||
|
||
IUKUIPanelPlugin *m_plugin;
|
||
LeftAlignedTextStyle *m_style;
|
||
QWidget *m_allFrame;
|
||
QWidget *m_placeHolder;
|
||
QGSettings *m_changeTheme;
|
||
|
||
public slots:
|
||
void WindowAddtoTaskBar(QString arg);
|
||
// void WindowSdkAddtoTaskBar(QString arg);
|
||
void WindowRemovefromTaskBar(QString arg);
|
||
|
||
};
|
||
|
||
#endif // UKUITASKBAR_H
|