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