diff --git a/src/widgets/dialogs/SelectChannelDialog.cpp b/src/widgets/dialogs/SelectChannelDialog.cpp index b5af90fe5..be0779190 100644 --- a/src/widgets/dialogs/SelectChannelDialog.cpp +++ b/src/widgets/dialogs/SelectChannelDialog.cpp @@ -21,6 +21,7 @@ #include "widgets/helper/EditableModelView.hpp" #define TAB_TWITCH 0 +#define TAB_IRC 1 namespace chatterino { @@ -134,7 +135,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent) // outerBox.emplace("Connection:"); { - auto view = new EditableModelView( + auto view = this->ui_.irc.servers = new EditableModelView( Irc::getInstance().newConnectionModel(this)); view->setTitles( @@ -170,7 +171,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent) { auto box = outerBox.emplace().withoutMargin(); box.emplace("Channel:"); - box.emplace(); + this->ui_.irc.channel = box.emplace().getElement(); } // auto vbox = obj.setLayoutType(); @@ -261,6 +262,30 @@ void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel) this->ui_.twitch.whispers->setFocus(); } break; + case Channel::Type::Irc: + { + this->ui_.notebook->selectIndex(TAB_IRC); + this->ui_.irc.channel->setText(_channel.get()->getName()); + + if (auto ircChannel = + dynamic_cast(_channel.get().get())) + { + if (auto server = + Irc::getInstance().getServerOfChannel(ircChannel)) + { + int i = 0; + for (auto &&conn : Irc::getInstance().connections) + { + if (conn.id == server->getId()) + { + this->ui_.irc.servers->getTableView()->selectRow(i); + break; + } + } + } + } + } + break; default: { this->ui_.notebook->selectIndex(TAB_TWITCH); @@ -302,6 +327,27 @@ IndirectChannel SelectChannelDialog::getSelectedChannel() const return app->twitch.server->whispersChannel; } } + break; + case TAB_IRC: + { + int row = this->ui_.irc.servers->getTableView() + ->selectionModel() + ->currentIndex() + .row(); + + auto &&vector = Irc::getInstance().connections.getVector(); + + if (row >= 0 && row < int(vector.size())) + { + return Irc::getInstance().getOrAddChannel( + vector[row].id, this->ui_.irc.channel->text()); + } + else + { + return Channel::getEmpty(); + } + } + break; } return this->selectedChannel_; diff --git a/src/widgets/dialogs/SelectChannelDialog.hpp b/src/widgets/dialogs/SelectChannelDialog.hpp index 5d5890d9a..51944ce7b 100644 --- a/src/widgets/dialogs/SelectChannelDialog.hpp +++ b/src/widgets/dialogs/SelectChannelDialog.hpp @@ -12,6 +12,7 @@ namespace chatterino { class Notebook; +class EditableModelView; class SelectChannelDialog final : public BaseWindow { @@ -47,6 +48,10 @@ private: QRadioButton *mentions; QRadioButton *watching; } twitch; + struct { + QLineEdit *channel; + EditableModelView *servers; + } irc; } ui_; EventFilter tabFilter_;