~ubuntu-branches/ubuntu/oneiric/psi/oneiric

« back to all changes in this revision

Viewing changes to src/groupchatdlg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2006-01-20 00:20:36 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060120002036-7nw6yo6totip0ee5
Tags: 0.10-2
* Added upstream changelog (Closes: Bug#327748)
* Mention --no-gpg and --no-gpg-agent in manpage (Closes: Bug#204416)

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#include<qaction.h>
36
36
#include<qobjectlist.h>
37
37
#include<qpopupmenu.h>
 
38
#include<qcursor.h>
38
39
#include"psicon.h"
39
40
#include"psiaccount.h"
40
41
#include"userlist.h"
44
45
#include"msgmle.h"
45
46
#include"iconwidget.h"
46
47
#include"iconselect.h"
 
48
#include"psitoolbar.h"
47
49
#include"iconaction.h"
48
50
 
49
51
#ifdef Q_WS_WIN
360
362
 
361
363
        QPopupMenu *pm = new QPopupMenu;
362
364
        pm->insertItem(IconsetFactory::icon("psi/sendMessage"), tr("Send &message"), 0);
363
 
        pm->insertItem(IconsetFactory::icon("psi/chat"), tr("Open &chat window"), 1);
 
365
        pm->insertItem(IconsetFactory::icon("psi/start-chat"), tr("Open &chat window"), 1);
364
366
        pm->insertSeparator();
365
367
        //pm->insertItem(tr("Send &file"), 4);
366
368
        //pm->insertSeparator();
399
401
        QLineEdit *le_topic;
400
402
        GCUserView *lv_users;
401
403
        QPushButton *pb_topic;
402
 
        IconAction *act_find;
403
 
        IconToolButton *tb_clear, *tb_icon;
 
404
        PsiToolBar *toolbar;
 
405
        IconAction *act_find, *act_clear, *act_icon;
 
406
        QPopupMenu *pm_settings;
 
407
        bool smallChat;
404
408
        int pending;
405
409
 
406
410
        bool trackBar;
660
664
};
661
665
 
662
666
GCMainDlg::GCMainDlg(PsiAccount *pa, const Jid &j)
663
 
:QWidget(0, 0, WDestructiveClose)
 
667
:AdvancedWidget<QWidget>(0, 0, WDestructiveClose)
664
668
{
665
669
        nicknumber=0;
666
670
        d = new Private(this);
685
689
        setIcon(IconsetFactory::icon("psi/groupChat"));
686
690
#endif
687
691
 
688
 
        d->act_find = new IconAction(tr("Find"), "psi/search", tr("&Find"), CTRL+Key_F, this);
689
 
        connect(d->act_find, SIGNAL(activated()), SLOT(openFind()));
690
 
 
691
 
        QVBoxLayout *dlg_layout = new QVBoxLayout(this);
692
 
 
693
 
        QSplitter *vsplit = new QSplitter(this);
694
 
        vsplit->setOrientation( QSplitter::Vertical );
695
 
        dlg_layout->addWidget(vsplit);
 
692
        QVBoxLayout *dlg_layout = new QVBoxLayout(this, 4);
 
693
 
 
694
        QWidget *vsplit;
 
695
        if ( !option.chatLineEdit ) {
 
696
                vsplit = new QSplitter(this);
 
697
                ((QSplitter *)vsplit)->setOrientation( QSplitter::Vertical );
 
698
                dlg_layout->addWidget(vsplit);
 
699
        }
 
700
        else
 
701
                vsplit = this;
696
702
 
697
703
        // --- top part ---
698
704
        QWidget *sp_top = new QWidget(vsplit);
699
 
        QVBoxLayout *vb_top = new QVBoxLayout(sp_top, 4);
 
705
        sp_top->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
 
706
        if ( option.chatLineEdit )
 
707
                dlg_layout->addWidget( sp_top );
 
708
        QVBoxLayout *vb_top = new QVBoxLayout(sp_top, 0, 4);
700
709
 
701
710
        // top row
702
 
        QHBoxLayout *hb_top = new QHBoxLayout(vb_top);
 
711
        QWidget *sp_top_top = new QWidget( sp_top );
 
712
        vb_top->addWidget( sp_top_top );
 
713
        QHBoxLayout *hb_top = new QHBoxLayout( sp_top_top, 0, 4 );
703
714
 
704
 
        d->pb_topic = new QPushButton(tr("Topic:"), sp_top);
 
715
        d->pb_topic = new QPushButton(tr("Topic:"), sp_top_top);
705
716
        connect(d->pb_topic, SIGNAL(clicked()), SLOT(doTopic()));
706
717
        hb_top->addWidget(d->pb_topic);
707
718
 
708
 
        d->le_topic = new QLineEdit(sp_top);
 
719
        d->le_topic = new QLineEdit(sp_top_top);
709
720
        d->le_topic->setReadOnly(true);
710
721
        hb_top->addWidget(d->le_topic);
711
722
 
712
 
        IconToolButton *tb_find = new IconToolButton(sp_top);
713
 
        tb_find->setIcon(IconsetFactory::iconPtr("psi/search"));
714
 
        connect(tb_find, SIGNAL(clicked()), SLOT(openFind()));
715
 
        hb_top->addWidget(tb_find);
 
723
        d->act_find = new IconAction(tr("Find"), "psi/search", tr("&Find"), CTRL+Key_F, this);
 
724
        connect(d->act_find, SIGNAL(activated()), SLOT(openFind()));
 
725
        d->act_find->addTo( sp_top_top );
716
726
 
717
 
        QLabel *lb_ident = d->pa->accountLabel(sp_top, true);
 
727
        QLabel *lb_ident = d->pa->accountLabel(sp_top_top, true);
718
728
        lb_ident->setSizePolicy(QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ));
719
729
        hb_top->addWidget(lb_ident);
720
730
 
726
736
 
727
737
        d->te_log = new ChatView(hsp);
728
738
        d->te_log->setTextFormat( RichText );
 
739
#ifdef Q_WS_MAC
 
740
        connect(d->te_log,SIGNAL(selectionChanged()),SLOT(logSelectionChanged()));
 
741
        d->te_log->setFocusPolicy(QWidget::NoFocus);
 
742
#endif
729
743
 
730
744
        d->lv_users = new GCUserView(hsp);
731
745
        d->lv_users->setMinimumWidth(20);
733
747
 
734
748
        // --- bottom part ---
735
749
        QWidget *sp_bottom = new QWidget(vsplit);
736
 
        QVBoxLayout *vb_bottom = new QVBoxLayout(sp_bottom, 4);
737
 
 
738
 
        // top row
739
 
        // icon selector
740
 
        //connect(pa->psi->iconSelectPopup(), SIGNAL(iconSelected(const Icon *)), d, SLOT(addEmoticon(const Icon *)));
 
750
        sp_bottom->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum );
 
