~ubuntu-branches/ubuntu/wily/psi/wily-proposed

« back to all changes in this revision

Viewing changes to src/psichatdlg.cpp

  • Committer: Package Import Robot
  • Author(s): Jan Niehusmann
  • Date: 2014-07-01 21:49:34 UTC
  • mfrom: (6.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20140701214934-gt4dkgm94byi4vnn
Tags: 0.15-1
* New upstream version
* set debhelper compat level to 9
* set Standards-Version to 3.9.5 (no further changes)
* add lintian override regarding license-problem-non-free-RFC
* use qconf to regenerate configure script
* implement hardening using buildflags instead of hardening-wrapper

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include "avatars.h"
32
32
#include "psitooltip.h"
33
33
#include "psioptions.h"
 
34
#include "coloropt.h"
34
35
#include "shortcutmanager.h"
35
36
#include "accountlabel.h"
36
37
#include "iconlabel.h"
204
205
        pm_settings_ = new QMenu(this);
205
206
        connect(pm_settings_, SIGNAL(aboutToShow()), SLOT(buildMenu()));
206
207
        ui_.tb_actions->setMenu(pm_settings_);
 
208
        ui_.tb_actions->setStyleSheet(" QToolButton::menu-indicator { image:none } ");
207
209
 
208
210
        connect(account()->capsManager(), SIGNAL(capsChanged(const Jid&)), SLOT(capsChanged(const Jid&)));
209
211
 
467
469
 
468
470
void PsiChatDlg::doClearButton()
469
471
{
470
 
        int n = QMessageBox::information(this, tr("Warning"), tr("Are you sure you want to clear the chat window?\n(note: does not affect saved history)"), tr("&Yes"), tr("&No"));
471
 
        if (n == 0)
 
472
        if (PsiOptions::instance()->getOption("options.ui.chat.warn-before-clear").toBool()) {
 
473
                switch (
 
474
                        QMessageBox::warning(
 
475
                                this,
 
476
                                tr("Warning"),
 
477
                                tr("Are you sure you want to clear the chat window?\n(note: does not affect saved history)"),
 
478
                                QMessageBox::Yes, QMessageBox::YesAll, QMessageBox::No
 
479
                        )
 
480
                ) {
 
481
                case QMessageBox::No:
 
482
                        break;
 
483
                case QMessageBox::YesAll:
 
484
                        PsiOptions::instance()->setOption("options.ui.chat.warn-before-clear", false);
 
485
                        // fall-through
 
486
                case QMessageBox::Yes:
 
487
                        doClear();
 
488
                }
 
489
        } else {
472
490
                doClear();
 
491
        }
473
492
}
474
493
 
475
494
void PsiChatDlg::setPGPEnabled(bool enabled)
507
526
        ui_.lb_count->setNum(chatEdit()->toPlainText().length());
508
527
}
509
528
 
510
 
void PsiChatDlg::appendEmoteMessage(SpooledType spooled, const QDateTime& time, bool local, QString txt)
 
529
void PsiChatDlg::appendEmoteMessage(SpooledType spooled, const QDateTime& time, bool local, const QString& txt, const QString& subject)
511
530
{
512
531
        updateLastMsgTime(time);
513
532
        QString color = colorString(local, spooled);
514
533
        QString timestr = chatView()->formatTimeStamp(time);
515
534
 
516
 
        chatView()->appendText(QString("<span style=\"color: %1\">").arg(color) + QString("[%1]").arg(timestr) + QString(" *%1 ").arg(whoNick(local)) + txt + "</span>");
 
535
        if (subject.isEmpty()) {
 
536
                chatView()->appendText(QString("<span style=\"color: %1\">").arg(color) + QString("[%1]").arg(timestr) + QString(" *%1 ").arg(whoNick(local)) + txt + "</span>");
 
537
        } else {
 
538
                chatView()->appendText(QString("<span style=\"color: %1\">").arg(color) + QString("[%1]").arg(timestr) + "</span><br><b>" + tr("Subject:") + "</b> " + subject);
 
539
                chatView()->appendText(QString("<span style=\"color: %1\">").arg(color) + QString(" *%1 ").arg(whoNick(local)) + txt + "</span>");
 
540
        }
 
541
 
517
542
}
518
543
 
519
 
void PsiChatDlg::appendNormalMessage(SpooledType spooled, const QDateTime& time, bool local, QString txt)
 
