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