751
        if ( option.chatLineEdit )
 
752
                dlg_layout->addWidget( sp_bottom );
 
753
        QVBoxLayout *vb_bottom = new QVBoxLayout(sp_bottom);
 
754
 
 
755
        // toolbar
 
756
        d->act_clear = new IconAction (tr("Clear chat window"), "psi/clearChat", tr("Clear chat window"), 0, this);
 
757
        connect( d->act_clear, SIGNAL( activated() ), SLOT( doClearButton() ) );
 
758
 
741
759
        connect(pa->psi()->iconSelectPopup(), SIGNAL(textSelected(QString)), d, SLOT(addEmoticon(QString)));
742
 
 
743
 
        d->tb_clear = new IconToolButton(sp_bottom) ;
744
 
        d->tb_clear->setIcon(IconsetFactory::iconPtr("psi/clearChat"));
745
 
        connect(d->tb_clear, SIGNAL(clicked()), SLOT(doClearButton()));
746
 
 
747
 
        d->tb_icon = new IconToolButton(sp_bottom);
748
 
        d->tb_icon->setIcon(IconsetFactory::iconPtr("psi/smile"));
749
 
        d->tb_icon->setPopup(pa->psi()->iconSelectPopup());
750
 
        d->tb_icon->setPopupDelay (1);
751
 
 
752
 
        QHBoxLayout *toolbox = new QHBoxLayout(vb_bottom);
753
 
        toolbox->addWidget(d->tb_clear);
754
 
        toolbox->addStretch();
755
 
        toolbox->addWidget(d->tb_icon);
 
760
        d->act_icon = new IconAction( tr( "Select icon" ), "psi/smile", tr( "Select icon" ), 0, this );
 
761
        d->act_icon->setPopup( pa->psi()->iconSelectPopup() );
 
762
 
 
763
        d->toolbar = new PsiToolBar( tr("Groupchat toolbar"), 0, sp_bottom );
 
764
        d->toolbar->setCustomizeable( false ); // it isn't ready now, and we don't want segfaults
 
765
        d->toolbar->setFrameShape( QFrame::NoFrame );
 
766
        vb_bottom->addWidget( d->toolbar );
 
