mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
add panel settings menu
Change-Id: I8cca172b7c07d427447f8c5cd45bda1e6d7ef610
This commit is contained in:
parent
cc6437046a
commit
b24569cee1
@ -5,3 +5,8 @@ PlaceholderItem::PlaceholderItem(QWidget *parent)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
}
|
||||
|
||||
void PlaceholderItem::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
QWidget::mousePressEvent(e);
|
||||
}
|
||||
|
@ -9,6 +9,9 @@ class PlaceholderItem : public DockItem
|
||||
|
||||
public:
|
||||
explicit PlaceholderItem(QWidget *parent = 0);
|
||||
|
||||
private:
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
};
|
||||
|
||||
#endif // PLACEHOLDERITEM_H
|
||||
|
@ -2,12 +2,80 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#define ICON_SIZE_LARGE 48
|
||||
#define ICON_SIZE_MEDIUM 36
|
||||
#define ICON_SIZE_SMALL 24
|
||||
|
||||
DockSettings::DockSettings(QObject *parent)
|
||||
: QObject(parent),
|
||||
|
||||
m_settingsMenu(this),
|
||||
m_fashionModeAct(tr("Fashion Mode"), this),
|
||||
m_efficientModeAct(tr("Efficient Mode"), this),
|
||||
m_topPosAct(tr("Top"), this),
|
||||
m_bottomPosAct(tr("Bottom"), this),
|
||||
m_leftPosAct(tr("Left"), this),
|
||||
m_rightPosAct(tr("Right"), this),
|
||||
m_largeSizeAct(tr("Large"), this),
|
||||
m_mediumSizeAct(tr("Medium"), this),
|
||||
m_smallSizeAct(tr("Small"), this),
|
||||
m_keepShownAct(tr("Keep Shown"), this),
|
||||
m_keepHiddenAct(tr("Keep Hidden"), this),
|
||||
m_smartHideAct(tr("Smart Hide"), this),
|
||||
|
||||
m_dockInter(new DBusDock(this)),
|
||||
m_itemController(DockItemController::instance(this))
|
||||
{
|
||||
m_position = Dock::Position(m_dockInter->position());
|
||||
m_displayMode = Dock::DisplayMode(m_dockInter->displayMode());
|
||||
|
||||
m_fashionModeAct.setCheckable(true);
|
||||
m_efficientModeAct.setCheckable(true);
|
||||
m_topPosAct.setCheckable(true);
|
||||
m_bottomPosAct.setCheckable(true);
|
||||
m_leftPosAct.setCheckable(true);
|
||||
m_rightPosAct.setCheckable(true);
|
||||
m_largeSizeAct.setCheckable(true);
|
||||
m_mediumSizeAct.setCheckable(true);
|
||||
m_smallSizeAct.setCheckable(true);
|
||||
m_keepShownAct.setCheckable(true);
|
||||
m_keepHiddenAct.setCheckable(true);
|
||||
m_smartHideAct.setCheckable(true);
|
||||
|
||||
DMenu *modeSubMenu = new DMenu(&m_settingsMenu);
|
||||
modeSubMenu->addAction(&m_fashionModeAct);
|
||||
modeSubMenu->addAction(&m_efficientModeAct);
|
||||
DAction *modeSubMenuAct = new DAction(tr("Mode"), this);
|
||||
modeSubMenuAct->setMenu(modeSubMenu);
|
||||
|
||||
DMenu *locationSubMenu = new DMenu(&m_settingsMenu);
|
||||
locationSubMenu->addAction(&m_topPosAct);
|
||||
locationSubMenu->addAction(&m_bottomPosAct);
|
||||
locationSubMenu->addAction(&m_leftPosAct);
|
||||
locationSubMenu->addAction(&m_rightPosAct);
|
||||
DAction *locationSubMenuAct = new DAction(tr("Location"), this);
|
||||
locationSubMenuAct->setMenu(locationSubMenu);
|
||||
|
||||
DMenu *sizeSubMenu = new DMenu(&m_settingsMenu);
|
||||
sizeSubMenu->addAction(&m_largeSizeAct);
|
||||
sizeSubMenu->addAction(&m_mediumSizeAct);
|
||||
sizeSubMenu->addAction(&m_smallSizeAct);
|
||||
DAction *sizeSubMenuAct = new DAction(tr("Size"), this);
|
||||
sizeSubMenuAct->setMenu(sizeSubMenu);
|
||||
|
||||
DMenu *statusSubMenu = new DMenu(&m_settingsMenu);
|
||||
statusSubMenu->addAction(&m_keepShownAct);
|
||||
statusSubMenu->addAction(&m_keepHiddenAct);
|
||||
statusSubMenu->addAction(&m_smartHideAct);
|
||||
DAction *statusSubMenuAct = new DAction(tr("Status"), this);
|
||||
statusSubMenuAct->setMenu(statusSubMenu);
|
||||
|
||||
m_settingsMenu.addAction(modeSubMenuAct);
|
||||
m_settingsMenu.addAction(locationSubMenuAct);
|
||||
m_settingsMenu.addAction(sizeSubMenuAct);
|
||||
m_settingsMenu.addAction(statusSubMenuAct);
|
||||
|
||||
connect(&m_settingsMenu, &DMenu::triggered, this, &DockSettings::menuActionClicked);
|
||||
}
|
||||
|
||||
Position DockSettings::position() const
|
||||
@ -20,7 +88,49 @@ const QSize DockSettings::mainWindowSize() const
|
||||
return m_mainWindowSize;
|
||||
}
|
||||
|
||||
void DockSettings::showDockSettingsMenu()
|
||||
{
|
||||
m_fashionModeAct.setChecked(m_displayMode == Fashion);
|
||||
m_efficientModeAct.setChecked(m_displayMode == Efficient);
|
||||
m_topPosAct.setChecked(m_position == Top);
|
||||
m_bottomPosAct.setChecked(m_position == Bottom);
|
||||
m_leftPosAct.setChecked(m_position == Left);
|
||||
m_rightPosAct.setChecked(m_position == Right);
|
||||
m_largeSizeAct.setChecked(m_iconSize == ICON_SIZE_LARGE);
|
||||
m_mediumSizeAct.setChecked(m_iconSize == ICON_SIZE_MEDIUM);
|
||||
m_smallSizeAct.setChecked(m_iconSize == ICON_SIZE_SMALL);
|
||||
m_keepShownAct.setChecked(m_hideMode == KeepShowing);
|
||||
m_keepHiddenAct.setChecked(m_hideMode == KeepHidden);
|
||||
m_smartHideAct.setChecked(m_hideMode == SmartHide);
|
||||
|
||||
m_settingsMenu.exec();
|
||||
}
|
||||
|
||||
void DockSettings::updateGeometry()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DockSettings::menuActionClicked(DAction *action)
|
||||
{
|
||||
Q_ASSERT(action);
|
||||
|
||||
if (action == &m_fashionModeAct)
|
||||
return m_dockInter->setDisplayMode(Fashion);
|
||||
if (action == &m_efficientModeAct)
|
||||
return m_dockInter->setDisplayMode(Efficient);
|
||||
if (action == &m_topPosAct)
|
||||
return m_dockInter->setPosition(Top);
|
||||
if (action == &m_bottomPosAct)
|
||||
return m_dockInter->setPosition(Bottom);
|
||||
if (action == &m_leftPosAct)
|
||||
return m_dockInter->setPosition(Left);
|
||||
if (action == &m_rightPosAct)
|
||||
return m_dockInter->setPosition(Right);
|
||||
if (action == &m_keepShownAct)
|
||||
return m_dockInter->setHideMode(KeepShowing);
|
||||
if (action == &m_keepHiddenAct)
|
||||
return m_dockInter->setHideMode(KeepHidden);
|
||||
if (action == &m_smartHideAct)
|
||||
return m_dockInter->setHideMode(SmartHide);
|
||||
}
|
||||
|
@ -3,11 +3,17 @@
|
||||
|
||||
#include "constants.h"
|
||||
#include "dbus/dbusdock.h"
|
||||
#include "dbus/dbusmenumanager.h"
|
||||
#include "controller/dockitemcontroller.h"
|
||||
|
||||
#include <DAction>
|
||||
#include <DMenu>
|
||||
|
||||
#include <QObject>
|
||||
#include <QSize>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
using namespace Dock;
|
||||
|
||||
class DockSettings : public QObject
|
||||
@ -20,6 +26,8 @@ public:
|
||||
Position position() const;
|
||||
const QSize mainWindowSize() const;
|
||||
|
||||
void showDockSettingsMenu();
|
||||
|
||||
signals:
|
||||
void dataChanged() const;
|
||||
|
||||
@ -27,11 +35,29 @@ public slots:
|
||||
void updateGeometry();
|
||||
|
||||
private slots:
|
||||
void menuActionClicked(DAction *action);
|
||||
|
||||
private:
|
||||
int m_iconSize;
|
||||
Position m_position;
|
||||
HideMode m_hideMode;
|
||||
DisplayMode m_displayMode;
|
||||
QSize m_mainWindowSize;
|
||||
|
||||
DMenu m_settingsMenu;
|
||||
DAction m_fashionModeAct;
|
||||
DAction m_efficientModeAct;
|
||||
DAction m_topPosAct;
|
||||
DAction m_bottomPosAct;
|
||||
DAction m_leftPosAct;
|
||||
DAction m_rightPosAct;
|
||||
DAction m_largeSizeAct;
|
||||
DAction m_mediumSizeAct;
|
||||
DAction m_smallSizeAct;
|
||||
DAction m_keepShownAct;
|
||||
DAction m_keepHiddenAct;
|
||||
DAction m_smartHideAct;
|
||||
|
||||
DBusDock *m_dockInter;
|
||||
DockItemController *m_itemController;
|
||||
};
|
||||
|
@ -36,6 +36,14 @@ void MainWindow::resizeEvent(QResizeEvent *e)
|
||||
m_mainPanel->setFixedSize(e->size());
|
||||
}
|
||||
|
||||
void MainWindow::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
e->ignore();
|
||||
|
||||
if (e->button() == Qt::RightButton)
|
||||
m_settings->showDockSettingsMenu();
|
||||
}
|
||||
|
||||
void MainWindow::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
switch (e->key())
|
||||
|
@ -19,6 +19,7 @@ public:
|
||||
|
||||
private:
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
void initComponents();
|
||||
void initConnections();
|
||||
|
Loading…
x
Reference in New Issue
Block a user