~ubuntu-branches/ubuntu/edgy/psi/edgy

« back to all changes in this revision

Viewing changes to src/chatdlg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Stephan Hermann
  • Date: 2005-09-14 16:33:49 UTC
  • mfrom: (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050914163349-3zacov4afysz5cw5
Tags: 0.9.3-2ubuntu1
* Sync with debian
* Applied patch to psi.desktop to start psi without gpg-agent use (known
  issue)
* Updated README.Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include<qlabel.h>
24
24
#include<qcursor.h>
 
25
#include<qdragobject.h>
25
26
#include<qlineedit.h>
26
27
#include<qtoolbutton.h>
27
28
#include<qlayout.h>
39
40
#include"msgmle.h"
40
41
#include"iconselect.h"
41
42
#include"psicon.h"
 
43
#include"psitoolbar.h"
 
44
#include"iconaction.h"
 
45
//#include"avatars.h"
42
46
 
43
47
#ifdef Q_WS_WIN
44
48
#include<windows.h>
45
49
#endif
46
50
 
47
51
//----------------------------------------------------------------------------
 
52
// Some required actions
 
53
//----------------------------------------------------------------------------
 
54
 
 
55
class StretchWidget : public QWidget
 
56
{
 
57
public:
 
58
        StretchWidget(QWidget *parent)
 
59
        : QWidget(parent)
 
60
        {
 
61
                setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
 
62
        }
 
63
};
 
64
 
 
65
//----------------------------------------------------------------------------
48
66
// ChatDlg
49
67
//----------------------------------------------------------------------------
50
68
class ChatDlg::Private : public QObject
65
83
        ChatView *log;
66
84
        ChatEdit *mle;
67
85
 
 
86
        // Avatars
 
87
        //QLabel *avatar;
 
88
 
68
89
        QLabel *lb_ident;
69
90
        IconLabel *lb_status;
70
91
        QLineEdit *le_jid;
71
92
        QLCDNumber *lcd_count;
72
 
        IconToolButton *tb_send, *tb_clear, *tb_history, *tb_info, *tb_pgp, *tb_icon, *tb_file;
73
93
        QPopupMenu *pm_settings;
74
94
 
 
95
        PsiToolBar *toolbar;
 
96
        IconAction *act_send, *act_clear, *act_history, *act_info, *act_pgp, *act_icon, *act_file;
 
97
 
75
98
        int pending;
76
99
        bool keepOpen, warnSend;
77
100
 
85
108
        bool lastWasEncrypted;
86
109
        bool smallChat;
87
110
 
 
111
        // Message Events
 
112
        QTimer *composingTimer;
 
113
        bool isComposing;
 
114
        bool contactIsComposing;
 
115
        bool sendComposingEvents;
 
116
        QString eventId;
 
117
 
 
118
signals:
 
119
        // Signals if user (re)started/stopped composing
 
120
        void composing(bool);
 
121
 
88
122
public slots:
89
123
        void addEmoticon(const Icon *icon) {
90
124
                if ( !dlg->isActiveWindow() )
115
149
        void updateCounter() {
116
150
                lcd_count->display((int)mle->text().length());
117
151
        }
 
152
 
 
153
        // Records that the user is composing
 
154
        void setComposing() {
 
155
                if (!composingTimer) {
 
156
                        /* User (re)starts composing */
 
157
                        composingTimer = new QTimer(this);
 
158
                        connect(composingTimer, SIGNAL(timeout()), SLOT(checkComposing()));
 
159
                        composingTimer->start(2000); // FIXME: magic number
 
160
                        emit composing(true);
 
161
                }
 
162
                isComposing = true;
 
163
        }
 
164
 
 
165
        // Checks if the user is still composing
 
166
        void checkComposing() {
 
167
                if (!isComposing) {
 
168
                        // User stopped composing
 
169
                        delete composingTimer;
 
170
                        composingTimer = 0;
 
171
                        emit composing(false);
 
172
                }
 
173
                isComposing = false; // Reset composing
 
174
        }
118
175
};
119
176
 
120
177
ChatDlg::ChatDlg(const Jid &jid, PsiAccount *pa)
133
190
        d->key = "";
134
191
        d->lastWasEncrypted = false;
135
192
 
 
193
        setAcceptDrops(TRUE);
 
194
 
136
195
        QVBoxLayout *vb1 = new QVBoxLayout(this, 4);
137
196
        QSplitter *sp = new QSplitter(Vertical, this);
138
197
        vb1->addWidget(sp);
166
225
        // tool area
167
226
        QVBoxLayout *vb3 = new QVBoxLayout(sp_bottom, 4);
168
227
        QHBoxLayout *hb3 = new QHBoxLayout(vb3);
169
 
        d->tb_clear = new IconToolButton(sp_bottom);
170
 
        connect(d->tb_clear, SIGNAL(clicked()), SLOT(doClearButton()));
171
 
        QToolTip::add(d->tb_clear, tr("Clear chat window"));
172
 
        hb3->addWidget(d->tb_clear);
173
 
        hb3->addStretch(1);
174
 
 
175
 
        // icon selector
176
 
        //connect(pa->psi()->iconSelectPopup(), SIGNAL(iconSelected(const Icon *)), d, SLOT(addEmoticon(const Icon *)));
 
228
 
 
229
        d->toolbar = new PsiToolBar(tr("Chat toolbar"), 0, sp_bottom);
 
230
        d->toolbar->setCustomizeable( false ); // it isn't ready now, and we don't want segfaults
 
231
        d->toolbar->setFrameShape( QFrame::NoFrame );
 
232
        hb3->addWidget( d->toolbar );
 
233
 
 
234
        d->act_clear = new IconAction (tr("Clear chat window"), "psi/clearChat", tr("Clear chat window"), 0, this);
 
235
        connect( d->act_clear, SIGNAL( activated() ), SLOT( doClearButton() ) );
 
236
 
177
237
        connect(pa->psi()->iconSelectPopup(), SIGNAL(textSelected(QString)), d, SLOT(addEmoticon(QString)));
178
 
        d->tb_icon = new IconToolButton(sp_bottom);
179
 
        d->tb_icon->setPopup(pa->psi()->iconSelectPopup());
180
 
        d->tb_icon->setPopupDelay (1);
181
 
        QToolTip::add(d->tb_icon, tr("Select icon"));
182
 
        hb3->addWidget(d->tb_icon);
183
 
 
184
 
        d->tb_file = new IconToolButton(sp_bottom);
185
 
        connect(d->tb_file, SIGNAL(clicked()), SLOT(doFile()));
186
 
        QToolTip::add(d->tb_file, tr("Send file"));
187
 
        hb3->addWidget(d->tb_file);
188
 
 
189
 
        d->tb_pgp = new IconToolButton(sp_bottom);
190
 
        d->tb_pgp->setToggleButton(true);
191
 
        QToolTip::add(d->tb_pgp, tr("Toggle encryption"));
192
 
        hb3->addWidget(d->tb_pgp);
193
 
 
194
 
        d->tb_info = new IconToolButton(sp_bottom);
195
 
        connect(d->tb_info, SIGNAL(clicked()), SLOT(doInfo()));
196
 
        QToolTip::add(d->tb_info, tr("User info"));
197
 
        hb3->addWidget(d->tb_info);
198
 
 
199
 
        d->tb_history = new IconToolButton(sp_bottom);
200
 
        connect(d->tb_history, SIGNAL(clicked()), SLOT(doHistory()));
201
 
        QToolTip::add(d->tb_history, tr("Message history"));
202
 
        hb3->addWidget(d->tb_history);
203
 
 
 
238
        d->act_icon = new IconAction( tr( "Select icon" ), "psi/smile", tr( "Select icon" ), 0, this );
 
239
        d->act_icon->setPopup( pa->psi()->iconSelectPopup() );
 
240
 
 
241
        d->act_file = new IconAction( tr( "Send file" ), "psi/upload", tr( "Send file" ), 0, this );
 
242
        connect( d->act_file, SIGNAL( activated() ), SLOT( doFile() ) );
 
243
 
 
244
        d->act_pgp = new IconAction( tr( "Toggle encryption" ), "psi/cryptoNo", tr( "Toggle encryption" ), 0, this, 0, true );
 
245
 
 
246
        d->act_info = new IconAction( tr( "User info" ), "psi/vCard", tr( "User info" ), 0, this );
 
247
        connect( d->act_info, SIGNAL( activated() ), SLOT( doInfo() ) );
 
248
 
 
249
        d->act_history = new IconAction( tr( "Message history" ), "psi/history", tr( "Message history" ), 0, this );
 
250
        connect( d->act_history, SIGNAL( activated() ), SLOT( doHistory() ) );
 
251
 
 
252
        d->act_clear->addTo( d->toolbar );
 
253
        d->toolbar->setStretchableWidget(new StretchWidget(d->toolbar));
 
254
 
 
255
        d->act_icon->addTo( d->toolbar );
 
256
        d->act_file->addTo( d->toolbar );
 
257
        d->act_pgp->addTo( d->toolbar );
 
258
        d->act_info->addTo( d->toolbar );
 
259
        d->act_history->addTo( d->toolbar );
 
260
 
 
261
        // Bottom row
 
262
        QHBoxLayout *hb4 = new QHBoxLayout(vb3);
 
263
 
 
264
        // Text input
204
265
        d->mle = new ChatEdit(sp_bottom);
205
 
        vb3->addWidget(d->mle);
 
266
        hb4->addWidget(d->mle);
206
267
        connect(d->mle, SIGNAL(textChanged()), d, SLOT(updateCounter()));
207
268
 
 
269
        // Avatars
 
270
        //d->avatar = new QLabel(sp_bottom);
 
271
        //hb4->addWidget(d->avatar);
 
272
        //updateAvatar();
 
273
        // FIXME: Maybe the psiaccount should do this, to avoid a signal to each
 
274
        // open window when an avatar changes.
 
275
        //connect(d->pa->avatarFactory(),SIGNAL(avatarChanged(const Jid&)), this, SLOT(updateAvatar(const Jid&)));
 
276
        //connect(d->pa->psi(),SIGNAL(emitOptionsUpdate()), this, SLOT(updateAvatar()));
 
277
 
208
278
        d->pm_settings=new QPopupMenu(this);
209
279
 
210
280
        connect(d->pm_settings, SIGNAL(aboutToShow()), SLOT(buildMenu()));
216
286
        d->status = -1;
217
287
        d->pa->dialogRegister(this, d->jid);
218
288
 
 
289
        // Message events
 
290
        d->contactIsComposing = false;
 
291
        d->sendComposingEvents = false;
 
292
        d->isComposing = false;
 
293
        d->composingTimer = 0;
 
294
        connect(d->mle, SIGNAL(textChanged()), d, SLOT(setComposing()));
 
295
        connect(d, SIGNAL(composing(bool)), SLOT(updateIsComposing(bool)));
 
296
 
219
297
        updateContact(d->jid, true);
220
298
 
221
299
        d->smallChat=option.smallChats;
234
312
 
235
313
        UserListItem *u = d->pa->findFirstRelavent(d->jid);
236
314
        if(u && u->isSecure(d->jid.resource()))
237
 
                d->tb_pgp->setOn(true);
 
315
                d->act_pgp->setOn(true);
238
316
}
239
317
 
240
318
ChatDlg::~ChatDlg()
241
319
{
242
320
        d->pa->dialogUnregister(this);
243
321
 
244
 
        //QMimeSourceFactory *m = d->log->mimeSourceFactory();
245
 
        //d->log->setMimeSourceFactory(QMimeSourceFactory::defaultFactory());
246
 
        //delete m;
247
 
 
248
322
        delete d;
249
323
}
250
324
 
269
343
                d->log->setContentsPos(d->log->contentsX(), d->log->contentsY() - d->log->visibleHeight()/2);
270
344
        else if(e->key() == Key_PageDown && (e->state() & ShiftButton))
271
345
                d->log->setContentsPos(d->log->contentsX(), d->log->contentsY() + d->log->visibleHeight()/2);
 
346
        else if(e->key() == Key_C && (e->state() & ControlButton)) {
 
347
                if(d->log->hasSelectedText()) {
 
348
                        d->log->copy();
 
349
                } else  {
 
350
                        d->mle->copy();
 
351
                }
 
352
        }
272
353
        else
273
354
                e->ignore();
274
355
}
301
382
                        setSelfDestruct(60 * 24);
302
383
        }
303
384
 
 
385
        // Reset 'contact is composing' & cancel own composing event
 
386
        updateContactIsComposing(false);
 
