From 5a2bd4da786e1bdf28c8da8bfddb501e87f10268 Mon Sep 17 00:00:00 2001 From: Anders Olofsson Date: Wed, 21 Dec 2011 20:30:03 +0100 Subject: [PATCH] api: Add plugin events to show/hide contact list Adds fifo commands to show and hide the Qt4-Gui main window. --- licq/doc/CHANGELOG | 1 + licq/include/licq/pluginsignal.h | 2 ++ licq/src/fifo.cpp | 22 ++++++++++++++++++++ qt4-gui/src/core/mainwin.cpp | 33 ++++++++++++++++-------------- qt4-gui/src/core/mainwin.h | 6 ++++++ qt4-gui/src/core/signalmanager.cpp | 8 ++++++++ qt4-gui/src/core/signalmanager.h | 11 ++++++++++ 7 files changed, 68 insertions(+), 15 deletions(-) diff --git a/licq/doc/CHANGELOG b/licq/doc/CHANGELOG index 90a9955d0..1fbb516de 100644 --- a/licq/doc/CHANGELOG +++ b/licq/doc/CHANGELOG @@ -1,6 +1,7 @@ Change log for Licq. New in 1.7.0 +o Fifo: Added commands to show/hide UI contact list window o Qt4-Gui: Moved debug level menu to log window diff --git a/licq/include/licq/pluginsignal.h b/licq/include/licq/pluginsignal.h index 4ad7ae3d8..57c152ec4 100644 --- a/licq/include/licq/pluginsignal.h +++ b/licq/include/licq/pluginsignal.h @@ -98,6 +98,8 @@ class PluginSignal { PluginViewEvent = 1, // UI should popup oldest unread event for userId (if set) PluginStartMessage = 2, // UI should open message dialog for userId + PluginShowUserList = 3, // UI should show (if hidden) and raise contact list + PluginHideUserList = 4, // UI should hide contact list }; /** diff --git a/licq/src/fifo.cpp b/licq/src/fifo.cpp index 310323c72..a80a1e5cb 100644 --- a/licq/src/fifo.cpp +++ b/licq/src/fifo.cpp @@ -121,6 +121,12 @@ static const char* const HELP_UIVIEWEVENT = tr( static const char* const HELP_UIMESSAGE = tr( "\tui_message \n" "\t\tOpen the plugin message composer to \n"); +static const char* const HELP_UISHOWUSERLIST = tr( + "\tui_showuserlist\n" + "\t\tShow and raise the contact list window\n"); +static const char* const HELP_UIHIDEUSERLIST = tr( + "\tui_hideuserlist\n" + "\t\tHide the contact list window\n"); static const char* const HELP_PLUGINLIST = tr( "\tlist_plugins\n" "\t\tLists the loaded UI plugins\n"); @@ -684,6 +690,20 @@ static int fifo_ui_message(int argc, const char* const* argv) return nRet; } +static int fifo_ui_showuserlist(int /* argc */, const char* const* /* argv */) +{ + gPluginManager.pushPluginSignal(new PluginSignal(PluginSignal::SignalPluginEvent, + PluginSignal::PluginShowUserList)); + return 0; +} + +static int fifo_ui_hideuserlist(int /* argc */, const char* const* /* argv */) +{ + gPluginManager.pushPluginSignal(new PluginSignal(PluginSignal::SignalPluginEvent, + PluginSignal::PluginHideUserList)); + return 0; +} + static int fifo_plugin_list(int /* argc */, const char* const* /* argv */) { Licq::GeneralPluginsList plugins; @@ -802,6 +822,8 @@ static struct command_t fifocmd_table[]= {"exit", fifo_exit, HELP_EXIT}, {"ui_viewevent", fifo_ui_viewevent, HELP_UIVIEWEVENT}, {"ui_message", fifo_ui_message, HELP_UIMESSAGE}, + {"ui_showuserlist", fifo_ui_showuserlist, HELP_UISHOWUSERLIST}, + {"ui_hideuserlist", fifo_ui_hideuserlist, HELP_UIHIDEUSERLIST}, {"list_plugins", fifo_plugin_list, HELP_PLUGINLIST}, {"load_plugin", fifo_plugin_load, HELP_PLUGINLOAD}, {"unload_plugin", fifo_plugin_unload, HELP_PLUGINUNLOAD}, diff --git a/qt4-gui/src/core/mainwin.cpp b/qt4-gui/src/core/mainwin.cpp index c2801063f..e49cb9d51 100644 --- a/qt4-gui/src/core/mainwin.cpp +++ b/qt4-gui/src/core/mainwin.cpp @@ -234,6 +234,8 @@ MainWindow::MainWindow(bool bStartHidden, QWidget* parent) mySystemMenu, SLOT(addOwner(const Licq::UserId&))); connect(gGuiSignalManager, SIGNAL(ownerRemoved(const Licq::UserId&)), mySystemMenu, SLOT(removeOwner(const Licq::UserId&))); + connect(gGuiSignalManager, SIGNAL(ui_showuserlist()), SLOT(unhide())); + connect(gGuiSignalManager, SIGNAL(ui_hideuserlist()), SLOT(hide())); if (conf->mainwinRect().isValid()) setGeometry(conf->mainwinRect()); @@ -350,27 +352,28 @@ void MainWindow::updateShortcuts() void MainWindow::trayIconClicked() { if (isVisible() && !isMinimized() && isActiveWindow()) - { hide(); - } else - { - show(); + unhide(); +} + +void MainWindow::unhide() +{ + show(); #ifdef USE_KDE - KWindowSystem::setOnDesktop(winId(), KWindowSystem::currentDesktop()); + KWindowSystem::setOnDesktop(winId(), KWindowSystem::currentDesktop()); #endif - if (isMaximized()) - showMaximized(); - else - showNormal(); + if (isMaximized()) + showMaximized(); + else + showNormal(); - // Sticky state is lost when window is hidden so restore it now - if (Config::General::instance()->mainwinSticky()) - setMainwinSticky(true); + // Sticky state is lost when window is hidden so restore it now + if (Config::General::instance()->mainwinSticky()) + setMainwinSticky(true); - activateWindow(); - raise(); - } + activateWindow(); + raise(); } void MainWindow::updateSkin() diff --git a/qt4-gui/src/core/mainwin.h b/qt4-gui/src/core/mainwin.h index 5ccf85217..05ad9afd8 100644 --- a/qt4-gui/src/core/mainwin.h +++ b/qt4-gui/src/core/mainwin.h @@ -115,6 +115,12 @@ public slots: void showAutoResponseHints(QWidget* parent = 0); void hide(); + /** + * Show and raise main window + * Also restore properties that are lost on hide + */ + void unhide(); + private: QString myCaption; bool myInMiniMode; diff --git a/qt4-gui/src/core/signalmanager.cpp b/qt4-gui/src/core/signalmanager.cpp index 6fea28bc5..c46325a19 100644 --- a/qt4-gui/src/core/signalmanager.cpp +++ b/qt4-gui/src/core/signalmanager.cpp @@ -111,6 +111,14 @@ void SignalManager::ProcessSignal(Licq::PluginSignal* sig) case Licq::PluginSignal::PluginStartMessage: emit ui_message(userId); break; + + case Licq::PluginSignal::PluginShowUserList: + emit ui_showuserlist(); + break; + + case Licq::PluginSignal::PluginHideUserList: + emit ui_hideuserlist(); + break; } break; } diff --git a/qt4-gui/src/core/signalmanager.h b/qt4-gui/src/core/signalmanager.h index c1e57724a..bf3f2e58c 100644 --- a/qt4-gui/src/core/signalmanager.h +++ b/qt4-gui/src/core/signalmanager.h @@ -89,6 +89,17 @@ class SignalManager: public QObject * @param userId User to open dialog for */ void ui_message(const Licq::UserId& userId); + + /** + * Show and raise the user list (main window) + */ + void ui_showuserlist(); + + /** + * Hide the user list (main window) + */ + void ui_hideuserlist(); + void protocolPlugin(unsigned long); /**