VirtualBox

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

Last change on this file was 104980, checked in by vboxsync, 3 months ago

FE/Qt: bugref:10666, bugref:10669: QILineEdit: Merge resizeEvent and showEvent into event function; Throw out some excessive code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1/* $Id: QILineEdit.h 104980 2024-06-20 13:21:58Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - Qt extensions: QILineEdit class declaration.
4 */
5
6/*
7 * Copyright (C) 2008-2024 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 <QLineEdit>
36
37/* GUI includes: */
38#include "UILibraryDefs.h"
39
40/* Forward declarations: */
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 /** Defines whether line-edit is @a fMarkable. */
65 void setMarkable(bool fMarkable);
66 /** Puts an icon to mark some error on the right hand side of the line edit. @p is used as tooltip of the icon. */
67 void mark(bool fError, const QString &strErrorMessage, const QString &strNoErrorMessage);
68
69protected:
70
71 /** Handles any Qt @a pEvent. */
72 virtual bool event(QEvent *pEvent) RT_OVERRIDE;
73
74private slots:
75
76 /** Copies text into clipboard. */
77 void copy();
78
79private:
80
81 /** Prepares all. */
82 void prepare();
83
84 /** Calculates suitable @a strText size. */
85 QSize fitTextWidth(const QString &strText) const;
86
87 /** Sets the geometry of the icon label. */
88 void moveIconLabel();
89
90 /** Holds whether this is allowed to copy contents when disabled. */
91 bool m_fAllowToCopyContentsWhenDisabled;
92 /** Holds the copy to clipboard action. */
93 QAction *m_pCopyAction;
94
95 /** Holds whether line-edit is markable. */
96 bool m_fMarkable;
97 /** Holds whether line-edit is marked for error. */
98 bool m_fMarkForError;
99 /** Holds the icon label instance. */
100 QLabel *m_pLabelIcon;
101 /** Holds last error message. */
102 QString m_strErrorMessage;
103 /** Holds cached icon margin. */
104 int m_iIconMargin;
105};
106
107#endif /* !FEQT_INCLUDED_SRC_extensions_QILineEdit_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle
ContactPrivacy/Do Not Sell My InfoTerms of Use