387
        if (d->composingTimer) {
 
388
                delete d->composingTimer;
 
389
                d->composingTimer = 0;
 
390
                d->isComposing = false;
 
391
                updateIsComposing(false);
 
392
        }
 
393
 
 
394
 
304
395
        if(d->pending > 0) {
305
396
                d->pending = 0;
306
397
                messagesRead(d->jid);
339
430
        }
340
431
}
341
432
 
 
433
 
 
434
void ChatDlg::dropEvent(QDropEvent* event)
 
435
{
 
436
        QStringList l;
 
437
        if (d->pa->loggedIn() && QUriDrag::decodeLocalFiles(event,l) && !l.isEmpty())
 
438
                d->pa->actionSendFiles(d->jid,l);
 
439
}
 
440
 
 
441
void ChatDlg::dragEnterEvent(QDragEnterEvent* event)
 
442
{
 
443
        QStringList l;
 
444
        event->accept(d->pa->loggedIn() && QUriDrag::canDecode(event) && QUriDrag::decodeLocalFiles(event,l) && !l.isEmpty());
 
445
}
 
446
 
 
447
 
342
448
const Jid & ChatDlg::jid() const
343
449
{
344
450
        return d->jid;
407
513
                        d->statusString = statusString;
408
514
                }
409
515
 
