DtkWidget
DTK Widget module
载入中...
搜索中...
未找到
dsegmentedcontrol.h
1// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DSEGMENTEDCONTROL_H
6#define DSEGMENTEDCONTROL_H
7
8#include <dtkwidget_global.h>
9
10#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
11
12#include <QFrame>
13#include <QHBoxLayout>
14#include <QToolButton>
15#include <QPropertyAnimation>
16#include <QList>
17#include <QEasingCurve>
18#include <DObject>
19
20DWIDGET_BEGIN_NAMESPACE
21
22class LIBDTKWIDGETSHARED_EXPORT D_DECL_DEPRECATED DSegmentedHighlight : public QToolButton
23{
24 Q_OBJECT
25
26public:
27 explicit DSegmentedHighlight(QWidget *parent = 0);
28};
29
30class DSegmentedControlPrivate;
31class LIBDTKWIDGETSHARED_EXPORT D_DECL_DEPRECATED_X("Use DButtonBox") DSegmentedControl : public QWidget, public DCORE_NAMESPACE::DObject
32{
33 Q_OBJECT
34 D_DECLARE_PRIVATE(DSegmentedControl)
35
36 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
37 Q_PROPERTY(int count READ count)
38 Q_PROPERTY(int animationDuration READ animationDuration WRITE setAnimationDuration)
39 Q_PROPERTY(QEasingCurve::Type animationType READ animationType WRITE setAnimationType)
40public:
41 explicit DSegmentedControl(QWidget *parent = 0);
42
43 int count() const;
44 const DSegmentedHighlight *highlight() const;
45 int currentIndex() const;
46 QToolButton *at(int index) const;
47 QString getText(int index) const;
48 QIcon getIcon(int index) const;
49 int animationDuration() const;
50 int indexByTitle(const QString &title) const;
51
52 QEasingCurve::Type animationType() const;
53
54public Q_SLOTS:
55 int addSegmented(const QString &title);
56 int addSegmented(const QIcon &icon, const QString &title);
57 void addSegmented(const QStringList &titleList);
58 void addSegmented(const QList<QIcon> &iconList, const QStringList &titleList);
59 void insertSegmented(int index, const QString &title);
60 void insertSegmented(int index, const QIcon &icon, const QString &title);
61 void removeSegmented(int index);
62 void clear();
63 bool setCurrentIndex(int currentIndex);
64 bool setCurrentIndexByTitle(const QString &title);
65 void setText(int index, const QString &title);
66 void setIcon(int index, const QIcon &icon);
67 void setAnimationDuration(int animationDuration);
68 void setAnimationType(QEasingCurve::Type animationType);
69
70private Q_SLOTS:
71 void updateHighlightGeometry(bool animation = true);
72 void buttonClicked();
73
74Q_SIGNALS:
75 void currentChanged(int index);
76 void currentTitleChanged(QString title);
77 void animationDurationChanged(int animationDuration);
78
79protected:
80 bool eventFilter(QObject *, QEvent *) override;
81 void resizeEvent(QResizeEvent *event) override;
82};
83
84DWIDGET_END_NAMESPACE
85#endif // DSEGMENTEDCONTROL_H
86
87#endif