File indexing completed on 2024-05-05 05:29:54

0001 /*
0002  * SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005  */
0006 #pragma once
0007 
0008 #include "decorationbutton.h"
0009 
0010 #include <QPointer>
0011 
0012 class QElapsedTimer;
0013 class QTimer;
0014 
0015 //
0016 //  W A R N I N G
0017 //  -------------
0018 //
0019 // This file is not part of the KDecoration2 API.  It exists purely as an
0020 // implementation detail.  This header file may change from version to
0021 // version without notice, or even be removed.
0022 //
0023 // We mean it.
0024 //
0025 
0026 namespace KDecoration2
0027 {
0028 class Q_DECL_HIDDEN DecorationButton::Private
0029 {
0030 public:
0031     explicit Private(DecorationButtonType type, const QPointer<Decoration> &decoration, DecorationButton *parent);
0032     ~Private();
0033 
0034     bool isPressed() const
0035     {
0036         return m_pressed != Qt::NoButton;
0037     }
0038     bool isPressed(Qt::MouseButton button) const
0039     {
0040         return m_pressed.testFlag(button);
0041     }
0042 
0043     void setHovered(bool hovered);
0044     void setPressed(Qt::MouseButton, bool pressed);
0045     void setAcceptedButtons(Qt::MouseButtons buttons);
0046     void setEnabled(bool enabled);
0047     void setChecked(bool checked);
0048     void setCheckable(bool checkable);
0049     void setVisible(bool visible);
0050     void startDoubleClickTimer();
0051     void invalidateDoubleClickTimer();
0052     bool wasDoubleClick() const;
0053     void setPressAndHold(bool enable);
0054     void startPressAndHold();
0055     void stopPressAndHold();
0056 
0057     QString typeToString(DecorationButtonType type);
0058 
0059     QPointer<Decoration> decoration;
0060     DecorationButtonType type;
0061     QRectF geometry;
0062     bool hovered;
0063     bool enabled;
0064     bool checkable;
0065     bool checked;
0066     bool visible;
0067     Qt::MouseButtons acceptedButtons;
0068     bool doubleClickEnabled;
0069     bool pressAndHold;
0070 
0071 private:
0072     void init();
0073     DecorationButton *q;
0074     Qt::MouseButtons m_pressed;
0075     std::unique_ptr<QElapsedTimer> m_doubleClickTimer;
0076     std::unique_ptr<QTimer> m_pressAndHoldTimer;
0077 };
0078 
0079 }