| 1 | /*
|
|---|
| 2 | * statusdlg.cpp - dialogs for setting and reading status messages
|
|---|
| 3 | * Copyright (C) 2001, 2002 Justin Karneges
|
|---|
| 4 | *
|
|---|
| 5 | * This program is free software; you can redistribute it and/or
|
|---|
| 6 | * modify it under the terms of the GNU General Public License
|
|---|
| 7 | * as published by the Free Software Foundation; either version 2
|
|---|
| 8 | * of the License, or (at your option) any later version.
|
|---|
| 9 | *
|
|---|
| 10 | * This program is distributed in the hope that it will be useful,
|
|---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 13 | * GNU General Public License for more details.
|
|---|
| 14 | *
|
|---|
| 15 | * You should have received a copy of the GNU General Public License
|
|---|
| 16 | * along with this library; if not, write to the Free Software
|
|---|
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 18 | *
|
|---|
| 19 | */
|
|---|
| 20 |
|
|---|
| 21 | #include"statusdlg.h"
|
|---|
| 22 |
|
|---|
| 23 | #include<qpushbutton.h>
|
|---|
| 24 | #include<qlayout.h>
|
|---|
| 25 | #include<qlabel.h>
|
|---|
| 26 | #include<qcombobox.h>
|
|---|
| 27 | #include<qinputdialog.h>
|
|---|
| 28 | #include<qcheckbox.h>
|
|---|
| 29 | #include"psicon.h"
|
|---|
| 30 | #include"psiaccount.h"
|
|---|
| 31 | #include"userlist.h"
|
|---|
| 32 | #include"common.h"
|
|---|
| 33 | #include"msgmle.h"
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 | //----------------------------------------------------------------------------
|
|---|
| 37 | // StatusShowDlg
|
|---|
| 38 | // FIXME: Will no longer be needed once it is out of the groupchat contactview
|
|---|
| 39 | //----------------------------------------------------------------------------
|
|---|
| 40 | StatusShowDlg::StatusShowDlg(const UserListItem &u)
|
|---|
| 41 | :QDialog(0, 0, false, WDestructiveClose)
|
|---|
| 42 | {
|
|---|
| 43 | // build the dialog
|
|---|
| 44 | QVBoxLayout *vb = new QVBoxLayout(this, 8);
|
|---|
| 45 | PsiTextView *te = new PsiTextView(this);
|
|---|
| 46 | vb->addWidget(te);
|
|---|
| 47 | QHBoxLayout *hb = new QHBoxLayout(vb);
|
|---|
| 48 | QPushButton *pb = new QPushButton(tr("&Close"), this);
|
|---|
| 49 | connect(pb, SIGNAL(clicked()), SLOT(close()));
|
|---|
| 50 | hb->addStretch(1);
|
|---|
| 51 | hb->addWidget(pb);
|
|---|
| 52 | hb->addStretch(1);
|
|---|
| 53 |
|
|---|
| 54 | // set the rest up
|
|---|
| 55 | te->setReadOnly(true);
|
|---|
| 56 | te->setTextFormat(RichText);
|
|---|
| 57 | te->setText(u.makeDesc());
|
|---|
| 58 |
|
|---|
| 59 | setCaption(tr("Status for %1").arg(jidnick(u.jid().full(), u.name())));
|
|---|
| 60 | resize(400,240);
|
|---|
| 61 |
|
|---|
| 62 | pb->setFocus();
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | //----------------------------------------------------------------------------
|
|---|
| 67 | // StatusSetDlg
|
|---|
| 68 | //----------------------------------------------------------------------------
|
|---|
| 69 | static int combomap[7] = { STATUS_CHAT, STATUS_ONLINE, STATUS_AWAY, STATUS_XA, STATUS_DND, STATUS_INVISIBLE, STATUS_OFFLINE };
|
|---|
| 70 |
|
|---|
| 71 | class StatusSetDlg::Private
|
|---|
| 72 | {
|
|---|
| 73 | public:
|
|---|
| 74 | Private() {}
|
|---|
| 75 |
|
|---|
| 76 | PsiCon *psi;
|
|---|
| 77 | PsiAccount *pa;
|
|---|
| 78 | Status s;
|
|---|
| 79 | ChatView *te;
|
|---|
| 80 | QComboBox *cb_type, *cb_preset;
|
|---|
| 81 | QCheckBox *save;
|
|---|
| 82 | };
|
|---|
| 83 |
|
|---|
| 84 | StatusSetDlg::StatusSetDlg(PsiCon *psi, const Status &s)
|
|---|
| 85 | :QDialog(0, 0, false, WDestructiveClose)
|
|---|
| 86 | {
|
|---|
| 87 | d = new Private;
|
|---|
| 88 | d->psi = psi;
|
|---|
| 89 | d->pa = 0;
|
|---|
| 90 | d->psi->dialogRegister(this);
|
|---|
| 91 | d->s = s;
|
|---|
| 92 |
|
|---|
| 93 | setCaption(CAP(tr("Set Status: All accounts")));
|
|---|
| 94 | init();
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | StatusSetDlg::StatusSetDlg(PsiAccount *pa, const Status &s)
|
|---|
| 98 | :QDialog(0, 0, false, WDestructiveClose)
|
|---|
| 99 | {
|
|---|
| 100 | d = new Private;
|
|---|
| 101 | d->psi = 0;
|
|---|
| 102 | d->pa = pa;
|
|---|
| 103 | d->pa->dialogRegister(this);
|
|---|
| 104 | d->s = s;
|
|---|
| 105 |
|
|---|
| 106 | setCaption(CAP(tr("Set Status: %1").arg(d->pa->name())));
|
|---|
| 107 | init();
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | void StatusSetDlg::init()
|
|---|
| 111 | {
|
|---|
| 112 | int type = makeSTATUS(d->s);
|
|---|
| 113 |
|
|---|
| 114 | // build the dialog
|
|---|
| 115 | QVBoxLayout *vb = new QVBoxLayout(this, 8);
|
|---|
| 116 | QHBoxLayout *hb1 = new QHBoxLayout(vb);
|
|---|
| 117 |
|
|---|
| 118 | QLabel *l;
|
|---|
| 119 | l = new QLabel(tr("Status:"), this);
|
|---|
|
|---|