Browse Source

clean code

tags/v0.6
Robin Thoni 7 years ago
parent
commit
def9d8eb3f
5 changed files with 30 additions and 68 deletions
  1. 1
    55
      main.cpp
  2. 23
    9
      maindialog.cpp
  3. 4
    0
      maindialog.h
  4. 1
    3
      rdesktoplauncher.cpp
  5. 1
    1
      rdpoptionshelper.cpp

+ 1
- 55
main.cpp View File

@@ -1,66 +1,12 @@
1
-#include "maindialog.h"
2 1
 #include <QApplication>
3
-#include <QTextCodec>
4
-#include <QWindow>
5
-#include <QDebug>
6
-#include <QTimer>
2
+#include "maindialog.h"
7 3
 
8 4
 
9 5
 int main(int argc, char *argv[])
10 6
 {
11 7
     QApplication a(argc, argv);
12
-//    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
13
-//    QTextCodec::setCodecForTr(QTextCodec::codecForCStrings());
14 8
     MainDialog w;
15 9
     w.show();
16 10
 
17
-//    Display *dpy;
18
-//    Window rootWindow;
19
-//    Window parent;
20
-//    Window *children;
21
-//    Window *child;
22
-//    unsigned long noOfChildren;
23
-
24
-//    dpy = XOpenDisplay(NULL);
25
-//    if (!dpy) {
26
-//        return 7;
27
-//    }
28
-//    rootWindow = RootWindow(dpy, -1);
29
-
30
-
31
-//    children = (Window*)get_client_list(dpy, &noOfChildren);
32
-
33
-////    XQueryTree(dpy, rootWindow, &rootWindow, &parent, &children, &noOfChildren);
34
-//    for (int i = 0; i < noOfChildren; ++i) {
35
-//        char* nameStr;
36
-//        XFetchName(dpy, children[i], &nameStr);
37
-//        QString name(nameStr);
38
-//        XFree(nameStr);
39
-//        if (name.startsWith("rdesktop - ")) {
40
-////        if (name.startsWith("robin@gigi-lt1: /tmp")) {
41
-//            qDebug() << name;
42
-//            QWindow *window = QWindow::fromWinId(children[i]);
43
-//            window->setFlags(Qt::FramelessWindowHint);
44
-
45
-//            QWidget *widget = QWidget::createWindowContainer(window);
46
-////            QEvent e(QEvent::EmbeddingControl);
47
-////            QApplication::sendEvent(widget, &e);
48
-////            widget->show();
49
-////            QTimer* timer = new QTimer(widget);
50
-////            QObject::connect(timer, SIGNAL(timeout()), widget, SLOT(update()));
51
-////            timer->start(100);
52
-//            break;
53
-//        }
54
-//    }
55
-
56
-////    QWindow *window = QWindow::fromWinId(0x0340056f);
57
-////    window->setFlags(Qt::FramelessWindowHint);
58
-
59
-////    QWidget *widget = QWidget::createWindowContainer(window);
60
-
61
-////    QVBoxLayout *layout = new QVBoxLayout(this);
62
-////    layout->addWidget(widget);
63
-////    this->setLayout(layout);
64
-
65 11
     return a.exec();
66 12
 }

+ 23
- 9
maindialog.cpp View File

@@ -1,7 +1,7 @@
1 1
 #include <QApplication>
2 2
 #include <QDesktopWidget>
3 3
 #include <QUuid>
4
-#include <QDebug>
4
+#include <QWindow>
5 5
 #include "maindialog.h"
6 6
 #include "ui_maindialog.h"
7 7
 #include "rdesktoplauncher.h"
@@ -10,7 +10,8 @@
10 10
 MainDialog::MainDialog(QWidget *parent) :
11 11
     QDialog(parent),
12 12
     ui(new Ui::MainDialog),
13
-    m_launcher(0)
13
+    m_launcher(0),
14
+    m_dlgConnecting(0)
14 15
 {
15 16
     ui->setupUi(this);
16 17
     connect(ui->lineComputer->lineEdit(), SIGNAL(returnPressed()), ui->btnConnect, SLOT(animateClick()));
@@ -210,16 +211,29 @@ void MainDialog::on_btnRemoveSession_clicked()
210 211
 void MainDialog::onProcessFinished(int status)
211 212
 {
212 213
     ui->lblExitStatus->setText(RDesktopLauncher::getExitStatusString(status));
213
-    m_launcher->deleteLater();
214
-    m_launcher = 0;
215
-    m_dlgConnecting->deleteLater();
216
-    m_dlgConnecting = 0;
214
+    clearLauncher();
215
+    clearDialogConnecting();
217 216
     show();
218 217
 }
219 218
 
220
-void MainDialog::onWindowFound(WId wid)
219
+void MainDialog::onWindowFound(WId)
221 220
 {
222
-    m_dlgConnecting->deleteLater();
223
-    m_dlgConnecting = 0;
221
+    clearDialogConnecting();
224 222
     hide();
225 223
 }
224
+
225
+void MainDialog::clearDialogConnecting()
226
+{
227
+    if (m_dlgConnecting) {
228
+        m_dlgConnecting->deleteLater();
229
+        m_dlgConnecting = 0;
230
+    }
231
+}
232
+
233
+void MainDialog::clearLauncher()
234
+{
235
+    if (m_launcher) {
236
+        m_launcher->deleteLater();
237
+        m_launcher = 0;
238
+    }
239
+}

+ 4
- 0
maindialog.h View File

@@ -49,6 +49,10 @@ private slots:
49 49
 
50 50
     void onWindowFound(WId wid);
51 51
 
52
+    void clearDialogConnecting();
53
+
54
+    void clearLauncher();
55
+
52 56
 private:
53 57
     Ui::MainDialog *ui;
54 58
 

+ 1
- 3
rdesktoplauncher.cpp View File

@@ -2,8 +2,6 @@
2 2
 #include "rdesktoplauncher.h"
3 3
 #include "x11helper.h"
4 4
 
5
-#include <QDebug>
6
-
7 5
 RDesktopLauncher::RDesktopLauncher(QObject *parent)
8 6
     : QObject(parent)
9 7
     , m_process(0)
@@ -157,7 +155,7 @@ void RDesktopLauncher::kill()
157 155
     }
158 156
 }
159 157
 
160
-void RDesktopLauncher::onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
158
+void RDesktopLauncher::onProcessFinished(int exitCode, QProcess::ExitStatus)
161 159
 {
162 160
     clearWindowLookUpTimer();
163 161
     m_process->deleteLater();

+ 1
- 1
rdpoptionshelper.cpp View File

@@ -1,7 +1,7 @@
1 1
 #include <QSettings>
2
-#include "rdpoptionshelper.h"
3 2
 #include <QList>
4 3
 #include <QStringList>
4
+#include "rdpoptionshelper.h"
5 5
 
6 6
 void RdpOptionsHelper::save(const RdpOptions &opt)
7 7
 {

Loading…
Cancel
Save