Hi all! With this patch applied, the dialog for entering the away message is automatically closed after 9 seconds (with a visible countdown), unless the user gives any input. This is similar to what the official ICQ client does.
Index: plugins/qt-gui/src/awaymsgdlg.cpp =================================================================== RCS file: /cvsroot/licq/qt-gui/src/awaymsgdlg.cpp,v retrieving revision 1.54 diff -u -r1.54 awaymsgdlg.cpp --- plugins/qt-gui/src/awaymsgdlg.cpp 10 Oct 2004 15:35:18 -0000 1.54 +++ plugins/qt-gui/src/awaymsgdlg.cpp 7 May 2005 12:15:29 -0000 @@ -156,6 +156,13 @@ mleAwayMsg->setFocus(); QTimer::singleShot(0, mleAwayMsg, SLOT(selectAll())); + installEventFilter(this); + mleAwayMsg->installEventFilter(this); + connect(mleAwayMsg, SIGNAL(clicked(int, int)), + this, SLOT(slot_autocloseStop())); + m_autocloseCounter = 9; + slot_autocloseTick(); + if (!isVisible()) { if (!snPos.isNull()) move(snPos); @@ -179,6 +186,7 @@ void AwayMsgDlg::ok() { + m_autocloseCounter = -1; QString s = mleAwayMsg->text(); while (s[s.length()-1].isSpace()) s.truncate(s.length()-1); @@ -196,6 +204,7 @@ void AwayMsgDlg::reject() { + m_autocloseCounter = -1; QTimer::singleShot(0, this, SLOT(close())); } @@ -220,6 +229,37 @@ e->accept(); } +bool AwayMsgDlg::eventFilter(QObject *obj, QEvent *e) +{ + if (e->type() == QEvent::KeyPress || + e->type() == QEvent::MouseButtonPress || + e->type() == QEvent::Accel || + e->type() == QEvent::FocusOut) { + slot_autocloseStop(); + } + return FALSE; +} + +void AwayMsgDlg::slot_autocloseTick() +{ + if (m_autocloseCounter >= 0) { + btnOk->setText(tr("(Closing in %1)").arg(m_autocloseCounter)); + m_autocloseCounter--; + if (m_autocloseCounter < 0) + ok(); + else + QTimer::singleShot(1000, this, SLOT(slot_autocloseTick())); + } +} + +void AwayMsgDlg::slot_autocloseStop() +{ + if (m_autocloseCounter >= 0) { + m_autocloseCounter = -1; + btnOk->setText(tr("&Ok")); + } +} + // ----------------------------------------------------------------------------- Index: plugins/qt-gui/src/awaymsgdlg.h =================================================================== RCS file: /cvsroot/licq/qt-gui/src/awaymsgdlg.h,v retrieving revision 1.25 diff -u -r1.25 awaymsgdlg.h --- plugins/qt-gui/src/awaymsgdlg.h 2 Jul 2003 04:41:02 -0000 1.25 +++ plugins/qt-gui/src/awaymsgdlg.h 7 May 2005 12:15:29 -0000 @@ -23,8 +23,10 @@ unsigned short m_nStatus; static QPoint snPos; short m_nSAR; + int m_autocloseCounter; void closeEvent(QCloseEvent *); + bool eventFilter(QObject *, QEvent *); signals: void popupOptions(int); @@ -35,6 +37,8 @@ virtual void reject(); void slot_selectMessage(int); void slot_hints(); + void slot_autocloseTick(); + void slot_autocloseStop(); }; class CustomAwayMsgDlg : public LicqDialog
ciao Jörg