Quellcode durchsuchen

save rdp options

tags/v0.5^0
Robin Thoni vor 8 Jahren
Ursprung
Commit
af1e007f3f
9 geänderte Dateien mit 270 neuen und 65 gelöschten Zeilen
  1. 35
    8
      maindialog.cpp
  2. 4
    0
      maindialog.h
  3. 99
    47
      maindialog.ui
  4. 4
    2
      rd-launcher.pro
  5. 7
    1
      rdesktoplauncher.cpp
  6. 14
    4
      rdpoptions.cpp
  7. 8
    3
      rdpoptions.h
  8. 81
    0
      rdpoptionshelper.cpp
  9. 18
    0
      rdpoptionshelper.h

+ 35
- 8
maindialog.cpp Datei anzeigen

@@ -4,6 +4,7 @@
4 4
 #include "maindialog.h"
5 5
 #include "ui_maindialog.h"
6 6
 #include "rdesktoplauncher.h"
7
+#include "rdpoptionshelper.h"
7 8
 
8 9
 MainDialog::MainDialog(QWidget *parent) :
9 10
     QDialog(parent),
@@ -13,6 +14,25 @@ MainDialog::MainDialog(QWidget *parent) :
13 14
     connect(ui->lineComputer->lineEdit(), SIGNAL(returnPressed()), ui->btnConnect, SLOT(animateClick()));
14 15
     connect(ui->lineComputer->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
15 16
     computeResolutions();
17
+    QStringList layouts;
18
+    for (int l = QLocale::Abkhazian; l <= QLocale::Shambala; ++l)
19
+    {
20
+        QString name = QLocale((QLocale::Language)l).name();
21
+        if (!layouts.contains(name))
22
+            layouts.append(name);
23
+    }
24
+    layouts.sort();
25
+    ui->comboKeyboard->addItems(layouts);
26
+    ui->comboKeyboard->setCurrentIndex(ui->comboKeyboard->findText("en_US"));
27
+
28
+    m_rdpOptions = RdpOptionsHelper::loadAll();
29
+    ui->lineComputer->addItem("");
30
+    for (int i = 1; i < m_rdpOptions.size(); ++i)
31
+    {
32
+        RdpOptions opt = m_rdpOptions.at(i);
33
+        ui->lineComputer->addItem(opt.host());
34
+    }
35
+
16 36
     ui->lineComputer->setFocus();
17 37
 }
18 38
 
@@ -27,8 +47,8 @@ RdpOptions MainDialog::getRdpOptions() const
27 47
     opt.setHost(ui->lineComputer->currentText());
28 48
     opt.setUsername(ui->lineUsername->text());
29 49
     opt.setPassword(ui->linePassword->text());
30
-    opt.setFullescreen(ui->slidResolution->value() == m_resolutions.size());
31
-    if (!opt.fullescreen())
50
+    opt.setFullscreen(ui->slidResolution->value() == m_resolutions.size());
51
+    if (!opt.fullscreen())
32 52
         opt.setResolution(m_resolutions.at(m_resolutions.size() - 1));
33 53
     opt.setUseAllMonitors(ui->checkAllDisplays->isChecked());
34 54
 
@@ -46,7 +66,7 @@ RdpOptions MainDialog::getRdpOptions() const
46 66
 
47 67
     opt.setFullscreenBar(ui->checkFullscreenBar->isChecked());
48 68
     int meta = ui->comboMetaKeys->currentIndex();
49
-    opt.setMetaKeys(meta == 0 || (opt.fullescreen() && meta == 2));
69
+    opt.setMetaKeys(meta == 0 || (opt.fullscreen() && meta == 2));
50 70
     opt.setUseShell(ui->checkShell->isChecked());
51 71
     if (opt.useShell())
