Skip to content

Commit

Permalink
Clang format fix
Browse files Browse the repository at this point in the history
  • Loading branch information
urFate committed Nov 1, 2022
1 parent 2f8a153 commit f12f50a
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 79 deletions.
11 changes: 6 additions & 5 deletions src/decoration/qgnomeplatformdecoration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void QGnomePlatformDecoration::paint(QPaintDevice *device)
roundedRect.addRoundedRect(margins().left(), margins().bottom(), surfaceRect.width() - margins().left() - margins().right(), margins().top() + 8, 8, 8);
}

p.fillPath(roundedRect.simplified(), active ? m_backgroundColor: m_backgroundInactiveColor);
p.fillPath(roundedRect.simplified(), active ? m_backgroundColor : m_backgroundInactiveColor);

// Border around
// ********************************
Expand Down Expand Up @@ -322,7 +322,7 @@ void QGnomePlatformDecoration::paint(QPaintDevice *device)
.addRoundedRect(WINDOW_BORDER_WIDTH, WINDOW_BORDER_WIDTH, surfaceRect.width() - margins().left() - margins().right(), margins().top() + 8, 8, 8);
}

p.fillPath(roundedRect.simplified(), active ? m_backgroundColor: m_backgroundInactiveColor);
p.fillPath(roundedRect.simplified(), active ? m_backgroundColor : m_backgroundInactiveColor);

// Border around
// ********************************
Expand Down Expand Up @@ -416,7 +416,7 @@ void QGnomePlatformDecoration::paint(QPaintDevice *device)

// Close button

renderButton(&p, closeButtonRect(), Adwaita::ButtonType::ButtonClose, m_clicking == Button::Close);
renderButton(&p, closeButtonRect(), Adwaita::ButtonType::ButtonClose, m_clicking == Button::Close);

// Maximize button
if (GnomeSettings::getInstance().titlebarButtons().testFlag(GnomeSettings::getInstance().MaximizeButton)) {
Expand All @@ -428,7 +428,7 @@ void QGnomePlatformDecoration::paint(QPaintDevice *device)

// Minimize button
if (GnomeSettings::getInstance().titlebarButtons().testFlag(GnomeSettings::getInstance().MinimizeButton)) {
renderButton(&p, minimizeButtonRect(), Adwaita::ButtonType::ButtonMinimize, m_clicking == Button::Minimize);
renderButton(&p, minimizeButtonRect(), Adwaita::ButtonType::ButtonMinimize, m_clicking == Button::Minimize);
}
}

Expand Down Expand Up @@ -737,7 +737,8 @@ bool QGnomePlatformDecoration::updateButtonHoverState(Button hoveredButton)
return false;
}