410
 
                //if(statusChanged) {
 
516
                if(statusChanged) {
411
517
                        if(status == -1 || !u)
412
518
                                d->lb_status->setIcon(IconsetFactory::iconPtr("status/noauth"));
413
519
                        else
414
520
                                d->lb_status->setIcon(is->statusPtr(jid, status));
415
 
                //}
 
521
                }
416
522
 
417
523
                if(u)
418
524
                        QToolTip::add(d->lb_status, u->makeTip(true, false));
454
560
                                appendSysMsg(msg);
455
561
                        }
456
562
                }
 
563
 
 
564
                // Reset 'is composing' event if the status changed
 
565
                if (statusChanged) {
 
566
                        updateContactIsComposing(false);
 
567
                }
457
568
        }
458
569
}
459
570
 
 
571
 
 
572
// Avatars
 
573
//void ChatDlg::updateAvatar(const Jid& j)
 
574
//{
 
575
//      if (j.compare(d->jid,false))
 
576
//              updateAvatar();
 
577
//}
 
578
 
 
579
//void ChatDlg::updateAvatar()
 
580
//{
 
581
//      QString res;
 
582
//      QString client;
 
583
 
 
584
//      if (!option.avatarsEnabled || !option.avatarsChatdlgEnabled) {
 
585
//              d->avatar->hide();
 
586
//              return;
 
587
//      }
 
588
//
 
589
//      UserListItem *ul = d->pa->findFirstRelavent(d->jid);
 
590
//      if (ul && !ul->userResourceList().isEmpty()) {
 
591
//              UserResourceList::Iterator it = ul->userResourceList().find(d->jid.resource());
 
592
//              if(it == ul->userResourceList().end())
 
593
//                      it = ul->userResourceList().priority();
 
594
//
 
595
//              res = (*it).name();
 
596
//              client = (*it).clientName();
 
597
//      }
 
598
//      QPixmap p = d->pa->avatarFactory()->getAvatar(d->jid.withResource(res),client);
 
599
//      if (p.isNull()) {
 