52 72
     {
@@ -56,6 +76,7 @@ RdpOptions MainDialog::getRdpOptions() const
56 76
     opt.setExperience((RdpOptions::Experience)ui->comboExperience->currentIndex());
57 77
     opt.setBitmapCache(ui->checkCacheBitmap->isChecked());
58 78
     opt.setAutoReconnect(ui->checkAutoReconnect->isChecked());
79
+    opt.setKeymap(ui->comboKeyboard->currentText());
59 80
     return opt;
60 81
 }
61 82
 
@@ -64,13 +85,13 @@ void MainDialog::setRdpOptions(const RdpOptions &opt)
64 85
     ui->lineComputer->lineEdit()->setText(opt.host());
65 86
     ui->lineUsername->setText(opt.username());
66 87
     ui->linePassword->setText(opt.password());
67
-    if (opt.fullescreen())
88
+    if (opt.fullscreen())
68 89
     {
69 90
         ui->slidResolution->setValue(ui->slidResolution->maximum());
70 91
     }
71 92
     else
72 93
     {
73
-
94
+        ui->slidResolution->setValue(ui->slidResolution->maximum() - 1);
74 95
     }
75 96
     ui->checkAllDisplays->setChecked(opt.useAllMonitors());
76 97
 
@@ -94,12 +115,13 @@ void MainDialog::setRdpOptions(const RdpOptions &opt)
94 115
     ui->comboExperience->setCurrentIndex((int)opt.experience());
95 116
     ui->checkCacheBitmap->setChecked(opt.bitmapCache());
96 117
     ui->checkAutoReconnect->setChecked(opt.autoReconnect());
118
+    ui->comboKeyboard->setCurrentIndex(ui->comboKeyboard->findText(opt.keymap()));
97 119
 }
98 120
 
99 121
 void MainDialog::on_btnConnect_clicked()
100 122
 {
101 123
     RdpOptions opt = getRdpOptions();
102
-
124
+    RdpOptionsHelper::save(opt);
103 125
     RDesktopLauncher launcher;
104 126
     launcher.start(opt);
105 127
 }
@@ -132,15 +154,20 @@ void MainDialog::on_slidResolution_valueChanged(int value)
132 154
 
133 155
 void MainDialog::on_btnSaveSession_clicked()
134 156
 {
135
-
157
+    RdpOptionsHelper::save(getRdpOptions());
136 158
 }
137 159
 
138 160
 void MainDialog::on_btnSaveAsSession_clicked()
139 161
 {
140
-
162
+    on_btnSaveSession_clicked();
141 163
 }
142 164
 
143 165
 void MainDialog::on_btnOpenSession_clicked()
144 166
 {
145 167
 
146 168
 }
169
+
170
+void MainDialog::on_lineComputer_currentIndexChanged(int index)
171
+{
172
+    setRdpOptions(m_rdpOptions.at(index));
173
+}

+ 4
- 0
maindialog.h Datei anzeigen

@@ -36,10 +36,14 @@ private slots:
36 36
 
37 37
     void on_btnOpenSession_clicked();
38 38
 
39
+    void on_lineComputer_currentIndexChanged(int index);
40
+
39 41
 private:
40 42
     Ui::MainDialog *ui;
41 43
 
42 44
     QList<QSize> m_resolutions;
45
+
46
+    QList<RdpOptions> m_rdpOptions;
43 47
 };
44 48
 
45 49
 #endif // MAINDIALOG_H

+ 99
- 47
maindialog.ui Datei anzeigen

@@ -7,7 +7,7 @@
7 7
     <x>0</x>
8 8
     <y>0</y>
9 9
     <width>467</width>
10
-    <height>480</height>
10
+    <height>557</height>
11 11
    </rect>
12 12
   </property>
13 13
   <property name="windowTitle">
@@ -107,49 +107,6 @@
107 107
           <string>Paramètres d'ouverture de session</string>
108 108
          </property>
109 109
          <layout class="QGridLayout" name="gridLayout">
