summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Borisov <b0ric.alex@gmail.com>2012-03-24 11:41:57 +0200
committerAlex Borisov <b0ric.alex@gmail.com>2012-03-24 11:41:57 +0200
commitefdd71f35935f8b14abfb26fa852bad77dbd3f9e (patch)
tree6469f2b58673cc2582382b8c7ebea63654f60f4e
parent23f69b08e46c6101cbcba2f8c9592aa14bf1dccd (diff)
Ticket #3 fix (tray click workaround and no windown on taskbar)
-rw-r--r--client/Dialog.cpp34
-rw-r--r--client/Dialog.h6
-rw-r--r--client/ProxyClientApp.cpp32
-rw-r--r--client/ProxyClientApp.h4
4 files changed, 55 insertions, 21 deletions
diff --git a/client/Dialog.cpp b/client/Dialog.cpp
index 2610bea..169d33e 100644
--- a/client/Dialog.cpp
+++ b/client/Dialog.cpp
@@ -11,7 +11,7 @@
using namespace std;
-ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)
+ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent, Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)
{
UpdatedConfig *cfg = UpdatedConfig::CurrentConfig();
@@ -20,8 +20,6 @@ ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent, Qt::FramelessWindowHi
{
Logger::Error("No valid proxifier configuration file found!\n");
}
-
- connect(this, SIGNAL(finished(int)), this, SLOT(Closed(int)));
/* generic proxy panel */
topLabel = new QLabel(QString::fromLocal8Bit(cfg->TopPanelText.c_str()));
@@ -123,6 +121,21 @@ ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent, Qt::FramelessWindowHi
setLayout(mainLayout);
}
+
+bool ProxyDialog::event(QEvent* event)
+{
+ if (event->type() == QEvent::ActivationChange)
+ {
+ Logger::Debug("Activation change\n");
+ if(QApplication::activeWindow() != this)
+ {
+ this->close();
+ }
+ }
+ return QDialog::event(event);
+}
+
+
void ProxyDialog::resizeEvent(QResizeEvent* event)
{
QRect availScreenRect = QApplication::desktop()->availableGeometry();
@@ -131,21 +144,6 @@ void ProxyDialog::resizeEvent(QResizeEvent* event)
}
-void ProxyDialog::Closed(int i)
-{
- Logger::Trace("Dialog closed\n");
- Proxifier *proxifier = Proxifier::GetInstance();
- if (!proxifier->IsValid())
- {
- Logger::Error("No valid proxifier configuration file found!\n");
- return; // do not restart if no config found
- }
- if (!proxifier->ReloadConfig())
- {
- Logger::Error("Unable to restart Proxifier process!\n");
- }
-}
-
void ProxyDialog::ProxyToggled(bool on)
{
QPushButton* btn = (QPushButton*) sender();
diff --git a/client/Dialog.h b/client/Dialog.h
index 2c07747..18fb9e5 100644
--- a/client/Dialog.h
+++ b/client/Dialog.h
@@ -23,13 +23,13 @@ public:
* @brief Create an instance of dialog window
* @param parent parent window
*/
- ProxyDialog(QWidget *parent = 0);
+ ProxyDialog(QWidget* parent = 0);
protected:
- void resizeEvent(QResizeEvent* event);
+ bool event(QEvent* event);
+ void resizeEvent(QResizeEvent* event);
private slots:
- void Closed(int i);
void ProxyToggled(bool on);
void StaticProxyToggled(bool on);
void CountryActivated(int index);
diff --git a/client/ProxyClientApp.cpp b/client/ProxyClientApp.cpp
index c20d232..3b703d8 100644
--- a/client/ProxyClientApp.cpp
+++ b/client/ProxyClientApp.cpp
@@ -11,6 +11,7 @@ using namespace std;
ProxyClientApp::ProxyClientApp(int &argc, char *argv[]): QApplication(argc, argv)
{
dialog = NULL;
+ closeTime = 0;
/* initiates UpdatedConfig singleton that start sending configuration requests */
UpdatedConfig *cfg = UpdatedConfig::CurrentConfig();
@@ -81,6 +82,14 @@ void ProxyClientApp::trayActivated(QSystemTrayIcon::ActivationReason reason)
if (dialog == NULL)
{
+ // part of tray click workaround
+ quint64 time = QDateTime::currentMSecsSinceEpoch();
+ if (time - closeTime < 400)
+ {
+ return;
+ }
+ closeTime = 0;
+
showProxyDialog();
}
else
@@ -95,7 +104,30 @@ void ProxyClientApp::showProxyDialog()
{
dialog = new ProxyDialog();
dialog->setAttribute(Qt::WA_DeleteOnClose);
+ connect(dialog, SIGNAL(finished(int)), this, SLOT(DialogClosed(int)));
dialog->show();
+ dialog->activateWindow();
+
+ closeTime = 0;
+}
+
+void ProxyClientApp::DialogClosed(int result)
+{
+ // part of tray click workaround
+ closeTime = QDateTime::currentMSecsSinceEpoch();
+
+ Logger::Trace("Dialog closed\n");
+ dialog = NULL;
+ Proxifier *proxifier = Proxifier::GetInstance();
+ if (!proxifier->IsValid())
+ {
+ Logger::Error("No valid proxifier configuration file found!\n");
+ return; // do not restart if no config found
+ }
+ if (!proxifier->ReloadConfig())
+ {
+ Logger::Error("Unable to restart Proxifier process!\n");
+ }
}
void ProxyClientApp::configUpdated()
diff --git a/client/ProxyClientApp.h b/client/ProxyClientApp.h
index 60b8de6..cc0a7eb 100644
--- a/client/ProxyClientApp.h
+++ b/client/ProxyClientApp.h
@@ -23,6 +23,7 @@ public:
private slots:
void trayActivated(QSystemTrayIcon::ActivationReason reason);
void showProxyDialog();
+ void DialogClosed(int result);
void configUpdated();
void quitApp();
@@ -30,6 +31,9 @@ private:
QSystemTrayIcon *trayIcon;
ProxyDialog *dialog;
FileOpThread fileOpThread;
+
+ // fucking tray icon workaround
+ quint64 closeTime;
};