1 | /* $Id: UIGlobalSettingsGeneral.cpp 53449 2014-12-05 09:48:21Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIGlobalSettingsGeneral class implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2013 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifdef VBOX_WITH_PRECOMPILED_HEADERS
|
---|
19 | # include <precomp.h>
|
---|
20 | #else /* !VBOX_WITH_PRECOMPILED_HEADERS */
|
---|
21 |
|
---|
22 | /* Qt includes: */
|
---|
23 | # include <QDir>
|
---|
24 |
|
---|
25 | /* GUI includes: */
|
---|
26 | # include "UIGlobalSettingsGeneral.h"
|
---|
27 | # include "VBoxGlobal.h"
|
---|
28 |
|
---|
29 | #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
|
---|
30 |
|
---|
31 |
|
---|
32 | UIGlobalSettingsGeneral::UIGlobalSettingsGeneral()
|
---|
33 | {
|
---|
34 | /* Apply UI decorations: */
|
---|
35 | Ui::UIGlobalSettingsGeneral::setupUi(this);
|
---|
36 |
|
---|
37 | #ifndef Q_WS_MAC
|
---|
38 | m_pLabelPresentationMode->hide();
|
---|
39 | m_pCheckBoxPresentationMode->hide();
|
---|
40 | #endif /* !Q_WS_MAC */
|
---|
41 | /* Hide checkbox for now: */
|
---|
42 | m_pLabelHostScreenSaver->hide();
|
---|
43 | m_pCheckBoxHostScreenSaver->hide();
|
---|
44 |
|
---|
45 | /* Setup widgets: */
|
---|
46 | m_pSelectorMachineFolder->setHomeDir(vboxGlobal().homeFolder());
|
---|
47 | m_pSelectorVRDPLibName->setHomeDir(vboxGlobal().homeFolder());
|
---|
48 | m_pSelectorVRDPLibName->setMode(VBoxFilePathSelectorWidget::Mode_File_Open);
|
---|
49 |
|
---|
50 | /* Apply language settings: */
|
---|
51 | retranslateUi();
|
---|
52 | }
|
---|
53 |
|
---|
54 | /* Load data to cache from corresponding external object(s),
|
---|
55 | * this task COULD be performed in other than GUI thread: */
|
---|
56 | void UIGlobalSettingsGeneral::loadToCacheFrom(QVariant &data)
|
---|
57 | {
|
---|
58 | /* Fetch data to properties & settings: */
|
---|
59 | UISettingsPageGlobal::fetchData(data);
|
---|
60 |
|
---|
61 | /* Load to cache: */
|
---|
62 | m_cache.m_strDefaultMachineFolder = m_properties.GetDefaultMachineFolder();
|
---|
63 | m_cache.m_strVRDEAuthLibrary = m_properties.GetVRDEAuthLibrary();
|
---|
64 | #ifdef Q_WS_MAC
|
---|
65 | m_cache.m_fPresentationModeEnabled = m_settings.presentationModeEnabled();
|
---|
66 | #endif /* Q_WS_MAC */
|
---|
67 | m_cache.m_fHostScreenSaverDisabled = m_settings.hostScreenSaverDisabled();
|
---|
68 |
|
---|
69 | /* Upload properties & settings to data: */
|
---|
70 | UISettingsPageGlobal::uploadData(data);
|
---|
71 | }
|
---|
72 |
|
---|
73 | /* Load data to corresponding widgets from cache,
|
---|
74 | * this task SHOULD be performed in GUI thread only: */
|
---|
75 | void UIGlobalSettingsGeneral::getFromCache()
|
---|
76 | {
|
---|
77 | /* Fetch from cache: */
|
---|
78 | m_pSelectorMachineFolder->setPath(m_cache.m_strDefaultMachineFolder);
|
---|
79 | m_pSelectorVRDPLibName->setPath(m_cache.m_strVRDEAuthLibrary);
|
---|
80 | #ifdef Q_WS_MAC
|
---|
81 | m_pCheckBoxPresentationMode->setChecked(m_cache.m_fPresentationModeEnabled);
|
---|
82 | #endif /* Q_WS_MAC */
|
---|
83 | m_pCheckBoxHostScreenSaver->setChecked(m_cache.m_fHostScreenSaverDisabled);
|
---|
84 | }
|
---|
85 |
|
---|
86 | /* Save data from corresponding widgets to cache,
|
---|
87 | * this task SHOULD be performed in GUI thread only: */
|
---|
88 | void UIGlobalSettingsGeneral::putToCache()
|
---|
89 | {
|
---|
90 | /* Upload to cache: */
|
---|
91 | m_cache.m_strDefaultMachineFolder = m_pSelectorMachineFolder->path();
|
---|
92 | m_cache.m_strVRDEAuthLibrary = m_pSelectorVRDPLibName->path();
|
---|
93 | #ifdef Q_WS_MAC
|
---|
94 | m_cache.m_fPresentationModeEnabled = m_pCheckBoxPresentationMode->isChecked();
|
---|
95 | #endif /* Q_WS_MAC */
|
---|
96 | m_cache.m_fHostScreenSaverDisabled = m_pCheckBoxHostScreenSaver->isChecked();
|
---|
97 | }
|
---|
98 |
|
---|
99 | /* Save data from cache to corresponding external object(s),
|
---|
100 | * this task COULD be performed in other than GUI thread: */
|
---|
101 | void UIGlobalSettingsGeneral::saveFromCacheTo(QVariant &data)
|
---|
102 | {
|
---|
103 | /* Fetch data to properties & settings: */
|
---|
104 | UISettingsPageGlobal::fetchData(data);
|
---|
105 |
|
---|
106 | /* Save from cache: */
|
---|
107 | if (m_properties.isOk() && m_pSelectorMachineFolder->isModified())
|
---|
108 | m_properties.SetDefaultMachineFolder(m_cache.m_strDefaultMachineFolder);
|
---|
109 | if (m_properties.isOk() && m_pSelectorVRDPLibName->isModified())
|
---|
110 | m_properties.SetVRDEAuthLibrary(m_cache.m_strVRDEAuthLibrary);
|
---|
111 | #ifdef Q_WS_MAC
|
---|
112 | m_settings.setPresentationModeEnabled(m_cache.m_fPresentationModeEnabled);
|
---|
113 | #endif /* Q_WS_MAC */
|
---|
114 | m_settings.setHostScreenSaverDisabled(m_cache.m_fHostScreenSaverDisabled);
|
---|
115 |
|
---|
116 | /* Upload properties & settings to data: */
|
---|
117 | UISettingsPageGlobal::uploadData(data);
|
---|
118 | }
|
---|
119 |
|
---|
120 | void UIGlobalSettingsGeneral::setOrderAfter(QWidget *pWidget)
|
---|
121 | {
|
---|
122 | /* Configure navigation: */
|
---|
123 | setTabOrder(pWidget, m_pSelectorMachineFolder);
|
---|
124 | setTabOrder(m_pSelectorMachineFolder, m_pSelectorVRDPLibName);
|
---|
125 | setTabOrder(m_pSelectorVRDPLibName, m_pCheckBoxPresentationMode);
|
---|
126 | setTabOrder(m_pCheckBoxPresentationMode, m_pCheckBoxHostScreenSaver);
|
---|
127 | }
|
---|
128 |
|
---|
129 | void UIGlobalSettingsGeneral::retranslateUi()
|
---|
130 | {
|
---|
131 | /* Translate uic generated strings: */
|
---|
132 | Ui::UIGlobalSettingsGeneral::retranslateUi(this);
|
---|
133 | }
|
---|
134 |
|
---|