MainWindow::MainWindow() { setUnifiedTitleAndToolBarOnMac( true ); r = new Comms(); createActions(); createToolBars(); createDocks(); contactsList = new QListWidget(); contactsList->setMinimumWidth( 150 ); contactsList->setMinimumHeight( 250 ); contactsList->setUniformItemSizes( true ); contactsList->setSpacing( 3 ); contactsList->setWordWrap( true ); connectBox = new ConnectBox(); setCentralWidget( connectBox ); QObject::connect( r, SIGNAL( sigConnected() ), this, SLOT( slotConnected() ) ); QObject::connect( r, SIGNAL( sigRoster( QStringList* ) ), this, SLOT( slotRoster( QStringList* ) ) ); QObject::connect( r, SIGNAL( sigRosterPresence(QString, QString) ), this, SLOT( slotRosterPresence(QString, QString) ) ); QObject::connect( r, SIGNAL( sigVCardReceived(QString,QString) ), this, SLOT( slotVCardReceived(QString,QString) ) ); QObject::connect( r, SIGNAL( sigMessage(QString,QString) ), this, SLOT( slotMessage(QString,QString) ) ); QObject::connect( connectBox, SIGNAL( tryConnection(QString,QString) ), this, SLOT( setIdents(QString,QString) ) ); timer = new QTimer( this ); QObject::connect( timer, SIGNAL( timeout() ), r, SLOT( slotReceive() ) ); QObject::connect( contactsList, SIGNAL( itemDoubleClicked(QListWidgetItem*) ), this, SLOT( slotLocalSession(QListWidgetItem*) ) ); }
void KBattleshipClient::init() { if(connect()) { emit sigSocketFailure(status()); return; } m_readNotifier = new QSocketNotifier(fd(), QSocketNotifier::Read, this); QObject::connect(m_readNotifier, SIGNAL(activated(int)), SLOT(slotReadData())); emit sigConnected(); }
Matrix::Matrix(QWidget *parent) : QWidget(parent), ui(new Ui::Matrix) { ui->setupUi(this); inDXP = ""; for(int i = 0; i< 4; i++) { outDXP.append(false); }; dxpClient = new TCPClient(this); connect(dxpClient, SIGNAL(sigConnected()), this, SLOT(dxp_connected())); connect(dxpClient, SIGNAL(sigDisconnected()), this, SLOT(dxp_disconnected())); this->setEnabled(false); }
void StartUi::slotStartServer() { /* todo GameFrame if(!settings->getShowIpStats()) ip_stats->hide(); */ menuTabFrame->setSettings(); if(settings->isServer()) { qsrand(QDateTime::currentDateTime().toTime_t()); adminPassword.setNum(qrand ()); if(server) { server->kill(); delete server; } server = new QProcess(this); connect(server, SIGNAL(started()), this, SLOT(slotServerLaunched())); connect(server, SIGNAL(error(QProcess::ProcessError)), this, SLOT(slotServerLaunchedError(QProcess::ProcessError))); //read debug ouputs connect(server,SIGNAL(readyReadStandardOutput()),this,SLOT(slotReadServerDebug())); server->setReadChannelMode(QProcess::MergedChannels); QString serverCmdLine("./Serverd"); serverCmdLine += " --port "; serverCmdLine += QString::number(settings->getServerPort()); serverCmdLine += " --admin-password " + adminPassword; if(settings->isDebugMode()) serverCmdLine += " --debug-mode"; serverCmdLine += " --started-from-gui"; server->start(serverCmdLine); } else { adminPassword = menuTabFrame->getAdminPassword(); } gamePlay = new GamePlay(settings, menuTabFrame->getGraphicPreview(), menuTabFrame->getPlayerName()); NetClient *netclient = gamePlay->getNetClient(); connect( gamePlay, SIGNAL(quitGame()), this, SLOT(closeGame()), Qt::QueuedConnection ); connect( gamePlay, SIGNAL(sigLoadInterGame()), this, SLOT(slotLoadInterGame()) ); /* Connect some signals to the ourselves */ connect( netclient, SIGNAL(sigConnectionError()), this, SLOT(slotConnectionError()), Qt::QueuedConnection); connect( netclient, SIGNAL(sigGameStarted()), this, SLOT(slotGameStarted())); connect( netclient, SIGNAL(sigNetClientEnd()), this, SLOT(closeGame())); /* Connect some signals to the IP stats widget */ connect( netclient, SIGNAL(sigStatPing(int)), &ipStats, SLOT(slotStatPing(int))); connect( netclient, SIGNAL(sigStatPacketLoss(double)), &ipStats, SLOT(slotStatPacketLoss(double))); /* Connect some signals to the frame menu */ connect( netclient, SIGNAL(sigConnected()), menuTabFrame, SLOT(slotConnectedToServer())); connect( netclient, SIGNAL(sigIsServerAdmin()), menuTabFrame, SLOT(slotIsServerAdmin())); connect( netclient, SIGNAL(sigUpdatePlayerData(qint8,QString)), menuTabFrame, SLOT(slotUpdatePlayerData(qint8,QString))); connect( netclient, SIGNAL(sigMaxPlayersChanged(int)), menuTabFrame, SLOT(slotMaxPlayersValueChanged(int))); connect( netclient, SIGNAL(sigMaxWinsChanged(int)), menuTabFrame, SLOT(slotMaxWinsValueChanged(int))); connect( netclient, SIGNAL(sigMapRandom(bool)), menuTabFrame, SLOT(slotMapRandom(bool))); connect( netclient, SIGNAL(mapPreviewReceived(MapClient*)), menuTabFrame,SLOT(slotMapPreviewReceived(MapClient*))); connect( netclient, SIGNAL(sigPlayerLeft(qint8)), menuTabFrame, SLOT(slotPlayerLeft(qint8))); /* Connect some signals to the player list */ connect( netclient, SIGNAL(sigUpdatePlayerData(qint8, QString)), &playerListWidget, SLOT(slotAddPlayer(qint8, QString))); connect( gamePlay, SIGNAL(sigNewPlayerGraphic(qint8,const QPixmap &)), &playerListWidget, SLOT(slotNewPlayerGraphic(qint8,const QPixmap &))); connect( netclient, SIGNAL(sigPlayerLeft(qint8)), &playerListWidget, SLOT(slotRemovePlayer(qint8))); connect( netclient, SIGNAL(sigScoreUpdate(qint8, qint16)), &playerListWidget, SLOT(slotUpdatePlayerScore(qint8, qint16))); // must be queued otherwise NetClient instance is deleted before finishing its processing connect( netclient, SIGNAL(sigServerStopped()), this, SLOT(slotServerStopped()), Qt::QueuedConnection); // if the server is remote, try to connect immediately (otherwise server's output must be checked) if(!settings->isServer()) gamePlay->cliConnect(adminPassword); }
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))); }