mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
feat(dock): change the lohic for dock icon‘s size
This commit is contained in:
parent
d8c0188dfc
commit
d325a98a2b
@ -361,7 +361,6 @@ bool PluginsItem::checkGSettingsControl() const
|
|||||||
|
|
||||||
void PluginsItem::resizeEvent(QResizeEvent *event)
|
void PluginsItem::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
setMinimumSize(m_centralWidget->minimumSize());
|
|
||||||
setMaximumSize(m_centralWidget->maximumSize());
|
setMaximumSize(m_centralWidget->maximumSize());
|
||||||
return DockItem::resizeEvent(event);
|
return DockItem::resizeEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "../item/placeholderitem.h"
|
#include "../item/placeholderitem.h"
|
||||||
#include "../item/components/appdrag.h"
|
#include "../item/components/appdrag.h"
|
||||||
#include "../item/appitem.h"
|
#include "../item/appitem.h"
|
||||||
|
#include "../item/pluginsitem.h"
|
||||||
|
|
||||||
#include <QDrag>
|
#include <QDrag>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@ -36,6 +37,7 @@
|
|||||||
#include <DWindowManagerHelper>
|
#include <DWindowManagerHelper>
|
||||||
|
|
||||||
#define SPLITER_SIZE 2
|
#define SPLITER_SIZE 2
|
||||||
|
#define TRASH_MARGIN 20
|
||||||
|
|
||||||
DWIDGET_USE_NAMESPACE
|
DWIDGET_USE_NAMESPACE
|
||||||
|
|
||||||
@ -66,6 +68,7 @@ MainPanelControl::MainPanelControl(QWidget *parent)
|
|||||||
|
|
||||||
m_appAreaWidget->installEventFilter(this);
|
m_appAreaWidget->installEventFilter(this);
|
||||||
m_appAreaSonWidget->installEventFilter(this);
|
m_appAreaSonWidget->installEventFilter(this);
|
||||||
|
m_trayAreaWidget->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainPanelControl::~MainPanelControl()
|
MainPanelControl::~MainPanelControl()
|
||||||
@ -153,41 +156,31 @@ void MainPanelControl::updateMainPanelLayout()
|
|||||||
m_trayAreaLayout->setContentsMargins(10, 0, 10, 0);
|
m_trayAreaLayout->setContentsMargins(10, 0, 10, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanelControl::addFixedAreaItem(int index, QWidget *wdg)
|
void MainPanelControl::addFixedAreaItem(int index, QWidget *wdg)
|
||||||
{
|
{
|
||||||
m_fixedAreaLayout->insertWidget(index, wdg);
|
m_fixedAreaLayout->insertWidget(index, wdg);
|
||||||
|
resizeDockIcon();
|
||||||
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
|
|
||||||
wdg->setMaximumSize(height(), height());
|
|
||||||
} else {
|
|
||||||
wdg->setMaximumSize(width(), width());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanelControl::addAppAreaItem(int index, QWidget *wdg)
|
void MainPanelControl::addAppAreaItem(int index, QWidget *wdg)
|
||||||
{
|
{
|
||||||
m_appAreaSonLayout->insertWidget(index, wdg);
|
m_appAreaSonLayout->insertWidget(index, wdg);
|
||||||
|
resizeDockIcon();
|
||||||
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
|
|
||||||
wdg->setMaximumSize(height(), height());
|
|
||||||
} else {
|
|
||||||
wdg->setMaximumSize(width(), width());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanelControl::addTrayAreaItem(int index, QWidget *wdg)
|
void MainPanelControl::addTrayAreaItem(int index, QWidget *wdg)
|
||||||
{
|
{
|
||||||
m_trayAreaLayout->insertWidget(index, wdg);
|
m_trayAreaLayout->insertWidget(index, wdg);
|
||||||
|
resizeDockIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanelControl::addPluginAreaItem(int index, QWidget *wdg)
|
void MainPanelControl::addPluginAreaItem(int index, QWidget *wdg)
|
||||||
{
|
{
|
||||||
m_pluginLayout->insertWidget(index, wdg);
|
m_pluginLayout->insertWidget(index, wdg);
|
||||||
|
resizeDockIcon();
|
||||||
QTimer::singleShot(50, this, [ = ] {m_pluginAreaWidget->adjustSize();});
|
QTimer::singleShot(50, this, [ = ] {m_pluginAreaWidget->adjustSize();});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanelControl::removeFixedAreaItem(QWidget *wdg)
|
void MainPanelControl::removeFixedAreaItem(QWidget *wdg)
|
||||||
@ -212,28 +205,7 @@ void MainPanelControl::removePluginAreaItem(QWidget *wdg)
|
|||||||
|
|
||||||
void MainPanelControl::resizeEvent(QResizeEvent *event)
|
void MainPanelControl::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_appAreaSonLayout->count(); ++i) {
|
resizeDockIcon();
|
||||||
QWidget *w = m_appAreaSonLayout->itemAt(i)->widget();
|
|
||||||
if (w) {
|
|
||||||
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
|
|
||||||
w->setMaximumSize(height(), height());
|
|
||||||
} else {
|
|
||||||
w->setMaximumSize(width(), width());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < m_fixedAreaLayout->count(); ++i) {
|
|
||||||
QWidget *w = m_fixedAreaLayout->itemAt(i)->widget();
|
|
||||||
if (w) {
|
|
||||||
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
|
|
||||||
w->setMaximumSize(height(), height());
|
|
||||||
} else {
|
|
||||||
w->setMaximumSize(width(), width());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return QWidget::resizeEvent(event);
|
return QWidget::resizeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,38 +453,8 @@ bool MainPanelControl::eventFilter(QObject *watched, QEvent *event)
|
|||||||
if (watched == m_appAreaSonWidget) {
|
if (watched == m_appAreaSonWidget) {
|
||||||
if (event->type() == QEvent::LayoutRequest) {
|
if (event->type() == QEvent::LayoutRequest) {
|
||||||
m_appAreaSonWidget->adjustSize();
|
m_appAreaSonWidget->adjustSize();
|
||||||
|
resizeDockIcon();
|
||||||
|
|
||||||
if (m_position == Dock::Position::Top || m_position == Dock::Position::Bottom) {
|
|
||||||
m_fixedSpliter->setFixedSize(SPLITER_SIZE, height() * 0.6);
|
|
||||||
m_appSpliter->setFixedSize(SPLITER_SIZE, height() * 0.6);
|
|
||||||
m_traySpliter->setFixedSize(SPLITER_SIZE, height() * 0.5);
|
|
||||||
} else {
|
|
||||||
m_fixedSpliter->setFixedSize(width() * 0.6, SPLITER_SIZE);
|
|
||||||
m_appSpliter->setFixedSize(width() * 0.6, SPLITER_SIZE);
|
|
||||||
m_traySpliter->setFixedSize(width() * 0.5, SPLITER_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < m_appAreaSonLayout->count(); ++i) {
|
|
||||||
QWidget *w = m_appAreaSonLayout->itemAt(i)->widget();
|
|
||||||
if (w) {
|
|
||||||
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
|
|
||||||
w->setMaximumSize(height(), height());
|
|
||||||
} else {
|
|
||||||
w->setMaximumSize(width(), width());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < m_fixedAreaLayout->count(); ++i) {
|
|
||||||
QWidget *w = m_fixedAreaLayout->itemAt(i)->widget();
|
|
||||||
if (w) {
|
|
||||||
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
|
|
||||||
w->setMaximumSize(height(), height());
|
|
||||||
} else {
|
|
||||||
w->setMaximumSize(width(), width());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
moveAppSonWidget();
|
moveAppSonWidget();
|
||||||
}
|
}
|
||||||
@ -530,6 +472,16 @@ bool MainPanelControl::eventFilter(QObject *watched, QEvent *event)
|
|||||||
moveAppSonWidget();
|
moveAppSonWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (watched == m_trayAreaWidget) {
|
||||||
|
if (event->type() == QEvent::Resize) {
|
||||||
|
resizeDockIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (watched == m_trayAreaWidget) {
|
||||||
|
if (event->type() == QEvent::Resize) {
|
||||||
|
}
|
||||||
|
}
|
||||||
if (m_appDragWidget && watched == static_cast<QGraphicsView *>(m_appDragWidget)->viewport()) {
|
if (m_appDragWidget && watched == static_cast<QGraphicsView *>(m_appDragWidget)->viewport()) {
|
||||||
QDropEvent *e = static_cast<QDropEvent *>(event);
|
QDropEvent *e = static_cast<QDropEvent *>(event);
|
||||||
bool isContains = rect().contains(mapFromGlobal(m_appDragWidget->mapToGlobal(e->pos())));
|
bool isContains = rect().contains(mapFromGlobal(m_appDragWidget->mapToGlobal(e->pos())));
|
||||||
@ -767,3 +719,75 @@ void MainPanelControl::paintEvent(QPaintEvent *event)
|
|||||||
painter.fillRect(m_appSpliter->geometry(), color);
|
painter.fillRect(m_appSpliter->geometry(), color);
|
||||||
painter.fillRect(m_traySpliter->geometry(), color);
|
painter.fillRect(m_traySpliter->geometry(), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainPanelControl::resizeDockIcon()
|
||||||
|
{
|
||||||
|
//计算插件区域的垃圾箱大小
|
||||||
|
int trashWidth = 0;
|
||||||
|
int trashHeight = 0;
|
||||||
|
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
||||||
|
PluginsItem *w = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
|
||||||
|
if (w->pluginName() == "trash") {
|
||||||
|
trashWidth = w->width();
|
||||||
|
trashHeight = w->height();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//计算luancher 和 APP 区域大小
|
||||||
|
int iconWidgetwidth = 0;
|
||||||
|
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
|
||||||
|
iconWidgetwidth = this->width() - m_trayAreaWidget->width() - (m_pluginAreaWidget->width() - trashHeight);
|
||||||
|
} else {
|
||||||
|
iconWidgetwidth = this->height() - m_trayAreaWidget->height() - (m_pluginAreaWidget->height() - trashWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
//计算每一个icon的大小
|
||||||
|
float iconSize = (iconWidgetwidth) / (m_fixedAreaLayout->count() + m_appAreaSonLayout->count() + 1) - 1;
|
||||||
|
|
||||||
|
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
|
||||||
|
if (iconSize >= height()) {
|
||||||
|
calcuDockIconSize(height(), height());
|
||||||
|
} else {
|
||||||
|
calcuDockIconSize(iconSize, height());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (iconSize >= width()) {
|
||||||
|
calcuDockIconSize(width(), width());
|
||||||
|
} else {
|
||||||
|
calcuDockIconSize(width(), iconSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainPanelControl::calcuDockIconSize(int w, int h)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < m_fixedAreaLayout->count(); ++ i) {
|
||||||
|
m_fixedAreaLayout->itemAt(i)->widget()->setFixedSize(w, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < m_appAreaSonLayout->count(); ++ i) {
|
||||||
|
m_appAreaSonLayout->itemAt(i)->widget()->setFixedSize(w, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
||||||
|
PluginsItem *p = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
|
||||||
|
if (p->pluginName() == "trash") {
|
||||||
|
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
|
||||||
|
p->setFixedSize(w, h - TRASH_MARGIN);
|
||||||
|
} else {
|
||||||
|
p->setFixedSize(w - TRASH_MARGIN, h);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_position == Dock::Position::Top || m_position == Dock::Position::Bottom) {
|
||||||
|
m_fixedSpliter->setFixedSize(SPLITER_SIZE, w * 0.6);
|
||||||
|
m_appSpliter->setFixedSize(SPLITER_SIZE, w * 0.6);
|
||||||
|
m_traySpliter->setFixedSize(SPLITER_SIZE, w * 0.5);
|
||||||
|
} else {
|
||||||
|
m_fixedSpliter->setFixedSize(h * 0.6, SPLITER_SIZE);
|
||||||
|
m_appSpliter->setFixedSize(h * 0.6, SPLITER_SIZE);
|
||||||
|
m_traySpliter->setFixedSize(h * 0.5, SPLITER_SIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -85,6 +85,8 @@ private:
|
|||||||
void moveItem(DockItem *sourceItem, DockItem *targetItem);
|
void moveItem(DockItem *sourceItem, DockItem *targetItem);
|
||||||
void handleDragMove(QDragMoveEvent *e, bool isFilter);
|
void handleDragMove(QDragMoveEvent *e, bool isFilter);
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
|
void resizeDockIcon();
|
||||||
|
void calcuDockIconSize(int w,int h);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void insertItem(const int index, DockItem *item);
|
void insertItem(const int index, DockItem *item);
|
||||||
@ -102,6 +104,7 @@ private:
|
|||||||
QBoxLayout *m_pluginLayout;
|
QBoxLayout *m_pluginLayout;
|
||||||
QWidget *m_appAreaSonWidget;
|
QWidget *m_appAreaSonWidget;
|
||||||
QBoxLayout *m_appAreaSonLayout;
|
QBoxLayout *m_appAreaSonLayout;
|
||||||
|
QBoxLayout *m_appAreaLayout;
|
||||||
Position m_position;
|
Position m_position;
|
||||||
QPointer<PlaceholderItem> m_placeholderItem;
|
QPointer<PlaceholderItem> m_placeholderItem;
|
||||||
MainPanelDelegate *m_delegate;
|
MainPanelDelegate *m_delegate;
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
MultitaskingWidget::MultitaskingWidget(QWidget *parent)
|
MultitaskingWidget::MultitaskingWidget(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
||||||
m_icon = QIcon::fromTheme(":/icons/deepin-multitasking-view.svg");
|
m_icon = QIcon::fromTheme(":/icons/deepin-multitasking-view.svg");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,11 +37,6 @@ void MultitaskingWidget::refreshIcon()
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize MultitaskingWidget::sizeHint() const
|
|
||||||
{
|
|
||||||
return QSize(16, 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MultitaskingWidget::paintEvent(QPaintEvent *e)
|
void MultitaskingWidget::paintEvent(QPaintEvent *e)
|
||||||
{
|
{
|
||||||
Q_UNUSED(e);
|
Q_UNUSED(e);
|
||||||
@ -63,18 +57,3 @@ void MultitaskingWidget::paintEvent(QPaintEvent *e)
|
|||||||
const QRectF &rfp = QRectF(icon.rect());
|
const QRectF &rfp = QRectF(icon.rect());
|
||||||
painter.drawPixmap(rf.center() - rfp.center() / ratio, icon);
|
painter.drawPixmap(rf.center() - rfp.center() / ratio, icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultitaskingWidget::resizeEvent(QResizeEvent *event)
|
|
||||||
{
|
|
||||||
const Dock::Position position = qApp->property(PROP_POSITION).value<Dock::Position>();
|
|
||||||
// 保持横纵比
|
|
||||||
if (position == Dock::Bottom || position == Dock::Top) {
|
|
||||||
setMinimumWidth(height());
|
|
||||||
setMinimumHeight(PLUGIN_ICON_MIN_SIZE);
|
|
||||||
} else {
|
|
||||||
setMinimumWidth(PLUGIN_ICON_MIN_SIZE);
|
|
||||||
setMinimumHeight(width());
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget::resizeEvent(event);
|
|
||||||
}
|
|
||||||
|
@ -34,14 +34,12 @@ class MultitaskingWidget : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit MultitaskingWidget(QWidget *parent = 0);
|
explicit MultitaskingWidget(QWidget *parent = 0);
|
||||||
void refreshIcon();
|
void refreshIcon();
|
||||||
QSize sizeHint() const override;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void requestContextMenu(const QString &itemKey) const;
|
void requestContextMenu(const QString &itemKey) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
|
||||||
QIcon m_icon;
|
QIcon m_icon;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
ShowDesktopWidget::ShowDesktopWidget(QWidget *parent)
|
ShowDesktopWidget::ShowDesktopWidget(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowDesktopWidget::refreshIcon()
|
void ShowDesktopWidget::refreshIcon()
|
||||||
@ -37,11 +36,6 @@ void ShowDesktopWidget::refreshIcon()
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize ShowDesktopWidget::sizeHint() const
|
|
||||||
{
|
|
||||||
return QSize(16, 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShowDesktopWidget::paintEvent(QPaintEvent *e)
|
void ShowDesktopWidget::paintEvent(QPaintEvent *e)
|
||||||
{
|
{
|
||||||
Q_UNUSED(e);
|
Q_UNUSED(e);
|
||||||
@ -62,18 +56,3 @@ void ShowDesktopWidget::paintEvent(QPaintEvent *e)
|
|||||||
const QRectF &rfp = QRectF(icon.rect());
|
const QRectF &rfp = QRectF(icon.rect());
|
||||||
painter.drawPixmap(rf.center() - rfp.center() / ratio, icon);
|
painter.drawPixmap(rf.center() - rfp.center() / ratio, icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowDesktopWidget::resizeEvent(QResizeEvent *event)
|
|
||||||
{
|
|
||||||
const Dock::Position position = qApp->property(PROP_POSITION).value<Dock::Position>();
|
|
||||||
// 保持横纵比
|
|
||||||
if (position == Dock::Bottom || position == Dock::Top) {
|
|
||||||
setMinimumWidth(height());
|
|
||||||
setMinimumHeight(PLUGIN_ICON_MIN_SIZE);
|
|
||||||
} else {
|
|
||||||
setMinimumWidth(PLUGIN_ICON_MIN_SIZE);
|
|
||||||
setMinimumHeight(width());
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget::resizeEvent(event);
|
|
||||||
}
|
|
||||||
|
@ -31,14 +31,12 @@ class ShowDesktopWidget : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit ShowDesktopWidget(QWidget *parent = 0);
|
explicit ShowDesktopWidget(QWidget *parent = 0);
|
||||||
void refreshIcon();
|
void refreshIcon();
|
||||||
QSize sizeHint() const override;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void requestContextMenu(const QString &itemKey) const;
|
void requestContextMenu(const QString &itemKey) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SHOWDESKTOPWIDGET_H
|
#endif // SHOWDESKTOPWIDGET_H
|
||||||
|
@ -44,8 +44,6 @@ TrashWidget::TrashWidget(QWidget *parent)
|
|||||||
|
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
setMinimumSize(PLUGIN_ICON_MIN_SIZE, PLUGIN_ICON_MIN_SIZE);
|
|
||||||
|
|
||||||
m_defaulticon = QIcon::fromTheme(":/icons/user-trash.svg");
|
m_defaulticon = QIcon::fromTheme(":/icons/user-trash.svg");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,14 +52,6 @@ QWidget *TrashWidget::popupApplet()
|
|||||||
return m_popupApplet;
|
return m_popupApplet;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize TrashWidget::sizeHint() const
|
|
||||||
{
|
|
||||||
int w = std::min(width(), DOCK_MAX_SIZE);
|
|
||||||
int h = std::min(height(), DOCK_MAX_SIZE);
|
|
||||||
int size = std::max(w, h);
|
|
||||||
return QSize(size, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString TrashWidget::contextMenu() const
|
const QString TrashWidget::contextMenu() const
|
||||||
{
|
{
|
||||||
QList<QVariant> items;
|
QList<QVariant> items;
|
||||||
@ -177,21 +167,6 @@ void TrashWidget::paintEvent(QPaintEvent *e)
|
|||||||
painter.drawPixmap(rf.center() - rfp.center() / devicePixelRatioF(), m_icon);
|
painter.drawPixmap(rf.center() - rfp.center() / devicePixelRatioF(), m_icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrashWidget::resizeEvent(QResizeEvent *e)
|
|
||||||
{
|
|
||||||
const Dock::Position position = qApp->property(PROP_POSITION).value<Dock::Position>();
|
|
||||||
// 保持横纵比
|
|
||||||
if (position == Dock::Bottom || position == Dock::Top) {
|
|
||||||
setMaximumWidth(height());
|
|
||||||
setMaximumHeight(QWIDGETSIZE_MAX);
|
|
||||||
} else {
|
|
||||||
setMaximumHeight(width());
|
|
||||||
setMaximumWidth(QWIDGETSIZE_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget::resizeEvent(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrashWidget::updateIcon()
|
void TrashWidget::updateIcon()
|
||||||
{
|
{
|
||||||
// Dock::DisplayMode displayMode = qApp->property(PROP_DISPLAY_MODE).value<Dock::DisplayMode>();
|
// Dock::DisplayMode displayMode = qApp->property(PROP_DISPLAY_MODE).value<Dock::DisplayMode>();
|
||||||
@ -203,11 +178,10 @@ void TrashWidget::updateIcon()
|
|||||||
if (displayMode == Dock::Efficient)
|
if (displayMode == Dock::Efficient)
|
||||||
iconString.append("-symbolic");
|
iconString.append("-symbolic");
|
||||||
|
|
||||||
const int size = std::min(width(), height()) ;
|
const int size = std::min(width(), height()) * ((Dock::Fashion == qApp->property(PROP_DISPLAY_MODE).value<Dock::DisplayMode>()) ? 0.8 : 0.7);
|
||||||
QIcon icon = QIcon::fromTheme(iconString, m_defaulticon);
|
QIcon icon = QIcon::fromTheme(iconString, m_defaulticon);
|
||||||
|
|
||||||
const auto ratio = devicePixelRatioF();
|
const auto ratio = devicePixelRatioF();
|
||||||
|
|
||||||
m_icon = icon.pixmap(size * ratio, size * ratio);
|
m_icon = icon.pixmap(size * ratio, size * ratio);
|
||||||
m_icon.setDevicePixelRatio(ratio);
|
m_icon.setDevicePixelRatio(ratio);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,6 @@ public:
|
|||||||
|
|
||||||
QWidget *popupApplet();
|
QWidget *popupApplet();
|
||||||
|
|
||||||
QSize sizeHint() const Q_DECL_OVERRIDE;
|
|
||||||
const QString contextMenu() const;
|
const QString contextMenu() const;
|
||||||
int trashItemCount() const;
|
int trashItemCount() const;
|
||||||
void invokeMenuItem(const QString &menuId, const bool checked);
|
void invokeMenuItem(const QString &menuId, const bool checked);
|
||||||
@ -59,7 +58,6 @@ protected:
|
|||||||
void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE;
|
void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE;
|
||||||
void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE;
|
void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE;
|
||||||
void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
|
void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
|
||||||
void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void removeApp(const QString &appKey);
|
void removeApp(const QString &appKey);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user