/** * Runs all the gumph necessary before hiding a chat. * (checking new messages, setting the autodelete, cancelling composing etc) * \return ChatDlg is ready to be hidden. */ bool ChatDlg::readyToHide() { // really lame way of checking if we are encrypting if (!chatEdit()->isEnabled()) { return false; } if (keepOpen_) { QMessageBox mb(QMessageBox::Information, tr("Warning"), tr("A new chat message was just received.\nDo you still want to close the window?"), QMessageBox::Cancel, this); mb.addButton(tr("Close"), QMessageBox::AcceptRole); if (mb.exec() == QMessageBox::Cancel) { return false; } } // destroy the dialog if delChats is dcClose if (PsiOptions::instance()->getOption("options.ui.chat.delete-contents-after").toString() == "instant") { setAttribute(Qt::WA_DeleteOnClose); } else { if (PsiOptions::instance()->getOption("options.ui.chat.delete-contents-after").toString() == "hour") { setSelfDestruct(60); } else if (PsiOptions::instance()->getOption("options.ui.chat.delete-contents-after").toString() == "day") { setSelfDestruct(60 * 24); } } // Reset 'contact is composing' & cancel own composing event resetComposing(); setChatState(StateGone); if (contactChatState_ == StateComposing || contactChatState_ == StateInactive) { setContactChatState(StatePaused); } if (pending_ > 0) { pending_ = 0; messagesRead(jid()); invalidateTab(); } doFlash(false); chatEdit()->setFocus(); return true; }
void WbDlg::closeEvent(QCloseEvent *e) { e->accept(); if(keepOpen_) { int n = QMessageBox::information(this, tr("Warning"), tr("A new whiteboard message was just received.\nDo you still want to close the window?"), tr("&Yes"), tr("&No")); if(n != 0) { e->ignore(); return; } } // destroy the dialog if delChats is dcClose if(PsiOptions::instance()->getOption("options.ui.chat.delete-contents-after").toString() == "instant") endSession(); else { if(PsiOptions::instance()->getOption("options.ui.chat.delete-contents-after").toString() == "hour") setSelfDestruct(60); else if(PsiOptions::instance()->getOption("options.ui.chat.delete-contents-after").toString() == "day") setSelfDestruct(60 * 24); } }
void ChatDlg::optionsUpdate() { setLooks(); setShortcuts(); if (isHidden()) { if (PsiOptions::instance()->getOption("options.ui.chat.delete-contents-after").toString() == "instant") { deleteLater(); return; } else { if (PsiOptions::instance()->getOption("options.ui.chat.delete-contents-after").toString() == "hour") { setSelfDestruct(60); } else if (PsiOptions::instance()->getOption("options.ui.chat.delete-contents-after").toString() == "day") { setSelfDestruct(60 * 24); } else { setSelfDestruct(0); } } } }
void ChatDlg::showEvent(QShowEvent *) { setSelfDestruct(0); }