1 | /* $Id: UIConverter.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIConverter declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012-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_converter_UIConverter_h
|
---|
29 | #define FEQT_INCLUDED_SRC_converter_UIConverter_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QColor>
|
---|
36 | #include <QIcon>
|
---|
37 | #include <QPixmap>
|
---|
38 | #include <QString>
|
---|
39 |
|
---|
40 | /* GUI includes: */
|
---|
41 | #include "UILibraryDefs.h"
|
---|
42 |
|
---|
43 | /** High-level interface for different conversions between GUI classes.
|
---|
44 | * @todo Replace singleton with static template interface. */
|
---|
45 | class SHARED_LIBRARY_STUFF UIConverter
|
---|
46 | {
|
---|
47 | public:
|
---|
48 |
|
---|
49 | /** Returns singleton instance. */
|
---|
50 | static UIConverter *instance() { return s_pInstance; }
|
---|
51 |
|
---|
52 | /** Creates singleton instance. */
|
---|
53 | static void create();
|
---|
54 | /** Destroys singleton instance. */
|
---|
55 | static void destroy();
|
---|
56 |
|
---|
57 | /** Converts QColor <= template class. */
|
---|
58 | template<class T> QColor toColor(const T &data) const;
|
---|
59 |
|
---|
60 | /** Converts QIcon <= template class. */
|
---|
61 | template<class T> QIcon toIcon(const T &data) const;
|
---|
62 |
|
---|
63 | /** Converts QPixmap <= template class. */
|
---|
64 | template<class T> QPixmap toWarningPixmap(const T &data) const;
|
---|
65 |
|
---|
66 | /** Converts QString <= template class. */
|
---|
67 | template<class T> QString toString(const T &data) const;
|
---|
68 | /** Converts template class <= QString. */
|
---|
69 | template<class T> T fromString(const QString &strData) const;
|
---|
70 |
|
---|
71 | /** Converts QString <= template class. */
|
---|
72 | template<class T> QString toInternalString(const T &data) const;
|
---|
73 | /** Converts template class <= QString. */
|
---|
74 | template<class T> T fromInternalString(const QString &strData) const;
|
---|
75 |
|
---|
76 | /** Converts int <= template class. */
|
---|
77 | template<class T> int toInternalInteger(const T &data) const;
|
---|
78 | /** Converts template class <= int. */
|
---|
79 | template<class T> T fromInternalInteger(const int &iData) const;
|
---|
80 |
|
---|
81 | private:
|
---|
82 |
|
---|
83 | /** Constructs converter. */
|
---|
84 | UIConverter() { s_pInstance = this; }
|
---|
85 | /** Destructs converter. */
|
---|
86 | virtual ~UIConverter() { s_pInstance = 0; }
|
---|
87 |
|
---|
88 | /** Holds the static instance. */
|
---|
89 | static UIConverter *s_pInstance;
|
---|
90 | };
|
---|
91 |
|
---|
92 | /** Singleton UI converter 'official' name. */
|
---|
93 | #define gpConverter UIConverter::instance()
|
---|
94 |
|
---|
95 | #endif /* !FEQT_INCLUDED_SRC_converter_UIConverter_h */
|
---|