diff options
Diffstat (limited to 'src/gatscon/mainwnd.cpp')
-rw-r--r-- | src/gatscon/mainwnd.cpp | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/src/gatscon/mainwnd.cpp b/src/gatscon/mainwnd.cpp deleted file mode 100644 index 5d31019..0000000 --- a/src/gatscon/mainwnd.cpp +++ /dev/null | |||
@@ -1,119 +0,0 @@ | |||
1 | #include "mainwnd.h" | ||
2 | |||
3 | #include "clientwidget.h" | ||
4 | #include "proxywidget.h" | ||
5 | #include "filewidget.h" | ||
6 | |||
7 | #include "connectdlg.h" | ||
8 | #include "setupproxydlg.h" | ||
9 | |||
10 | #include <QLabel> | ||
11 | #include <QFileDialog> | ||
12 | |||
13 | MainWnd::MainWnd() | ||
14 | { | ||
15 | setupUi( this ); | ||
16 | |||
17 | pMode = new QLabel( "Idle", this ); | ||
18 | statusBar()->addPermanentWidget( pMode ); | ||
19 | } | ||
20 | |||
21 | MainWnd::~MainWnd() | ||
22 | { | ||
23 | } | ||
24 | |||
25 | void MainWnd::connect() | ||
26 | { | ||
27 | ConnectDlg dlg( this ); | ||
28 | if( dlg.exec() == QDialog::Accepted ) | ||
29 | { | ||
30 | sCurFile.clear(); | ||
31 | setCentralWidget( | ||
32 | new ClientWidget( | ||
33 | this, dlg.getHostname(), dlg.getPort() | ||
34 | ) | ||
35 | ); | ||
36 | pMode->setText( | ||
37 | QString("Client Mode: %1:%2").arg( QString(dlg.getHostname()) ). | ||
38 | arg( dlg.getPort() ) | ||
39 | ); | ||
40 | } | ||
41 | } | ||
42 | |||
43 | void MainWnd::proxy() | ||
44 | { | ||
45 | SetupProxyDlg dlg( this ); | ||
46 | |||
47 | if( dlg.exec() == QDialog::Accepted ) | ||
48 | { | ||
49 | sCurFile.clear(); | ||
50 | setCentralWidget( | ||
51 | new ProxyWidget( | ||
52 | this, dlg.getPortIn(), dlg.getHostOut(), dlg.getPortOut() | ||
53 | ) | ||
54 | ); | ||
55 | pMode->setText( | ||
56 | QString("Proxy Mode: :%1 -> %2:%3").arg( dlg.getPortIn() ). | ||
57 | arg( QString(dlg.getHostOut()) ). | ||
58 | arg( dlg.getPortOut() ) | ||
59 | ); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | void MainWnd::open() | ||
64 | { | ||
65 | QString sFile = QFileDialog::getOpenFileName( | ||
66 | this, "Gats Console - open gats file" | ||
67 | ); | ||
68 | if( sFile.isEmpty() ) | ||
69 | return; | ||
70 | |||
71 | sCurFile = sFile; | ||
72 | setCentralWidget( | ||
73 | new FileWidget( this, sFile ) | ||
74 | ); | ||
75 | pMode->setText( QString("File mode: %1").arg( sCurFile ) ); | ||
76 | } | ||
77 | |||
78 | void MainWnd::newFile() | ||
79 | { | ||
80 | sCurFile.clear(); | ||
81 | setCentralWidget( | ||
82 | new FileWidget( this ) | ||
83 | ); | ||
84 | pMode->setText( QString("File mode: <untitled>") ); | ||
85 | } | ||
86 | |||
87 | void MainWnd::save() | ||
88 | { | ||
89 | if( sCurFile.isEmpty() ) | ||
90 | { | ||
91 | saveAs(); | ||
92 | } | ||
93 | else | ||
94 | { | ||
95 | IoBase *pIo = dynamic_cast<IoBase *>(centralWidget()); | ||
96 | if( !pIo ) | ||
97 | return; | ||
98 | |||
99 | pIo->saveTo( sCurFile ); | ||
100 | } | ||
101 | } | ||
102 | |||
103 | void MainWnd::saveAs() | ||
104 | { | ||
105 | IoBase *pIo = dynamic_cast<IoBase *>(centralWidget()); | ||
106 | if( !pIo ) | ||
107 | return; | ||
108 | |||
109 | QString sFile = QFileDialog::getSaveFileName( | ||
110 | this, "Gats Console - save gats file" | ||
111 | ); | ||
112 | if( sFile.isEmpty() ) | ||
113 | return; | ||
114 | |||
115 | pIo->saveTo( sFile ); | ||
116 | |||
117 | sCurFile = sFile; | ||
118 | } | ||
119 | |||