From db10b50c84a4aaf5014e0f164b3f4f79ca222429 Mon Sep 17 00:00:00 2001 From: Alex Borisov Date: Sat, 24 Mar 2012 00:28:40 +0200 Subject: FIX: speed calc problem, tray click fix, other --- client/Dialog.cpp | 21 +++++++++++++-------- client/Logger.cpp | 4 ++-- client/Proxy.cpp | 2 +- client/ProxyClientApp.cpp | 28 ++++++++++++++++++++-------- client/ProxyClientApp.h | 6 ++++-- client/SslClient.cpp | 4 ++-- client/client.qrc | 2 +- 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 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 << "" << staticProxyLine[j].speed << ""; + btnStr = QString("") + + QString::number(speed, 'f', 3) + + QString(""); } else { - ss << "" << staticProxyLine[j].speed << ""; + btnStr = QString("") + + QString::number(speed, 'f', 3) + + QString(""); } - 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 #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 #include +#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 @@ client.key client.crt ca.crt - icon.png + icon.png 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; -- cgit v1.2.3 From 23f69b08e46c6101cbcba2f8c9592aa14bf1dccd Mon Sep 17 00:00:00 2001 From: Alex Borisov Date: Sat, 24 Mar 2012 00:31:17 +0200 Subject: Turn back file logging facility --- client/Logger.cpp | 2 -- client/SslClient.cpp | 2 -- 2 files changed, 4 deletions(-) diff --git a/client/Logger.cpp b/client/Logger.cpp index c8661bc..63c4d8f 100644 --- a/client/Logger.cpp +++ b/client/Logger.cpp @@ -15,13 +15,11 @@ 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/SslClient.cpp b/client/SslClient.cpp index b052ed4..d3eb9a9 100644 --- a/client/SslClient.cpp +++ b/client/SslClient.cpp @@ -220,7 +220,6 @@ void SslClient::DataRecieved() return; } -/* fprintf(Logger::logFile, "[ "); const char * tmp = pkt.constData(); for (int i = 0; i < pkt.size(); i++) @@ -235,7 +234,6 @@ void SslClient::DataRecieved() } } fprintf(Logger::logFile, "]\n"); -*/ /* remove header and tail */ pkt.remove(pkt.size()-3, 3); -- cgit v1.2.3