110
-          <item row="1" column="2">
111
-           <widget class="QComboBox" name="lineComputer">
112
-            <property name="editable">
113
-             <bool>true</bool>
114
-            </property>
115
-           </widget>
116
-          </item>
117
-          <item row="1" column="1">
118
-           <widget class="QLabel" name="label_3">
119
-            <property name="sizePolicy">
120
-             <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
121
-              <horstretch>0</horstretch>
122
-              <verstretch>0</verstretch>
123
-             </sizepolicy>
124
-            </property>
125
-            <property name="text">
126
-             <string>Ordinateur:</string>
127
-            </property>
128
-            <property name="buddy">
129
-             <cstring>lineComputer</cstring>
130
-            </property>
131
-           </widget>
132
-          </item>
133
-          <item row="0" column="1" colspan="2">
134
-           <widget class="QLabel" name="label_2">
135
-            <property name="text">
136
-             <string>Entrez le nom de l'ordinateur distant:</string>
137
-            </property>
138
-            <property name="wordWrap">
139
-             <bool>true</bool>
140
-            </property>
141
-           </widget>
142
-          </item>
143
-          <item row="4" column="1" colspan="2">
144
-           <widget class="QCheckBox" name="checkSaveSession">
145
-            <property name="text">
146
-             <string>Me permettre d'enregistrer les informations d'idenfication</string>
147
-            </property>
148
-            <property name="checked">
149
-             <bool>true</bool>
150
-            </property>
151
-           </widget>
152
-          </item>
153 110
           <item row="0" column="0" rowspan="2">
154 111
            <widget class="QLabel" name="label">
155 112
             <property name="sizePolicy">
@@ -169,8 +126,12 @@
169 126
             </property>
170 127
            </widget>
171 128
           </item>
172
-          <item row="2" column="2">
173
-           <widget class="QLineEdit" name="lineUsername"/>
129
+          <item row="1" column="2">
130
+           <widget class="QComboBox" name="lineComputer">
131
+            <property name="editable">
132
+             <bool>true</bool>
133
+            </property>
134
+           </widget>
174 135
           </item>
175 136
           <item row="2" column="1">
176 137
            <widget class="QLabel" name="label_4">
@@ -189,6 +150,35 @@
189 150
             </property>
190 151
            </widget>
191 152
           </item>
153
+          <item row="2" column="2">
154
+           <widget class="QLineEdit" name="lineUsername"/>
155
+          </item>
156
+          <item row="0" column="1" colspan="2">
157
+           <widget class="QLabel" name="label_2">
158
+            <property name="text">
159
+             <string>Entrez le nom de l'ordinateur distant:</string>
160
+            </property>
161
+            <property name="wordWrap">
162
+             <bool>true</bool>
163
+            </property>
164
+           </widget>
165
+          </item>
166
+          <item row="1" column="1">
167
+           <widget class="QLabel" name="label_3">
168
+            <property name="sizePolicy">
169
+             <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
170
+              <horstretch>0</horstretch>
171
+              <verstretch>0</verstretch>
172
+             </sizepolicy>
173
+            </property>
174
+            <property name="text">
175
+             <string>Ordinateur:</string>
176
+            </property>
177
+            <property name="buddy">
178
+             <cstring>lineComputer</cstring>
179
+            </property>
180
+           </widget>
181
+          </item>
192 182
           <item row="3" column="2">
193 183
            <widget class="QLineEdit" name="linePassword">
194 184
             <property name="echoMode">
@@ -233,6 +223,9 @@
233 223
           </item>
234 224
           <item row="1" column="2">
235 225
            <widget class="QPushButton" name="btnSaveAsSession">
226
+            <property name="enabled">
227
+             <bool>false</bool>
228
+            </property>
236 229
             <property name="text">
237 230
              <string>Enregistrer sous...</string>
238 231
             </property>
@@ -240,6 +233,9 @@
240 233
           </item>
241 234
           <item row="1" column="3">
242 235
            <widget class="QPushButton" name="btnOpenSession">
236
+            <property name="enabled">
237
+             <bool>false</bool>
238
+            </property>
243 239
             <property name="text">
244 240
              <string>Ouvrir...</string>
245 241
             </property>
