diff options
Diffstat (limited to 'src/gatscon/mainwnd.cpp')
-rw-r--r-- | src/gatscon/mainwnd.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/gatscon/mainwnd.cpp b/src/gatscon/mainwnd.cpp index 628988e..bddaf08 100644 --- a/src/gatscon/mainwnd.cpp +++ b/src/gatscon/mainwnd.cpp | |||
@@ -7,11 +7,15 @@ | |||
7 | #include "connectdlg.h" | 7 | #include "connectdlg.h" |
8 | #include "setupproxydlg.h" | 8 | #include "setupproxydlg.h" |
9 | 9 | ||
10 | #include <QLabel> | ||
10 | #include <QFileDialog> | 11 | #include <QFileDialog> |
11 | 12 | ||
12 | MainWnd::MainWnd() | 13 | MainWnd::MainWnd() |
13 | { | 14 | { |
14 | setupUi( this ); | 15 | setupUi( this ); |
16 | |||
17 | pMode = new QLabel( "Idle", this ); | ||
18 | statusBar()->addPermanentWidget( pMode ); | ||
15 | } | 19 | } |
16 | 20 | ||
17 | MainWnd::~MainWnd() | 21 | MainWnd::~MainWnd() |
@@ -23,11 +27,16 @@ void MainWnd::connect() | |||
23 | ConnectDlg dlg( this ); | 27 | ConnectDlg dlg( this ); |
24 | if( dlg.exec() == QDialog::Accepted ) | 28 | if( dlg.exec() == QDialog::Accepted ) |
25 | { | 29 | { |
30 | sCurFile.clear(); | ||
26 | setCentralWidget( | 31 | setCentralWidget( |
27 | new ClientWidget( | 32 | new ClientWidget( |
28 | this, dlg.getHostname(), dlg.getPort() | 33 | this, dlg.getHostname(), dlg.getPort() |
29 | ) | 34 | ) |
30 | ); | 35 | ); |
36 | pMode->setText( | ||
37 | QString("Client Mode: %1:%2").arg( QString(dlg.getHostname()) ). | ||
38 | arg( dlg.getPort() ) | ||
39 | ); | ||
31 | } | 40 | } |
32 | } | 41 | } |
33 | 42 | ||
@@ -37,11 +46,17 @@ void MainWnd::proxy() | |||
37 | 46 | ||
38 | if( dlg.exec() == QDialog::Accepted ) | 47 | if( dlg.exec() == QDialog::Accepted ) |
39 | { | 48 | { |
49 | sCurFile.clear(); | ||
40 | setCentralWidget( | 50 | setCentralWidget( |
41 | new ProxyWidget( | 51 | new ProxyWidget( |
42 | this, dlg.getPortIn(), dlg.getHostOut(), dlg.getPortOut() | 52 | this, dlg.getPortIn(), dlg.getHostOut(), dlg.getPortOut() |
43 | ) | 53 | ) |
44 | ); | 54 | ); |
55 | pMode->setText( | ||
56 | QString("Proxy Mode: :%1 -> %2:%3").arg( dlg.getPortIn() ). | ||
57 | arg( QString(dlg.getHostOut()) ). | ||
58 | arg( dlg.getPortOut() ) | ||
59 | ); | ||
45 | } | 60 | } |
46 | } | 61 | } |
47 | 62 | ||
@@ -53,8 +68,52 @@ void MainWnd::open() | |||
53 | if( sFile.isEmpty() ) | 68 | if( sFile.isEmpty() ) |
54 | return; | 69 | return; |
55 | 70 | ||
71 | sCurFile = sFile; | ||
56 | setCentralWidget( | 72 | setCentralWidget( |
57 | new FileWidget( this, sFile ) | 73 | new FileWidget( this, sFile ) |
58 | ); | 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, "GatsCon - save gats file" | ||
111 | ); | ||
112 | if( sFile.isEmpty() ) | ||
113 | return; | ||
114 | |||
115 | pIo->saveTo( sFile ); | ||
116 | |||
117 | sCurFile = sFile; | ||
59 | } | 118 | } |
60 | 119 | ||