this commit is too big

This commit is contained in:
fourtf
2018-08-02 14:23:27 +02:00
parent 3b3c5d8d75
commit c2e2dfb577
186 changed files with 3626 additions and 2656 deletions
+28 -39
View File
@@ -76,7 +76,7 @@ Split::Split(QWidget *parent)
createShortcut(this, "CTRL+R", &Split::doChangeChannel);
// CTRL+F: Search
createShortcut(this, "CTRL+F", &Split::doSearch);
createShortcut(this, "CTRL+F", &Split::showSearchPopup);
// F12
createShortcut(this, "F10", [] {
@@ -378,7 +378,7 @@ void Split::doChangeChannel()
auto popup = this->findChildren<QDockWidget *>();
if (popup.size() && popup.at(0)->isVisible() && !popup.at(0)->isFloating()) {
popup.at(0)->hide();
doOpenViewerList();
showViewerList();
}
}
@@ -401,36 +401,33 @@ void Split::doClearChat()
this->view_.clearMessages();
}
void Split::doOpenChannel()
void Split::openInBrowser()
{
ChannelPtr _channel = this->getChannel();
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(_channel.get());
auto channel = this->getChannel();
if (tc != nullptr) {
QDesktopServices::openUrl("https://twitch.tv/" + tc->name);
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get())) {
QDesktopServices::openUrl("https://twitch.tv/" + twitchChannel->getName());
}
}
void Split::doOpenPopupPlayer()
void Split::openInPopupPlayer()
{
ChannelPtr _channel = this->getChannel();
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(_channel.get());
if (tc != nullptr) {
QDesktopServices::openUrl("https://player.twitch.tv/?channel=" + tc->name);
ChannelPtr channel = this->getChannel();
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get())) {
QDesktopServices::openUrl("https://player.twitch.tv/?channel=" + twitchChannel->getName());
}
}
void Split::doOpenStreamlink()
void Split::openInStreamlink()
{
try {
openStreamlinkForChannel(this->getChannel()->name);
openStreamlinkForChannel(this->getChannel()->getName());
} catch (const Exception &ex) {
Log("Error in doOpenStreamlink: {}", ex.what());
}
}
void Split::doOpenViewerList()
void Split::showViewerList()
{
auto viewerDock = new QDockWidget("Viewer List", this);
viewerDock->setAllowedAreas(Qt::LeftDockWidgetArea);
@@ -458,10 +455,10 @@ void Split::doOpenViewerList()
auto loadingLabel = new QLabel("Loading...");
auto request = NetworkRequest::twitchRequest("https://tmi.twitch.tv/group/user/" +
this->getChannel()->name + "/chatters");
this->getChannel()->getName() + "/chatters");
request.setCaller(this);
request.onSuccess([=](auto result) {
request.onSuccess([=](auto result) -> Outcome {
auto obj = result.parseJson();
QJsonObject chattersObj = obj.value("chatters").toObject();
@@ -472,7 +469,7 @@ void Split::doOpenViewerList()
chattersList->addItem(v.toString());
}
return true;
return Success;
});
request.execute();
@@ -485,8 +482,7 @@ void Split::doOpenViewerList()
chattersList->hide();
resultList->clear();
for (auto &item : results) {
if (!labels.contains(item->text()))
resultList->addItem(item->text());
if (!labels.contains(item->text())) resultList->addItem(item->text());
}
resultList->show();
} else {
@@ -500,13 +496,13 @@ void Split::doOpenViewerList()
QObject::connect(chattersList, &QListWidget::doubleClicked, this, [=]() {
if (!labels.contains(chattersList->currentItem()->text())) {
doOpenUserInfoPopup(chattersList->currentItem()->text());
showUserInfoPopup(chattersList->currentItem()->text());
}
});
QObject::connect(resultList, &QListWidget::doubleClicked, this, [=]() {
if (!labels.contains(resultList->currentItem()->text())) {
doOpenUserInfoPopup(resultList->currentItem()->text());
showUserInfoPopup(resultList->currentItem()->text());
}
});
@@ -522,22 +518,22 @@ void Split::doOpenViewerList()
viewerDock->show();
}
void Split::doOpenUserInfoPopup(const QString &user)
void Split::showUserInfoPopup(const UserName &user)
{
auto *userPopup = new UserInfoPopup;
userPopup->setData(user, this->getChannel());
userPopup->setData(user.string, this->getChannel());
userPopup->setAttribute(Qt::WA_DeleteOnClose);
userPopup->move(QCursor::pos() -
QPoint(int(150 * this->getScale()), int(70 * this->getScale())));
userPopup->show();
}
void Split::doCopy()
void Split::copyToClipboard()
{
QApplication::clipboard()->setText(this->view_.getSelectedText());
}
void Split::doSearch()
void Split::showSearchPopup()
{
SearchPopup *popup = new SearchPopup();
@@ -563,26 +559,19 @@ static Iter select_randomly(Iter start, Iter end)
void Split::drag()
{
auto container = dynamic_cast<SplitContainer *>(this->parentWidget());
if (container != nullptr) {
if (auto container = dynamic_cast<SplitContainer *>(this->parentWidget())) {
SplitContainer::isDraggingSplit = true;
SplitContainer::draggingSplit = this;
auto originalLocation = container->releaseSplit(this);
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
auto drag = new QDrag(this);
auto mimeData = new QMimeData;
mimeData->setData("chatterino/split", "xD");
drag->setMimeData(mimeData);
Qt::DropAction dropAction = drag->exec(Qt::MoveAction);
if (dropAction == Qt::IgnoreAction) {
container->insertSplit(this,
originalLocation); // SplitContainer::dragOriginalPosition);
if (drag->exec(Qt::MoveAction) == Qt::IgnoreAction) {
container->insertSplit(this, originalLocation);
}
SplitContainer::isDraggingSplit = false;
+11 -7
View File
@@ -90,7 +90,11 @@ protected:
void focusInEvent(QFocusEvent *event) override;
private:
void doOpenUserInfoPopup(const QString &user);
void showUserInfoPopup(const QString &userName)
{
this->showUserInfoPopup(UserName{userName});
}
void showUserInfoPopup(const UserName &user);
void channelNameUpdated(const QString &newChannelName);
void handleModifiers(Qt::KeyboardModifiers modifiers);
@@ -137,22 +141,22 @@ public slots:
void doClearChat();
// Open link to twitch channel in default browser
void doOpenChannel();
void openInBrowser();
// Open popup player of twitch channel in default browser
void doOpenPopupPlayer();
void openInPopupPlayer();
// Open twitch channel stream through streamlink
void doOpenStreamlink();
void openInStreamlink();
// Copy text from chat
void doCopy();
void copyToClipboard();
// Open a search popup
void doSearch();
void showSearchPopup();
// Open viewer list of the channel
void doOpenViewerList();
void showViewerList();
};
} // namespace chatterino
+5 -9
View File
@@ -464,11 +464,9 @@ void SplitContainer::paintEvent(QPaintEvent *)
void SplitContainer::dragEnterEvent(QDragEnterEvent *event)
{
if (!event->mimeData()->hasFormat("chatterino/split"))
return;
if (!event->mimeData()->hasFormat("chatterino/split")) return;
if (!SplitContainer::isDraggingSplit)
return;
if (!SplitContainer::isDraggingSplit) return;
this->isDragging_ = true;
this->layout();
@@ -516,7 +514,7 @@ void SplitContainer::refreshTabTitle()
bool first = true;
for (const auto &chatWidget : this->splits_) {
auto channelName = chatWidget->getChannel()->name;
auto channelName = chatWidget->getChannel()->getName();
if (channelName.isEmpty()) {
continue;
}
@@ -851,10 +849,8 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale, std::vector<Dro
std::vector<ResizeRect> &resizeRects)
{
for (std::unique_ptr<Node> &node : this->children_) {
if (node->flexH_ <= 0)
node->flexH_ = 0;
if (node->flexV_ <= 0)
node->flexV_ = 0;
if (node->flexH_ <= 0) node->flexH_ = 0;
if (node->flexV_ <= 0) node->flexV_ = 0;
}
switch (this->type_) {
+10 -10
View File
@@ -115,8 +115,8 @@ void SplitHeader::addDropdownItems(RippleEffectButton *)
this->dropdownMenu_.addAction("Close split", this->split_, &Split::doCloseSplit, QKeySequence(tr("Ctrl+W")));
this->dropdownMenu_.addAction("Change channel", this->split_, &Split::doChangeChannel, QKeySequence(tr("Ctrl+R")));
this->dropdownMenu_.addSeparator();
this->dropdownMenu_.addAction("Viewer list", this->split_, &Split::doOpenViewerList);
this->dropdownMenu_.addAction("Search", this->split_, &Split::doSearch, QKeySequence(tr("Ctrl+F")));
this->dropdownMenu_.addAction("Viewer list", this->split_, &Split::showViewerList);
this->dropdownMenu_.addAction("Search", this->split_, &Split::showSearchPopup, QKeySequence(tr("Ctrl+F")));
this->dropdownMenu_.addSeparator();
this->dropdownMenu_.addAction("Popup", this->split_, &Split::doPopup);
#ifdef USEWEBENGINE
@@ -131,11 +131,11 @@ void SplitHeader::addDropdownItems(RippleEffectButton *)
}
});
#endif
this->dropdownMenu_.addAction("Open browser", this->split_, &Split::doOpenChannel);
this->dropdownMenu_.addAction("Open browser", this->split_, &Split::openInBrowser);
#ifndef USEWEBENGINE
this->dropdownMenu_.addAction("Open browser popup", this->split_, &Split::doOpenPopupPlayer);
this->dropdownMenu_.addAction("Open browser popup", this->split_, &Split::openInPopupPlayer);
#endif
this->dropdownMenu_.addAction("Open streamlink", this->split_, &Split::doOpenStreamlink);
this->dropdownMenu_.addAction("Open streamlink", this->split_, &Split::openInStreamlink);
this->dropdownMenu_.addSeparator();
this->dropdownMenu_.addAction("Reload channel emotes", this, SLOT(menuReloadChannelEmotes()));
this->dropdownMenu_.addAction("Reconnect", this, SLOT(menuManualReconnect()));
@@ -303,7 +303,7 @@ void SplitHeader::updateChannelText()
auto indirectChannel = this->split_->getIndirectChannel();
auto channel = this->split_->getChannel();
QString title = channel->name;
QString title = channel->getName();
if (indirectChannel.getType() == Channel::Type::TwitchWatching) {
title = "watching: " + (title.isEmpty() ? "none" : title);
@@ -349,8 +349,8 @@ void SplitHeader::updateModerationModeIcon()
auto app = getApp();
this->moderationButton_->setPixmap(this->split_->getModerationMode()
? *app->resources->moderationmode_enabled->getPixmap()
: *app->resources->moderationmode_disabled->getPixmap());
? app->resources->buttons.modModeEnabled
: app->resources->buttons.modModeDisabled);
bool modButtonVisible = false;
ChannelPtr channel = this->split_->getChannel();
@@ -473,9 +473,9 @@ void SplitHeader::themeChangedEvent()
}
if (this->theme->isLightTheme()) {
this->dropdownButton_->setPixmap(QPixmap(":/images/menu_black.png"));
this->dropdownButton_->setPixmap(getApp()->resources->buttons.menuDark);
} else {
this->dropdownButton_->setPixmap(QPixmap(":/images/menu_white.png"));
this->dropdownButton_->setPixmap(getApp()->resources->buttons.menuLight);
}
this->titleLabel->setPalette(palette);
+2 -2
View File
@@ -130,7 +130,7 @@ void SplitInput::updateEmoteButton()
{
float scale = this->getScale();
QString text = "<img src=':/images/emote.svg' width='xD' height='xD' />";
QString text = "<img src=':/buttons/emote.svg' width='xD' height='xD' />";
text.replace("xD", QString::number(int(12 * scale)));
if (this->theme->isLightTheme()) {
@@ -254,7 +254,7 @@ void SplitInput::installKeyPressedEvent()
}
} else if (event->key() == Qt::Key_C && event->modifiers() == Qt::ControlModifier) {
if (this->split_->view_.hasSelection()) {
this->split_->doCopy();
this->split_->copyToClipboard();
event->accept();
}
}
+5 -6
View File
@@ -29,12 +29,11 @@ SplitOverlay::SplitOverlay(Split *parent)
layout->setColumnStretch(1, 1);
layout->setColumnStretch(3, 1);
QPushButton *move = new QPushButton(getApp()->resources->split.move, QString());
QPushButton *left = this->left_ = new QPushButton(getApp()->resources->split.left, QString());
QPushButton *right = this->right_ =
new QPushButton(getApp()->resources->split.right, QString());
QPushButton *up = this->up_ = new QPushButton(getApp()->resources->split.up, QString());
QPushButton *down = this->down_ = new QPushButton(getApp()->resources->split.down, QString());
auto *move = new QPushButton(getApp()->resources->split.move, QString());
auto *left = this->left_ = new QPushButton(getApp()->resources->split.left, QString());
auto *right = this->right_ = new QPushButton(getApp()->resources->split.right, QString());
auto *up = this->up_ = new QPushButton(getApp()->resources->split.up, QString());
auto *down = this->down_ = new QPushButton(getApp()->resources->split.down, QString());
move->setGraphicsEffect(new QGraphicsOpacityEffect(this));
left->setGraphicsEffect(new QGraphicsOpacityEffect(this));