diff options
author | Frédéric Brière <fbriere@fbriere.net> | 2016-10-04 19:59:10 -0400 |
---|---|---|
committer | Frédéric Brière <fbriere@fbriere.net> | 2016-10-05 20:34:39 -0400 |
commit | 5d35f03d07a9849840561b8eefd29887799dce2d (patch) | |
tree | 3983ee2e9b98ce961b5bcf12921da39cbc30f6d8 /src/gui | |
parent | 38ff020afe607a08b147bd281a30b3b16527d802 (diff) | |
download | twinkle-5d35f03d07a9849840561b8eefd29887799dce2d.tar twinkle-5d35f03d07a9849840561b8eefd29887799dce2d.tar.gz twinkle-5d35f03d07a9849840561b8eefd29887799dce2d.tar.lz twinkle-5d35f03d07a9849840561b8eefd29887799dce2d.tar.xz twinkle-5d35f03d07a9849840561b8eefd29887799dce2d.zip |
Have --call/show/hide invoke methods in the GUI thread
Fixes #82
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui.cpp | 20 | ||||
-rw-r--r-- | src/gui/gui.h | 4 |
2 files changed, 18 insertions, 6 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index a87315a..8d3a126 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -2774,6 +2774,12 @@ void t_gui::cb_im_iscomposing_not_supported(t_user *user_config, t_response *r) } void t_gui::cmd_call(const string &destination, bool immediate) { + QMetaObject::invokeMethod(this, "gui_cmd_call", + Q_ARG(const string&, destination), + Q_ARG(bool, immediate)); +} + +void t_gui::gui_cmd_call(const string &destination, bool immediate) { string subject; string dst_no_headers; t_display_url du; @@ -2783,14 +2789,12 @@ void t_gui::cmd_call(const string &destination, bool immediate) { expand_destination(user, destination, du, subject, dst_no_headers); if (!du.is_valid()) return; - lock(); if (immediate) { mainWindow->do_phoneInvite(user, du.display.c_str(), du.url, subject.c_str(), false); } else { mainWindow->phoneInvite(dst_no_headers.c_str(), subject.c_str(), false); } - unlock(); } void t_gui::cmd_quit(void) { @@ -2800,7 +2804,10 @@ void t_gui::cmd_quit(void) { } void t_gui::cmd_show(void) { - lock(); + QMetaObject::invokeMethod(this, "gui_cmd_show"); +} + +void t_gui::gui_cmd_show(void) { if (mainWindow->isMinimized()) { mainWindow->setWindowState((mainWindow->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); @@ -2810,17 +2817,18 @@ void t_gui::cmd_show(void) { mainWindow->raise(); mainWindow->activateWindow(); } - unlock(); } void t_gui::cmd_hide(void) { - lock(); + QMetaObject::invokeMethod(this, "gui_cmd_hide"); +} + +void t_gui::gui_cmd_hide(void) { if (sys_config->get_gui_use_systray()) { mainWindow->hide(); } else { mainWindow->setWindowState(mainWindow->windowState() | Qt::WindowMinimized); } - unlock(); } string t_gui::get_name_from_abook(t_user *user_config, const t_url &u) { diff --git a/src/gui/gui.h b/src/gui/gui.h index 306404f..3538afb 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -171,6 +171,10 @@ private slots: void gui_do_dtmf(const QString &digits); void gui_do_user(const QString &profile_name); QString gui_get_current_profile(); + + void gui_cmd_call(const string &destination, bool immediate); + void gui_cmd_show(void); + void gui_cmd_hide(void); public: t_gui(t_phone *_phone); virtual ~t_gui(); |