mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
added irc tab in SelectChannelView
This commit is contained in:
parent
fd0c11964e
commit
5974438edf
2 changed files with 53 additions and 2 deletions
|
@ -21,6 +21,7 @@
|
||||||
#include "widgets/helper/EditableModelView.hpp"
|
#include "widgets/helper/EditableModelView.hpp"
|
||||||
|
|
||||||
#define TAB_TWITCH 0
|
#define TAB_TWITCH 0
|
||||||
|
#define TAB_IRC 1
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
@ -134,7 +135,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||||
// outerBox.emplace<QLabel>("Connection:");
|
// outerBox.emplace<QLabel>("Connection:");
|
||||||
|
|
||||||
{
|
{
|
||||||
auto view = new EditableModelView(
|
auto view = this->ui_.irc.servers = new EditableModelView(
|
||||||
Irc::getInstance().newConnectionModel(this));
|
Irc::getInstance().newConnectionModel(this));
|
||||||
|
|
||||||
view->setTitles(
|
view->setTitles(
|
||||||
|
@ -170,7 +171,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||||
{
|
{
|
||||||
auto box = outerBox.emplace<QHBoxLayout>().withoutMargin();
|
auto box = outerBox.emplace<QHBoxLayout>().withoutMargin();
|
||||||
box.emplace<QLabel>("Channel:");
|
box.emplace<QLabel>("Channel:");
|
||||||
box.emplace<QLineEdit>();
|
this->ui_.irc.channel = box.emplace<QLineEdit>().getElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
// auto vbox = obj.setLayoutType<QVBoxLayout>();
|
// auto vbox = obj.setLayoutType<QVBoxLayout>();
|
||||||
|
@ -261,6 +262,30 @@ void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel)
|
||||||
this->ui_.twitch.whispers->setFocus();
|
this->ui_.twitch.whispers->setFocus();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Channel::Type::Irc:
|
||||||
|
{
|
||||||
|
this->ui_.notebook->selectIndex(TAB_IRC);
|
||||||
|
this->ui_.irc.channel->setText(_channel.get()->getName());
|
||||||
|
|
||||||
|
if (auto ircChannel =
|
||||||
|
dynamic_cast<IrcChannel *>(_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:
|
default:
|
||||||
{
|
{
|
||||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
||||||
|
@ -302,6 +327,27 @@ IndirectChannel SelectChannelDialog::getSelectedChannel() const
|
||||||
return app->twitch.server->whispersChannel;
|
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_;
|
return this->selectedChannel_;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class Notebook;
|
class Notebook;
|
||||||
|
class EditableModelView;
|
||||||
|
|
||||||
class SelectChannelDialog final : public BaseWindow
|
class SelectChannelDialog final : public BaseWindow
|
||||||
{
|
{
|
||||||
|
@ -47,6 +48,10 @@ private:
|
||||||
QRadioButton *mentions;
|
QRadioButton *mentions;
|
||||||
QRadioButton *watching;
|
QRadioButton *watching;
|
||||||
} twitch;
|
} twitch;
|
||||||
|
struct {
|
||||||
|
QLineEdit *channel;
|
||||||
|
EditableModelView *servers;
|
||||||
|
} irc;
|
||||||
} ui_;
|
} ui_;
|
||||||
|
|
||||||
EventFilter tabFilter_;
|
EventFilter tabFilter_;
|
||||||
|
|
Loading…
Reference in a new issue