mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
feat: support change frame opacity
Change-Id: I5d20a2736e70097b357a9c4e51befd5e7c135878
This commit is contained in:
parent
53280266c7
commit
0310a31352
Notes:
gerrit
2018-10-10 09:09:16 +08:00
Verified+1: <jenkins@deepin.com> Verified+1: zhaofangfangdeepin <zhaofangfang@linuxdeepin.com> Code-Review+2: 流年匆忙 <lxz@ilxz.me> Submitted-by: 流年匆忙 <lxz@ilxz.me> Submitted-at: Wed, 10 Oct 2018 09:09:14 +0800 Reviewed-on: https://cr.deepin.io/38788 Project: dde/dde-dock Branch: refs/heads/master
@ -71,6 +71,7 @@ MainPanel::MainPanel(QWidget *parent)
|
||||
connect(m_itemController, &DockItemController::itemManaged, this, &MainPanel::manageItem);
|
||||
connect(m_itemController, &DockItemController::itemUpdated, m_itemAdjustTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
|
||||
connect(m_itemAdjustTimer, &QTimer::timeout, this, &MainPanel::adjustItemSize, Qt::QueuedConnection);
|
||||
connect(&DockSettings::Instance(), &DockSettings::opacityChanged, this, &MainPanel::setMaskAlpha);
|
||||
|
||||
m_itemAdjustTimer->setSingleShot(true);
|
||||
m_itemAdjustTimer->setInterval(100);
|
||||
@ -158,10 +159,12 @@ int MainPanel::position() const
|
||||
void MainPanel::setEffectEnabled(const bool enabled)
|
||||
{
|
||||
if (enabled)
|
||||
setMaskColor(QColor(0, 0, 0, 255 * 0.4));
|
||||
setMaskColor(DarkColor);
|
||||
else
|
||||
setMaskColor(QColor(55, 63, 71));
|
||||
|
||||
setMaskAlpha(DockSettings::Instance().Opacity());
|
||||
|
||||
m_itemAdjustTimer->start();
|
||||
}
|
||||
|
||||
|
@ -39,26 +39,25 @@ DWIDGET_USE_NAMESPACE
|
||||
extern const QPoint rawXPosition(const QPoint &scaledPos);
|
||||
|
||||
DockSettings::DockSettings(QWidget *parent)
|
||||
: QObject(parent),
|
||||
|
||||
m_autoHide(true),
|
||||
|
||||
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_displayInter(new DBusDisplay(this)),
|
||||
m_dockInter(new DBusDock(this)),
|
||||
m_itemController(DockItemController::instance(this))
|
||||
: QObject(parent)
|
||||
, m_opacity(0)
|
||||
, m_autoHide(true)
|
||||
, 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_displayInter(new DBusDisplay(this))
|
||||
, m_dockInter(new DBusDock(this))
|
||||
, m_itemController(DockItemController::instance(this))
|
||||
, m_appearanceInter(new Appearance("com.deepin.daemon.Appearance", "/com/deepin/daemon/Appearance", QDBusConnection::sessionBus(), this))
|
||||
{
|
||||
m_primaryRect = m_displayInter->primaryRect();
|
||||
m_primaryRawRect = m_displayInter->primaryRawRect();
|
||||
@ -75,6 +74,8 @@ DockSettings::DockSettings(QWidget *parent)
|
||||
DockItem::setDockDisplayMode(m_displayMode);
|
||||
qApp->setProperty(PROP_DISPLAY_MODE, QVariant::fromValue(m_displayMode));
|
||||
|
||||
m_appearanceInter->setSync(false, false);
|
||||
|
||||
m_fashionModeAct.setCheckable(true);
|
||||
m_efficientModeAct.setCheckable(true);
|
||||
m_topPosAct.setCheckable(true);
|
||||
@ -142,6 +143,8 @@ DockSettings::DockSettings(QWidget *parent)
|
||||
connect(m_displayInter, &DBusDisplay::ScreenHeightChanged, this, &DockSettings::primaryScreenChanged, Qt::QueuedConnection);
|
||||
connect(m_displayInter, &DBusDisplay::ScreenWidthChanged, this, &DockSettings::primaryScreenChanged, Qt::QueuedConnection);
|
||||
|
||||
connect(m_appearanceInter, &Appearance::OpacityChanged, this, &DockSettings::onOpacityChanged);
|
||||
|
||||
DApplication *app = qobject_cast<DApplication*>(qApp);
|
||||
if (app) {
|
||||
connect(app, &DApplication::iconThemeChanged, this, &DockSettings::gtkIconThemeChanged);
|
||||
@ -150,6 +153,7 @@ DockSettings::DockSettings(QWidget *parent)
|
||||
calculateWindowConfig();
|
||||
updateForbidPostions();
|
||||
resetFrontendGeometry();
|
||||
onOpacityChanged(m_appearanceInter->opacity());
|
||||
}
|
||||
|
||||
DockSettings &DockSettings::Instance()
|
||||
@ -496,6 +500,15 @@ void DockSettings::updateForbidPostions()
|
||||
m_forbidPositions = std::move(forbids);
|
||||
}
|
||||
|
||||
void DockSettings::onOpacityChanged(const double value)
|
||||
{
|
||||
if (m_opacity == value) return;
|
||||
|
||||
m_opacity = value;
|
||||
|
||||
emit opacityChanged(value * 255);
|
||||
}
|
||||
|
||||
void DockSettings::calculateWindowConfig()
|
||||
{
|
||||
const auto ratio = qApp->devicePixelRatio();
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "dbus/dbusmenumanager.h"
|
||||
#include "dbus/dbusdisplay.h"
|
||||
#include "controller/dockitemcontroller.h"
|
||||
#include <com_deepin_daemon_appearance.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
@ -39,6 +40,7 @@
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
using namespace Dock;
|
||||
using Appearance = com::deepin::daemon::Appearance;
|
||||
|
||||
class WhiteMenu : public QMenu
|
||||
{
|
||||
@ -74,6 +76,7 @@ public:
|
||||
inline const QRect primaryRawRect() const { return m_primaryRawRect; }
|
||||
inline const QRect frontendWindowRect() const { return m_frontendRect; }
|
||||
inline const QSize windowSize() const { return m_mainWindowSize; }
|
||||
inline const quint8 Opacity() const { return m_opacity * 255; }
|
||||
|
||||
const QSize panelSize() const;
|
||||
const QRect windowRect(const Position position, const bool hide = false) const;
|
||||
@ -88,6 +91,7 @@ signals:
|
||||
void windowVisibleChanged() const;
|
||||
void windowHideModeChanged() const;
|
||||
void windowGeometryChanged() const;
|
||||
void opacityChanged(const quint8 value) const;
|
||||
|
||||
public slots:
|
||||
void updateGeometry();
|
||||
@ -104,6 +108,7 @@ private slots:
|
||||
void primaryScreenChanged();
|
||||
void resetFrontendGeometry();
|
||||
void updateForbidPostions();
|
||||
void onOpacityChanged(const double value);
|
||||
|
||||
private:
|
||||
DockSettings(QWidget *parent = 0);
|
||||
@ -119,6 +124,7 @@ private:
|
||||
bool m_autoHide;
|
||||
int m_screenRawHeight;
|
||||
int m_screenRawWidth;
|
||||
double m_opacity;
|
||||
QSet<Position> m_forbidPositions;
|
||||
Position m_position;
|
||||
HideMode m_hideMode;
|
||||
@ -147,6 +153,7 @@ private:
|
||||
DBusDisplay *m_displayInter;
|
||||
DBusDock *m_dockInter;
|
||||
DockItemController *m_itemController;
|
||||
Appearance* m_appearanceInter;
|
||||
};
|
||||
|
||||
#endif // DOCKSETTINGS_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user