mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
feat(plugin):plugin layout error on close window effect
This commit is contained in:
parent
bea54c36a0
commit
2224cca64e
@ -65,17 +65,9 @@ void DatetimeWidget::set24HourFormat(const bool value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize DatetimeWidget::sizeHint() const
|
QSize DatetimeWidget::curTimeSize() const
|
||||||
{
|
|
||||||
// 最大尺寸
|
|
||||||
QFontMetrics fm(TIME_FONT);
|
|
||||||
return fm.boundingRect("88:88 A.A.").size() + QSize(20, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatetimeWidget::resizeEvent(QResizeEvent *e)
|
|
||||||
{
|
{
|
||||||
const Dock::Position position = qApp->property(PROP_POSITION).value<Dock::Position>();
|
const Dock::Position position = qApp->property(PROP_POSITION).value<Dock::Position>();
|
||||||
|
|
||||||
QFontMetrics fm(TIME_FONT);
|
QFontMetrics fm(TIME_FONT);
|
||||||
QString format;
|
QString format;
|
||||||
if (m_24HourFormat)
|
if (m_24HourFormat)
|
||||||
@ -89,12 +81,20 @@ void DatetimeWidget::resizeEvent(QResizeEvent *e)
|
|||||||
timeSize.setWidth(dateSize.width());
|
timeSize.setWidth(dateSize.width());
|
||||||
|
|
||||||
if (position == Dock::Bottom || position == Dock::Top) {
|
if (position == Dock::Bottom || position == Dock::Top) {
|
||||||
setMaximumWidth(timeSize.width());
|
return QSize(timeSize.width(), DOCK_MAX_SIZE);
|
||||||
setMaximumHeight(QWIDGETSIZE_MAX);
|
|
||||||
} else {
|
} else {
|
||||||
setMaximumWidth(QWIDGETSIZE_MAX);
|
return QSize(DOCK_MAX_SIZE, timeSize.height() * 2);
|
||||||
setMaximumHeight(timeSize.height() * 2);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize DatetimeWidget::sizeHint() const
|
||||||
|
{
|
||||||
|
return curTimeSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatetimeWidget::resizeEvent(QResizeEvent *e)
|
||||||
|
{
|
||||||
|
setMaximumSize(curTimeSize());
|
||||||
|
|
||||||
QWidget::resizeEvent(e);
|
QWidget::resizeEvent(e);
|
||||||
}
|
}
|
||||||
@ -132,21 +132,3 @@ void DatetimeWidget::paintEvent(QPaintEvent *e)
|
|||||||
painter.drawText(rect(), Qt::AlignCenter, current.toString(format));
|
painter.drawText(rect(), Qt::AlignCenter, current.toString(format));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QPixmap DatetimeWidget::loadSvg(const QString &fileName, const QSize size)
|
|
||||||
{
|
|
||||||
const auto ratio = devicePixelRatioF();
|
|
||||||
|
|
||||||
QPixmap pixmap(size * ratio);
|
|
||||||
QSvgRenderer renderer(fileName);
|
|
||||||
pixmap.fill(Qt::transparent);
|
|
||||||
|
|
||||||
QPainter painter;
|
|
||||||
painter.begin(&pixmap);
|
|
||||||
renderer.render(&painter);
|
|
||||||
painter.end();
|
|
||||||
|
|
||||||
pixmap.setDevicePixelRatio(ratio);
|
|
||||||
|
|
||||||
return pixmap;
|
|
||||||
}
|
|
||||||
|
@ -32,6 +32,7 @@ public:
|
|||||||
explicit DatetimeWidget(QWidget *parent = 0);
|
explicit DatetimeWidget(QWidget *parent = 0);
|
||||||
|
|
||||||
bool is24HourFormat() const { return m_24HourFormat; }
|
bool is24HourFormat() const { return m_24HourFormat; }
|
||||||
|
QSize sizeHint() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void requestUpdateGeometry() const;
|
void requestUpdateGeometry() const;
|
||||||
@ -40,11 +41,9 @@ public slots:
|
|||||||
void set24HourFormat(const bool value);
|
void set24HourFormat(const bool value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSize sizeHint() const;
|
|
||||||
void resizeEvent(QResizeEvent *e);
|
void resizeEvent(QResizeEvent *e);
|
||||||
void paintEvent(QPaintEvent *e);
|
void paintEvent(QPaintEvent *e);
|
||||||
|
QSize curTimeSize() const;
|
||||||
const QPixmap loadSvg(const QString &fileName, const QSize size);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_24HourFormat;
|
bool m_24HourFormat;
|
||||||
|
@ -54,7 +54,10 @@ QWidget *TrashWidget::popupApplet()
|
|||||||
|
|
||||||
QSize TrashWidget::sizeHint() const
|
QSize TrashWidget::sizeHint() const
|
||||||
{
|
{
|
||||||
return QSize(DOCK_MAX_SIZE, DOCK_MAX_SIZE);
|
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
|
||||||
|
@ -24,7 +24,6 @@ AbstractContainer::AbstractContainer(TrayPlugin *trayPlugin, QWidget *parent)
|
|||||||
|
|
||||||
void AbstractContainer::refreshVisible()
|
void AbstractContainer::refreshVisible()
|
||||||
{
|
{
|
||||||
qDebug() << this << size() << minimumSize() << maximumSize();
|
|
||||||
if (!m_wrapperList.isEmpty()) {
|
if (!m_wrapperList.isEmpty()) {
|
||||||
//非空保留两边边距
|
//非空保留两边边距
|
||||||
if (m_dockPosition == Dock::Position::Top || m_dockPosition == Dock::Position::Bottom) {
|
if (m_dockPosition == Dock::Position::Top || m_dockPosition == Dock::Position::Bottom) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user