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