@@ -258,6 +254,63 @@
258 254
          </layout>
259 255
         </widget>
260 256
        </item>
257
+       <item>
258
+        <widget class="QGroupBox" name="groupBox_7">
259
+         <property name="title">
260
+          <string>Clavier</string>
261
+         </property>
262
+         <layout class="QGridLayout" name="gridLayout_10">
263
+          <item row="0" column="1">
264
+           <widget class="QLabel" name="label_27">
265
+            <property name="sizePolicy">
266
+             <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
267
+              <horstretch>0</horstretch>
268
+              <verstretch>0</verstretch>
269
+             </sizepolicy>
270
+            </property>
271
+            <property name="text">
272
+             <string>Choisissez votre disposition de clavier:</string>
273
+            </property>
274
+            <property name="wordWrap">
275
+             <bool>true</bool>
276
+            </property>
277
+           </widget>
278
+          </item>
279
+          <item row="1" column="1">
280
+           <widget class="QComboBox" name="comboKeyboard">
281
+            <property name="sizePolicy">
282
+             <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
283
+              <horstretch>0</horstretch>
284
+              <verstretch>0</verstretch>
285
+             </sizepolicy>
286
+            </property>
287
+            <property name="sizeAdjustPolicy">
288
+             <enum>QComboBox::AdjustToContents</enum>
289
+            </property>
290
+           </widget>
291
+          </item>
292
+          <item row="0" column="0" rowspan="2">
293
+           <widget class="QLabel" name="label_26">
294
+            <property name="sizePolicy">
295
+             <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
296
+              <horstretch>0</horstretch>
297
+              <verstretch>0</verstretch>
298
+             </sizepolicy>
299
+            </property>
300
+            <property name="text">
301
+             <string/>
302
+            </property>
303
+            <property name="pixmap">
304
+             <pixmap resource="rc.qrc">:/images/icons/Icon_7.ico</pixmap>
305
+            </property>
306
+            <property name="alignment">
307
+             <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
308
+            </property>
309
+           </widget>
310
+          </item>
311
+         </layout>
312
+        </widget>
313
+       </item>
261 314
        <item>
262 315
         <spacer name="verticalSpacer">
263 316
          <property name="orientation">
@@ -985,7 +1038,6 @@
985 1038
   <tabstop>lineComputer</tabstop>
986 1039
   <tabstop>lineUsername</tabstop>
987 1040
   <tabstop>linePassword</tabstop>
988
-  <tabstop>checkSaveSession</tabstop>
989 1041
   <tabstop>btnSaveSession</tabstop>
990 1042
   <tabstop>btnSaveAsSession</tabstop>
991 1043
   <tabstop>btnOpenSession</tabstop>

+ 4
- 2
rd-launcher.pro Datei anzeigen

@@ -15,11 +15,13 @@ TEMPLATE = app
15 15
 SOURCES += main.cpp\
16 16
         maindialog.cpp \
17 17
     rdpoptions.cpp \
18
-    rdesktoplauncher.cpp
18
+    rdesktoplauncher.cpp \
19
+    rdpoptionshelper.cpp
19 20
 
20 21
 HEADERS  += maindialog.h \
21 22
     rdpoptions.h \
22
-    rdesktoplauncher.h
23
+    rdesktoplauncher.h \
24
+    rdpoptionshelper.h
23 25
 
24 26
 FORMS    += maindialog.ui
25 27
 

+ 7
- 1
rdesktoplauncher.cpp Datei anzeigen

@@ -16,7 +16,7 @@ void RDesktopLauncher::start(RdpOptions options)
16 16
     args.append(options.password());
17 17
     args.append("-a");
18 18
     args.append(QString("%1").arg((int)options.colors()));
19
-    if (!options.fullescreen())
19
+    if (!options.fullscreen())
20 20
     {
21 21
         args.append("-g");
22 22
         QSize reso = options.resolution();
@@ -42,6 +42,12 @@ void RDesktopLauncher::start(RdpOptions options)
42 42
         args.append(options.shellWorkingDir());
43 43
     }
