summaryrefslogtreecommitdiff
path: root/src/VBox/Frontends/VirtualBox/src/cloud/consolemanager/UICloudConsoleDetailsWidget.h
blob: 65ba362a8d4dde24bfdcb4cf5d208a98ea2a0879 (plain)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/* $Id$ */
/** @file
 * VBox Qt GUI - UICloudConsoleDetailsWidget class declaration.
 */

/*
 * Copyright (C) 2009-2022 Oracle Corporation
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * General Public License (GPL) as published by the Free Software
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 */

#ifndef FEQT_INCLUDED_SRC_cloud_consolemanager_UICloudConsoleDetailsWidget_h
#define FEQT_INCLUDED_SRC_cloud_consolemanager_UICloudConsoleDetailsWidget_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif

/* Qt includes: */
#include <QMap>
#include <QWidget>

/* GUI includes: */
#include "QIManagerDialog.h"
#include "QIWithRetranslateUI.h"

/* Forward declarations: */
class QAbstractButton;
class QLabel;
class QLineEdit;
class QStackedLayout;
class QIDialogButtonBox;


/** Cloud Console Application data structure. */
struct UIDataCloudConsoleApplication
{
    /** Constructs data. */
    UIDataCloudConsoleApplication()
        : m_fRestricted(false)
    {}

    /** Returns whether the @a other passed data is equal to this one. */
    bool equal(const UIDataCloudConsoleApplication &other) const
    {
        return true
               && (m_strId == other.m_strId)
               && (m_strName == other.m_strName)
               && (m_strPath == other.m_strPath)
               && (m_strArgument == other.m_strArgument)
               && (m_fRestricted == other.m_fRestricted)
               ;
    }

    /** Returns whether the @a other passed data is equal to this one. */
    bool operator==(const UIDataCloudConsoleApplication &other) const { return equal(other); }
    /** Returns whether the @a other passed data is different from this one. */
    bool operator!=(const UIDataCloudConsoleApplication &other) const { return !equal(other); }

    /** Holds the console application ID. */
    QString  m_strId;
    /** Holds the console application name. */
    QString  m_strName;
    /** Holds the console application path. */
    QString  m_strPath;
    /** Holds the console application argument. */
    QString  m_strArgument;
    /** Holds whether console application is restricted. */
    bool     m_fRestricted;
};

/** Cloud Console Profile data structure. */
struct UIDataCloudConsoleProfile
{
    /** Constructs data. */
    UIDataCloudConsoleProfile()
        : m_fRestricted(false)
    {}

    /** Returns whether the @a other passed data is equal to this one. */
    bool equal(const UIDataCloudConsoleProfile &other) const
    {
        return true
               && (m_strApplicationId == other.m_strApplicationId)
               && (m_strId == other.m_strId)
               && (m_strName == other.m_strName)
               && (m_strArgument == other.m_strArgument)
               && (m_fRestricted == other.m_fRestricted)
               ;
    }

    /** Returns whether the @a other passed data is equal to this one. */
    bool operator==(const UIDataCloudConsoleProfile &other) const { return equal(other); }
    /** Returns whether the @a other passed data is different from this one. */
    bool operator!=(const UIDataCloudConsoleProfile &other) const { return !equal(other); }

    /** Holds the console profile application ID. */
    QString  m_strApplicationId;
    /** Holds the console profile ID. */
    QString  m_strId;
    /** Holds the console profile name. */
    QString  m_strName;
    /** Holds the console profile argument. */
    QString  m_strArgument;
    /** Holds whether console profile is restricted. */
    bool     m_fRestricted;
};


/** Cloud Console details widget. */
class UICloudConsoleDetailsWidget : public QIWithRetranslateUI<QWidget>
{
    Q_OBJECT;

signals:

    /** Notifies listeners about data changed and whether it @a fDiffers. */
    void sigDataChanged(bool fDiffers);

    /** Notifies listeners about data change rejected and should be reseted. */
    void sigDataChangeRejected();
    /** Notifies listeners about data change accepted and should be applied. */
    void sigDataChangeAccepted();

public:

