mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
add settings enum
Change-Id: I9d3461dc84d6692c87388183c773d3aba5d9341f
This commit is contained in:
parent
04e950d013
commit
cc6437046a
@ -59,16 +59,16 @@ public:
|
|||||||
inline uint activeWindow() const
|
inline uint activeWindow() const
|
||||||
{ return qvariant_cast< uint >(property("ActiveWindow")); }
|
{ return qvariant_cast< uint >(property("ActiveWindow")); }
|
||||||
|
|
||||||
Q_PROPERTY(int DisplayMode READ displayMode WRITE setDisplayMode NOTIFY DisplayModeChanged)
|
|
||||||
inline int displayMode() const
|
|
||||||
{ return qvariant_cast< int >(property("DisplayMode")); }
|
|
||||||
inline void setDisplayMode(int value)
|
|
||||||
{ setProperty("DisplayMode", QVariant::fromValue(value)); }
|
|
||||||
|
|
||||||
Q_PROPERTY(QList<QDBusObjectPath> Entries READ entries NOTIFY EntriesChanged)
|
Q_PROPERTY(QList<QDBusObjectPath> Entries READ entries NOTIFY EntriesChanged)
|
||||||
inline QList<QDBusObjectPath> entries() const
|
inline QList<QDBusObjectPath> entries() const
|
||||||
{ return qvariant_cast< QList<QDBusObjectPath> >(property("Entries")); }
|
{ return qvariant_cast< QList<QDBusObjectPath> >(property("Entries")); }
|
||||||
|
|
||||||
|
Q_PROPERTY(int DisplayMode READ displayMode WRITE setDisplayMode NOTIFY DisplayModeChanged)
|
||||||
|
inline int displayMode() const
|
||||||
|
{ return int(qvariant_cast< int >(property("DisplayMode"))); }
|
||||||
|
inline void setDisplayMode(int value)
|
||||||
|
{ setProperty("DisplayMode", QVariant::fromValue(int(value))); }
|
||||||
|
|
||||||
Q_PROPERTY(int HideMode READ hideMode WRITE setHideMode NOTIFY HideModeChanged)
|
Q_PROPERTY(int HideMode READ hideMode WRITE setHideMode NOTIFY HideModeChanged)
|
||||||
inline int hideMode() const
|
inline int hideMode() const
|
||||||
{ return qvariant_cast< int >(property("HideMode")); }
|
{ return qvariant_cast< int >(property("HideMode")); }
|
||||||
@ -77,13 +77,13 @@ public:
|
|||||||
|
|
||||||
Q_PROPERTY(int HideState READ hideState NOTIFY HideStateChanged)
|
Q_PROPERTY(int HideState READ hideState NOTIFY HideStateChanged)
|
||||||
inline int hideState() const
|
inline int hideState() const
|
||||||
{ return qvariant_cast< int >(property("HideState")); }
|
{ return int(qvariant_cast< int >(property("HideState"))); }
|
||||||
|
|
||||||
Q_PROPERTY(int Position READ position WRITE setPosition NOTIFY PositionChanged)
|
Q_PROPERTY(int Position READ position WRITE setPosition NOTIFY PositionChanged)
|
||||||
inline int position() const
|
inline int position() const
|
||||||
{ return qvariant_cast< int >(property("Position")); }
|
{ return int(qvariant_cast< int >(property("Position"))); }
|
||||||
inline void setPosition(int value)
|
inline void setPosition(int value)
|
||||||
{ setProperty("Position", QVariant::fromValue(value)); }
|
{ setProperty("Position", QVariant::fromValue(int(value))); }
|
||||||
|
|
||||||
public Q_SLOTS: // METHODS
|
public Q_SLOTS: // METHODS
|
||||||
inline QDBusPendingReply<> ActivateWindow(uint in0)
|
inline QDBusPendingReply<> ActivateWindow(uint in0)
|
||||||
|
@ -69,10 +69,6 @@ public:
|
|||||||
inline QString id() const
|
inline QString id() const
|
||||||
{ return qvariant_cast< QString >(property("Id")); }
|
{ return qvariant_cast< QString >(property("Id")); }
|
||||||
|
|
||||||
Q_PROPERTY(QString Title READ title NOTIFY TitleChanged)
|
|
||||||
inline QString title() const
|
|
||||||
{ return qvariant_cast< QString >(property("Title")); }
|
|
||||||
|
|
||||||
Q_PROPERTY(QString Icon READ icon NOTIFY IconChanged)
|
Q_PROPERTY(QString Icon READ icon NOTIFY IconChanged)
|
||||||
inline QString icon() const
|
inline QString icon() const
|
||||||
{ return qvariant_cast< QString >(property("Icon")); }
|
{ return qvariant_cast< QString >(property("Icon")); }
|
||||||
@ -88,6 +84,11 @@ public Q_SLOTS: // METHODS
|
|||||||
return asyncCallWithArgumentList(QStringLiteral("Activate"), argumentList);
|
return asyncCallWithArgumentList(QStringLiteral("Activate"), argumentList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<> HandleMenuItem(const QString &item)
|
||||||
|
{
|
||||||
|
return asyncCall(QStringLiteral("HandleMenuItem"), item);
|
||||||
|
}
|
||||||
|
|
||||||
inline QDBusPendingReply<> RequestDock()
|
inline QDBusPendingReply<> RequestDock()
|
||||||
{
|
{
|
||||||
return asyncCall(QStringLiteral("RequestDock"));
|
return asyncCall(QStringLiteral("RequestDock"));
|
||||||
|
@ -63,8 +63,8 @@ void AppItem::paintEvent(QPaintEvent *e)
|
|||||||
painter.drawPixmap(rect().center() - m_icon.rect().center(), m_icon);
|
painter.drawPixmap(rect().center() - m_icon.rect().center(), m_icon);
|
||||||
|
|
||||||
// draw text
|
// draw text
|
||||||
painter.setPen(Qt::red);
|
// painter.setPen(Qt::red);
|
||||||
painter.drawText(rect(), m_itemEntry->title());
|
// painter.drawText(rect(), m_itemEntry->title());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppItem::mouseReleaseEvent(QMouseEvent *e)
|
void AppItem::mouseReleaseEvent(QMouseEvent *e)
|
||||||
@ -109,8 +109,9 @@ void AppItem::resizeEvent(QResizeEvent *e)
|
|||||||
|
|
||||||
void AppItem::invokedMenuItem(const QString &itemId, const bool checked)
|
void AppItem::invokedMenuItem(const QString &itemId, const bool checked)
|
||||||
{
|
{
|
||||||
Q_UNUSED(itemId)
|
Q_UNUSED(checked);
|
||||||
Q_UNUSED(checked)
|
|
||||||
|
m_itemEntry->HandleMenuItem(itemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString AppItem::contextMenu() const
|
const QString AppItem::contextMenu() const
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
|
|
||||||
DockItem::DockItem(const ItemType type, QWidget *parent)
|
DockItem::DockItem(const ItemType type, QWidget *parent)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
m_side(DockSide::Top),
|
m_side(Position::Top),
|
||||||
m_type(type),
|
m_type(type),
|
||||||
|
|
||||||
m_menuManagerInter(new DBusMenuManager(this))
|
m_menuManagerInter(new DBusMenuManager(this))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DockItem::setDockSide(const DockSide side)
|
void DockItem::setDockSide(const Position side)
|
||||||
{
|
{
|
||||||
m_side = side;
|
m_side = side;
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
|
|
||||||
|
using namespace Dock;
|
||||||
|
|
||||||
class DBusMenuManager;
|
class DBusMenuManager;
|
||||||
class DockItem : public QWidget
|
class DockItem : public QWidget
|
||||||
{
|
{
|
||||||
@ -20,7 +22,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DockItem(const ItemType type, QWidget *parent = nullptr);
|
explicit DockItem(const ItemType type, QWidget *parent = nullptr);
|
||||||
void setDockSide(const DockSide side);
|
void setDockSide(const Position side);
|
||||||
|
|
||||||
ItemType itemType() const;
|
ItemType itemType() const;
|
||||||
|
|
||||||
@ -36,7 +38,7 @@ protected:
|
|||||||
virtual const QString contextMenu() const;
|
virtual const QString contextMenu() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DockSide m_side;
|
Position m_side;
|
||||||
ItemType m_type;
|
ItemType m_type;
|
||||||
|
|
||||||
DBusMenuManager *m_menuManagerInter;
|
DBusMenuManager *m_menuManagerInter;
|
||||||
|
@ -35,14 +35,14 @@ MainPanel::MainPanel(QWidget *parent)
|
|||||||
setLayout(m_itemLayout);
|
setLayout(m_itemLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanel::updateDockSide(const DockSide dockSide)
|
void MainPanel::updateDockSide(const Position dockSide)
|
||||||
{
|
{
|
||||||
switch (dockSide)
|
switch (dockSide)
|
||||||
{
|
{
|
||||||
case DockSide::Top:
|
case Position::Top:
|
||||||
case DockSide::Bottom: m_itemLayout->setDirection(QBoxLayout::LeftToRight); break;
|
case Position::Bottom: m_itemLayout->setDirection(QBoxLayout::LeftToRight); break;
|
||||||
case DockSide::Left:
|
case Position::Left:
|
||||||
case DockSide::Right: m_itemLayout->setDirection(QBoxLayout::TopToBottom); break;
|
case Position::Right: m_itemLayout->setDirection(QBoxLayout::TopToBottom); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class MainPanel : public QFrame
|
|||||||
public:
|
public:
|
||||||
explicit MainPanel(QWidget *parent = 0);
|
explicit MainPanel(QWidget *parent = 0);
|
||||||
|
|
||||||
void updateDockSide(const DockSide dockSide);
|
void updateDockSide(const Position dockSide);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resizeEvent(QResizeEvent *e);
|
void resizeEvent(QResizeEvent *e);
|
||||||
|
@ -3,13 +3,16 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
DockSettings::DockSettings(QObject *parent)
|
DockSettings::DockSettings(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent),
|
||||||
|
m_dockInter(new DBusDock(this)),
|
||||||
|
m_itemController(DockItemController::instance(this))
|
||||||
{
|
{
|
||||||
|
m_position = Dock::Position(m_dockInter->position());
|
||||||
}
|
}
|
||||||
|
|
||||||
DockSide DockSettings::side() const
|
Position DockSettings::position() const
|
||||||
{
|
{
|
||||||
return Bottom;
|
return m_position;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QSize DockSettings::mainWindowSize() const
|
const QSize DockSettings::mainWindowSize() const
|
||||||
|
@ -2,10 +2,14 @@
|
|||||||
#define DOCKSETTINGS_H
|
#define DOCKSETTINGS_H
|
||||||
|
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
|
#include "dbus/dbusdock.h"
|
||||||
|
#include "controller/dockitemcontroller.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
|
|
||||||
|
using namespace Dock;
|
||||||
|
|
||||||
class DockSettings : public QObject
|
class DockSettings : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -13,17 +17,23 @@ class DockSettings : public QObject
|
|||||||
public:
|
public:
|
||||||
explicit DockSettings(QObject *parent = 0);
|
explicit DockSettings(QObject *parent = 0);
|
||||||
|
|
||||||
DockSide side() const;
|
Position position() const;
|
||||||
const QSize mainWindowSize() const;
|
const QSize mainWindowSize() const;
|
||||||
|
|
||||||
public slots:
|
|
||||||
void updateGeometry();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dataChanged() const;
|
void dataChanged() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void updateGeometry();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Position m_position;
|
||||||
QSize m_mainWindowSize;
|
QSize m_mainWindowSize;
|
||||||
|
|
||||||
|
DBusDock *m_dockInter;
|
||||||
|
DockItemController *m_itemController;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DOCKSETTINGS_H
|
#endif // DOCKSETTINGS_H
|
||||||
|
@ -87,7 +87,7 @@ void MainWindow::setStrutPartial()
|
|||||||
// first, clear old strut partial
|
// first, clear old strut partial
|
||||||
clearStrutPartial();
|
clearStrutPartial();
|
||||||
|
|
||||||
const DockSide side = m_settings->side();
|
const Position side = m_settings->position();
|
||||||
const int maxScreenHeight = m_displayInter->screenHeight();
|
const int maxScreenHeight = m_displayInter->screenHeight();
|
||||||
|
|
||||||
XcbMisc::Orientation orientation;
|
XcbMisc::Orientation orientation;
|
||||||
@ -99,25 +99,25 @@ void MainWindow::setStrutPartial()
|
|||||||
const QRect r = rect();
|
const QRect r = rect();
|
||||||
switch (side)
|
switch (side)
|
||||||
{
|
{
|
||||||
case DockSide::Top:
|
case Position::Top:
|
||||||
orientation = XcbMisc::OrientationTop;
|
orientation = XcbMisc::OrientationTop;
|
||||||
strut = r.bottom();
|
strut = r.bottom();
|
||||||
strutStart = r.left();
|
strutStart = r.left();
|
||||||
strutEnd = r.right();
|
strutEnd = r.right();
|
||||||
break;
|
break;
|
||||||
case DockSide::Bottom:
|
case Position::Bottom:
|
||||||
orientation = XcbMisc::OrientationBottom;
|
orientation = XcbMisc::OrientationBottom;
|
||||||
strut = maxScreenHeight - p.y();
|
strut = maxScreenHeight - p.y();
|
||||||
strutStart = r.left();
|
strutStart = r.left();
|
||||||
strutEnd = r.right();
|
strutEnd = r.right();
|
||||||
break;
|
break;
|
||||||
case DockSide::Left:
|
case Position::Left:
|
||||||
orientation = XcbMisc::OrientationLeft;
|
orientation = XcbMisc::OrientationLeft;
|
||||||
strut = r.width();
|
strut = r.width();
|
||||||
strutStart = r.top();
|
strutStart = r.top();
|
||||||
strutEnd = r.bottom();
|
strutEnd = r.bottom();
|
||||||
break;
|
break;
|
||||||
case DockSide::Right:
|
case Position::Right:
|
||||||
orientation = XcbMisc::OrientationRight;
|
orientation = XcbMisc::OrientationRight;
|
||||||
strut = r.width();
|
strut = r.width();
|
||||||
strutStart = r.top();
|
strutStart = r.top();
|
||||||
|
@ -1,11 +1,38 @@
|
|||||||
#ifndef CONSTANTS_H
|
#ifndef CONSTANTS_H
|
||||||
#define CONSTANTS_H
|
#define CONSTANTS_H
|
||||||
|
|
||||||
enum DockSide {
|
namespace Dock {
|
||||||
Top,
|
|
||||||
Bottom,
|
enum DisplayMode
|
||||||
Left,
|
{
|
||||||
Right,
|
Fashion = 0,
|
||||||
|
Efficient = 1,
|
||||||
|
// deprecreated
|
||||||
|
// Classic = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum HideMode
|
||||||
|
{
|
||||||
|
KeepShowing = 0,
|
||||||
|
KeepHidden = 1,
|
||||||
|
SmartHide = 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Position
|
||||||
|
{
|
||||||
|
Top = 0,
|
||||||
|
Right = 1,
|
||||||
|
Bottom = 2,
|
||||||
|
Left = 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum HideState
|
||||||
|
{
|
||||||
|
Unknown = 0,
|
||||||
|
Show = 1,
|
||||||
|
Hide = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // CONSTANTS_H
|
#endif // CONSTANTS_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user