qabstractslider.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2016 The Qt Company Ltd.
  4. ** Contact: https://www.qt.io/licensing/
  5. **
  6. ** This file is part of the QtWidgets module of the Qt Toolkit.
  7. **
  8. ** $QT_BEGIN_LICENSE:LGPL$
  9. ** Commercial License Usage
  10. ** Licensees holding valid commercial Qt licenses may use this file in
  11. ** accordance with the commercial license agreement provided with the
  12. ** Software or, alternatively, in accordance with the terms contained in
  13. ** a written agreement between you and The Qt Company. For licensing terms
  14. ** and conditions see https://www.qt.io/terms-conditions. For further
  15. ** information use the contact form at https://www.qt.io/contact-us.
  16. **
  17. ** GNU Lesser General Public License Usage
  18. ** Alternatively, this file may be used under the terms of the GNU Lesser
  19. ** General Public License version 3 as published by the Free Software
  20. ** Foundation and appearing in the file LICENSE.LGPL3 included in the
  21. ** packaging of this file. Please review the following information to
  22. ** ensure the GNU Lesser General Public License version 3 requirements
  23. ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
  24. **
  25. ** GNU General Public License Usage
  26. ** Alternatively, this file may be used under the terms of the GNU
  27. ** General Public License version 2.0 or (at your option) the GNU General
  28. ** Public license version 3 or any later version approved by the KDE Free
  29. ** Qt Foundation. The licenses are as published by the Free Software
  30. ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
  31. ** included in the packaging of this file. Please review the following
  32. ** information to ensure the GNU General Public License requirements will
  33. ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
  34. ** https://www.gnu.org/licenses/gpl-3.0.html.
  35. **
  36. ** $QT_END_LICENSE$
  37. **
  38. ****************************************************************************/
  39. #ifndef QABSTRACTSLIDER_H
  40. #define QABSTRACTSLIDER_H
  41. #include <QtWidgets/qwidget.h>
  42. QT_BEGIN_NAMESPACE
  43. class QAbstractSliderPrivate;
  44. class Q_WIDGETS_EXPORT QAbstractSlider : public QWidget
  45. {
  46. Q_OBJECT
  47. Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
  48. Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
  49. Q_PROPERTY(int singleStep READ singleStep WRITE setSingleStep)
  50. Q_PROPERTY(int pageStep READ pageStep WRITE setPageStep)
  51. Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged USER true)
  52. Q_PROPERTY(int sliderPosition READ sliderPosition WRITE setSliderPosition NOTIFY sliderMoved)
  53. Q_PROPERTY(bool tracking READ hasTracking WRITE setTracking)
  54. Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
  55. Q_PROPERTY(bool invertedAppearance READ invertedAppearance WRITE setInvertedAppearance)
  56. Q_PROPERTY(bool invertedControls READ invertedControls WRITE setInvertedControls)
  57. Q_PROPERTY(bool sliderDown READ isSliderDown WRITE setSliderDown DESIGNABLE false)
  58. public:
  59. explicit QAbstractSlider(QWidget *parent = Q_NULLPTR);
  60. ~QAbstractSlider();
  61. Qt::Orientation orientation() const;
  62. void setMinimum(int);
  63. int minimum() const;
  64. void setMaximum(int);
  65. int maximum() const;
  66. void setSingleStep(int);
  67. int singleStep() const;
  68. void setPageStep(int);
  69. int pageStep() const;
  70. void setTracking(bool enable);
  71. bool hasTracking() const;
  72. void setSliderDown(bool);
  73. bool isSliderDown() const;
  74. void setSliderPosition(int);
  75. int sliderPosition() const;
  76. void setInvertedAppearance(bool);
  77. bool invertedAppearance() const;
  78. void setInvertedControls(bool);
  79. bool invertedControls() const;
  80. enum SliderAction {
  81. SliderNoAction,
  82. SliderSingleStepAdd,
  83. SliderSingleStepSub,
  84. SliderPageStepAdd,
  85. SliderPageStepSub,
  86. SliderToMinimum,
  87. SliderToMaximum,
  88. SliderMove
  89. };
  90. int value() const;
  91. void triggerAction(SliderAction action);
  92. public Q_SLOTS:
  93. void setValue(int);
  94. void setOrientation(Qt::Orientation);
  95. void setRange(int min, int max);
  96. Q_SIGNALS:
  97. void valueChanged(int value);
  98. void sliderPressed();
  99. void sliderMoved(int position);
  100. void sliderReleased();
  101. void rangeChanged(int min, int max);
  102. void actionTriggered(int action);
  103. protected:
  104. bool event(QEvent *e) Q_DECL_OVERRIDE;
  105. void setRepeatAction(SliderAction action, int thresholdTime = 500, int repeatTime = 50);
  106. SliderAction repeatAction() const;
  107. enum SliderChange {
  108. SliderRangeChange,
  109. SliderOrientationChange,
  110. SliderStepsChange,
  111. SliderValueChange
  112. };
  113. virtual void sliderChange(SliderChange change);
  114. void keyPressEvent(QKeyEvent *ev) Q_DECL_OVERRIDE;
  115. void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE;
  116. #ifndef QT_NO_WHEELEVENT
  117. void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE;
  118. #endif
  119. void changeEvent(QEvent *e) Q_DECL_OVERRIDE;
  120. protected:
  121. QAbstractSlider(QAbstractSliderPrivate &dd, QWidget *parent = Q_NULLPTR);
  122. private:
  123. Q_DISABLE_COPY(QAbstractSlider)
  124. Q_DECLARE_PRIVATE(QAbstractSlider)
  125. };
  126. QT_END_NAMESPACE
  127. #endif // QABSTRACTSLIDER_H