VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILineEdit.h

Last change on this file was 104041, checked in by vboxsync, 8 weeks ago

FE/Qt: bugref:6899: Accessibility improvement for UIMarkableLineEdit; This wrapper should now redirect tool-tip assigned to wrapped line-edit, VoiceOver likes that one.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/* $Id: QILineEdit.h 104041 2024-03-25 14:24:04Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - Qt extensions: QILineEdit class declaration.
4 */
5
6/*
7 * Copyright (C) 2008-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef FEQT_INCLUDED_SRC_extensions_QILineEdit_h
29#define FEQT_INCLUDED_SRC_extensions_QILineEdit_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes */
35#include <QIcon>
36#include <QLineEdit>
37
38/* GUI includes: */
39#include "UILibraryDefs.h"
40
41class QLabel;
42
43/** QLineEdit extension with advanced functionality. */
44class SHARED_LIBRARY_STUFF QILineEdit : public QLineEdit
45{
46 Q_OBJECT;
47
48public:
49
50 /** Constructs line-edit passing @a pParent to the base-class. */
51 QILineEdit(QWidget *pParent = 0);
52 /** Constructs line-edit passing @a pParent to the base-class.
53 * @param strText Brings the line-edit text. */
54 QILineEdit(const QString &strText, QWidget *pParent = 0);
55
56 /** Defines whether this is @a fAllowed to copy contents when disabled. */
57 void setAllowToCopyContentsWhenDisabled(bool fAllowed);
58
59 /** Forces line-edit to adjust minimum width acording to passed @a strText. */
60 void setMinimumWidthByText(const QString &strText);
61 /** Forces line-edit to adjust fixed width acording to passed @a strText. */
62 void setFixedWidthByText(const QString &strText);
63
64 /** Puts an icon to mark some error on the right hand side of the line edit. @p is used as tooltip of the icon. */
65 void mark(bool fError, const QString &strErrorMessage = QString());
66
67protected:
68
69 /** Handles any Qt @a pEvent. */
70 virtual bool event(QEvent *pEvent) RT_OVERRIDE;
71
72 /** Handles resize @a pEvent. */
73 virtual void resizeEvent(QResizeEvent *pResizeEvent) RT_OVERRIDE;
74
75private slots:
76
77 /** Copies text into clipboard. */
78 void copy();
79
80private:
81
82 /** Prepares all. */
83 void prepare();
84
85 /** Calculates suitable @a strText size. */
86 QSize fitTextWidth(const QString &strText) const;
87
88 /** Holds whether this is allowed to copy contents when disabled. */
89 bool m_fAllowToCopyContentsWhenDisabled;
90 /** Holds the copy to clipboard action. */
91 QAction *m_pCopyAction;
92
93 QLabel *m_pIconLabel;
94 QIcon m_markIcon;
95 bool m_fMarkForError;
96 QString m_strErrorMessage;
97};
98
99class SHARED_LIBRARY_STUFF UIMarkableLineEdit : public QWidget
100{
101 Q_OBJECT;
102
103signals:
104
105 void textChanged(const QString &strText);
106
107public:
108
109 UIMarkableLineEdit(QWidget *pParent = 0);
110 void mark(bool fError, const QString &strErrorMessage = QString());
111
112 /** @name Pass through functions for QILineEdit.
113 * @{ */
114 void setText(const QString &strText);
115 void setToolTip(const QString &strText);
116 QString text() const;
117 void setValidator(const QValidator *pValidator);
118 bool hasAcceptableInput() const;
119 void setPlaceholderText(const QString &strText);
120 /** @} */
121
122private:
123
124 void prepare();
125
126 QILineEdit *m_pLineEdit;
127 QLabel *m_pIconLabel;
128};
129
130#endif /* !FEQT_INCLUDED_SRC_extensions_QILineEdit_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use