bool QGnomePlatformDecoration::isButtonHovered(Adwaita::ButtonType button) const {
bool QGnomePlatformDecoration::isButtonHovered(Adwaita::ButtonType button) const
{
switch (button) {
case Adwaita::ButtonType::ButtonClose:
return m_closeButtonHovered;
Expand Down
148 changes: 74 additions & 74 deletions src/decoration/qgnomeplatformdecoration.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/*
* Copyright (C) 2019-2022 Jan Grulich <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
* Copyright (C) 2019-2022 Jan Grulich <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/

#ifndef QGNOMEPLATFORMDECORATION_H
#define QGNOMEPLATFORMDECORATION_H
Expand All @@ -42,73 +42,73 @@ enum Button { None, Close, Maximize, Minimize, Restore };
class QGnomePlatformDecoration : public QWaylandAbstractDecoration
{
public:
QGnomePlatformDecoration();
virtual ~QGnomePlatformDecoration() override = default;
QGnomePlatformDecoration();
virtual ~QGnomePlatformDecoration() override = default;

protected:
#ifdef DECORATION_SHADOWS_SUPPORT // Qt 6.2.0+ or patched QtWayland
QMargins margins(MarginsType marginsType = Full) const override;
QMargins margins(MarginsType marginsType = Full) const override;
#else
QMargins margins() const override;
QMargins margins() const override;
#endif
void paint(QPaintDevice *device) override;
bool handleMouse(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
void paint(QPaintDevice *device) override;
bool handleMouse(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
#if QT_VERSION >= 0x060000
bool
handleTouch(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, QEventPoint::State state, Qt::KeyboardModifiers mods) override;
bool
handleTouch(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, QEventPoint::State state, Qt::KeyboardModifiers mods) override;
#else
bool
handleTouch(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, Qt::TouchPointState state, Qt::KeyboardModifiers mods) override;
bool
handleTouch(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, Qt::TouchPointState state, Qt::KeyboardModifiers mods) override;
#endif

private:
QRect windowContentGeometry() const;

void forceRepaint();
void loadConfiguration();

void processMouseTop(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b, Qt::KeyboardModifiers mods);
void processMouseBottom(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b, Qt::KeyboardModifiers mods);
void processMouseLeft(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b, Qt::KeyboardModifiers mods);
void processMouseRight(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b, Qt::KeyboardModifiers mods);
void renderButton(QPainter *painter, const QRectF &rect, Adwaita::ButtonType button, bool sunken);

bool clickButton(Qt::MouseButtons b, Button btn);
bool doubleClickButton(Qt::MouseButtons b, const QPointF &local, const QDateTime &currentTime);
bool updateButtonHoverState(Button hoveredButton);

QRectF closeButtonRect() const;
QRectF maximizeButtonRect() const;
QRectF minimizeButtonRect() const;

// Colors
QColor m_backgroundColor;
QColor m_foregroundColor;
QColor m_backgroundInactiveColor;
QColor m_foregroundInactiveColor;
QColor m_borderColor;
QColor m_borderInactiveColor;
QColor m_buttonBackgroundColor;
QColor m_buttonHoverColor;

// Buttons
bool m_closeButtonHovered;
bool m_maximizeButtonHovered;
bool m_minimizeButtonHovered;
bool isButtonHovered(Adwaita::ButtonType button) const;

// For double-click support
QDateTime m_lastButtonClick;
QPointF m_lastButtonClickPosition;
Button m_doubleClicking = None;

QStaticText m_windowTitle;
Button m_clicking = None;

// Shadows
QPixmap m_shadowPixmap;

Adwaita::ColorVariant m_adwaitaVariant;
QRect windowContentGeometry() const;

void forceRepaint();
void loadConfiguration();

void processMouseTop(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b, Qt::KeyboardModifiers mods);
void processMouseBottom(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b, Qt::KeyboardModifiers mods);
void processMouseLeft(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b, Qt::KeyboardModifiers mods);
void processMouseRight(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b, Qt::KeyboardModifiers mods);
void renderButton(QPainter *painter, const QRectF &rect, Adwaita::ButtonType button, bool sunken);

bool clickButton(Qt::MouseButtons b, Button btn);
bool doubleClickButton(Qt::MouseButtons b, const QPointF &local, const QDateTime &currentTime);
bool updateButtonHoverState(Button hoveredButton);
bool isButtonHovered(Adwaita::ButtonType button) const;

QRectF closeButtonRect() const;
QRectF maximizeButtonRect() const;
QRectF minimizeButtonRect() const;

// Colors
QColor m_backgroundColor;
QColor m_foregroundColor;
QColor m_backgroundInactiveColor;
QColor m_foregroundInactiveColor;
QColor m_borderColor;
QColor m_borderInactiveColor;
QColor m_buttonBackgroundColor;
QColor m_buttonHoverColor;

// Buttons
bool m_closeButtonHovered;
bool m_maximizeButtonHovered;
bool m_minimizeButtonHovered;

// For double-click support
QDateTime m_lastButtonClick;
QPointF m_lastButtonClickPosition;
Button m_doubleClicking = None;

QStaticText m_windowTitle;
Button m_clicking = None;

// Shadows
QPixmap m_shadowPixmap;

Adwaita::ColorVariant m_adwaitaVariant;
};

#endif // QGNOMEPLATFORMDECORATION_H

0 comments on commit f12f50a

Please sign in to comment.