23 #include "gui/irc/ircdocktabcontents.h" 24 #include "gui/irc/ircnetworkselectionbox.h" 25 #include "gui/irc/ircsounds.h" 26 #include "irc/configuration/chatnetworkscfg.h" 27 #include "irc/configuration/ircconfig.h" 28 #include "irc/ircnetworkadapter.h" 30 #include "ui_ircdock.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()));
80 pNewAdapterWidget->setIRCAdapter(pIRCAdapter);
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)
92 pWidget->applyAppearanceSettings();
98 int tabIndex = d->tabWidget->indexOf(pCaller);
100 tabCloseRequestedSlot(tabIndex);
114 pIRCNetworkAdapter->connect();
117 tabFocusRequest(pTab);
122 return this->d->tabWidget->currentWidget() == pTab;
128 if (pWidget ==
nullptr)
131 return pWidget->ircAdapter()->network();
134 void IRCDock::performNetworkAutojoins()
137 connectionInfo.
alternateNick = gIRCConfig.personal.alternativeNickname;
138 connectionInfo.
nick = gIRCConfig.personal.nickname;
139 connectionInfo.
realName = gIRCConfig.personal.fullName;
140 connectionInfo.
userName = gIRCConfig.personal.userName;
142 QList<IRCNetworkEntity> autojoinNetworks =
ChatNetworksCfg().autoJoinNetworks();
147 connectToNewNetwork(connectionInfo.
autoFilled(),
false);
153 if (pMessageSender !=
nullptr)
156 if (pTargetNetwork != pMessageSender)
157 return QString(
"%1: %2").arg(pMessageSender->
title(), message);
163 void IRCDock::setupToolbar()
165 auto pToolBar =
new QToolBar(
this);
166 pToolBar->setMovable(
false);
167 pToolBar->setOrientation(Qt::Vertical);
169 d->toolBarConnect =
new QAction(QIcon(
":/icons/network-connect-3.png"), tr(
"Connect"), pToolBar);
170 d->toolBarOpenChatWindow =
new QAction(QIcon(
":/icons/irc_channel.png"), tr(
"Open chat window"), pToolBar);
172 pToolBar->addAction(d->toolBarConnect);
173 pToolBar->addAction(d->toolBarOpenChatWindow);
175 d->horizontalLayout->insertWidget(0, pToolBar);
176 connect(pToolBar, SIGNAL(actionTriggered(QAction*)),
this, SLOT(toolBarAction(QAction*)));
184 void IRCDock::tabCloseRequestedSlot(
int index)
186 QWidget *pPageWidget = d->tabWidget->widget(index);
187 d->tabWidget->removeTab(index);
192 void IRCDock::tabCurrentChanged(
int index)
196 d->tabWidget->tabBarPublic()->setTabTextColor(index,
"");
204 d->tabWidget->setCurrentWidget(pCaller);
209 if (d->tabWidget->currentWidget() !=
nullptr)
210 return static_cast<IRCDockTabContents *>(d->tabWidget->currentWidget());
216 int tabIndex = d->tabWidget->indexOf(caller);
218 d->tabWidget->setTabText(tabIndex, caller->title());
221 void IRCDock::titleChangeWithColorOfSenderIfNotFocused()
224 int tabIndex = d->tabWidget->indexOf(caller);
227 d->tabWidget->setTabText(tabIndex, caller->title());
228 d->tabWidget->tabBarPublic()->setTabTextColor(tabIndex, caller->titleColor());
232 void IRCDock::toolBarAction(QAction *pAction)
234 if (pAction == d->toolBarConnect)
237 if (networkSelection.exec() == QDialog::Accepted)
243 gIRCConfig.personal.alternativeNickname = connectionInfo.
alternateNick;
244 gIRCConfig.personal.nickname = connectionInfo.
nick;
245 gIRCConfig.personal.fullName = connectionInfo.
realName;
246 gIRCConfig.personal.userName = connectionInfo.
userName;
248 connectToNewNetwork(connectionInfo.
autoFilled(),
true);
251 else if (pAction == d->toolBarOpenChatWindow)
254 if (pNetwork ==
nullptr)
255 QMessageBox::warning(
nullptr, tr(
"Doomseeker IRC - Open chat window"), tr(
"Cannot obtain network connection adapter."));
256 else if (!pNetwork->isConnected())
257 QMessageBox::warning(
nullptr, tr(
"Doomseeker IRC - Open chat window"), tr(
"You are not connected to this network."));
260 QString recipientName = QInputDialog::getText(
nullptr, tr(
"Open chat window"), tr(
"Specify a channel or user name:"));
261 if (!recipientName.isEmpty())
Interprets communication between the client and the IRC server.
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.