[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [vidalia/master] Flash Message Log button when a warn status event happens



commit b61cca2c672532ff2bc8f54df06ac35d85f623c4
Author: Tomás Touceda <chiiph@xxxxxxxxxxxxxx>
Date:   Wed Mar 7 12:44:48 2012 -0300

    Flash Message Log button when a warn status event happens
---
 changes/bug3957             |    2 ++
 src/vidalia/MainWindow.cpp  |   31 +++++++++++++++++++++++++++++++
 src/vidalia/MainWindow.h    |    9 +++++++++
 src/vidalia/VClickLabel.cpp |   25 +++++++++++++++++++++++++
 src/vidalia/VClickLabel.h   |    7 +++++++
 5 files changed, 74 insertions(+), 0 deletions(-)

diff --git a/changes/bug3957 b/changes/bug3957
new file mode 100644
index 0000000..36e3d61
--- /dev/null
+++ b/changes/bug3957
@@ -0,0 +1,2 @@
+  o Notify users that a warning status event has appeared by flashing
+    the Message Log button. Fixes bug 3957.
\ No newline at end of file
diff --git a/src/vidalia/MainWindow.cpp b/src/vidalia/MainWindow.cpp
index a23478e..e45919d 100644
--- a/src/vidalia/MainWindow.cpp
+++ b/src/vidalia/MainWindow.cpp
@@ -105,6 +105,8 @@ MainWindow::MainWindow()
 
   ui.setupUi(this);
 
+  _warnTimer = new QTimer();
+
   /* Pressing 'Esc' or 'Ctrl+W' will close the window */
   Vidalia::createShortcut("Ctrl+W", this, ui.btnHide, SLOT(click()));
   Vidalia::createShortcut("Esc", this, ui.btnHide, SLOT(click()));
@@ -162,6 +164,8 @@ MainWindow::MainWindow()
           this, SLOT(circuitEstablished()));
   connect(_torControl, SIGNAL(dangerousPort(quint16, bool)),
           this, SLOT(warnDangerousPort(quint16, bool)));
+  connect(_torControl, SIGNAL(logMessage(tc::Severity, QString)),
+          this, SLOT(log(tc::Severity, QString)));
 
   /* Create a new HelperProcess object, used to start the web browser */
   _browserProcess = new HelperProcess(this);
@@ -186,6 +190,8 @@ MainWindow::MainWindow()
   connect(vApp, SIGNAL(running()), this, SLOT(running()));
   connect(vApp, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()));
 
+  connect(_warnTimer, SIGNAL(timeout()), this, SLOT(warnButton()));
+
 #if defined(USE_AUTOUPDATE)
   /* Create a timer used to remind us to check for software updates */
   connect(&_updateTimer, SIGNAL(timeout()), this, SLOT(checkForUpdates()));
@@ -229,6 +235,8 @@ MainWindow::MainWindow()
   /* Vidalia launched in background (LSUIElement=true). Bring to foreground. */
   VidaliaWindow::setVisible(true);
 #endif
+
+  _flashToggle = false;
 }
 
 /** Destructor. */
@@ -439,6 +447,10 @@ MainWindow::createActions()
           _messageLog, SLOT(showWindow()));
   connect(ui.lblMessageLog, SIGNAL(clicked()),
           _messageLog, SLOT(showWindow()));