600
//              d->avatar->hide();
 
601
//      }
 
602
//      else {
 
603
//              d->avatar->setPixmap(p);
 
604
//              d->avatar->show();
 
605
//      }
 
606
//}
 
607
 
 
608
 
460
609
void ChatDlg::setLooks()
461
610
{
462
611
        // update the font
466
615
        d->mle->setFont(f);
467
616
 
468
617
        if (d->smallChat) {
469
 
                //hide the first row
470
618
                d->lb_ident->hide();
471
619
                d->lb_status->hide();
472
620
                d->le_jid->hide();
473
 
                d->lcd_count->hide();
474
 
                //hide the toolbar row
475
 
                d->tb_clear->hide();
476
 
                d->tb_file->hide();
477
 
                d->tb_pgp->hide();
478
 
                d->tb_info->hide();
479
 
                d->tb_history->hide();
 
621
                d->toolbar->hide();
480
622
        }
481
623
        else {
482
 
                //show the first row
483
624
                d->lb_ident->show();
484
625
                d->lb_status->show();
485
626
                d->le_jid->show();
486
 
                //show the toolbar row
487
 
                d->tb_clear->show();
488
 
                d->tb_file->show();
489
 
                d->tb_pgp->show();
490
 
                d->tb_info->show();
491
 
                d->tb_history->show();
 
627
                d->toolbar->show();
492
628
        }
493
629
 
494
630
        if ( option.showCounter && !d->smallChat )
496
632
        else
497
633
                d->lcd_count->hide();
498
634
 
499
 
        if ( option.useEmoticons&& !d->smallChat )
500
 
                d->tb_icon->show();
501
 
        else
502
 
                d->tb_icon->hide();
503
 
 
504
635
        // update contact info
505
636
        d->status = -2; // sick way of making it redraw the status
506
637
        updateContact(d->jid, false);
507
638
 
508
639
        // toolbuttons
509
 
        d->tb_clear->setIcon(IconsetFactory::iconPtr("psi/clearChat"));
510
 
        d->tb_info->setIcon(IconsetFactory::iconPtr("psi/vCard"));
511
 
        d->tb_history->setIcon(IconsetFactory::iconPtr("psi/history"));
512
 
        d->tb_icon->setIcon(IconsetFactory::iconPtr("psi/smile"));
513
640
        QIconSet i;
514
641
        i.setPixmap(IconsetFactory::icon("psi/cryptoNo"),  QIconSet::Automatic, QIconSet::Normal, QIconSet::Off);
515
642
        i.setPixmap(IconsetFactory::icon("psi/cryptoYes"), QIconSet::Automatic, QIconSet::Normal, QIconSet::On);
516
 
        d->tb_pgp->setIconSet( i );
517
 
        d->tb_file->setIcon(IconsetFactory::iconPtr("psi/upload"));
 
643
        d->act_pgp->setIcon( 0 );
 
644
        d->act_pgp->setIconSet( i );
518
645
 
519
646
        // update the widget icon
 
647
#ifndef Q_WS_MAC
520
648
        setIcon(IconsetFactory::icon("psi/chat"));
 
649
#endif
521
650
}
522
651
 