    /** Constructs cloud console details widget passing @a pParent to the base-class.
      * @param  enmEmbedding  Brings embedding type. */
    UICloudConsoleDetailsWidget(EmbedTo enmEmbedding, QWidget *pParent = 0);

    /** Returns the cloud console application data. */
    const UIDataCloudConsoleApplication &applicationData() const { return m_newApplicationData; }
    /** Returns the cloud console profile data. */
    const UIDataCloudConsoleProfile &profileData() const { return m_newProfileData; }
    /** Defines the cloud console application @a data. */
    void setApplicationData(const UIDataCloudConsoleApplication &data);
    /** Defines the cloud console profile @a data. */
    void setProfileData(const UIDataCloudConsoleProfile &data);
    /** Clears all the console data. */
    void clearData();

protected:

    /** Handles translation event. */
    virtual void retranslateUi() RT_OVERRIDE;

private slots:

    /** @name Change handling stuff.
      * @{ */
        /** Handles console application name change. */
        void sltApplicationNameChanged(const QString &strName);
        /** Handles console application path change. */
        void sltApplicationPathChanged(const QString &strPath);
        /** Handles console application argument change. */
        void sltApplicationArgumentChanged(const QString &strArgument);
        /** Handles console profile name change. */
        void sltProfileNameChanged(const QString &strName);
        /** Handles console profile argument change. */
        void sltProfileArgumentChanged(const QString &strArgument);

        /** Handles button-box button click. */
        void sltHandleButtonBoxClick(QAbstractButton *pButton);
    /** @} */

private:

    /** @name Prepare/cleanup cascade.
      * @{ */
        /** Prepares all. */
        void prepare();
        /** Prepares widgets. */
        void prepareWidgets();
    /** @} */

    /** @name Loading stuff.
      * @{ */
        /** Loads data. */
        void loadData();
    /** @} */

    /** @name Change handling stuff.
      * @{ */
        /** Revalidates changes for passed @a pWidget. */
        void revalidate(QWidget *pWidget = 0);

        /** Retranslates validation for passed @a pWidget. */
        void retranslateValidation(QWidget *pWidget = 0);

        /** Updates button states. */
        void updateButtonStates();
    /** @} */

    /** @name General variables.
      * @{ */
        /** Holds the parent widget embedding type. */
        const EmbedTo  m_enmEmbedding;

        /** Holds the old console application data copy. */
        UIDataCloudConsoleApplication  m_oldApplicationData;
        /** Holds the new console application data copy. */
        UIDataCloudConsoleApplication  m_newApplicationData;

        /** Holds the old console profile data copy. */
        UIDataCloudConsoleProfile  m_oldProfileData;
        /** Holds the new console profile data copy. */
        UIDataCloudConsoleProfile  m_newProfileData;
    /** @} */

    /** @name Widget variables.
      * @{ */
        /** Holds the stacked layout isntance. */
        QStackedLayout *m_pStackedLayout;

        /** Holds the application name label instance. */
        QLabel    *m_pLabelApplicationName;
        /** Holds the application name editor instance. */
        QLineEdit *m_pEditorApplicationName;
        /** Holds the application path label instance. */
        QLabel    *m_pLabelApplicationPath;
        /** Holds the application path editor instance. */
        QLineEdit *m_pEditorApplicationPath;
        /** Holds the application argument label instance. */
        QLabel    *m_pLabelApplicationArgument;
        /** Holds the application argument editor instance. */
        QLineEdit *m_pEditorApplicationArgument;

        /** Holds the profile name label instance. */
        QLabel    *m_pLabelProfileName;
        /** Holds the profile name editor instance. */
        QLineEdit *m_pEditorProfileName;
        /** Holds the profile argument label instance. */
        QLabel    *m_pLabelProfileArgument;
        /** Holds the profile argument editor instance. */
        QLineEdit *m_pEditorProfileArgument;

        /** Holds the button-box instance. */
        QIDialogButtonBox *m_pButtonBox;
    /** @} */
};


#endif /* !FEQT_INCLUDED_SRC_cloud_consolemanager_UICloudConsoleDetailsWidget_h */