+  connect(ui.lblMessageLog, SIGNAL(clicked()),
+          _warnTimer, SLOT(stop()));
+  connect(ui.lblMessageLog, SIGNAL(clicked()),
+          ui.lblMessageLog, SLOT(disableFlashing()));
 
   _actionShowNetworkMap = new QAction(tr("Network Map"), this);
   connect(_actionShowNetworkMap, SIGNAL(triggered()), 
@@ -2122,3 +2134,22 @@ MainWindow::updateBrowserEnv() {
 
   return env;
 }
+
+void
+MainWindow::log(tc::Severity type, const QString &message)
+{
+  if(type == tc::WarnSeverity)
+    _warnTimer->start(1000);
+}
+
+void
+MainWindow::warnButton()
+{
+  if(_flashToggle) {
+    ui.lblMessageLog->enableFlashing();
+  } else {
+    ui.lblMessageLog->disableFlashing();
+  }
+
+  _flashToggle = !_flashToggle;
+}
diff --git a/src/vidalia/MainWindow.h b/src/vidalia/MainWindow.h
index dc251e1..f13fee8 100644
--- a/src/vidalia/MainWindow.h
+++ b/src/vidalia/MainWindow.h
@@ -143,6 +143,11 @@ private slots:
                            const QString &version,
                            const QStringList &recommended);
 
+  /** Called when torControl emits logMessage() */
+  void log(tc::Severity type, const QString &message);
+  /** Toggles the color for the Message Log button */
+  void warnButton();
+
 #if defined(USE_AUTOUPDATE)
   /** Called when the user clicks the 'Check Now' button in the General
    * settings page. */
@@ -290,6 +295,10 @@ private:
 
   quint16 _autoControlPort;
 
+  /** Timer and bool used to flash buttons with a different color */
+  QTimer *_warnTimer;
+  bool _flashToggle;
+
   Ui::MainWindow ui; /**< Qt Designer generated object. */
 };
 
diff --git a/src/vidalia/VClickLabel.cpp b/src/vidalia/VClickLabel.cpp
index 9691a52..3166ee2 100644
--- a/src/vidalia/VClickLabel.cpp
+++ b/src/vidalia/VClickLabel.cpp
@@ -24,6 +24,7 @@ VClickLabel::VClickLabel(QWidget *parent)
  : QWidget(parent)
 {
   setCursor(Qt::PointingHandCursor);
+  _flashToggle = false;
 }
 
 /** Returns the current size hint for this widget's current contents. */
@@ -49,6 +50,17 @@ VClickLabel::paintEvent(QPaintEvent *e)
   QPainter p(this);
   QRect rect = this->rect();
 
+  if(_flashToggle) {
+    p.setBrush(QColor(150,150,150));
+    rect.setX(rect.x()+1);
+    rect.setY(rect.y()+1);
+    rect.setWidth(rect.width());
+    rect.setHeight(rect.height());
+    p.drawRect(rect);
+  }
+
+  rect = this->rect();
+
   if (vApp->isLeftToRight()) {
     if (!_pixmap.isNull())
       p.drawPixmap(0, qMax((rect.height()-_pixmap.height())/2, 0), _pixmap);
@@ -93,3 +105,16 @@ VClickLabel::setPixmap(const QPixmap &pixmap)
   update();
 }
 
+void
+VClickLabel::enableFlashing()
+{
+  _flashToggle = true;
+  repaint();
+}
+
+void
+VClickLabel::disableFlashing()
+{
+  _flashToggle = false;
+  repaint();
+}
diff --git a/src/vidalia/VClickLabel.h b/src/vidalia/VClickLabel.h
index 2f3e677..23a2b74 100644
--- a/src/vidalia/VClickLabel.h
+++ b/src/vidalia/VClickLabel.h
@@ -46,6 +46,12 @@ public:
   Q_PROPERTY(QString text READ text WRITE setText USER true);
   Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap USER true);
 
+public slots:
+  /** Enables painting a different background color for this label */
+  void enableFlashing();
+  /** Disables the background color modification */
+  void disableFlashing();
+
 signals:
   /** Emitted when the widget is left-clicked. */
   void clicked();
@@ -59,6 +65,7 @@ protected:
 private:
   QString _text;    /**< Text label to display in the widget. */
   QPixmap _pixmap;  /**< Image to display in the widget. */
+  bool _flashToggle;/**< Bool toggle for flashing the button. */
 };
 
 #endif

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits