File indexing completed on 2024-05-19 05:35:22
0001 #ifndef oxygenfollowmouseanimationconfigitem_h 0002 #define oxygenfollowmouseanimationconfigitem_h 0003 0004 ////////////////////////////////////////////////////////////////////////////// 0005 // oxygenanimationconfigitem.h 0006 // animation configuration item 0007 // ------------------- 0008 // 0009 // SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0010 // 0011 // SPDX-License-Identifier: MIT 0012 ////////////////////////////////////////////////////////////////////////////// 0013 0014 #include "../oxygen.h" 0015 #include "oxygenanimationconfigitem.h" 0016 0017 #include <KComboBox> 0018 0019 #include <QFrame> 0020 #include <QLabel> 0021 #include <QSpinBox> 0022 0023 class Ui_FollowMouseAnimationConfigBox; 0024 0025 namespace Oxygen 0026 { 0027 class FollowMouseAnimationConfigBox : public QFrame 0028 { 0029 Q_OBJECT 0030 0031 public: 0032 //* constructor 0033 explicit FollowMouseAnimationConfigBox(QWidget *); 0034 0035 //* destructor 0036 ~FollowMouseAnimationConfigBox(void) override; 0037 0038 //* type ComboBox 0039 KComboBox *typeComboBox(void) const; 0040 0041 //* duration spin box 0042 QSpinBox *durationSpinBox(void) const; 0043 0044 //* duration spin box 0045 QLabel *durationLabel(void) const; 0046 0047 //* follow mouse duration spinbox 0048 QSpinBox *followMouseDurationSpinBox(void) const; 0049 0050 private Q_SLOTS: 0051 0052 //* type changed 0053 void typeChanged(int); 0054 0055 private: 0056 Ui_FollowMouseAnimationConfigBox *ui; 0057 }; 0058 0059 //* generic animation config item 0060 class FollowMouseAnimationConfigItem : public AnimationConfigItem 0061 { 0062 Q_OBJECT 0063 0064 public: 0065 //* constructor 0066 explicit FollowMouseAnimationConfigItem(QWidget *parent, const QString &title = QString(), const QString &description = QString()) 0067 : AnimationConfigItem(parent, title, description) 0068 { 0069 } 0070 0071 //* initialize configuration widget 0072 void initializeConfigurationWidget(QWidget *) override; 0073 0074 //* configuration widget 0075 QWidget *configurationWidget(void) const override 0076 { 0077 return _configurationWidget.data(); 0078 } 0079 0080 //* type 0081 int type(void) const 0082 { 0083 return (_configurationWidget) ? _configurationWidget.data()->typeComboBox()->currentIndex() : 0; 0084 } 0085 0086 //* duration 0087 int duration(void) const 0088 { 0089 return (_configurationWidget) ? _configurationWidget.data()->durationSpinBox()->value() : 0; 0090 } 0091 0092 //* duration 0093 int followMouseDuration(void) const 0094 { 0095 return (_configurationWidget) ? _configurationWidget.data()->followMouseDurationSpinBox()->value() : 0; 0096 } 0097 0098 //* hide duration spinbox 0099 void hideDurationSpinBox(void) 0100 { 0101 if (_configurationWidget) { 0102 _configurationWidget.data()->durationLabel()->hide(); 0103 _configurationWidget.data()->durationSpinBox()->hide(); 0104 } 0105 } 0106 0107 public Q_SLOTS: 0108 0109 //* type 0110 void setType(int value) 0111 { 0112 if (_configurationWidget) { 0113 _configurationWidget.data()->typeComboBox()->setCurrentIndex(value); 0114 } 0115 } 0116 0117 //* duration 0118 void setDuration(int value) 0119 { 0120 if (_configurationWidget) { 0121 _configurationWidget.data()->durationSpinBox()->setValue(value); 0122 } 0123 } 0124 0125 //* follow mouse duration 0126 void setFollowMouseDuration(int value) 0127 { 0128 if (_configurationWidget) { 0129 _configurationWidget.data()->followMouseDurationSpinBox()->setValue(value); 0130 } 0131 } 0132 0133 private: 0134 //* configuration widget 0135 WeakPointer<FollowMouseAnimationConfigBox> _configurationWidget; 0136 }; 0137 } 0138 0139 #endif