From ab83223e1b5c7d34855d091e0c868462bd9452d1 Mon Sep 17 00:00:00 2001 From: Lubos Dolezel Date: Tue, 2 Jun 2015 19:32:25 +0200 Subject: Twinkle now compiles with Qt4 uic, but crashes at runtime (due to GUI calls from outside the main thread) --- src/gui/inviteform.cpp | 167 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 src/gui/inviteform.cpp (limited to 'src/gui/inviteform.cpp') diff --git a/src/gui/inviteform.cpp b/src/gui/inviteform.cpp new file mode 100644 index 0000000..0ec1ddd --- /dev/null +++ b/src/gui/inviteform.cpp @@ -0,0 +1,167 @@ +#include "inviteform.h" +//Added by qt3to4: +#include +#include "gui.h" +#include "util.h" +#include "audits/memman.h" +#include "sys_settings.h" +#include +#include + +/* + Copyright (C) 2005-2009 Michel de Boer + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +InviteForm::InviteForm(QWidget *parent, const char *name, bool modal) + : QDialog(parent, name, modal) +{ + setupUi(this); + init(); +} + +InviteForm::~InviteForm() +{ + destroy(); +} + +void InviteForm::init() +{ + getAddressForm = 0; + + // Set toolbutton icons for disabled options. + setDisabledIcon(addressToolButton, ":/icons/images/kontact_contacts-disabled.png"); + + // A QComboBox accepts a new line through copy/paste. + QRegExp rxNoNewLine("[^\\n\\r]*"); + inviteComboBox->setValidator(new QRegExpValidator(rxNoNewLine, this)); +} + +void InviteForm::destroy() +{ + if (getAddressForm) { + MEMMAN_DELETE(getAddressForm); + delete getAddressForm; + } +} + +void InviteForm::clear() +{ + inviteComboBox->clearEdit(); + subjectLineEdit->clear(); + hideUserCheckBox->setChecked(false); + inviteComboBox->setFocus(); +} + +void InviteForm::show(t_user *user_config, const QString &dest, const QString &subject, + bool anonymous) +{ + ((t_gui *)ui)->fill_user_combo(fromComboBox); + + // Select from user + if (user_config) { + for (int i = 0; i < fromComboBox->count(); i++) { + if (fromComboBox->text(i) == + user_config->get_profile_name().c_str()) + { + fromComboBox->setCurrentItem(i); + break; + } + } + } + + inviteComboBox->setEditText(dest); + subjectLineEdit->setText(subject); + hideUserCheckBox->setChecked(anonymous); + QDialog::show(); +} + +void InviteForm::validate() +{ + string display, dest_str; + t_user *from_user = phone->ref_user_profile( + fromComboBox->currentText().ascii()); + + ui->expand_destination(from_user, + inviteComboBox->currentText().stripWhiteSpace().ascii(), + display, dest_str); + t_url dest(dest_str); + + if (dest.is_valid()) { + addToInviteComboBox(inviteComboBox->currentText()); + emit raw_destination(inviteComboBox->currentText()); + emit destination(from_user, display.c_str(), dest, subjectLineEdit->text(), + hideUserCheckBox->isChecked()); + accept(); + } else { + inviteComboBox->setFocus(); + inviteComboBox->lineEdit()->selectAll(); + } +} + +// Add a destination to the history list of inviteComboBox +void InviteForm::addToInviteComboBox(const QString &destination) +{ + inviteComboBox->insertItem(destination, 0); + if (inviteComboBox->count() > SIZE_REDIAL_LIST) { + inviteComboBox->removeItem(inviteComboBox->count() - 1); + } +} + + +void InviteForm::reject() +{ + // Unseize the line + ((t_gui *)ui)->action_unseize(); + QDialog::reject(); +} + +void InviteForm::closeEvent(QCloseEvent *) +{ + reject(); +} + +void InviteForm::showAddressBook() +{ + if (!getAddressForm) { + getAddressForm = new GetAddressForm( + this, "select address", true); + MEMMAN_NEW(getAddressForm); + } + + connect(getAddressForm, + SIGNAL(address(const QString &)), + this, SLOT(selectedAddress(const QString &))); + + getAddressForm->show(); +} + +void InviteForm::selectedAddress(const QString &address) +{ + inviteComboBox->setEditText(address); +} + +void InviteForm::warnHideUser(void) { + // Warn only once + if (!sys_config->get_warn_hide_user()) return; + + QString msg = tr("Not all SIP providers support identity hiding. Make sure your SIP provider " + "supports it if you really need it."); + ((t_gui *)ui)->cb_show_msg(this, msg.ascii(), MSG_WARNING); + + // Do not warn again + sys_config->set_warn_hide_user(false); +} -- cgit v1.2.3