24 #include "ui_ircdock.h" 25 #include "gui/irc/ircdocktabcontents.h" 26 #include "gui/irc/ircnetworkselectionbox.h" 27 #include "gui/irc/ircsounds.h" 28 #include "irc/configuration/chatnetworkscfg.h" 29 #include "irc/configuration/ircconfig.h" 30 #include "irc/ircnetworkadapter.h" 32 #include <QInputDialog> 33 #include <QMessageBox> 36 DClass<IRCDock> :
public Ui::IRCDock
40 QAction* toolBarConnect;
41 QAction* toolBarOpenChatWindow;
50 toggleViewAction()->setIcon(QIcon(
":/icons/chat.png"));
52 d->pSounds.loadFromConfig();
56 connect(d->tabWidget, SIGNAL( currentChanged(
int) ),
57 SLOT( tabCurrentChanged(
int) ));
59 connect(d->tabWidget, SIGNAL( tabCloseRequested(
int) ),
60 SLOT( tabCloseRequestedSlot(
int) ));
74 connect(pNewAdapterWidget, SIGNAL(newMessagePrinted()),
75 SLOT(titleChangeWithColorOfSenderIfNotFocused()));
76 connect(pNewAdapterWidget, SIGNAL(titleBlinkRequested()),
77 SLOT(titleChangeWithColorOfSenderIfNotFocused()));
80 d->tabWidget->addTab(pNewAdapterWidget, pNewAdapterWidget->icon(), pNewAdapterWidget->title());
81 this->titleChange(pNewAdapterWidget);
83 return pNewAdapterWidget;
88 for (
int i = 0; i < d->tabWidget->count(); ++i)
97 int tabIndex = d->tabWidget->indexOf(pCaller);
100 tabCloseRequestedSlot(tabIndex);
115 pIRCNetworkAdapter->connect();
119 tabFocusRequest(pTab);
125 return (this->d->tabWidget->currentWidget() == pTab);
136 return pWidget->ircAdapter()->
network();
139 void IRCDock::performNetworkAutojoins()
142 connectionInfo.
alternateNick = gIRCConfig.personal.alternativeNickname;
143 connectionInfo.
nick = gIRCConfig.personal.nickname;
144 connectionInfo.
realName = gIRCConfig.personal.fullName;
148 QList<IRCNetworkEntity> autojoinNetworks =
ChatNetworksCfg().autoJoinNetworks();
153 connectToNewNetwork(connectionInfo,
false);
159 if (pMessageSender != NULL)
162 if (pTargetNetwork != pMessageSender)
164 return QString(
"%1: %2").arg(pMessageSender->
title(), message);
171 void IRCDock::setupToolbar()
173 QToolBar* pToolBar =
new QToolBar(
this);
174 pToolBar->setMovable(
false);
175 pToolBar->setOrientation(Qt::Vertical);
177 d->toolBarConnect =
new QAction(QIcon(
":/icons/network-connect-3.png"), tr(
"Connect"), pToolBar);
178 d->toolBarOpenChatWindow =
new QAction(QIcon(
":/icons/irc_channel.png"), tr(
"Open chat window"), pToolBar);
180 pToolBar->addAction(d->toolBarConnect);
181 pToolBar->addAction(d->toolBarOpenChatWindow);
183 d->horizontalLayout->insertWidget(0, pToolBar);
184 connect(pToolBar, SIGNAL( actionTriggered(QAction*) ),
this, SLOT( toolBarAction(QAction*) ) );
192 void IRCDock::tabCloseRequestedSlot(
int index)
194 QWidget* pPageWidget = d->tabWidget->widget(index);
195 d->tabWidget->removeTab(index);
200 void IRCDock::tabCurrentChanged(
int index)
204 d->tabWidget->tabBarPublic()->setTabTextColor(index,
"");
212 d->tabWidget->setCurrentWidget(pCaller);
217 if (d->tabWidget->currentWidget() != NULL)
226 int tabIndex = d->tabWidget->indexOf(caller);
229 d->tabWidget->setTabText(tabIndex, caller->title());
233 void IRCDock::titleChangeWithColorOfSenderIfNotFocused()
236 int tabIndex = d->tabWidget->indexOf(caller);
239 d->tabWidget->setTabText(tabIndex, caller->title());
240 d->tabWidget->tabBarPublic()->setTabTextColor(tabIndex, caller->titleColor());
244 void IRCDock::toolBarAction(QAction* pAction)
246 if (pAction == d->toolBarConnect)
249 if (networkSelection.exec() == QDialog::Accepted)
255 gIRCConfig.personal.alternativeNickname = connectionInfo.
alternateNick;
256 gIRCConfig.personal.nickname = connectionInfo.
nick;
257 gIRCConfig.personal.fullName = connectionInfo.
realName;
261 connectToNewNetwork(connectionInfo,
true);
264 else if (pAction == d->toolBarOpenChatWindow)
267 if (pNetwork == NULL)
269 QMessageBox::warning(NULL, tr(
"Doomseeker IRC - Open chat window"), tr(
"Cannot obtain network connection adapter."));
271 else if (!pNetwork->isConnected())
273 QMessageBox::warning(NULL, tr(
"Doomseeker IRC - Open chat window"), tr(
"You are not connected to this network."));
277 QString recipientName = QInputDialog::getText(NULL, tr(
"Open chat window"), tr(
"Specify a channel or user name:"));
278 if (!recipientName.isEmpty())
Interprets communication between the client and the IRC server.
void setIRCAdapter(IRCAdapterBase *pAdapter)
Calling this multiple times on the same object will cause memory leaks.
Dockable widget designed for IRC communication.
void openNewAdapter(const QString &recipientName)
Opens a new chat adapter for specified recipient.
void grabFocus()
Called when tab becomes active.
Provides an unified communication interface between a client and IRC network entities.
void setEmitAllIRCMessagesEnabled(bool b)
Struct containing information about client's connection to the IRC server.
IRCNetworkEntity networkEntity
Information about the network to which we will connect.
void fillInMissingFields()
Fills missing data with presets.
Dockable widget designed for IRC communication.
virtual QString title() const =0
Gets title for this adapter.
void applyAppearanceSettings()
Applies IRC appearance settings to all open tabs.
Part of IRC UI package. Plays IRC related sounds.
virtual IRCNetworkAdapter * network()=0
The idea of the adapter system is that each adapter is either a network or is a child of a network...
Data structure that describes and defines a connection to an IRC network or server.
QString realName
User's real name. Optional.
void applyAppearanceSettings()
Applies current appearance settings from the IRC config.
QString alternateNick
Alternate nickname in case if ' nick ' is taken when connecting.
QString nick
Original nickname. This variable will always store the current nickname of the client.