mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
add app item
Change-Id: I74a2bfd9f5b6658ef66e8a5ab072f3da9137ea1d
This commit is contained in:
parent
68d8db4d25
commit
655683b70f
@ -1,5 +1,6 @@
|
|||||||
#include "dockitemcontroller.h"
|
#include "dockitemcontroller.h"
|
||||||
#include "dbus/dbusdockentry.h"
|
#include "dbus/dbusdockentry.h"
|
||||||
|
#include "item/appitem.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
@ -13,8 +14,20 @@ DockItemController *DockItemController::instance(QObject *parent)
|
|||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DockItemController::~DockItemController()
|
||||||
|
{
|
||||||
|
qDeleteAll(m_itemList);
|
||||||
|
}
|
||||||
|
|
||||||
|
const QList<DockItem *> DockItemController::itemList() const
|
||||||
|
{
|
||||||
|
return m_itemList;
|
||||||
|
}
|
||||||
|
|
||||||
DockItemController::DockItemController(QObject *parent)
|
DockItemController::DockItemController(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
m_entryManager(new DBusDockEntryManager(this))
|
m_entryManager(new DBusDockEntryManager(this))
|
||||||
{
|
{
|
||||||
|
for (auto entry : m_entryManager->entries())
|
||||||
|
m_itemList.append(new AppItem(entry));
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define DOCKITEMCONTROLLER_H
|
#define DOCKITEMCONTROLLER_H
|
||||||
|
|
||||||
#include "dbus/dbusdockentrymanager.h"
|
#include "dbus/dbusdockentrymanager.h"
|
||||||
|
#include "item/dockitem.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
@ -11,13 +12,19 @@ class DockItemController : public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static DockItemController *instance(QObject *parent);
|
static DockItemController *instance(QObject *parent);
|
||||||
|
~DockItemController();
|
||||||
|
|
||||||
|
const QList<DockItem *> itemList() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dockItemCountChanged() const;
|
void dockItemCountChanged(const int count) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit DockItemController(QObject *parent = 0);
|
explicit DockItemController(QObject *parent = 0);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList<DockItem *> m_itemList;
|
||||||
|
|
||||||
DBusDockEntryManager *m_entryManager;
|
DBusDockEntryManager *m_entryManager;
|
||||||
|
|
||||||
static DockItemController *INSTANCE;
|
static DockItemController *INSTANCE;
|
||||||
|
54
dbus/dbusdisplay.cpp
Normal file
54
dbus/dbusdisplay.cpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* This file was generated by qdbusxml2cpp version 0.8
|
||||||
|
* Command line was: qdbusxml2cpp -p DBusDisplay -c DBusDisplay com.deepin.daemon.Display.xml
|
||||||
|
*
|
||||||
|
* qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
*
|
||||||
|
* This is an auto-generated file.
|
||||||
|
* This file may have been hand-edited. Look for HAND-EDIT comments
|
||||||
|
* before re-generating it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "dbusdisplay.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Implementation of interface class DBusDisplay
|
||||||
|
*/
|
||||||
|
|
||||||
|
DBusDisplay::DBusDisplay(QObject *parent)
|
||||||
|
: QDBusAbstractInterface(staticServiceName(), staticObjectPath(), staticInterfaceName(), QDBusConnection::sessionBus(), parent)
|
||||||
|
{
|
||||||
|
qDBusRegisterMetaType<BrightnessMap>();
|
||||||
|
qDBusRegisterMetaType<DisplayRect>();
|
||||||
|
|
||||||
|
QDBusConnection::sessionBus().connect(this->service(), this->path(), "org.freedesktop.DBus.Properties", "PropertiesChanged","sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage)));
|
||||||
|
}
|
||||||
|
|
||||||
|
DBusDisplay::~DBusDisplay()
|
||||||
|
{
|
||||||
|
QDBusConnection::sessionBus().disconnect(service(), path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(propertyChanged(QDBusMessage)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QDBusArgument &operator<<(QDBusArgument &argument, const DisplayRect &rect)
|
||||||
|
{
|
||||||
|
argument.beginStructure();
|
||||||
|
argument << rect.x << rect.y << rect.width << rect.height;
|
||||||
|
argument.endStructure();
|
||||||
|
return argument;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QDBusArgument &operator>>(const QDBusArgument &argument, DisplayRect &rect)
|
||||||
|
{
|
||||||
|
argument.beginStructure();
|
||||||
|
argument >> rect.x >> rect.y >> rect.width >> rect.height;
|
||||||
|
argument.endStructure();
|
||||||
|
return argument;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug deg, const DisplayRect &rect)
|
||||||
|
{
|
||||||
|
qDebug() << "x:" << rect.x << "y:" << rect.y << "width:" << rect.width << "height:" << rect.height;
|
||||||
|
|
||||||
|
return deg;
|
||||||
|
}
|
229
dbus/dbusdisplay.h
Normal file
229
dbus/dbusdisplay.h
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
/*
|
||||||
|
* This file was generated by qdbusxml2cpp version 0.8
|
||||||
|
* Command line was: qdbusxml2cpp -p DBusDisplay -c DBusDisplay com.deepin.daemon.Display.xml
|
||||||
|
*
|
||||||
|
* qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
*
|
||||||
|
* This is an auto-generated file.
|
||||||
|
* Do not edit! All changes made to it will be lost.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DBUSDISPLAY_H_1439948860
|
||||||
|
#define DBUSDISPLAY_H_1439948860
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QByteArray>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
#include <QtCore/QMap>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
#include <QtCore/QVariant>
|
||||||
|
#include <QtDBus/QtDBus>
|
||||||
|
|
||||||
|
typedef QMap<QString, double> BrightnessMap;
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(BrightnessMap)
|
||||||
|
|
||||||
|
struct DisplayRect{
|
||||||
|
qint16 x;
|
||||||
|
qint16 y;
|
||||||
|
quint16 width;
|
||||||
|
quint16 height;
|
||||||
|
|
||||||
|
operator QRect() const
|
||||||
|
{
|
||||||
|
return QRect(x, y, width, height);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(DisplayRect)
|
||||||
|
|
||||||
|
QDBusArgument &operator<<(QDBusArgument &argument, const DisplayRect &rect);
|
||||||
|
const QDBusArgument &operator>>(const QDBusArgument &argument, DisplayRect &rect);
|
||||||
|
QDebug operator<<(QDebug deg, const DisplayRect &rect);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Proxy class for interface com.deepin.daemon.Display
|
||||||
|
*/
|
||||||
|
class DBusDisplay: public QDBusAbstractInterface
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_SLOT void __propertyChanged__(const QDBusMessage& msg)
|
||||||
|
{
|
||||||
|
QList<QVariant> arguments = msg.arguments();
|
||||||
|
if (3 != arguments.count())
|
||||||
|
return;
|
||||||
|
QString interfaceName = msg.arguments().at(0).toString();
|
||||||
|
if (interfaceName !="com.deepin.daemon.Display")
|
||||||
|
return;
|
||||||
|
QVariantMap changedProps = qdbus_cast<QVariantMap>(arguments.at(1).value<QDBusArgument>());
|
||||||
|
QStringList keys = changedProps.keys();
|
||||||
|
foreach(const QString &prop, keys) {
|
||||||
|
const QMetaObject* self = metaObject();
|
||||||
|
for (int i=self->propertyOffset(); i < self->propertyCount(); ++i) {
|
||||||
|
QMetaProperty p = self->property(i);
|
||||||
|
if (p.name() == prop) {
|
||||||
|
Q_EMIT p.notifySignal().invoke(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
static inline const char *staticInterfaceName()
|
||||||
|
{ return "com.deepin.daemon.Display"; }
|
||||||
|
static inline const char *staticServiceName()
|
||||||
|
{ return "com.deepin.daemon.Display"; }
|
||||||
|
static inline const char *staticObjectPath()
|
||||||
|
{ return "/com/deepin/daemon/Display"; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DBusDisplay(QObject *parent = 0);
|
||||||
|
|
||||||
|
~DBusDisplay();
|
||||||
|
|
||||||
|
Q_PROPERTY(BrightnessMap Brightness READ brightness NOTIFY BrightnessChanged)
|
||||||
|
inline BrightnessMap brightness() const
|
||||||
|
{ return qvariant_cast< BrightnessMap >(property("Brightness")); }
|
||||||
|
|
||||||
|
Q_PROPERTY(QDBusObjectPath BuiltinOutput READ builtinOutput NOTIFY BuiltinOutputChanged)
|
||||||
|
inline QDBusObjectPath builtinOutput() const
|
||||||
|
{ return qvariant_cast< QDBusObjectPath >(property("BuiltinOutput")); }
|
||||||
|
|
||||||
|
Q_PROPERTY(short DisplayMode READ displayMode NOTIFY DisplayModeChanged)
|
||||||
|
inline short displayMode() const
|
||||||
|
{ return qvariant_cast< short >(property("DisplayMode")); }
|
||||||
|
|
||||||
|
Q_PROPERTY(bool HasChanged READ hasChanged NOTIFY HasChangedChanged)
|
||||||
|
inline bool hasChanged() const
|
||||||
|
{ return qvariant_cast< bool >(property("HasChanged")); }
|
||||||
|
|
||||||
|
Q_PROPERTY(QList<QDBusObjectPath> Monitors READ monitors NOTIFY MonitorsChanged)
|
||||||
|
inline QList<QDBusObjectPath> monitors() const
|
||||||
|
{ return qvariant_cast< QList<QDBusObjectPath> >(property("Monitors")); }
|
||||||
|
|
||||||
|
Q_PROPERTY(QString Primary READ primary NOTIFY PrimaryChanged)
|
||||||
|
inline QString primary() const
|
||||||
|
{ return qvariant_cast< QString >(property("Primary")); }
|
||||||
|
|
||||||
|
Q_PROPERTY(DisplayRect PrimaryRect READ primaryRect NOTIFY PrimaryRectChanged)
|
||||||
|
inline DisplayRect primaryRect() const
|
||||||
|
{ return qvariant_cast< DisplayRect >(property("PrimaryRect")); }
|
||||||
|
|
||||||
|
Q_PROPERTY(ushort ScreenHeight READ screenHeight NOTIFY ScreenHeightChanged)
|
||||||
|
inline ushort screenHeight() const
|
||||||
|
{ return qvariant_cast< ushort >(property("ScreenHeight")); }
|
||||||
|
|
||||||
|
Q_PROPERTY(ushort ScreenWidth READ screenWidth NOTIFY ScreenWidthChanged)
|
||||||
|
inline ushort screenWidth() const
|
||||||
|
{ return qvariant_cast< ushort >(property("ScreenWidth")); }
|
||||||
|
|
||||||
|
public Q_SLOTS: // METHODS
|
||||||
|
inline QDBusPendingReply<> Apply()
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("Apply"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<> AssociateTouchScreen(const QString &in0, const QString &in1)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("AssociateTouchScreen"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<> ChangeBrightness(const QString &in0, double in1)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("ChangeBrightness"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<> JoinMonitor(const QString &in0, const QString &in1)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("JoinMonitor"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<QString> QueryCurrentPlanName()
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("QueryCurrentPlanName"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<int> QueryOutputFeature(const QString &in0)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("QueryOutputFeature"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<> Reset()
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("Reset"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<> ResetBrightness(const QString &in0)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("ResetBrightness"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<> ResetChanges()
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("ResetChanges"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<> SaveChanges()
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("SaveChanges"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<> SetBrightness(const QString &in0, double in1)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("SetBrightness"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<> SetPrimary(const QString &in0)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("SetPrimary"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<> SplitMonitor(const QString &in0)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("SplitMonitor"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<> SwitchMode(short in0, const QString &in1)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("SwitchMode"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_SIGNALS: // SIGNALS
|
||||||
|
// void PrimaryChanged(const QRect &in0);
|
||||||
|
// begin property changed signals
|
||||||
|
void BrightnessChanged();
|
||||||
|
void BuiltinOutputChanged();
|
||||||
|
void DisplayModeChanged();
|
||||||
|
void HasChangedChanged();
|
||||||
|
void MonitorsChanged();
|
||||||
|
void PrimaryChanged();
|
||||||
|
void PrimaryRectChanged();
|
||||||
|
void ScreenHeightChanged();
|
||||||
|
void ScreenWidthChanged();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -13,7 +13,9 @@ SOURCES += main.cpp \
|
|||||||
item/dockitem.cpp \
|
item/dockitem.cpp \
|
||||||
panel/mainpanel.cpp \
|
panel/mainpanel.cpp \
|
||||||
controller/dockitemcontroller.cpp \
|
controller/dockitemcontroller.cpp \
|
||||||
dbus/dbusdockentry.cpp
|
dbus/dbusdockentry.cpp \
|
||||||
|
dbus/dbusdisplay.cpp \
|
||||||
|
item/appitem.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
window/mainwindow.h \
|
window/mainwindow.h \
|
||||||
@ -22,4 +24,6 @@ HEADERS += \
|
|||||||
item/dockitem.h \
|
item/dockitem.h \
|
||||||
panel/mainpanel.h \
|
panel/mainpanel.h \
|
||||||
controller/dockitemcontroller.h \
|
controller/dockitemcontroller.h \
|
||||||
dbus/dbusdockentry.h
|
dbus/dbusdockentry.h \
|
||||||
|
dbus/dbusdisplay.h \
|
||||||
|
item/appitem.h
|
||||||
|
19
item/appitem.cpp
Normal file
19
item/appitem.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include "appitem.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
||||||
|
: DockItem(parent),
|
||||||
|
m_itemEntry(new DBusDockEntry(entry.path(), this))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppItem::paintEvent(QPaintEvent *e)
|
||||||
|
{
|
||||||
|
DockItem::paintEvent(e);
|
||||||
|
|
||||||
|
QPainter painter(this);
|
||||||
|
painter.fillRect(rect(), Qt::cyan);
|
||||||
|
painter.drawText(rect(), m_itemEntry->id());
|
||||||
|
}
|
21
item/appitem.h
Normal file
21
item/appitem.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef APPITEM_H
|
||||||
|
#define APPITEM_H
|
||||||
|
|
||||||
|
#include "dockitem.h"
|
||||||
|
#include "dbus/dbusdockentry.h"
|
||||||
|
|
||||||
|
class AppItem : public DockItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit AppItem(const QDBusObjectPath &entry, QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void paintEvent(QPaintEvent *e);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DBusDockEntry *m_itemEntry;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // APPITEM_H
|
@ -5,3 +5,8 @@ DockItem::DockItem(QWidget *parent)
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DockItem::paintEvent(QPaintEvent *e)
|
||||||
|
{
|
||||||
|
QWidget::paintEvent(e);
|
||||||
|
}
|
||||||
|
@ -7,8 +7,17 @@ class DockItem : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
enum ItemType {
|
||||||
|
Launcher,
|
||||||
|
App,
|
||||||
|
Plugins,
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DockItem(QWidget *parent = 0);
|
explicit DockItem(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *e);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DOCKITEM_H
|
#endif // DOCKITEM_H
|
||||||
|
@ -1,7 +1,22 @@
|
|||||||
#include "mainpanel.h"
|
#include "mainpanel.h"
|
||||||
|
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
MainPanel::MainPanel(QWidget *parent)
|
MainPanel::MainPanel(QWidget *parent)
|
||||||
: QFrame(parent)
|
: QFrame(parent),
|
||||||
|
m_itemController(DockItemController::instance(this))
|
||||||
{
|
{
|
||||||
setStyleSheet("background-color:red;");
|
setObjectName("MainPanel");
|
||||||
|
setStyleSheet("QWidget #MainPanel {"
|
||||||
|
"border:none;"
|
||||||
|
"background-color:red;"
|
||||||
|
// "border-radius:5px 5px 5px 5px;"
|
||||||
|
"}");
|
||||||
|
|
||||||
|
QHBoxLayout *layout = new QHBoxLayout;
|
||||||
|
setLayout(layout);
|
||||||
|
|
||||||
|
const QList<DockItem *> itemList = m_itemController->itemList();
|
||||||
|
for (auto item : itemList)
|
||||||
|
layout->addWidget(item);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef MAINPANEL_H
|
#ifndef MAINPANEL_H
|
||||||
#define MAINPANEL_H
|
#define MAINPANEL_H
|
||||||
|
|
||||||
|
#include "controller/dockitemcontroller.h"
|
||||||
|
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
|
|
||||||
class MainPanel : public QFrame
|
class MainPanel : public QFrame
|
||||||
@ -9,6 +11,9 @@ class MainPanel : public QFrame
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainPanel(QWidget *parent = 0);
|
explicit MainPanel(QWidget *parent = 0);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DockItemController *m_itemController;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINPANEL_H
|
#endif // MAINPANEL_H
|
||||||
|
@ -5,9 +5,22 @@
|
|||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
|
m_position(BOTTOM),
|
||||||
|
|
||||||
m_mainPanel(new MainPanel(this)),
|
m_mainPanel(new MainPanel(this)),
|
||||||
m_itemController(DockItemController::instance(this))
|
|
||||||
|
m_displayInter(new DBusDisplay(this)),
|
||||||
|
|
||||||
|
m_positionUpdateTimer(new QTimer(this))
|
||||||
{
|
{
|
||||||
|
setWindowFlags(Qt::FramelessWindowHint);
|
||||||
|
setAttribute(Qt::WA_TranslucentBackground);
|
||||||
|
|
||||||
|
connect(m_positionUpdateTimer, &QTimer::timeout, this, &MainWindow::updatePosition);
|
||||||
|
|
||||||
|
m_positionUpdateTimer->setSingleShot(true);
|
||||||
|
m_positionUpdateTimer->setInterval(200);
|
||||||
|
m_positionUpdateTimer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::resizeEvent(QResizeEvent *e)
|
void MainWindow::resizeEvent(QResizeEvent *e)
|
||||||
@ -16,3 +29,24 @@ void MainWindow::resizeEvent(QResizeEvent *e)
|
|||||||
|
|
||||||
m_mainPanel->setFixedSize(e->size());
|
m_mainPanel->setFixedSize(e->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::keyPressEvent(QKeyEvent *e)
|
||||||
|
{
|
||||||
|
switch (e->key())
|
||||||
|
{
|
||||||
|
#ifdef QT_DEBUG
|
||||||
|
case Qt::Key_Escape: qApp->quit(); break;
|
||||||
|
#endif
|
||||||
|
default:;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::updatePosition()
|
||||||
|
{
|
||||||
|
const QRect rect = m_displayInter->primaryRect();
|
||||||
|
|
||||||
|
setFixedWidth(rect.width());
|
||||||
|
setFixedHeight(80);
|
||||||
|
|
||||||
|
move(0, 0);
|
||||||
|
}
|
||||||
|
@ -3,22 +3,40 @@
|
|||||||
|
|
||||||
#include "xcb/xcb_misc.h"
|
#include "xcb/xcb_misc.h"
|
||||||
#include "panel/mainpanel.h"
|
#include "panel/mainpanel.h"
|
||||||
#include "controller/dockitemcontroller.h"
|
#include "dbus/dbusdisplay.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
class MainWindow : public QWidget
|
class MainWindow : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
enum Position {
|
||||||
|
TOP,
|
||||||
|
BOTTOM,
|
||||||
|
LEFT,
|
||||||
|
RIGHT,
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = 0);
|
explicit MainWindow(QWidget *parent = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resizeEvent(QResizeEvent *e);
|
void resizeEvent(QResizeEvent *e);
|
||||||
|
void keyPressEvent(QKeyEvent *e);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updatePosition();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Position m_position;
|
||||||
|
|
||||||
MainPanel *m_mainPanel;
|
MainPanel *m_mainPanel;
|
||||||
DockItemController *m_itemController;
|
|
||||||
|
DBusDisplay *m_displayInter;
|
||||||
|
|
||||||
|
QTimer *m_positionUpdateTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user