forgot to commit in a while

This commit is contained in:
fourtf
2018-06-01 14:20:46 +02:00
parent a3e4c92b9f
commit 3a78068810
15 changed files with 218 additions and 72 deletions
+3
View File
@@ -113,6 +113,9 @@ void SplitOverlay::paintEvent(QPaintEvent *)
default:;
}
rect.setRight(rect.right() - 1);
rect.setBottom(rect.bottom() - 1);
if (!rect.isNull()) {
painter.setPen(getApp()->themes->splits.dropPreviewBorder);
painter.setBrush(getApp()->themes->splits.dropPreview);
+62 -4
View File
@@ -1,17 +1,75 @@
#include "lastruncrashdialog.hpp"
#include <QDialogButtonBox>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include "singletons/updatemanager.hpp"
#include "util/layoutcreator.hpp"
#include "util/posttothread.hpp"
namespace chatterino {
namespace widgets {
LastRunCrashDialog::LastRunCrashDialog()
{
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(
new QLabel("The application wasn't terminated properly last time it was executed."));
this->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
this->setWindowTitle("Chatterino");
this->setLayout(layout);
auto &updateManager = singletons::UpdateManager::getInstance();
auto layout = util::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 = singletons::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 = singletons::UpdateManager::getInstance();
switch (updateManager.getStatus()) {
case singletons::UpdateManager::None: {
update->setText("Not checking for updates.");
} break;
case singletons::UpdateManager::Searching: {
update->setText("Checking for updates...");
} break;
case singletons::UpdateManager::UpdateAvailable: {
update->setText("Update available.");
} break;
case singletons::UpdateManager::NoUpdateAvailable: {
update->setText("No update abailable.");
} break;
case singletons::UpdateManager::Error: {
update->setText("Error while searching for update.\nEither the update service is "
"temporarily down or there is an issue with your installation.");
} break;
}
};
updateUpdateLabel();
this->managedConnect(updateManager.statusUpdated, [updateUpdateLabel](auto) mutable {
util::postToThread([updateUpdateLabel]() mutable { updateUpdateLabel(); });
});
}
} // namespace widgets
+2 -1
View File
@@ -1,11 +1,12 @@
#pragma once
#include <QDialog>
#include <pajlada/signals/signalholder.hpp>
namespace chatterino {
namespace widgets {
class LastRunCrashDialog : public QDialog
class LastRunCrashDialog : public QDialog, pajlada::Signals::SignalHolder
{
public:
LastRunCrashDialog();
+3 -3
View File
@@ -1,6 +1,7 @@
#include "widgets/split.hpp"
#include "application.hpp"
#include "common.hpp"
#include "providers/twitch/emotevalue.hpp"
#include "providers/twitch/twitchchannel.hpp"
#include "providers/twitch/twitchmessagebuilder.hpp"
@@ -129,7 +130,7 @@ Split::Split(QWidget *parent)
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
this->managedConnect(modifierStatusChanged, [this](Qt::KeyboardModifiers status) {
if ((status == Qt::AltModifier || status == (Qt::AltModifier | Qt::ControlModifier)) &&
if ((status == showSplitOverlayModifiers /*|| status == showAddSplitRegions*/) &&
this->isMouseOver) {
this->overlay->show();
} else {
@@ -307,8 +308,7 @@ void Split::enterEvent(QEvent *event)
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
if (modifierStatus == Qt::AltModifier ||
modifierStatus == (Qt::AltModifier | Qt::ControlModifier)) {
if (modifierStatus == showSplitOverlayModifiers /*|| modifierStatus == showAddSplitRegions*/) {
this->overlay->show();
}
}
+30 -11
View File
@@ -42,7 +42,7 @@ SplitContainer::SplitContainer(Notebook *parent)
this->managedConnect(Split::modifierStatusChanged, [this](auto modifiers) {
this->layout();
if (modifiers == Qt::AltModifier) {
if (modifiers == showResizeHandlesModifiers) {
for (std::unique_ptr<ResizeHandle> &handle : this->resizeHandles) {
handle->show();
handle->raise();
@@ -52,6 +52,12 @@ SplitContainer::SplitContainer(Notebook *parent)
handle->hide();
}
}
if (modifiers == showSplitOverlayModifiers) {
this->setCursor(Qt::PointingHandCursor);
} else {
this->unsetCursor();
}
});
this->setCursor(Qt::PointingHandCursor);
@@ -296,9 +302,8 @@ void SplitContainer::layout()
std::vector<DropRect> _dropRects;
std::vector<ResizeRect> _resizeRects;
this->baseNode.layout(
Split::modifierStatus == (Qt::AltModifier | Qt::ControlModifier) || this->isDragging,
this->getScale(), _dropRects, _resizeRects);
this->baseNode.layout(Split::modifierStatus == showAddSplitRegions || this->isDragging,
this->getScale(), _dropRects, _resizeRects);
this->dropRects = _dropRects;
@@ -345,7 +350,7 @@ void SplitContainer::layout()
handle->setVertical(resizeRect.vertical);
handle->node = resizeRect.node;
if (Split::modifierStatus == Qt::AltModifier) {
if (Split::modifierStatus == showResizeHandlesModifiers) {
handle->show();
handle->raise();
}
@@ -371,6 +376,7 @@ void SplitContainer::mouseReleaseEvent(QMouseEvent *event)
if (this->splits.size() == 0) {
// "Add Chat" was clicked
this->appendNewSplit(true);
this->mouseOverPoint = QPoint(-10000, -10000);
// this->setCursor(QCursor(Qt::ArrowCursor));
} else {
@@ -410,18 +416,31 @@ void SplitContainer::paintEvent(QPaintEvent *)
}
for (DropRect &dropRect : this->dropRects) {
QColor border = getApp()->themes->splits.dropPreviewBorder;
QColor background = getApp()->themes->splits.dropPreview;
QColor border = getApp()->themes->splits.dropTargetRectBorder;
QColor background = getApp()->themes->splits.dropTargetRect;
if (!dropRect.rect.contains(this->mouseOverPoint)) {
// border.setAlphaF(0.1);
background.setAlphaF(0.1);
// background.setAlphaF(0.1);
} else {
// background.setAlphaF(0.1);
border.setAlpha(255);
}
painter.setPen(border);
painter.setBrush(background);
painter.drawRect(dropRect.rect.marginsRemoved(QMargins(2, 2, 2, 2)));
auto rect = dropRect.rect.marginsRemoved(QMargins(2, 2, 2, 2));
painter.drawRect(rect);
int s = std::min<int>(dropRect.rect.width(), dropRect.rect.height()) - 12;
painter.setPen(QColor(255, 255, 255));
painter.drawLine(rect.left() + rect.width() / 2 - (s / 2), rect.top() + rect.height() / 2,
rect.left() + rect.width() / 2 + (s / 2), rect.top() + rect.height() / 2);
painter.drawLine(rect.left() + rect.width() / 2, rect.top() + rect.height() / 2 - (s / 2),
rect.left() + rect.width() / 2, rect.top() + rect.height() / 2 + (s / 2));
}
QBrush accentColor = (QApplication::activeWindow() == this->window()
@@ -1045,9 +1064,9 @@ SplitContainer::ResizeHandle::ResizeHandle(SplitContainer *_parent)
void SplitContainer::ResizeHandle::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setPen(QPen(getApp()->themes->splits.dropPreviewBorder, 2));
painter.setPen(QPen(getApp()->themes->splits.resizeHandle, 2));
painter.fillRect(this->rect(), getApp()->themes->splits.dropPreview);
painter.fillRect(this->rect(), getApp()->themes->splits.resizeHandleBackground);
if (this->vertical) {
painter.drawLine(0, this->height() / 2, this->width(), this->height() / 2);
+3 -2
View File
@@ -6,6 +6,7 @@
#include "singletons/settingsmanager.hpp"
#include "singletons/thememanager.hpp"
#include "singletons/windowmanager.hpp"
#include "version.hpp"
#include "widgets/accountswitchpopupwidget.hpp"
#include "widgets/helper/shortcut.hpp"
#include "widgets/notebook.hpp"
@@ -118,7 +119,7 @@ Window::Window(WindowType _type)
// ircManager.addFakeMessage(cheerMessages[index++ % cheerMessages.size()]);
// });
this->setWindowTitle("Chatterino 2 Development Build");
this->refreshWindowTitle("");
this->notebook.setAllowUserTabManagement(true);
this->notebook.setShowAddButton(true);
@@ -151,7 +152,7 @@ SplitNotebook &Window::getNotebook()
void Window::refreshWindowTitle(const QString &username)
{
this->setWindowTitle(username + " - Chatterino for Twitch");
this->setWindowTitle(username + " - Chatterino Beta " CHATTERINO_VERSION);
}
bool Window::event(QEvent *event)