29 #include <kfiledialog.h>
31 #include <QDesktopWidget>
36 static const QStringList
keymaps = (QStringList()
80 const int index =
keymaps.lastIndexOf(keymap);
86 if (layout >= 0 && layout <
keymaps.count())
103 const int index =
desktopTypes.lastIndexOf(desktopType);
127 nxUi.setupUi(nxPage);
129 nxUi.kcfg_NxHeight->setValue(
height());
130 nxUi.kcfg_NxWidth->setValue(
width());
135 nxUi.checkboxDefaultPrivateKey->setChecked(
true);
136 nxUi.groupboxPrivateKey->setEnabled(
false);
137 setDefaultPrivateKey(Qt::Checked);
139 nxUi.checkboxDefaultPrivateKey->setChecked(
false);
140 nxUi.groupboxPrivateKey->setEnabled(
true);
141 setDefaultPrivateKey(Qt::Unchecked);
144 connect(nxUi.resolutionComboBox, SIGNAL(currentIndexChanged(
int)), SLOT(updateWidthHeight(
int)));
145 connect(nxUi.checkboxDefaultPrivateKey, SIGNAL(stateChanged(
int)), SLOT(setDefaultPrivateKey(
int)));
146 connect(nxUi.buttonImportPrivateKey, SIGNAL(pressed()), SLOT(chooseKeyFile()));
147 connect(nxUi.kcfg_NxPrivateKey, SIGNAL(textChanged()), SLOT(updatePrivateKey()));
149 const QString resolutionString = QString::number(
width()) +
'x' + QString::number(
height());
150 const int resolutionIndex = nxUi.resolutionComboBox->findText(resolutionString, Qt::MatchContains);
151 nxUi.resolutionComboBox->setCurrentIndex((resolutionIndex == -1) ? 5 : resolutionIndex);
156 void NxHostPreferences::updateWidthHeight(
int index)
160 nxUi.kcfg_NxHeight->setValue(480);
161 nxUi.kcfg_NxWidth->setValue(640);
164 nxUi.kcfg_NxHeight->setValue(600);
165 nxUi.kcfg_NxWidth->setValue(800);
168 nxUi.kcfg_NxHeight->setValue(768);
169 nxUi.kcfg_NxWidth->setValue(1024);
172 nxUi.kcfg_NxHeight->setValue(1024);
173 nxUi.kcfg_NxWidth->setValue(1280);
176 nxUi.kcfg_NxHeight->setValue(1200);
177 nxUi.kcfg_NxWidth->setValue(1600);
180 QDesktopWidget *desktop = QApplication::desktop();
181 int currentScreen = desktop->screenNumber(nxUi.kcfg_NxHeight);
182 nxUi.kcfg_NxHeight->setValue(desktop->screenGeometry(currentScreen).height());
183 nxUi.kcfg_NxWidth->setValue(desktop->screenGeometry(currentScreen).width());
191 bool enabled = (index == 6) ?
true :
false;
193 nxUi.kcfg_NxHeight->setEnabled(enabled);
194 nxUi.kcfg_NxWidth->setEnabled(enabled);
195 nxUi.heightLabel->setEnabled(enabled);
196 nxUi.widthLabel->setEnabled(enabled);
199 void NxHostPreferences::setDefaultPrivateKey(
int state)
201 if (state == Qt::Checked) {
203 nxUi.groupboxPrivateKey->setEnabled(
false);
204 }
else if (state == Qt::Unchecked) {
206 nxUi.groupboxPrivateKey->setEnabled(
true);
210 void NxHostPreferences::updatePrivateKey()
212 m_privateKey = nxUi.kcfg_NxPrivateKey->toPlainText();
215 void NxHostPreferences::chooseKeyFile()
217 const QString fileName = KFileDialog::getOpenFileName(KUrl(QDir::homePath()),
218 "*.key|" + i18n(
"Key Files (*.key)"),
219 nxPage, i18n(
"Open DSA Key File"));
221 QFile file(fileName);
222 if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
226 while (!file.atEnd())
227 key += file.readLine();
229 nxUi.kcfg_NxPrivateKey->setPlainText(QString(key));
238 setWidth(nxUi.kcfg_NxWidth->value());
267 if (!desktopType.isNull())
278 if (!keyboardLayout.isNull())
289 if (!privateKey.isNull())
298 #include "nxhostpreferences.moc"
KConfigGroup m_configGroup
static QString nxPrivateKey()
Get NxPrivateKey.
static int nxKeyboardLayout()
Get NxKeyboardLayout.
static const int defaultKeymap
static const int defaultDesktopType
QString privateKey() const
static int nxDesktopType()
Get NxDesktopType.
void setKeyboardLayout(const QString &keyboardLayout)
void setHeight(int height)
QString keyboardLayout() const
QString int2keymap(int layout)
void setDesktopType(const QString &desktopType)
static const QStringList desktopTypes
static int nxHeight()
Get NxHeight.
QString desktopType() const
static int nxWidth()
Get NxWidth.
virtual void acceptConfig()
Called when the user validates the config dialog.
static const QStringList keymaps
void acceptConfig()
Called when the user validates the config dialog.
int keymap2int(const QString &keymap)
int desktopType2int(const QString &desktopType)
QString int2desktopType(int index)
QWidget * createProtocolSpecificConfigPage()
NxHostPreferences(KConfigGroup configGroup, QObject *parent=0)
void setPrivateKey(const QString &privateKey)