Changeset View
Changeset View
Standalone View
Standalone View
vnc/vnchostpreferences.cpp
Show All 21 Lines | |||||
22 | ****************************************************************************/ | 22 | ****************************************************************************/ | ||
23 | 23 | | |||
24 | #include "vnchostpreferences.h" | 24 | #include "vnchostpreferences.h" | ||
25 | 25 | | |||
26 | #include "settings.h" | 26 | #include "settings.h" | ||
27 | 27 | | |||
28 | #include <QDesktopWidget> | 28 | #include <QDesktopWidget> | ||
29 | 29 | | |||
30 | static const char quality_config_key[] = "quality"; | ||||
dfaure: static const char quality_config_key[] =
so that it goes into the rodata section.
(I just… | |||||
31 | static const char use_ssh_tunnel_config_key[] = "use_ssh_tunnel"; | ||||
32 | static const char use_ssh_tunnel_loopback_config_key[] = "use_ssh_tunnel_loopback"; | ||||
33 | static const char ssh_tunnel_port_config_key[] = "ssh_tunnel_port"; | ||||
34 | static const char ssh_tunnel_user_name_config_key[] = "ssh_tunnel_user_name"; | ||||
35 | | ||||
30 | VncHostPreferences::VncHostPreferences(KConfigGroup configGroup, QObject *parent) | 36 | VncHostPreferences::VncHostPreferences(KConfigGroup configGroup, QObject *parent) | ||
31 | : HostPreferences(configGroup, parent) | 37 | : HostPreferences(configGroup, parent) | ||
32 | { | 38 | { | ||
33 | } | 39 | } | ||
34 | 40 | | |||
35 | VncHostPreferences::~VncHostPreferences() | 41 | VncHostPreferences::~VncHostPreferences() | ||
36 | { | 42 | { | ||
37 | } | 43 | } | ||
Show All 12 Lines | 46 | { | |||
50 | connect(vncUi.kcfg_Scaling, SIGNAL(toggled(bool)), SLOT(updateScaling(bool))); | 56 | connect(vncUi.kcfg_Scaling, SIGNAL(toggled(bool)), SLOT(updateScaling(bool))); | ||
51 | 57 | | |||
52 | const QString resolutionString = QString::number(width()) + QLatin1Char('x') + QString::number(height()); | 58 | const QString resolutionString = QString::number(width()) + QLatin1Char('x') + QString::number(height()); | ||
53 | const int resolutionIndex = vncUi.resolutionComboBox->findText(resolutionString, Qt::MatchContains); | 59 | const int resolutionIndex = vncUi.resolutionComboBox->findText(resolutionString, Qt::MatchContains); | ||
54 | vncUi.resolutionComboBox->setCurrentIndex((resolutionIndex == -1) ? vncUi.resolutionComboBox->count() - 1 : resolutionIndex); | 60 | vncUi.resolutionComboBox->setCurrentIndex((resolutionIndex == -1) ? vncUi.resolutionComboBox->count() - 1 : resolutionIndex); | ||
55 | 61 | | |||
56 | updateScaling(windowedScale()); | 62 | updateScaling(windowedScale()); | ||
57 | 63 | | |||
64 | #ifdef LIBSSH_FOUND | ||||
dfaure: the connect could move under #ifdef LIBSSH_FOUND | |||||
65 | connect(vncUi.use_ssh_tunnel, &QCheckBox::toggled, vncUi.ssh_groupBox, &QWidget::setVisible); | ||||
66 | | ||||
67 | vncUi.ssh_groupBox->setVisible(useSshTunnel()); | ||||
68 | vncUi.use_ssh_tunnel->setChecked(useSshTunnel()); | ||||
69 | vncUi.use_loopback->setChecked(useSshTunnelLoopback()); | ||||
70 | vncUi.ssh_tunnel_port->setValue(sshTunnelPort()); | ||||
71 | vncUi.ssh_tunnel_user_name->setText(sshTunnelUserName()); | ||||
72 | #else | ||||
73 | vncUi.ssh_groupBox->hide(); | ||||
74 | vncUi.use_ssh_tunnel->hide(); | ||||
75 | #endif | ||||
76 | | ||||
58 | return vncPage; | 77 | return vncPage; | ||
59 | } | 78 | } | ||
60 | 79 | | |||
61 | void VncHostPreferences::updateScalingWidthHeight(int index) | 80 | void VncHostPreferences::updateScalingWidthHeight(int index) | ||
62 | { | 81 | { | ||
63 | switch (index) { | 82 | switch (index) { | ||
64 | case 0: | 83 | case 0: | ||
65 | vncUi.kcfg_ScalingHeight->setValue(480); | 84 | vncUi.kcfg_ScalingHeight->setValue(480); | ||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | |||||
120 | { | 139 | { | ||
121 | HostPreferences::acceptConfig(); | 140 | HostPreferences::acceptConfig(); | ||
122 | setQuality((RemoteView::Quality)(vncUi.kcfg_Quality->currentIndex() + 1)); | 141 | setQuality((RemoteView::Quality)(vncUi.kcfg_Quality->currentIndex() + 1)); | ||
123 | setWindowedScale(vncUi.kcfg_Scaling->isChecked()); | 142 | setWindowedScale(vncUi.kcfg_Scaling->isChecked()); | ||
124 | if(vncUi.kcfg_Scaling->isChecked()) { | 143 | if(vncUi.kcfg_Scaling->isChecked()) { | ||
125 | setHeight(vncUi.kcfg_ScalingHeight->value()); | 144 | setHeight(vncUi.kcfg_ScalingHeight->value()); | ||
126 | setWidth(vncUi.kcfg_ScalingWidth->value()); | 145 | setWidth(vncUi.kcfg_ScalingWidth->value()); | ||
127 | } | 146 | } | ||
147 | | ||||
148 | setUseSshTunnel(vncUi.use_ssh_tunnel->isChecked()); | ||||
149 | setUseSshTunnelLoopback(vncUi.use_loopback->isChecked()); | ||||
150 | setSshTunnelPort(vncUi.ssh_tunnel_port->value()); | ||||
151 | setSshTunnelUserName(vncUi.ssh_tunnel_user_name->text()); | ||||
128 | } | 152 | } | ||
129 | 153 | | |||
130 | void VncHostPreferences::setQuality(RemoteView::Quality quality) | 154 | void VncHostPreferences::setQuality(RemoteView::Quality quality) | ||
131 | { | 155 | { | ||
132 | if (quality >= 0 && quality <= 3) | 156 | if (quality >= 0 && quality <= 3) | ||
133 | m_configGroup.writeEntry("quality", (int) quality); | 157 | m_configGroup.writeEntry(quality_config_key, (int) quality); | ||
134 | } | 158 | } | ||
135 | 159 | | |||
136 | RemoteView::Quality VncHostPreferences::quality() | 160 | RemoteView::Quality VncHostPreferences::quality() | ||
137 | { | 161 | { | ||
138 | return (RemoteView::Quality) m_configGroup.readEntry("quality", (int) Settings::quality() + 1); | 162 | return (RemoteView::Quality) m_configGroup.readEntry(quality_config_key, (int) Settings::quality() + 1); | ||
163 | } | ||||
164 | | ||||
165 | bool VncHostPreferences::useSshTunnel() const | ||||
166 | { | ||||
167 | return m_configGroup.readEntry(use_ssh_tunnel_config_key, false); | ||||
139 | } | 168 | } | ||
140 | 169 | | |||
170 | void VncHostPreferences::setUseSshTunnel(bool useSshTunnel) | ||||
171 | { | ||||
172 | m_configGroup.writeEntry(use_ssh_tunnel_config_key, useSshTunnel); | ||||
173 | } | ||||
174 | | ||||
175 | bool VncHostPreferences::useSshTunnelLoopback() const | ||||
176 | { | ||||
177 | return m_configGroup.readEntry(use_ssh_tunnel_loopback_config_key, false); | ||||
178 | } | ||||
179 | | ||||
180 | void VncHostPreferences::setUseSshTunnelLoopback(bool useSshTunnelLoopback) | ||||
181 | { | ||||
182 | m_configGroup.writeEntry(use_ssh_tunnel_loopback_config_key, useSshTunnelLoopback); | ||||
183 | } | ||||
184 | | ||||
185 | int VncHostPreferences::sshTunnelPort() const | ||||
186 | { | ||||
187 | return m_configGroup.readEntry(ssh_tunnel_port_config_key, 22); | ||||
188 | } | ||||
189 | | ||||
190 | void VncHostPreferences::setSshTunnelPort(int port) | ||||
191 | { | ||||
192 | m_configGroup.writeEntry(ssh_tunnel_port_config_key, port); | ||||
193 | } | ||||
194 | | ||||
195 | QString VncHostPreferences::sshTunnelUserName() const | ||||
196 | { | ||||
197 | return m_configGroup.readEntry(ssh_tunnel_user_name_config_key, QString()); | ||||
198 | } | ||||
199 | | ||||
200 | void VncHostPreferences::setSshTunnelUserName(const QString &userName) | ||||
201 | { | ||||
202 | m_configGroup.writeEntry(ssh_tunnel_user_name_config_key, userName); | ||||
203 | } |
static const char quality_config_key[] =
so that it goes into the rodata section.
(I just rechecked with a small test program, and yes, this is still valid, a const char* goes into .data while a const char[] goes into .rodata)