Remove experimental IRC support (#5547)

This commit is contained in:
pajlada
2024-08-18 14:04:26 +02:00
committed by GitHub
parent cc8bd538b9
commit 998920d244
44 changed files with 478 additions and 2841 deletions
@@ -1,98 +0,0 @@
#include "widgets/dialogs/IrcConnectionEditor.hpp"
#include "ui_IrcConnectionEditor.h"
namespace chatterino {
IrcConnectionEditor::IrcConnectionEditor(const IrcServerData &data, bool isAdd,
QWidget *parent)
: QDialog(parent, Qt::WindowStaysOnTopHint)
, ui_(new Ui::IrcConnectionEditor)
, data_(data)
{
this->ui_->setupUi(this);
this->setWindowTitle(QString(isAdd ? "Add " : "Edit ") + "Irc Connection");
QObject::connect(this->ui_->userNameLineEdit, &QLineEdit::textChanged, this,
[this](const QString &text) {
this->ui_->nickNameLineEdit->setPlaceholderText(text);
this->ui_->realNameLineEdit->setPlaceholderText(text);
});
this->ui_->serverLineEdit->setText(data.host);
this->ui_->portSpinBox->setValue(data.port);
this->ui_->securityCheckBox->setChecked(data.ssl);
this->ui_->userNameLineEdit->setText(data.user);
this->ui_->nickNameLineEdit->setText(data.nick);
this->ui_->realNameLineEdit->setText(data.real);
this->ui_->connectCommandsEditor->setPlainText(
data.connectCommands.join('\n'));
data.getPassword(this, [this](const QString &password) {
this->ui_->passwordLineEdit->setText(password);
});
this->ui_->loginMethodComboBox->setCurrentIndex([&] {
switch (data.authType)
{
case IrcAuthType::Custom:
return 1;
case IrcAuthType::Pass:
return 2;
case IrcAuthType::Sasl:
return 3;
default:
return 0;
}
}());
QObject::connect(this->ui_->loginMethodComboBox,
qOverload<int>(&QComboBox::currentIndexChanged), this,
[this](int index) {
if (index == 1) // Custom
{
this->ui_->connectCommandsEditor->setFocus();
}
});
QFont font("Monospace");
font.setStyleHint(QFont::TypeWriter);
this->ui_->connectCommandsEditor->setFont(font);
}
IrcConnectionEditor::~IrcConnectionEditor()
{
delete ui_;
}
IrcServerData IrcConnectionEditor::data()
{
auto data = this->data_;
data.host = this->ui_->serverLineEdit->text();
data.port = this->ui_->portSpinBox->value();
data.ssl = this->ui_->securityCheckBox->isChecked();
data.user = this->ui_->userNameLineEdit->text();
data.nick = this->ui_->nickNameLineEdit->text();
data.real = this->ui_->realNameLineEdit->text();
data.connectCommands =
this->ui_->connectCommandsEditor->toPlainText().split('\n');
data.setPassword(this->ui_->passwordLineEdit->text());
data.authType = [this] {
switch (this->ui_->loginMethodComboBox->currentIndex())
{
case 1:
return IrcAuthType::Custom;
case 2:
return IrcAuthType::Pass;
case 3:
return IrcAuthType::Sasl;
default:
return IrcAuthType::Anonymous;
}
}();
return data;
}
} // namespace chatterino
@@ -1,38 +0,0 @@
#pragma once
#include "providers/irc/Irc2.hpp"
#include "widgets/BaseWindow.hpp"
#include <QDialog>
namespace Ui {
class IrcConnectionEditor;
} // namespace Ui
namespace chatterino {
struct IrcServerData;
class IrcConnectionEditor : public QDialog
{
Q_OBJECT
public:
explicit IrcConnectionEditor(const IrcServerData &data, bool isAdd = false,
QWidget *parent = nullptr);
IrcConnectionEditor(const IrcConnectionEditor &) = delete;
IrcConnectionEditor(IrcConnectionEditor &&) = delete;
IrcConnectionEditor &operator=(const IrcConnectionEditor &) = delete;
IrcConnectionEditor &operator=(IrcConnectionEditor &&) = delete;
~IrcConnectionEditor() override;
IrcServerData data();
private:
Ui::IrcConnectionEditor *ui_;
IrcServerData data_;
};
} // namespace chatterino
-261
View File
@@ -1,261 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>IrcConnectionEditor</class>
<widget class="QDialog" name="IrcConnectionEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>329</width>
<height>414</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="serverLabel">
<property name="text">
<string>Host:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="serverLineEdit">
<property name="placeholderText">
<string>irc.example.com</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="portLabel">
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="portSpinBox">
<property name="maximum">
<number>65636</number>
</property>
<property name="value">
<number>6697</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="securityLabel">
<property name="text">
<string>SSL:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="securityCheckBox">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QLabel" name="userNameLabel">
<property name="text">
<string>User Name:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="userNameLineEdit"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="nickNameLabel">
<property name="text">
<string>Nick Name:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="nickNameLineEdit"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="realNameLabel">
<property name="text">
<string>Real Name:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="realNameLineEdit"/>
</item>
<item row="8" column="0">
<widget class="QLabel" name="loginMethodLabel">
<property name="text">
<string>Login method:</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="passwordLabel">
<property name="text">
<string>Password:</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLineEdit" name="passwordLineEdit">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="7" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="8" column="1">
<widget class="QComboBox" name="loginMethodComboBox">
<item>
<property name="text">
<string>Anonymous</string>
</property>
</item>
<item>
<property name="text">
<string>Custom</string>
</property>
</item>
<item>
<property name="text">
<string>Server Password (/PASS $password)</string>
</property>
</item>
<item>
<property name="text">
<string>SASL</string>
</property>
</item>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="connectCommandsLabel">
<property name="text">
<string>Send IRC commands
on connect:</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QPlainTextEdit" name="connectCommandsEditor">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="11" column="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>serverLineEdit</tabstop>
<tabstop>portSpinBox</tabstop>
<tabstop>securityCheckBox</tabstop>
<tabstop>userNameLineEdit</tabstop>
<tabstop>nickNameLineEdit</tabstop>
<tabstop>realNameLineEdit</tabstop>
<tabstop>loginMethodComboBox</tabstop>
<tabstop>passwordLineEdit</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>IrcConnectionEditor</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>254</x>
<y>248</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>IrcConnectionEditor</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>254</x>
<y>248</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
+1 -189
View File
@@ -3,14 +3,10 @@
#include "Application.hpp"
#include "common/QLogging.hpp"
#include "controllers/hotkeys/HotkeyController.hpp"
#include "providers/irc/Irc2.hpp"
#include "providers/irc/IrcChannel2.hpp"
#include "providers/irc/IrcServer.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/dialogs/IrcConnectionEditor.hpp"
#include "widgets/helper/EditableModelView.hpp"
#include "widgets/helper/NotebookTab.hpp"
#include "widgets/Notebook.hpp"
@@ -28,7 +24,6 @@
namespace chatterino {
constexpr int TAB_TWITCH = 0;
constexpr int TAB_IRC = 1;
SelectChannelDialog::SelectChannelDialog(QWidget *parent)
: BaseWindow(
@@ -175,76 +170,6 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
tab->setCustomTitle("Twitch");
}
// irc
{
LayoutCreator<QWidget> obj(new QWidget());
auto outerBox = obj.setLayoutType<QFormLayout>();
{
auto *view = this->ui_.irc.servers =
new EditableModelView(Irc::instance().newConnectionModel(this));
view->setTitles({"host", "port", "ssl", "user", "nick", "real",
"password", "login command"});
view->getTableView()->horizontalHeader()->resizeSection(0, 140);
view->getTableView()->horizontalHeader()->setSectionHidden(1, true);
view->getTableView()->horizontalHeader()->setSectionHidden(2, true);
view->getTableView()->horizontalHeader()->setSectionHidden(4, true);
view->getTableView()->horizontalHeader()->setSectionHidden(5, true);
// We can safely ignore this signal's connection since the button won't be
// accessible after this dialog is closed
std::ignore = view->addButtonPressed.connect([] {
auto unique = IrcServerData{};
unique.id = Irc::instance().uniqueId();
auto *editor = new IrcConnectionEditor(unique);
if (editor->exec() == QDialog::Accepted)
{
Irc::instance().connections.append(editor->data());
}
});
QObject::connect(
view->getTableView(), &QTableView::doubleClicked,
[](const QModelIndex &index) {
auto *editor = new IrcConnectionEditor(
Irc::instance().connections.raw()[size_t(index.row())]);
if (editor->exec() == QDialog::Accepted)
{
auto data = editor->data();
auto &&conns = Irc::instance().connections.raw();
int i = 0;
for (auto &&conn : conns)
{
if (conn.id == data.id)
{
Irc::instance().connections.removeAt(
i, Irc::noEraseCredentialCaller);
Irc::instance().connections.insert(data, i);
}
i++;
}
}
});
outerBox->addRow("Server:", view);
}
outerBox->addRow("Channel: #", this->ui_.irc.channel = new QLineEdit);
auto *tab = notebook->addPage(obj.getElement());
tab->setCustomTitle("Irc (Beta)");
if (!getSettings()->enableExperimentalIrc)
{
tab->setEnable(false);
tab->setVisible(false);
}
}
layout->setStretchFactor(notebook.getElement(), 1);
auto buttons =
@@ -265,29 +190,11 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
this->ui_.notebook->selectIndex(TAB_TWITCH);
this->ui_.twitch.channel->setFocus();
// restore ui state
// fourtf: enable when releasing irc
if (getSettings()->enableExperimentalIrc)
{
this->ui_.notebook->selectIndex(getSettings()->lastSelectChannelTab);
}
this->addShortcuts();
this->ui_.irc.servers->getTableView()->selectRow(
getSettings()->lastSelectIrcConn);
}
void SelectChannelDialog::ok()
{
// save ui state
getSettings()->lastSelectChannelTab =
this->ui_.notebook->getSelectedIndex();
getSettings()->lastSelectIrcConn = this->ui_.irc.servers->getTableView()
->selectionModel()
->currentIndex()
.row();
// accept and close
this->hasSelectedChannel_ = true;
this->close();
@@ -334,31 +241,6 @@ void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel)
this->ui_.twitch.automod->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<IrcChannel *>(_channel.get().get()))
{
if (auto *server = ircChannel->server())
{
int i = 0;
for (auto &&conn : Irc::instance().connections)
{
if (conn.id == server->id())
{
this->ui_.irc.servers->getTableView()->selectRow(i);
break;
}
i++;
}
}
}
this->ui_.irc.channel->setFocus();
}
break;
default: {
this->ui_.notebook->selectIndex(TAB_TWITCH);
this->ui_.twitch.channel->setFocus();
@@ -405,25 +287,6 @@ IndirectChannel SelectChannelDialog::getSelectedChannel() const
}
}
break;
case TAB_IRC: {
int row = this->ui_.irc.servers->getTableView()
->selectionModel()
->currentIndex()
.row();
auto &&vector = Irc::instance().connections.raw();
if (row >= 0 && row < int(vector.size()))
{
return Irc::instance().getOrAddChannel(
vector[size_t(row)].id, this->ui_.irc.channel->text());
}
else
{
return Channel::getEmpty();
}
}
//break;
}
return this->selectedChannel_;
@@ -559,60 +422,9 @@ void SelectChannelDialog::addShortcuts()
{"scrollPage", nullptr},
{"search", nullptr},
{"delete", nullptr},
{"openTab", nullptr},
};
if (getSettings()->enableExperimentalIrc)
{
actions.insert(
{"openTab", [this](std::vector<QString> arguments) -> QString {
if (arguments.size() == 0)
{
qCWarning(chatterinoHotkeys)
<< "openTab shortcut called without arguments. "
"Takes only "
"one argument: tab specifier";
return "openTab shortcut called without arguments. "
"Takes only one argument: tab specifier";
}
auto target = arguments.at(0);
if (target == "last")
{
this->ui_.notebook->selectLastTab();
}
else if (target == "next")
{
this->ui_.notebook->selectNextTab();
}
else if (target == "previous")
{
this->ui_.notebook->selectPreviousTab();
}
else
{
bool ok;
int result = target.toInt(&ok);
if (ok)
{
this->ui_.notebook->selectIndex(result);
}
else
{
qCWarning(chatterinoHotkeys)
<< "Invalid argument for openTab shortcut";
return QString("Invalid argument for openTab "
"shortcut: \"%1\". Use \"last\", "
"\"next\", \"previous\" or an integer.")
.arg(target);
}
}
return "";
}});
}
else
{
actions.emplace("openTab", nullptr);
}
this->shortcuts_ = getApp()->getHotkeys()->shortcutsForCategory(
HotkeyCategory::PopupWindow, actions, this);
}
@@ -51,10 +51,6 @@ private:
QRadioButton *live;
QRadioButton *automod;
} twitch;
struct {
QLineEdit *channel;
EditableModelView *servers;
} irc;
} ui_;
EventFilter tabFilter_;
+1 -2
View File
@@ -752,8 +752,7 @@ void UserInfoPopup::setData(const QString &name,
auto type = this->channel_->getType();
if (type == Channel::Type::TwitchLive ||
type == Channel::Type::TwitchWhispers || type == Channel::Type::Irc ||
type == Channel::Type::Misc)
type == Channel::Type::TwitchWhispers || type == Channel::Type::Misc)
{
// not a normal twitch channel, the url opened by the button will be invalid, so hide the button
this->ui_.usercardLabel->hide();