Refactor the markerline into a proper QGraphicsWidget
[quassel.git] / src / qtui / statusnotifieritem.cpp
index 9d61fa7..8d7972f 100644 (file)
@@ -54,7 +54,9 @@ void StatusNotifierItem::init() {
   qDBusRegisterMetaType<DBusToolTipStruct>();
 
   _statusNotifierItemDBus = new StatusNotifierItemDBus(this);
+
   connect(this, SIGNAL(toolTipChanged(QString,QString)), _statusNotifierItemDBus, SIGNAL(NewToolTip()));
+  connect(this, SIGNAL(animationEnabledChanged(bool)), _statusNotifierItemDBus, SIGNAL(NewAttentionIcon()));
 
   connect(QDBusConnection::sessionBus().interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
                                                      SLOT(serviceChange(QString,QString,QString)));
@@ -133,6 +135,20 @@ void StatusNotifierItem::serviceChange(const QString& name, const QString& oldOw
   }
 }
 
+bool StatusNotifierItem::isSystemTrayAvailable() const {
+  if(mode() == StatusNotifier)
+    return true; // else it should be set to legacy on registration
+
+  return StatusNotifierItemParent::isSystemTrayAvailable();
+}
+
+bool StatusNotifierItem::isVisible() const {
+  if(mode() == StatusNotifier)
+    return shouldBeVisible(); // we don't have a way to check, so we need to trust everything went right
+
+  return StatusNotifierItemParent::isVisible();
+}
+
 void StatusNotifierItem::setMode(Mode mode_) {
   StatusNotifierItemParent::setMode(mode_);
 
@@ -148,6 +164,21 @@ void StatusNotifierItem::setState(State state_) {
   emit _statusNotifierItemDBus->NewIcon();
 }
 
+void StatusNotifierItem::setVisible(bool visible) {
+  LegacySystemTray::setVisible(visible);
+
+  if(mode() == StatusNotifier) {
+    if(shouldBeVisible()) {
+      _statusNotifierItemDBus->registerService();
+      registerToDaemon();
+    } else {
+      _statusNotifierItemDBus->unregisterService();
+      _statusNotifierWatcher->deleteLater();
+      _statusNotifierWatcher = 0;
+    }
+  }
+}
+
 QString StatusNotifierItem::title() const {
   return QString("Quassel IRC");
 }
@@ -160,7 +191,10 @@ QString StatusNotifierItem::iconName() const {
 }
 
 QString StatusNotifierItem::attentionIconName() const {
-  return QString("quassel_message");
+  if(animationEnabled())
+    return QString("quassel_message");
+  else
+    return QString("quassel");
 }
 
 QString StatusNotifierItem::toolTipIconName() const {