+
+void InputWidget::updateEnabledState()
+{
+// FIXME: Find a visualization for this that does not disable the widget!
+// Disabling kills global action shortcuts, plus users sometimes need/want to enter text
+// even in inactive channels.
+#if 0
+ QModelIndex currentIndex = selectionModel()->currentIndex();
+
+ const Network *net = Client::networkModel()->networkByIndex(currentIndex);
+ bool enabled = false;
+ if (net) {
+ // disable inputline if it's a channelbuffer we parted from or...
+ enabled = (currentIndex.data(NetworkModel::ItemActiveRole).value<bool>() || (currentIndex.data(NetworkModel::BufferTypeRole).toInt() != BufferInfo::ChannelBuffer));
+ // ... if we're not connected to the network at all
+ enabled &= net->isConnected();
+ }
+
+ ui.inputEdit->setEnabled(enabled);
+#endif
+}
+
+
+const Network *InputWidget::currentNetwork() const
+{
+ return Client::network(_networkId);
+}
+
+
+BufferInfo InputWidget::currentBufferInfo() const
+{
+ return selectionModel()->currentIndex().data(NetworkModel::BufferInfoRole).value<BufferInfo>();
+}
+
+
+void InputWidget::applyFormatActiveColor()
+{
+ if (!ui.textcolorButton->defaultAction()) {
+ return;
+ }
+ colorChosen(ui.textcolorButton->defaultAction());
+}
+
+
+void InputWidget::applyFormatActiveColorFill()
+{
+ if (!ui.highlightcolorButton->defaultAction()) {
+ return;
+ }
+ colorHighlightChosen(ui.highlightcolorButton->defaultAction());
+}
+
+
+void InputWidget::toggleFormatBold()
+{
+ setFormatBold(!ui.boldButton->isChecked());
+}
+
+
+void InputWidget::toggleFormatItalic()
+{
+ setFormatItalic(!ui.italicButton->isChecked());
+}
+
+
+void InputWidget::toggleFormatUnderline()
+{
+ setFormatUnderline(!ui.underlineButton->isChecked());
+}
+
+
+void InputWidget::clearFormat()
+{
+ // Clear all formatting for selection (not global)
+ setFormatClear(false);
+}
+
+
+void InputWidget::setNetwork(NetworkId networkId)
+{
+ if (_networkId == networkId)
+ return;
+
+ const Network *previousNet = Client::network(_networkId);
+ if (previousNet) {
+ disconnect(previousNet, nullptr, this, nullptr);
+ if (previousNet->me())
+ disconnect(previousNet->me(), nullptr, this, nullptr);
+ }
+
+ _networkId = networkId;
+
+ const Network *network = Client::network(networkId);
+ if (network) {
+ connect(network, &Network::identitySet, this, &InputWidget::setIdentity);
+ connectMyIrcUser();
+ setIdentity(network->identity());
+ }
+ else {
+ setIdentity(0);
+ _networkId = 0;
+ }
+}
+
+
+void InputWidget::connectMyIrcUser()
+{
+ const Network *network = currentNetwork();
+ if (network->me()) {
+ connect(network->me(), &IrcUser::nickSet, this, &InputWidget::updateNickSelector);
+ connect(network->me(), &IrcUser::userModesSet, this, &InputWidget::updateNickSelector);
+ connect(network->me(), &IrcUser::userModesAdded, this, &InputWidget::updateNickSelector);
+ connect(network->me(), &IrcUser::userModesRemoved, this, &InputWidget::updateNickSelector);
+ connect(network->me(), &IrcUser::awaySet, this, &InputWidget::updateNickSelector);
+ disconnect(network, &Network::myNickSet, this, &InputWidget::connectMyIrcUser);
+ updateNickSelector();
+ }
+ else {
+ connect(network, &Network::myNickSet, this, &InputWidget::connectMyIrcUser);
+ }
+}
+
+
+void InputWidget::setIdentity(IdentityId identityId)
+{
+ if (_identityId == identityId)
+ return;
+
+ const Identity *previousIdentity = Client::identity(_identityId);
+ if (previousIdentity)
+ disconnect(previousIdentity, nullptr, this, nullptr);
+
+ _identityId = identityId;
+
+ const Identity *identity = Client::identity(identityId);
+ if (identity) {
+ connect(identity, &Identity::nicksSet, this, &InputWidget::updateNickSelector);
+ }
+ else {
+ _identityId = 0;