Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 42 additions & 27 deletions panels/dock/tray/frame/dockapplet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,33 @@
#include <QTranslator>
#include <QWindow>

namespace dock {

DockApplet::DockApplet(QObject *parent)
: DApplet(parent)
, m_window(new DockTrayWindow)
, m_dockAdapter(nullptr)
, m_widgetProxy(nullptr)
, m_dockWidth(0)
, m_dockHeight(0)
{

}
namespace dock {

DockApplet::DockApplet(QObject *parent)
: DApplet(parent)
, m_dockAdapter(nullptr)
, m_widgetProxy(nullptr)
, m_dockWidth(0)
, m_dockHeight(0)
{

void DockApplet::setDockWidth(int width)
{
if (m_dockWidth != width) {
m_dockWidth = width;
if (m_widgetProxy) {
m_widgetProxy->setImplicitWidth(width);
}
Q_EMIT dockWidthChanged(width);

DockApplet::~DockApplet()
{
if (m_window)
delete m_window;
}

void DockApplet::setDockWidth(int width)
{
if (m_dockWidth != width) {
m_dockWidth = width;
if (m_widgetProxy) {
m_widgetProxy->setImplicitWidth(width);
}
Q_EMIT dockWidthChanged(width);
}
}

int DockApplet::dockWidth() const
Expand All @@ -65,22 +70,26 @@ int DockApplet::dockHeight() const

void DockApplet::setPanelPosition(int x, int y) const
{
m_window->move(x, y);
if (m_window)
m_window->move(x, y);
}

void DockApplet::setDockPosition(int pos) const
{
m_window->setPositon(Dock::Position(pos));
if (m_window)
m_window->setPositon(Dock::Position(pos));
}

void DockApplet::setPanelSize(int size) const
{
m_window->setDockSize(size);
if (m_window)
m_window->setDockSize(size);
}

void DockApplet::setDisplayMode(int displayMode) const
{
m_window->setDisplayMode(Dock::DisplayMode(displayMode));
if (m_window)
m_window->setDisplayMode(Dock::DisplayMode(displayMode));
}

void DockApplet::initDock()
Expand All @@ -89,6 +98,8 @@ void DockApplet::initDock()
if (init) return;
init = !init;

m_window = new DockTrayWindow;

DGuiApplicationHelper::setAttribute(DGuiApplicationHelper::UseInactiveColorGroup, false);

auto appletItem = qobject_cast<DS_NAMESPACE::DAppletItem *>(rootObject());
Expand All @@ -100,10 +111,6 @@ void DockApplet::initDock()
}
m_widgetProxy->setWidget(m_window);

QTranslator *tl = new QTranslator(this);
tl->load(QString("/usr/share/dde-dock/tmp/translations/dde-dock_%1.qm").arg(QLocale().name()));
qApp->installTranslator(tl);

connect(m_window, &DockTrayWindow::sizeChanged, this, [ = ] {
setDockWidth(m_window->width());
setDockHeight(m_window->height());
Expand All @@ -118,6 +125,14 @@ bool DockApplet::init()
{
DApplet::init();

QTranslator *tl = new QTranslator(this);
auto loaded = tl->load(QString("/usr/share/dde-dock/tmp/translations/dde-dock_%1.qm").arg(QLocale().name()));
if(!loaded) {
qWarning() << "Faield to load translator of dock";
} else {
qApp->installTranslator(tl);
}

return true;
}

Expand Down
3 changes: 2 additions & 1 deletion panels/dock/tray/frame/dockapplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class DockApplet : public DS_NAMESPACE::DApplet

public:
explicit DockApplet(QObject *parent = nullptr);
~ DockApplet();

void setDockWidth(int width);
int dockWidth() const;
Expand Down Expand Up @@ -49,7 +50,7 @@ class DockApplet : public DS_NAMESPACE::DApplet
void dockHeightChanged(int);

private:
DockTrayWindow *m_window;
QPointer<DockTrayWindow> m_window;
OldDBusDock *m_dockAdapter;
QuickProxyWidget *m_widgetProxy;
int m_dockWidth;
Expand Down
19 changes: 11 additions & 8 deletions panels/dock/tray/frame/quickproxywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void QuickProxyWidgetPrivate::sendWidgetMouseEvent(QHoverEvent *event)
{
QMouseEvent mouseEvent(QEvent::MouseMove, event->position(), event->button(), event->buttons(), event->modifiers());
sendWidgetMouseEvent(&mouseEvent);
// event->setAccepted(mouseEvent.isAccepted());
event->setAccepted(mouseEvent.isAccepted());
}

void QuickProxyWidgetPrivate::sendWidgetMouseEvent(QMouseEvent *event)
Expand Down Expand Up @@ -492,7 +492,16 @@ void QuickProxyWidget::dragMoveEvent(QDragMoveEvent *event)
// Map event position from us to the receiver
QPoint receiverPos = d->mapToReceiver(p, receiver).toPoint();
if (receiver != d->dragDropWidget) {
// Try to enter before we leave
/* Qt will automatically send the leave event to last widget
* that received the enter event, instead of the one we manually specified.
* So send the leave event first.
*/
if (d->dragDropWidget) {
QDragLeaveEvent dragLeave;
QCoreApplication::sendEvent(d->dragDropWidget, &dragLeave);
}
d->dragDropWidget = receiver;

QDragEnterEvent dragEnter(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
dragEnter.setDropAction(event->proposedAction());
QCoreApplication::sendEvent(receiver, &dragEnter);
Expand All @@ -504,12 +513,6 @@ void QuickProxyWidget::dragMoveEvent(QDragMoveEvent *event)
}

d->lastDropAction = event->dropAction();

if (d->dragDropWidget) {
QDragLeaveEvent dragLeave;
QCoreApplication::sendEvent(d->dragDropWidget, &dragLeave);
}
d->dragDropWidget = receiver;
}

QDragMoveEvent dragMove(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ void DateTimeDisplayer::mouseReleaseEvent(QMouseEvent *event)
if (event->button() != Qt::LeftButton || !rect().contains(event->pos()))
return;

DDBusSender().service("com.deepin.Calendar")
.path("/com/deepin/Calendar")
.interface("com.deepin.Calendar")
.method("RaiseWindow").call();
DDBusSender().service("org.desktopspec.ApplicationManager1")
.path("/org/desktopspec/ApplicationManager1/dde_2dcalendar")
.interface("org.desktopspec.ApplicationManager1.Application")
.method("Launch").arg(QString()).arg(QStringList()).arg(QVariantMap()).call();
}

QString DateTimeDisplayer::getTimeString(const Dock::Position &position) const
Expand Down
12 changes: 6 additions & 6 deletions panels/dock/tray/frame/window/docktraywindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ void DockTrayWindow::onUpdateComponentSize()
case Dock::Position::Right:
// m_toolLineLabel->setFixedSize(width() * 0.6, SPLITERSIZE);
// m_showDesktopWidget->setFixedSize(QWIDGETSIZE_MAX, FRONTSPACING);
m_dateTimeWidget->setFixedSize(40, m_dateTimeWidget->suitableSize().height());
m_systemPuginWidget->setFixedSize(40, m_systemPuginWidget->suitableSize().height());
m_quickIconWidget->setFixedSize(40, m_quickIconWidget->suitableSize().height());
m_dateTimeWidget->setFixedSize(m_dockSize, m_dateTimeWidget->suitableSize().height());
m_systemPuginWidget->setFixedSize(m_dockSize, m_systemPuginWidget->suitableSize().height());
m_quickIconWidget->setFixedSize(m_dockSize, m_quickIconWidget->suitableSize().height());
m_trayView->setFixedSize(m_dockSize, m_trayView->suitableSize().height());
m_toolFrontSpaceWidget->setFixedSize(m_dockSize, SPLITESPACE);
m_toolBackSpaceWidget->setFixedSize(m_dockSize, SPLITESPACE);
Expand All @@ -407,9 +407,9 @@ void DockTrayWindow::onUpdateComponentSize()
// m_toolLineLabel->setFixedSize(SPLITERSIZE, height() * 0.6);
// m_showDesktopWidget->setFixedSize(FRONTSPACING, QWIDGETSIZE_MAX);
// FIXME: in some cases, m_dateTimeWidget QWIDGETSIZE_MAX get a huge height.
m_dateTimeWidget->setFixedSize(m_dateTimeWidget->suitableSize().width(), qMin(40, this->height()));
m_systemPuginWidget->setFixedSize(m_systemPuginWidget->suitableSize().width(), 40);
m_quickIconWidget->setFixedSize(m_quickIconWidget->suitableSize().width(), 40);
m_dateTimeWidget->setFixedSize(m_dateTimeWidget->suitableSize().width(), qMin(m_dockSize, this->height()));
m_systemPuginWidget->setFixedSize(m_systemPuginWidget->suitableSize().width(), m_dockSize);
m_quickIconWidget->setFixedSize(m_quickIconWidget->suitableSize().width(), m_dockSize);
m_trayView->setFixedSize(m_trayView->suitableSize().width(), m_dockSize);
m_toolFrontSpaceWidget->setFixedSize(SPLITESPACE, m_dockSize);
m_toolBackSpaceWidget->setFixedSize(SPLITESPACE, m_dockSize);
Expand Down
10 changes: 5 additions & 5 deletions panels/dock/tray/frame/window/tray/tray_gridview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,12 @@ void TrayGridView::handleDragEnterEvent(QDragEnterEvent *e)
{
const QModelIndex index = indexAt(e->position().toPoint());

if (model()->canDropMimeData(e->mimeData(), e->dropAction(), index.row(),
index.column(), index)) {
e->accept();
} else {
// if (model()->canDropMimeData(e->mimeData(), e->dropAction(), index.row(),
// index.column(), index)) {
// e->accept();
// } else {
e->ignore();
}
// }

Q_EMIT dragEntered();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class HighlightIconEngine : public QIconEngine
if (painter->device() && (!QCoreApplication::testAttribute(Qt::AA_UseHighDpiPixmaps)))
scale = painter->device()->devicePixelRatioF();

pixmapSize *= scale;

QPixmap pm = m_icon.pixmap(pixmapSize, mode, state);
if (pm.isNull())
return;
Expand Down
4 changes: 2 additions & 2 deletions panels/dock/tray/plugins/pluginmanager/quicksettingitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void QuickSettingItem::paintEvent(QPaintEvent *e)
{
QWidget::paintEvent(e);
QPainter painter(this);
painter.setRenderHint(QPainter::RenderHint::Antialiasing);
painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
painter.setPen(foregroundColor());
QPainterPath path;
path.addRoundedRect(rect(), RADIUS, RADIUS);
Expand All @@ -106,7 +106,7 @@ void QuickSettingItem::paintEvent(QPaintEvent *e)
}

painter.save();
painter.setPen(borderColor);
painter.setPen(QPen(borderColor, 2));
painter.drawRoundedRect(rect(), RADIUS, RADIUS);
painter.restore();
}
Expand Down