2018-06-26 14:39:22 +02:00
|
|
|
#include "widgets/splits/Split.hpp"
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2018-06-26 15:33:51 +02:00
|
|
|
#include "common/Common.hpp"
|
2019-09-23 19:36:52 +02:00
|
|
|
#include "common/Env.hpp"
|
2018-07-15 14:11:46 +02:00
|
|
|
#include "common/NetworkRequest.hpp"
|
2018-11-14 17:26:08 +01:00
|
|
|
#include "controllers/accounts/AccountController.hpp"
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "providers/twitch/EmoteValue.hpp"
|
|
|
|
#include "providers/twitch/TwitchChannel.hpp"
|
2019-09-15 13:02:02 +02:00
|
|
|
#include "providers/twitch/TwitchIrcServer.hpp"
|
2019-09-23 19:36:52 +02:00
|
|
|
#include "providers/twitch/TwitchMessageBuilder.hpp"
|
2018-06-28 19:46:45 +02:00
|
|
|
#include "singletons/Settings.hpp"
|
2018-06-28 20:03:04 +02:00
|
|
|
#include "singletons/Theme.hpp"
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "singletons/WindowManager.hpp"
|
2020-01-24 21:36:51 +01:00
|
|
|
#include "util/Clipboard.hpp"
|
2020-02-09 11:15:39 +01:00
|
|
|
#include "util/NuulsUploader.hpp"
|
2018-12-02 17:49:15 +01:00
|
|
|
#include "util/Shortcut.hpp"
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "util/StreamLink.hpp"
|
2018-08-11 22:23:06 +02:00
|
|
|
#include "widgets/Notebook.hpp"
|
2019-09-16 11:48:17 +02:00
|
|
|
#include "widgets/TooltipWidget.hpp"
|
2018-06-26 17:20:03 +02:00
|
|
|
#include "widgets/Window.hpp"
|
2018-06-26 15:11:45 +02:00
|
|
|
#include "widgets/dialogs/QualityPopup.hpp"
|
|
|
|
#include "widgets/dialogs/SelectChannelDialog.hpp"
|
|
|
|
#include "widgets/dialogs/TextInputDialog.hpp"
|
|
|
|
#include "widgets/dialogs/UserInfoPopup.hpp"
|
2018-08-11 22:23:06 +02:00
|
|
|
#include "widgets/helper/ChannelView.hpp"
|
2018-06-26 17:20:03 +02:00
|
|
|
#include "widgets/helper/DebugPopup.hpp"
|
2018-10-09 19:43:29 +02:00
|
|
|
#include "widgets/helper/NotebookTab.hpp"
|
2018-08-11 22:23:06 +02:00
|
|
|
#include "widgets/helper/ResizingTextEdit.hpp"
|
2018-06-26 17:20:03 +02:00
|
|
|
#include "widgets/helper/SearchPopup.hpp"
|
2018-10-09 19:43:29 +02:00
|
|
|
#include "widgets/splits/ClosedSplits.hpp"
|
2018-06-26 17:20:03 +02:00
|
|
|
#include "widgets/splits/SplitContainer.hpp"
|
2018-08-11 22:23:06 +02:00
|
|
|
#include "widgets/splits/SplitHeader.hpp"
|
|
|
|
#include "widgets/splits/SplitInput.hpp"
|
2018-06-26 17:20:03 +02:00
|
|
|
#include "widgets/splits/SplitOverlay.hpp"
|
2017-01-17 00:15:44 +01:00
|
|
|
|
2017-09-12 19:06:16 +02:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QClipboard>
|
2018-01-17 03:18:47 +01:00
|
|
|
#include <QDesktopServices>
|
2017-09-11 22:37:39 +02:00
|
|
|
#include <QDockWidget>
|
2018-01-17 01:19:42 +01:00
|
|
|
#include <QDrag>
|
2018-07-15 14:11:46 +02:00
|
|
|
#include <QJsonArray>
|
2018-10-09 18:28:40 +02:00
|
|
|
#include <QLabel>
|
2017-09-11 22:37:39 +02:00
|
|
|
#include <QListWidget>
|
2018-01-17 01:19:42 +01:00
|
|
|
#include <QMimeData>
|
2018-10-09 18:28:40 +02:00
|
|
|
#include <QMovie>
|
2017-01-17 00:15:44 +01:00
|
|
|
#include <QPainter>
|
|
|
|
#include <QVBoxLayout>
|
2016-12-29 17:31:07 +01:00
|
|
|
|
2017-07-09 17:49:02 +02:00
|
|
|
#include <functional>
|
2017-09-17 04:36:48 +02:00
|
|
|
#include <random>
|
2017-07-09 17:49:02 +02:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
namespace chatterino {
|
2018-10-09 18:28:40 +02:00
|
|
|
namespace {
|
|
|
|
void showTutorialVideo(QWidget *parent, const QString &source,
|
|
|
|
const QString &title, const QString &description)
|
|
|
|
{
|
|
|
|
auto window =
|
2019-09-08 21:45:46 +02:00
|
|
|
new BaseWindow(BaseWindow::Flags::EnableCustomFrame, parent);
|
2018-10-09 18:28:40 +02:00
|
|
|
window->setWindowTitle("Chatterino - " + title);
|
|
|
|
window->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
auto layout = new QVBoxLayout();
|
|
|
|
layout->addWidget(new QLabel(description));
|
|
|
|
auto label = new QLabel(window);
|
|
|
|
layout->addWidget(label);
|
|
|
|
auto movie = new QMovie(label);
|
|
|
|
movie->setFileName(source);
|
|
|
|
label->setMovie(movie);
|
|
|
|
movie->start();
|
|
|
|
window->getLayoutContainer()->setLayout(layout);
|
|
|
|
window->show();
|
|
|
|
}
|
|
|
|
} // namespace
|
|
|
|
|
2018-05-10 23:58:07 +02:00
|
|
|
pajlada::Signals::Signal<Qt::KeyboardModifiers> Split::modifierStatusChanged;
|
|
|
|
Qt::KeyboardModifiers Split::modifierStatus = Qt::NoModifier;
|
2018-05-08 15:12:04 +02:00
|
|
|
|
2018-04-28 22:00:05 +02:00
|
|
|
Split::Split(SplitContainer *parent)
|
2018-06-24 11:45:30 +02:00
|
|
|
: Split(static_cast<QWidget *>(parent))
|
2018-04-28 22:00:05 +02:00
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
this->container_ = parent;
|
2018-04-28 22:00:05 +02:00
|
|
|
}
|
|
|
|
|
2018-04-27 22:11:19 +02:00
|
|
|
Split::Split(QWidget *parent)
|
|
|
|
: BaseWidget(parent)
|
2018-07-06 19:23:47 +02:00
|
|
|
, container_(nullptr)
|
|
|
|
, channel_(Channel::getEmpty())
|
2018-08-11 22:23:06 +02:00
|
|
|
, vbox_(new QVBoxLayout(this))
|
|
|
|
, header_(new SplitHeader(this))
|
|
|
|
, view_(new ChannelView(this))
|
|
|
|
, input_(new SplitInput(this))
|
2018-07-06 19:23:47 +02:00
|
|
|
, overlay_(new SplitOverlay(this))
|
2016-12-29 17:31:07 +01:00
|
|
|
{
|
2018-01-17 01:19:42 +01:00
|
|
|
this->setMouseTracking(true);
|
2018-12-02 18:37:51 +01:00
|
|
|
this->view_->setPausable(true);
|
2019-09-08 12:29:02 +02:00
|
|
|
this->view_->setFocusPolicy(Qt::FocusPolicy::NoFocus);
|
2018-01-17 01:19:42 +01:00
|
|
|
|
2018-08-11 22:23:06 +02:00
|
|
|
this->vbox_->setSpacing(0);
|
|
|
|
this->vbox_->setMargin(1);
|
2017-01-01 02:30:42 +01:00
|
|
|
|
2018-08-11 22:23:06 +02:00
|
|
|
this->vbox_->addWidget(this->header_);
|
|
|
|
this->vbox_->addWidget(this->view_, 1);
|
|
|
|
this->vbox_->addWidget(this->input_);
|
2017-06-10 23:53:39 +02:00
|
|
|
|
2017-06-11 11:36:42 +02:00
|
|
|
// Initialize chat widget-wide hotkeys
|
2017-06-10 23:53:39 +02:00
|
|
|
// CTRL+W: Close Split
|
2018-08-08 15:35:54 +02:00
|
|
|
createShortcut(this, "CTRL+W", &Split::deleteFromContainer);
|
2017-06-10 23:53:39 +02:00
|
|
|
|
|
|
|
// CTRL+R: Change Channel
|
2018-08-08 15:35:54 +02:00
|
|
|
createShortcut(this, "CTRL+R", &Split::changeChannel);
|
2017-11-12 17:21:50 +01:00
|
|
|
|
2018-01-05 13:42:23 +01:00
|
|
|
// CTRL+F: Search
|
2018-08-08 15:35:54 +02:00
|
|
|
createShortcut(this, "CTRL+F", &Split::showSearch);
|
2018-01-05 13:42:23 +01:00
|
|
|
|
2018-11-14 17:26:08 +01:00
|
|
|
// F5: reload emotes
|
2018-10-23 07:20:02 +02:00
|
|
|
createShortcut(this, "F5", &Split::reloadChannelAndSubscriberEmotes);
|
2018-10-22 22:46:55 +02:00
|
|
|
|
2018-12-09 12:44:37 +01:00
|
|
|
// F10
|
2018-07-06 17:02:26 +02:00
|
|
|
createShortcut(this, "F10", [] {
|
2018-04-06 16:37:30 +02:00
|
|
|
auto *popup = new DebugPopup;
|
|
|
|
popup->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
popup->show();
|
|
|
|
});
|
|
|
|
|
2017-11-12 17:21:50 +01:00
|
|
|
// xd
|
2018-01-06 20:24:04 +01:00
|
|
|
// CreateShortcut(this, "ALT+SHIFT+RIGHT", &Split::doIncFlexX);
|
|
|
|
// CreateShortcut(this, "ALT+SHIFT+LEFT", &Split::doDecFlexX);
|
|
|
|
// CreateShortcut(this, "ALT+SHIFT+UP", &Split::doIncFlexY);
|
|
|
|
// CreateShortcut(this, "ALT+SHIFT+DOWN", &Split::doDecFlexY);
|
2017-09-17 04:36:48 +02:00
|
|
|
|
2018-08-11 22:23:06 +02:00
|
|
|
this->input_->ui_.textEdit->installEventFilter(parent);
|
2017-09-16 00:05:06 +02:00
|
|
|
|
2018-12-02 18:37:51 +01:00
|
|
|
this->view_->mouseDown.connect([this](QMouseEvent *) { //
|
2018-06-04 21:44:03 +02:00
|
|
|
this->giveFocus(Qt::MouseFocusReason);
|
|
|
|
});
|
2018-08-11 22:23:06 +02:00
|
|
|
this->view_->selectionChanged.connect([this]() {
|
2018-10-21 13:43:02 +02:00
|
|
|
if (view_->hasSelection())
|
|
|
|
{
|
2018-08-11 22:23:06 +02:00
|
|
|
this->input_->clearSelection();
|
2017-12-17 16:19:16 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-09-21 20:35:14 +02:00
|
|
|
this->view_->joinToChannel.connect([this](QString twitchChannel) {
|
|
|
|
this->container_->appendNewSplit(false)->setChannel(
|
2018-09-30 18:55:41 +02:00
|
|
|
getApp()->twitch.server->getOrAddChannel(twitchChannel));
|
2018-09-21 20:35:14 +02:00
|
|
|
});
|
|
|
|
|
2018-08-11 22:23:06 +02:00
|
|
|
this->input_->textChanged.connect([=](const QString &newText) {
|
2018-10-21 13:43:02 +02:00
|
|
|
if (getSettings()->showEmptyInput)
|
|
|
|
{
|
2017-12-17 16:19:16 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-21 13:43:02 +02:00
|
|
|
if (newText.length() == 0)
|
|
|
|
{
|
2018-08-11 22:23:06 +02:00
|
|
|
this->input_->hide();
|
2018-10-21 13:43:02 +02:00
|
|
|
}
|
|
|
|
else if (this->input_->isHidden())
|
|
|
|
{
|
2018-08-11 22:23:06 +02:00
|
|
|
this->input_->show();
|
2017-12-17 16:19:16 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-08-08 15:35:54 +02:00
|
|
|
getSettings()->showEmptyInput.connect(
|
2018-07-05 18:17:12 +02:00
|
|
|
[this](const bool &showEmptyInput, auto) {
|
2018-10-21 13:43:02 +02:00
|
|
|
if (!showEmptyInput && this->input_->getInputText().length() == 0)
|
|
|
|
{
|
2018-08-11 22:23:06 +02:00
|
|
|
this->input_->hide();
|
2018-10-21 13:43:02 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-08-11 22:23:06 +02:00
|
|
|
this->input_->show();
|
2018-01-02 02:15:11 +01:00
|
|
|
}
|
2018-04-27 22:11:19 +02:00
|
|
|
},
|
2018-07-06 19:23:47 +02:00
|
|
|
this->managedConnections_);
|
2018-01-17 16:52:51 +01:00
|
|
|
|
2018-08-11 22:23:06 +02:00
|
|
|
this->header_->updateModerationModeIcon();
|
2018-07-06 19:23:47 +02:00
|
|
|
this->overlay_->hide();
|
2018-04-18 19:18:14 +02:00
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
this->setSizePolicy(QSizePolicy::MinimumExpanding,
|
|
|
|
QSizePolicy::MinimumExpanding);
|
2018-05-08 15:12:04 +02:00
|
|
|
|
2019-08-11 21:08:18 +02:00
|
|
|
this->managedConnect(modifierStatusChanged, [this](Qt::KeyboardModifiers
|
|
|
|
status) {
|
|
|
|
if ((status ==
|
|
|
|
showSplitOverlayModifiers /*|| status == showAddSplitRegions*/) &&
|
2018-10-21 13:43:02 +02:00
|
|
|
this->isMouseOver_)
|
2019-08-11 21:08:18 +02:00
|
|
|
{
|
|
|
|
this->overlay_->show();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->overlay_->hide();
|
|
|
|
}
|
2019-09-16 10:40:02 +02:00
|
|
|
|
|
|
|
if (getSettings()->pauseChatModifier.getEnum() != Qt::NoModifier &&
|
|
|
|
status == getSettings()->pauseChatModifier.getEnum())
|
|
|
|
{
|
|
|
|
this->view_->pause(PauseReason::KeyboardModifier);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->view_->unpause(PauseReason::KeyboardModifier);
|
|
|
|
}
|
2019-08-11 21:08:18 +02:00
|
|
|
});
|
2018-05-25 14:57:17 +02:00
|
|
|
|
2018-08-11 22:23:06 +02:00
|
|
|
this->input_->ui_.textEdit->focused.connect(
|
2018-08-06 21:17:03 +02:00
|
|
|
[this] { this->focused.invoke(); });
|
2018-08-11 22:23:06 +02:00
|
|
|
this->input_->ui_.textEdit->focusLost.connect(
|
2018-08-06 21:17:03 +02:00
|
|
|
[this] { this->focusLost.invoke(); });
|
2020-05-09 13:14:41 +02:00
|
|
|
this->input_->ui_.textEdit->imagePasted.connect([this](const QMimeData
|
|
|
|
*source) {
|
|
|
|
if (getSettings()->askOnImageUpload.getValue())
|
|
|
|
{
|
|
|
|
QMessageBox msgBox;
|
|
|
|
msgBox.setText("Image upload");
|
|
|
|
msgBox.setInformativeText(
|
|
|
|
"You are uploading an image to i.nuuls.com. You won't be able "
|
|
|
|
"to remove the image from the site. Are you okay with this?");
|
|
|
|
msgBox.addButton(QMessageBox::Cancel);
|
|
|
|
msgBox.addButton(QMessageBox::Yes);
|
|
|
|
msgBox.addButton("Yes, don't ask again", QMessageBox::YesRole);
|
|
|
|
|
|
|
|
msgBox.setDefaultButton(QMessageBox::Yes);
|
|
|
|
|
|
|
|
auto picked = msgBox.exec();
|
|
|
|
if (picked == QMessageBox::Cancel)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (picked == 0) // don't ask again button
|
|
|
|
{
|
|
|
|
getSettings()->askOnImageUpload.setValue(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
upload(source, this->getChannel(), *this->input_->ui_.textEdit);
|
|
|
|
});
|
2020-02-08 16:41:01 +01:00
|
|
|
setAcceptDrops(true);
|
2017-01-01 02:30:42 +01:00
|
|
|
}
|
|
|
|
|
2017-11-12 17:21:50 +01:00
|
|
|
Split::~Split()
|
2017-01-01 02:30:42 +01:00
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
this->usermodeChangedConnection_.disconnect();
|
|
|
|
this->roomModeChangedConnection_.disconnect();
|
|
|
|
this->channelIDChangedConnection_.disconnect();
|
|
|
|
this->indirectChannelChangedConnection_.disconnect();
|
2016-12-29 17:31:07 +01:00
|
|
|
}
|
|
|
|
|
2018-05-10 19:50:31 +02:00
|
|
|
ChannelView &Split::getChannelView()
|
|
|
|
{
|
2018-08-11 22:23:06 +02:00
|
|
|
return *this->view_;
|
2018-05-10 19:50:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SplitContainer *Split::getContainer()
|
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
return this->container_;
|
2018-05-10 19:50:31 +02:00
|
|
|
}
|
|
|
|
|
2018-04-25 14:49:30 +02:00
|
|
|
bool Split::isInContainer() const
|
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
return this->container_ != nullptr;
|
2018-04-25 14:49:30 +02:00
|
|
|
}
|
|
|
|
|
2018-07-06 19:23:47 +02:00
|
|
|
void Split::setContainer(SplitContainer *container)
|
2018-05-10 23:58:07 +02:00
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
this->container_ = container;
|
2018-05-10 23:58:07 +02:00
|
|
|
}
|
|
|
|
|
2018-04-20 19:54:45 +02:00
|
|
|
IndirectChannel Split::getIndirectChannel()
|
2017-04-12 17:46:44 +02:00
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
return this->channel_;
|
2017-04-12 17:46:44 +02:00
|
|
|
}
|
|
|
|
|
2018-04-20 19:54:45 +02:00
|
|
|
ChannelPtr Split::getChannel()
|
2017-04-12 17:46:44 +02:00
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
return this->channel_.get();
|
2018-04-20 19:54:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Split::setChannel(IndirectChannel newChannel)
|
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
this->channel_ = newChannel;
|
2018-04-20 22:33:28 +02:00
|
|
|
|
2018-08-11 22:23:06 +02:00
|
|
|
this->view_->setChannel(newChannel.get());
|
2017-02-02 22:15:09 +01:00
|
|
|
|
2018-07-06 19:23:47 +02:00
|
|
|
this->usermodeChangedConnection_.disconnect();
|
|
|
|
this->roomModeChangedConnection_.disconnect();
|
|
|
|
this->indirectChannelChangedConnection_.disconnect();
|
2018-01-17 18:36:12 +01:00
|
|
|
|
2018-04-20 19:54:45 +02:00
|
|
|
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(newChannel.get().get());
|
2018-01-17 18:36:12 +01:00
|
|
|
|
2018-10-21 13:43:02 +02:00
|
|
|
if (tc != nullptr)
|
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
this->usermodeChangedConnection_ = tc->userStateChanged.connect([this] {
|
2018-08-11 22:23:06 +02:00
|
|
|
this->header_->updateModerationModeIcon();
|
|
|
|
this->header_->updateRoomModes();
|
2018-07-04 19:43:41 +02:00
|
|
|
});
|
2018-05-24 08:58:34 +02:00
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
this->roomModeChangedConnection_ = tc->roomModesChanged.connect(
|
2018-08-11 22:23:06 +02:00
|
|
|
[this] { this->header_->updateRoomModes(); });
|
2018-01-17 18:36:12 +01:00
|
|
|
}
|
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
this->indirectChannelChangedConnection_ =
|
|
|
|
newChannel.getChannelChanged().connect([this] { //
|
|
|
|
QTimer::singleShot(0, [this] { this->setChannel(this->channel_); });
|
|
|
|
});
|
2018-04-20 19:54:45 +02:00
|
|
|
|
2018-08-11 22:23:06 +02:00
|
|
|
this->header_->updateModerationModeIcon();
|
|
|
|
this->header_->updateChannelText();
|
|
|
|
this->header_->updateRoomModes();
|
2018-01-17 18:36:12 +01:00
|
|
|
|
2018-04-03 02:55:32 +02:00
|
|
|
this->channelChanged.invoke();
|
2018-10-07 18:27:40 +02:00
|
|
|
|
|
|
|
// Queue up save because: Split channel changed
|
|
|
|
getApp()->windows->queueSave();
|
2017-04-12 17:46:44 +02:00
|
|
|
}
|
|
|
|
|
2018-01-17 16:52:51 +01:00
|
|
|
void Split::setModerationMode(bool value)
|
|
|
|
{
|
2018-10-21 16:13:26 +02:00
|
|
|
this->moderationMode_ = value;
|
|
|
|
this->header_->updateModerationModeIcon();
|
2018-11-03 21:26:57 +01:00
|
|
|
this->view_->queueLayout();
|
2018-01-17 16:52:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Split::getModerationMode() const
|
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
return this->moderationMode_;
|
2018-01-17 16:52:51 +01:00
|
|
|
}
|
|
|
|
|
2018-07-10 18:27:42 +02:00
|
|
|
void Split::insertTextToInput(const QString &text)
|
|
|
|
{
|
2018-08-11 22:23:06 +02:00
|
|
|
this->input_->insertText(text);
|
2018-07-10 18:27:42 +02:00
|
|
|
}
|
|
|
|
|
2018-04-18 09:12:29 +02:00
|
|
|
void Split::showChangeChannelPopup(const char *dialogTitle, bool empty,
|
|
|
|
std::function<void(bool)> callback)
|
2017-01-17 00:15:44 +01:00
|
|
|
{
|
2018-10-21 13:43:02 +02:00
|
|
|
if (this->selectChannelDialog_.hasElement())
|
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
this->selectChannelDialog_->raise();
|
2018-06-24 11:45:30 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-12-02 17:49:15 +01:00
|
|
|
auto dialog = new SelectChannelDialog(this);
|
2018-10-21 13:43:02 +02:00
|
|
|
if (!empty)
|
|
|
|
{
|
2018-04-20 22:33:28 +02:00
|
|
|
dialog->setSelectedChannel(this->getIndirectChannel());
|
2017-01-17 00:15:44 +01:00
|
|
|
}
|
2018-04-18 09:12:29 +02:00
|
|
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
dialog->show();
|
|
|
|
dialog->closed.connect([=] {
|
2018-10-21 13:43:02 +02:00
|
|
|
if (dialog->hasSeletedChannel())
|
|
|
|
{
|
2018-04-18 09:12:29 +02:00
|
|
|
this->setChannel(dialog->getSelectedChannel());
|
2018-10-21 13:43:02 +02:00
|
|
|
if (this->isInContainer())
|
|
|
|
{
|
2018-10-13 14:20:06 +02:00
|
|
|
this->container_->refreshTab();
|
2018-04-25 14:49:30 +02:00
|
|
|
}
|
2018-04-18 09:12:29 +02:00
|
|
|
}
|
2017-07-31 01:36:42 +02:00
|
|
|
|
2018-04-18 09:12:29 +02:00
|
|
|
callback(dialog->hasSeletedChannel());
|
2018-07-06 19:23:47 +02:00
|
|
|
this->selectChannelDialog_ = nullptr;
|
2018-04-18 09:12:29 +02:00
|
|
|
});
|
2018-07-06 19:23:47 +02:00
|
|
|
this->selectChannelDialog_ = dialog;
|
2017-01-17 00:15:44 +01:00
|
|
|
}
|
|
|
|
|
2017-11-12 17:21:50 +01:00
|
|
|
void Split::updateGifEmotes()
|
2017-04-12 17:46:44 +02:00
|
|
|
{
|
2018-08-11 22:23:06 +02:00
|
|
|
this->view_->queueUpdate();
|
2017-04-12 17:46:44 +02:00
|
|
|
}
|
|
|
|
|
2018-01-23 22:48:33 +01:00
|
|
|
void Split::updateLastReadMessage()
|
|
|
|
{
|
2018-08-11 22:23:06 +02:00
|
|
|
this->view_->updateLastReadMessage();
|
2018-01-23 22:48:33 +01:00
|
|
|
}
|
|
|
|
|
2017-11-12 17:21:50 +01:00
|
|
|
void Split::giveFocus(Qt::FocusReason reason)
|
2017-08-12 15:41:14 +02:00
|
|
|
{
|
2018-08-11 22:23:06 +02:00
|
|
|
this->input_->ui_.textEdit->setFocus(reason);
|
2017-08-12 15:41:14 +02:00
|
|
|
}
|
|
|
|
|
2017-11-12 17:21:50 +01:00
|
|
|
bool Split::hasFocus() const
|
2017-06-11 20:53:43 +02:00
|
|
|
{
|
2018-08-11 22:23:06 +02:00
|
|
|
return this->input_->ui_.textEdit->hasFocus();
|
2017-06-11 20:53:43 +02:00
|
|
|
}
|
|
|
|
|
2017-11-12 17:21:50 +01:00
|
|
|
void Split::paintEvent(QPaintEvent *)
|
2016-12-29 17:31:07 +01:00
|
|
|
{
|
2017-04-12 17:46:44 +02:00
|
|
|
// color the background of the chat
|
2017-01-11 18:52:09 +01:00
|
|
|
QPainter painter(this);
|
2016-12-29 17:31:07 +01:00
|
|
|
|
2018-07-06 17:11:37 +02:00
|
|
|
painter.fillRect(this->rect(), this->theme->splits.background);
|
2016-12-29 17:31:07 +01:00
|
|
|
}
|
2017-01-29 11:38:00 +01:00
|
|
|
|
2018-01-17 01:19:42 +01:00
|
|
|
void Split::mouseMoveEvent(QMouseEvent *event)
|
|
|
|
{
|
2018-05-31 16:02:20 +02:00
|
|
|
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
2018-01-17 01:19:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Split::keyPressEvent(QKeyEvent *event)
|
|
|
|
{
|
2018-08-11 22:23:06 +02:00
|
|
|
this->view_->unsetCursor();
|
2018-05-31 16:02:20 +02:00
|
|
|
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
2018-01-17 01:19:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Split::keyReleaseEvent(QKeyEvent *event)
|
|
|
|
{
|
2018-08-11 22:23:06 +02:00
|
|
|
this->view_->unsetCursor();
|
2018-05-31 16:02:20 +02:00
|
|
|
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
2018-01-17 01:19:42 +01:00
|
|
|
}
|
|
|
|
|
2018-05-08 15:12:04 +02:00
|
|
|
void Split::resizeEvent(QResizeEvent *event)
|
|
|
|
{
|
2018-10-07 18:27:40 +02:00
|
|
|
// Queue up save because: Split resized
|
|
|
|
getApp()->windows->queueSave();
|
|
|
|
|
2018-05-08 15:12:04 +02:00
|
|
|
BaseWidget::resizeEvent(event);
|
|
|
|
|
2018-07-06 19:23:47 +02:00
|
|
|
this->overlay_->setGeometry(this->rect());
|
2018-05-08 15:12:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Split::enterEvent(QEvent *event)
|
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
this->isMouseOver_ = true;
|
2018-05-10 23:58:07 +02:00
|
|
|
|
2018-05-31 16:02:20 +02:00
|
|
|
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
2018-05-10 23:58:07 +02:00
|
|
|
|
2018-10-21 13:43:02 +02:00
|
|
|
if (modifierStatus ==
|
|
|
|
showSplitOverlayModifiers /*|| modifierStatus == showAddSplitRegions*/)
|
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
this->overlay_->show();
|
2018-05-08 15:12:04 +02:00
|
|
|
}
|
2018-06-01 14:46:41 +02:00
|
|
|
|
2018-10-21 13:43:02 +02:00
|
|
|
if (this->container_ != nullptr)
|
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
this->container_->resetMouseStatus();
|
2018-06-01 14:46:41 +02:00
|
|
|
}
|
2018-05-08 15:12:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Split::leaveEvent(QEvent *event)
|
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
this->isMouseOver_ = false;
|
2018-05-17 16:39:38 +02:00
|
|
|
|
2018-07-06 19:23:47 +02:00
|
|
|
this->overlay_->hide();
|
2018-05-17 16:39:38 +02:00
|
|
|
|
2019-10-07 22:42:34 +02:00
|
|
|
TooltipWidget::instance()->hide();
|
2019-09-16 11:48:17 +02:00
|
|
|
|
2018-05-31 16:02:20 +02:00
|
|
|
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
2018-05-08 15:12:04 +02:00
|
|
|
}
|
|
|
|
|
2018-05-31 16:02:20 +02:00
|
|
|
void Split::focusInEvent(QFocusEvent *event)
|
|
|
|
{
|
|
|
|
this->giveFocus(event->reason());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Split::handleModifiers(Qt::KeyboardModifiers modifiers)
|
2018-01-17 01:19:42 +01:00
|
|
|
{
|
2018-10-21 13:43:02 +02:00
|
|
|
if (modifierStatus != modifiers)
|
|
|
|
{
|
2018-05-10 23:58:07 +02:00
|
|
|
modifierStatus = modifiers;
|
|
|
|
modifierStatusChanged.invoke(modifiers);
|
2018-01-17 01:19:42 +01:00
|
|
|
}
|
2018-05-10 19:50:31 +02:00
|
|
|
}
|
|
|
|
|
2018-09-04 21:39:54 +02:00
|
|
|
void Split::setIsTopRightSplit(bool value)
|
|
|
|
{
|
|
|
|
this->isTopRightSplit_ = value;
|
|
|
|
this->header_->setAddButtonVisible(value);
|
|
|
|
}
|
|
|
|
|
2017-06-10 23:53:39 +02:00
|
|
|
/// Slots
|
2018-08-08 15:35:54 +02:00
|
|
|
void Split::addSibling()
|
2017-06-10 23:53:39 +02:00
|
|
|
{
|
2018-10-21 13:43:02 +02:00
|
|
|
if (this->container_)
|
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
this->container_->appendNewSplit(true);
|
2018-04-25 14:49:30 +02:00
|
|
|
}
|
2017-06-10 23:53:39 +02:00
|
|
|
}
|
|
|
|
|
2018-08-08 15:35:54 +02:00
|
|
|
void Split::deleteFromContainer()
|
2017-06-10 23:53:39 +02:00
|
|
|
{
|
2018-10-21 13:43:02 +02:00
|
|
|
if (this->container_)
|
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
this->container_->deleteSplit(this);
|
2018-10-09 19:43:29 +02:00
|
|
|
auto *tab = this->getContainer()->getTab();
|
|
|
|
tab->connect(tab, &QWidget::destroyed,
|
|
|
|
[tab]() mutable { ClosedSplits::invalidateTab(tab); });
|
|
|
|
ClosedSplits::push({this->getChannel()->getName(), tab});
|
2018-04-25 14:49:30 +02:00
|
|
|
}
|
2017-06-10 23:53:39 +02:00
|
|
|
}
|
|
|
|
|
2018-08-08 15:35:54 +02:00
|
|
|
void Split::changeChannel()
|
2017-06-10 23:53:39 +02:00
|
|
|
{
|
2018-04-18 09:12:29 +02:00
|
|
|
this->showChangeChannelPopup("Change channel", false, [](bool) {});
|
2018-06-24 11:45:30 +02:00
|
|
|
|
2017-09-15 17:23:49 +02:00
|
|
|
auto popup = this->findChildren<QDockWidget *>();
|
2018-10-21 13:43:02 +02:00
|
|
|
if (popup.size() && popup.at(0)->isVisible() && !popup.at(0)->isFloating())
|
|
|
|
{
|
2017-09-12 22:10:30 +02:00
|
|
|
popup.at(0)->hide();
|
2018-08-02 14:23:27 +02:00
|
|
|
showViewerList();
|
2017-09-12 22:10:30 +02:00
|
|
|
}
|
2017-06-10 23:53:39 +02:00
|
|
|
}
|
|
|
|
|
2018-10-09 18:28:40 +02:00
|
|
|
void Split::explainMoving()
|
|
|
|
{
|
|
|
|
showTutorialVideo(this, ":/examples/moving.gif", "Moving",
|
|
|
|
"Hold <Ctrl+Alt> to move splits.\n\nExample:");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Split::explainSplitting()
|
|
|
|
{
|
|
|
|
showTutorialVideo(this, ":/examples/splitting.gif", "Splitting",
|
|
|
|
"Hold <Ctrl+Alt> to add new splits.\n\nExample:");
|
|
|
|
}
|
|
|
|
|
2018-08-08 15:35:54 +02:00
|
|
|
void Split::popup()
|
2017-06-11 09:11:55 +02:00
|
|
|
{
|
2018-04-27 22:11:19 +02:00
|
|
|
auto app = getApp();
|
2018-08-11 22:23:06 +02:00
|
|
|
Window &window = app->windows->createWindow(WindowType::Popup);
|
2017-11-12 17:21:50 +01:00
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
Split *split = new Split(static_cast<SplitContainer *>(
|
|
|
|
window.getNotebook().getOrAddSelectedPage()));
|
2017-11-12 17:21:50 +01:00
|
|
|
|
2018-04-20 22:54:09 +02:00
|
|
|
split->setChannel(this->getIndirectChannel());
|
2018-05-10 19:50:31 +02:00
|
|
|
window.getNotebook().getOrAddSelectedPage()->appendSplit(split);
|
2017-11-12 17:21:50 +01:00
|
|
|
|
|
|
|
window.show();
|
2017-06-11 09:11:55 +02:00
|
|
|
}
|
|
|
|
|
2018-08-08 15:35:54 +02:00
|
|
|
void Split::clear()
|
2017-06-11 09:11:55 +02:00
|
|
|
{
|
2018-08-11 22:23:06 +02:00
|
|
|
this->view_->clearMessages();
|
2017-06-11 09:11:55 +02:00
|
|
|
}
|
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
void Split::openInBrowser()
|
2017-06-11 09:11:55 +02:00
|
|
|
{
|
2018-08-02 14:23:27 +02:00
|
|
|
auto channel = this->getChannel();
|
2018-01-17 03:18:47 +01:00
|
|
|
|
2018-10-21 13:43:02 +02:00
|
|
|
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
|
|
|
|
{
|
2018-08-06 21:17:03 +02:00
|
|
|
QDesktopServices::openUrl("https://twitch.tv/" +
|
|
|
|
twitchChannel->getName());
|
2018-01-17 03:18:47 +01:00
|
|
|
}
|
2017-06-11 09:11:55 +02:00
|
|
|
}
|
|
|
|
|
2018-08-08 15:35:54 +02:00
|
|
|
void Split::openBrowserPlayer()
|
2017-06-11 09:11:55 +02:00
|
|
|
{
|
2018-08-02 14:23:27 +02:00
|
|
|
ChannelPtr channel = this->getChannel();
|
2018-10-21 13:43:02 +02:00
|
|
|
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
|
|
|
|
{
|
2020-06-12 19:44:05 +02:00
|
|
|
QDesktopServices::openUrl(
|
|
|
|
"https://player.twitch.tv/?parent=twitch.tv&channel=" +
|
|
|
|
twitchChannel->getName());
|
2018-01-17 03:18:47 +01:00
|
|
|
}
|
2017-06-11 09:11:55 +02:00
|
|
|
}
|
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
void Split::openInStreamlink()
|
2017-08-12 14:44:27 +02:00
|
|
|
{
|
2018-10-21 13:43:02 +02:00
|
|
|
try
|
|
|
|
{
|
2018-08-02 14:23:27 +02:00
|
|
|
openStreamlinkForChannel(this->getChannel()->getName());
|
2018-10-21 13:43:02 +02:00
|
|
|
}
|
|
|
|
catch (const Exception &ex)
|
|
|
|
{
|
2020-01-03 20:51:37 +01:00
|
|
|
qDebug() << "Error in doOpenStreamlink:" << ex.what();
|
2017-08-12 14:44:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-11 11:43:35 +02:00
|
|
|
void Split::openWithCustomScheme()
|
|
|
|
{
|
|
|
|
const auto scheme = getSettings()->customURIScheme.getValue();
|
|
|
|
if (scheme.isEmpty())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto channel = this->getChannel().get();
|
|
|
|
|
|
|
|
if (const auto twitchChannel = dynamic_cast<TwitchChannel *>(channel))
|
|
|
|
{
|
|
|
|
QDesktopServices::openUrl(QString("%1https://twitch.tv/%2")
|
|
|
|
.arg(scheme)
|
|
|
|
.arg(twitchChannel->getName()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
void Split::showViewerList()
|
2017-09-11 22:37:39 +02:00
|
|
|
{
|
2017-09-15 17:23:49 +02:00
|
|
|
auto viewerDock = new QDockWidget("Viewer List", this);
|
2017-09-11 22:37:39 +02:00
|
|
|
viewerDock->setAllowedAreas(Qt::LeftDockWidgetArea);
|
|
|
|
viewerDock->setFeatures(QDockWidget::DockWidgetVerticalTitleBar |
|
2018-08-06 21:17:03 +02:00
|
|
|
QDockWidget::DockWidgetClosable |
|
|
|
|
QDockWidget::DockWidgetFloatable);
|
|
|
|
viewerDock->resize(
|
|
|
|
0.5 * this->width(),
|
2018-08-11 22:23:06 +02:00
|
|
|
this->height() - this->header_->height() - this->input_->height());
|
|
|
|
viewerDock->move(0, this->header_->height());
|
2017-09-11 22:37:39 +02:00
|
|
|
|
|
|
|
auto multiWidget = new QWidget(viewerDock);
|
|
|
|
auto dockVbox = new QVBoxLayout(viewerDock);
|
|
|
|
auto searchBar = new QLineEdit(viewerDock);
|
|
|
|
|
|
|
|
auto chattersList = new QListWidget();
|
|
|
|
auto resultList = new QListWidget();
|
|
|
|
|
2019-07-14 11:43:57 +02:00
|
|
|
static QStringList labels = {"Broadcaster", "VIPs", "Moderators",
|
2019-04-04 11:30:50 +02:00
|
|
|
"Staff", "Admins", "Global Moderators",
|
|
|
|
"Viewers"};
|
|
|
|
static QStringList jsonLabels = {"broadcaster", "vips", "moderators",
|
|
|
|
"staff", "admins", "global_mods",
|
|
|
|
"viewers"};
|
2017-09-15 17:23:49 +02:00
|
|
|
QList<QListWidgetItem *> labelList;
|
2018-10-21 13:43:02 +02:00
|
|
|
for (auto &x : labels)
|
|
|
|
{
|
2017-09-11 22:37:39 +02:00
|
|
|
auto label = new QListWidgetItem(x);
|
2018-07-06 17:11:37 +02:00
|
|
|
label->setBackgroundColor(this->theme->splits.header.background);
|
2017-09-11 22:37:39 +02:00
|
|
|
labelList.append(label);
|
2017-08-12 14:44:27 +02:00
|
|
|
}
|
2017-09-11 22:37:39 +02:00
|
|
|
auto loadingLabel = new QLabel("Loading...");
|
|
|
|
|
2019-08-20 21:50:36 +02:00
|
|
|
NetworkRequest::twitchRequest("https://tmi.twitch.tv/group/user/" +
|
|
|
|
this->getChannel()->getName() + "/chatters")
|
|
|
|
.caller(this)
|
|
|
|
.onSuccess([=](auto result) -> Outcome {
|
|
|
|
auto obj = result.parseJson();
|
|
|
|
QJsonObject chattersObj = obj.value("chatters").toObject();
|
|
|
|
|
|
|
|
loadingLabel->hide();
|
|
|
|
for (int i = 0; i < jsonLabels.size(); i++)
|
|
|
|
{
|
|
|
|
auto currentCategory =
|
|
|
|
chattersObj.value(jsonLabels.at(i)).toArray();
|
|
|
|
// If current category of chatters is empty, dont show this
|
|
|
|
// category.
|
|
|
|
if (currentCategory.empty())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
chattersList->addItem(labelList.at(i));
|
|
|
|
foreach (const QJsonValue &v, currentCategory)
|
|
|
|
chattersList->addItem(v.toString());
|
|
|
|
}
|
2018-07-07 13:08:57 +02:00
|
|
|
|
2019-08-20 21:50:36 +02:00
|
|
|
return Success;
|
|
|
|
})
|
|
|
|
.execute();
|
2017-09-11 22:37:39 +02:00
|
|
|
|
|
|
|
searchBar->setPlaceholderText("Search User...");
|
2017-09-15 17:23:49 +02:00
|
|
|
QObject::connect(searchBar, &QLineEdit::textEdited, this, [=]() {
|
2017-09-11 22:37:39 +02:00
|
|
|
auto query = searchBar->text();
|
2018-10-21 13:43:02 +02:00
|
|
|
if (!query.isEmpty())
|
|
|
|
{
|
2017-09-15 17:23:49 +02:00
|
|
|
auto results = chattersList->findItems(query, Qt::MatchStartsWith);
|
2017-09-11 22:37:39 +02:00
|
|
|
chattersList->hide();
|
|
|
|
resultList->clear();
|
2018-10-21 13:43:02 +02:00
|
|
|
for (auto &item : results)
|
|
|
|
{
|
2018-08-06 21:17:03 +02:00
|
|
|
if (!labels.contains(item->text()))
|
|
|
|
resultList->addItem(item->text());
|
2017-09-11 22:37:39 +02:00
|
|
|
}
|
|
|
|
resultList->show();
|
2018-10-21 13:43:02 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-11 22:37:39 +02:00
|
|
|
resultList->hide();
|
|
|
|
chattersList->show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-09-15 17:23:49 +02:00
|
|
|
QObject::connect(viewerDock, &QDockWidget::topLevelChanged, this,
|
|
|
|
[=]() { viewerDock->setMinimumWidth(300); });
|
2017-09-11 22:37:39 +02:00
|
|
|
|
2018-10-06 12:13:14 +02:00
|
|
|
auto listDoubleClick = [=](QString userName) {
|
2018-10-21 13:43:02 +02:00
|
|
|
if (!labels.contains(userName))
|
|
|
|
{
|
2018-10-06 12:13:14 +02:00
|
|
|
this->view_->showUserInfoPopup(userName);
|
2017-09-12 22:10:30 +02:00
|
|
|
}
|
2018-10-06 12:13:14 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
QObject::connect(chattersList, &QListWidget::doubleClicked, this, [=]() {
|
|
|
|
listDoubleClick(chattersList->currentItem()->text());
|
2017-09-12 22:10:30 +02:00
|
|
|
});
|
|
|
|
|
2017-09-15 17:23:49 +02:00
|
|
|
QObject::connect(resultList, &QListWidget::doubleClicked, this, [=]() {
|
2018-10-06 12:13:14 +02:00
|
|
|
listDoubleClick(resultList->currentItem()->text());
|
2017-09-12 22:10:30 +02:00
|
|
|
});
|
|
|
|
|
2017-09-11 22:37:39 +02:00
|
|
|
dockVbox->addWidget(searchBar);
|
|
|
|
dockVbox->addWidget(loadingLabel);
|
|
|
|
dockVbox->addWidget(chattersList);
|
|
|
|
dockVbox->addWidget(resultList);
|
|
|
|
resultList->hide();
|
|
|
|
|
2018-07-06 17:11:37 +02:00
|
|
|
multiWidget->setStyleSheet(this->theme->splits.input.styleSheet);
|
2017-09-11 22:37:39 +02:00
|
|
|
multiWidget->setLayout(dockVbox);
|
|
|
|
viewerDock->setWidget(multiWidget);
|
2019-07-14 11:43:57 +02:00
|
|
|
viewerDock->setFloating(true);
|
2017-09-11 22:37:39 +02:00
|
|
|
viewerDock->show();
|
2019-07-14 11:43:57 +02:00
|
|
|
viewerDock->activateWindow();
|
2017-08-12 14:44:27 +02:00
|
|
|
}
|
|
|
|
|
2019-07-16 21:59:04 +02:00
|
|
|
void Split::openSubPage()
|
|
|
|
{
|
|
|
|
ChannelPtr channel = this->getChannel();
|
|
|
|
|
|
|
|
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
|
|
|
|
{
|
|
|
|
QDesktopServices::openUrl(twitchChannel->subscriptionUrl());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
void Split::copyToClipboard()
|
2017-09-12 19:06:16 +02:00
|
|
|
{
|
2020-01-24 21:36:51 +01:00
|
|
|
crossPlatformCopy(this->view_->getSelectedText());
|
2017-09-12 19:06:16 +02:00
|
|
|
}
|
|
|
|
|
2018-08-08 15:35:54 +02:00
|
|
|
void Split::showSearch()
|
2018-01-05 13:42:23 +01:00
|
|
|
{
|
|
|
|
SearchPopup *popup = new SearchPopup();
|
|
|
|
|
|
|
|
popup->setChannel(this->getChannel());
|
|
|
|
popup->show();
|
|
|
|
}
|
|
|
|
|
2018-10-22 22:46:55 +02:00
|
|
|
void Split::reloadChannelAndSubscriberEmotes()
|
|
|
|
{
|
|
|
|
getApp()->accounts->twitch.getCurrent()->loadEmotes();
|
|
|
|
auto channel = this->getChannel();
|
|
|
|
|
|
|
|
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
|
2019-08-27 20:45:55 +02:00
|
|
|
{
|
2020-05-16 12:43:44 +02:00
|
|
|
twitchChannel->refreshBTTVChannelEmotes(true);
|
|
|
|
twitchChannel->refreshFFZChannelEmotes(true);
|
2019-08-27 20:45:55 +02:00
|
|
|
}
|
2018-10-22 22:46:55 +02:00
|
|
|
}
|
|
|
|
|
2020-02-08 16:41:01 +01:00
|
|
|
void Split::dragEnterEvent(QDragEnterEvent *event)
|
|
|
|
{
|
|
|
|
if (event->mimeData()->hasImage() || event->mimeData()->hasUrls())
|
|
|
|
{
|
|
|
|
event->acceptProposedAction();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BaseWidget::dragEnterEvent(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Split::dropEvent(QDropEvent *event)
|
|
|
|
{
|
|
|
|
if (event->mimeData()->hasImage() || event->mimeData()->hasUrls())
|
|
|
|
{
|
|
|
|
this->input_->ui_.textEdit->imagePasted.invoke(event->mimeData());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BaseWidget::dropEvent(event);
|
|
|
|
}
|
|
|
|
}
|
2017-09-17 04:36:48 +02:00
|
|
|
template <typename Iter, typename RandomGenerator>
|
|
|
|
static Iter select_randomly(Iter start, Iter end, RandomGenerator &g)
|
|
|
|
{
|
|
|
|
std::uniform_int_distribution<> dis(0, std::distance(start, end) - 1);
|
|
|
|
std::advance(start, dis(g));
|
|
|
|
return start;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Iter>
|
|
|
|
static Iter select_randomly(Iter start, Iter end)
|
|
|
|
{
|
|
|
|
static std::random_device rd;
|
|
|
|
static std::mt19937 gen(rd());
|
|
|
|
return select_randomly(start, end, gen);
|
|
|
|
}
|
|
|
|
|
2018-01-17 01:19:42 +01:00
|
|
|
void Split::drag()
|
|
|
|
{
|
2018-10-21 13:43:02 +02:00
|
|
|
if (auto container = dynamic_cast<SplitContainer *>(this->parentWidget()))
|
|
|
|
{
|
2018-01-17 01:19:42 +01:00
|
|
|
SplitContainer::isDraggingSplit = true;
|
|
|
|
SplitContainer::draggingSplit = this;
|
|
|
|
|
2018-05-10 19:50:31 +02:00
|
|
|
auto originalLocation = container->releaseSplit(this);
|
2018-08-02 14:23:27 +02:00
|
|
|
auto drag = new QDrag(this);
|
|
|
|
auto mimeData = new QMimeData;
|
2018-01-17 01:19:42 +01:00
|
|
|
|
|
|
|
mimeData->setData("chatterino/split", "xD");
|
|
|
|
drag->setMimeData(mimeData);
|
|
|
|
|
2018-10-21 13:43:02 +02:00
|
|
|
if (drag->exec(Qt::MoveAction) == Qt::IgnoreAction)
|
|
|
|
{
|
2018-08-02 14:23:27 +02:00
|
|
|
container->insertSplit(this, originalLocation);
|
2018-01-17 01:19:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SplitContainer::isDraggingSplit = false;
|
|
|
|
}
|
|
|
|
}
|
2018-03-31 13:44:15 +02:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
} // namespace chatterino
|