44 44
 
45
+    args.append("-k");
46
+    args.append(options.keymap());
47
+
48
+    args.append("-r");
49
+    args.append("clipboard:PRIMARYCLIPBOARD");
50
+
45 51
     args.append(options.host());
46 52
 
47 53
     QProcess::startDetached("rdesktop", args);

+ 14
- 4
rdpoptions.cpp Datei anzeigen

@@ -44,14 +44,14 @@ void RdpOptions::setResolution(const QSize &resolution)
44 44
     m_resolution = resolution;
45 45
 }
46 46
 
47
-bool RdpOptions::fullescreen() const
47
+bool RdpOptions::fullscreen() const
48 48
 {
49
-    return m_fullescreen;
49
+    return m_fullscreen;
50 50
 }
51 51
 
52
-void RdpOptions::setFullescreen(bool fullescreen)
52
+void RdpOptions::setFullscreen(bool fullscreen)
53 53
 {
54
-    m_fullescreen = fullescreen;
54
+    m_fullscreen = fullscreen;
55 55
 }
56 56
 
57 57
 RdpOptions::Experience RdpOptions::experience() const
@@ -149,6 +149,16 @@ void RdpOptions::setAutoReconnect(bool autoReconnect)
149 149
 {
150 150
     m_autoReconnect = autoReconnect;
151 151
 }
152
+QString RdpOptions::keymap() const
153
+{
154
+    return m_keymap;
155
+}
156
+
157
+void RdpOptions::setKeymap(const QString &keymap)
158
+{
159
+    m_keymap = keymap;
160
+}
161
+
152 162
 
153 163
 
154 164
 

+ 8
- 3
rdpoptions.h Datei anzeigen

@@ -40,8 +40,8 @@ public:
40 40
     QSize resolution() const;
41 41
     void setResolution(const QSize &resolution);
42 42
 
43
-    bool fullescreen() const;
44
-    void setFullescreen(bool fullescreen);
43
+    bool fullscreen() const;
44
+    void setFullscreen(bool fullscreen);
45 45
 
46 46
     Experience experience() const;
47 47
     void setExperience(const Experience &experience);
@@ -73,6 +73,9 @@ public:
73 73
     bool autoReconnect() const;
74 74
     void setAutoReconnect(bool autoReconnect);
75 75
 
76
+    QString keymap() const;
77
+    void setKeymap(const QString &keymap);
78
+
76 79
 private:
77 80
     QString m_host;
78 81
 
@@ -80,7 +83,7 @@ private:
80 83
 
81 84
     QString m_password;
82 85
 
83
-    bool m_fullescreen;
86
+    bool m_fullscreen;
84 87
 
85 88
     QSize m_resolution;
86 89
 
@@ -103,6 +106,8 @@ private:
103 106
     bool m_bitmapCache;
104 107
 
105 108
     bool m_autoReconnect;
109
+
110
+    QString m_keymap;
106 111
 };
107 112
 
108 113
 #endif // RDPOPTIONS_H

+ 81
- 0
rdpoptionshelper.cpp Datei anzeigen

