added irc support
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
#include "IrcConnectionEditor.hpp"
|
||||
#include "ui_IrcConnectionEditor.h"
|
||||
|
||||
IrcConnectionEditor::IrcConnectionEditor(bool isAdd, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::IrcConnectionEditor)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
this->setWindowTitle(QString(isAdd ? "Add " : "Edit ") + "Irc Connection");
|
||||
}
|
||||
|
||||
IrcConnectionEditor::~IrcConnectionEditor()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class IrcConnectionEditor;
|
||||
}
|
||||
|
||||
class IrcConnectionEditor : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit IrcConnectionEditor(bool isAdd = false, QWidget *parent = nullptr);
|
||||
~IrcConnectionEditor();
|
||||
|
||||
private:
|
||||
Ui::IrcConnectionEditor *ui;
|
||||
};
|
||||
@@ -0,0 +1,159 @@
|
||||
<?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>264</width>
|
||||
<height>258</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>Server:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="serverLineEdit"/>
|
||||
</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="passwordLabel">
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLineEdit" name="passwordLineEdit">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>IrcConnectionEditor</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</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>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "IrcConnectionPopup.hpp"
|
||||
|
||||
#include "providers/irc/Irc2.hpp"
|
||||
#include "util/LayoutHelper.hpp"
|
||||
#include "widgets/helper/EditableModelView.hpp"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QTableView>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
IrcConnectionPopup::IrcConnectionPopup(QWidget *parent)
|
||||
: BaseWindow(parent, BaseWindow::Flags::EnableCustomFrame)
|
||||
{
|
||||
this->setWindowTitle("Edit Irc Connections");
|
||||
|
||||
// view
|
||||
auto view =
|
||||
new EditableModelView(Irc::getInstance().newConnectionModel(this));
|
||||
|
||||
view->setTitles({"host", "port", "ssl", "user", "nick", "password"});
|
||||
view->getTableView()->horizontalHeader()->resizeSection(0, 140);
|
||||
view->getTableView()->horizontalHeader()->resizeSection(1, 30);
|
||||
view->getTableView()->horizontalHeader()->resizeSection(2, 30);
|
||||
|
||||
this->setScaleIndependantSize(800, 500);
|
||||
|
||||
view->addButtonPressed.connect([] {
|
||||
Irc::getInstance().connections.appendItem(IrcConnection_::unique());
|
||||
});
|
||||
|
||||
// init layout
|
||||
this->getLayoutContainer()->setLayout(makeLayout<QHBoxLayout>({view}));
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "widgets/BaseWindow.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class IrcConnectionPopup : public BaseWindow
|
||||
{
|
||||
public:
|
||||
IrcConnectionPopup(QWidget *parent);
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "singletons/Theme.hpp"
|
||||
#include "util/LayoutCreator.hpp"
|
||||
#include "widgets/Notebook.hpp"
|
||||
#include "widgets/dialogs/IrcConnectionEditor.hpp"
|
||||
#include "widgets/dialogs/IrcConnectionPopup.hpp"
|
||||
#include "widgets/helper/NotebookTab.hpp"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
@@ -14,6 +16,10 @@
|
||||
#include <QLineEdit>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <QTableView>
|
||||
#include "providers/irc/Irc2.hpp"
|
||||
#include "widgets/helper/EditableModelView.hpp"
|
||||
|
||||
#define TAB_TWITCH 0
|
||||
|
||||
namespace chatterino {
|
||||
@@ -122,21 +128,72 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||
}
|
||||
|
||||
// irc
|
||||
/*
|
||||
{
|
||||
LayoutCreator<QWidget> obj(new QWidget());
|
||||
auto outerBox = obj.setLayoutType<QVBoxLayout>();
|
||||
// outerBox.emplace<QLabel>("Connection:");
|
||||
|
||||
{
|
||||
LayoutCreator<QWidget> obj(new QWidget());
|
||||
auto vbox = obj.setLayoutType<QVBoxLayout>();
|
||||
auto form = vbox.emplace<QFormLayout>();
|
||||
auto view = new EditableModelView(
|
||||
Irc::getInstance().newConnectionModel(this));
|
||||
|
||||
form->addRow(new QLabel("User name:"), new QLineEdit());
|
||||
form->addRow(new QLabel("First nick choice:"), new QLineEdit());
|
||||
form->addRow(new QLabel("Second nick choice:"), new QLineEdit());
|
||||
form->addRow(new QLabel("Third nick choice:"), new QLineEdit());
|
||||
view->setTitles(
|
||||
{"host", "port", "ssl", "user", "nick", "password"});
|
||||
view->getTableView()->horizontalHeader()->resizeSection(0, 140);
|
||||
view->getTableView()->horizontalHeader()->resizeSection(1, 30);
|
||||
view->getTableView()->horizontalHeader()->resizeSection(2, 30);
|
||||
|
||||
auto tab = notebook->addPage(obj.getElement());
|
||||
tab->setCustomTitle("Irc");
|
||||
view->addButtonPressed.connect([] {
|
||||
Irc::getInstance().connections.appendItem(
|
||||
IrcConnection_::unique());
|
||||
});
|
||||
|
||||
outerBox->addWidget(view);
|
||||
|
||||
// auto box = outerBox.emplace<QHBoxLayout>().withoutMargin();
|
||||
|
||||
// auto conns = box.emplace<QListView>();
|
||||
// conns->addActions({new QAction("hackint")});
|
||||
|
||||
// auto buttons = box.emplace<QVBoxLayout>().withoutMargin();
|
||||
|
||||
// buttons.emplace<QPushButton>("Add").onClick(this, [this]() {
|
||||
// (new IrcConnectionPopup(this))
|
||||
// ->show(); // XXX: don't show multiple
|
||||
// });
|
||||
|
||||
// buttons.emplace<QPushButton>("Edit");
|
||||
// buttons.emplace<QPushButton>("Remove");
|
||||
// buttons->addStretch(1);
|
||||
}
|
||||
*/
|
||||
|
||||
{
|
||||
auto box = outerBox.emplace<QHBoxLayout>().withoutMargin();
|
||||
box.emplace<QLabel>("Channel:");
|
||||
box.emplace<QLineEdit>();
|
||||
}
|
||||
|
||||
// auto vbox = obj.setLayoutType<QVBoxLayout>();
|
||||
// auto form = vbox.emplace<QFormLayout>();
|
||||
|
||||
// auto servers = new QComboBox;
|
||||
// auto accounts = new QComboBox;
|
||||
//servers->setEditable(true);
|
||||
//servers->addItems(
|
||||
// {"irc://irc.hackint.org:6697", "irc://irc.somethingelse.com:6667"});
|
||||
|
||||
// form->addRow("Server:", servers);
|
||||
// form->addRow("Account:", accounts);
|
||||
// form->addRow("Channel:", new QLineEdit());
|
||||
|
||||
// form->addRow("User name:", new QLineEdit());
|
||||
// form->addRow("First nick choice:", new QLineEdit());
|
||||
// form->addRow("Second nick choice:", new QLineEdit());
|
||||
// form->addRow("Third nick choice:", new QLineEdit());
|
||||
|
||||
auto tab = notebook->addPage(obj.getElement());
|
||||
tab->setCustomTitle("Irc");
|
||||
}
|
||||
|
||||
layout->setStretchFactor(notebook.getElement(), 1);
|
||||
|
||||
@@ -151,7 +208,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||
[=](bool) { this->close(); });
|
||||
}
|
||||
|
||||
this->setScaleIndependantSize(300, 310);
|
||||
this->setMinimumSize(300, 310);
|
||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
||||
this->ui_.twitch.channel->setFocus();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user