Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Commit

Permalink
api: Add plugin events to show/hide contact list
Browse files Browse the repository at this point in the history
Adds fifo commands to show and hide the Qt4-Gui main window.
  • Loading branch information
flynd committed Dec 21, 2011
1 parent ab59e4c commit 5a2bd4d
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 15 deletions.
1 change: 1 addition & 0 deletions 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


Expand Down
2 changes: 2 additions & 0 deletions licq/include/licq/pluginsignal.h
Expand Up @@ -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
};

/**
Expand Down
22 changes: 22 additions & 0 deletions licq/src/fifo.cpp
Expand Up @@ -121,6 +121,12 @@ static const char* const HELP_UIVIEWEVENT = tr(
static const char* const HELP_UIMESSAGE = tr(
"\tui_message <buddy>\n"
"\t\tOpen the plugin message composer to <buddy>\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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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},
Expand Down
33 changes: 18 additions & 15 deletions qt4-gui/src/core/mainwin.cpp
Expand Up @@ -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());
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions qt4-gui/src/core/mainwin.h
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions qt4-gui/src/core/signalmanager.cpp
Expand Up @@ -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;
}
Expand Down
11 changes: 11 additions & 0 deletions qt4-gui/src/core/signalmanager.h
Expand Up @@ -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);

/**
Expand Down

0 comments on commit 5a2bd4d

Please sign in to comment.