@@ -0,0 +1,81 @@
1
+#include <QSettings>
2
+#include "rdpoptionshelper.h"
3
+#include <QList>
4
+#include <QStringList>
5
+
6
+void RdpOptionsHelper::save(const RdpOptions &opt)
7
+{
8
+    QString group;
9
+    if (opt.host().isEmpty())
10
+        group = RdpOptionsHelper::getDefaultName();
11
+    else if (opt.username().isEmpty())
12
+        group = opt.host();
13
+    else
14
+        group = opt.username() + "@" + opt.host();
15
+    QSettings set(QSettings::UserScope, "RdpOptions");
16
+    set.beginGroup(group);
17
+    set.setValue("host", opt.host());
18
+    set.setValue("username", opt.username());
19
+    set.setValue("password", QByteArray(opt.password().toStdString().c_str()).toBase64());
20
+    set.setValue("fullscreen", opt.fullscreen());
21
+    set.setValue("resolution", opt.resolution());
22
+    set.setValue("useAllMonitors", opt.useAllMonitors());
23
+    set.setValue("colors", opt.colors());
24
+    set.setValue("fullscreenBar", opt.fullscreenBar());
25
+    set.setValue("metaKeys", opt.metaKeys());
26
+    set.setValue("useShell", opt.useShell());
27
+    set.setValue("shell", opt.shell());
28
+    set.setValue("shellWorkingDir", opt.shellWorkingDir());
29
+    set.setValue("experience", opt.experience());
30
+    set.setValue("bitmapCache", opt.bitmapCache());
31
+    set.setValue("autoReconnect", opt.autoReconnect());
32
+    set.setValue("keymap", opt.keymap());
33
+    set.endGroup();
34
+}
35
+
36
+RdpOptions RdpOptionsHelper::load(QString group)
37
+{
38
+    if (group.isEmpty())
39
+        group = getDefaultName();
40
+    QSettings set(QSettings::UserScope, "RdpOptions");
41
+    set.beginGroup(group);
42
+    RdpOptions opt;
43
+    opt.setHost(set.value("host", "").toString());
44
+    opt.setUsername(set.value("username", "").toString());
45
+    opt.setPassword(QByteArray::fromBase64(set.value("password", "").toByteArray()));
46
+    opt.setFullscreen(set.value("fullscreen", true).toBool());
47
+    opt.setResolution(set.value("resolution", QSize(0, 0)).toSize());
48
+    opt.setUseAllMonitors(set.value("useAllMonitors", false).toBool());
49
+    opt.setColors((RdpOptions::Colors)set.value("colors", RdpOptions::HighestQuality).toInt());
50
+    opt.setFullscreenBar(set.value("fullscreenBar", true).toBool());
51
+    opt.setMetaKeys(set.value("metaKeys", true).toBool());
52
+    opt.setUseShell(set.value("useShell", false).toBool());
53
+    opt.setShell(set.value("shell", "").toString());
54
+    opt.setShellWorkingDir(set.value("shellWorkingDir", "").toString());
55
+    opt.setExperience((RdpOptions::Experience)set.value("experience", RdpOptions::Detect).toInt());
56
+    opt.setBitmapCache(set.value("bitmapCache", true).toBool());
57
+    opt.setAutoReconnect(set.value("autoReconnect", true).toBool());
58
+    opt.setKeymap(set.value("keymap", "en_US").toString());
59
+    set.endGroup();
60
+    return opt;
61
+}
62
+
63
+QList<RdpOptions> RdpOptionsHelper::loadAll()
64
+{
65
+    QSettings set(QSettings::UserScope, "RdpOptions");
66
+    QList<RdpOptions> opts;
67
+    opts.append(load(getDefaultName()));
68
+    QStringList groups = set.childGroups();
69
+    for (int i = 0; i < groups.size(); ++i)
70
+    {
71
+        QString group = groups.at(i);
72
+        if (group != getDefaultName())
73
+            opts.append(load(groups.at(i)));
74
+    }
75
+    return opts;
76
+}
77
+
78
+QString RdpOptionsHelper::getDefaultName()
79
+{
80
+    return "__Default__";
81
+}

+ 18
- 0
rdpoptionshelper.h Datei anzeigen

@@ -0,0 +1,18 @@
1
+#ifndef RDPOPTIONSHELPER_H
2
+#define RDPOPTIONSHELPER_H
3
+
4
+#include "rdpoptions.h"
5
+
6
+class RdpOptionsHelper
7
+{
8
+public:
9
+    static void save(const RdpOptions& opt);
10
+
11
+    static RdpOptions load(QString group);
12
+
13
+    static QList<RdpOptions> loadAll();
14
+
15
+    static QString getDefaultName();
16
+};
17
+
18
+#endif // RDPOPTIONSHELPER_H

Laden…
Abbrechen
Speichern