diff options
author | Alex Borisov <b0ric.alex@gmail.com> | 2012-03-24 00:28:40 +0200 |
---|---|---|
committer | Alex Borisov <b0ric.alex@gmail.com> | 2012-03-24 00:28:40 +0200 |
commit | db10b50c84a4aaf5014e0f164b3f4f79ca222429 (patch) | |
tree | 8d4e05390d478046d9bc602f5bee91e07b6e8170 | |
parent | 05712da90682fed84e2ecf7e3037d8aed29ecf83 (diff) |
FIX: speed calc problem, tray click fix, other
-rw-r--r-- | client/Dialog.cpp | 21 | ||||
-rw-r--r-- | client/Logger.cpp | 4 | ||||
-rw-r--r-- | client/Proxy.cpp | 2 | ||||
-rw-r--r-- | client/ProxyClientApp.cpp | 28 | ||||
-rw-r--r-- | client/ProxyClientApp.h | 6 | ||||
-rw-r--r-- | client/SslClient.cpp | 4 | ||||
-rw-r--r-- | client/client.qrc | 2 | ||||
-rw-r--r-- | client/config.cfg | 12 |
8 files changed, 48 insertions, 31 deletions
diff --git a/client/Dialog.cpp b/client/Dialog.cpp index 3ae26aa..2610bea 100644 --- a/client/Dialog.cpp +++ b/client/Dialog.cpp @@ -11,15 +11,16 @@ using namespace std; -ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent, Qt::Popup) +ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint) { UpdatedConfig *cfg = UpdatedConfig::CurrentConfig(); + Proxifier *proxifier = Proxifier::GetInstance(); if (!proxifier->IsValid()) { Logger::Error("No valid proxifier configuration file found!\n"); } - + connect(this, SIGNAL(finished(int)), this, SLOT(Closed(int))); /* generic proxy panel */ @@ -65,22 +66,26 @@ ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent, Qt::Popup) vector<ProxyEntryStatic> staticProxyLine = cfg->GetStaticProxyGuiLine(i+1); for (unsigned j = 0; j < staticProxyLine.size(); j++) { - stringstream ss; + QString btnStr; if (cfg->IsSpeedVisible) { + double speed = 1.0 * staticProxyLine[j].speed * 8 / 1000000; if (staticProxyLine[j].speed > cfg->StaticProxySpeedLow) { - ss << "<font color=\"green\"><b>" << staticProxyLine[j].speed << "</b></font>"; + btnStr = QString("<font color=\"green\"><b>") + + QString::number(speed, 'f', 3) + + QString("</b></font>"); } else { - ss << "<font color=\"red\"><b>" << staticProxyLine[j].speed << "</b></font>"; + btnStr = QString("<font color=\"red\"><b>") + + QString::number(speed, 'f', 3) + + QString("</b></font>"); } - ss << " "; + btnStr += " "; } - ss << staticProxyLine[j].name; + btnStr += QString::fromLocal8Bit(staticProxyLine[j].name.c_str()); - QString btnStr = QString::fromLocal8Bit(ss.str().c_str()); QLabel *btnLabel = new QLabel(btnStr); btnLabel->setAttribute(Qt::WA_TransparentForMouseEvents); QHBoxLayout *btnLayout = new QHBoxLayout; diff --git a/client/Logger.cpp b/client/Logger.cpp index 9de51c8..c8661bc 100644 --- a/client/Logger.cpp +++ b/client/Logger.cpp @@ -15,13 +15,13 @@ FILE* Logger::logFile = NULL; void Logger::InitLogFile() { - /* +/* if (logFile == NULL) { logFile = fopen("client.log", "a"); setbuf(logFile, NULL); } - */ +*/ } void Logger::Trace(string msg, ...) diff --git a/client/Proxy.cpp b/client/Proxy.cpp index 0854cbb..abfaf22 100644 --- a/client/Proxy.cpp +++ b/client/Proxy.cpp @@ -97,4 +97,4 @@ void ProxyEntryStatic::Parse(std::string entry) lp1 = lp2+1; speed = atoi(entry.substr(lp1).c_str()); } -
\ No newline at end of file + diff --git a/client/ProxyClientApp.cpp b/client/ProxyClientApp.cpp index e111001..c20d232 100644 --- a/client/ProxyClientApp.cpp +++ b/client/ProxyClientApp.cpp @@ -2,7 +2,6 @@ #include <QtGui> #include "client.h" -#include "Dialog.h" #include "Proxifier.h" #include "ProxyClientApp.h" #include "UpdatedConfig.h" @@ -10,7 +9,9 @@ using namespace std; ProxyClientApp::ProxyClientApp(int &argc, char *argv[]): QApplication(argc, argv) -{ +{ + dialog = NULL; + /* initiates UpdatedConfig singleton that start sending configuration requests */ UpdatedConfig *cfg = UpdatedConfig::CurrentConfig(); connect(cfg, SIGNAL(updated()), @@ -73,17 +74,28 @@ ProxyClientApp::ProxyClientApp(int &argc, char *argv[]): QApplication(argc, argv void ProxyClientApp::trayActivated(QSystemTrayIcon::ActivationReason reason) { - if (reason == QSystemTrayIcon::Trigger) + if (reason != QSystemTrayIcon::Trigger) { - showProxyDialog(); - } + return; + } + + if (dialog == NULL) + { + showProxyDialog(); + } + else + { + dialog->reject(); + delete dialog; + dialog = NULL; + } } void ProxyClientApp::showProxyDialog() { - Logger::Trace("Creating proxy dialog.\n"); - ProxyDialog *dialog = new ProxyDialog(); - dialog->show(); + dialog = new ProxyDialog(); + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->show(); } void ProxyClientApp::configUpdated() diff --git a/client/ProxyClientApp.h b/client/ProxyClientApp.h index 3901adb..60b8de6 100644 --- a/client/ProxyClientApp.h +++ b/client/ProxyClientApp.h @@ -5,6 +5,7 @@ #include <QSystemTrayIcon> #include <QApplication> +#include "Dialog.h" #include "FileOpThread.h" @@ -21,12 +22,13 @@ public: private slots: void trayActivated(QSystemTrayIcon::ActivationReason reason); - void showProxyDialog(); - void configUpdated(); + void showProxyDialog(); + void configUpdated(); void quitApp(); private: QSystemTrayIcon *trayIcon; + ProxyDialog *dialog; FileOpThread fileOpThread; }; diff --git a/client/SslClient.cpp b/client/SslClient.cpp index 64f63ac..b052ed4 100644 --- a/client/SslClient.cpp +++ b/client/SslClient.cpp @@ -220,7 +220,7 @@ void SslClient::DataRecieved() return; } - /* +/* fprintf(Logger::logFile, "[ "); const char * tmp = pkt.constData(); for (int i = 0; i < pkt.size(); i++) @@ -235,7 +235,7 @@ void SslClient::DataRecieved() } } fprintf(Logger::logFile, "]\n"); - */ +*/ /* remove header and tail */ pkt.remove(pkt.size()-3, 3); diff --git a/client/client.qrc b/client/client.qrc index 145a45c..4837528 100644 --- a/client/client.qrc +++ b/client/client.qrc @@ -3,6 +3,6 @@ <file>client.key</file> <file>client.crt</file> <file>ca.crt</file> - <file>icon.png</file> + <file>icon.png</file> </qresource> </RCC> diff --git a/client/config.cfg b/client/config.cfg index 892f44c..4039d17 100644 --- a/client/config.cfg +++ b/client/config.cfg @@ -1,11 +1,9 @@ -config_update_interval=300;
+config_update_interval=150;
client_update_interval=60000;
-server=195.211.188.1 10 10;
-server=192.168.1.100 600 60;
+server=127.0.0.1 10;
welcome_msg=Welcome to the proxy configurator!;
-config_downloaded_msg=Config downloaded successfully;
top_panel_text=Top Panel;
-bottom_panel_text=Bottom Panel;
+bottom_panel_text=Bottom Text;
speed_visibility=1;
-proxifier_exe=C:\ProxifierPortable\Proxifier.exe;
-proxifier_profile=C:\ProxifierPortable\Profiles\invwar.ppx;
+proxifier_exe=C:\Proxifier\Proxifier.exe;
+proxifier_profile=C:\Proxifier\Profiles\invwar.ppx;
|