2014-10-31 06:53:04 +00:00
|
|
|
/*
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
|
|
|
*/
|
2014-10-31 06:53:04 +00:00
|
|
|
#ifndef KDECOARTIONS_PREVIEW_CLIENT_H
|
|
|
|
#define KDECOARTIONS_PREVIEW_CLIENT_H
|
|
|
|
|
2015-03-31 13:26:42 +00:00
|
|
|
#include "../../../decorations/decorationpalette.h"
|
|
|
|
|
2014-10-31 06:53:04 +00:00
|
|
|
#include <KDecoration2/Private/DecoratedClientPrivate>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QPalette>
|
|
|
|
|
|
|
|
class QAbstractItemModel;
|
|
|
|
|
|
|
|
namespace KDecoration2
|
|
|
|
{
|
|
|
|
namespace Preview
|
|
|
|
{
|
2017-01-11 09:21:03 +00:00
|
|
|
class PreviewClient : public QObject, public ApplicationMenuEnabledDecoratedClientPrivate
|
2014-10-31 06:53:04 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(KDecoration2::Decoration *decoration READ decoration CONSTANT)
|
|
|
|
Q_PROPERTY(QString caption READ caption WRITE setCaption NOTIFY captionChanged)
|
|
|
|
Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY iconChanged)
|
|
|
|
Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged)
|
|
|
|
Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
|
|
|
|
Q_PROPERTY(bool closeable READ isCloseable WRITE setCloseable NOTIFY closeableChanged)
|
|
|
|
Q_PROPERTY(bool keepAbove READ isKeepAbove WRITE setKeepAbove NOTIFY keepAboveChanged)
|
|
|
|
Q_PROPERTY(bool keepBelow READ isKeepBelow WRITE setKeepBelow NOTIFY keepBelowChanged)
|
|
|
|
Q_PROPERTY(bool maximizable READ isMaximizeable WRITE setMaximizable NOTIFY maximizableChanged)
|
|
|
|
Q_PROPERTY(bool maximized READ isMaximized NOTIFY maximizedChanged)
|
|
|
|
Q_PROPERTY(bool maximizedVertically READ isMaximizedVertically WRITE setMaximizedVertically NOTIFY maximizedVerticallyChanged)
|
|
|
|
Q_PROPERTY(bool maximizedHorizontally READ isMaximizedHorizontally WRITE setMaximizedHorizontally NOTIFY maximizedHorizontallyChanged)
|
|
|
|
Q_PROPERTY(bool minimizable READ isMinimizeable WRITE setMinimizable NOTIFY minimizableChanged)
|
|
|
|
Q_PROPERTY(bool modal READ isModal WRITE setModal NOTIFY modalChanged)
|
|
|
|
Q_PROPERTY(bool movable READ isMoveable WRITE setMovable NOTIFY movableChanged)
|
|
|
|
Q_PROPERTY(int desktop READ desktop WRITE setDesktop NOTIFY desktopChanged)
|
|
|
|
Q_PROPERTY(bool onAllDesktops READ isOnAllDesktops NOTIFY onAllDesktopsChanged)
|
|
|
|
Q_PROPERTY(bool resizable READ isResizeable WRITE setResizable NOTIFY resizableChanged)
|
|
|
|
Q_PROPERTY(bool shadeable READ isShadeable WRITE setShadeable NOTIFY shadeableChanged)
|
|
|
|
Q_PROPERTY(bool shaded READ isShaded WRITE setShaded NOTIFY shadedChanged)
|
|
|
|
Q_PROPERTY(bool providesContextHelp READ providesContextHelp WRITE setProvidesContextHelp NOTIFY providesContextHelpChanged)
|
|
|
|
Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
|
|
|
|
Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
|
|
|
|
Q_PROPERTY(bool bordersTopEdge READ bordersTopEdge WRITE setBordersTopEdge NOTIFY bordersTopEdgeChanged)
|
|
|
|
Q_PROPERTY(bool bordersLeftEdge READ bordersLeftEdge WRITE setBordersLeftEdge NOTIFY bordersLeftEdgeChanged)
|
|
|
|
Q_PROPERTY(bool bordersRightEdge READ bordersRightEdge WRITE setBordersRightEdge NOTIFY bordersRightEdgeChanged)
|
|
|
|
Q_PROPERTY(bool bordersBottomEdge READ bordersBottomEdge WRITE setBordersBottomEdge NOTIFY bordersBottomEdgeChanged)
|
|
|
|
public:
|
|
|
|
explicit PreviewClient(DecoratedClient *client, Decoration *decoration);
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
~PreviewClient() override;
|
2014-10-31 06:53:04 +00:00
|
|
|
|
|
|
|
QString caption() const override;
|
|
|
|
WId decorationId() const override;
|
|
|
|
WId windowId() const override;
|
|
|
|
int desktop() const override;
|
|
|
|
QIcon icon() const override;
|
|
|
|
bool isActive() const override;
|
|
|
|
bool isCloseable() const override;
|
|
|
|
bool isKeepAbove() const override;
|
|
|
|
bool isKeepBelow() const override;
|
|
|
|
bool isMaximizeable() const override;
|
|
|
|
bool isMaximized() const override;
|
|
|
|
bool isMaximizedVertically() const override;
|
|
|
|
bool isMaximizedHorizontally() const override;
|
|
|
|
bool isMinimizeable() const override;
|
|
|
|
bool isModal() const override;
|
|
|
|
bool isMoveable() const override;
|
|
|
|
bool isOnAllDesktops() const override;
|
|
|
|
bool isResizeable() const override;
|
|
|
|
bool isShadeable() const override;
|
|
|
|
bool isShaded() const override;
|
|
|
|
bool providesContextHelp() const override;
|
|
|
|
|
|
|
|
int width() const override;
|
|
|
|
int height() const override;
|
2020-01-27 13:16:02 +00:00
|
|
|
QSize size() const override;
|
2014-10-31 06:53:04 +00:00
|
|
|
QPalette palette() const override;
|
2015-03-31 13:26:42 +00:00
|
|
|
QColor color(ColorGroup group, ColorRole role) const override;
|
2014-11-11 13:33:31 +00:00
|
|
|
Qt::Edges adjacentScreenEdges() const override;
|
2014-10-31 06:53:04 +00:00
|
|
|
|
2017-01-11 09:21:03 +00:00
|
|
|
bool hasApplicationMenu() const override;
|
|
|
|
bool isApplicationMenuActive() const override;
|
|
|
|
|
2018-01-18 18:59:17 +00:00
|
|
|
void requestShowToolTip(const QString &text) override;
|
|
|
|
void requestHideToolTip() override;
|
2014-10-31 06:53:04 +00:00
|
|
|
void requestClose() override;
|
|
|
|
void requestContextHelp() override;
|
2014-11-11 08:53:54 +00:00
|
|
|
void requestToggleMaximization(Qt::MouseButtons buttons) override;
|
2014-10-31 06:53:04 +00:00
|
|
|
void requestMinimize() override;
|
|
|
|
void requestToggleKeepAbove() override;
|
|
|
|
void requestToggleKeepBelow() override;
|
|
|
|
void requestToggleShade() override;
|
|
|
|
void requestShowWindowMenu() override;
|
2017-01-11 09:21:03 +00:00
|
|
|
void requestShowApplicationMenu(const QRect &rect, int actionId) override;
|
2014-10-31 06:53:04 +00:00
|
|
|
void requestToggleOnAllDesktops() override;
|
|
|
|
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
void showApplicationMenu(int actionId) override;
|
2017-01-11 09:21:03 +00:00
|
|
|
|
2014-10-31 06:53:04 +00:00
|
|
|
void setCaption(const QString &caption);
|
|
|
|
void setActive(bool active);
|
|
|
|
void setCloseable(bool closeable);
|
|
|
|
void setMaximizable(bool maximizable);
|
|
|
|
void setKeepBelow(bool keepBelow);
|
|
|
|
void setKeepAbove(bool keepAbove);
|
|
|
|
void setMaximizedHorizontally(bool maximized);
|
|
|
|
void setMaximizedVertically(bool maximized);
|
|
|
|
void setMinimizable(bool minimizable);
|
|
|
|
void setModal(bool modal);
|
|
|
|
void setMovable(bool movable);
|
|
|
|
void setResizable(bool resizable);
|
|
|
|
void setShadeable(bool shadeable);
|
|
|
|
void setShaded(bool shaded);
|
|
|
|
void setProvidesContextHelp(bool contextHelp);
|
|
|
|
void setDesktop(int desktop);
|
|
|
|
|
|
|
|
void setWidth(int width);
|
|
|
|
void setHeight(int height);
|
|
|
|
|
|
|
|
QString iconName() const;
|
|
|
|
void setIconName(const QString &icon);
|
|
|
|
void setIcon(const QIcon &icon);
|
|
|
|
|
|
|
|
bool bordersTopEdge() const;
|
|
|
|
bool bordersLeftEdge() const;
|
|
|
|
bool bordersRightEdge() const;
|
|
|
|
bool bordersBottomEdge() const;
|
|
|
|
|
|
|
|
void setBordersTopEdge(bool enabled);
|
|
|
|
void setBordersLeftEdge(bool enabled);
|
|
|
|
void setBordersRightEdge(bool enabled);
|
|
|
|
void setBordersBottomEdge(bool enabled);
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void captionChanged(const QString &);
|
|
|
|
void iconChanged(const QIcon &);
|
|
|
|
void iconNameChanged(const QString &);
|
|
|
|
void activeChanged(bool);
|
|
|
|
void closeableChanged(bool);
|
|
|
|
void keepAboveChanged(bool);
|
|
|
|
void keepBelowChanged(bool);
|
|
|
|
void maximizableChanged(bool);
|
|
|
|
void maximizedChanged(bool);
|
|
|
|
void maximizedVerticallyChanged(bool);
|
|
|
|
void maximizedHorizontallyChanged(bool);
|
|
|
|
void minimizableChanged(bool);
|
|
|
|
void modalChanged(bool);
|
|
|
|
void movableChanged(bool);
|
|
|
|
void onAllDesktopsChanged(bool);
|
|
|
|
void resizableChanged(bool);
|
|
|
|
void shadeableChanged(bool);
|
|
|
|
void shadedChanged(bool);
|
|
|
|
void providesContextHelpChanged(bool);
|
|
|
|
void desktopChanged(int);
|
|
|
|
void widthChanged(int);
|
|
|
|
void heightChanged(int);
|
|
|
|
void paletteChanged(const QPalette&);
|
|
|
|
void bordersTopEdgeChanged(bool);
|
|
|
|
void bordersLeftEdgeChanged(bool);
|
|
|
|
void bordersRightEdgeChanged(bool);
|
|
|
|
void bordersBottomEdgeChanged(bool);
|
|
|
|
|
|
|
|
void showWindowMenuRequested();
|
2017-01-11 09:21:03 +00:00
|
|
|
void showApplicationMenuRequested();
|
2014-10-31 06:53:04 +00:00
|
|
|
void minimizeRequested();
|
|
|
|
void closeRequested();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_caption;
|
|
|
|
QIcon m_icon;
|
|
|
|
QString m_iconName;
|
2015-03-31 13:26:42 +00:00
|
|
|
KWin::Decoration::DecorationPalette m_palette;
|
2014-10-31 06:53:04 +00:00
|
|
|
bool m_active;
|
|
|
|
bool m_closeable;
|
|
|
|
bool m_keepBelow;
|
|
|
|
bool m_keepAbove;
|
|
|
|
bool m_maximizable;
|
|
|
|
bool m_maximizedHorizontally;
|
|
|
|
bool m_maximizedVertically;
|
|
|
|
bool m_minimizable;
|
|
|
|
bool m_modal;
|
|
|
|
bool m_movable;
|
|
|
|
bool m_resizable;
|
|
|
|
bool m_shadeable;
|
|
|
|
bool m_shaded;
|
|
|
|
bool m_providesContextHelp;
|
|
|
|
int m_desktop;
|
|
|
|
int m_width;
|
|
|
|
int m_height;
|
|
|
|
bool m_bordersTopEdge;
|
|
|
|
bool m_bordersLeftEdge;
|
|
|
|
bool m_bordersRightEdge;
|
|
|
|
bool m_bordersBottomEdge;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Preview
|
|
|
|
} // namespace KDecoration2
|
|
|
|
|
|
|
|
#endif
|