1 /**************************************************************************
2 * Copyright (C) 2005-2020 by Oleksandr Shneyder *
3 * <o.shneyder@phoca-gmbh.de> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program. If not, see <https://www.gnu.org/licenses/>. *
16 ***************************************************************************/
17 #include "xsettingswidget.h"
18 #include "x2gosettings.h"
19 #include "x2goutils.h"
20 #include <QFileDialog>
21
22 #ifdef Q_OS_WIN
XSettingsWidget(QWidget * parent)23 XSettingsWidget::XSettingsWidget(QWidget* parent)
24 {
25 UNUSED (parent);
26 setupUi(this);
27
28 X2goSettings st ( "settings" );
29 rbXming->setChecked(st.setting()->value("useintx",true).toBool());
30 rbOther->setChecked(!(st.setting()->value("useintx",true).toBool()));
31 cbNoPrimary->setChecked(st.setting()->value("noprimaryclip",false).toBool());
32 leExec->setText(st.setting()->value("xexec","C:\\program files\\vcxsrv\\vcxsrv.exe").toString());
33 leCmdOptions->setText(st.setting()->value("options","-multiwindow -notrayicon -clipboard").toString());
34
35 cbOnstart->setChecked(true);
36 cbOnstart->setChecked(st.setting()->value("onstart",true).toBool());
37
38 leWinMod->setText(st.setting()->value("optionswin","-screen 0 %wx%h -notrayicon -clipboard").toString());
39 leFSMod->setText(st.setting()->value("optionsfs","-fullscreen -notrayicon -clipboard").toString());
40 leSingApp->setText(st.setting()->value("optionssingle","-multiwindow -notrayicon -clipboard").toString());
41 leWholeDisplay->setText (st.setting ()->value ("optionswholedisplay", "-nodecoration -notrayicon -clipboard -screen 0 @").toString ());
42
43 // spDelay->setValue(st.setting()->value("delay",3).toInt());
44 pbExec->setIcon( QPixmap ( ":/img/icons/16x16/file-open.png" ) );
45 }
46
~XSettingsWidget()47 XSettingsWidget::~XSettingsWidget()
48 {
49 }
50
slotSetExecutable()51 void XSettingsWidget::slotSetExecutable()
52 {
53 QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
54 "C:\\",
55 tr("Executable (*.exe)"));
56
57 if (fileName.length())
58 leExec->setText(fileName);
59
60 }
61
setDefaults()62 void XSettingsWidget::setDefaults()
63 {
64 rbXming->setChecked(true);
65 leExec->setText("C:\\program files\\vcxsrv\\vcxsrv.exe");
66 leCmdOptions->setText("-multiwindow -notrayicon -clipboard");
67 cbOnstart->setChecked(true);
68 leWinMod->setText("-screen 0 %wx%h -notrayicon -clipboard");
69 leFSMod->setText("-fullscreen -notrayicon -clipboard");
70 leSingApp->setText("-multiwindow -notrayicon -clipboard");
71 leWholeDisplay->setText ("-nodecoration -notrayicon -clipboard -screen 0 @");
72 // spDelay->setValue(3);
73
74 }
75
saveSettings()76 void XSettingsWidget::saveSettings()
77 {
78 X2goSettings st ( "settings" );
79 st.setting()->setValue("useintx",rbXming->isChecked());
80 st.setting()->setValue("xexec",leExec->text());
81 st.setting()->setValue("options",leCmdOptions->text());
82 st.setting()->setValue("onstart",cbOnstart->isChecked());
83 st.setting()->setValue("noprimaryclip", cbNoPrimary->isChecked());
84
85 st.setting()->setValue("optionswin",leWinMod->text());
86 st.setting()->setValue("optionsfs",leFSMod->text());
87 st.setting()->setValue("optionssingle",leSingApp->text());
88 st.setting ()->setValue ("optionswholedisplay", leWholeDisplay->text ());
89 // st.setting()->setValue("delay",spDelay->value());
90 st.setting()->sync();
91 }
92 #endif //Q_OS_WIN
93