diff options
author | Luboš Doležel <lubos@dolezel.info> | 2016-10-07 10:00:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-07 10:00:58 +0200 |
commit | 78118a7bcf5fdbf3ceea368d44c321631baa8d24 (patch) | |
tree | fc84640122cd8a86f5709273c2a631b84e7d51a4 | |
parent | 38ff020afe607a08b147bd281a30b3b16527d802 (diff) | |
parent | b7a591acf16e18cf5258a70f3e0115d3318f8434 (diff) | |
download | twinkle-78118a7bcf5fdbf3ceea368d44c321631baa8d24.tar twinkle-78118a7bcf5fdbf3ceea368d44c321631baa8d24.tar.gz twinkle-78118a7bcf5fdbf3ceea368d44c321631baa8d24.tar.lz twinkle-78118a7bcf5fdbf3ceea368d44c321631baa8d24.tar.xz twinkle-78118a7bcf5fdbf3ceea368d44c321631baa8d24.zip |
Merge pull request #84 from fbriere/issue/82-gui-thread-call-show-hide
Have --call/show/hide invoke methods in the GUI thread
-rw-r--r-- | src/gui/gui.cpp | 78 | ||||
-rw-r--r-- | src/gui/gui.h | 4 |
2 files changed, 47 insertions, 35 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index a87315a..ac14edd 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -730,6 +730,44 @@ void t_gui::gui_do_user(const QString &profile_name) } } +void t_gui::gui_cmd_call(const string &destination, bool immediate) { + string subject; + string dst_no_headers; + t_display_url du; + + t_user *user = phone->ref_user_profile( + mainWindow->userComboBox->currentText().toStdString()); + expand_destination(user, destination, du, subject, dst_no_headers); + if (!du.is_valid()) return; + + 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); + } +} + +void t_gui::gui_cmd_show(void) { + if (mainWindow->isMinimized()) { + mainWindow->setWindowState((mainWindow->windowState() & ~Qt::WindowMinimized) | + Qt::WindowActive); + mainWindow->raise(); + } else { + mainWindow->show(); + mainWindow->raise(); + mainWindow->activateWindow(); + } +} + +void t_gui::gui_cmd_hide(void) { + if (sys_config->get_gui_use_systray()) { + mainWindow->hide(); + } else { + mainWindow->setWindowState(mainWindow->windowState() | Qt::WindowMinimized); + } +} + ///////////////////////////////////////////////// // PUBLIC ///////////////////////////////////////////////// @@ -2774,23 +2812,9 @@ 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) { - string subject; - string dst_no_headers; - t_display_url du; - - t_user *user = phone->ref_user_profile( - mainWindow->userComboBox->currentText().toStdString()); - 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(); + QMetaObject::invokeMethod(this, "gui_cmd_call", + Q_ARG(const string&, destination), + Q_ARG(bool, immediate)); } void t_gui::cmd_quit(void) { @@ -2800,27 +2824,11 @@ void t_gui::cmd_quit(void) { } void t_gui::cmd_show(void) { - lock(); - if (mainWindow->isMinimized()) { - mainWindow->setWindowState((mainWindow->windowState() & ~Qt::WindowMinimized) | - Qt::WindowActive); - mainWindow->raise(); - } else { - mainWindow->show(); - mainWindow->raise(); - mainWindow->activateWindow(); - } - unlock(); + QMetaObject::invokeMethod(this, "gui_cmd_show"); } void t_gui::cmd_hide(void) { - lock(); - if (sys_config->get_gui_use_systray()) { - mainWindow->hide(); - } else { - mainWindow->setWindowState(mainWindow->windowState() | Qt::WindowMinimized); - } - unlock(); + QMetaObject::invokeMethod(this, "gui_cmd_hide"); } 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(); |