544
void PsiChatDlg::appendNormalMessage(SpooledType spooled, const QDateTime& time, bool local, const QString& txt, const QString& subject)
520
545
{
521
546
        updateLastMsgTime(time);
522
547
        QString color = colorString(local, spooled);
523
548
        QString timestr = chatView()->formatTimeStamp(time);
 
549
        QString subjectLine;
 
550
        if (!subject.isEmpty()) {
 
551
                subjectLine = "<b>" + tr("Subject:") + "</b> " + subject;
 
552
        }
524
553
 
525
554
        if (PsiOptions::instance()->getOption("options.ui.chat.use-chat-says-style").toBool()) {
526
 
                chatView()->appendText(QString("<p style=\"color: %1\">").arg(color) + QString("[%1] ").arg(timestr) + tr("%1 says:").arg(whoNick(local)) + "</p>" + txt);
 
555
                chatView()->appendText(QString("<span style=\"color: %1\">").arg(color) + QString("[%1] ").arg(timestr) + tr("%1 says:").arg(whoNick(local)) + "</span>");
 
556
                if (!subjectLine.isEmpty()) {
 
557
                        chatView()->appendText(subjectLine);
 
558
                }
 
559
                chatView()->appendText(txt);
527
560
        }
528
561
        else {
529
 
                chatView()->appendText(QString("<span style=\"color: %1\">").arg(color) + QString("[%1] &lt;").arg(timestr) + whoNick(local) + QString("&gt;</span> ") + txt);
 
562
                QString intro = QString("<span style=\"color: %1\">").arg(color) + QString("[%1] &lt;").arg(timestr) + whoNick(local) + QString("&gt;</span>");
 
563
                if (subjectLine.isEmpty()) {
 
564
                        chatView()->appendText(intro + " " + txt);
 
565
                } else {
 
566
                        chatView()->appendText(intro);
 
567
                        chatView()->appendText(subjectLine);
 
568
                        chatView()->appendText(txt);
 
569
                }
 
570
 
530
571
        }
531
572
}
532
573
 
533
574
void PsiChatDlg::appendMessageFields(const Message& m)
534
575
{
535
 
        if (!m.subject().isEmpty()) {
536
 
                chatView()->appendText(QString("<b>") + tr("Subject:") + "</b> " + QString("%1").arg(Qt::escape(m.subject())));
537
 
        }
 
576
//      if (!m.subject().isEmpty()) {
 
577
//              chatView()->appendText(QString("<b>") + tr("Subject:") + "</b> " + QString("%1").arg(Qt::escape(m.subject())));
 
578
//      }
538
579
        if (!m.urlList().isEmpty()) {
539
580
                UrlList urls = m.urlList();
540
581
                chatView()->appendText(QString("<i>") + tr("-- Attached URL(s) --") + "</i>");
556
597
        QDateTime t = QDateTime::currentDateTime();
557
598
        updateLastMsgTime(t);
558
599
        QString timestr = chatView()->formatTimeStamp(t);
559
 
        QString color = PsiOptions::instance()->getOption("options.ui.look.colors.messages.informational").toString();
 
600
        QString color = ColorOpt::instance()->color("options.ui.look.colors.messages.informational").name();
560
601
 
561
602
        chatView()->appendText(QString("<font color=\"%1\">[%2]").arg(color, timestr) + QString(" *** %1</font>").arg(str));
562
603
}
564
605
QString PsiChatDlg::colorString(bool local, ChatDlg::SpooledType spooled) const
565
606
{
566
607
        if (spooled == ChatDlg::Spooled_OfflineStorage) {
567
 
                return PsiOptions::instance()->getOption("options.ui.look.colors.messages.informational").toString();
 
608
                return ColorOpt::instance()->color("options.ui.look.colors.messages.informational").name();
568
609
        }
569
610
 
570
611
        if (local) {
571
 
                return PsiOptions::instance()->getOption("options.ui.look.colors.messages.sent").toString();
 
612
                return ColorOpt::instance()->color("options.ui.look.colors.messages.sent").name();
572
613
        }
573
614
 
574
 
        return PsiOptions::instance()->getOption("options.ui.look.colors.messages.received").toString();
 
615
        return ColorOpt::instance()->color("options.ui.look.colors.messages.received").name();
575
616
}
576
617
 
577
618
ChatView* PsiChatDlg::chatView() const
635
676
                }
636
677
 
637
678
                tabCompletion.reset();
638
 
                return false;
639
679
        }
640
680
 
641
681
        return ChatDlg::eventFilter( obj, ev );