523
652
void ChatDlg::optionsUpdate()
524
653
{
 
654
        if (option.oldSmallChats!=option.smallChats)
 
655
        {
 
656
                d->smallChat=option.smallChats;
 
657
        }
 
658
        
525
659
        setLooks();
526
660
 
527
661
        if(isHidden()) {
543
677
void ChatDlg::updatePGP()
544
678
{
545
679
        if(!d->pa->pgpKey().isEmpty()) {
546
 
                d->tb_pgp->setEnabled(true);
 
680
                d->act_pgp->setEnabled(true);
547
681
        }
548
682
        else {
549
 
                d->tb_pgp->setOn(false);
550
 
                d->tb_pgp->setEnabled(false);
 
683
                d->act_pgp->setOn(false);
 
684
                d->act_pgp->setEnabled(false);
551
685
        }
552
686
}
553
687
 
617
751
        }
618
752
        cap += d->dispNick;
619
753
 
 
754
        if (d->contactIsComposing)
 
755
                cap = tr("%1 (Composing ...)").arg(cap);
 
756
 
620
757
        // if taskbar flash, then we need to erase first and redo
621
758
#ifdef Q_WS_WIN
622
759
        bool on = false;
700
837
        m.setType("chat");
701
838
        m.setBody(d->mle->text());
702
839
        m.setTimeStamp(QDateTime::currentDateTime());
703
 
        if(d->tb_pgp->isOn())
 
840
        if(d->act_pgp->isOn())
704
841
                m.setWasEncrypted(true);
705
842
        d->m = m;
706
843
 
707
 
        if(d->tb_pgp->isOn()) {
 
844
        // Request events
 
845
        if (option.messageEvents) {
 
846
                //m.addEvent(OfflineEvent);
 
847
                //m.addEvent(DeliveredEvent);
 
848
                //m.addEvent(DisplayedEvent);
 
849
                m.addEvent(ComposingEvent);
 
850
        }
 
851
 
 
852
        if(d->act_pgp->isOn()) {
708
853
                d->mle->setEnabled(false);
709
854
                d->transid = d->pa->sendMessageEncrypted(m);
710
855
                if(d->transid == -1) {
722
867
void ChatDlg::doneSend()
723
868
{
724
869
        appendMessage(d->m, true);
 
870
        disconnect(d->mle, SIGNAL(textChanged()), d, SLOT(setComposing()));
725
871
        d->mle->setText("");
 
872
 
 
873
        // Reset composing timer
 
874
        connect(d->mle, SIGNAL(textChanged()), d, SLOT(setComposing()));
 
875
        if (d->composingTimer) {
 
876
                delete d->composingTimer;
 
877
                d->composingTimer = 0;
 
878
                d->isComposing = false;
 
879
        }
726
880
}
727
881
 
728
882
void ChatDlg::encryptedMessageSent(int x, bool b)
742
896
 
743
897
void ChatDlg::incomingMessage(const Message &m)
744
898
{
745
 
        appendMessage(m);
 
899
        if (m.body().isEmpty()) {
 
900
                /* Event message */
 
901
                if (m.containsEvent(CancelEvent))
 
902
                        updateContactIsComposing(false);
 
903
                if (m.containsEvent(ComposingEvent))
 
904
                        updateContactIsComposing(true);
 
905
        }
 
906
        else {
 
907
                // Normal message
 
908
                // Check if user requests event messages
 
909
                d->sendComposingEvents = m.containsEvent(ComposingEvent);
 
910
                if (!m.eventId().isEmpty())
 
911
                        d->eventId = m.eventId();
 
912
                updateContactIsComposing(false);
 
913
                appendMessage(m);
 
914
        }
746
915
}
747
916
 
748
917
void ChatDlg::appendSysMsg(const QString &str)
789
958
                if(encEnabled) {
790
959
                        appendSysMsg(QString("<icon name=\"psi/cryptoYes\"> ") + tr("Encryption Enabled"));
791
960
                        if(!local)
792
 
                                d->tb_pgp->setOn(true);
 
961
                                d->act_pgp->setOn(true);
793
962
                }
794
963
                else {
795
964
                        appendSysMsg(QString("<icon name=\"psi/cryptoNo\"> ") + tr("Encryption Disabled"));
796
965
                        if(!local) {
797
 
                                d->tb_pgp->setOn(false);
 
966
                                d->act_pgp->setOn(false);
798
967
 
799
968
                                // enable warning
800
969
                                d->warnSend = true;
805
974
 
806
975
        QString timestr;
807
976
        QDateTime time = m.timeStamp();
808
 
        //timestr.sprintf("%02d:%02d:%02d", time.time().hour(), time.time().minute(), time.time().second());
809
977
        timestr = time.time().toString(LocalDate);
810
978
 
811
979
        int y = d->log->contentsHeight() - d->log->visibleHeight();
883
1051
        d->log->scrollToBottom();
884
1052
}
885
1053
 
 
1054
void ChatDlg::updateIsComposing(bool c)
 
1055
{
 
1056
        if (option.messageEvents && d->sendComposingEvents) {
 
1057
                // Don't send to offline resource
 
1058
                QPtrList<UserListItem> ul = d->pa->findRelavent(d->jid);
 
1059
                if(ul.isEmpty()) {
 
1060
                        d->sendComposingEvents = false;
 
1061
                        return;
 
1062
                }
 
1063
 
 
1064
                QString rname = d->jid.resource();
 
1065
                UserListItem *u = ul.first();
 
1066
                if(rname.isEmpty() && !u->isAvailable() || u->userResourceList().find(rname) == u->userResourceList().end()) {
 
1067
                        d->sendComposingEvents = false;
 
1068
                        return;
 
1069
                }
 
1070
 
 
1071
                // Send event message
 
1072
                Message m(d->jid);
 
1073
                m.setEventId(d->eventId);
 
1074
                if (c) {
 
1075
                        m.addEvent(ComposingEvent);
 
1076
                }
 
1077
                else {
 
1078
                        m.addEvent(CancelEvent);
 
1079
                }
 
1080
                d->pa->dj_sendMessage(m, false);
 
1081
        }
 
1082
}
 
1083
 
 
1084
void ChatDlg::updateContactIsComposing(bool c)
 
1085
{
 
1086
        d->contactIsComposing = c;
 
1087
        updateCaption();
 
1088
}
 
1089
 
886
1090
void ChatDlg::toggleSmallChat()
887
1091
{
888
1092
        if (d->smallChat)
894
1098
 
895
1099
void ChatDlg::toggleEncryption()
896
1100
{
897
 
        d->tb_pgp->setOn(1-d->tb_pgp->isOn());
 
1101
        d->act_pgp->setOn( !d->act_pgp->isOn() );
898
1102
}
899
1103
 
900
1104
void ChatDlg::buildMenu()
901
1105
{
 
1106
        // Dialog menu
902
1107
        d->pm_settings->clear();
903
 
        d->pm_settings->insertItem("Toggle Compact/Full Size", this, SLOT(toggleSmallChat()));
904
 
        d->pm_settings->insertItem(IconsetFactory::iconPtr("psi/clearChat")->pixmap(),"Clear Chat", this, SLOT(doClearButton()));
905
 
        d->pm_settings->insertSeparator();
906
 
        if (d->tb_pgp->isEnabled()) {
907
 
                if (d->tb_pgp->isOn())
908
 
                        d->pm_settings->insertItem(IconsetFactory::icon("psi/cryptoYes").pixmap(),"Toggle Encryption", this, SLOT(toggleEncryption()));
909
 
                else
910
 
                        d->pm_settings->insertItem(IconsetFactory::icon("psi/cryptoNo").pixmap(),"Toggle Encryption", this, SLOT(toggleEncryption()));
911
 
        }
912
 
        d->pm_settings->insertSeparator();
913
 
        d->pm_settings->insertItem(IconsetFactory::iconPtr("psi/vCard")->pixmap(),"View User Profile", this, SLOT(doInfo()));
914
 
        d->pm_settings->insertItem(IconsetFactory::iconPtr("psi/history")->pixmap(),"View History", this, SLOT(doHistory()));
 
1108
        d->pm_settings->insertItem(tr("Toggle Compact/Full Size"), this, SLOT(toggleSmallChat()));
 
1109
 
 
1110
        d->act_clear->addTo( d->pm_settings );
 
1111
        d->pm_settings->insertSeparator();
 
1112
 
 
1113
        d->act_icon->addTo( d->pm_settings );
 
1114
        d->act_file->addTo( d->pm_settings );
 
1115
        d->act_pgp->addTo( d->pm_settings );
 
1116
        d->pm_settings->insertSeparator();
 
1117
 
 
1118
        d->act_info->addTo( d->pm_settings );
 
1119
        d->act_history->addTo( d->pm_settings );
915
1120
}
 
1121
 
916
1122
#include "chatdlg.moc"