Merge branch 'master' into irc-support

This commit is contained in:
fourtf
2019-09-18 13:03:16 +02:00
204 changed files with 17026 additions and 16467 deletions
+1 -1
View File
@@ -101,7 +101,7 @@ namespace {
} // namespace
EmotePopup::EmotePopup(QWidget *parent)
: BaseWindow(parent, BaseWindow::EnableCustomFrame)
: BaseWindow(BaseWindow::EnableCustomFrame, parent)
{
auto layout = new QVBoxLayout(this);
this->getLayoutContainer()->setLayout(layout);
+92 -92
View File
@@ -1,92 +1,92 @@
#include "LastRunCrashDialog.hpp"
#include <QDialogButtonBox>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include "singletons/Updates.hpp"
#include "util/LayoutCreator.hpp"
#include "util/PostToThread.hpp"
namespace chatterino {
LastRunCrashDialog::LastRunCrashDialog()
{
this->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
this->setWindowTitle("Chatterino");
auto layout =
LayoutCreator<LastRunCrashDialog>(this).setLayoutType<QVBoxLayout>();
layout.emplace<QLabel>("The application wasn't terminated properly the "
"last time it was executed.");
layout->addSpacing(16);
// auto update = layout.emplace<QLabel>();
auto buttons = layout.emplace<QDialogButtonBox>();
// auto *installUpdateButton = buttons->addButton("Install Update",
// QDialogButtonBox::NoRole); installUpdateButton->setEnabled(false);
// QObject::connect(installUpdateButton, &QPushButton::clicked, [this,
// update]() mutable {
// auto &updateManager = UpdateManager::getInstance();
// updateManager.installUpdates();
// this->setEnabled(false);
// update->setText("Downloading updates...");
// });
auto *okButton =
buttons->addButton("Ignore", QDialogButtonBox::ButtonRole::NoRole);
QObject::connect(okButton, &QPushButton::clicked,
[this] { this->accept(); });
// Updates
// auto updateUpdateLabel = [update]() mutable {
// auto &updateManager = UpdateManager::getInstance();
// switch (updateManager.getStatus()) {
// case UpdateManager::None: {
// update->setText("Not checking for updates.");
// } break;
// case UpdateManager::Searching: {
// update->setText("Checking for updates...");
// } break;
// case UpdateManager::UpdateAvailable: {
// update->setText("Update available.");
// } break;
// case UpdateManager::NoUpdateAvailable: {
// update->setText("No update abailable.");
// } break;
// case UpdateManager::SearchFailed: {
// update->setText("Error while searching for update.\nEither
// the update service is "
// "temporarily down or there is an issue
// with your installation.");
// } break;
// case UpdateManager::Downloading: {
// update->setText(
// "Downloading the update. Chatterino will close once
// the download is done.");
// } break;
// case UpdateManager::DownloadFailed: {
// update->setText("Download failed.");
// } break;
// case UpdateManager::WriteFileFailed: {
// update->setText("Writing the update file to the hard drive
// failed.");
// } break;
// }
// };
// updateUpdateLabel();
// this->managedConnect(updateManager.statusUpdated,
// [updateUpdateLabel](auto) mutable {
// postToThread([updateUpdateLabel]() mutable { updateUpdateLabel();
// });
// });
}
} // namespace chatterino
#include "LastRunCrashDialog.hpp"
#include <QDialogButtonBox>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include "singletons/Updates.hpp"
#include "util/LayoutCreator.hpp"
#include "util/PostToThread.hpp"
namespace chatterino {
LastRunCrashDialog::LastRunCrashDialog()
{
this->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
this->setWindowTitle("Chatterino");
auto layout =
LayoutCreator<LastRunCrashDialog>(this).setLayoutType<QVBoxLayout>();
layout.emplace<QLabel>("The application wasn't terminated properly the "
"last time it was executed.");
layout->addSpacing(16);
// auto update = layout.emplace<QLabel>();
auto buttons = layout.emplace<QDialogButtonBox>();
// auto *installUpdateButton = buttons->addButton("Install Update",
// QDialogButtonBox::NoRole); installUpdateButton->setEnabled(false);
// QObject::connect(installUpdateButton, &QPushButton::clicked, [this,
// update]() mutable {
// auto &updateManager = UpdateManager::getInstance();
// updateManager.installUpdates();
// this->setEnabled(false);
// update->setText("Downloading updates...");
// });
auto *okButton =
buttons->addButton("Ignore", QDialogButtonBox::ButtonRole::NoRole);
QObject::connect(okButton, &QPushButton::clicked,
[this] { this->accept(); });
// Updates
// auto updateUpdateLabel = [update]() mutable {
// auto &updateManager = UpdateManager::getInstance();
// switch (updateManager.getStatus()) {
// case UpdateManager::None: {
// update->setText("Not checking for updates.");
// } break;
// case UpdateManager::Searching: {
// update->setText("Checking for updates...");
// } break;
// case UpdateManager::UpdateAvailable: {
// update->setText("Update available.");
// } break;
// case UpdateManager::NoUpdateAvailable: {
// update->setText("No update abailable.");
// } break;
// case UpdateManager::SearchFailed: {
// update->setText("Error while searching for update.\nEither
// the update service is "
// "temporarily down or there is an issue
// with your installation.");
// } break;
// case UpdateManager::Downloading: {
// update->setText(
// "Downloading the update. Chatterino will close once
// the download is done.");
// } break;
// case UpdateManager::DownloadFailed: {
// update->setText("Download failed.");
// } break;
// case UpdateManager::WriteFileFailed: {
// update->setText("Writing the update file to the hard drive
// failed.");
// } break;
// }
// };
// updateUpdateLabel();
// this->managedConnect(updateManager.statusUpdated,
// [updateUpdateLabel](auto) mutable {
// postToThread([updateUpdateLabel]() mutable { updateUpdateLabel();
// });
// });
}
} // namespace chatterino
+14 -14
View File
@@ -1,14 +1,14 @@
#pragma once
#include <QDialog>
#include <pajlada/signals/signalholder.hpp>
namespace chatterino {
class LastRunCrashDialog : public QDialog, pajlada::Signals::SignalHolder
{
public:
LastRunCrashDialog();
};
} // namespace chatterino
#pragma once
#include <QDialog>
#include <pajlada/signals/signalholder.hpp>
namespace chatterino {
class LastRunCrashDialog : public QDialog, pajlada::Signals::SignalHolder
{
public:
LastRunCrashDialog();
};
} // namespace chatterino
+25 -25
View File
@@ -4,6 +4,7 @@
#include "common/Channel.hpp"
#include "common/NetworkRequest.hpp"
#include "debug/Log.hpp"
#include "messages/Message.hpp"
#include "providers/twitch/PartialTwitchUser.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchMessageBuilder.hpp"
@@ -20,34 +21,30 @@ namespace chatterino {
LogsPopup::LogsPopup()
: channel_(Channel::getEmpty())
{
this->initLayout();
this->resize(400, 600);
}
void LogsPopup::initLayout()
{
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setMargin(0);
this->channelView_ = new ChannelView(this);
layout->addWidget(this->channelView_);
this->setLayout(layout);
}
void LogsPopup::setChannelName(QString channelName)
{
this->channelName_ = channelName;
}
void LogsPopup::setChannel(std::shared_ptr<Channel> channel)
void LogsPopup::setChannel(const ChannelPtr &channel)
{
this->channel_ = channel;
this->updateWindowTitle();
}
void LogsPopup::setTargetUserName(QString userName)
void LogsPopup::setChannelName(const QString &channelName)
{
this->channelName_ = channelName;
this->updateWindowTitle();
}
void LogsPopup::setTargetUserName(const QString &userName)
{
this->userName_ = userName;
this->updateWindowTitle();
}
void LogsPopup::updateWindowTitle()
{
this->setWindowTitle(this->userName_ + "'s logs in #" + this->channelName_);
}
void LogsPopup::getLogs()
@@ -60,8 +57,6 @@ void LogsPopup::getLogs()
this->channelName_ = twitchChannel->getName();
this->getLogviewerLogs(twitchChannel->roomId());
this->setWindowTitle(this->userName_ + "'s logs in #" +
this->channelName_);
return;
}
}
@@ -83,7 +78,7 @@ void LogsPopup::setMessages(std::vector<MessagePtr> &messages)
ChannelPtr logsChannel(new Channel("logs", Channel::Type::Misc));
logsChannel->addMessagesAtStart(messages);
this->channelView_->setChannel(logsChannel);
SearchPopup::setChannel(logsChannel);
}
void LogsPopup::getLogviewerLogs(const QString &roomID)
@@ -121,6 +116,8 @@ void LogsPopup::getLogviewerLogs(const QString &roomID)
static_cast<Communi::IrcPrivateMessage *>(ircMessage);
TwitchMessageBuilder builder(this->channel_.get(), privMsg,
args);
builder.message().searchText = message;
messages.push_back(builder.build());
}
@@ -165,6 +162,7 @@ void LogsPopup::getOverrustleLogs()
for (auto i : dataMessages)
{
QJsonObject singleMessage = i.toObject();
auto text = singleMessage.value("text").toString();
QTime timeStamp =
QDateTime::fromSecsSinceEpoch(
singleMessage.value("timestamp").toInt())
@@ -175,9 +173,10 @@ void LogsPopup::getOverrustleLogs()
builder.emplace<TextElement>(this->userName_,
MessageElementFlag::Username,
MessageColor::System);
builder.emplace<TextElement>(
singleMessage.value("text").toString(),
MessageElementFlag::Text, MessageColor::Text);
builder.emplace<TextElement>(text, MessageElementFlag::Text,
MessageColor::Text);
builder.message().messageText = text;
builder.message().displayName = this->userName_;
messages.push_back(builder.release());
}
}
@@ -191,4 +190,5 @@ void LogsPopup::getOverrustleLogs()
})
.execute();
}
} // namespace chatterino
+8 -16
View File
@@ -1,37 +1,29 @@
#pragma once
#include "widgets/BaseWindow.hpp"
#include "widgets/helper/SearchPopup.hpp"
namespace chatterino {
class Channel;
class ChannelView;
class Channel;
using ChannelPtr = std::shared_ptr<Channel>;
struct Message;
using MessagePtr = std::shared_ptr<const Message>;
class LogsPopup : public BaseWindow
class LogsPopup : public SearchPopup
{
public:
LogsPopup();
void setChannelName(QString channelName);
void setChannel(std::shared_ptr<Channel> channel);
void setTargetUserName(QString userName);
void setChannel(const ChannelPtr &channel) override;
void setChannelName(const QString &channelName);
void setTargetUserName(const QString &userName);
void getLogs();
protected:
void updateWindowTitle() override;
private:
ChannelView *channelView_ = nullptr;
ChannelPtr channel_;
QString userName_;
QString channelName_;
void initLayout();
void setMessages(std::vector<MessagePtr> &messages);
void getOverrustleLogs();
void getLogviewerLogs(const QString &roomID);
+54 -54
View File
@@ -1,54 +1,54 @@
#include "NotificationPopup.hpp"
#include "common/Channel.hpp"
#include "messages/Message.hpp"
#include "widgets/helper/ChannelView.hpp"
#include <QApplication>
#include <QDesktopWidget>
#include <QScreen>
namespace chatterino {
NotificationPopup::NotificationPopup()
: BaseWindow((QWidget *)nullptr, BaseWindow::Frameless)
, channel_(std::make_shared<Channel>("notifications", Channel::Type::None))
{
this->channelView_ = new ChannelView(this);
auto *layout = new QVBoxLayout(this);
this->setLayout(layout);
layout->addWidget(this->channelView_);
this->channelView_->setChannel(this->channel_);
this->setScaleIndependantSize(300, 150);
}
void NotificationPopup::updatePosition()
{
Location location = BottomRight;
QDesktopWidget *desktop = QApplication::desktop();
const QRect rect = desktop->availableGeometry();
switch (location)
{
case BottomRight:
{
this->move(rect.right() - this->width(),
rect.bottom() - this->height());
}
break;
}
}
void NotificationPopup::addMessage(MessagePtr msg)
{
this->channel_->addMessage(msg);
// QTimer::singleShot(5000, this, [this, msg] { this->channel->remove });
}
} // namespace chatterino
#include "NotificationPopup.hpp"
#include "common/Channel.hpp"
#include "messages/Message.hpp"
#include "widgets/helper/ChannelView.hpp"
#include <QApplication>
#include <QDesktopWidget>
#include <QScreen>
namespace chatterino {
NotificationPopup::NotificationPopup()
: BaseWindow(BaseWindow::Frameless)
, channel_(std::make_shared<Channel>("notifications", Channel::Type::None))
{
this->channelView_ = new ChannelView(this);
auto *layout = new QVBoxLayout(this);
this->setLayout(layout);
layout->addWidget(this->channelView_);
this->channelView_->setChannel(this->channel_);
this->setScaleIndependantSize(300, 150);
}
void NotificationPopup::updatePosition()
{
Location location = BottomRight;
QDesktopWidget *desktop = QApplication::desktop();
const QRect rect = desktop->availableGeometry();
switch (location)
{
case BottomRight:
{
this->move(rect.right() - this->width(),
rect.bottom() - this->height());
}
break;
}
}
void NotificationPopup::addMessage(MessagePtr msg)
{
this->channel_->addMessage(msg);
// QTimer::singleShot(5000, this, [this, msg] { this->channel->remove });
}
} // namespace chatterino
+29 -29
View File
@@ -1,29 +1,29 @@
#pragma once
#include "widgets/BaseWindow.hpp"
namespace chatterino {
class ChannelView;
class Channel;
using ChannelPtr = std::shared_ptr<Channel>;
struct Message;
using MessagePtr = std::shared_ptr<const Message>;
class NotificationPopup : public BaseWindow
{
public:
enum Location { TopLeft, TopRight, BottomLeft, BottomRight };
NotificationPopup();
void addMessage(MessagePtr msg);
void updatePosition();
private:
ChannelView *channelView_;
ChannelPtr channel_;
};
} // namespace chatterino
#pragma once
#include "widgets/BaseWindow.hpp"
namespace chatterino {
class ChannelView;
class Channel;
using ChannelPtr = std::shared_ptr<Channel>;
struct Message;
using MessagePtr = std::shared_ptr<const Message>;
class NotificationPopup : public BaseWindow
{
public:
enum Location { TopLeft, TopRight, BottomLeft, BottomRight };
NotificationPopup();
void addMessage(MessagePtr msg);
void updatePosition();
private:
ChannelView *channelView_;
ChannelPtr channel_;
};
} // namespace chatterino
+473 -473
View File
@@ -1,473 +1,473 @@
#include "SelectChannelDialog.hpp"
#include "Application.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
#include "singletons/Theme.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/Notebook.hpp"
#include "widgets/dialogs/IrcConnectionEditor.hpp"
#include "widgets/helper/NotebookTab.hpp"
#include <QDialogButtonBox>
#include <QFormLayout>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
#include <QVBoxLayout>
#include <QTableView>
#include "providers/irc/Irc2.hpp"
#include "widgets/helper/EditableModelView.hpp"
#define TAB_TWITCH 0
#define TAB_IRC 1
namespace chatterino {
SelectChannelDialog::SelectChannelDialog(QWidget *parent)
: BaseWindow(parent, BaseWindow::EnableCustomFrame)
, selectedChannel_(Channel::getEmpty())
{
this->setWindowTitle("Select a channel to join");
this->tabFilter_.dialog = this;
LayoutCreator<QWidget> layoutWidget(this->getLayoutContainer());
auto layout = layoutWidget.setLayoutType<QVBoxLayout>().withoutMargin();
auto notebook = layout.emplace<Notebook>(this).assign(&this->ui_.notebook);
// twitch
{
LayoutCreator<QWidget> obj(new QWidget());
auto vbox = obj.setLayoutType<QVBoxLayout>();
// channel_btn
auto channel_btn = vbox.emplace<QRadioButton>("Channel").assign(
&this->ui_.twitch.channel);
auto channel_lbl =
vbox.emplace<QLabel>("Join a twitch channel by its name.").hidden();
channel_lbl->setWordWrap(true);
auto channel_edit = vbox.emplace<QLineEdit>().hidden().assign(
&this->ui_.twitch.channelName);
QObject::connect(channel_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable {
if (enabled)
{
channel_edit->setFocus();
channel_edit->setSelection(
0, channel_edit->text().length());
}
channel_edit->setVisible(enabled);
channel_lbl->setVisible(enabled);
});
channel_btn->installEventFilter(&this->tabFilter_);
channel_edit->installEventFilter(&this->tabFilter_);
// whispers_btn
auto whispers_btn = vbox.emplace<QRadioButton>("Whispers")
.assign(&this->ui_.twitch.whispers);
auto whispers_lbl =
vbox.emplace<QLabel>("Shows the whispers that you receive while "
"chatterino is running.")
.hidden();
whispers_lbl->setWordWrap(true);
whispers_btn->installEventFilter(&this->tabFilter_);
QObject::connect(
whispers_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable { whispers_lbl->setVisible(enabled); });
// mentions_btn
auto mentions_btn = vbox.emplace<QRadioButton>("Mentions")
.assign(&this->ui_.twitch.mentions);
auto mentions_lbl =
vbox.emplace<QLabel>("Shows all the messages that highlight you "
"from any channel.")
.hidden();
mentions_lbl->setWordWrap(true);
mentions_btn->installEventFilter(&this->tabFilter_);
QObject::connect(
mentions_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable { mentions_lbl->setVisible(enabled); });
// watching_btn
auto watching_btn = vbox.emplace<QRadioButton>("Watching")
.assign(&this->ui_.twitch.watching);
auto watching_lbl =
vbox.emplace<QLabel>("Requires the chatterino browser extension.")
.hidden();
watching_lbl->setWordWrap(true);
watching_btn->installEventFilter(&this->tabFilter_);
QObject::connect(
watching_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable { watching_lbl->setVisible(enabled); });
vbox->addStretch(1);
// tabbing order
QWidget::setTabOrder(watching_btn.getElement(),
channel_btn.getElement());
QWidget::setTabOrder(channel_btn.getElement(),
whispers_btn.getElement());
QWidget::setTabOrder(whispers_btn.getElement(),
mentions_btn.getElement());
QWidget::setTabOrder(mentions_btn.getElement(),
watching_btn.getElement());
// tab
auto tab = notebook->addPage(obj.getElement());
tab->setCustomTitle("Twitch");
}
// irc
{
LayoutCreator<QWidget> obj(new QWidget());
auto outerBox = obj.setLayoutType<QFormLayout>();
{
auto view = this->ui_.irc.servers = new EditableModelView(
Irc::getInstance().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);
view->addButtonPressed.connect([] {
auto unique = IrcServerData{};
unique.id = Irc::getInstance().uniqueId();
auto editor = new IrcConnectionEditor(unique);
if (editor->exec() == QDialog::Accepted)
{
Irc::getInstance().connections.appendItem(editor->data());
}
});
QObject::connect(
view->getTableView(), &QTableView::doubleClicked,
[](const QModelIndex &index) {
auto editor = new IrcConnectionEditor(
Irc::getInstance()
.connections.getVector()[size_t(index.row())]);
if (editor->exec() == QDialog::Accepted)
{
auto data = editor->data();
auto &&conns =
Irc::getInstance().connections.getVector();
int i = 0;
for (auto &&conn : conns)
{
if (conn.id == data.id)
{
Irc::getInstance().connections.removeItem(
i, Irc::noEraseCredentialCaller);
Irc::getInstance().connections.insertItem(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)");
}
layout->setStretchFactor(notebook.getElement(), 1);
auto buttons =
layout.emplace<QHBoxLayout>().emplace<QDialogButtonBox>(this);
{
auto *button_ok = buttons->addButton(QDialogButtonBox::Ok);
QObject::connect(button_ok, &QPushButton::clicked,
[=](bool) { this->ok(); });
auto *button_cancel = buttons->addButton(QDialogButtonBox::Cancel);
QObject::connect(button_cancel, &QAbstractButton::clicked,
[=](bool) { this->close(); });
}
this->setMinimumSize(300, 310);
this->ui_.notebook->selectIndex(TAB_TWITCH);
this->ui_.twitch.channel->setFocus();
// Shortcuts
auto *shortcut_ok = new QShortcut(QKeySequence("Return"), this);
QObject::connect(shortcut_ok, &QShortcut::activated, [=] { this->ok(); });
auto *shortcut_cancel = new QShortcut(QKeySequence("Esc"), this);
QObject::connect(shortcut_cancel, &QShortcut::activated,
[=] { this->close(); });
// restore ui state
this->ui_.notebook->selectIndex(getSettings()->lastSelectChannelTab);
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();
}
void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel)
{
auto channel = _channel.get();
assert(channel);
this->selectedChannel_ = channel;
switch (_channel.getType())
{
case Channel::Type::Twitch:
{
this->ui_.notebook->selectIndex(TAB_TWITCH);
this->ui_.twitch.channel->setFocus();
this->ui_.twitch.channelName->setText(channel->getName());
}
break;
case Channel::Type::TwitchWatching:
{
this->ui_.notebook->selectIndex(TAB_TWITCH);
this->ui_.twitch.watching->setFocus();
}
break;
case Channel::Type::TwitchMentions:
{
this->ui_.notebook->selectIndex(TAB_TWITCH);
this->ui_.twitch.mentions->setFocus();
}
break;
case Channel::Type::TwitchWhispers:
{
this->ui_.notebook->selectIndex(TAB_TWITCH);
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<IrcChannel *>(_channel.get().get()))
{
if (auto server = ircChannel->server())
{
int i = 0;
for (auto &&conn : Irc::getInstance().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();
}
}
this->hasSelectedChannel_ = false;
}
IndirectChannel SelectChannelDialog::getSelectedChannel() const
{
if (!this->hasSelectedChannel_)
{
return this->selectedChannel_;
}
auto app = getApp();
switch (this->ui_.notebook->getSelectedIndex())
{
case TAB_TWITCH:
{
if (this->ui_.twitch.channel->isChecked())
{
return app->twitch.server->getOrAddChannel(
this->ui_.twitch.channelName->text().trimmed());
}
else if (this->ui_.twitch.watching->isChecked())
{
return app->twitch.server->watchingChannel;
}
else if (this->ui_.twitch.mentions->isChecked())
{
return app->twitch.server->mentionsChannel;
}
else if (this->ui_.twitch.whispers->isChecked())
{
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[size_t(row)].id, this->ui_.irc.channel->text());
}
else
{
return Channel::getEmpty();
}
}
//break;
}
return this->selectedChannel_;
}
bool SelectChannelDialog::hasSeletedChannel() const
{
return this->hasSelectedChannel_;
}
bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched,
QEvent *event)
{
auto *widget = static_cast<QWidget *>(watched);
if (event->type() == QEvent::FocusIn)
{
widget->grabKeyboard();
auto *radio = dynamic_cast<QRadioButton *>(watched);
if (radio)
{
radio->setChecked(true);
}
return true;
}
else if (event->type() == QEvent::FocusOut)
{
widget->releaseKeyboard();
return false;
}
else if (event->type() == QEvent::KeyPress)
{
QKeyEvent *event_key = static_cast<QKeyEvent *>(event);
if ((event_key->key() == Qt::Key_Tab ||
event_key->key() == Qt::Key_Down) &&
event_key->modifiers() == Qt::NoModifier)
{
if (widget == this->dialog->ui_.twitch.channelName)
{
this->dialog->ui_.twitch.whispers->setFocus();
return true;
}
else
{
widget->nextInFocusChain()->setFocus();
}
return true;
}
else if (((event_key->key() == Qt::Key_Tab ||
event_key->key() == Qt::Key_Backtab) &&
event_key->modifiers() == Qt::ShiftModifier) ||
((event_key->key() == Qt::Key_Up) &&
event_key->modifiers() == Qt::NoModifier))
{
if (widget == this->dialog->ui_.twitch.channelName)
{
this->dialog->ui_.twitch.watching->setFocus();
return true;
}
else if (widget == this->dialog->ui_.twitch.whispers)
{
this->dialog->ui_.twitch.channel->setFocus();
return true;
}
widget->previousInFocusChain()->setFocus();
return true;
}
else
{
return false;
}
}
else if (event->type() == QEvent::KeyRelease)
{
QKeyEvent *event_key = static_cast<QKeyEvent *>(event);
if ((event_key->key() == Qt::Key_Backtab ||
event_key->key() == Qt::Key_Down) &&
event_key->modifiers() == Qt::NoModifier)
{
return true;
}
}
return false;
}
void SelectChannelDialog::closeEvent(QCloseEvent *)
{
this->closed.invoke();
}
void SelectChannelDialog::themeChangedEvent()
{
BaseWindow::themeChangedEvent();
if (this->theme->isLightTheme())
{
this->setStyleSheet(
"QRadioButton { color: #000 } QLabel { color: #000 }");
}
else
{
this->setStyleSheet(
"QRadioButton { color: #fff } QLabel { color: #fff }");
}
}
} // namespace chatterino
#include "SelectChannelDialog.hpp"
#include "Application.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
#include "singletons/Theme.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/Notebook.hpp"
#include "widgets/dialogs/IrcConnectionEditor.hpp"
#include "widgets/helper/NotebookTab.hpp"
#include <QDialogButtonBox>
#include <QFormLayout>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
#include <QVBoxLayout>
#include <QTableView>
#include "providers/irc/Irc2.hpp"
#include "widgets/helper/EditableModelView.hpp"
#define TAB_TWITCH 0
#define TAB_IRC 1
namespace chatterino {
SelectChannelDialog::SelectChannelDialog(QWidget *parent)
: BaseWindow(parent, BaseWindow::EnableCustomFrame)
, selectedChannel_(Channel::getEmpty())
{
this->setWindowTitle("Select a channel to join");
this->tabFilter_.dialog = this;
LayoutCreator<QWidget> layoutWidget(this->getLayoutContainer());
auto layout = layoutWidget.setLayoutType<QVBoxLayout>().withoutMargin();
auto notebook = layout.emplace<Notebook>(this).assign(&this->ui_.notebook);
// twitch
{
LayoutCreator<QWidget> obj(new QWidget());
auto vbox = obj.setLayoutType<QVBoxLayout>();
// channel_btn
auto channel_btn = vbox.emplace<QRadioButton>("Channel").assign(
&this->ui_.twitch.channel);
auto channel_lbl =
vbox.emplace<QLabel>("Join a twitch channel by its name.").hidden();
channel_lbl->setWordWrap(true);
auto channel_edit = vbox.emplace<QLineEdit>().hidden().assign(
&this->ui_.twitch.channelName);
QObject::connect(channel_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable {
if (enabled)
{
channel_edit->setFocus();
channel_edit->setSelection(
0, channel_edit->text().length());
}
channel_edit->setVisible(enabled);
channel_lbl->setVisible(enabled);
});
channel_btn->installEventFilter(&this->tabFilter_);
channel_edit->installEventFilter(&this->tabFilter_);
// whispers_btn
auto whispers_btn = vbox.emplace<QRadioButton>("Whispers")
.assign(&this->ui_.twitch.whispers);
auto whispers_lbl =
vbox.emplace<QLabel>("Shows the whispers that you receive while "
"chatterino is running.")
.hidden();
whispers_lbl->setWordWrap(true);
whispers_btn->installEventFilter(&this->tabFilter_);
QObject::connect(
whispers_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable { whispers_lbl->setVisible(enabled); });
// mentions_btn
auto mentions_btn = vbox.emplace<QRadioButton>("Mentions")
.assign(&this->ui_.twitch.mentions);
auto mentions_lbl =
vbox.emplace<QLabel>("Shows all the messages that highlight you "
"from any channel.")
.hidden();
mentions_lbl->setWordWrap(true);
mentions_btn->installEventFilter(&this->tabFilter_);
QObject::connect(
mentions_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable { mentions_lbl->setVisible(enabled); });
// watching_btn
auto watching_btn = vbox.emplace<QRadioButton>("Watching")
.assign(&this->ui_.twitch.watching);
auto watching_lbl =
vbox.emplace<QLabel>("Requires the chatterino browser extension.")
.hidden();
watching_lbl->setWordWrap(true);
watching_btn->installEventFilter(&this->tabFilter_);
QObject::connect(
watching_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable { watching_lbl->setVisible(enabled); });
vbox->addStretch(1);
// tabbing order
QWidget::setTabOrder(watching_btn.getElement(),
channel_btn.getElement());
QWidget::setTabOrder(channel_btn.getElement(),
whispers_btn.getElement());
QWidget::setTabOrder(whispers_btn.getElement(),
mentions_btn.getElement());
QWidget::setTabOrder(mentions_btn.getElement(),
watching_btn.getElement());
// tab
auto tab = notebook->addPage(obj.getElement());
tab->setCustomTitle("Twitch");
}
// irc
{
LayoutCreator<QWidget> obj(new QWidget());
auto outerBox = obj.setLayoutType<QFormLayout>();
{
auto view = this->ui_.irc.servers = new EditableModelView(
Irc::getInstance().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);
view->addButtonPressed.connect([] {
auto unique = IrcServerData{};
unique.id = Irc::getInstance().uniqueId();
auto editor = new IrcConnectionEditor(unique);
if (editor->exec() == QDialog::Accepted)
{
Irc::getInstance().connections.appendItem(editor->data());
}
});
QObject::connect(
view->getTableView(), &QTableView::doubleClicked,
[](const QModelIndex &index) {
auto editor = new IrcConnectionEditor(
Irc::getInstance()
.connections.getVector()[size_t(index.row())]);
if (editor->exec() == QDialog::Accepted)
{
auto data = editor->data();
auto &&conns =
Irc::getInstance().connections.getVector();
int i = 0;
for (auto &&conn : conns)
{
if (conn.id == data.id)
{
Irc::getInstance().connections.removeItem(
i, Irc::noEraseCredentialCaller);
Irc::getInstance().connections.insertItem(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)");
}
layout->setStretchFactor(notebook.getElement(), 1);
auto buttons =
layout.emplace<QHBoxLayout>().emplace<QDialogButtonBox>(this);
{
auto *button_ok = buttons->addButton(QDialogButtonBox::Ok);
QObject::connect(button_ok, &QPushButton::clicked,
[=](bool) { this->ok(); });
auto *button_cancel = buttons->addButton(QDialogButtonBox::Cancel);
QObject::connect(button_cancel, &QAbstractButton::clicked,
[=](bool) { this->close(); });
}
this->setMinimumSize(300, 310);
this->ui_.notebook->selectIndex(TAB_TWITCH);
this->ui_.twitch.channel->setFocus();
// Shortcuts
auto *shortcut_ok = new QShortcut(QKeySequence("Return"), this);
QObject::connect(shortcut_ok, &QShortcut::activated, [=] { this->ok(); });
auto *shortcut_cancel = new QShortcut(QKeySequence("Esc"), this);
QObject::connect(shortcut_cancel, &QShortcut::activated,
[=] { this->close(); });
// restore ui state
this->ui_.notebook->selectIndex(getSettings()->lastSelectChannelTab);
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();
}
void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel)
{
auto channel = _channel.get();
assert(channel);
this->selectedChannel_ = channel;
switch (_channel.getType())
{
case Channel::Type::Twitch:
{
this->ui_.notebook->selectIndex(TAB_TWITCH);
this->ui_.twitch.channel->setFocus();
this->ui_.twitch.channelName->setText(channel->getName());
}
break;
case Channel::Type::TwitchWatching:
{
this->ui_.notebook->selectIndex(TAB_TWITCH);
this->ui_.twitch.watching->setFocus();
}
break;
case Channel::Type::TwitchMentions:
{
this->ui_.notebook->selectIndex(TAB_TWITCH);
this->ui_.twitch.mentions->setFocus();
}
break;
case Channel::Type::TwitchWhispers:
{
this->ui_.notebook->selectIndex(TAB_TWITCH);
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<IrcChannel *>(_channel.get().get()))
{
if (auto server = ircChannel->server())
{
int i = 0;
for (auto &&conn : Irc::getInstance().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();
}
}
this->hasSelectedChannel_ = false;
}
IndirectChannel SelectChannelDialog::getSelectedChannel() const
{
if (!this->hasSelectedChannel_)
{
return this->selectedChannel_;
}
auto app = getApp();
switch (this->ui_.notebook->getSelectedIndex())
{
case TAB_TWITCH:
{
if (this->ui_.twitch.channel->isChecked())
{
return app->twitch.server->getOrAddChannel(
this->ui_.twitch.channelName->text().trimmed());
}
else if (this->ui_.twitch.watching->isChecked())
{
return app->twitch.server->watchingChannel;
}
else if (this->ui_.twitch.mentions->isChecked())
{
return app->twitch.server->mentionsChannel;
}
else if (this->ui_.twitch.whispers->isChecked())
{
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[size_t(row)].id, this->ui_.irc.channel->text());
}
else
{
return Channel::getEmpty();
}
}
//break;
}
return this->selectedChannel_;
}
bool SelectChannelDialog::hasSeletedChannel() const
{
return this->hasSelectedChannel_;
}
bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched,
QEvent *event)
{
auto *widget = static_cast<QWidget *>(watched);
if (event->type() == QEvent::FocusIn)
{
widget->grabKeyboard();
auto *radio = dynamic_cast<QRadioButton *>(watched);
if (radio)
{
radio->setChecked(true);
}
return true;
}
else if (event->type() == QEvent::FocusOut)
{
widget->releaseKeyboard();
return false;
}
else if (event->type() == QEvent::KeyPress)
{
QKeyEvent *event_key = static_cast<QKeyEvent *>(event);
if ((event_key->key() == Qt::Key_Tab ||
event_key->key() == Qt::Key_Down) &&
event_key->modifiers() == Qt::NoModifier)
{
if (widget == this->dialog->ui_.twitch.channelName)
{
this->dialog->ui_.twitch.whispers->setFocus();
return true;
}
else
{
widget->nextInFocusChain()->setFocus();
}
return true;
}
else if (((event_key->key() == Qt::Key_Tab ||
event_key->key() == Qt::Key_Backtab) &&
event_key->modifiers() == Qt::ShiftModifier) ||
((event_key->key() == Qt::Key_Up) &&
event_key->modifiers() == Qt::NoModifier))
{
if (widget == this->dialog->ui_.twitch.channelName)
{
this->dialog->ui_.twitch.watching->setFocus();
return true;
}
else if (widget == this->dialog->ui_.twitch.whispers)
{
this->dialog->ui_.twitch.channel->setFocus();
return true;
}
widget->previousInFocusChain()->setFocus();
return true;
}
else
{
return false;
}
}
else if (event->type() == QEvent::KeyRelease)
{
QKeyEvent *event_key = static_cast<QKeyEvent *>(event);
if ((event_key->key() == Qt::Key_Backtab ||
event_key->key() == Qt::Key_Down) &&
event_key->modifiers() == Qt::NoModifier)
{
return true;
}
}
return false;
}
void SelectChannelDialog::closeEvent(QCloseEvent *)
{
this->closed.invoke();
}
void SelectChannelDialog::themeChangedEvent()
{
BaseWindow::themeChangedEvent();
if (this->theme->isLightTheme())
{
this->setStyleSheet(
"QRadioButton { color: #000 } QLabel { color: #000 }");
}
else
{
this->setStyleSheet(
"QRadioButton { color: #fff } QLabel { color: #fff }");
}
}
} // namespace chatterino
+66 -66
View File
@@ -1,66 +1,66 @@
#pragma once
#include "Application.hpp"
#include "common/Channel.hpp"
#include "widgets/BaseWindow.hpp"
#include <pajlada/signals/signal.hpp>
#include <QLabel>
#include <QRadioButton>
namespace chatterino {
class Notebook;
class EditableModelView;
class SelectChannelDialog final : public BaseWindow
{
public:
SelectChannelDialog(QWidget *parent = nullptr);
void setSelectedChannel(IndirectChannel selectedChannel_);
IndirectChannel getSelectedChannel() const;
bool hasSeletedChannel() const;
pajlada::Signals::NoArgSignal closed;
protected:
virtual void closeEvent(QCloseEvent *) override;
virtual void themeChangedEvent() override;
private:
class EventFilter : public QObject
{
public:
SelectChannelDialog *dialog;
protected:
virtual bool eventFilter(QObject *watched, QEvent *event) override;
};
struct {
Notebook *notebook;
struct {
QRadioButton *channel;
QLineEdit *channelName;
QRadioButton *whispers;
QRadioButton *mentions;
QRadioButton *watching;
} twitch;
struct {
QLineEdit *channel;
EditableModelView *servers;
} irc;
} ui_;
EventFilter tabFilter_;
ChannelPtr selectedChannel_;
bool hasSelectedChannel_ = false;
void ok();
friend class EventFilter;
};
} // namespace chatterino
#pragma once
#include "Application.hpp"
#include "common/Channel.hpp"
#include "widgets/BaseWindow.hpp"
#include <pajlada/signals/signal.hpp>
#include <QLabel>
#include <QRadioButton>
namespace chatterino {
class Notebook;
class EditableModelView;
class SelectChannelDialog final : public BaseWindow
{
public:
SelectChannelDialog(QWidget *parent = nullptr);
void setSelectedChannel(IndirectChannel selectedChannel_);
IndirectChannel getSelectedChannel() const;
bool hasSeletedChannel() const;
pajlada::Signals::NoArgSignal closed;
protected:
virtual void closeEvent(QCloseEvent *) override;
virtual void themeChangedEvent() override;
private:
class EventFilter : public QObject
{
public:
SelectChannelDialog *dialog;
protected:
virtual bool eventFilter(QObject *watched, QEvent *event) override;
};
struct {
Notebook *notebook;
struct {
QRadioButton *channel;
QLineEdit *channelName;
QRadioButton *whispers;
QRadioButton *mentions;
QRadioButton *watching;
} twitch;
struct {
QLineEdit *channel;
EditableModelView *servers;
} irc;
} ui_;
EventFilter tabFilter_;
ChannelPtr selectedChannel_;
bool hasSelectedChannel_ = false;
void ok();
friend class EventFilter;
};
} // namespace chatterino
+2 -2
View File
@@ -24,7 +24,7 @@ namespace chatterino {
SettingsDialog *SettingsDialog::handle = nullptr;
SettingsDialog::SettingsDialog()
: BaseWindow(nullptr, BaseWindow::DisableCustomScaling)
: BaseWindow(BaseWindow::DisableCustomScaling)
{
this->setWindowTitle("Chatterino Settings");
@@ -41,7 +41,7 @@ SettingsDialog::SettingsDialog()
void SettingsDialog::initUi()
{
auto outerBox = LayoutCreator<SettingsDialog>(this)
auto outerBox = LayoutCreator<QWidget>(this->getLayoutContainer())
.setLayoutType<QVBoxLayout>()
.withoutSpacing();
+91 -92
View File
@@ -1,92 +1,91 @@
#include "UpdateDialog.hpp"
#include "singletons/Updates.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/Label.hpp"
#include <QDialogButtonBox>
#include <QPushButton>
#include <QVBoxLayout>
namespace chatterino {
UpdateDialog::UpdateDialog()
: BaseWindow(nullptr,
BaseWindow::Flags(BaseWindow::Frameless | BaseWindow::TopMost |
BaseWindow::EnableCustomFrame))
{
auto layout =
LayoutCreator<UpdateDialog>(this).setLayoutType<QVBoxLayout>();
layout.emplace<Label>("You shouldn't be seeing this dialog.")
.assign(&this->ui_.label);
auto buttons = layout.emplace<QDialogButtonBox>();
auto install = buttons->addButton("Install", QDialogButtonBox::AcceptRole);
this->ui_.installButton = install;
auto dismiss = buttons->addButton("Dismiss", QDialogButtonBox::RejectRole);
QObject::connect(install, &QPushButton::clicked, this, [this] {
Updates::getInstance().installUpdates();
this->close();
});
QObject::connect(dismiss, &QPushButton::clicked, this, [this] {
this->buttonClicked.invoke(Dismiss);
this->close();
});
this->updateStatusChanged(Updates::getInstance().getStatus());
this->connections_.managedConnect(
Updates::getInstance().statusUpdated,
[this](auto status) { this->updateStatusChanged(status); });
this->setScaleIndependantHeight(150);
}
void UpdateDialog::updateStatusChanged(Updates::Status status)
{
this->ui_.installButton->setVisible(status == Updates::UpdateAvailable);
switch (status)
{
case Updates::UpdateAvailable:
{
this->ui_.label->setText(
QString("An update (%1) is available.\n\nDo you want to "
"download and install it?")
.arg(Updates::getInstance().getOnlineVersion()));
this->updateGeometry();
}
break;
case Updates::SearchFailed:
{
this->ui_.label->setText("Failed to load version information.");
}
break;
case Updates::Downloading:
{
this->ui_.label->setText(
"Downloading updates.\n\nChatterino will restart "
"automatically when the download is done.");
}
break;
case Updates::DownloadFailed:
{
this->ui_.label->setText("Failed to download the update.");
}
break;
case Updates::WriteFileFailed:
{
this->ui_.label->setText("Failed to save the update to disk.");
}
break;
default:;
}
}
} // namespace chatterino
#include "UpdateDialog.hpp"
#include "singletons/Updates.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/Label.hpp"
#include <QDialogButtonBox>
#include <QPushButton>
#include <QVBoxLayout>
namespace chatterino {
UpdateDialog::UpdateDialog()
: BaseWindow({BaseWindow::Frameless, BaseWindow::TopMost,
BaseWindow::EnableCustomFrame})
{
auto layout =
LayoutCreator<UpdateDialog>(this).setLayoutType<QVBoxLayout>();
layout.emplace<Label>("You shouldn't be seeing this dialog.")
.assign(&this->ui_.label);
auto buttons = layout.emplace<QDialogButtonBox>();
auto install = buttons->addButton("Install", QDialogButtonBox::AcceptRole);
this->ui_.installButton = install;
auto dismiss = buttons->addButton("Dismiss", QDialogButtonBox::RejectRole);
QObject::connect(install, &QPushButton::clicked, this, [this] {
Updates::getInstance().installUpdates();
this->close();
});
QObject::connect(dismiss, &QPushButton::clicked, this, [this] {
this->buttonClicked.invoke(Dismiss);
this->close();
});
this->updateStatusChanged(Updates::getInstance().getStatus());
this->connections_.managedConnect(
Updates::getInstance().statusUpdated,
[this](auto status) { this->updateStatusChanged(status); });
this->setScaleIndependantHeight(150);
}
void UpdateDialog::updateStatusChanged(Updates::Status status)
{
this->ui_.installButton->setVisible(status == Updates::UpdateAvailable);
switch (status)
{
case Updates::UpdateAvailable:
{
this->ui_.label->setText(
QString("An update (%1) is available.\n\nDo you want to "
"download and install it?")
.arg(Updates::getInstance().getOnlineVersion()));
this->updateGeometry();
}
break;
case Updates::SearchFailed:
{
this->ui_.label->setText("Failed to load version information.");
}
break;
case Updates::Downloading:
{
this->ui_.label->setText(
"Downloading updates.\n\nChatterino will restart "
"automatically when the download is done.");
}
break;
case Updates::DownloadFailed:
{
this->ui_.label->setText("Failed to download the update.");
}
break;
case Updates::WriteFileFailed:
{
this->ui_.label->setText("Failed to save the update to disk.");
}
break;
default:;
}
}
} // namespace chatterino
+32 -32
View File
@@ -1,32 +1,32 @@
#pragma once
#include "pajlada/signals/signalholder.hpp"
#include "singletons/Updates.hpp"
#include "widgets/BaseWindow.hpp"
#include "widgets/Label.hpp"
class QPushButton;
namespace chatterino {
class UpdateDialog : public BaseWindow
{
public:
enum Button { Dismiss, Install };
UpdateDialog();
pajlada::Signals::Signal<Button> buttonClicked;
private:
void updateStatusChanged(Updates::Status status);
struct {
Label *label = nullptr;
QPushButton *installButton = nullptr;
} ui_;
pajlada::Signals::SignalHolder connections_;
};
} // namespace chatterino
#pragma once
#include "pajlada/signals/signalholder.hpp"
#include "singletons/Updates.hpp"
#include "widgets/BaseWindow.hpp"
#include "widgets/Label.hpp"
class QPushButton;
namespace chatterino {
class UpdateDialog : public BaseWindow
{
public:
enum Button { Dismiss, Install };
UpdateDialog();
pajlada::Signals::Signal<Button> buttonClicked;
private:
void updateStatusChanged(Updates::Status status);
struct {
Label *label = nullptr;
QPushButton *installButton = nullptr;
} ui_;
pajlada::Signals::SignalHolder connections_;
};
} // namespace chatterino
File diff suppressed because it is too large Load Diff
+73 -73
View File
@@ -1,73 +1,73 @@
#pragma once
#include "widgets/BaseWindow.hpp"
#include <pajlada/signals/signal.hpp>
class QCheckBox;
namespace chatterino {
class Channel;
using ChannelPtr = std::shared_ptr<Channel>;
class Label;
class UserInfoPopup final : public BaseWindow
{
Q_OBJECT
public:
UserInfoPopup();
void setData(const QString &name, const ChannelPtr &channel);
protected:
virtual void themeChangedEvent() override;
virtual void scaleChangedEvent(float scale) override;
private:
void installEvents();
void updateUserData();
void loadAvatar(const QUrl &url);
bool isMod_;
bool isBroadcaster_;
QString userName_;
QString userId_;
ChannelPtr channel_;
pajlada::Signals::NoArgSignal userStateChanged_;
std::shared_ptr<bool> hack_;
struct {
Button *avatarButton = nullptr;
// RippleEffectLabel2 *viewLogs = nullptr;
Label *nameLabel = nullptr;
Label *viewCountLabel = nullptr;
Label *followerCountLabel = nullptr;
Label *createdDateLabel = nullptr;
Label *userIDLabel = nullptr;
QCheckBox *follow = nullptr;
QCheckBox *ignore = nullptr;
QCheckBox *ignoreHighlights = nullptr;
} ui_;
class TimeoutWidget : public BaseWidget
{
public:
enum Action { Ban, Unban, Timeout };
TimeoutWidget();
pajlada::Signals::Signal<std::pair<Action, int>> buttonClicked;
protected:
void paintEvent(QPaintEvent *event) override;
};
};
} // namespace chatterino
#pragma once
#include "widgets/BaseWindow.hpp"
#include <pajlada/signals/signal.hpp>
class QCheckBox;
namespace chatterino {
class Channel;
using ChannelPtr = std::shared_ptr<Channel>;
class Label;
class UserInfoPopup final : public BaseWindow
{
Q_OBJECT
public:
UserInfoPopup();
void setData(const QString &name, const ChannelPtr &channel);
protected:
virtual void themeChangedEvent() override;
virtual void scaleChangedEvent(float scale) override;
private:
void installEvents();
void updateUserData();
void loadAvatar(const QUrl &url);
bool isMod_;
bool isBroadcaster_;
QString userName_;
QString userId_;
ChannelPtr channel_;
pajlada::Signals::NoArgSignal userStateChanged_;
std::shared_ptr<bool> hack_;
struct {
Button *avatarButton = nullptr;
// RippleEffectLabel2 *viewLogs = nullptr;
Label *nameLabel = nullptr;
Label *viewCountLabel = nullptr;
Label *followerCountLabel = nullptr;
Label *createdDateLabel = nullptr;
Label *userIDLabel = nullptr;
QCheckBox *follow = nullptr;
QCheckBox *ignore = nullptr;
QCheckBox *ignoreHighlights = nullptr;
} ui_;
class TimeoutWidget : public BaseWidget
{
public:
enum Action { Ban, Unban, Timeout };
TimeoutWidget();
pajlada::Signals::Signal<std::pair<Action, int>> buttonClicked;
protected:
void paintEvent(QPaintEvent *event) override;
};
};
} // namespace chatterino
+11 -11
View File
@@ -1,11 +1,11 @@
#include "WelcomeDialog.hpp"
namespace chatterino {
WelcomeDialog::WelcomeDialog()
: BaseWindow(nullptr, BaseWindow::EnableCustomFrame)
{
this->setWindowTitle("Chatterino quick setup");
}
} // namespace chatterino
#include "WelcomeDialog.hpp"
namespace chatterino {
WelcomeDialog::WelcomeDialog()
: BaseWindow(BaseWindow::EnableCustomFrame)
{
this->setWindowTitle("Chatterino quick setup");
}
} // namespace chatterino
+13 -13
View File
@@ -1,13 +1,13 @@
#pragma once
#include "widgets/BaseWindow.hpp"
namespace chatterino {
class WelcomeDialog : public BaseWindow
{
public:
WelcomeDialog();
};
} // namespace chatterino
#pragma once
#include "widgets/BaseWindow.hpp"
namespace chatterino {
class WelcomeDialog : public BaseWindow
{
public:
WelcomeDialog();
};
} // namespace chatterino