MessageDialog::MessageDialog(const QString &nick, QWidget *parent) : QDialog(parent), ui(new Ui::MessageDialog)
{
    ui->setupUi(this);
    this->nick = nick;

    setWindowTitle(nick);

    QList<int> sizes;
    sizes << 600 << 100;
    ui->splitter->setSizes(sizes);

    connect(ui->pushButtonSend, SIGNAL(clicked()), this, SLOT(sendPressed()));
    connect(ui->plainTextEdit, SIGNAL(sendKeyPressed()), this, SLOT(sendPressed()));

    //smiles
    smilemenu = new QMenu(this);
    smilewidgetaction = new QWidgetAction(smilemenu);
    smilebar = new SmileBar();
    smilewidgetaction->setDefaultWidget(smilebar);
    smilemenu->addAction(smilewidgetaction);
    connect(smilebar, SIGNAL(smileClicked(QString)), ui->plainTextEdit, SLOT(insertPlainText(QString)));
    connect(smilebar, SIGNAL(smileClicked(QString)), ui->plainTextEdit, SLOT(setFocus()));
    ui->toolButtonEmoticons->setMenu(smilemenu);
}
EmoticonDialog::EmoticonDialog(QWidget * parent, Qt::WindowFlags f)
: QDialog(parent, f) {
    m_pLayout = new FlowLayout(this);

    m_pLayout->setMargin(0);
    m_pLayout->setSpacing(0);

    setWindowTitle(tr("Select emoticon"));

    QSize s;
    EmoticonFactory::getInstance()->fillLayout(m_pLayout, s);

    resize(s);

    foreach(EmoticonLabel *l, findChildren<EmoticonLabel*>())
        connect(l, SIGNAL(clicked()), this, SLOT(smileClicked()));
}
예제 #3
0
/* 
 *  Constructs a Smilies which is a child of 'parent', with the 
 *  name 'name' and widget flags set to 'f' 
 */
