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> 37 DClass<IRCDock> :
public Ui::IRCDock
41 QAction* toolBarConnect;
42 QAction* toolBarOpenChatWindow;
51 toggleViewAction()->setIcon(QIcon(
":/icons/chat.png"));
53 d->pSounds.loadFromConfig();
57 connect(d->tabWidget, SIGNAL( currentChanged(
int) ),
58 SLOT( tabCurrentChanged(
int) ));
60 connect(d->tabWidget, SIGNAL( tabCloseRequested(
int) ),
61 SLOT( tabCloseRequestedSlot(
int) ));
75 connect(pNewAdapterWidget, SIGNAL(newMessagePrinted()),
76 SLOT(titleChangeWithColorOfSenderIfNotFocused()));
77 connect(pNewAdapterWidget, SIGNAL(titleBlinkRequested()),
78 SLOT(titleChangeWithColorOfSenderIfNotFocused()));
81 d->tabWidget->addTab(pNewAdapterWidget, pNewAdapterWidget->icon(), pNewAdapterWidget->title());
82 this->titleChange(pNewAdapterWidget);
84 return pNewAdapterWidget;
89 for (
int i = 0; i < d->tabWidget->count(); ++i)
98 int tabIndex = d->tabWidget->indexOf(pCaller);
101 tabCloseRequestedSlot(tabIndex);
116 pIRCNetworkAdapter->connect();
120 tabFocusRequest(pTab);
126 return (this->d->tabWidget->currentWidget() == pTab);
137 return pWidget->ircAdapter()->
network();
140 void IRCDock::performNetworkAutojoins()
143 connectionInfo.
alternateNick = gIRCConfig.personal.alternativeNickname;
144 connectionInfo.
nick = gIRCConfig.personal.nickname;
145 connectionInfo.
realName = gIRCConfig.personal.fullName;
146 connectionInfo.
userName = gIRCConfig.personal.userName;
148 QList<IRCNetworkEntity> autojoinNetworks =
ChatNetworksCfg().autoJoinNetworks();
153 connectToNewNetwork(connectionInfo.
autoFilled(),
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;
258 gIRCConfig.personal.userName = connectionInfo.
userName;
260 connectToNewNetwork(connectionInfo.
autoFilled(),
true);
263 else if (pAction == d->toolBarOpenChatWindow)
266 if (pNetwork == NULL)
268 QMessageBox::warning(NULL, tr(
"Doomseeker IRC - Open chat window"), tr(
"Cannot obtain network connection adapter."));
270 else if (!pNetwork->isConnected())
272 QMessageBox::warning(NULL, tr(
"Doomseeker IRC - Open chat window"), tr(
"You are not connected to this network."));
276 QString recipientName = QInputDialog::getText(NULL, tr(
"Open chat window"), tr(
"Specify a channel or user name:"));
277 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.
QString userName
User name sent in /user command.
Dockable widget designed for IRC communication.
QString alternateNick
Alternate nickname in case if ' nick ' is taken when connecting.
IRCNetworkConnectionInfo autoFilled() const
Fills missing data with presets.
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)
QString nick
Original nickname. This variable will always store the current nickname of the client.
Struct containing information about client's connection to the IRC server.
Dockable widget designed for IRC communication.
virtual QString title() const =0
Gets title for this adapter.
QString realName
User's real name. Optional.
IRCNetworkEntity networkEntity
Information about the network to which we will connect.
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.
void applyAppearanceSettings()
Applies current appearance settings from the IRC config.