diff -ru -X exclude psi-clean/src/common.h psi/src/common.h --- psi-clean/src/common.h 2004-08-07 13:44:42.000000000 +0200 +++ psi/src/common.h 2004-08-07 13:45:26.000000000 +0200 @@ -102,6 +102,7 @@ int recentStatusLimit; bool storePresets; QStringList recentStatus; //recent status messages + int statusTimeout; int asAway, asXa, asOffline; bool use_asAway, use_asXa, use_asOffline; diff -ru -X exclude psi-clean/src/psi_profiles.cpp psi/src/psi_profiles.cpp --- psi-clean/src/psi_profiles.cpp 2004-08-07 13:44:42.000000000 +0200 +++ psi/src/psi_profiles.cpp 2004-08-07 13:45:26.000000000 +0200 @@ -407,6 +407,7 @@ prefs.recentStatus.clear(); prefs.recentStatusLimit = 5; prefs.storePresets = true; + prefs.statusTimeout = 10; prefs.color[cOnline] = QColor("#0060C0"); prefs.color[cListBack] = QColor("#C0C0C0"); @@ -848,6 +849,9 @@ setBoolAttribute(e, "storePresets", prefs.storePresets); p_pres.appendChild(e); } + { + p_pres.appendChild(textTag(doc, "timeout", prefs.statusTimeout)); + } } { @@ -1358,6 +1362,7 @@ if(tag.hasAttribute("storePresets")) readBoolAttribute(tag, "storePresets", &prefs.storePresets); xmlToStringList(p_pres, "recentstatus", &prefs.recentStatus); + readNumEntry(p_pres, "timeout",&prefs.statusTimeout); } } diff -ru -X exclude psi-clean/src/statusdlg.cpp psi/src/statusdlg.cpp --- psi-clean/src/statusdlg.cpp 2004-08-07 13:44:42.000000000 +0200 +++ psi/src/statusdlg.cpp 2004-08-07 13:47:16.000000000 +0200 @@ -26,6 +26,7 @@ #include #include #include +#include #include"psicon.h" #include"psiaccount.h" #include"userlist.h" @@ -80,6 +81,9 @@ ChatView *te; QComboBox *cb_type, *cb_preset; QCheckBox *save; + int timeout; + QTimer* timer; + QString prefix; }; StatusSetDlg::StatusSetDlg(PsiCon *psi, const Status &s) @@ -92,8 +96,10 @@ d->s = s; d->recentNum = -1; - setCaption(CAP(tr("Set Status: All accounts"))); - init(); + d->timeout = option.statusTimeout; + d->prefix = tr("Set Status: All accounts"); + + init(); } StatusSetDlg::StatusSetDlg(PsiAccount *pa, const Status &s) @@ -106,14 +112,28 @@ d->s = s; d->recentNum = -1; - setCaption(CAP(tr("Set Status: %1").arg(d->pa->name()))); - init(); + d->timeout = option.statusTimeout; + d->prefix = tr("Set Status: %1").arg(pa->name()); + + init(); } void StatusSetDlg::init() { int type = makeSTATUS(d->s); + + if(d->timeout != -1) { + d->timer = new QTimer(this); + connect( d->timer, SIGNAL(timeout()), this, SLOT(updateCaption()) ); + d->timer->start(1000); + updateCaption(); + } + else{ + d->timer = 0; + setCaption(CAP(d->prefix)); + } + // build the dialog QVBoxLayout *vb = new QVBoxLayout(this, 8); QHBoxLayout *hb1 = new QHBoxLayout(vb); @@ -146,6 +166,7 @@ d->te->setReadOnly(false); d->te->setTextFormat(PlainText); d->te->setMinimumHeight(50); + d->te->installEventFilter( this ); vb->addWidget(d->te); QHBoxLayout *hb = new QHBoxLayout(vb); QPushButton *pb1 = new QPushButton(tr("&Set"), this); @@ -172,8 +193,20 @@ resize(400,240); } +void StatusSetDlg::stopTimer() +{ + if(d->timer){ + setCaption(CAP(d->prefix)); + if(d->timer->isActive()) + d->timer->stop(); + delete d->timer; + d->timer = 0; + } +} + StatusSetDlg::~StatusSetDlg() { + stopTimer(); if(d->psi) d->psi->dialogUnregister(this); else if(d->pa) @@ -181,6 +214,14 @@ delete d; } +void StatusSetDlg::updateCaption(){ + setCaption(CAP(d->prefix+QString(tr(" [%1 sek.]")).arg(d->timeout))); + if(!d->timeout--){ + stopTimer(); + doButton(); + } +} + void StatusSetDlg::keyPressEvent(QKeyEvent *e) { if(e->key() == Key_Escape) @@ -193,6 +234,9 @@ bool StatusSetDlg::eventFilter( QObject *o, QEvent *e ) { + // events which cause countdown cancelation (comming from edit widget) + if ( e->type() == QEvent::KeyPress || e->type() == QEvent::FocusOut ) + stopTimer(); if ( e->type() == QEvent::KeyPress ) { QKeyEvent *ke = (QKeyEvent*)e; if(ke->key() == Key_Up && (ke->state() & AltButton) ) diff -ru -X exclude psi-clean/src/statusdlg.h psi/src/statusdlg.h --- psi-clean/src/statusdlg.h 2004-08-07 13:44:42.000000000 +0200 +++ psi/src/statusdlg.h 2004-08-07 13:45:26.000000000 +0200 @@ -59,12 +59,14 @@ void cancel(); void reject(); void chooseStatusPreset(int); + void updateCaption(); private: class Private; Private *d; void init(); + void stopTimer(); }; #endif