Smilies::Smilies( QWidget* parent,  const char* name, WFlags fl )
    : QWidget( parent, name, fl )
{
    QPixmap image0( SmallIcon("face_smile") );
    QPixmap image1( SmallIcon("face_angel") );
    QPixmap image2( SmallIcon("face_embarrassed") );
    QPixmap image3( SmallIcon("face_yell") );
    QPixmap image4( SmallIcon("face_wink") );
    QPixmap image5( SmallIcon("face_glasses") );
    QPixmap image6( SmallIcon("face_moneymouth") );
    QPixmap image7( SmallIcon("face_crossedlips") );
    QPixmap image8( SmallIcon("face_sad") );
    QPixmap image9( SmallIcon("face_scream") );
    QPixmap image10( SmallIcon("face_cry") );
    QPixmap image11( SmallIcon("face_burp") );
    QPixmap image12( SmallIcon("face_kiss") );
    QPixmap image13( SmallIcon("face_think") );
    QPixmap image14( SmallIcon("face_tongue") );
    QPixmap image15( SmallIcon("face_luke") );
    QPixmap image16( SmallIcon("face_bigsmile") );
    QPixmap image17( SmallIcon("face_oneeye") );
    if ( !name )
	setName( "Smilies" );
    resize( 124, 139 ); 
    setCaption( tr( "kaim-smiles" ) );
    SmiliesLayout = new QGridLayout( this ); 
    SmiliesLayout->setSpacing( 0 );
    SmiliesLayout->setMargin( 0 );

    smile = new QToolButton( this, "smile" );
    smile->setText( tr( " " ) );
    smile->setPixmap( image0 );

    SmiliesLayout->addWidget( smile, 0, 0 );

    angel = new QToolButton( this, "angel" );
    angel->setText( tr( " " ) );
    angel->setPixmap( image1 );

    SmiliesLayout->addWidget( angel, 2, 3 );

    embarrassed = new QToolButton( this, "embarrassed" );
    embarrassed->setText( tr( " " ) );
    embarrassed->setPixmap( image2 );

    SmiliesLayout->addWidget( embarrassed, 2, 2 );

    yell = new QToolButton( this, "yell" );
    yell->setText( tr( " " ) );
    yell->setPixmap( image3 );

    SmiliesLayout->addWidget( yell, 1, 2 );

    wink = new QToolButton( this, "wink" );
    wink->setText( tr( " " ) );
    wink->setPixmap( image4 );

    SmiliesLayout->addWidget( wink, 0, 3 );

    glasses = new QToolButton( this, "glasses" );
    glasses->setText( tr( " " ) );
    glasses->setPixmap( image5 );

    SmiliesLayout->addWidget( glasses, 2, 0 );

    moneymouth = new QToolButton( this, "moneymouth" );
    moneymouth->setText( tr( " " ) );
    moneymouth->setPixmap( image6 );

    SmiliesLayout->addWidget( moneymouth, 3, 3 );

    crossedlips = new QToolButton( this, "crossedlips" );
    crossedlips->setText( tr( " " ) );
    crossedlips->setPixmap( image7 );

    SmiliesLayout->addWidget( crossedlips, 3, 2 );

    sad = new QToolButton( this, "sad" );
    sad->setText( tr( " " ) );
    sad->setPixmap( image8 );

    SmiliesLayout->addWidget( sad, 0, 2 );

    scream = new QToolButton( this, "scream" );
    scream->setText( tr( " " ) );
    scream->setPixmap( image9 );

    SmiliesLayout->addWidget( scream, 1, 1 );

    cry = new QToolButton( this, "cry" );
    cry->setText( tr( " " ) );
    cry->setPixmap( image10 );

    SmiliesLayout->addWidget( cry, 3, 1 );

    burp = new QToolButton( this, "burp" );
    burp->setText( tr( " " ) );
    burp->setPixmap( image11 );

    SmiliesLayout->addWidget( burp, 2, 1 );

    kiss = new QToolButton( this, "kiss" );
    kiss->setText( tr( " " ) );
    kiss->setPixmap( image12 );

    SmiliesLayout->addWidget( kiss, 1, 3 );

    think = new QToolButton( this, "think" );
    think->setText( tr( " " ) );
    think->setPixmap( image13 );

    SmiliesLayout->addWidget( think, 3, 0 );

    tongue = new QToolButton( this, "tongue" );
    tongue->setText( tr( " " ) );
    tongue->setPixmap( image14 );

    SmiliesLayout->addWidget( tongue, 1, 0 );

    luke = new QToolButton( this, "luke" );
    luke->setText( tr( " " ) );
    luke->setPixmap( image15 );

    SmiliesLayout->addWidget( luke, 4, 2 );

    bigsmile = new QToolButton( this, "bigsmile" );
    bigsmile->setText( tr( " " ) );
    bigsmile->setPixmap( image16 );

    SmiliesLayout->addWidget( bigsmile, 0, 1 );

    oneeye = new QToolButton( this, "oneeye" );
    oneeye->setText( tr( " " ) );
    oneeye->setPixmap( image17 );

    SmiliesLayout->addWidget( oneeye, 4, 1 );

		QObject::connect( smile, SIGNAL(clicked()), SLOT(smileClicked()) );
		QObject::connect( angel, SIGNAL(clicked()), SLOT(angelClicked()) );
		QObject::connect( embarrassed, SIGNAL(clicked()), SLOT(embarrassedClicked()) );
		QObject::connect( yell, SIGNAL(clicked()), SLOT(yellClicked()) );
		QObject::connect( wink, SIGNAL(clicked()), SLOT(winkClicked()) );
		QObject::connect( glasses, SIGNAL(clicked()), SLOT(glassesClicked()) );
		QObject::connect( moneymouth, SIGNAL(clicked()), SLOT(moneymouthClicked()) );
		QObject::connect( crossedlips, SIGNAL(clicked()), SLOT(crossedlipsClicked()) );
		QObject::connect( sad, SIGNAL(clicked()), SLOT(sadClicked()) );
		QObject::connect( scream, SIGNAL(clicked()), SLOT(screamClicked()) );
		QObject::connect( cry, SIGNAL(clicked()), SLOT(cryClicked()) );
		QObject::connect( burp, SIGNAL(clicked()), SLOT(burpClicked()) );
		QObject::connect( kiss, SIGNAL(clicked()), SLOT(kissClicked()) );
		QObject::connect( think, SIGNAL(clicked()), SLOT(thinkClicked()) );
		QObject::connect( tongue, SIGNAL(clicked()), SLOT(tongueClicked()) );
		QObject::connect( luke, SIGNAL(clicked()), SLOT(lukeClicked()) );
		QObject::connect( bigsmile, SIGNAL(clicked()), SLOT(bigsmileClicked()) );
		QObject::connect( oneeye, SIGNAL(clicked()), SLOT(oneeyeClicked()) );

}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    readSettings();
    ui->actionSound->setChecked(settings.soundsenabled);

    irc = new QIrc();
    if (!irc->createSession())
    {
        QMessageBox::critical(this, tr("Error"), tr("Can't create session"));
        close();
        return;
    }
    connect(irc, SIGNAL(sigConnected()), this, SLOT(sltConnected()));
    connect(irc, SIGNAL(sigMessage(QString,QString)), this, SLOT(sltMessage(QString,QString)));
    connect(irc, SIGNAL(sigChannelJoined(QString,QString)), this, SLOT(sltChannelJoined(QString,QString)));
    connect(irc, SIGNAL(sigChannelParted(QString,QString,QString)), this, SLOT(sltChannelParted(QString,QString,QString)));
    connect(irc, SIGNAL(sigChannelNames(QString,QString,QStringList)), this, SLOT(sltChannelNames(QString,QString,QStringList)));
    connect(irc, SIGNAL(sigChannelMessage(QString,QString,QString)), this, SLOT(sltChannelMessage(QString,QString,QString)));
    connect(irc, SIGNAL(sigPrivateMessage(QString,QString,QString)), this, SLOT(sltPrivateMessage(QString,QString,QString)));
    connect(irc, SIGNAL(sigNick(QString,QString)), this, SLOT(sltNick(QString,QString)));
    connect(irc, SIGNAL(sigNotice(QString,QString,QString)), this, SLOT(sltNotice(QString,QString,QString)));
    connect(irc, SIGNAL(sigTopic(QString,QString,QString)), this, SLOT(sltTopic(QString,QString,QString)));
    connect(irc, SIGNAL(sigTopicSet(QString,QString,QString,QString)), this, SLOT(sltTopicSet(QString,QString,QString,QString)));
    connect(irc, SIGNAL(sigKick(QString,QString,QString)), this, SLOT(sltKick(QString,QString,QString)));
    connect(irc, SIGNAL(sigQuit(QString,QString)), this, SLOT(sltQuit(QString,QString)));
    connect(irc, SIGNAL(sigChannelModeChanged(QString,QString,QStringList)), this, SLOT(sltChannelModeChanged(QString,QString,QStringList)));
    connect(irc, SIGNAL(sigUmode(QString,QString)), this, SLOT(sltUmode(QString,QString)));
    connect(irc, SIGNAL(sigInvite(QString,QString,QString)), this, SLOT(sltInvite(QString,QString,QString)));
    connect(irc, SIGNAL(sigCtcpAction(QString,QString,QString)), this, SLOT(sltCtcpAction(QString,QString,QString)));
    connect(irc, SIGNAL(sigErrorOccured(QString)), this, SLOT(sltErrorOccured(QString)));

    consolebrowser = new QTextEdit();
    consolebrowser->setReadOnly(true);
    QFont consolefont;
    if (consolefont.fromString(settings.consolefont))
        consolebrowser->setFont(consolefont);

    if (!settings.hideconsole)
        consoleindex =ui->tabWidget->insertTab(0, consolebrowser, tr("Console"));

    setsdlg = 0;

    usercontextmenu = new QMenu(this);
    usercontextmenu->addAction(ui->actionPrivateChat);
    usercontextmenu->addAction(ui->actionInsert_to_editor);
    QMenu *managementmenu = usercontextmenu->addMenu(tr("Management"));
    managementmenu->addAction(ui->actionKick);
    managementmenu->addAction(ui->actionBan);
    managementmenu->addAction(ui->actionKickBan);
    managementmenu->addSeparator();
    managementmenu->addAction(ui->actionOp);
    managementmenu->addAction(ui->actionDeOp);
    managementmenu->addSeparator();
    managementmenu->addAction(ui->actionVoice);
    managementmenu->addAction(ui->actiondeVoice);
    connect(ui->treeWidget, SIGNAL(userContextMenu(QPoint)), this, SLOT(userContextMenuRequested(QPoint)));

    channelcontextmenu = new QMenu(this);
    channelcontextmenu->addAction(ui->actionLeave_channel);
    channelcontextmenu->addAction(ui->actionChannel_settings);
    connect(ui->treeWidget, SIGNAL(channelContextMenu(QPoint)), this, SLOT(channelContextMenuRequested(QPoint)));

    channelsettingsdialog = 0;
    trayicon = 0;
    traymenu = 0;
    setTrayIcon(settings.trayicon);
    connect(ui->actionChannel_settings, SIGNAL(triggered()), this, SLOT(channelSettingsPressed()));

    //smile menu
    smilemenu = new QMenu(this);
    smilewidgetaction = new QWidgetAction(smilemenu);
    smilebar = new SmileBar();
    smilewidgetaction->setDefaultWidget(smilebar);
    smilemenu->addAction(smilewidgetaction);
    connect(smilebar, SIGNAL(smileClicked(QString)), ui->plainTextEditMessage, SLOT(insertPlainText(QString)));
    connect(smilebar, SIGNAL(smileClicked(QString)), ui->plainTextEditMessage, SLOT(setFocus()));
    ui->actionEmoticons->setMenu(smilemenu);
    smilebutton = new QToolButton();
    smilebutton->setDefaultAction(ui->actionEmoticons);
    smilebutton->setPopupMode(QToolButton::InstantPopup);
    ui->mainToolBar->addWidget(smilebutton);

    channellistdialog = new ChannelListDialog();
    connect(irc, SIGNAL(sigChannelListStart()), channellistdialog, SLOT(showAndClear()));
    connect(irc, SIGNAL(sigChannelListAddItem(QString,QString,QString)), channellistdialog,
            SLOT(addListItem(QString,QString,QString)));
    connect(irc, SIGNAL(sigChannelListEnd()), channellistdialog, SLOT(endOfList()));
    connect(channellistdialog, SIGNAL(channelDoubleClicked(QString)), irc, SLOT(joinChannel(QString)));

    connect(ui->pushButtonSend, SIGNAL(clicked()), ui->plainTextEditMessage, SIGNAL(sendKeyPressed()));
    connect(ui->plainTextEditMessage, SIGNAL(sendKeyPressed()), this, SLOT(sendPressed()));
    connect(ui->actionConnect, SIGNAL(triggered()), this, SLOT(connectPressed()));
    connect(ui->actionDisconnect, SIGNAL(triggered()), this, SLOT(disconnectPressed()));
    connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(settingsPressed()));
    connect(ui->actionJoin, SIGNAL(triggered()), this, SLOT(joinPressed()));
    connect(ui->treeWidget, SIGNAL(userDoubleClicked(QString)), this, SLOT(userDoubleClicked(QString)));
    connect(ui->actionPrivateChat, SIGNAL(triggered()), this, SLOT(privateChatPressed()));
    connect(ui->actionLeave_channel, SIGNAL(triggered()), this, SLOT(leaveChannelPressed()));
    connect(ui->actionKick, SIGNAL(triggered()), this, SLOT(kickPressed()));
    connect(ui->actionBan, SIGNAL(triggered()), this, SLOT(BanPressed()));
    connect(ui->actionKickBan, SIGNAL(triggered()), this, SLOT(kickBanPressed()));
    connect(ui->actionOp, SIGNAL(triggered()), this, SLOT(opPressed()));
    connect(ui->actionDeOp, SIGNAL(triggered()), this, SLOT(deOpPressed()));
    connect(ui->actionVoice, SIGNAL(triggered()), this, SLOT(voicePressed()));
    connect(ui->actiondeVoice, SIGNAL(triggered()), this, SLOT(devoicePressed()));
    connect(ui->pushButtonNick, SIGNAL(clicked()), this, SLOT(nickButtonPressed()));
    connect(ui->actionList_of_channels, SIGNAL(triggered()), irc, SLOT(getChannelsList()));
    connect(ui->actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(ui->tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(tabCloseRequested(int)));
    connect(ui->actionInsert_to_editor, SIGNAL(triggered()), this, SLOT(insertUserToEditorPressed()));
    connect(ui->actionShowHide, SIGNAL(triggered()), this, SLOT(trayIconActivated()));
    connect(ui->actionQuit_program, SIGNAL(triggered()), this, SLOT(quitProgram()));
    connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(aboutPressed()));
    connect(ui->actionSound, SIGNAL(toggled(bool)), this, SLOT(soundActionToogled(bool)));
}