[Konversation-devel] [Bug 247263] Konversation lacks a shortcut to Toggle Main Window

Eike Hein hein at kde.org
Tue Aug 10 21:32:34 CEST 2010


https://bugs.kde.org/show_bug.cgi?id=247263


Eike Hein <hein at kde.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED




--- Comment #2 from Eike Hein <hein kde org>  2010-08-10 21:32:28 ---
commit 1e59b7b1a41ba268ca27c332d6d384c1acfc4493
Author: Eike Hein <hein at kde.org>
Date:   Tue Aug 10 21:32:25 2010 +0200

    Add an action to show/hide the main window.

    BUG:247263

diff --git a/ChangeLog b/ChangeLog
index 0eb8e89..ffe288a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -117,6 +117,9 @@ Changes since 1.3.1:
   - Average spreed of link detection has improved slightly.
 * Incoming actions (i.e. "/me") without an argument are now handled properly.
 * Fixed a number of crashes on illegal data from the server.
+* Added a "Show/Hide Konversation" action that can be used to toggle the
+  minimized state of the Konversation window or, if the tray icon is enabled,
+  its visibility.


 Changes from 1.3 to 1.3.1:
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 35e16c7..caf8b32 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -486,6 +486,12 @@ MainWindow::MainWindow() : KXmlGuiWindow(0)
     connect(toggleChannelNickListsAction, SIGNAL(triggered()),
m_viewContainer, SLOT(toggleChannelNicklists()));
     actionCollection()->addAction("hide_nicknamelist",
toggleChannelNickListsAction);

+    action=new KAction(this);
+    action->setText(i18n("Show/Hide Konversation"));
+    connect(action, SIGNAL(triggered()), this, SLOT(toggleVisibility()));
+    actionCollection()->addAction("toggle_mainwindow_visibility", action);
+    action->setGlobalShortcut(KShortcut());
+
     // Bookmarks
     KActionMenu *bookmarkMenu = new KActionMenu(i18n("Bookmarks"),
actionCollection());
     new KonviBookmarkHandler(bookmarkMenu->menu(), this);
@@ -844,4 +850,22 @@ void MainWindow::setOnlineList(Server* notifyServer,const
QStringList& /*list*/,
     // FIXME  if (changed && nicksOnlinePanel) newText(nicksOnlinePanel,
QString::null, true);
 }

+void MainWindow::toggleVisibility()
+{
+    if (isMinimized())
+    {
+        KWindowSystem::unminimizeWindow(winId());
+        KWindowSystem::activateWindow(winId());
+    }
+    else if (isVisible())
+    {
+        if (Preferences::self()->showTrayIcon())
+            hide();
+        else
+            KWindowSystem::minimizeWindow(winId());
+    }
+    else if (Preferences::self()->showTrayIcon())
+        m_trayIcon->restore();
+}
+
 #include "mainwindow.moc"
diff --git a/src/mainwindow.h b/src/mainwindow.h
index cac6526..8cff7ba 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -109,6 +109,8 @@ class MainWindow : public KXmlGuiWindow
         void openNotifications();
         void notifyAction(int connectionId,const QString& nick);

+        void toggleVisibility();
+
         void showEvent(QShowEvent* e);
         void hideEvent(QHideEvent* e);
         void leaveEvent(QEvent* e);
diff --git a/src/viewer/trayicon.h b/src/viewer/trayicon.h
index de99b05..418868d 100644
--- a/src/viewer/trayicon.h
+++ b/src/viewer/trayicon.h
@@ -34,13 +34,15 @@ namespace Konversation
 #endif
     {
         Q_OBJECT
-        
+
         public:
             explicit TrayIcon(QWidget* parent = 0);
             ~TrayIcon();

             bool notificationEnabled() { return m_notificationEnabled; }

+            void restore();
+
         public slots:
             void startNotification();
             void endNotification();
diff --git a/src/viewer/trayiconkstatusnotifieritem.cpp
b/src/viewer/trayiconkstatusnotifieritem.cpp
index 250c005..9982e18 100644
--- a/src/viewer/trayiconkstatusnotifieritem.cpp
+++ b/src/viewer/trayiconkstatusnotifieritem.cpp
@@ -18,7 +18,7 @@ namespace Konversation
         setStatus(Active);

         m_notificationEnabled = false;
-        
+
         updateAppearance();

         setToolTip("konversation", i18n("Konversation"), i18n("Konversation -
IRC Client"));
@@ -28,6 +28,11 @@ namespace Konversation
     {
     }

+    void TrayIcon::restore()
+    {
+        activate(QPoint());
+    }
+
     void TrayIcon::startNotification()
     {
         if (!m_notificationEnabled)
@@ -42,12 +47,12 @@ namespace Konversation
     {
         setStatus(Active);
     }
-    
+
     void TrayIcon::updateAppearance()
     {
         m_nomessagePix = "konversation";
         m_messagePix = "konv_message";
-        
+
         setIconByName(m_nomessagePix);
         setAttentionIconByName(m_messagePix);
     }
diff --git a/src/viewer/trayiconksystemtray.cpp
b/src/viewer/trayiconksystemtray.cpp
index f72e389..4b60381 100644
--- a/src/viewer/trayiconksystemtray.cpp
+++ b/src/viewer/trayiconksystemtray.cpp
@@ -38,6 +38,11 @@ namespace Konversation
     {
     }

+    void TrayIcon::restore()
+    {
+        toggleActive();
+    }
+
     void TrayIcon::startNotification()
     {
         if(!m_notificationEnabled)
@@ -80,13 +85,13 @@ namespace Konversation
             setIcon(m_nomessagePix);
         }
     }
-    
+
     void TrayIcon::updateAppearance()
     {
         m_nomessagePix = loadIcon("konversation");
         m_messagePix = loadIcon("konv_message");
         setIcon(m_nomessagePix);
-        
+
         show();
     }
 }

-- 
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the Konversation-devel mailing list