• 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
  • vnc
vnchostpreferences.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2007 Urs Wolfer <uwolfer @ kde.org>
4 **
5 ** This file is part of KDE.
6 **
7 ** This program is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License as published by
9 ** the Free Software Foundation; either version 2 of the License, or
10 ** (at your option) any later version.
11 **
12 ** This program is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ** GNU General Public License for more details.
16 **
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program; see the file COPYING. If not, write to
19 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 ** Boston, MA 02110-1301, USA.
21 **
22 ****************************************************************************/
23 
24 #include "vnchostpreferences.h"
25 
26 #include "settings.h"
27 
28 #include <KDebug>
29 
30 #include <QDesktopWidget>
31 
32 VncHostPreferences::VncHostPreferences(KConfigGroup configGroup, QObject *parent)
33  : HostPreferences(configGroup, parent)
34 {
35 }
36 
37 VncHostPreferences::~VncHostPreferences()
38 {
39 }
40 
41 QWidget* VncHostPreferences::createProtocolSpecificConfigPage()
42 {
43  QWidget *vncPage = new QWidget();
44  vncUi.setupUi(vncPage);
45 
46  vncUi.kcfg_Quality->setCurrentIndex(quality() - 1);
47  vncUi.kcfg_Scaling->setChecked(windowedScale());
48  vncUi.kcfg_ScalingWidth->setValue(width());
49  vncUi.kcfg_ScalingHeight->setValue(height());
50 
51  connect(vncUi.resolutionComboBox, SIGNAL(currentIndexChanged(int)), SLOT(updateScalingWidthHeight(int)));
52  connect(vncUi.kcfg_Scaling, SIGNAL(toggled(bool)), SLOT(updateScaling(bool)));
53 
54  const QString resolutionString = QString::number(width()) + 'x' + QString::number(height());
55  const int resolutionIndex = vncUi.resolutionComboBox->findText(resolutionString, Qt::MatchContains);
56  vncUi.resolutionComboBox->setCurrentIndex((resolutionIndex == -1) ? vncUi.resolutionComboBox->count() - 1 : resolutionIndex);
57 
58  updateScaling(windowedScale());
59 
60  return vncPage;
61 }
62 
63 void VncHostPreferences::updateScalingWidthHeight(int index)
64 {
65  switch (index) {
66  case 0:
67  vncUi.kcfg_ScalingHeight->setValue(480);
68  vncUi.kcfg_ScalingWidth->setValue(640);
69  break;
70  case 1:
71  vncUi.kcfg_ScalingHeight->setValue(600);
72  vncUi.kcfg_ScalingWidth->setValue(800);
73  break;
74  case 2:
75  vncUi.kcfg_ScalingHeight->setValue(768);
76  vncUi.kcfg_ScalingWidth->setValue(1024);
77  break;
78  case 3:
79  vncUi.kcfg_ScalingHeight->setValue(1024);
80  vncUi.kcfg_ScalingWidth->setValue(1280);
81  break;
82  case 4:
83  vncUi.kcfg_ScalingHeight->setValue(1200);
84  vncUi.kcfg_ScalingWidth->setValue(1600);
85  break;
86  case 5: {
87  QDesktopWidget *desktop = QApplication::desktop();
88  int currentScreen = desktop->screenNumber(vncUi.kcfg_ScalingHeight);
89  vncUi.kcfg_ScalingHeight->setValue(desktop->screenGeometry(currentScreen).height());
90  vncUi.kcfg_ScalingWidth->setValue(desktop->screenGeometry(currentScreen).width());
91  break;
92  }
93  case 6:
94  default:
95  break;
96  }
97 
98  checkEnableCustomSize(index);
99 }
100 
101 void VncHostPreferences::updateScaling(bool enabled)
102 {
103  vncUi.resolutionComboBox->setEnabled(enabled);
104  if(enabled) {
105  checkEnableCustomSize(vncUi.resolutionComboBox->currentIndex());
106  } else {
107  checkEnableCustomSize(-1);
108  }
109 }
110 
111 void VncHostPreferences::checkEnableCustomSize(int index)
112 {
113  const bool enabled = (index == 6);
114 
115  vncUi.kcfg_ScalingHeight->setEnabled(enabled);
116  vncUi.kcfg_ScalingWidth->setEnabled(enabled);
117  vncUi.heightLabel->setEnabled(enabled);
118  vncUi.widthLabel->setEnabled(enabled);
119 }
120 
121 void VncHostPreferences::acceptConfig()
122 {
123  HostPreferences::acceptConfig();
124  setQuality((RemoteView::Quality)(vncUi.kcfg_Quality->currentIndex() + 1));
125  setWindowedScale(vncUi.kcfg_Scaling->isChecked());
126  if(vncUi.kcfg_Scaling->isChecked()) {
127  setHeight(vncUi.kcfg_ScalingHeight->value());
128  setWidth(vncUi.kcfg_ScalingWidth->value());
129  }
130 }
131 
132 void VncHostPreferences::setQuality(RemoteView::Quality quality)
133 {
134  if (quality >= 0 && quality <= 3)
135  m_configGroup.writeEntry("quality", (int) quality);
136 }
137 
138 RemoteView::Quality VncHostPreferences::quality()
139 {
140  return (RemoteView::Quality) m_configGroup.readEntry("quality", (int) Settings::quality() + 1);
141 }
142 
143 #include "vnchostpreferences.moc"
HostPreferences::m_configGroup
KConfigGroup m_configGroup
Definition: hostpreferences.h:101
VncHostPreferences::createProtocolSpecificConfigPage
virtual QWidget * createProtocolSpecificConfigPage()
Definition: vnchostpreferences.cpp:41
vnchostpreferences.h
HostPreferences::windowedScale
bool windowedScale()
Whether scaling is enabled when session is not full screen.
Definition: hostpreferences.cpp:119
RemoteView::Quality
Quality
Definition: remoteview.h:67
HostPreferences::setWindowedScale
void setWindowedScale(bool scale)
Definition: hostpreferences.cpp:124
VncHostPreferences::VncHostPreferences
VncHostPreferences(KConfigGroup configGroup, QObject *parent=0)
Definition: vnchostpreferences.cpp:32
VncHostPreferences::setQuality
void setQuality(RemoteView::Quality quality)
Definition: vnchostpreferences.cpp:132
QWidget
QObject
Settings::quality
static int quality()
Get Quality.
Definition: settings.h:372
HostPreferences::setWidth
void setWidth(int width)
Definition: hostpreferences.cpp:98
HostPreferences::height
int height()
Saved height.
Definition: hostpreferences.cpp:93
HostPreferences
Definition: hostpreferences.h:42
settings.h
HostPreferences::acceptConfig
virtual void acceptConfig()
Called when the user validates the config dialog.
Definition: hostpreferences.cpp:56
VncHostPreferences::quality
RemoteView::Quality quality()
Definition: vnchostpreferences.cpp:138
VncHostPreferences::acceptConfig
void acceptConfig()
Called when the user validates the config dialog.
Definition: vnchostpreferences.cpp:121
VncHostPreferences::~VncHostPreferences
~VncHostPreferences()
Definition: vnchostpreferences.cpp:37
HostPreferences::width
int width()
Saved width.
Definition: hostpreferences.cpp:104
HostPreferences::setHeight
void setHeight(int height)
Definition: hostpreferences.cpp:87
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