File: dlineedit.h

package info (click to toggle)
dtkwidget 5.7.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 36,540 kB
  • sloc: cpp: 63,257; ansic: 132; python: 88; sh: 42; makefile: 13
file content (96 lines) | stat: -rw-r--r-- 2,615 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#ifndef DLINEEDIT_H
#define DLINEEDIT_H

#include <dobject.h>
#include <dtkwidget_global.h>

#include <QWidget>
#include <QLineEdit>
#include <QHBoxLayout>

DWIDGET_BEGIN_NAMESPACE

class DLineEditPrivate;
class DStyleOptionLineEdit;
class LIBDTKWIDGETSHARED_EXPORT DLineEdit : public QWidget, public DTK_CORE_NAMESPACE::DObject
{
    Q_OBJECT
    Q_DISABLE_COPY(DLineEdit)
    D_DECLARE_PRIVATE(DLineEdit)
    Q_PROPERTY(bool alert READ isAlert WRITE setAlert NOTIFY alertChanged)

public:
    DLineEdit(QWidget *parent = nullptr);
    virtual ~DLineEdit() override;

    QLineEdit *lineEdit() const;
    void setPlaceholderText(const QString &);

    void setAlert(bool isAlert);
    bool isAlert() const;
    void showAlertMessage(const QString &text, int duration = 3000);
    void showAlertMessage(const QString &text, QWidget *follower, int duration = 3000);
    void setAlertMessageAlignment(Qt::Alignment alignment);
    Qt::Alignment alertMessageAlignment() const;
    void hideAlertMessage();

    void setLeftWidgets(const QList<QWidget *> &list);
    void setRightWidgets(const QList<QWidget *> &list);

    void setLeftWidgetsVisible(bool visible);
    void setRightWidgetsVisible(bool visible);

    void setClearButtonEnabled(bool enable);
    bool isClearButtonEnabled() const;

    void setText(const QString &text);
    QString text();

    void clear();

    QLineEdit::EchoMode echoMode() const;
    void setEchoMode(QLineEdit::EchoMode mode);

    void setContextMenuPolicy(Qt::ContextMenuPolicy policy);

    bool speechToTextIsEnabled() const;
    void setSpeechToTextEnabled(bool enable);

    bool textToSpeechIsEnabled() const;
    void setTextToSpeechEnabled(bool enable);

    bool textToTranslateIsEnabled() const;
    void setTextToTranslateEnabled(bool enable);

    bool copyEnabled() const;
    void setCopyEnabled(bool enable);

    bool cutEnabled() const;
    void setCutEnabled(bool enable);

Q_SIGNALS:
    void alertChanged(bool alert) const;
    void focusChanged(bool onFocus) const;

    void textChanged(const QString &);
    void textEdited(const QString &);
    void cursorPositionChanged(int, int);
    void returnPressed();
    void editingFinished();
    void selectionChanged();

protected:
    DLineEdit(DLineEditPrivate &q, QWidget *parent);
    bool eventFilter(QObject *watched, QEvent *event) override;
    bool event(QEvent *event) override;

    friend class DStyleOptionLineEdit;
};

DWIDGET_END_NAMESPACE

#endif // DLINEEDIT_H