~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsGeneral.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-01-30 23:27:25 UTC
  • mfrom: (0.3.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20110130232725-2ouajjd2ggdet0zd
Tags: 4.0.2-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Drop ubuntu-01-fix-build-gcc45.patch, fixed upstream.
* Drop ubuntu-02-as-needed.patch, added to the Debian package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: UIGlobalSettingsGeneral.cpp 33926 2010-11-10 09:02:39Z vboxsync $ */
 
2
/** @file
 
3
 *
 
4
 * VBox frontends: Qt4 GUI ("VirtualBox"):
 
5
 * UIGlobalSettingsGeneral class implementation
 
6
 */
 
7
 
 
8
/*
 
9
 * Copyright (C) 2006-2010 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
/* Global includes */
 
21
#include <QDir>
 
22
 
 
23
/* Local includes */
 
24
#include "UIGlobalSettingsGeneral.h"
 
25
#include "VBoxGlobal.h"
 
26
 
 
27
/* General page constructor: */
 
28
UIGlobalSettingsGeneral::UIGlobalSettingsGeneral()
 
29
{
 
30
    /* Apply UI decorations: */
 
31
    Ui::UIGlobalSettingsGeneral::setupUi(this);
 
32
 
 
33
#ifndef VBOX_GUI_WITH_SYSTRAY
 
34
    m_pEnableTrayIconCheckbox->hide();
 
35
    m_pSpacerWidget1->hide();
 
36
#endif /* !VBOX_GUI_WITH_SYSTRAY */
 
37
#ifndef Q_WS_MAC
 
38
    m_pEnablePresentationModeCheckbox->hide();
 
39
    m_pSpacerWidget2->hide();
 
40
#endif /* !Q_WS_MAC */
 
41
//#ifndef Q_WS_WIN /* Checkbox hidden for now! */
 
42
    m_pDisableHostScreenSaverCheckbox->hide();
 
43
    m_pSpacerWidget3->hide();
 
44
//#endif /* !Q_WS_WIN */
 
45
 
 
46
    /* If all checkboxes hidden, hide separator too: */
 
47
    if (m_pEnableTrayIconCheckbox->isHidden() &&
 
48
        m_pEnablePresentationModeCheckbox->isHidden() &&
 
49
        m_pDisableHostScreenSaverCheckbox->isHidden())
 
50
        m_pLineSeparator2->hide();
 
51
 
 
52
    /* Setup widgets: */
 
53
    m_pMachineFolderSelector->setHomeDir(vboxGlobal().virtualBox().GetHomeFolder());
 
54
    m_pVRDPLibNameSelector->setHomeDir(vboxGlobal().virtualBox().GetHomeFolder());
 
55
    m_pVRDPLibNameSelector->setMode(VBoxFilePathSelectorWidget::Mode_File_Open);
 
56
 
 
57
    /* Apply language settings: */
 
58
    retranslateUi();
 
59
}
 
60
 
 
61
/* Load data to cashe from corresponding external object(s),
 
62
 * this task COULD be performed in other than GUI thread: */
 
63
void UIGlobalSettingsGeneral::loadToCacheFrom(QVariant &data)
 
64
{
 
65
    /* Fetch data to properties & settings: */
 
66
    UISettingsPageGlobal::fetchData(data);
 
67
 
 
68
    /* Load to cache: */
 
69
    m_cache.m_strDefaultMachineFolder = m_properties.GetDefaultMachineFolder();
 
70
    m_cache.m_strVRDEAuthLibrary = m_properties.GetVRDEAuthLibrary();
 
71
    m_cache.m_fTrayIconEnabled = m_settings.trayIconEnabled();
 
72
#ifdef Q_WS_MAC
 
73
    m_cache.m_fPresentationModeEnabled = m_settings.presentationModeEnabled();
 
74
#endif /* Q_WS_MAC */
 
75
    m_cache.m_fHostScreenSaverDisables = m_settings.hostScreenSaverDisabled();
 
76
 
 
77
    /* Upload properties & settings to data: */
 
78
    UISettingsPageGlobal::uploadData(data);
 
79
}
 
80
 
 
81
/* Load data to corresponding widgets from cache,
 
82
 * this task SHOULD be performed in GUI thread only: */
 
83
void UIGlobalSettingsGeneral::getFromCache()
 
84
{
 
85
    /* Fetch from cache: */
 
86
    m_pMachineFolderSelector->setPath(m_cache.m_strDefaultMachineFolder);
 
87
    m_pVRDPLibNameSelector->setPath(m_cache.m_strVRDEAuthLibrary);
 
88
    m_pEnableTrayIconCheckbox->setChecked(m_cache.m_fTrayIconEnabled);
 
89
#ifdef Q_WS_MAC
 
90
    m_pEnablePresentationModeCheckbox->setChecked(m_cache.m_fPresentationModeEnabled);
 
91
#endif /* Q_WS_MAC */
 
92
    m_pDisableHostScreenSaverCheckbox->setChecked(m_cache.m_fHostScreenSaverDisables);
 
93
}
 
94
 
 
95
/* Save data from corresponding widgets to cache,
 
96
 * this task SHOULD be performed in GUI thread only: */
 
97
void UIGlobalSettingsGeneral::putToCache()
 
98
{
 
99
    /* Upload to cache: */
 
100
    m_cache.m_strDefaultMachineFolder = m_pMachineFolderSelector->path();
 
101
    m_cache.m_strVRDEAuthLibrary = m_pVRDPLibNameSelector->path();
 
102
    m_cache.m_fTrayIconEnabled = m_pEnableTrayIconCheckbox->isChecked();
 
103
#ifdef Q_WS_MAC
 
104
    m_cache.m_fPresentationModeEnabled = m_pEnablePresentationModeCheckbox->isChecked();
 
105
#endif /* Q_WS_MAC */
 
106
    m_cache.m_fHostScreenSaverDisables = m_pDisableHostScreenSaverCheckbox->isChecked();
 
107
}
 
108
 
 
109
/* Save data from cache to corresponding external object(s),
 
110
 * this task COULD be performed in other than GUI thread: */
 
111
void UIGlobalSettingsGeneral::saveFromCacheTo(QVariant &data)
 
112
{
 
113
    /* Fetch data to properties & settings: */
 
114
    UISettingsPageGlobal::fetchData(data);
 
115
 
 
116
    /* Save from cache: */
 
117
    if (m_properties.isOk() && m_pMachineFolderSelector->isModified())
 
118
        m_properties.SetDefaultMachineFolder(m_cache.m_strDefaultMachineFolder);
 
119
    if (m_properties.isOk() && m_pVRDPLibNameSelector->isModified())
 
120
        m_properties.SetVRDEAuthLibrary(m_cache.m_strVRDEAuthLibrary);
 
121
    m_settings.setTrayIconEnabled(m_cache.m_fTrayIconEnabled);
 
122
#ifdef Q_WS_MAC
 
123
    m_settings.setPresentationModeEnabled(m_cache.m_fPresentationModeEnabled);
 
124
#endif /* Q_WS_MAC */
 
125
    m_settings.setHostScreenSaverDisabled(m_cache.m_fHostScreenSaverDisables);
 
126
 
 
127
    /* Upload properties & settings to data: */
 
128
    UISettingsPageGlobal::uploadData(data);
 
129
}
 
130
 
 
131
/* Navigation stuff: */
 
132
void UIGlobalSettingsGeneral::setOrderAfter(QWidget *pWidget)
 
133
{
 
134
    setTabOrder(pWidget, m_pMachineFolderSelector);
 
135
    setTabOrder(m_pMachineFolderSelector, m_pVRDPLibNameSelector);
 
136
    setTabOrder(m_pVRDPLibNameSelector, m_pEnableTrayIconCheckbox);
 
137
    setTabOrder(m_pEnableTrayIconCheckbox, m_pEnablePresentationModeCheckbox);
 
138
    setTabOrder(m_pEnablePresentationModeCheckbox, m_pDisableHostScreenSaverCheckbox);
 
139
}
 
140
 
 
141
/* Translation stuff: */
 
142
void UIGlobalSettingsGeneral::retranslateUi()
 
143
{
 
144
    /* Translate uic generated strings: */
 
145
    Ui::UIGlobalSettingsGeneral::retranslateUi(this);
 
146
 
 
147
    m_pMachineFolderSelector->setWhatsThis(tr("Displays the path to the default virtual "
 
148
                                              "machine folder. This folder is used, if not "
 
149
                                              "explicitly specified otherwise, when creating "
 
150
                                              "new virtual machines."));
 
151
    m_pVRDPLibNameSelector->setWhatsThis(tr("Displays the path to the library that "
 
152
                                            "provides authentication for Remote Display "
 
153
                                            "(VRDP) clients."));
 
154
}
 
155