File indexing completed on 2024-04-28 16:44:34
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 class QElapsedTimer; 0011 class QTimer; 0012 0013 // 0014 // W A R N I N G 0015 // ------------- 0016 // 0017 // This file is not part of the KDecoration2 API. It exists purely as an 0018 // implementation detail. This header file may change from version to 0019 // version without notice, or even be removed. 0020 // 0021 // We mean it. 0022 // 0023 0024 namespace KDecoration2 0025 { 0026 class Q_DECL_HIDDEN DecorationButton::Private 0027 { 0028 public: 0029 explicit Private(DecorationButtonType type, const QPointer<Decoration> &decoration, DecorationButton *parent); 0030 ~Private(); 0031 0032 bool isPressed() const 0033 { 0034 return m_pressed != Qt::NoButton; 0035 } 0036 bool isPressed(Qt::MouseButton button) const 0037 { 0038 return m_pressed.testFlag(button); 0039 } 0040 0041 void setHovered(bool hovered); 0042 void setPressed(Qt::MouseButton, bool pressed); 0043 void setAcceptedButtons(Qt::MouseButtons buttons); 0044 void setEnabled(bool enabled); 0045 void setChecked(bool checked); 0046 void setCheckable(bool checkable); 0047 void setVisible(bool visible); 0048 void startDoubleClickTimer(); 0049 void invalidateDoubleClickTimer(); 0050 bool wasDoubleClick() const; 0051 void setPressAndHold(bool enable); 0052 void startPressAndHold(); 0053 void stopPressAndHold(); 0054 0055 QString typeToString(DecorationButtonType type); 0056 0057 QPointer<Decoration> decoration; 0058 DecorationButtonType type; 0059 QRectF geometry; 0060 bool hovered; 0061 bool enabled; 0062 bool checkable; 0063 bool checked; 0064 bool visible; 0065 Qt::MouseButtons acceptedButtons; 0066 bool doubleClickEnabled; 0067 bool pressAndHold; 0068 0069 private: 0070 void init(); 0071 DecorationButton *q; 0072 Qt::MouseButtons m_pressed; 0073 QScopedPointer<QElapsedTimer> m_doubleClickTimer; 0074 QScopedPointer<QTimer> m_pressAndHoldTimer; 0075 }; 0076 0077 }