767
 
 
768
        d->act_clear->addTo( d->toolbar );
 
769
        d->toolbar->setStretchableWidget(new StretchWidget(d->toolbar));
 
770
        d->act_icon->addTo( d->toolbar );
756
771
 
757
772
        // chat edit
758
 
        d->mle = new ChatEdit(sp_bottom);
759
 
        //d->mle->setFixedHeight(48);
760
 
        vb_bottom->addWidget(d->mle);
 
773
        if ( !option.chatLineEdit ) {
 
774
                d->mle = new ChatEdit(sp_bottom);
 
775
                vb_bottom->addWidget(d->mle);
 
776
        }
 
777
        else {
 
778
                QHBoxLayout *hb5 = new QHBoxLayout( dlg_layout );
 
779
                d->mle = new LineEdit( vsplit );
 
780
#ifdef Q_WS_MAC
 
781
                hb5->addSpacing( 16 );
 
782
#endif
 
783
                hb5->addWidget( d->mle );
 
784
#ifdef Q_WS_MAC
 
785
                hb5->addSpacing( 16 );
 
786
#endif
 
787
        }
 
788
 
761
789
        d->mle->installEventFilter( d );
762
790
 
 
791
        d->pm_settings = new QPopupMenu(this);
 
792
        connect(d->pm_settings, SIGNAL(aboutToShow()), SLOT(buildMenu()));
 
793
 
763
794
        // resize the horizontal splitter
764
795
        QValueList<int> list;
765
796
        list << 500;
769
800
        list.clear();
770
801
        list << 324;
771
802
        list << 10;
772
 
        vsplit->setSizes(list);
 
803
        if ( !option.chatLineEdit )
 
804
                (( QSplitter *)vsplit)->setSizes(list);
773
805
 
774
806
        resize(580,420);
775
807
 
 
808
        d->smallChat = option.smallChats;
776
809
        X11WM_CLASS("groupchat");
777
810
 
778
811
        d->mle->setFocus();
830
863
        }
831
864
}
832
865
 
 
866
 
 
867
void GCMainDlg::logSelectionChanged()
 
868
{
 
869
#ifdef Q_WS_MAC
 
870
        // A hack to only give the message log focus when text is selected
 
871
        if (d->te_log->hasSelectedText()) 
 
872
                d->te_log->setFocus();
 
873
        else 
 
874
                d->mle->setFocus();
 
875
#endif
 
876
}
 
877
 
833
878
void GCMainDlg::mle_returnPressed()
834
879
{
835
880
        if(d->mle->text().isEmpty())
1319
1364
        f.fromString(option.font[fRoster]);
1320
1365
        d->lv_users->QListView::setFont(f);
1321
1366
 
1322
 
        if ( option.useEmoticons ) {
1323
 
                //d->tb_clear->show();
1324
 
                d->tb_icon->show();
 
1367
        if ( d->smallChat ) {
 
1368
                d->toolbar->hide();
1325
1369
        }
1326
1370
        else {
1327
 
                //d->tb_clear->hide();
1328
 
                d->tb_icon->hide();
 
1371
                d->toolbar->show();
1329
1372
        }
1330
1373
 
1331
1374
        // update the widget icon
1376
1419
        }
1377
1420
}
1378
1421
 
 
1422
void GCMainDlg::contextMenuEvent(QContextMenuEvent *)
 
1423
{
 
1424
        d->pm_settings->exec(QCursor::pos());
 
1425
}
 
1426
 
 
1427
void GCMainDlg::buildMenu()
 
1428
{
 
1429
        // Dialog menu
 
1430
        d->pm_settings->clear();
 
1431
        d->pm_settings->insertItem(tr("Toggle Compact/Full Size"), this, SLOT(toggleSmallChat()));
 
1432
 
 
1433
        d->act_clear->addTo( d->pm_settings );
 
1434
        d->pm_settings->insertSeparator();
 
1435
 
 
1436
        d->act_icon->addTo( d->pm_settings );
 
1437
}
 
1438
 
 
1439
void GCMainDlg::toggleSmallChat()
 
1440
{
 
1441
        d->smallChat = !d->smallChat;
 
1442
        setLooks();
 
1443
}
1379
1444
 
1380
1445
//----------------------------------------------------------------------------
1381
1446
// GCFindDlg
1436
1501
 
1437
1502
void GCFindDlg::doFind()
1438
1503
{
1439
 
        find(para, index, le_input->text());
 
1504
        emit find(para, index, le_input->text());
1440
1505
}
1441
1506
 
1442
1507
#include "groupchatdlg.moc"