mirror of
https://github.com/ONLYOFFICE/desktop-apps.git
synced 2026-04-07 14:09:22 +08:00
[linux] added rounding of window corners
This commit is contained in:
@ -124,6 +124,7 @@ void CWindowBase::updateScaling(bool resize)
|
||||
void CWindowBase::setWindowColors(const QColor& background, const QColor& border)
|
||||
{
|
||||
Q_UNUSED(border)
|
||||
setProperty("borderColor", border);
|
||||
setStyleSheet(QString("QMainWindow{border:1px solid %1;"
|
||||
#ifdef _WIN32
|
||||
"border-bottom:2px solid %1;"
|
||||
|
||||
@ -35,19 +35,25 @@
|
||||
#include "defines.h"
|
||||
#include "utils.h"
|
||||
#include <QTimer>
|
||||
#include <QPainter>
|
||||
#include <QX11Info>
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
#ifdef DOCUMENTSCORE_OPENSSL_SUPPORT
|
||||
# include "platform_linux/cdialogopenssl.h"
|
||||
#endif
|
||||
#define WINDOW_CORNER_RADIUS 6
|
||||
|
||||
|
||||
CWindowPlatform::CWindowPlatform(const QRect &rect) :
|
||||
CWindowBase(rect),
|
||||
CX11Decoration(this)
|
||||
{
|
||||
if (isCustomWindowStyle())
|
||||
if (isCustomWindowStyle()) {
|
||||
if (QX11Info::isCompositingManagerRunning())
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
CX11Decoration::turnOff();
|
||||
}
|
||||
setIsCustomWindowStyle(!CX11Decoration::isDecorated());
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
setProperty("stabilized", true);
|
||||
@ -145,6 +151,30 @@ void CWindowPlatform::setScreenScalingFactor(double factor, bool resize)
|
||||
CWindowBase::setScreenScalingFactor(factor, resize);
|
||||
}
|
||||
|
||||
void CWindowPlatform::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
CWindowBase::paintEvent(event);
|
||||
if (!QX11Info::isCompositingManagerRunning())
|
||||
return;
|
||||
|
||||
QPainter pnt(this);
|
||||
pnt.setRenderHint(QPainter::Antialiasing);
|
||||
int d = 2 * WINDOW_CORNER_RADIUS * m_dpiRatio;
|
||||
QPainterPath path;
|
||||
path.moveTo(width(), d/2);
|
||||
path.arcTo(width() - d, 0, d, d, 0, 90);
|
||||
path.lineTo(d/2, 0);
|
||||
path.arcTo(0, 0, d, d, 90, 90);
|
||||
path.lineTo(0, height());
|
||||
path.lineTo(width(), height());
|
||||
path.lineTo(width(), d/2);
|
||||
path.closeSubpath();
|
||||
pnt.fillPath(path, palette().window().color());
|
||||
QColor borderColor = property("borderColor").value<QColor>();
|
||||
pnt.strokePath(path, QPen(borderColor, 1));
|
||||
pnt.end();
|
||||
}
|
||||
|
||||
/** Private **/
|
||||
|
||||
void CWindowPlatform::mouseMoveEvent(QMouseEvent *e)
|
||||
|
||||
@ -53,6 +53,7 @@ protected:
|
||||
virtual bool event(QEvent *event) override;
|
||||
virtual bool nativeEvent(const QByteArray&, void*, long*) final;
|
||||
virtual void setScreenScalingFactor(double, bool resize = true) override;
|
||||
virtual void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private:
|
||||
virtual void mouseMoveEvent(QMouseEvent *) final;
|
||||
|
||||
Reference in New Issue
Block a user