• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

krdc

  • sources
  • kde-4.12
  • kdenetwork
  • krdc
  • rdp
rdphostpreferences.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2007 - 2012 Urs Wolfer <uwolfer @ kde.org>
4 ** Copyright (C) 2012 AceLan Kao <acelan @ acelan.idv.tw>
5 **
6 ** This file is part of KDE.
7 **
8 ** This program is free software; you can redistribute it and/or modify
9 ** it under the terms of the GNU General Public License as published by
10 ** the Free Software Foundation; either version 2 of the License, or
11 ** (at your option) any later version.
12 **
13 ** This program is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ** GNU General Public License for more details.
17 **
18 ** You should have received a copy of the GNU General Public License
19 ** along with this program; see the file COPYING. If not, write to
20 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 ** Boston, MA 02110-1301, USA.
22 **
23 ****************************************************************************/
24 
25 #include "rdphostpreferences.h"
26 
27 #include "settings.h"
28 
29 #include <KDebug>
30 
31 #include <QDesktopWidget>
32 
33 static const QStringList keymaps = (QStringList()
34  << "ar"
35  << "cs"
36  << "da"
37  << "de"
38  << "de-ch"
39  << "en-dv"
40  << "en-gb"
41  << "en-us"
42  << "es"
43  << "et"
44  << "fi"
45  << "fo"
46  << "fr"
47  << "fr-be"
48  << "fr-ca"
49  << "fr-ch"
50  << "he"
51  << "hr"
52  << "hu"
53  << "is"
54  << "it"
55  << "ja"
56  << "ko"
57  << "lt"
58  << "lv"
59  << "mk"
60  << "nl"
61  << "nl-be"
62  << "no"
63  << "pl"
64  << "pt"
65  << "pt-br"
66  << "ru"
67  << "sl"
68  << "sv"
69  << "th"
70  << "tr"
71 );
72 
73 static const int defaultKeymap = 7; // en-us
74 
75 inline int keymap2int(const QString &keymap)
76 {
77  const int index = keymaps.lastIndexOf(keymap);
78  return (index == -1) ? defaultKeymap : index;
79 }
80 
81 inline QString int2keymap(int layout)
82 {
83  if (layout >= 0 && layout < keymaps.count())
84  return keymaps.at(layout);
85  else
86  return keymaps.at(defaultKeymap);
87 }
88 
89 RdpHostPreferences::RdpHostPreferences(KConfigGroup configGroup, QObject *parent)
90  : HostPreferences(configGroup, parent)
91 {
92 }
93 
94 RdpHostPreferences::~RdpHostPreferences()
95 {
96 }
97 
98 QWidget* RdpHostPreferences::createProtocolSpecificConfigPage()
99 {
100  QWidget *rdpPage = new QWidget();
101  rdpUi.setupUi(rdpPage);
102 
103  rdpUi.loginGroupBox->setVisible(false);
104 
105  rdpUi.kcfg_Height->setValue(height());
106  rdpUi.kcfg_Width->setValue(width());
107  rdpUi.kcfg_ColorDepth->setCurrentIndex(colorDepth());
108  rdpUi.kcfg_KeyboardLayout->setCurrentIndex(keymap2int(keyboardLayout()));
109  rdpUi.kcfg_Sound->setCurrentIndex(sound());
110  rdpUi.kcfg_Console->setChecked(console());
111  rdpUi.kcfg_ExtraOptions->setText(extraOptions());
112  rdpUi.kcfg_RemoteFX->setChecked(remoteFX());
113  rdpUi.kcfg_Performance->setCurrentIndex(performance());
114  rdpUi.kcfg_ShareMedia->setText(shareMedia());
115 
116  connect(rdpUi.resolutionComboBox, SIGNAL(currentIndexChanged(int)), SLOT(updateWidthHeight(int)));
117 
118  const QString resolutionString = QString::number(width()) + 'x' + QString::number(height());
119  const int resolutionIndex = rdpUi.resolutionComboBox->findText(resolutionString, Qt::MatchContains);
120  rdpUi.resolutionComboBox->setCurrentIndex((resolutionIndex == -1) ? rdpUi.resolutionComboBox->count() - 2 : resolutionIndex); // - 2 is index of custom resolution
121 
122  return rdpPage;
123 }
124 
125 void RdpHostPreferences::updateWidthHeight(int index)
126 {
127  switch (index) {
128  case 0:
129  rdpUi.kcfg_Height->setValue(480);
130  rdpUi.kcfg_Width->setValue(640);
131  break;
132  case 1:
133  rdpUi.kcfg_Height->setValue(600);
134  rdpUi.kcfg_Width->setValue(800);
135  break;
136  case 2:
137  rdpUi.kcfg_Height->setValue(768);
138  rdpUi.kcfg_Width->setValue(1024);
139  break;
140  case 3:
141  rdpUi.kcfg_Height->setValue(1024);
142  rdpUi.kcfg_Width->setValue(1280);
143  break;
144  case 4:
145  rdpUi.kcfg_Height->setValue(1200);
146  rdpUi.kcfg_Width->setValue(1600);
147  break;
148  case 5: {
149  QDesktopWidget *desktop = QApplication::desktop();
150  int currentScreen = desktop->screenNumber(rdpUi.kcfg_Height);
151  rdpUi.kcfg_Height->setValue(desktop->screenGeometry(currentScreen).height());
152  rdpUi.kcfg_Width->setValue(desktop->screenGeometry(currentScreen).width());
153  break;
154  }
155  case 7:
156  rdpUi.kcfg_Height->setValue(0);
157  rdpUi.kcfg_Width->setValue(0);
158  break;
159  case 6:
160  default:
161  break;
162  }
163 
164  const bool enabled = (index == 6) ? true : false;
165 
166  rdpUi.kcfg_Height->setEnabled(enabled);
167  rdpUi.kcfg_Width->setEnabled(enabled);
168  rdpUi.heightLabel->setEnabled(enabled);
169  rdpUi.widthLabel->setEnabled(enabled);
170 }
171 
172 void RdpHostPreferences::acceptConfig()
173 {
174  HostPreferences::acceptConfig();
175 
176  setHeight(rdpUi.kcfg_Height->value());
177  setWidth(rdpUi.kcfg_Width->value());
178  setColorDepth(rdpUi.kcfg_ColorDepth->currentIndex());
179  setKeyboardLayout(int2keymap(rdpUi.kcfg_KeyboardLayout->currentIndex()));
180  setSound(rdpUi.kcfg_Sound->currentIndex());
181  setConsole(rdpUi.kcfg_Console->isChecked());
182  setExtraOptions(rdpUi.kcfg_ExtraOptions->text());
183  setRemoteFX(rdpUi.kcfg_RemoteFX->isChecked());
184  setPerformance(rdpUi.kcfg_Performance->currentIndex());
185  setShareMedia(rdpUi.kcfg_ShareMedia->text());
186 }
187 
188 void RdpHostPreferences::setColorDepth(int colorDepth)
189 {
190  if (colorDepth >= 0)
191  m_configGroup.writeEntry("colorDepth", colorDepth);
192 }
193 
194 int RdpHostPreferences::colorDepth() const
195 {
196  return m_configGroup.readEntry("colorDepth", Settings::colorDepth());
197 }
198 
199 void RdpHostPreferences::setKeyboardLayout(const QString &keyboardLayout)
200 {
201  if (!keyboardLayout.isNull())
202  m_configGroup.writeEntry("keyboardLayout", keymap2int(keyboardLayout));
203 }
204 
205 QString RdpHostPreferences::keyboardLayout() const
206 {
207  return int2keymap(m_configGroup.readEntry("keyboardLayout", Settings::keyboardLayout()));
208 }
209 
210 void RdpHostPreferences::setSound(int sound)
211 {
212  if (sound >= 0)
213  m_configGroup.writeEntry("sound", sound);
214 }
215 
216 int RdpHostPreferences::sound() const
217 {
218  return m_configGroup.readEntry("sound", Settings::sound());
219 }
220 
221 void RdpHostPreferences::setConsole(bool console)
222 {
223  m_configGroup.writeEntry("console", console);
224 }
225 
226 bool RdpHostPreferences::console() const
227 {
228  return m_configGroup.readEntry("console", Settings::console());
229 }
230 
231 void RdpHostPreferences::setExtraOptions(const QString &extraOptions)
232 {
233  if (!extraOptions.isNull())
234  m_configGroup.writeEntry("extraOptions", extraOptions);
235 }
236 
237 QString RdpHostPreferences::extraOptions() const
238 {
239  return m_configGroup.readEntry("extraOptions", Settings::extraOptions());
240 }
241 
242 void RdpHostPreferences::setRemoteFX(bool remoteFX)
243 {
244  m_configGroup.writeEntry("remoteFX", remoteFX);
245 }
246 
247 bool RdpHostPreferences::remoteFX() const
248 {
249  return m_configGroup.readEntry("remoteFX", Settings::remoteFX());
250 }
251 
252 void RdpHostPreferences::setPerformance(int performance)
253 {
254  if (performance >= 0)
255  m_configGroup.writeEntry("performance", performance);
256 }
257 
258 int RdpHostPreferences::performance() const
259 {
260  return m_configGroup.readEntry("performance", Settings::performance());
261 }
262 
263 void RdpHostPreferences::setShareMedia(const QString &shareMedia)
264 {
265  if (!shareMedia.isNull())
266  m_configGroup.writeEntry("shareMedia", shareMedia);
267 }
268 
269 QString RdpHostPreferences::shareMedia() const
270 {
271  return m_configGroup.readEntry("shareMedia", Settings::shareMedia());
272 }
273 
274 #include "rdphostpreferences.moc"
HostPreferences::m_configGroup
KConfigGroup m_configGroup
Definition: hostpreferences.h:101
Settings::console
static bool console()
Get Console.
Definition: settings.h:543
RdpHostPreferences::setColorDepth
void setColorDepth(int colorDepth)
Definition: rdphostpreferences.cpp:188
RdpHostPreferences::colorDepth
int colorDepth() const
Definition: rdphostpreferences.cpp:194
RdpHostPreferences::setKeyboardLayout
void setKeyboardLayout(const QString &keyboardLayout)
Definition: rdphostpreferences.cpp:199
RdpHostPreferences::setPerformance
void setPerformance(int performance)
Definition: rdphostpreferences.cpp:252
Settings::extraOptions
static QString extraOptions()
Get ExtraOptions.
Definition: settings.h:562
RdpHostPreferences::keyboardLayout
QString keyboardLayout() const
Definition: rdphostpreferences.cpp:205
QWidget
RdpHostPreferences::setSound
void setSound(int sound)
Definition: rdphostpreferences.cpp:210
keymaps
static const QStringList keymaps
Definition: rdphostpreferences.cpp:33
QObject
RdpHostPreferences::~RdpHostPreferences
~RdpHostPreferences()
Definition: rdphostpreferences.cpp:94
RdpHostPreferences::RdpHostPreferences
RdpHostPreferences(KConfigGroup configGroup, QObject *parent=0)
Definition: rdphostpreferences.cpp:89
Settings::performance
static int performance()
Get Performance.
Definition: settings.h:638
RdpHostPreferences::console
bool console() const
Definition: rdphostpreferences.cpp:226
Settings::shareMedia
static QString shareMedia()
Get ShareMedia.
Definition: settings.h:657
RdpHostPreferences::setShareMedia
void setShareMedia(const QString &shareMedia)
Definition: rdphostpreferences.cpp:263
keymap2int
int keymap2int(const QString &keymap)
Definition: rdphostpreferences.cpp:75
Settings::sound
static int sound()
Get Sound.
Definition: settings.h:524
HostPreferences::setWidth
void setWidth(int width)
Definition: hostpreferences.cpp:98
HostPreferences::height
int height()
Saved height.
Definition: hostpreferences.cpp:93
Settings::colorDepth
static int colorDepth()
Get ColorDepth.
Definition: settings.h:505
Settings::remoteFX
static bool remoteFX()
Get RemoteFX.
Definition: settings.h:619
RdpHostPreferences::setExtraOptions
void setExtraOptions(const QString &extraOptions)
Definition: rdphostpreferences.cpp:231
Settings::keyboardLayout
static int keyboardLayout()
Get KeyboardLayout.
Definition: settings.h:486
rdphostpreferences.h
RdpHostPreferences::createProtocolSpecificConfigPage
QWidget * createProtocolSpecificConfigPage()
Definition: rdphostpreferences.cpp:98
HostPreferences
Definition: hostpreferences.h:42
settings.h
HostPreferences::acceptConfig
virtual void acceptConfig()
Called when the user validates the config dialog.
Definition: hostpreferences.cpp:56
RdpHostPreferences::shareMedia
QString shareMedia() const
Definition: rdphostpreferences.cpp:269
HostPreferences::width
int width()
Saved width.
Definition: hostpreferences.cpp:104
RdpHostPreferences::setConsole
void setConsole(bool console)
Definition: rdphostpreferences.cpp:221
RdpHostPreferences::performance
int performance() const
Definition: rdphostpreferences.cpp:258
int2keymap
QString int2keymap(int layout)
Definition: rdphostpreferences.cpp:81
RdpHostPreferences::extraOptions
QString extraOptions() const
Definition: rdphostpreferences.cpp:237
HostPreferences::setHeight
void setHeight(int height)
Definition: hostpreferences.cpp:87
RdpHostPreferences::setRemoteFX
void setRemoteFX(bool remoteFX)
Definition: rdphostpreferences.cpp:242
RdpHostPreferences::remoteFX
bool remoteFX() const
Definition: rdphostpreferences.cpp:247
RdpHostPreferences::sound
int sound() const
Definition: rdphostpreferences.cpp:216
defaultKeymap
static const int defaultKeymap
Definition: rdphostpreferences.cpp:73
RdpHostPreferences::acceptConfig
void acceptConfig()
Called when the user validates the config dialog.
Definition: rdphostpreferences.cpp:172
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:54:04 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

krdc

Skip menu "krdc"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal