added brace wrapping after if and for
This commit is contained in:
@@ -15,7 +15,8 @@ AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
|
||||
|
||||
this->addItem(ANONYMOUS_USERNAME_LABEL);
|
||||
|
||||
for (const auto &userName : app->accounts->twitch.getUsernames()) {
|
||||
for (const auto &userName : app->accounts->twitch.getUsernames())
|
||||
{
|
||||
this->addItem(userName);
|
||||
}
|
||||
|
||||
@@ -26,7 +27,8 @@ AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
|
||||
|
||||
this->addItem(ANONYMOUS_USERNAME_LABEL);
|
||||
|
||||
for (const auto &userName : app->accounts->twitch.getUsernames()) {
|
||||
for (const auto &userName : app->accounts->twitch.getUsernames())
|
||||
{
|
||||
this->addItem(userName);
|
||||
}
|
||||
|
||||
@@ -38,12 +40,16 @@ AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
|
||||
this->refreshSelection();
|
||||
|
||||
QObject::connect(this, &QListWidget::clicked, [=] {
|
||||
if (!this->selectedItems().isEmpty()) {
|
||||
if (!this->selectedItems().isEmpty())
|
||||
{
|
||||
QString newUsername = this->currentItem()->text();
|
||||
if (newUsername.compare(ANONYMOUS_USERNAME_LABEL,
|
||||
Qt::CaseInsensitive) == 0) {
|
||||
Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
app->accounts->twitch.currentUsername = "";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
app->accounts->twitch.currentUsername =
|
||||
newUsername.toStdString();
|
||||
}
|
||||
@@ -61,20 +67,25 @@ void AccountSwitchWidget::refreshSelection()
|
||||
this->blockSignals(true);
|
||||
|
||||
// Select the currently logged in user
|
||||
if (this->count() > 0) {
|
||||
if (this->count() > 0)
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
auto currentUser = app->accounts->twitch.getCurrent();
|
||||
|
||||
if (currentUser->isAnon()) {
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
this->setCurrentRow(0);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
const QString ¤tUsername = currentUser->getUserName();
|
||||
for (int i = 0; i < this->count(); ++i) {
|
||||
for (int i = 0; i < this->count(); ++i)
|
||||
{
|
||||
QString itemText = this->item(i)->text();
|
||||
|
||||
if (itemText.compare(currentUsername, Qt::CaseInsensitive) ==
|
||||
0) {
|
||||
if (itemText.compare(currentUsername, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
this->setCurrentRow(i);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -37,8 +37,10 @@ AttachedWindow::AttachedWindow(void *_target, int _yOffset)
|
||||
|
||||
AttachedWindow::~AttachedWindow()
|
||||
{
|
||||
for (auto it = items.begin(); it != items.end(); it++) {
|
||||
if (it->window == this) {
|
||||
for (auto it = items.begin(); it != items.end(); it++)
|
||||
{
|
||||
if (it->window == this)
|
||||
{
|
||||
items.erase(it);
|
||||
break;
|
||||
}
|
||||
@@ -50,8 +52,10 @@ AttachedWindow::~AttachedWindow()
|
||||
AttachedWindow *AttachedWindow::get(void *target, const GetArgs &args)
|
||||
{
|
||||
AttachedWindow *window = [&]() {
|
||||
for (Item &item : items) {
|
||||
if (item.hwnd == target) {
|
||||
for (Item &item : items)
|
||||
{
|
||||
if (item.hwnd == target)
|
||||
{
|
||||
return item.window;
|
||||
}
|
||||
}
|
||||
@@ -64,26 +68,35 @@ AttachedWindow *AttachedWindow::get(void *target, const GetArgs &args)
|
||||
bool show = true;
|
||||
QSize size = window->size();
|
||||
|
||||
if (args.height != -1) {
|
||||
if (args.height == 0) {
|
||||
if (args.height != -1)
|
||||
{
|
||||
if (args.height == 0)
|
||||
{
|
||||
window->hide();
|
||||
show = false;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
window->height_ = args.height;
|
||||
size.setHeight(args.height);
|
||||
}
|
||||
}
|
||||
if (args.width != -1) {
|
||||
if (args.width == 0) {
|
||||
if (args.width != -1)
|
||||
{
|
||||
if (args.width == 0)
|
||||
{
|
||||
window->hide();
|
||||
show = false;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
window->width_ = args.width;
|
||||
size.setWidth(args.width);
|
||||
}
|
||||
}
|
||||
|
||||
if (show) {
|
||||
if (show)
|
||||
{
|
||||
window->updateWindowRect(window->target_);
|
||||
window->show();
|
||||
}
|
||||
@@ -93,8 +106,10 @@ AttachedWindow *AttachedWindow::get(void *target, const GetArgs &args)
|
||||
|
||||
void AttachedWindow::detach(const QString &winId)
|
||||
{
|
||||
for (Item &item : items) {
|
||||
if (item.winId == winId) {
|
||||
for (Item &item : items)
|
||||
{
|
||||
if (item.winId == winId)
|
||||
{
|
||||
item.window->deleteLater();
|
||||
}
|
||||
}
|
||||
@@ -113,7 +128,8 @@ void AttachedWindow::showEvent(QShowEvent *)
|
||||
void AttachedWindow::attachToHwnd(void *_attachedPtr)
|
||||
{
|
||||
#ifdef USEWINSDK
|
||||
if (this->attached_) {
|
||||
if (this->attached_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -125,7 +141,8 @@ void AttachedWindow::attachToHwnd(void *_attachedPtr)
|
||||
|
||||
QObject::connect(&this->timer_, &QTimer::timeout, [this, hwnd, attached] {
|
||||
// check process id
|
||||
if (!this->validProcessName_) {
|
||||
if (!this->validProcessName_)
|
||||
{
|
||||
DWORD processId;
|
||||
::GetWindowThreadProcessId(attached, &processId);
|
||||
|
||||
@@ -139,7 +156,8 @@ void AttachedWindow::attachToHwnd(void *_attachedPtr)
|
||||
QString::fromWCharArray(filename.get(), filenameLength);
|
||||
|
||||
if (!qfilename.endsWith("chrome.exe") &&
|
||||
!qfilename.endsWith("firefox.exe")) {
|
||||
!qfilename.endsWith("firefox.exe"))
|
||||
{
|
||||
qDebug() << "NM Illegal caller" << qfilename;
|
||||
this->timer_.stop();
|
||||
this->deleteLater();
|
||||
@@ -167,7 +185,8 @@ void AttachedWindow::updateWindowRect(void *_attachedPtr)
|
||||
RECT rect;
|
||||
::GetWindowRect(attached, &rect);
|
||||
|
||||
if (::GetLastError() != 0) {
|
||||
if (::GetLastError() != 0)
|
||||
{
|
||||
qDebug() << "NM GetLastError()" << ::GetLastError();
|
||||
|
||||
this->timer_.stop();
|
||||
@@ -182,7 +201,8 @@ void AttachedWindow::updateWindowRect(void *_attachedPtr)
|
||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
|
||||
|
||||
float scale = 1.f;
|
||||
if (auto dpi = getWindowDpi(attached)) {
|
||||
if (auto dpi = getWindowDpi(attached))
|
||||
{
|
||||
scale = dpi.get() / 96.f;
|
||||
|
||||
// for (auto w : this->ui_.split->findChildren<BaseWidget *>()) {
|
||||
@@ -191,12 +211,15 @@ void AttachedWindow::updateWindowRect(void *_attachedPtr)
|
||||
// this->ui_.split->setOverrideScale(scale);
|
||||
}
|
||||
|
||||
if (this->height_ == -1) {
|
||||
if (this->height_ == -1)
|
||||
{
|
||||
// ::MoveWindow(hwnd, rect.right - this->width_ - 8, rect.top +
|
||||
// this->yOffset_ - 8,
|
||||
// this->width_, rect.bottom - rect.top - this->yOffset_,
|
||||
// false);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
::MoveWindow(hwnd, //
|
||||
int(rect.right - this->width_ * scale - 8), //
|
||||
int(rect.bottom - this->height_ * scale - 8), //
|
||||
|
||||
+19
-10
@@ -28,13 +28,15 @@ BaseWidget::BaseWidget(QWidget *parent, Qt::WindowFlags f)
|
||||
|
||||
float BaseWidget::getScale() const
|
||||
{
|
||||
if (this->overrideScale_) {
|
||||
if (this->overrideScale_)
|
||||
{
|
||||
return this->overrideScale_.get();
|
||||
}
|
||||
|
||||
BaseWidget *baseWidget = dynamic_cast<BaseWidget *>(this->window());
|
||||
|
||||
if (baseWidget == nullptr) {
|
||||
if (baseWidget == nullptr)
|
||||
{
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
@@ -87,10 +89,12 @@ void BaseWidget::setScaleIndependantSize(QSize size)
|
||||
{
|
||||
this->scaleIndependantSize_ = size;
|
||||
|
||||
if (size.width() > 0) {
|
||||
if (size.width() > 0)
|
||||
{
|
||||
this->setFixedWidth((int)(size.width() * this->getScale()));
|
||||
}
|
||||
if (size.height() > 0) {
|
||||
if (size.height() > 0)
|
||||
{
|
||||
this->setFixedHeight((int)(size.height() * this->getScale()));
|
||||
}
|
||||
}
|
||||
@@ -109,16 +113,21 @@ void BaseWidget::setScaleIndependantHeight(int value)
|
||||
|
||||
void BaseWidget::childEvent(QChildEvent *event)
|
||||
{
|
||||
if (event->added()) {
|
||||
if (event->added())
|
||||
{
|
||||
BaseWidget *widget = dynamic_cast<BaseWidget *>(event->child());
|
||||
|
||||
if (widget != nullptr) {
|
||||
if (widget != nullptr)
|
||||
{
|
||||
this->widgets_.push_back(widget);
|
||||
}
|
||||
} else if (event->removed()) {
|
||||
for (auto it = this->widgets_.begin(); it != this->widgets_.end();
|
||||
it++) {
|
||||
if (*it == event->child()) {
|
||||
}
|
||||
else if (event->removed())
|
||||
{
|
||||
for (auto it = this->widgets_.begin(); it != this->widgets_.end(); it++)
|
||||
{
|
||||
if (*it == event->child())
|
||||
{
|
||||
this->widgets_.erase(it);
|
||||
break;
|
||||
}
|
||||
|
||||
+171
-81
@@ -48,7 +48,8 @@ BaseWindow::BaseWindow(QWidget *parent, Flags _flags)
|
||||
, frameless_(_flags & Frameless)
|
||||
, flags_(_flags)
|
||||
{
|
||||
if (this->frameless_) {
|
||||
if (this->frameless_)
|
||||
{
|
||||
this->enableCustomFrame_ = false;
|
||||
this->setWindowFlag(Qt::FramelessWindowHint);
|
||||
}
|
||||
@@ -82,7 +83,8 @@ void BaseWindow::init()
|
||||
this->setWindowIcon(QIcon(":/images/icon.png"));
|
||||
|
||||
#ifdef USEWINSDK
|
||||
if (this->hasCustomWindowFrame()) {
|
||||
if (this->hasCustomWindowFrame())
|
||||
{
|
||||
// CUSTOM WINDOW FRAME
|
||||
QVBoxLayout *layout = new QVBoxLayout();
|
||||
this->ui_.windowLayout = layout;
|
||||
@@ -90,7 +92,8 @@ void BaseWindow::init()
|
||||
layout->setSpacing(0);
|
||||
this->setLayout(layout);
|
||||
{
|
||||
if (!this->frameless_) {
|
||||
if (!this->frameless_)
|
||||
{
|
||||
QHBoxLayout *buttonLayout = this->ui_.titlebarBox =
|
||||
new QHBoxLayout();
|
||||
buttonLayout->setMargin(0);
|
||||
@@ -161,7 +164,8 @@ void BaseWindow::init()
|
||||
|
||||
#ifdef USEWINSDK
|
||||
// fourtf: don't ask me why we need to delay this
|
||||
if (!(this->flags_ & Flags::TopMost)) {
|
||||
if (!(this->flags_ & Flags::TopMost))
|
||||
{
|
||||
QTimer::singleShot(1, this, [this] {
|
||||
getSettings()->windowTopMost.connect(
|
||||
[this](bool topMost, auto) {
|
||||
@@ -204,9 +208,12 @@ BaseWindow::ActionOnFocusLoss BaseWindow::getActionOnFocusLoss() const
|
||||
|
||||
QWidget *BaseWindow::getLayoutContainer()
|
||||
{
|
||||
if (this->hasCustomWindowFrame()) {
|
||||
if (this->hasCustomWindowFrame())
|
||||
{
|
||||
return this->ui_.layoutBase;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -224,13 +231,15 @@ bool BaseWindow::hasCustomWindowFrame()
|
||||
|
||||
void BaseWindow::themeChangedEvent()
|
||||
{
|
||||
if (this->hasCustomWindowFrame()) {
|
||||
if (this->hasCustomWindowFrame())
|
||||
{
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Background, QColor(0, 0, 0, 0));
|
||||
palette.setColor(QPalette::Foreground, this->theme->window.text);
|
||||
this->setPalette(palette);
|
||||
|
||||
if (this->ui_.titleLabel) {
|
||||
if (this->ui_.titleLabel)
|
||||
{
|
||||
QPalette palette_title;
|
||||
palette_title.setColor(
|
||||
QPalette::Foreground,
|
||||
@@ -238,10 +247,13 @@ void BaseWindow::themeChangedEvent()
|
||||
this->ui_.titleLabel->setPalette(palette_title);
|
||||
}
|
||||
|
||||
for (Button *button : this->ui_.buttons) {
|
||||
for (Button *button : this->ui_.buttons)
|
||||
{
|
||||
button->setMouseEffectColor(this->theme->window.text);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Background, this->theme->window.background);
|
||||
palette.setColor(QPalette::Foreground, this->theme->window.text);
|
||||
@@ -252,7 +264,8 @@ void BaseWindow::themeChangedEvent()
|
||||
bool BaseWindow::event(QEvent *event)
|
||||
{
|
||||
if (event->type() ==
|
||||
QEvent::WindowDeactivate /*|| event->type() == QEvent::FocusOut*/) {
|
||||
QEvent::WindowDeactivate /*|| event->type() == QEvent::FocusOut*/)
|
||||
{
|
||||
this->onFocusLost();
|
||||
}
|
||||
|
||||
@@ -261,15 +274,20 @@ bool BaseWindow::event(QEvent *event)
|
||||
|
||||
void BaseWindow::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (event->orientation() != Qt::Vertical) {
|
||||
if (event->orientation() != Qt::Vertical)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
if (event->delta() > 0) {
|
||||
if (event->modifiers() & Qt::ControlModifier)
|
||||
{
|
||||
if (event->delta() > 0)
|
||||
{
|
||||
getSettings()->uiScale.setValue(WindowManager::clampUiScale(
|
||||
getSettings()->uiScale.getValue() + 1));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
getSettings()->uiScale.setValue(WindowManager::clampUiScale(
|
||||
getSettings()->uiScale.getValue() - 1));
|
||||
}
|
||||
@@ -278,18 +296,25 @@ void BaseWindow::wheelEvent(QWheelEvent *event)
|
||||
|
||||
void BaseWindow::onFocusLost()
|
||||
{
|
||||
switch (this->getActionOnFocusLoss()) {
|
||||
case Delete: {
|
||||
switch (this->getActionOnFocusLoss())
|
||||
{
|
||||
case Delete:
|
||||
{
|
||||
this->deleteLater();
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Close: {
|
||||
case Close:
|
||||
{
|
||||
this->close();
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Hide: {
|
||||
case Hide:
|
||||
{
|
||||
this->hide();
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:;
|
||||
}
|
||||
@@ -298,24 +323,29 @@ void BaseWindow::onFocusLost()
|
||||
void BaseWindow::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
#ifndef Q_OS_WIN
|
||||
if (this->flags_ & FramelessDraggable) {
|
||||
if (this->flags_ & FramelessDraggable)
|
||||
{
|
||||
this->movingRelativePos = event->localPos();
|
||||
if (auto widget =
|
||||
this->childAt(event->localPos().x(), event->localPos().y())) {
|
||||
this->childAt(event->localPos().x(), event->localPos().y()))
|
||||
{
|
||||
std::function<bool(QWidget *)> recursiveCheckMouseTracking;
|
||||
recursiveCheckMouseTracking = [&](QWidget *widget) {
|
||||
if (widget == nullptr) {
|
||||
if (widget == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (widget->hasMouseTracking()) {
|
||||
if (widget->hasMouseTracking())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return recursiveCheckMouseTracking(widget->parentWidget());
|
||||
};
|
||||
|
||||
if (!recursiveCheckMouseTracking(widget)) {
|
||||
if (!recursiveCheckMouseTracking(widget))
|
||||
{
|
||||
log("Start moving");
|
||||
this->moving = true;
|
||||
}
|
||||
@@ -329,8 +359,10 @@ void BaseWindow::mousePressEvent(QMouseEvent *event)
|
||||
void BaseWindow::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
#ifndef Q_OS_WIN
|
||||
if (this->flags_ & FramelessDraggable) {
|
||||
if (this->moving) {
|
||||
if (this->flags_ & FramelessDraggable)
|
||||
{
|
||||
if (this->moving)
|
||||
{
|
||||
log("Stop moving");
|
||||
this->moving = false;
|
||||
}
|
||||
@@ -343,8 +375,10 @@ void BaseWindow::mouseReleaseEvent(QMouseEvent *event)
|
||||
void BaseWindow::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
#ifndef Q_OS_WIN
|
||||
if (this->flags_ & FramelessDraggable) {
|
||||
if (this->moving) {
|
||||
if (this->flags_ & FramelessDraggable)
|
||||
{
|
||||
if (this->moving)
|
||||
{
|
||||
const auto &newPos = event->screenPos() - this->movingRelativePos;
|
||||
this->move(newPos.x(), newPos.y());
|
||||
}
|
||||
@@ -389,7 +423,8 @@ void BaseWindow::changeEvent(QEvent *)
|
||||
TooltipWidget::getInstance()->hide();
|
||||
|
||||
#ifdef USEWINSDK
|
||||
if (this->ui_.maxButton) {
|
||||
if (this->ui_.maxButton)
|
||||
{
|
||||
this->ui_.maxButton->setButtonStyle(
|
||||
this->windowState() & Qt::WindowMaximized
|
||||
? TitleBarButtonStyle::Unmaximize
|
||||
@@ -409,7 +444,8 @@ void BaseWindow::leaveEvent(QEvent *)
|
||||
|
||||
void BaseWindow::moveTo(QWidget *parent, QPoint point, bool offset)
|
||||
{
|
||||
if (offset) {
|
||||
if (offset)
|
||||
{
|
||||
point.rx() += 16;
|
||||
point.ry() += 16;
|
||||
}
|
||||
@@ -443,7 +479,8 @@ void BaseWindow::closeEvent(QCloseEvent *)
|
||||
|
||||
void BaseWindow::moveIntoDesktopRect(QWidget *parent)
|
||||
{
|
||||
if (!this->stayInScreenRect_) return;
|
||||
if (!this->stayInScreenRect_)
|
||||
return;
|
||||
|
||||
// move the widget into the screen geometry if it's not already in there
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
@@ -451,20 +488,25 @@ void BaseWindow::moveIntoDesktopRect(QWidget *parent)
|
||||
QRect s = desktop->availableGeometry(parent);
|
||||
QPoint p = this->pos();
|
||||
|
||||
if (p.x() < s.left()) {
|
||||
if (p.x() < s.left())
|
||||
{
|
||||
p.setX(s.left());
|
||||
}
|
||||
if (p.y() < s.top()) {
|
||||
if (p.y() < s.top())
|
||||
{
|
||||
p.setY(s.top());
|
||||
}
|
||||
if (p.x() + this->width() > s.right()) {
|
||||
if (p.x() + this->width() > s.right())
|
||||
{
|
||||
p.setX(s.right() - this->width());
|
||||
}
|
||||
if (p.y() + this->height() > s.bottom()) {
|
||||
if (p.y() + this->height() > s.bottom())
|
||||
{
|
||||
p.setY(s.bottom() - this->height());
|
||||
}
|
||||
|
||||
if (p != this->pos()) this->move(p);
|
||||
if (p != this->pos())
|
||||
this->move(p);
|
||||
}
|
||||
|
||||
bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message,
|
||||
@@ -479,7 +521,8 @@ bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message,
|
||||
|
||||
bool returnValue = false;
|
||||
|
||||
switch (msg->message) {
|
||||
switch (msg->message)
|
||||
{
|
||||
case WM_DPICHANGED:
|
||||
returnValue = handleDPICHANGED(msg);
|
||||
break;
|
||||
@@ -523,7 +566,8 @@ void BaseWindow::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
if (this->frameless_) {
|
||||
if (this->frameless_)
|
||||
{
|
||||
painter.setPen(QColor("#999"));
|
||||
painter.drawRect(0, 0, this->width() - 1, this->height() - 1);
|
||||
}
|
||||
@@ -539,25 +583,30 @@ void BaseWindow::updateScale()
|
||||
: getApp()->windows->getUiScaleValue());
|
||||
this->setScale(scale);
|
||||
|
||||
for (auto child : this->findChildren<BaseWidget *>()) {
|
||||
for (auto child : this->findChildren<BaseWidget *>())
|
||||
{
|
||||
child->setScale(scale);
|
||||
}
|
||||
}
|
||||
|
||||
void BaseWindow::calcButtonsSizes()
|
||||
{
|
||||
if (!this->shown_) {
|
||||
if (!this->shown_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((this->width() / this->getScale()) < 300) {
|
||||
if ((this->width() / this->getScale()) < 300)
|
||||
{
|
||||
if (this->ui_.minButton)
|
||||
this->ui_.minButton->setScaleIndependantSize(30, 30);
|
||||
if (this->ui_.maxButton)
|
||||
this->ui_.maxButton->setScaleIndependantSize(30, 30);
|
||||
if (this->ui_.exitButton)
|
||||
this->ui_.exitButton->setScaleIndependantSize(30, 30);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->ui_.minButton)
|
||||
this->ui_.minButton->setScaleIndependantSize(46, 30);
|
||||
if (this->ui_.maxButton)
|
||||
@@ -570,7 +619,8 @@ void BaseWindow::calcButtonsSizes()
|
||||
void BaseWindow::drawCustomWindowFrame(QPainter &painter)
|
||||
{
|
||||
#ifdef USEWINSDK
|
||||
if (this->hasCustomWindowFrame()) {
|
||||
if (this->hasCustomWindowFrame())
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
QColor bg = this->overrideBackgroundColor_.value_or(
|
||||
@@ -591,7 +641,8 @@ bool BaseWindow::handleDPICHANGED(MSG *msg)
|
||||
|
||||
static bool firstResize = true;
|
||||
|
||||
if (!firstResize) {
|
||||
if (!firstResize)
|
||||
{
|
||||
auto *prcNewWindow = reinterpret_cast<RECT *>(msg->lParam);
|
||||
SetWindowPos(msg->hwnd, nullptr, prcNewWindow->left, prcNewWindow->top,
|
||||
prcNewWindow->right - prcNewWindow->left,
|
||||
@@ -612,12 +663,14 @@ bool BaseWindow::handleDPICHANGED(MSG *msg)
|
||||
bool BaseWindow::handleSHOWWINDOW(MSG *msg)
|
||||
{
|
||||
#ifdef USEWINSDK
|
||||
if (auto dpi = getWindowDpi(msg->hwnd)) {
|
||||
if (auto dpi = getWindowDpi(msg->hwnd))
|
||||
{
|
||||
this->nativeScale_ = dpi.get() / 96.f;
|
||||
this->updateScale();
|
||||
}
|
||||
|
||||
if (!this->shown_ && this->isVisible() && this->hasCustomWindowFrame()) {
|
||||
if (!this->shown_ && this->isVisible() && this->hasCustomWindowFrame())
|
||||
{
|
||||
this->shown_ = true;
|
||||
|
||||
const MARGINS shadow = {8, 8, 8, 8};
|
||||
@@ -635,11 +688,13 @@ bool BaseWindow::handleSHOWWINDOW(MSG *msg)
|
||||
bool BaseWindow::handleNCCALCSIZE(MSG *msg, long *result)
|
||||
{
|
||||
#ifdef USEWINSDK
|
||||
if (this->hasCustomWindowFrame()) {
|
||||
if (this->hasCustomWindowFrame())
|
||||
{
|
||||
// int cx = GetSystemMetrics(SM_CXSIZEFRAME);
|
||||
// int cy = GetSystemMetrics(SM_CYSIZEFRAME);
|
||||
|
||||
if (msg->wParam == TRUE) {
|
||||
if (msg->wParam == TRUE)
|
||||
{
|
||||
NCCALCSIZE_PARAMS *ncp =
|
||||
(reinterpret_cast<NCCALCSIZE_PARAMS *>(msg->lParam));
|
||||
ncp->lppos->flags |= SWP_NOREDRAW;
|
||||
@@ -663,16 +718,23 @@ bool BaseWindow::handleNCCALCSIZE(MSG *msg, long *result)
|
||||
bool BaseWindow::handleSIZE(MSG *msg)
|
||||
{
|
||||
#ifdef USEWINSDK
|
||||
if (this->ui_.windowLayout) {
|
||||
if (this->frameless_) {
|
||||
if (this->ui_.windowLayout)
|
||||
{
|
||||
if (this->frameless_)
|
||||
{
|
||||
//
|
||||
} else if (this->hasCustomWindowFrame()) {
|
||||
if (msg->wParam == SIZE_MAXIMIZED) {
|
||||
}
|
||||
else if (this->hasCustomWindowFrame())
|
||||
{
|
||||
if (msg->wParam == SIZE_MAXIMIZED)
|
||||
{
|
||||
auto offset = int(this->getScale() * 8);
|
||||
|
||||
this->ui_.windowLayout->setContentsMargins(offset, offset,
|
||||
offset, offset);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui_.windowLayout->setContentsMargins(0, 1, 0, 0);
|
||||
}
|
||||
}
|
||||
@@ -695,102 +757,130 @@ bool BaseWindow::handleNCHITTEST(MSG *msg, long *result)
|
||||
|
||||
QPoint point(x - winrect.left, y - winrect.top);
|
||||
|
||||
if (this->hasCustomWindowFrame()) {
|
||||
if (this->hasCustomWindowFrame())
|
||||
{
|
||||
*result = 0;
|
||||
|
||||
bool resizeWidth = minimumWidth() != maximumWidth();
|
||||
bool resizeHeight = minimumHeight() != maximumHeight();
|
||||
|
||||
if (resizeWidth) {
|
||||
if (resizeWidth)
|
||||
{
|
||||
// left border
|
||||
if (x < winrect.left + border_width) {
|
||||
if (x < winrect.left + border_width)
|
||||
{
|
||||
*result = HTLEFT;
|
||||
}
|
||||
// right border
|
||||
if (x >= winrect.right - border_width) {
|
||||
if (x >= winrect.right - border_width)
|
||||
{
|
||||
*result = HTRIGHT;
|
||||
}
|
||||
}
|
||||
if (resizeHeight) {
|
||||
if (resizeHeight)
|
||||
{
|
||||
// bottom border
|
||||
if (y >= winrect.bottom - border_width) {
|
||||
if (y >= winrect.bottom - border_width)
|
||||
{
|
||||
*result = HTBOTTOM;
|
||||
}
|
||||
// top border
|
||||
if (y < winrect.top + border_width) {
|
||||
if (y < winrect.top + border_width)
|
||||
{
|
||||
*result = HTTOP;
|
||||
}
|
||||
}
|
||||
if (resizeWidth && resizeHeight) {
|
||||
if (resizeWidth && resizeHeight)
|
||||
{
|
||||
// bottom left corner
|
||||
if (x >= winrect.left && x < winrect.left + border_width &&
|
||||
y < winrect.bottom && y >= winrect.bottom - border_width) {
|
||||
y < winrect.bottom && y >= winrect.bottom - border_width)
|
||||
{
|
||||
*result = HTBOTTOMLEFT;
|
||||
}
|
||||
// bottom right corner
|
||||
if (x < winrect.right && x >= winrect.right - border_width &&
|
||||
y < winrect.bottom && y >= winrect.bottom - border_width) {
|
||||
y < winrect.bottom && y >= winrect.bottom - border_width)
|
||||
{
|
||||
*result = HTBOTTOMRIGHT;
|
||||
}
|
||||
// top left corner
|
||||
if (x >= winrect.left && x < winrect.left + border_width &&
|
||||
y >= winrect.top && y < winrect.top + border_width) {
|
||||
y >= winrect.top && y < winrect.top + border_width)
|
||||
{
|
||||
*result = HTTOPLEFT;
|
||||
}
|
||||
// top right corner
|
||||
if (x < winrect.right && x >= winrect.right - border_width &&
|
||||
y >= winrect.top && y < winrect.top + border_width) {
|
||||
y >= winrect.top && y < winrect.top + border_width)
|
||||
{
|
||||
*result = HTTOPRIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
if (*result == 0) {
|
||||
if (*result == 0)
|
||||
{
|
||||
bool client = false;
|
||||
|
||||
for (QWidget *widget : this->ui_.buttons) {
|
||||
if (widget->geometry().contains(point)) {
|
||||
for (QWidget *widget : this->ui_.buttons)
|
||||
{
|
||||
if (widget->geometry().contains(point))
|
||||
{
|
||||
client = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->ui_.layoutBase->geometry().contains(point)) {
|
||||
if (this->ui_.layoutBase->geometry().contains(point))
|
||||
{
|
||||
client = true;
|
||||
}
|
||||
|
||||
if (client) {
|
||||
if (client)
|
||||
{
|
||||
*result = HTCLIENT;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
*result = HTCAPTION;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (this->flags_ & FramelessDraggable) {
|
||||
}
|
||||
else if (this->flags_ & FramelessDraggable)
|
||||
{
|
||||
*result = 0;
|
||||
bool client = false;
|
||||
|
||||
if (auto widget = this->childAt(point)) {
|
||||
if (auto widget = this->childAt(point))
|
||||
{
|
||||
std::function<bool(QWidget *)> recursiveCheckMouseTracking;
|
||||
recursiveCheckMouseTracking = [&](QWidget *widget) {
|
||||
if (widget == nullptr) {
|
||||
if (widget == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (widget->hasMouseTracking()) {
|
||||
if (widget->hasMouseTracking())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return recursiveCheckMouseTracking(widget->parentWidget());
|
||||
};
|
||||
|
||||
if (recursiveCheckMouseTracking(widget)) {
|
||||
if (recursiveCheckMouseTracking(widget))
|
||||
{
|
||||
client = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (client) {
|
||||
if (client)
|
||||
{
|
||||
*result = HTCLIENT;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
*result = HTCAPTION;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@ const QString &Label::getText() const
|
||||
|
||||
void Label::setText(const QString &text)
|
||||
{
|
||||
if (this->text_ != text) {
|
||||
if (this->text_ != text)
|
||||
{
|
||||
this->text_ = text;
|
||||
this->updateSize();
|
||||
this->update();
|
||||
|
||||
+86
-42
@@ -63,7 +63,8 @@ NotebookTab *Notebook::addPage(QWidget *page, QString title, bool select)
|
||||
page->hide();
|
||||
page->setParent(this);
|
||||
|
||||
if (select || this->items_.count() == 1) {
|
||||
if (select || this->items_.count() == 1)
|
||||
{
|
||||
this->select(page);
|
||||
}
|
||||
|
||||
@@ -79,13 +80,20 @@ void Notebook::removePage(QWidget *page)
|
||||
// Queue up save because: Tab removed
|
||||
getApp()->windows->queueSave();
|
||||
|
||||
for (int i = 0; i < this->items_.count(); i++) {
|
||||
if (this->items_[i].page == page) {
|
||||
if (this->items_.count() == 1) {
|
||||
for (int i = 0; i < this->items_.count(); i++)
|
||||
{
|
||||
if (this->items_[i].page == page)
|
||||
{
|
||||
if (this->items_.count() == 1)
|
||||
{
|
||||
this->select(nullptr);
|
||||
} else if (i == this->items_.count() - 1) {
|
||||
}
|
||||
else if (i == this->items_.count() - 1)
|
||||
{
|
||||
this->select(this->items_[i - 1].page);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->select(this->items_[i + 1].page);
|
||||
}
|
||||
|
||||
@@ -106,15 +114,18 @@ void Notebook::removePage(QWidget *page)
|
||||
|
||||
void Notebook::removeCurrentPage()
|
||||
{
|
||||
if (this->selectedPage_ != nullptr) {
|
||||
if (this->selectedPage_ != nullptr)
|
||||
{
|
||||
this->removePage(this->selectedPage_);
|
||||
}
|
||||
}
|
||||
|
||||
int Notebook::indexOf(QWidget *page) const
|
||||
{
|
||||
for (int i = 0; i < this->items_.count(); i++) {
|
||||
if (this->items_[i].page == page) {
|
||||
for (int i = 0; i < this->items_.count(); i++)
|
||||
{
|
||||
if (this->items_[i].page == page)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -124,11 +135,13 @@ int Notebook::indexOf(QWidget *page) const
|
||||
|
||||
void Notebook::select(QWidget *page)
|
||||
{
|
||||
if (page == this->selectedPage_) {
|
||||
if (page == this->selectedPage_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (page != nullptr) {
|
||||
if (page != nullptr)
|
||||
{
|
||||
page->setHidden(false);
|
||||
|
||||
assert(this->containsPage(page));
|
||||
@@ -137,20 +150,27 @@ void Notebook::select(QWidget *page)
|
||||
item.tab->setSelected(true);
|
||||
item.tab->raise();
|
||||
|
||||
if (item.selectedWidget == nullptr) {
|
||||
if (item.selectedWidget == nullptr)
|
||||
{
|
||||
item.page->setFocus();
|
||||
} else {
|
||||
if (containsChild(page, item.selectedWidget)) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (containsChild(page, item.selectedWidget))
|
||||
{
|
||||
qDebug() << item.selectedWidget;
|
||||
item.selectedWidget->setFocus(Qt::MouseFocusReason);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug()
|
||||
<< "Notebook: selected child of page doesn't exist anymore";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this->selectedPage_ != nullptr) {
|
||||
if (this->selectedPage_ != nullptr)
|
||||
{
|
||||
this->selectedPage_->setHidden(true);
|
||||
|
||||
Item &item = this->findItem(selectedPage_);
|
||||
@@ -187,7 +207,8 @@ bool Notebook::containsChild(const QObject *obj, const QObject *child)
|
||||
{
|
||||
return std::any_of(obj->children().begin(), obj->children().end(),
|
||||
[child](const QObject *o) {
|
||||
if (o == child) {
|
||||
if (o == child)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -197,7 +218,8 @@ bool Notebook::containsChild(const QObject *obj, const QObject *child)
|
||||
|
||||
void Notebook::selectIndex(int index)
|
||||
{
|
||||
if (index < 0 || this->items_.count() <= index) {
|
||||
if (index < 0 || this->items_.count() <= index)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -206,7 +228,8 @@ void Notebook::selectIndex(int index)
|
||||
|
||||
void Notebook::selectNextTab()
|
||||
{
|
||||
if (this->items_.size() <= 1) {
|
||||
if (this->items_.size() <= 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -218,13 +241,15 @@ void Notebook::selectNextTab()
|
||||
|
||||
void Notebook::selectPreviousTab()
|
||||
{
|
||||
if (this->items_.size() <= 1) {
|
||||
if (this->items_.size() <= 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int index = this->indexOf(this->selectedPage_) - 1;
|
||||
|
||||
if (index < 0) {
|
||||
if (index < 0)
|
||||
{
|
||||
index += this->items_.count();
|
||||
}
|
||||
|
||||
@@ -255,13 +280,15 @@ QWidget *Notebook::tabAt(QPoint point, int &index, int maxWidth)
|
||||
{
|
||||
auto i = 0;
|
||||
|
||||
for (auto &item : this->items_) {
|
||||
for (auto &item : this->items_)
|
||||
{
|
||||
auto rect = item.tab->getDesiredRect();
|
||||
rect.setHeight(int(this->getScale() * 24));
|
||||
|
||||
rect.setWidth(std::min(maxWidth, rect.width()));
|
||||
|
||||
if (rect.contains(point)) {
|
||||
if (rect.contains(point))
|
||||
{
|
||||
index = i;
|
||||
return item.page;
|
||||
}
|
||||
@@ -311,7 +338,8 @@ void Notebook::scaleChangedEvent(float scale)
|
||||
|
||||
this->addButton_->setFixedSize(h, h);
|
||||
|
||||
for (auto &i : this->items_) {
|
||||
for (auto &i : this->items_)
|
||||
{
|
||||
i.tab->updateSize();
|
||||
}
|
||||
}
|
||||
@@ -332,8 +360,10 @@ void Notebook::performLayout(bool animated)
|
||||
auto y = 0;
|
||||
|
||||
// set size of custom buttons (settings, user, ...)
|
||||
for (auto *btn : this->customButtons_) {
|
||||
if (!btn->isVisible()) {
|
||||
for (auto *btn : this->customButtons_)
|
||||
{
|
||||
if (!btn->isVisible())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -347,7 +377,8 @@ void Notebook::performLayout(bool animated)
|
||||
auto firstInBottomRow =
|
||||
this->items_.size() ? &this->items_.front() : nullptr;
|
||||
|
||||
for (auto &item : this->items_) {
|
||||
for (auto &item : this->items_)
|
||||
{
|
||||
/// Break line if element doesn't fit.
|
||||
auto isFirst = &item == &this->items_.front();
|
||||
auto isLast = &item == &this->items_.back();
|
||||
@@ -355,7 +386,8 @@ void Notebook::performLayout(bool animated)
|
||||
auto fitsInLine =
|
||||
((isLast ? addButtonWidth : 0) + x + item.tab->width()) <= width();
|
||||
|
||||
if (!isFirst && !fitsInLine) {
|
||||
if (!isFirst && !fitsInLine)
|
||||
{
|
||||
y += item.tab->height();
|
||||
x = left;
|
||||
firstInBottomRow = &item;
|
||||
@@ -368,19 +400,23 @@ void Notebook::performLayout(bool animated)
|
||||
|
||||
/// Update which tabs are in the last row
|
||||
auto inLastRow = false;
|
||||
for (const auto &item : this->items_) {
|
||||
if (&item == firstInBottomRow) {
|
||||
for (const auto &item : this->items_)
|
||||
{
|
||||
if (&item == firstInBottomRow)
|
||||
{
|
||||
inLastRow = true;
|
||||
}
|
||||
item.tab->setInLastRow(inLastRow);
|
||||
}
|
||||
|
||||
// move misc buttons
|
||||
if (this->showAddButton_) {
|
||||
if (this->showAddButton_)
|
||||
{
|
||||
this->addButton_->move(x, y);
|
||||
}
|
||||
|
||||
if (this->lineY_ != y + tabHeight) {
|
||||
if (this->lineY_ != y + tabHeight)
|
||||
{
|
||||
this->lineY_ = y + tabHeight;
|
||||
this->update();
|
||||
}
|
||||
@@ -389,16 +425,19 @@ void Notebook::performLayout(bool animated)
|
||||
y += int(2 * scale);
|
||||
|
||||
// raise elements
|
||||
for (auto &i : this->items_) {
|
||||
for (auto &i : this->items_)
|
||||
{
|
||||
i.tab->raise();
|
||||
}
|
||||
|
||||
if (this->showAddButton_) {
|
||||
if (this->showAddButton_)
|
||||
{
|
||||
this->addButton_->raise();
|
||||
}
|
||||
|
||||
// set page bounds
|
||||
if (this->selectedPage_ != nullptr) {
|
||||
if (this->selectedPage_ != nullptr)
|
||||
{
|
||||
this->selectedPage_->move(0, y + tabHeight);
|
||||
this->selectedPage_->resize(width(), height() - y - tabHeight);
|
||||
this->selectedPage_->raise();
|
||||
@@ -431,8 +470,10 @@ NotebookButton *Notebook::addCustomButton()
|
||||
|
||||
NotebookTab *Notebook::getTabFromPage(QWidget *page)
|
||||
{
|
||||
for (auto &it : this->items_) {
|
||||
if (it.page == page) {
|
||||
for (auto &it : this->items_)
|
||||
{
|
||||
if (it.page == page)
|
||||
{
|
||||
return it.tab;
|
||||
}
|
||||
}
|
||||
@@ -448,7 +489,8 @@ SplitNotebook::SplitNotebook(Window *parent)
|
||||
});
|
||||
|
||||
// add custom buttons if they are not in the parent window frame
|
||||
if (!parent->hasCustomWindowFrame()) {
|
||||
if (!parent->hasCustomWindowFrame())
|
||||
{
|
||||
this->addCustomButtons();
|
||||
}
|
||||
}
|
||||
@@ -508,10 +550,12 @@ SplitContainer *SplitNotebook::getOrAddSelectedPage()
|
||||
|
||||
void SplitNotebook::select(QWidget *page)
|
||||
{
|
||||
if (auto selectedPage = this->getSelectedPage()) {
|
||||
if (auto splitContainer =
|
||||
dynamic_cast<SplitContainer *>(selectedPage)) {
|
||||
for (auto split : splitContainer->getSplits()) {
|
||||
if (auto selectedPage = this->getSelectedPage())
|
||||
{
|
||||
if (auto splitContainer = dynamic_cast<SplitContainer *>(selectedPage))
|
||||
{
|
||||
for (auto split : splitContainer->getSplits())
|
||||
{
|
||||
split->updateLastReadMessage();
|
||||
}
|
||||
}
|
||||
|
||||
+97
-41
@@ -62,7 +62,8 @@ void Scrollbar::clearHighlights()
|
||||
|
||||
LimitedQueueSnapshot<ScrollbarHighlight> Scrollbar::getHighlightSnapshot()
|
||||
{
|
||||
if (!this->highlightsPaused_) {
|
||||
if (!this->highlightsPaused_)
|
||||
{
|
||||
this->highlightSnapshot_ = this->highlights_.getSnapshot();
|
||||
}
|
||||
|
||||
@@ -114,8 +115,10 @@ void Scrollbar::setDesiredValue(qreal value, bool animated)
|
||||
std::min(this->maximum_ - this->largeChange_, value));
|
||||
|
||||
if (std::abs(this->desiredValue_ + this->smoothScrollingOffset_ - value) >
|
||||
0.0001) {
|
||||
if (animated) {
|
||||
0.0001)
|
||||
{
|
||||
if (animated)
|
||||
{
|
||||
this->currentValueAnimation_.stop();
|
||||
this->currentValueAnimation_.setStartValue(
|
||||
this->currentValue_ + this->smoothScrollingOffset_);
|
||||
@@ -130,9 +133,12 @@ void Scrollbar::setDesiredValue(qreal value, bool animated)
|
||||
this->atBottom_ = ((this->getMaximum() - this->getLargeChange()) -
|
||||
value) <= 0.0001;
|
||||
this->currentValueAnimation_.start();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->currentValueAnimation_.state() !=
|
||||
QPropertyAnimation::Running) {
|
||||
QPropertyAnimation::Running)
|
||||
{
|
||||
this->smoothScrollingOffset_ = 0;
|
||||
this->desiredValue_ = value;
|
||||
this->currentValueAnimation_.stop();
|
||||
@@ -182,9 +188,12 @@ qreal Scrollbar::getCurrentValue() const
|
||||
|
||||
void Scrollbar::offset(qreal value)
|
||||
{
|
||||
if (this->currentValueAnimation_.state() == QPropertyAnimation::Running) {
|
||||
if (this->currentValueAnimation_.state() == QPropertyAnimation::Running)
|
||||
{
|
||||
this->smoothScrollingOffset_ += value;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setDesiredValue(this->getDesiredValue() + value);
|
||||
}
|
||||
}
|
||||
@@ -205,7 +214,8 @@ void Scrollbar::setCurrentValue(qreal value)
|
||||
std::min(this->maximum_ - this->largeChange_,
|
||||
value + this->smoothScrollingOffset_));
|
||||
|
||||
if (std::abs(this->currentValue_ - value) > 0.0001) {
|
||||
if (std::abs(this->currentValue_ - value) > 0.0001)
|
||||
{
|
||||
this->currentValue_ = value;
|
||||
|
||||
this->updateScroll();
|
||||
@@ -241,12 +251,14 @@ void Scrollbar::paintEvent(QPaintEvent *)
|
||||
this->thumbRect_.setX(xOffset);
|
||||
|
||||
// mouse over thumb
|
||||
if (this->mouseDownIndex_ == 2) {
|
||||
if (this->mouseDownIndex_ == 2)
|
||||
{
|
||||
painter.fillRect(this->thumbRect_,
|
||||
this->theme->scrollbars.thumbSelected);
|
||||
}
|
||||
// mouse not over thumb
|
||||
else {
|
||||
else
|
||||
{
|
||||
painter.fillRect(this->thumbRect_, this->theme->scrollbars.thumb);
|
||||
}
|
||||
|
||||
@@ -254,7 +266,8 @@ void Scrollbar::paintEvent(QPaintEvent *)
|
||||
auto snapshot = this->getHighlightSnapshot();
|
||||
size_t snapshotLength = snapshot.getLength();
|
||||
|
||||
if (snapshotLength == 0) {
|
||||
if (snapshotLength == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -263,12 +276,15 @@ void Scrollbar::paintEvent(QPaintEvent *)
|
||||
float dY = float(this->height()) / float(snapshotLength);
|
||||
int highlightHeight = int(std::ceil(dY));
|
||||
|
||||
for (size_t i = 0; i < snapshotLength; i++) {
|
||||
for (size_t i = 0; i < snapshotLength; i++)
|
||||
{
|
||||
ScrollbarHighlight const &highlight = snapshot[i];
|
||||
|
||||
if (!highlight.isNull()) {
|
||||
if (!highlight.isNull())
|
||||
{
|
||||
QColor color = [&] {
|
||||
switch (highlight.getColor()) {
|
||||
switch (highlight.getColor())
|
||||
{
|
||||
case ScrollbarHighlight::Highlight:
|
||||
return getApp()
|
||||
->themes->scrollbars.highlights.highlight;
|
||||
@@ -279,15 +295,20 @@ void Scrollbar::paintEvent(QPaintEvent *)
|
||||
return QColor();
|
||||
}();
|
||||
|
||||
switch (highlight.getStyle()) {
|
||||
case ScrollbarHighlight::Default: {
|
||||
switch (highlight.getStyle())
|
||||
{
|
||||
case ScrollbarHighlight::Default:
|
||||
{
|
||||
painter.fillRect(w / 8 * 3, int(y), w / 4, highlightHeight,
|
||||
color);
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case ScrollbarHighlight::Line: {
|
||||
case ScrollbarHighlight::Line:
|
||||
{
|
||||
painter.fillRect(0, int(y), w, 1, color);
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case ScrollbarHighlight::None:;
|
||||
}
|
||||
@@ -304,27 +325,40 @@ void Scrollbar::resizeEvent(QResizeEvent *)
|
||||
|
||||
void Scrollbar::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (this->mouseDownIndex_ == -1) {
|
||||
if (this->mouseDownIndex_ == -1)
|
||||
{
|
||||
int y = event->pos().y();
|
||||
|
||||
auto oldIndex = this->mouseOverIndex_;
|
||||
|
||||
if (y < this->buttonHeight_) {
|
||||
if (y < this->buttonHeight_)
|
||||
{
|
||||
this->mouseOverIndex_ = 0;
|
||||
} else if (y < this->thumbRect_.y()) {
|
||||
}
|
||||
else if (y < this->thumbRect_.y())
|
||||
{
|
||||
this->mouseOverIndex_ = 1;
|
||||
} else if (this->thumbRect_.contains(2, y)) {
|
||||
}
|
||||
else if (this->thumbRect_.contains(2, y))
|
||||
{
|
||||
this->mouseOverIndex_ = 2;
|
||||
} else if (y < height() - this->buttonHeight_) {
|
||||
}
|
||||
else if (y < height() - this->buttonHeight_)
|
||||
{
|
||||
this->mouseOverIndex_ = 3;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->mouseOverIndex_ = 4;
|
||||
}
|
||||
|
||||
if (oldIndex != this->mouseOverIndex_) {
|
||||
if (oldIndex != this->mouseOverIndex_)
|
||||
{
|
||||
update();
|
||||
}
|
||||
} else if (this->mouseDownIndex_ == 2) {
|
||||
}
|
||||
else if (this->mouseDownIndex_ == 2)
|
||||
{
|
||||
int delta = event->pos().y() - this->lastMousePosition_.y();
|
||||
|
||||
setDesiredValue(this->desiredValue_ +
|
||||
@@ -338,15 +372,24 @@ void Scrollbar::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
int y = event->pos().y();
|
||||
|
||||
if (y < this->buttonHeight_) {
|
||||
if (y < this->buttonHeight_)
|
||||
{
|
||||
this->mouseDownIndex_ = 0;
|
||||
} else if (y < this->thumbRect_.y()) {
|
||||
}
|
||||
else if (y < this->thumbRect_.y())
|
||||
{
|
||||
this->mouseDownIndex_ = 1;
|
||||
} else if (this->thumbRect_.contains(2, y)) {
|
||||
}
|
||||
else if (this->thumbRect_.contains(2, y))
|
||||
{
|
||||
this->mouseDownIndex_ = 2;
|
||||
} else if (y < height() - this->buttonHeight_) {
|
||||
}
|
||||
else if (y < height() - this->buttonHeight_)
|
||||
{
|
||||
this->mouseDownIndex_ = 3;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->mouseDownIndex_ = 4;
|
||||
}
|
||||
}
|
||||
@@ -355,22 +398,35 @@ void Scrollbar::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
int y = event->pos().y();
|
||||
|
||||
if (y < this->buttonHeight_) {
|
||||
if (this->mouseDownIndex_ == 0) {
|
||||
if (y < this->buttonHeight_)
|
||||
{
|
||||
if (this->mouseDownIndex_ == 0)
|
||||
{
|
||||
setDesiredValue(this->desiredValue_ - this->smallChange_, true);
|
||||
}
|
||||
} else if (y < this->thumbRect_.y()) {
|
||||
if (this->mouseDownIndex_ == 1) {
|
||||
}
|
||||
else if (y < this->thumbRect_.y())
|
||||
{
|
||||
if (this->mouseDownIndex_ == 1)
|
||||
{
|
||||
setDesiredValue(this->desiredValue_ - this->smallChange_, true);
|
||||
}
|
||||
} else if (this->thumbRect_.contains(2, y)) {
|
||||
}
|
||||
else if (this->thumbRect_.contains(2, y))
|
||||
{
|
||||
// do nothing
|
||||
} else if (y < height() - this->buttonHeight_) {
|
||||
if (this->mouseDownIndex_ == 3) {
|
||||
}
|
||||
else if (y < height() - this->buttonHeight_)
|
||||
{
|
||||
if (this->mouseDownIndex_ == 3)
|
||||
{
|
||||
setDesiredValue(this->desiredValue_ + this->smallChange_, true);
|
||||
}
|
||||
} else {
|
||||
if (this->mouseDownIndex_ == 4) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->mouseDownIndex_ == 4)
|
||||
{
|
||||
setDesiredValue(this->desiredValue_ + this->smallChange_, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ namespace chatterino {
|
||||
TooltipWidget *TooltipWidget::getInstance()
|
||||
{
|
||||
static TooltipWidget *tooltipWidget = nullptr;
|
||||
if (tooltipWidget == nullptr) {
|
||||
if (tooltipWidget == nullptr)
|
||||
{
|
||||
tooltipWidget = new TooltipWidget();
|
||||
}
|
||||
return tooltipWidget;
|
||||
|
||||
+50
-24
@@ -48,9 +48,12 @@ Window::Window(WindowType type)
|
||||
[this] { this->onAccountSelected(); });
|
||||
this->onAccountSelected();
|
||||
|
||||
if (type == WindowType::Main) {
|
||||
if (type == WindowType::Main)
|
||||
{
|
||||
this->resize(int(600 * this->getScale()), int(500 * this->getScale()));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->resize(int(300 * this->getScale()), int(500 * this->getScale()));
|
||||
}
|
||||
}
|
||||
@@ -69,8 +72,10 @@ void Window::repaintVisibleChatWidgets(Channel *channel)
|
||||
{
|
||||
auto page = this->notebook_->getOrAddSelectedPage();
|
||||
|
||||
for (const auto &split : page->getSplits()) {
|
||||
if (channel == nullptr || channel == split->getChannel().get()) {
|
||||
for (const auto &split : page->getSplits())
|
||||
{
|
||||
if (channel == nullptr || channel == split->getChannel().get())
|
||||
{
|
||||
split->layoutMessages();
|
||||
}
|
||||
}
|
||||
@@ -78,26 +83,32 @@ void Window::repaintVisibleChatWidgets(Channel *channel)
|
||||
|
||||
bool Window::event(QEvent *event)
|
||||
{
|
||||
switch (event->type()) {
|
||||
switch (event->type())
|
||||
{
|
||||
case QEvent::WindowActivate:
|
||||
break;
|
||||
|
||||
case QEvent::WindowDeactivate: {
|
||||
case QEvent::WindowDeactivate:
|
||||
{
|
||||
auto page = this->notebook_->getOrAddSelectedPage();
|
||||
|
||||
if (page != nullptr) {
|
||||
if (page != nullptr)
|
||||
{
|
||||
std::vector<Split *> splits = page->getSplits();
|
||||
|
||||
for (Split *split : splits) {
|
||||
for (Split *split : splits)
|
||||
{
|
||||
split->updateLastReadMessage();
|
||||
}
|
||||
}
|
||||
|
||||
if (SplitContainer *container =
|
||||
dynamic_cast<SplitContainer *>(page)) {
|
||||
dynamic_cast<SplitContainer *>(page))
|
||||
{
|
||||
container->hideResizeHandles();
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:;
|
||||
};
|
||||
@@ -108,7 +119,8 @@ bool Window::event(QEvent *event)
|
||||
void Window::showEvent(QShowEvent *event)
|
||||
{
|
||||
// Startup notification
|
||||
if (getSettings()->startUpNotification.getValue() < 1) {
|
||||
if (getSettings()->startUpNotification.getValue() < 1)
|
||||
{
|
||||
getSettings()->startUpNotification = 1;
|
||||
|
||||
auto box = new QMessageBox(
|
||||
@@ -122,12 +134,14 @@ void Window::showEvent(QShowEvent *event)
|
||||
|
||||
// Show changelog
|
||||
if (getSettings()->currentVersion.getValue() != "" &&
|
||||
getSettings()->currentVersion.getValue() != CHATTERINO_VERSION) {
|
||||
getSettings()->currentVersion.getValue() != CHATTERINO_VERSION)
|
||||
{
|
||||
auto box = new QMessageBox(QMessageBox::Information,
|
||||
"Chatterino 2 Beta", "Show changelog?",
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
box->setAttribute(Qt::WA_DeleteOnClose);
|
||||
if (box->exec() == QMessageBox::Yes) {
|
||||
if (box->exec() == QMessageBox::Yes)
|
||||
{
|
||||
QDesktopServices::openUrl(
|
||||
QUrl("https://fourtf.com/chatterino-changelog/"));
|
||||
}
|
||||
@@ -141,7 +155,8 @@ void Window::showEvent(QShowEvent *event)
|
||||
|
||||
void Window::closeEvent(QCloseEvent *)
|
||||
{
|
||||
if (this->type_ == WindowType::Main) {
|
||||
if (this->type_ == WindowType::Main)
|
||||
{
|
||||
auto app = getApp();
|
||||
app->windows->save();
|
||||
app->windows->closeAll();
|
||||
@@ -149,7 +164,8 @@ void Window::closeEvent(QCloseEvent *)
|
||||
|
||||
this->closed.invoke();
|
||||
|
||||
if (this->type_ == WindowType::Main) {
|
||||
if (this->type_ == WindowType::Main)
|
||||
{
|
||||
QApplication::exit();
|
||||
}
|
||||
}
|
||||
@@ -170,8 +186,10 @@ void Window::addLayout()
|
||||
|
||||
void Window::addCustomTitlebarButtons()
|
||||
{
|
||||
if (!this->hasCustomWindowFrame()) return;
|
||||
if (this->type_ != WindowType::Main) return;
|
||||
if (!this->hasCustomWindowFrame())
|
||||
return;
|
||||
if (this->type_ != WindowType::Main)
|
||||
return;
|
||||
|
||||
// settings
|
||||
this->addTitleBarButton(TitleBarButtonStyle::Settings,
|
||||
@@ -309,15 +327,18 @@ void Window::addShortcuts()
|
||||
|
||||
// Reopen last closed split
|
||||
createWindowShortcut(this, "CTRL+G", [this] {
|
||||
if (ClosedSplits::empty()) {
|
||||
if (ClosedSplits::empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
ClosedSplits::SplitInfo si = ClosedSplits::pop();
|
||||
SplitContainer *splitContainer{nullptr};
|
||||
if (si.tab) {
|
||||
if (si.tab)
|
||||
{
|
||||
splitContainer = dynamic_cast<SplitContainer *>(si.tab->page);
|
||||
}
|
||||
if (!splitContainer) {
|
||||
if (!splitContainer)
|
||||
{
|
||||
splitContainer = this->notebook_->getOrAddSelectedPage();
|
||||
}
|
||||
this->notebook_->select(splitContainer);
|
||||
@@ -345,12 +366,17 @@ void Window::onAccountSelected()
|
||||
|
||||
this->setWindowTitle(windowTitleEnd);
|
||||
|
||||
if (user->isAnon()) {
|
||||
if (this->userLabel_) {
|
||||
if (user->isAnon())
|
||||
{
|
||||
if (this->userLabel_)
|
||||
{
|
||||
this->userLabel_->getLabel().setText("anonymous");
|
||||
}
|
||||
} else {
|
||||
if (this->userLabel_) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->userLabel_)
|
||||
{
|
||||
this->userLabel_->getLabel().setText(user->getUserName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,14 +29,18 @@ namespace {
|
||||
builder->flags.set(MessageFlag::Centered);
|
||||
builder->flags.set(MessageFlag::DisableCompactEmotes);
|
||||
|
||||
if (!map.empty()) {
|
||||
for (const auto &emote : map) {
|
||||
if (!map.empty())
|
||||
{
|
||||
for (const auto &emote : map)
|
||||
{
|
||||
builder
|
||||
.emplace<EmoteElement>(emote.second,
|
||||
MessageElementFlag::AlwaysShow)
|
||||
->setLink(Link(Link::InsertText, emote.first.string));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.emplace<TextElement>("no emotes available",
|
||||
MessageElementFlag::Text,
|
||||
MessageColor::System);
|
||||
@@ -50,7 +54,8 @@ namespace {
|
||||
{
|
||||
QMap<QString, QPair<bool, std::vector<MessagePtr>>> mapOfSets;
|
||||
|
||||
for (const auto &set : sets) {
|
||||
for (const auto &set : sets)
|
||||
{
|
||||
// TITLE
|
||||
auto channelName = set->channelName;
|
||||
auto text =
|
||||
@@ -62,13 +67,15 @@ namespace {
|
||||
builder->flags.set(MessageFlag::DisableCompactEmotes);
|
||||
|
||||
// If value of map is empty, create init pair and add title.
|
||||
if (mapOfSets.find(channelName) == mapOfSets.end()) {
|
||||
if (mapOfSets.find(channelName) == mapOfSets.end())
|
||||
{
|
||||
std::vector<MessagePtr> b;
|
||||
b.push_back(makeTitleMessage(text));
|
||||
mapOfSets[channelName] = qMakePair(set->key == "0", b);
|
||||
}
|
||||
|
||||
for (const auto &emote : set->emotes) {
|
||||
for (const auto &emote : set->emotes)
|
||||
{
|
||||
builder
|
||||
.emplace<EmoteElement>(
|
||||
getApp()->emotes->twitch.getOrCreateEmote(emote.id,
|
||||
@@ -82,9 +89,11 @@ namespace {
|
||||
|
||||
// Output to channel all created messages,
|
||||
// That contain title or emotes.
|
||||
foreach (auto pair, mapOfSets) {
|
||||
foreach (auto pair, mapOfSets)
|
||||
{
|
||||
auto &channel = pair.first ? globalChannel : subChannel;
|
||||
for (auto message : pair.second) {
|
||||
for (auto message : pair.second)
|
||||
{
|
||||
channel.addMessage(message);
|
||||
}
|
||||
}
|
||||
@@ -131,7 +140,8 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
|
||||
this->setWindowTitle("Emotes in #" + _channel->getName());
|
||||
|
||||
auto twitchChannel = dynamic_cast<TwitchChannel *>(_channel.get());
|
||||
if (twitchChannel == nullptr) return;
|
||||
if (twitchChannel == nullptr)
|
||||
return;
|
||||
|
||||
auto addEmotes = [&](Channel &channel, const EmoteMap &map,
|
||||
const QString &title) {
|
||||
@@ -162,7 +172,8 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
|
||||
this->subEmotesView_->setChannel(subChannel);
|
||||
this->channelEmotesView_->setChannel(channelChannel);
|
||||
|
||||
if (subChannel->getMessageSnapshot().getLength() == 0) {
|
||||
if (subChannel->getMessageSnapshot().getLength() == 0)
|
||||
{
|
||||
MessageBuilder builder;
|
||||
builder->flags.set(MessageFlag::Centered);
|
||||
builder->flags.set(MessageFlag::DisableCompactEmotes);
|
||||
|
||||
@@ -28,20 +28,25 @@ namespace {
|
||||
{
|
||||
QStringList errors;
|
||||
|
||||
if (userID.empty()) {
|
||||
if (userID.empty())
|
||||
{
|
||||
errors.append("Missing user ID");
|
||||
}
|
||||
if (username.empty()) {
|
||||
if (username.empty())
|
||||
{
|
||||
errors.append("Missing username");
|
||||
}
|
||||
if (clientID.empty()) {
|
||||
if (clientID.empty())
|
||||
{
|
||||
errors.append("Missing Client ID");
|
||||
}
|
||||
if (oauthToken.empty()) {
|
||||
if (oauthToken.empty())
|
||||
{
|
||||
errors.append("Missing OAuth Token");
|
||||
}
|
||||
|
||||
if (errors.length() > 0) {
|
||||
if (errors.length() > 0)
|
||||
{
|
||||
QMessageBox messageBox;
|
||||
messageBox.setIcon(QMessageBox::Critical);
|
||||
messageBox.setText(errors.join("<br />"));
|
||||
@@ -96,23 +101,34 @@ BasicLoginWidget::BasicLoginWidget()
|
||||
|
||||
std::string oauthToken, clientID, username, userID;
|
||||
|
||||
for (const auto ¶m : parameters) {
|
||||
for (const auto ¶m : parameters)
|
||||
{
|
||||
QStringList kvParameters = param.split('=');
|
||||
if (kvParameters.size() != 2) {
|
||||
if (kvParameters.size() != 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
QString key = kvParameters[0];
|
||||
QString value = kvParameters[1];
|
||||
|
||||
if (key == "oauth_token") {
|
||||
if (key == "oauth_token")
|
||||
{
|
||||
oauthToken = value.toStdString();
|
||||
} else if (key == "client_id") {
|
||||
}
|
||||
else if (key == "client_id")
|
||||
{
|
||||
clientID = value.toStdString();
|
||||
} else if (key == "username") {
|
||||
}
|
||||
else if (key == "username")
|
||||
{
|
||||
username = value.toStdString();
|
||||
} else if (key == "user_id") {
|
||||
}
|
||||
else if (key == "user_id")
|
||||
{
|
||||
userID = value.toStdString();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Unknown key in code: " << key;
|
||||
}
|
||||
}
|
||||
@@ -212,9 +228,12 @@ void AdvancedLoginWidget::refreshButtons()
|
||||
if (this->ui_.userIDInput.text().isEmpty() ||
|
||||
this->ui_.usernameInput.text().isEmpty() ||
|
||||
this->ui_.clientIDInput.text().isEmpty() ||
|
||||
this->ui_.oauthTokenInput.text().isEmpty()) {
|
||||
this->ui_.oauthTokenInput.text().isEmpty())
|
||||
{
|
||||
this->ui_.buttonUpperRow.addUserButton.setEnabled(false);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui_.buttonUpperRow.addUserButton.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "widgets/BaseWidget.hpp"
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QButtonGroup>
|
||||
@@ -16,6 +15,7 @@
|
||||
#include <QPushButton>
|
||||
#include <QTabWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
|
||||
@@ -54,7 +54,8 @@ void LogsPopup::getRoomID()
|
||||
{
|
||||
TwitchChannel *twitchChannel =
|
||||
dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
if (twitchChannel == nullptr) {
|
||||
if (twitchChannel == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -84,7 +85,8 @@ void LogsPopup::getLogviewerLogs()
|
||||
{
|
||||
TwitchChannel *twitchChannel =
|
||||
dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
if (twitchChannel == nullptr) {
|
||||
if (twitchChannel == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -107,7 +109,8 @@ void LogsPopup::getLogviewerLogs()
|
||||
|
||||
QJsonValue before = data.value("before");
|
||||
|
||||
for (auto i : before.toArray()) {
|
||||
for (auto i : before.toArray())
|
||||
{
|
||||
auto messageObject = i.toObject();
|
||||
QString message = messageObject.value("text").toString();
|
||||
|
||||
@@ -137,7 +140,8 @@ void LogsPopup::getOverrustleLogs()
|
||||
{
|
||||
TwitchChannel *twitchChannel =
|
||||
dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
if (twitchChannel == nullptr) {
|
||||
if (twitchChannel == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -164,9 +168,11 @@ void LogsPopup::getOverrustleLogs()
|
||||
req.onSuccess([this, channelName](auto result) -> Outcome {
|
||||
auto data = result.parseJson();
|
||||
std::vector<MessagePtr> messages;
|
||||
if (data.contains("lines")) {
|
||||
if (data.contains("lines"))
|
||||
{
|
||||
QJsonArray dataMessages = data.value("lines").toArray();
|
||||
for (auto i : dataMessages) {
|
||||
for (auto i : dataMessages)
|
||||
{
|
||||
QJsonObject singleMessage = i.toObject();
|
||||
QTime timeStamp = QDateTime::fromSecsSinceEpoch(
|
||||
singleMessage.value("timestamp").toInt())
|
||||
|
||||
@@ -33,11 +33,14 @@ void NotificationPopup::updatePosition()
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
const QRect rect = desktop->availableGeometry();
|
||||
|
||||
switch (location) {
|
||||
case BottomRight: {
|
||||
switch (location)
|
||||
{
|
||||
case BottomRight:
|
||||
{
|
||||
this->move(rect.right() - this->width(),
|
||||
rect.bottom() - this->height());
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,9 +44,12 @@ void QualityPopup::okButtonClicked()
|
||||
{
|
||||
QString channelURL = "twitch.tv/" + this->channelName_;
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
openStreamlink(channelURL, this->ui_.selector.currentText());
|
||||
} catch (const Exception &ex) {
|
||||
}
|
||||
catch (const Exception &ex)
|
||||
{
|
||||
log("Exception caught trying to open streamlink: {}", ex.what());
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,8 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||
|
||||
QObject::connect(channel_btn.getElement(), &QRadioButton::toggled,
|
||||
[=](bool enabled) mutable {
|
||||
if (enabled) {
|
||||
if (enabled)
|
||||
{
|
||||
channel_edit->setFocus();
|
||||
channel_edit->setSelection(
|
||||
0, channel_edit->text().length());
|
||||
@@ -176,25 +177,35 @@ void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel)
|
||||
|
||||
this->selectedChannel_ = channel;
|
||||
|
||||
switch (_channel.getType()) {
|
||||
case Channel::Type::Twitch: {
|
||||
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: {
|
||||
}
|
||||
break;
|
||||
case Channel::Type::TwitchWatching:
|
||||
{
|
||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
||||
this->ui_.twitch.watching->setFocus();
|
||||
} break;
|
||||
case Channel::Type::TwitchMentions: {
|
||||
}
|
||||
break;
|
||||
case Channel::Type::TwitchMentions:
|
||||
{
|
||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
||||
this->ui_.twitch.mentions->setFocus();
|
||||
} break;
|
||||
case Channel::Type::TwitchWhispers: {
|
||||
}
|
||||
break;
|
||||
case Channel::Type::TwitchWhispers:
|
||||
{
|
||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
||||
this->ui_.twitch.whispers->setFocus();
|
||||
} break;
|
||||
default: {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
||||
this->ui_.twitch.channel->setFocus();
|
||||
}
|
||||
@@ -205,22 +216,32 @@ void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel)
|
||||
|
||||
IndirectChannel SelectChannelDialog::getSelectedChannel() const
|
||||
{
|
||||
if (!this->hasSelectedChannel_) {
|
||||
if (!this->hasSelectedChannel_)
|
||||
{
|
||||
return this->selectedChannel_;
|
||||
}
|
||||
|
||||
auto app = getApp();
|
||||
|
||||
switch (this->ui_.notebook->getSelectedIndex()) {
|
||||
case TAB_TWITCH: {
|
||||
if (this->ui_.twitch.channel->isChecked()) {
|
||||
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()) {
|
||||
}
|
||||
else if (this->ui_.twitch.watching->isChecked())
|
||||
{
|
||||
return app->twitch.server->watchingChannel;
|
||||
} else if (this->ui_.twitch.mentions->isChecked()) {
|
||||
}
|
||||
else if (this->ui_.twitch.mentions->isChecked())
|
||||
{
|
||||
return app->twitch.server->mentionsChannel;
|
||||
} else if (this->ui_.twitch.whispers->isChecked()) {
|
||||
}
|
||||
else if (this->ui_.twitch.whispers->isChecked())
|
||||
{
|
||||
return app->twitch.server->whispersChannel;
|
||||
}
|
||||
}
|
||||
@@ -239,54 +260,74 @@ bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched,
|
||||
{
|
||||
auto *widget = (QWidget *)watched;
|
||||
|
||||
if (event->type() == QEvent::FocusIn) {
|
||||
if (event->type() == QEvent::FocusIn)
|
||||
{
|
||||
widget->grabKeyboard();
|
||||
|
||||
auto *radio = dynamic_cast<QRadioButton *>(watched);
|
||||
if (radio) {
|
||||
if (radio)
|
||||
{
|
||||
radio->setChecked(true);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (event->type() == QEvent::FocusOut) {
|
||||
}
|
||||
else if (event->type() == QEvent::FocusOut)
|
||||
{
|
||||
widget->releaseKeyboard();
|
||||
return false;
|
||||
} else if (event->type() == QEvent::KeyPress) {
|
||||
}
|
||||
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) {
|
||||
event_key->modifiers() == Qt::NoModifier)
|
||||
{
|
||||
if (widget == this->dialog->ui_.twitch.channelName)
|
||||
{
|
||||
this->dialog->ui_.twitch.whispers->setFocus();
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
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) {
|
||||
}
|
||||
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) {
|
||||
}
|
||||
else if (widget == this->dialog->ui_.twitch.whispers)
|
||||
{
|
||||
this->dialog->ui_.twitch.channel->setFocus();
|
||||
return true;
|
||||
}
|
||||
|
||||
widget->previousInFocusChain()->setFocus();
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else if (event->type() == QEvent::KeyRelease) {
|
||||
}
|
||||
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) {
|
||||
event_key->modifiers() == Qt::NoModifier)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -303,10 +344,13 @@ void SelectChannelDialog::themeChangedEvent()
|
||||
{
|
||||
BaseWindow::themeChangedEvent();
|
||||
|
||||
if (this->theme->isLightTheme()) {
|
||||
if (this->theme->isLightTheme())
|
||||
{
|
||||
this->setStyleSheet(
|
||||
"QRadioButton { color: #000 } QLabel { color: #000 }");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setStyleSheet(
|
||||
"QRadioButton { color: #fff } QLabel { color: #fff }");
|
||||
}
|
||||
|
||||
@@ -121,7 +121,8 @@ void SettingsDialog::addTab(SettingsPage *page, Qt::Alignment alignment)
|
||||
this->ui_.tabContainer->addWidget(tab, 0, alignment);
|
||||
this->tabs_.push_back(tab);
|
||||
|
||||
if (this->tabs_.size() == 1) {
|
||||
if (this->tabs_.size() == 1)
|
||||
{
|
||||
this->selectTab(tab);
|
||||
}
|
||||
}
|
||||
@@ -130,7 +131,8 @@ void SettingsDialog::selectTab(SettingsDialogTab *tab)
|
||||
{
|
||||
this->ui_.pageStack->setCurrentWidget(tab->getSettingsPage());
|
||||
|
||||
if (this->selectedTab_ != nullptr) {
|
||||
if (this->selectedTab_ != nullptr)
|
||||
{
|
||||
this->selectedTab_->setSelected(false);
|
||||
this->selectedTab_->setStyleSheet("color: #FFF");
|
||||
}
|
||||
@@ -145,10 +147,13 @@ void SettingsDialog::showDialog(PreferredTab preferredTab)
|
||||
static SettingsDialog *instance = new SettingsDialog();
|
||||
instance->refresh();
|
||||
|
||||
switch (preferredTab) {
|
||||
case SettingsDialog::PreferredTab::Accounts: {
|
||||
switch (preferredTab)
|
||||
{
|
||||
case SettingsDialog::PreferredTab::Accounts:
|
||||
{
|
||||
instance->selectTab(instance->tabs_.at(0));
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
instance->show();
|
||||
@@ -161,7 +166,8 @@ void SettingsDialog::refresh()
|
||||
{
|
||||
getSettings()->saveSnapshot();
|
||||
|
||||
for (auto *tab : this->tabs_) {
|
||||
for (auto *tab : this->tabs_)
|
||||
{
|
||||
tab->getSettingsPage()->onShow();
|
||||
}
|
||||
}
|
||||
@@ -174,7 +180,8 @@ void SettingsDialog::scaleChangedEvent(float newDpi)
|
||||
styleSheet.replace("<font-size>", QString::number(int(14 * newDpi)));
|
||||
styleSheet.replace("<checkbox-size>", QString::number(int(14 * newDpi)));
|
||||
|
||||
for (SettingsDialogTab *tab : this->tabs_) {
|
||||
for (SettingsDialogTab *tab : this->tabs_)
|
||||
{
|
||||
tab->setFixedHeight(int(30 * newDpi));
|
||||
}
|
||||
|
||||
@@ -200,7 +207,8 @@ void SettingsDialog::onOkClicked()
|
||||
|
||||
void SettingsDialog::onCancelClicked()
|
||||
{
|
||||
for (auto &tab : this->tabs_) {
|
||||
for (auto &tab : this->tabs_)
|
||||
{
|
||||
tab->getSettingsPage()->cancel();
|
||||
}
|
||||
|
||||
|
||||
@@ -43,31 +43,42 @@ void UpdateDialog::updateStatusChanged(Updates::Status status)
|
||||
{
|
||||
this->ui_.installButton->setVisible(status == Updates::UpdateAvailable);
|
||||
|
||||
switch (status) {
|
||||
case 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()));
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Updates::SearchFailed: {
|
||||
case Updates::SearchFailed:
|
||||
{
|
||||
this->ui_.label->setText("Failed to load version information.");
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Updates::Downloading: {
|
||||
case Updates::Downloading:
|
||||
{
|
||||
this->ui_.label->setText(
|
||||
"Downloading updates.\n\nChatterino will restart "
|
||||
"automatically when the download is done.");
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Updates::DownloadFailed: {
|
||||
case Updates::DownloadFailed:
|
||||
{
|
||||
this->ui_.label->setText("Failed to download the update.");
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Updates::WriteFileFailed: {
|
||||
case Updates::WriteFileFailed:
|
||||
{
|
||||
this->ui_.label->setText("Failed to save the update to disk.");
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,8 @@ UserInfoPopup::UserInfoPopup()
|
||||
TwitchChannel *twitchChannel =
|
||||
dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
|
||||
if (twitchChannel) {
|
||||
if (twitchChannel)
|
||||
{
|
||||
qDebug() << this->userName_;
|
||||
|
||||
bool isMyself =
|
||||
@@ -140,7 +141,8 @@ UserInfoPopup::UserInfoPopup()
|
||||
TwitchChannel *twitchChannel =
|
||||
dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
|
||||
if (twitchChannel) {
|
||||
if (twitchChannel)
|
||||
{
|
||||
lineMod->setVisible(twitchChannel->hasModRights());
|
||||
timeout->setVisible(twitchChannel->hasModRights());
|
||||
}
|
||||
@@ -151,25 +153,35 @@ UserInfoPopup::UserInfoPopup()
|
||||
int arg;
|
||||
std::tie(action, arg) = item;
|
||||
|
||||
switch (action) {
|
||||
case TimeoutWidget::Ban: {
|
||||
if (this->channel_) {
|
||||
switch (action)
|
||||
{
|
||||
case TimeoutWidget::Ban:
|
||||
{
|
||||
if (this->channel_)
|
||||
{
|
||||
this->channel_->sendMessage("/ban " + this->userName_);
|
||||
}
|
||||
} break;
|
||||
case TimeoutWidget::Unban: {
|
||||
if (this->channel_) {
|
||||
}
|
||||
break;
|
||||
case TimeoutWidget::Unban:
|
||||
{
|
||||
if (this->channel_)
|
||||
{
|
||||
this->channel_->sendMessage("/unban " +
|
||||
this->userName_);
|
||||
}
|
||||
} break;
|
||||
case TimeoutWidget::Timeout: {
|
||||
if (this->channel_) {
|
||||
}
|
||||
break;
|
||||
case TimeoutWidget::Timeout:
|
||||
{
|
||||
if (this->channel_)
|
||||
{
|
||||
this->channel_->sendMessage("/timeout " +
|
||||
this->userName_ + " " +
|
||||
QString::number(arg));
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -204,9 +216,12 @@ void UserInfoPopup::installEvents()
|
||||
};
|
||||
|
||||
this->ui_.follow->setEnabled(false);
|
||||
if (this->ui_.follow->isChecked()) {
|
||||
if (this->ui_.follow->isChecked())
|
||||
{
|
||||
currentUser->followUser(this->userId_, reenableFollowCheckbox);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
currentUser->unfollowUser(this->userId_,
|
||||
reenableFollowCheckbox);
|
||||
}
|
||||
@@ -218,7 +233,8 @@ void UserInfoPopup::installEvents()
|
||||
QObject::connect(
|
||||
this->ui_.ignore, &QCheckBox::stateChanged,
|
||||
[this, ignoreNext, hack](int) mutable {
|
||||
if (*ignoreNext) {
|
||||
if (*ignoreNext)
|
||||
{
|
||||
*ignoreNext = false;
|
||||
return;
|
||||
}
|
||||
@@ -226,24 +242,31 @@ void UserInfoPopup::installEvents()
|
||||
this->ui_.ignore->setEnabled(false);
|
||||
|
||||
auto currentUser = getApp()->accounts->twitch.getCurrent();
|
||||
if (this->ui_.ignore->isChecked()) {
|
||||
if (this->ui_.ignore->isChecked())
|
||||
{
|
||||
currentUser->ignoreByID(
|
||||
this->userId_, this->userName_,
|
||||
[=](auto result, const auto &message) mutable {
|
||||
if (hack.lock()) {
|
||||
if (result == IgnoreResult_Failed) {
|
||||
if (hack.lock())
|
||||
{
|
||||
if (result == IgnoreResult_Failed)
|
||||
{
|
||||
*ignoreNext = true;
|
||||
this->ui_.ignore->setChecked(false);
|
||||
}
|
||||
this->ui_.ignore->setEnabled(true);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
currentUser->unignoreByID(
|
||||
this->userId_, this->userName_,
|
||||
[=](auto result, const auto &message) mutable {
|
||||
if (hack.lock()) {
|
||||
if (result == UnignoreResult_Failed) {
|
||||
if (hack.lock())
|
||||
{
|
||||
if (result == UnignoreResult_Failed)
|
||||
{
|
||||
*ignoreNext = true;
|
||||
this->ui_.ignore->setChecked(true);
|
||||
}
|
||||
@@ -259,24 +282,32 @@ void UserInfoPopup::installEvents()
|
||||
[this](bool checked) mutable {
|
||||
this->ui_.ignoreHighlights->setEnabled(false);
|
||||
|
||||
if (checked) {
|
||||
if (checked)
|
||||
{
|
||||
getApp()->highlights->blacklistedUsers.insertItem(
|
||||
HighlightBlacklistUser{this->userName_, false});
|
||||
this->ui_.ignoreHighlights->setEnabled(true);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto &vector =
|
||||
getApp()->highlights->blacklistedUsers.getVector();
|
||||
|
||||
for (int i = 0; i < vector.size(); i++) {
|
||||
if (this->userName_ == vector[i].getPattern()) {
|
||||
for (int i = 0; i < vector.size(); i++)
|
||||
{
|
||||
if (this->userName_ == vector[i].getPattern())
|
||||
{
|
||||
getApp()->highlights->blacklistedUsers.removeItem(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
if (getApp()->highlights->blacklistContains(this->userName_)) {
|
||||
if (getApp()->highlights->blacklistContains(this->userName_))
|
||||
{
|
||||
this->ui_.ignoreHighlights->setToolTip(
|
||||
"Name matched by regex");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui_.ignoreHighlights->setEnabled(true);
|
||||
}
|
||||
}
|
||||
@@ -329,8 +360,10 @@ void UserInfoPopup::updateUserData()
|
||||
|
||||
// get follow state
|
||||
currentUser->checkFollow(id, [this, hack](auto result) {
|
||||
if (hack.lock()) {
|
||||
if (result != FollowResult_Failed) {
|
||||
if (hack.lock())
|
||||
{
|
||||
if (result != FollowResult_Failed)
|
||||
{
|
||||
this->ui_.follow->setEnabled(true);
|
||||
this->ui_.follow->setChecked(result ==
|
||||
FollowResult_Following);
|
||||
@@ -340,8 +373,10 @@ void UserInfoPopup::updateUserData()
|
||||
|
||||
// get ignore state
|
||||
bool isIgnoring = false;
|
||||
for (const auto &ignoredUser : currentUser->getIgnores()) {
|
||||
if (id == ignoredUser.id) {
|
||||
for (const auto &ignoredUser : currentUser->getIgnores())
|
||||
{
|
||||
if (id == ignoredUser.id)
|
||||
{
|
||||
isIgnoring = true;
|
||||
break;
|
||||
}
|
||||
@@ -350,16 +385,21 @@ void UserInfoPopup::updateUserData()
|
||||
// get ignoreHighlights state
|
||||
bool isIgnoringHighlights = false;
|
||||
const auto &vector = getApp()->highlights->blacklistedUsers.getVector();
|
||||
for (int i = 0; i < vector.size(); i++) {
|
||||
if (this->userName_ == vector[i].getPattern()) {
|
||||
for (int i = 0; i < vector.size(); i++)
|
||||
{
|
||||
if (this->userName_ == vector[i].getPattern())
|
||||
{
|
||||
isIgnoringHighlights = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (getApp()->highlights->blacklistContains(this->userName_) &&
|
||||
!isIgnoringHighlights) {
|
||||
!isIgnoringHighlights)
|
||||
{
|
||||
this->ui_.ignoreHighlights->setToolTip("Name matched by regex");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui_.ignoreHighlights->setEnabled(true);
|
||||
}
|
||||
this->ui_.ignore->setEnabled(true);
|
||||
@@ -381,14 +421,17 @@ void UserInfoPopup::loadAvatar(const QUrl &url)
|
||||
auto *reply = manager->get(req);
|
||||
|
||||
QObject::connect(reply, &QNetworkReply::finished, this, [=] {
|
||||
if (reply->error() == QNetworkReply::NoError) {
|
||||
if (reply->error() == QNetworkReply::NoError)
|
||||
{
|
||||
const auto data = reply->readAll();
|
||||
|
||||
// might want to cache the avatar image
|
||||
QPixmap avatar;
|
||||
avatar.loadFromData(data);
|
||||
this->ui_.avatarButton->setPixmap(avatar);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui_.avatarButton->setPixmap(QPixmap());
|
||||
}
|
||||
});
|
||||
@@ -454,13 +497,17 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget()
|
||||
auto hbox = vbox.emplace<QHBoxLayout>().withoutMargin();
|
||||
hbox->setSpacing(0);
|
||||
|
||||
for (const auto &item : items) {
|
||||
for (const auto &item : items)
|
||||
{
|
||||
auto a = hbox.emplace<EffectLabel2>();
|
||||
a->getLabel().setText(std::get<0>(item));
|
||||
|
||||
if (std::get<0>(item).length() > 1) {
|
||||
if (std::get<0>(item).length() > 1)
|
||||
{
|
||||
a->setScaleIndependantSize(buttonWidth2, buttonHeight);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
a->setScaleIndependantSize(buttonWidth, buttonHeight);
|
||||
}
|
||||
a->setBorderColor(color1);
|
||||
|
||||
@@ -97,7 +97,8 @@ void Button::setMenu(std::unique_ptr<QMenu> menu)
|
||||
|
||||
this->menu_->installEventFilter(
|
||||
new FunctionEventFilter(this, [this](QObject *, QEvent *event) {
|
||||
if (event->type() == QEvent::Hide) {
|
||||
if (event->type() == QEvent::Hide)
|
||||
{
|
||||
QTimer::singleShot(20, this,
|
||||
[this] { this->menuVisible_ = false; });
|
||||
}
|
||||
@@ -111,8 +112,10 @@ void Button::paintEvent(QPaintEvent *)
|
||||
|
||||
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
|
||||
if (!this->pixmap_.isNull()) {
|
||||
if (!this->mouseOver_ && this->dimPixmap_ && this->enabled_) {
|
||||
if (!this->pixmap_.isNull())
|
||||
{
|
||||
if (!this->mouseOver_ && this->dimPixmap_ && this->enabled_)
|
||||
{
|
||||
painter.setOpacity(this->getCurrentDimAmount());
|
||||
}
|
||||
|
||||
@@ -131,7 +134,8 @@ void Button::paintEvent(QPaintEvent *)
|
||||
|
||||
this->fancyPaint(painter);
|
||||
|
||||
if (this->borderColor_.isValid()) {
|
||||
if (this->borderColor_.isValid())
|
||||
{
|
||||
painter.setRenderHint(QPainter::Antialiasing, false);
|
||||
painter.setPen(this->borderColor_);
|
||||
painter.drawRect(0, 0, this->width() - 1, this->height() - 1);
|
||||
@@ -140,7 +144,8 @@ void Button::paintEvent(QPaintEvent *)
|
||||
|
||||
void Button::fancyPaint(QPainter &painter)
|
||||
{
|
||||
if (!this->enabled_) {
|
||||
if (!this->enabled_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -148,14 +153,18 @@ void Button::fancyPaint(QPainter &painter)
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
QColor c;
|
||||
|
||||
if (this->mouseEffectColor_) {
|
||||
if (this->mouseEffectColor_)
|
||||
{
|
||||
c = this->mouseEffectColor_.get();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
c = this->theme->isLightTheme() ? QColor(0, 0, 0)
|
||||
: QColor(255, 255, 255);
|
||||
}
|
||||
|
||||
if (this->hoverMultiplier_ > 0) {
|
||||
if (this->hoverMultiplier_ > 0)
|
||||
{
|
||||
QRadialGradient gradient(QPointF(mousePos_), this->width() / 2);
|
||||
|
||||
gradient.setColorAt(0, QColor(c.red(), c.green(), c.blue(),
|
||||
@@ -166,7 +175,8 @@ void Button::fancyPaint(QPainter &painter)
|
||||
painter.fillRect(this->rect(), gradient);
|
||||
}
|
||||
|
||||
for (auto effect : this->clickEffects_) {
|
||||
for (auto effect : this->clickEffects_)
|
||||
{
|
||||
QRadialGradient gradient(effect.position.x(), effect.position.y(),
|
||||
effect.progress * qreal(width()) * 2,
|
||||
effect.position.x(), effect.position.y());
|
||||
@@ -193,11 +203,13 @@ void Button::leaveEvent(QEvent *)
|
||||
|
||||
void Button::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!this->enabled_) {
|
||||
if (!this->enabled_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->button() != Qt::LeftButton) {
|
||||
if (event->button() != Qt::LeftButton)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -207,7 +219,8 @@ void Button::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
emit this->leftMousePress();
|
||||
|
||||
if (this->menu_ && !this->menuVisible_) {
|
||||
if (this->menu_ && !this->menuVisible_)
|
||||
{
|
||||
QTimer::singleShot(80, this, [this] { this->showMenu(); });
|
||||
this->mouseDown_ = false;
|
||||
this->mouseOver_ = false;
|
||||
@@ -216,24 +229,28 @@ void Button::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
void Button::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!this->enabled_) {
|
||||
if (!this->enabled_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->button() != Qt::LeftButton) {
|
||||
if (event->button() != Qt::LeftButton)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this->mouseDown_ = false;
|
||||
|
||||
if (this->rect().contains(event->pos())) {
|
||||
if (this->rect().contains(event->pos()))
|
||||
{
|
||||
emit clicked();
|
||||
}
|
||||
}
|
||||
|
||||
void Button::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!this->enabled_) {
|
||||
if (!this->enabled_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -246,49 +263,64 @@ void Button::onMouseEffectTimeout()
|
||||
{
|
||||
bool performUpdate = false;
|
||||
|
||||
if (selected_) {
|
||||
if (this->hoverMultiplier_ != 0) {
|
||||
if (selected_)
|
||||
{
|
||||
if (this->hoverMultiplier_ != 0)
|
||||
{
|
||||
this->hoverMultiplier_ =
|
||||
std::max(0.0, this->hoverMultiplier_ - 0.1);
|
||||
performUpdate = true;
|
||||
}
|
||||
} else if (mouseOver_) {
|
||||
if (this->hoverMultiplier_ != 1) {
|
||||
}
|
||||
else if (mouseOver_)
|
||||
{
|
||||
if (this->hoverMultiplier_ != 1)
|
||||
{
|
||||
this->hoverMultiplier_ =
|
||||
std::min(1.0, this->hoverMultiplier_ + 0.5);
|
||||
performUpdate = true;
|
||||
}
|
||||
} else {
|
||||
if (this->hoverMultiplier_ != 0) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->hoverMultiplier_ != 0)
|
||||
{
|
||||
this->hoverMultiplier_ =
|
||||
std::max(0.0, this->hoverMultiplier_ - 0.3);
|
||||
performUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->clickEffects_.size() != 0) {
|
||||
if (this->clickEffects_.size() != 0)
|
||||
{
|
||||
performUpdate = true;
|
||||
|
||||
for (auto it = this->clickEffects_.begin();
|
||||
it != this->clickEffects_.end();) {
|
||||
it != this->clickEffects_.end();)
|
||||
{
|
||||
it->progress += mouseDown_ ? 0.02 : 0.07;
|
||||
|
||||
if (it->progress >= 1.0) {
|
||||
if (it->progress >= 1.0)
|
||||
{
|
||||
it = this->clickEffects_.erase(it);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (performUpdate) {
|
||||
if (performUpdate)
|
||||
{
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void Button::showMenu()
|
||||
{
|
||||
if (!this->menu_) return;
|
||||
if (!this->menu_)
|
||||
return;
|
||||
|
||||
auto point = [this] {
|
||||
auto bounds = QApplication::desktop()->availableGeometry(this);
|
||||
@@ -296,7 +328,8 @@ void Button::showMenu()
|
||||
auto point = this->mapToGlobal(
|
||||
QPoint(this->width() - this->menu_->width(), this->height()));
|
||||
|
||||
if (point.y() + this->menu_->height() > bounds.bottom()) {
|
||||
if (point.y() + this->menu_->height() > bounds.bottom())
|
||||
{
|
||||
point.setY(point.y() - this->menu_->height() - this->height());
|
||||
}
|
||||
|
||||
|
||||
+379
-178
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,8 @@ QWidget *ComboBoxItemDelegate::createEditor(QWidget *parent,
|
||||
{
|
||||
QVariant data = index.data(Qt::UserRole + 1);
|
||||
|
||||
if (data.type() != QVariant::StringList) {
|
||||
if (data.type() != QVariant::StringList)
|
||||
{
|
||||
return QStyledItemDelegate::createEditor(parent, option, index);
|
||||
}
|
||||
|
||||
@@ -31,17 +32,21 @@ QWidget *ComboBoxItemDelegate::createEditor(QWidget *parent,
|
||||
void ComboBoxItemDelegate::setEditorData(QWidget *editor,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
if (QComboBox *cb = qobject_cast<QComboBox *>(editor)) {
|
||||
if (QComboBox *cb = qobject_cast<QComboBox *>(editor))
|
||||
{
|
||||
// get the index of the text in the combobox that matches the current
|
||||
// value of the itenm
|
||||
QString currentText = index.data(Qt::EditRole).toString();
|
||||
int cbIndex = cb->findText(currentText);
|
||||
|
||||
// if it is valid, adjust the combobox
|
||||
if (cbIndex >= 0) {
|
||||
if (cbIndex >= 0)
|
||||
{
|
||||
cb->setCurrentIndex(cbIndex);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
QStyledItemDelegate::setEditorData(editor, index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,8 @@ EditableModelView::EditableModelView(QAbstractTableModel *model)
|
||||
QObject::connect(remove, &QPushButton::clicked, [this] {
|
||||
QModelIndexList list;
|
||||
while ((list = this->getTableView()->selectionModel()->selectedRows(0))
|
||||
.length() > 0) {
|
||||
.length() > 0)
|
||||
{
|
||||
model_->removeRow(list[0].row());
|
||||
}
|
||||
});
|
||||
@@ -52,8 +53,10 @@ EditableModelView::EditableModelView(QAbstractTableModel *model)
|
||||
void EditableModelView::setTitles(std::initializer_list<QString> titles)
|
||||
{
|
||||
int i = 0;
|
||||
for (const QString &title : titles) {
|
||||
if (this->model_->columnCount() == i) {
|
||||
for (const QString &title : titles)
|
||||
{
|
||||
if (this->model_->columnCount() == i)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,12 @@ public:
|
||||
: BaseWidget(nullptr)
|
||||
, vertical_(vertical)
|
||||
{
|
||||
if (this->vertical_) {
|
||||
if (this->vertical_)
|
||||
{
|
||||
this->setScaleIndependantWidth(8);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setScaleIndependantHeight(8);
|
||||
}
|
||||
}
|
||||
@@ -26,10 +29,13 @@ public:
|
||||
|
||||
painter.setPen(QColor("#999"));
|
||||
|
||||
if (this->vertical_) {
|
||||
if (this->vertical_)
|
||||
{
|
||||
painter.drawLine(this->width() / 2, 0, this->width() / 2,
|
||||
this->height());
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
painter.drawLine(0, this->height() / 2, this->width(),
|
||||
this->height() / 2);
|
||||
}
|
||||
|
||||
@@ -45,10 +45,13 @@ void NotebookButton::paintEvent(QPaintEvent *event)
|
||||
QColor background;
|
||||
QColor foreground;
|
||||
|
||||
if (mouseDown_ || mouseOver_) {
|
||||
if (mouseDown_ || mouseOver_)
|
||||
{
|
||||
background = this->theme->tabs.regular.backgrounds.hover.color();
|
||||
foreground = this->theme->tabs.regular.text;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
background = this->theme->tabs.regular.backgrounds.regular.color();
|
||||
foreground = this->theme->tabs.regular.text;
|
||||
}
|
||||
@@ -57,13 +60,18 @@ void NotebookButton::paintEvent(QPaintEvent *event)
|
||||
|
||||
float h = height(), w = width();
|
||||
|
||||
switch (icon_) {
|
||||
case Plus: {
|
||||
switch (icon_)
|
||||
{
|
||||
case Plus:
|
||||
{
|
||||
painter.setPen([&] {
|
||||
QColor tmp = foreground;
|
||||
if (SplitContainer::isDraggingSplit) {
|
||||
if (SplitContainer::isDraggingSplit)
|
||||
{
|
||||
tmp = this->theme->tabs.selected.line.regular;
|
||||
} else if (!this->mouseOver_) {
|
||||
}
|
||||
else if (!this->mouseOver_)
|
||||
{
|
||||
tmp.setAlpha(180);
|
||||
}
|
||||
return tmp;
|
||||
@@ -79,9 +87,11 @@ void NotebookButton::paintEvent(QPaintEvent *event)
|
||||
rect.top() + rect.height() / 2 - (s / 2),
|
||||
rect.left() + rect.width() / 2,
|
||||
rect.top() + rect.height() / 2 + (s / 2));
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case User: {
|
||||
case User:
|
||||
{
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setRenderHint(QPainter::HighQualityAntialiasing);
|
||||
|
||||
@@ -98,9 +108,11 @@ void NotebookButton::paintEvent(QPaintEvent *event)
|
||||
|
||||
painter.setBrush(foreground);
|
||||
painter.drawEllipse(2.5 * a, 1.5 * a, 3 * a + 1, 3 * a);
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Settings: {
|
||||
case Settings:
|
||||
{
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setRenderHint(QPainter::HighQualityAntialiasing);
|
||||
|
||||
@@ -109,7 +121,8 @@ void NotebookButton::paintEvent(QPaintEvent *event)
|
||||
|
||||
path.arcMoveTo(a, a, 6 * a, 6 * a, 0 - (360 / 32.0));
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
path.arcTo(a, a, 6 * a, 6 * a, i * (360 / 8.0) - (360 / 32.0),
|
||||
(360 / 32.0));
|
||||
path.arcTo(2 * a, 2 * a, 4 * a, 4 * a,
|
||||
@@ -120,7 +133,8 @@ void NotebookButton::paintEvent(QPaintEvent *event)
|
||||
|
||||
painter.setBrush(background);
|
||||
painter.drawEllipse(3 * a, 3 * a, 2 * a, 2 * a);
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:;
|
||||
}
|
||||
@@ -130,7 +144,8 @@ void NotebookButton::paintEvent(QPaintEvent *event)
|
||||
|
||||
void NotebookButton::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
mouseDown_ = false;
|
||||
|
||||
update();
|
||||
@@ -143,7 +158,8 @@ void NotebookButton::mouseReleaseEvent(QMouseEvent *event)
|
||||
|
||||
void NotebookButton::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
if (!event->mimeData()->hasFormat("chatterino/split")) {
|
||||
if (!event->mimeData()->hasFormat("chatterino/split"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -170,12 +186,14 @@ void NotebookButton::dragLeaveEvent(QDragLeaveEvent *)
|
||||
|
||||
void NotebookButton::dropEvent(QDropEvent *event)
|
||||
{
|
||||
if (SplitContainer::isDraggingSplit) {
|
||||
if (SplitContainer::isDraggingSplit)
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
|
||||
Notebook *notebook = dynamic_cast<Notebook *>(this->parentWidget());
|
||||
|
||||
if (notebook != nuuls) {
|
||||
if (notebook != nuuls)
|
||||
{
|
||||
SplitContainer *page = new SplitContainer(notebook);
|
||||
auto *tab = notebook->addPage(page);
|
||||
page->setTab(tab);
|
||||
|
||||
@@ -50,7 +50,8 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
||||
d.setText(this->getCustomTitle());
|
||||
d.highlightText();
|
||||
|
||||
if (d.exec() == QDialog::Accepted) {
|
||||
if (d.exec() == QDialog::Accepted)
|
||||
{
|
||||
QString newTitle = d.getText();
|
||||
this->setCustomTitle(newTitle);
|
||||
}
|
||||
@@ -86,16 +87,20 @@ void NotebookTab::updateSize()
|
||||
FontStyle::UiTabs,
|
||||
float(qreal(this->getScale()) * this->devicePixelRatioF()));
|
||||
|
||||
if (this->hasXButton()) {
|
||||
if (this->hasXButton())
|
||||
{
|
||||
width = (metrics.width(this->getTitle()) + int(32 * scale));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
width = (metrics.width(this->getTitle()) + int(16 * scale));
|
||||
}
|
||||
|
||||
width = clamp(width, this->height(), int(150 * scale));
|
||||
auto height = int(NOTEBOOK_TAB_HEIGHT * scale);
|
||||
|
||||
if (this->width() != width || this->height() != height) {
|
||||
if (this->width() != width || this->height() != height)
|
||||
{
|
||||
this->resize(width, height);
|
||||
this->notebook_->performLayout();
|
||||
}
|
||||
@@ -108,7 +113,8 @@ const QString &NotebookTab::getCustomTitle() const
|
||||
|
||||
void NotebookTab::setCustomTitle(const QString &newTitle)
|
||||
{
|
||||
if (this->customTitle_ != newTitle) {
|
||||
if (this->customTitle_ != newTitle)
|
||||
{
|
||||
this->customTitle_ = newTitle;
|
||||
this->titleUpdated();
|
||||
}
|
||||
@@ -126,10 +132,12 @@ bool NotebookTab::hasCustomTitle() const
|
||||
|
||||
void NotebookTab::setDefaultTitle(const QString &title)
|
||||
{
|
||||
if (this->defaultTitle_ != title) {
|
||||
if (this->defaultTitle_ != title)
|
||||
{
|
||||
this->defaultTitle_ = title;
|
||||
|
||||
if (this->customTitle_.isEmpty()) {
|
||||
if (this->customTitle_.isEmpty())
|
||||
{
|
||||
this->titleUpdated();
|
||||
}
|
||||
}
|
||||
@@ -171,7 +179,8 @@ void NotebookTab::setSelected(bool value)
|
||||
|
||||
void NotebookTab::setInLastRow(bool value)
|
||||
{
|
||||
if (this->isInLastRow_ != value) {
|
||||
if (this->isInLastRow_ != value)
|
||||
{
|
||||
this->isInLastRow_ = value;
|
||||
this->update();
|
||||
}
|
||||
@@ -179,7 +188,8 @@ void NotebookTab::setInLastRow(bool value)
|
||||
|
||||
void NotebookTab::setLive(bool isLive)
|
||||
{
|
||||
if (this->isLive_ != isLive) {
|
||||
if (this->isLive_ != isLive)
|
||||
{
|
||||
this->isLive_ = isLive;
|
||||
this->update();
|
||||
}
|
||||
@@ -187,10 +197,12 @@ void NotebookTab::setLive(bool isLive)
|
||||
|
||||
void NotebookTab::setHighlightState(HighlightState newHighlightStyle)
|
||||
{
|
||||
if (this->isSelected() || !this->highlightEnabled_) {
|
||||
if (this->isSelected() || !this->highlightEnabled_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this->highlightState_ != HighlightState::Highlighted) {
|
||||
if (this->highlightState_ != HighlightState::Highlighted)
|
||||
{
|
||||
this->highlightState_ = newHighlightStyle;
|
||||
|
||||
this->update();
|
||||
@@ -226,14 +238,16 @@ void NotebookTab::moveAnimated(QPoint pos, bool animated)
|
||||
QWidget *w = this->window();
|
||||
|
||||
if ((w != nullptr && !w->isVisible()) || !animated ||
|
||||
!this->positionChangedAnimationRunning_) {
|
||||
!this->positionChangedAnimationRunning_)
|
||||
{
|
||||
this->move(pos);
|
||||
|
||||
this->positionChangedAnimationRunning_ = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->positionChangedAnimation_.endValue() == pos) {
|
||||
if (this->positionChangedAnimation_.endValue() == pos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -263,13 +277,20 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||
Theme::TabColors colors;
|
||||
Theme::TabColors regular = this->theme->tabs.regular;
|
||||
|
||||
if (this->selected_) {
|
||||
if (this->selected_)
|
||||
{
|
||||
colors = this->theme->tabs.selected;
|
||||
} else if (this->highlightState_ == HighlightState::Highlighted) {
|
||||
}
|
||||
else if (this->highlightState_ == HighlightState::Highlighted)
|
||||
{
|
||||
colors = this->theme->tabs.highlighted;
|
||||
} else if (this->highlightState_ == HighlightState::NewMessage) {
|
||||
}
|
||||
else if (this->highlightState_ == HighlightState::NewMessage)
|
||||
{
|
||||
colors = this->theme->tabs.newMessage;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
colors = this->theme->tabs.regular;
|
||||
}
|
||||
|
||||
@@ -295,7 +316,8 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||
: (windowFocused ? colors.line.regular : colors.line.unfocused));
|
||||
|
||||
// draw live indicator
|
||||
if (this->isLive_) {
|
||||
if (this->isLive_)
|
||||
{
|
||||
painter.setPen(QColor(Qt::GlobalColor::red));
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
QBrush b;
|
||||
@@ -321,7 +343,8 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||
QRect textRect(offset, this->selected_ ? 1 : 2,
|
||||
this->width() - offset - offset, height);
|
||||
|
||||
if (this->shouldDrawXButton()) {
|
||||
if (this->shouldDrawXButton())
|
||||
{
|
||||
textRect.setRight(textRect.right() - this->height() / 2);
|
||||
}
|
||||
|
||||
@@ -335,17 +358,22 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||
painter.drawText(textRect, this->getTitle(), option);
|
||||
|
||||
// draw close x
|
||||
if (this->shouldDrawXButton()) {
|
||||
if (this->shouldDrawXButton())
|
||||
{
|
||||
QRect xRect = this->getXRect();
|
||||
if (!xRect.isNull()) {
|
||||
if (this->selected_) xRect.moveTop(xRect.top() - 1);
|
||||
if (!xRect.isNull())
|
||||
{
|
||||
if (this->selected_)
|
||||
xRect.moveTop(xRect.top() - 1);
|
||||
|
||||
painter.setBrush(QColor("#fff"));
|
||||
|
||||
if (this->mouseOverX_) {
|
||||
if (this->mouseOverX_)
|
||||
{
|
||||
painter.fillRect(xRect, QColor(0, 0, 0, 64));
|
||||
|
||||
if (this->mouseDownX_) {
|
||||
if (this->mouseDownX_)
|
||||
{
|
||||
painter.fillRect(xRect, QColor(0, 0, 0, 64));
|
||||
}
|
||||
}
|
||||
@@ -360,13 +388,15 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||
}
|
||||
|
||||
// draw line at bottom
|
||||
if (!this->selected_ && this->isInLastRow_) {
|
||||
if (!this->selected_ && this->isInLastRow_)
|
||||
{
|
||||
painter.fillRect(0, this->height() - 1, this->width(), 1,
|
||||
app->themes->window.background);
|
||||
}
|
||||
|
||||
// draw mouse over effect
|
||||
if (!this->selected_) {
|
||||
if (!this->selected_)
|
||||
{
|
||||
this->fancyPaint(painter);
|
||||
}
|
||||
}
|
||||
@@ -384,7 +414,8 @@ bool NotebookTab::shouldDrawXButton()
|
||||
|
||||
void NotebookTab::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
this->mouseDown_ = true;
|
||||
this->mouseDownX_ = this->getXRect().contains(event->pos());
|
||||
|
||||
@@ -393,11 +424,15 @@ void NotebookTab::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
this->update();
|
||||
|
||||
if (this->notebook_->getAllowUserTabManagement()) {
|
||||
switch (event->button()) {
|
||||
case Qt::RightButton: {
|
||||
if (this->notebook_->getAllowUserTabManagement())
|
||||
{
|
||||
switch (event->button())
|
||||
{
|
||||
case Qt::RightButton:
|
||||
{
|
||||
this->menu_.popup(event->globalPos());
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
@@ -413,22 +448,30 @@ void NotebookTab::mouseReleaseEvent(QMouseEvent *event)
|
||||
"Are you sure that you want to remove this tab?",
|
||||
QMessageBox::Yes | QMessageBox::Cancel);
|
||||
|
||||
if (reply == QMessageBox::Yes) {
|
||||
if (reply == QMessageBox::Yes)
|
||||
{
|
||||
this->notebook_->removePage(this->page);
|
||||
}
|
||||
};
|
||||
|
||||
if (event->button() == Qt::MiddleButton) {
|
||||
if (this->rect().contains(event->pos())) {
|
||||
if (event->button() == Qt::MiddleButton)
|
||||
{
|
||||
if (this->rect().contains(event->pos()))
|
||||
{
|
||||
removeThisPage();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->hasXButton() && this->mouseDownX_ &&
|
||||
this->getXRect().contains(event->pos())) {
|
||||
this->getXRect().contains(event->pos()))
|
||||
{
|
||||
this->mouseDownX_ = false;
|
||||
|
||||
removeThisPage();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->update();
|
||||
}
|
||||
}
|
||||
@@ -455,11 +498,14 @@ void NotebookTab::leaveEvent(QEvent *event)
|
||||
|
||||
void NotebookTab::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;
|
||||
|
||||
if (this->notebook_->getAllowUserTabManagement()) {
|
||||
if (this->notebook_->getAllowUserTabManagement())
|
||||
{
|
||||
this->notebook_->select(this->page);
|
||||
}
|
||||
}
|
||||
@@ -473,7 +519,8 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
bool overX = this->getXRect().contains(event->pos());
|
||||
|
||||
if (overX != this->mouseOverX_) {
|
||||
if (overX != this->mouseOverX_)
|
||||
{
|
||||
// Over X state has been changed (we either left or entered it;
|
||||
this->mouseOverX_ = overX;
|
||||
|
||||
@@ -490,7 +537,8 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event)
|
||||
QWidget *clickedPage =
|
||||
this->notebook_->tabAt(relPoint, index, this->width());
|
||||
|
||||
if (clickedPage != nullptr && clickedPage != this->page) {
|
||||
if (clickedPage != nullptr && clickedPage != this->page)
|
||||
{
|
||||
this->notebook_->rearrangePage(this->page, index);
|
||||
}
|
||||
}
|
||||
@@ -500,9 +548,12 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event)
|
||||
|
||||
void NotebookTab::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (event->delta() > 0) {
|
||||
if (event->delta() > 0)
|
||||
{
|
||||
this->notebook_->selectPreviousTab();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->notebook_->selectNextTab();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,18 +44,22 @@ QString ResizingTextEdit::textUnderCursor(bool *hadSpace) const
|
||||
auto textUpToCursor = currentText.left(tc.selectionStart());
|
||||
|
||||
auto words = textUpToCursor.splitRef(' ');
|
||||
if (words.size() == 0) {
|
||||
if (words.size() == 0)
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool first = true;
|
||||
QString lastWord;
|
||||
for (auto it = words.crbegin(); it != words.crend(); ++it) {
|
||||
for (auto it = words.crbegin(); it != words.crend(); ++it)
|
||||
{
|
||||
auto word = *it;
|
||||
|
||||
if (first && word.isEmpty()) {
|
||||
if (first && word.isEmpty())
|
||||
{
|
||||
first = false;
|
||||
if (hadSpace != nullptr) {
|
||||
if (hadSpace != nullptr)
|
||||
{
|
||||
*hadSpace = true;
|
||||
}
|
||||
continue;
|
||||
@@ -65,7 +69,8 @@ QString ResizingTextEdit::textUnderCursor(bool *hadSpace) const
|
||||
break;
|
||||
}
|
||||
|
||||
if (lastWord.isEmpty()) {
|
||||
if (lastWord.isEmpty())
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
@@ -82,23 +87,27 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
|
||||
(event->key() == Qt::Key_Tab || event->key() == Qt::Key_Backtab) &&
|
||||
(event->modifiers() & Qt::ControlModifier) == Qt::NoModifier;
|
||||
|
||||
if (doComplete) {
|
||||
if (doComplete)
|
||||
{
|
||||
// check if there is a completer
|
||||
if (!this->completer_) {
|
||||
if (!this->completer_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QString currentCompletionPrefix = this->textUnderCursor();
|
||||
|
||||
// check if there is something to complete
|
||||
if (!currentCompletionPrefix.size()) {
|
||||
if (!currentCompletionPrefix.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto *completionModel =
|
||||
static_cast<CompletionModel *>(this->completer_->model());
|
||||
|
||||
if (!this->completionInProgress_) {
|
||||
if (!this->completionInProgress_)
|
||||
{
|
||||
// First type pressing tab after modifying a message, we refresh our
|
||||
// completion model
|
||||
this->completer_->setModel(completionModel);
|
||||
@@ -110,15 +119,20 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
|
||||
}
|
||||
|
||||
// scrolling through selections
|
||||
if (event->key() == Qt::Key_Tab) {
|
||||
if (event->key() == Qt::Key_Tab)
|
||||
{
|
||||
if (!this->completer_->setCurrentRow(
|
||||
this->completer_->currentRow() + 1)) {
|
||||
this->completer_->currentRow() + 1))
|
||||
{
|
||||
// wrap over and start again
|
||||
this->completer_->setCurrentRow(0);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!this->completer_->setCurrentRow(
|
||||
this->completer_->currentRow() - 1)) {
|
||||
this->completer_->currentRow() - 1))
|
||||
{
|
||||
// wrap over and start again
|
||||
this->completer_->setCurrentRow(
|
||||
this->completer_->completionCount() - 1);
|
||||
@@ -136,11 +150,13 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
|
||||
// might be a better solution but nobody is gonna bother anyways
|
||||
if (event->key() != Qt::Key_Shift && event->key() != Qt::Key_Control &&
|
||||
event->key() != Qt::Key_Alt && event->key() != Qt::Key_Super_L &&
|
||||
event->key() != Qt::Key_Super_R) {
|
||||
event->key() != Qt::Key_Super_R)
|
||||
{
|
||||
this->completionInProgress_ = false;
|
||||
}
|
||||
|
||||
if (!event->isAccepted()) {
|
||||
if (!event->isAccepted())
|
||||
{
|
||||
QTextEdit::keyPressEvent(event);
|
||||
}
|
||||
}
|
||||
@@ -149,7 +165,8 @@ void ResizingTextEdit::focusInEvent(QFocusEvent *event)
|
||||
{
|
||||
QTextEdit::focusInEvent(event);
|
||||
|
||||
if (event->gotFocus()) {
|
||||
if (event->gotFocus())
|
||||
{
|
||||
this->focused.invoke();
|
||||
}
|
||||
}
|
||||
@@ -158,20 +175,23 @@ void ResizingTextEdit::focusOutEvent(QFocusEvent *event)
|
||||
{
|
||||
QTextEdit::focusOutEvent(event);
|
||||
|
||||
if (event->lostFocus()) {
|
||||
if (event->lostFocus())
|
||||
{
|
||||
this->focusLost.invoke();
|
||||
}
|
||||
}
|
||||
|
||||
void ResizingTextEdit::setCompleter(QCompleter *c)
|
||||
{
|
||||
if (this->completer_) {
|
||||
if (this->completer_)
|
||||
{
|
||||
QObject::disconnect(this->completer_, nullptr, this, nullptr);
|
||||
}
|
||||
|
||||
this->completer_ = c;
|
||||
|
||||
if (!this->completer_) {
|
||||
if (!this->completer_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -186,7 +206,8 @@ void ResizingTextEdit::setCompleter(QCompleter *c)
|
||||
|
||||
void ResizingTextEdit::insertCompletion(const QString &completion)
|
||||
{
|
||||
if (this->completer_->widget() != this) {
|
||||
if (this->completer_->widget() != this)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -195,7 +216,8 @@ void ResizingTextEdit::insertCompletion(const QString &completion)
|
||||
|
||||
int prefixSize = prefix.size();
|
||||
|
||||
if (hadSpace) {
|
||||
if (hadSpace)
|
||||
{
|
||||
++prefixSize;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,12 +74,14 @@ void SearchPopup::performSearch()
|
||||
|
||||
ChannelPtr channel(new Channel("search", Channel::Type::None));
|
||||
|
||||
for (size_t i = 0; i < this->snapshot_.getLength(); i++) {
|
||||
for (size_t i = 0; i < this->snapshot_.getLength(); i++)
|
||||
{
|
||||
MessagePtr message = this->snapshot_[i];
|
||||
|
||||
if (text.isEmpty() ||
|
||||
message->searchText.indexOf(this->searchInput_->text(), 0,
|
||||
Qt::CaseInsensitive) != -1) {
|
||||
Qt::CaseInsensitive) != -1)
|
||||
{
|
||||
channel->addMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@ SettingsDialogTab::SettingsDialogTab(SettingsDialog *_dialog,
|
||||
|
||||
void SettingsDialogTab::setSelected(bool _selected)
|
||||
{
|
||||
if (this->selected_ == _selected) {
|
||||
if (this->selected_ == _selected)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -61,7 +62,8 @@ void SettingsDialogTab::paintEvent(QPaintEvent *)
|
||||
|
||||
void SettingsDialogTab::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() != Qt::LeftButton) {
|
||||
if (event->button() != Qt::LeftButton)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ void SignalLabel::mouseDoubleClickEvent(QMouseEvent *ev)
|
||||
|
||||
void SignalLabel::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
emit mouseDown();
|
||||
}
|
||||
|
||||
@@ -23,7 +24,8 @@ void SignalLabel::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
void SignalLabel::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
emit mouseUp();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,17 +34,21 @@ void TitleBarButton::paintEvent(QPaintEvent *event)
|
||||
|
||||
painter.setRenderHint(QPainter::Antialiasing, false);
|
||||
|
||||
switch (this->style_) {
|
||||
case TitleBarButtonStyle::Minimize: {
|
||||
switch (this->style_)
|
||||
{
|
||||
case TitleBarButtonStyle::Minimize:
|
||||
{
|
||||
painter.fillRect(centerX - xD / 2, xD * 3 / 2, xD, 1, color);
|
||||
break;
|
||||
}
|
||||
case TitleBarButtonStyle::Maximize: {
|
||||
case TitleBarButtonStyle::Maximize:
|
||||
{
|
||||
painter.setPen(color);
|
||||
painter.drawRect(centerX - xD / 2, xD, xD - 1, xD - 1);
|
||||
break;
|
||||
}
|
||||
case TitleBarButtonStyle::Unmaximize: {
|
||||
case TitleBarButtonStyle::Unmaximize:
|
||||
{
|
||||
int xD2 = xD * 1 / 5;
|
||||
int xD3 = xD * 4 / 5;
|
||||
|
||||
@@ -54,7 +58,8 @@ void TitleBarButton::paintEvent(QPaintEvent *event)
|
||||
painter.drawRect(centerX - xD / 2, xD + xD2, xD3, xD3);
|
||||
break;
|
||||
}
|
||||
case TitleBarButtonStyle::Close: {
|
||||
case TitleBarButtonStyle::Close:
|
||||
{
|
||||
QRect rect(centerX - xD / 2, xD, xD - 1, xD - 1);
|
||||
painter.setPen(QPen(color, 1));
|
||||
|
||||
@@ -62,7 +67,8 @@ void TitleBarButton::paintEvent(QPaintEvent *event)
|
||||
painter.drawLine(rect.topRight(), rect.bottomLeft());
|
||||
break;
|
||||
}
|
||||
case TitleBarButtonStyle::User: {
|
||||
case TitleBarButtonStyle::User:
|
||||
{
|
||||
color = "#999";
|
||||
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
@@ -88,7 +94,8 @@ void TitleBarButton::paintEvent(QPaintEvent *event)
|
||||
|
||||
break;
|
||||
}
|
||||
case TitleBarButtonStyle::Settings: {
|
||||
case TitleBarButtonStyle::Settings:
|
||||
{
|
||||
color = "#999";
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setRenderHint(QPainter::HighQualityAntialiasing);
|
||||
@@ -101,7 +108,8 @@ void TitleBarButton::paintEvent(QPaintEvent *event)
|
||||
|
||||
path.arcMoveTo(a, a, 6 * a, 6 * a, 0 - (360 / 32.0));
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
path.arcTo(a, a, 6 * a, 6 * a, i * (360 / 8.0) - (360 / 32.0),
|
||||
(360 / 32.0));
|
||||
path.arcTo(2 * a, 2 * a, 4 * a, 4 * a,
|
||||
|
||||
@@ -129,14 +129,17 @@ AboutPage::AboutPage()
|
||||
|
||||
QString line;
|
||||
|
||||
while (stream.readLineInto(&line)) {
|
||||
if (line.isEmpty() || line.startsWith('#')) {
|
||||
while (stream.readLineInto(&line))
|
||||
{
|
||||
if (line.isEmpty() || line.startsWith('#'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
QStringList contributorParts = line.split("|");
|
||||
|
||||
if (contributorParts.size() != 4) {
|
||||
if (contributorParts.size() != 4)
|
||||
{
|
||||
log("Missing parts in line '{}'", line);
|
||||
continue;
|
||||
}
|
||||
@@ -154,7 +157,8 @@ AboutPage::AboutPage()
|
||||
auto contributorBox2 = l.emplace<QHBoxLayout>();
|
||||
|
||||
const auto addAvatar = [&avatarUrl, &contributorBox2] {
|
||||
if (!avatarUrl.isEmpty()) {
|
||||
if (!avatarUrl.isEmpty())
|
||||
{
|
||||
QPixmap avatarPixmap;
|
||||
avatarPixmap.load(avatarUrl);
|
||||
|
||||
|
||||
@@ -98,12 +98,14 @@ void IgnoresPage::onShow()
|
||||
|
||||
auto user = app->accounts->twitch.getCurrent();
|
||||
|
||||
if (user->isAnon()) {
|
||||
if (user->isAnon())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList users;
|
||||
for (const auto &ignoredUser : user->getIgnores()) {
|
||||
for (const auto &ignoredUser : user->getIgnores())
|
||||
{
|
||||
users << ignoredUser.name;
|
||||
}
|
||||
this->userListModel_.setStringList(users);
|
||||
|
||||
@@ -181,7 +181,8 @@ void LookPage::addMessageTab(LayoutCreator<QVBoxLayout> layout)
|
||||
|
||||
const auto currentIndex = []() -> int {
|
||||
auto val = getSettings()->collpseMessagesMinLines.getValue();
|
||||
if (val > 0) {
|
||||
if (val > 0)
|
||||
{
|
||||
--val;
|
||||
}
|
||||
return val;
|
||||
@@ -332,7 +333,8 @@ void LookPage::addLastReadMessageIndicatorPatternSelector(
|
||||
combo->addItems({"Dotted line", "Solid line"});
|
||||
|
||||
const auto currentIndex = []() -> int {
|
||||
switch (getSettings()->lastMessagePattern.getValue()) {
|
||||
switch (getSettings()->lastMessagePattern.getValue())
|
||||
{
|
||||
case Qt::SolidLine:
|
||||
return 1;
|
||||
case Qt::VerPattern:
|
||||
@@ -347,7 +349,8 @@ void LookPage::addLastReadMessageIndicatorPatternSelector(
|
||||
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
[](int index) {
|
||||
getSettings()->lastMessagePattern = [&] {
|
||||
switch (index) {
|
||||
switch (index)
|
||||
{
|
||||
case 1:
|
||||
return Qt::SolidPattern;
|
||||
case 0:
|
||||
@@ -386,7 +389,8 @@ void LookPage::addLastReadMessageIndicatorPatternSelector(
|
||||
QObject::connect(
|
||||
button, &QPushButton::clicked, [updatePreviewColor, getCurrentColor]() {
|
||||
QColor newColor = QColorDialog::getColor(getCurrentColor());
|
||||
if (newColor.isValid()) {
|
||||
if (newColor.isValid())
|
||||
{
|
||||
updatePreviewColor(newColor);
|
||||
getSettings()->lastMessageColor = newColor.name();
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@ qint64 dirSize(QString dirPath)
|
||||
QDir dir(dirPath);
|
||||
// calculate total size of current directories' files
|
||||
QDir::Filters fileFilters = QDir::Files | QDir::System | QDir::Hidden;
|
||||
for (QString filePath : dir.entryList(fileFilters)) {
|
||||
for (QString filePath : dir.entryList(fileFilters))
|
||||
{
|
||||
QFileInfo fi(dir, filePath);
|
||||
size += fi.size();
|
||||
}
|
||||
@@ -49,8 +50,10 @@ QString formatSize(qint64 size)
|
||||
QStringList units = {"Bytes", "KB", "MB", "GB", "TB", "PB"};
|
||||
int i;
|
||||
double outputSize = size;
|
||||
for (i = 0; i < units.size() - 1; i++) {
|
||||
if (outputSize < 1024) break;
|
||||
for (i = 0; i < units.size() - 1; i++)
|
||||
{
|
||||
if (outputSize < 1024)
|
||||
break;
|
||||
outputSize = outputSize / 1024;
|
||||
}
|
||||
return QString("%0 %1").arg(outputSize, 0, 'f', 2).arg(units[i]);
|
||||
@@ -59,9 +62,12 @@ QString formatSize(qint64 size)
|
||||
QString fetchLogDirectorySize()
|
||||
{
|
||||
QString logPathDirectory;
|
||||
if (getSettings()->logPath == "") {
|
||||
if (getSettings()->logPath == "")
|
||||
{
|
||||
logPathDirectory = getPaths()->messageLogDirectory;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
logPathDirectory = getSettings()->logPath;
|
||||
}
|
||||
qint64 logsSize = dirSize(logPathDirectory);
|
||||
@@ -93,9 +99,12 @@ ModerationPage::ModerationPage()
|
||||
[logsPathLabel](const QString &logPath, auto) mutable {
|
||||
QString pathOriginal;
|
||||
|
||||
if (logPath == "") {
|
||||
if (logPath == "")
|
||||
{
|
||||
pathOriginal = getPaths()->messageLogDirectory;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
pathOriginal = logPath;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ void ClosedSplits::invalidateTab(NotebookTab *const tab)
|
||||
auto it = std::find_if(
|
||||
ClosedSplits::closedSplits_.begin(), ClosedSplits::closedSplits_.end(),
|
||||
[tab](const auto &item) -> bool { return item.tab == tab; });
|
||||
if (it == ClosedSplits::closedSplits_.end()) {
|
||||
if (it == ClosedSplits::closedSplits_.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
it->tab = nullptr;
|
||||
|
||||
@@ -125,7 +125,8 @@ Split::Split(QWidget *parent)
|
||||
this->giveFocus(Qt::MouseFocusReason);
|
||||
});
|
||||
this->view_->selectionChanged.connect([this]() {
|
||||
if (view_->hasSelection()) {
|
||||
if (view_->hasSelection())
|
||||
{
|
||||
this->input_->clearSelection();
|
||||
}
|
||||
});
|
||||
@@ -136,22 +137,29 @@ Split::Split(QWidget *parent)
|
||||
});
|
||||
|
||||
this->input_->textChanged.connect([=](const QString &newText) {
|
||||
if (getSettings()->showEmptyInput) {
|
||||
if (getSettings()->showEmptyInput)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (newText.length() == 0) {
|
||||
if (newText.length() == 0)
|
||||
{
|
||||
this->input_->hide();
|
||||
} else if (this->input_->isHidden()) {
|
||||
}
|
||||
else if (this->input_->isHidden())
|
||||
{
|
||||
this->input_->show();
|
||||
}
|
||||
});
|
||||
|
||||
getSettings()->showEmptyInput.connect(
|
||||
[this](const bool &showEmptyInput, auto) {
|
||||
if (!showEmptyInput && this->input_->getInputText().length() == 0) {
|
||||
if (!showEmptyInput && this->input_->getInputText().length() == 0)
|
||||
{
|
||||
this->input_->hide();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->input_->show();
|
||||
}
|
||||
},
|
||||
@@ -166,9 +174,12 @@ Split::Split(QWidget *parent)
|
||||
this->managedConnect(modifierStatusChanged,
|
||||
[this](Qt::KeyboardModifiers status) {
|
||||
if ((status == showSplitOverlayModifiers /*|| status == showAddSplitRegions*/) &&
|
||||
this->isMouseOver_) {
|
||||
this->isMouseOver_)
|
||||
{
|
||||
this->overlay_->show();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->overlay_->hide();
|
||||
}
|
||||
});
|
||||
@@ -229,7 +240,8 @@ void Split::setChannel(IndirectChannel newChannel)
|
||||
|
||||
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(newChannel.get().get());
|
||||
|
||||
if (tc != nullptr) {
|
||||
if (tc != nullptr)
|
||||
{
|
||||
this->usermodeChangedConnection_ = tc->userStateChanged.connect([this] {
|
||||
this->header_->updateModerationModeIcon();
|
||||
this->header_->updateRoomModes();
|
||||
@@ -256,7 +268,8 @@ void Split::setChannel(IndirectChannel newChannel)
|
||||
|
||||
void Split::setModerationMode(bool value)
|
||||
{
|
||||
if (value != this->moderationMode_) {
|
||||
if (value != this->moderationMode_)
|
||||
{
|
||||
this->moderationMode_ = value;
|
||||
this->header_->updateModerationModeIcon();
|
||||
this->view_->layoutMessages();
|
||||
@@ -276,22 +289,26 @@ void Split::insertTextToInput(const QString &text)
|
||||
void Split::showChangeChannelPopup(const char *dialogTitle, bool empty,
|
||||
std::function<void(bool)> callback)
|
||||
{
|
||||
if (this->selectChannelDialog_.hasElement()) {
|
||||
if (this->selectChannelDialog_.hasElement())
|
||||
{
|
||||
this->selectChannelDialog_->raise();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
SelectChannelDialog *dialog = new SelectChannelDialog(this);
|
||||
if (!empty) {
|
||||
if (!empty)
|
||||
{
|
||||
dialog->setSelectedChannel(this->getIndirectChannel());
|
||||
}
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dialog->show();
|
||||
dialog->closed.connect([=] {
|
||||
if (dialog->hasSeletedChannel()) {
|
||||
if (dialog->hasSeletedChannel())
|
||||
{
|
||||
this->setChannel(dialog->getSelectedChannel());
|
||||
if (this->isInContainer()) {
|
||||
if (this->isInContainer())
|
||||
{
|
||||
this->container_->refreshTab();
|
||||
}
|
||||
}
|
||||
@@ -368,11 +385,14 @@ void Split::enterEvent(QEvent *event)
|
||||
|
||||
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
||||
|
||||
if (modifierStatus == showSplitOverlayModifiers /*|| modifierStatus == showAddSplitRegions*/) {
|
||||
if (modifierStatus ==
|
||||
showSplitOverlayModifiers /*|| modifierStatus == showAddSplitRegions*/)
|
||||
{
|
||||
this->overlay_->show();
|
||||
}
|
||||
|
||||
if (this->container_ != nullptr) {
|
||||
if (this->container_ != nullptr)
|
||||
{
|
||||
this->container_->resetMouseStatus();
|
||||
}
|
||||
}
|
||||
@@ -393,7 +413,8 @@ void Split::focusInEvent(QFocusEvent *event)
|
||||
|
||||
void Split::handleModifiers(Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
if (modifierStatus != modifiers) {
|
||||
if (modifierStatus != modifiers)
|
||||
{
|
||||
modifierStatus = modifiers;
|
||||
modifierStatusChanged.invoke(modifiers);
|
||||
}
|
||||
@@ -408,14 +429,16 @@ void Split::setIsTopRightSplit(bool value)
|
||||
/// Slots
|
||||
void Split::addSibling()
|
||||
{
|
||||
if (this->container_) {
|
||||
if (this->container_)
|
||||
{
|
||||
this->container_->appendNewSplit(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Split::deleteFromContainer()
|
||||
{
|
||||
if (this->container_) {
|
||||
if (this->container_)
|
||||
{
|
||||
this->container_->deleteSplit(this);
|
||||
auto *tab = this->getContainer()->getTab();
|
||||
tab->connect(tab, &QWidget::destroyed,
|
||||
@@ -429,8 +452,8 @@ void Split::changeChannel()
|
||||
this->showChangeChannelPopup("Change channel", false, [](bool) {});
|
||||
|
||||
auto popup = this->findChildren<QDockWidget *>();
|
||||
if (popup.size() && popup.at(0)->isVisible() &&
|
||||
!popup.at(0)->isFloating()) {
|
||||
if (popup.size() && popup.at(0)->isVisible() && !popup.at(0)->isFloating())
|
||||
{
|
||||
popup.at(0)->hide();
|
||||
showViewerList();
|
||||
}
|
||||
@@ -471,7 +494,8 @@ void Split::openInBrowser()
|
||||
{
|
||||
auto channel = this->getChannel();
|
||||
|
||||
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get())) {
|
||||
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
|
||||
{
|
||||
QDesktopServices::openUrl("https://twitch.tv/" +
|
||||
twitchChannel->getName());
|
||||
}
|
||||
@@ -480,7 +504,8 @@ void Split::openInBrowser()
|
||||
void Split::openBrowserPlayer()
|
||||
{
|
||||
ChannelPtr channel = this->getChannel();
|
||||
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get())) {
|
||||
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
|
||||
{
|
||||
QDesktopServices::openUrl("https://player.twitch.tv/?channel=" +
|
||||
twitchChannel->getName());
|
||||
}
|
||||
@@ -488,9 +513,12 @@ void Split::openBrowserPlayer()
|
||||
|
||||
void Split::openInStreamlink()
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
openStreamlinkForChannel(this->getChannel()->getName());
|
||||
} catch (const Exception &ex) {
|
||||
}
|
||||
catch (const Exception &ex)
|
||||
{
|
||||
log("Error in doOpenStreamlink: {}", ex.what());
|
||||
}
|
||||
}
|
||||
@@ -519,7 +547,8 @@ void Split::showViewerList()
|
||||
static QStringList jsonLabels = {"moderators", "staff", "admins",
|
||||
"global_mods", "viewers"};
|
||||
QList<QListWidgetItem *> labelList;
|
||||
for (auto &x : labels) {
|
||||
for (auto &x : labels)
|
||||
{
|
||||
auto label = new QListWidgetItem(x);
|
||||
label->setBackgroundColor(this->theme->splits.header.background);
|
||||
labelList.append(label);
|
||||
@@ -536,12 +565,14 @@ void Split::showViewerList()
|
||||
QJsonObject chattersObj = obj.value("chatters").toObject();
|
||||
|
||||
loadingLabel->hide();
|
||||
for (int i = 0; i < jsonLabels.size(); i++) {
|
||||
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;
|
||||
if (currentCategory.empty())
|
||||
continue;
|
||||
|
||||
chattersList->addItem(labelList.at(i));
|
||||
foreach (const QJsonValue &v, currentCategory)
|
||||
@@ -556,16 +587,20 @@ void Split::showViewerList()
|
||||
searchBar->setPlaceholderText("Search User...");
|
||||
QObject::connect(searchBar, &QLineEdit::textEdited, this, [=]() {
|
||||
auto query = searchBar->text();
|
||||
if (!query.isEmpty()) {
|
||||
if (!query.isEmpty())
|
||||
{
|
||||
auto results = chattersList->findItems(query, Qt::MatchStartsWith);
|
||||
chattersList->hide();
|
||||
resultList->clear();
|
||||
for (auto &item : results) {
|
||||
for (auto &item : results)
|
||||
{
|
||||
if (!labels.contains(item->text()))
|
||||
resultList->addItem(item->text());
|
||||
}
|
||||
resultList->show();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
resultList->hide();
|
||||
chattersList->show();
|
||||
}
|
||||
@@ -575,7 +610,8 @@ void Split::showViewerList()
|
||||
[=]() { viewerDock->setMinimumWidth(300); });
|
||||
|
||||
auto listDoubleClick = [=](QString userName) {
|
||||
if (!labels.contains(userName)) {
|
||||
if (!labels.contains(userName))
|
||||
{
|
||||
this->view_->showUserInfoPopup(userName);
|
||||
}
|
||||
};
|
||||
@@ -631,7 +667,8 @@ static Iter select_randomly(Iter start, Iter end)
|
||||
|
||||
void Split::drag()
|
||||
{
|
||||
if (auto container = dynamic_cast<SplitContainer *>(this->parentWidget())) {
|
||||
if (auto container = dynamic_cast<SplitContainer *>(this->parentWidget()))
|
||||
{
|
||||
SplitContainer::isDraggingSplit = true;
|
||||
SplitContainer::draggingSplit = this;
|
||||
|
||||
@@ -642,7 +679,8 @@ void Split::drag()
|
||||
mimeData->setData("chatterino/split", "xD");
|
||||
drag->setMimeData(mimeData);
|
||||
|
||||
if (drag->exec(Qt::MoveAction) == Qt::IgnoreAction) {
|
||||
if (drag->exec(Qt::MoveAction) == Qt::IgnoreAction)
|
||||
{
|
||||
container->insertSplit(this, originalLocation);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,20 +41,28 @@ SplitContainer::SplitContainer(Notebook *parent)
|
||||
this->managedConnect(Split::modifierStatusChanged, [this](auto modifiers) {
|
||||
this->layout();
|
||||
|
||||
if (modifiers == showResizeHandlesModifiers) {
|
||||
for (auto &handle : this->resizeHandles_) {
|
||||
if (modifiers == showResizeHandlesModifiers)
|
||||
{
|
||||
for (auto &handle : this->resizeHandles_)
|
||||
{
|
||||
handle->show();
|
||||
handle->raise();
|
||||
}
|
||||
} else {
|
||||
for (auto &handle : this->resizeHandles_) {
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto &handle : this->resizeHandles_)
|
||||
{
|
||||
handle->hide();
|
||||
}
|
||||
}
|
||||
|
||||
if (modifiers == showSplitOverlayModifiers) {
|
||||
if (modifiers == showSplitOverlayModifiers)
|
||||
{
|
||||
this->setCursor(Qt::PointingHandCursor);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->unsetCursor();
|
||||
}
|
||||
});
|
||||
@@ -91,7 +99,8 @@ void SplitContainer::hideResizeHandles()
|
||||
{
|
||||
this->overlay_.hide();
|
||||
|
||||
for (auto &handle : this->resizeHandles_) {
|
||||
for (auto &handle : this->resizeHandles_)
|
||||
{
|
||||
handle->hide();
|
||||
}
|
||||
}
|
||||
@@ -109,9 +118,11 @@ Split *SplitContainer::appendNewSplit(bool openChannelNameDialog)
|
||||
Split *split = new Split(this);
|
||||
this->appendSplit(split);
|
||||
|
||||
if (openChannelNameDialog) {
|
||||
if (openChannelNameDialog)
|
||||
{
|
||||
split->showChangeChannelPopup("Open channel name", true, [=](bool ok) {
|
||||
if (!ok) {
|
||||
if (!ok)
|
||||
{
|
||||
this->deleteSplit(split);
|
||||
}
|
||||
});
|
||||
@@ -150,15 +161,23 @@ void SplitContainer::insertSplit(Split *split, Direction direction,
|
||||
|
||||
split->setContainer(this);
|
||||
|
||||
if (relativeTo == nullptr) {
|
||||
if (this->baseNode_.type_ == Node::EmptyRoot) {
|
||||
if (relativeTo == nullptr)
|
||||
{
|
||||
if (this->baseNode_.type_ == Node::EmptyRoot)
|
||||
{
|
||||
this->baseNode_.setSplit(split);
|
||||
} else if (this->baseNode_.type_ == Node::_Split) {
|
||||
}
|
||||
else if (this->baseNode_.type_ == Node::_Split)
|
||||
{
|
||||
this->baseNode_.nestSplitIntoCollection(split, direction);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->baseNode_.insertSplitRelative(split, direction);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(this->baseNode_.isOrContainsNode(relativeTo));
|
||||
|
||||
relativeTo->insertSplitRelative(split, direction);
|
||||
@@ -181,7 +200,8 @@ void SplitContainer::addSplit(Split *split)
|
||||
|
||||
split->getChannelView().tabHighlightRequested.connect(
|
||||
[this](HighlightState state) {
|
||||
if (this->tab_ != nullptr) {
|
||||
if (this->tab_ != nullptr)
|
||||
{
|
||||
this->tab_->setHighlightState(state);
|
||||
}
|
||||
});
|
||||
@@ -199,14 +219,16 @@ void SplitContainer::setSelected(Split *split)
|
||||
{
|
||||
this->selected_ = split;
|
||||
|
||||
if (Node *node = this->baseNode_.findNodeContainingSplit(split)) {
|
||||
if (Node *node = this->baseNode_.findNodeContainingSplit(split))
|
||||
{
|
||||
this->setPreferedTargetRecursive(node);
|
||||
}
|
||||
}
|
||||
|
||||
void SplitContainer::setPreferedTargetRecursive(Node *node)
|
||||
{
|
||||
if (node->parent_ != nullptr) {
|
||||
if (node->parent_ != nullptr)
|
||||
{
|
||||
node->parent_->preferedFocusTarget_ = node;
|
||||
|
||||
this->setPreferedTargetRecursive(node->parent_);
|
||||
@@ -225,10 +247,13 @@ SplitContainer::Position SplitContainer::releaseSplit(Split *split)
|
||||
split->setParent(nullptr);
|
||||
Position position = node->releaseSplit();
|
||||
this->layout();
|
||||
if (splits_.size() == 0) {
|
||||
if (splits_.size() == 0)
|
||||
{
|
||||
this->setSelected(nullptr);
|
||||
this->setCursor(Qt::PointingHandCursor);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->splits_.front()->giveFocus(Qt::MouseFocusReason);
|
||||
}
|
||||
|
||||
@@ -258,15 +283,18 @@ void SplitContainer::selectNextSplit(Direction direction)
|
||||
{
|
||||
assertInGuiThread();
|
||||
|
||||
if (Node *node = this->baseNode_.findNodeContainingSplit(this->selected_)) {
|
||||
if (Node *node = this->baseNode_.findNodeContainingSplit(this->selected_))
|
||||
{
|
||||
this->selectSplitRecursive(node, direction);
|
||||
}
|
||||
}
|
||||
|
||||
void SplitContainer::selectSplitRecursive(Node *node, Direction direction)
|
||||
{
|
||||
if (node->parent_ != nullptr) {
|
||||
if (node->parent_->type_ == Node::toContainerType(direction)) {
|
||||
if (node->parent_ != nullptr)
|
||||
{
|
||||
if (node->parent_->type_ == Node::toContainerType(direction))
|
||||
{
|
||||
auto &siblings = node->parent_->children_;
|
||||
|
||||
auto it = std::find_if(
|
||||
@@ -274,22 +302,33 @@ void SplitContainer::selectSplitRecursive(Node *node, Direction direction)
|
||||
[node](const auto &other) { return other.get() == node; });
|
||||
assert(it != siblings.end());
|
||||
|
||||
if (direction == Direction::Left || direction == Direction::Above) {
|
||||
if (it == siblings.begin()) {
|
||||
if (direction == Direction::Left || direction == Direction::Above)
|
||||
{
|
||||
if (it == siblings.begin())
|
||||
{
|
||||
this->selectSplitRecursive(node->parent_, direction);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->focusSplitRecursive(
|
||||
siblings[it - siblings.begin() - 1].get(), direction);
|
||||
}
|
||||
} else {
|
||||
if (it->get() == siblings.back().get()) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (it->get() == siblings.back().get())
|
||||
{
|
||||
this->selectSplitRecursive(node->parent_, direction);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->focusSplitRecursive(
|
||||
siblings[it - siblings.begin() + 1].get(), direction);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->selectSplitRecursive(node->parent_, direction);
|
||||
}
|
||||
}
|
||||
@@ -297,13 +336,17 @@ void SplitContainer::selectSplitRecursive(Node *node, Direction direction)
|
||||
|
||||
void SplitContainer::focusSplitRecursive(Node *node, Direction direction)
|
||||
{
|
||||
switch (node->type_) {
|
||||
case Node::_Split: {
|
||||
switch (node->type_)
|
||||
{
|
||||
case Node::_Split:
|
||||
{
|
||||
node->split_->giveFocus(Qt::OtherFocusReason);
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Node::HorizontalContainer:
|
||||
case Node::VerticalContainer: {
|
||||
case Node::VerticalContainer:
|
||||
{
|
||||
auto &children = node->children_;
|
||||
|
||||
auto it = std::find_if(
|
||||
@@ -311,13 +354,17 @@ void SplitContainer::focusSplitRecursive(Node *node, Direction direction)
|
||||
return node->preferedFocusTarget_ == other.get();
|
||||
});
|
||||
|
||||
if (it != children.end()) {
|
||||
if (it != children.end())
|
||||
{
|
||||
this->focusSplitRecursive(it->get(), direction);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->focusSplitRecursive(node->children_.front().get(),
|
||||
direction);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:;
|
||||
}
|
||||
@@ -325,7 +372,8 @@ void SplitContainer::focusSplitRecursive(Node *node, Direction direction)
|
||||
|
||||
Split *SplitContainer::getTopRightSplit(Node &node)
|
||||
{
|
||||
switch (node.getType()) {
|
||||
switch (node.getType())
|
||||
{
|
||||
case Node::_Split:
|
||||
return node.getSplit();
|
||||
case Node::VerticalContainer:
|
||||
@@ -345,9 +393,11 @@ void SplitContainer::layout()
|
||||
{
|
||||
// update top right split
|
||||
auto topRight = this->getTopRightSplit(this->baseNode_);
|
||||
if (this->topRight_) this->topRight_->setIsTopRightSplit(false);
|
||||
if (this->topRight_)
|
||||
this->topRight_->setIsTopRightSplit(false);
|
||||
this->topRight_ = topRight;
|
||||
if (topRight) this->topRight_->setIsTopRightSplit(true);
|
||||
if (topRight)
|
||||
this->topRight_->setIsTopRightSplit(true);
|
||||
|
||||
// layout
|
||||
this->baseNode_.geometry_ = this->rect().adjusted(-1, -1, 0, 0);
|
||||
@@ -360,7 +410,8 @@ void SplitContainer::layout()
|
||||
|
||||
this->dropRects_ = _dropRects;
|
||||
|
||||
for (Split *split : this->splits_) {
|
||||
for (Split *split : this->splits_)
|
||||
{
|
||||
const QRect &g = split->geometry();
|
||||
|
||||
Node *node = this->baseNode_.findNodeContainingSplit(split);
|
||||
@@ -385,7 +436,8 @@ void SplitContainer::layout()
|
||||
Position(node, Direction::Below)));
|
||||
}
|
||||
|
||||
if (this->splits_.empty()) {
|
||||
if (this->splits_.empty())
|
||||
{
|
||||
QRect g = this->rect();
|
||||
_dropRects.push_back(
|
||||
DropRect(QRect(g.left(), g.top(), g.width() - 1, g.height() - 1),
|
||||
@@ -395,24 +447,30 @@ void SplitContainer::layout()
|
||||
this->overlay_.setRects(std::move(_dropRects));
|
||||
|
||||
// handle resizeHandles
|
||||
if (this->resizeHandles_.size() < _resizeRects.size()) {
|
||||
while (this->resizeHandles_.size() < _resizeRects.size()) {
|
||||
if (this->resizeHandles_.size() < _resizeRects.size())
|
||||
{
|
||||
while (this->resizeHandles_.size() < _resizeRects.size())
|
||||
{
|
||||
this->resizeHandles_.push_back(
|
||||
std::make_unique<ResizeHandle>(this));
|
||||
}
|
||||
} else if (this->resizeHandles_.size() > _resizeRects.size()) {
|
||||
}
|
||||
else if (this->resizeHandles_.size() > _resizeRects.size())
|
||||
{
|
||||
this->resizeHandles_.resize(_resizeRects.size());
|
||||
}
|
||||
|
||||
{
|
||||
size_t i = 0;
|
||||
for (ResizeRect &resizeRect : _resizeRects) {
|
||||
for (ResizeRect &resizeRect : _resizeRects)
|
||||
{
|
||||
ResizeHandle *handle = this->resizeHandles_[i].get();
|
||||
handle->setGeometry(resizeRect.rect);
|
||||
handle->setVertical(resizeRect.vertical);
|
||||
handle->node = resizeRect.node;
|
||||
|
||||
if (Split::modifierStatus == showResizeHandlesModifiers) {
|
||||
if (Split::modifierStatus == showResizeHandlesModifiers)
|
||||
{
|
||||
handle->show();
|
||||
handle->raise();
|
||||
}
|
||||
@@ -434,20 +492,25 @@ void SplitContainer::resizeEvent(QResizeEvent *event)
|
||||
|
||||
void SplitContainer::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
if (this->splits_.size() == 0) {
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
if (this->splits_.size() == 0)
|
||||
{
|
||||
// "Add Chat" was clicked
|
||||
this->appendNewSplit(true);
|
||||
this->mouseOverPoint_ = QPoint(-10000, -10000);
|
||||
|
||||
// this->setCursor(QCursor(Qt::ArrowCursor));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
auto it =
|
||||
std::find_if(this->dropRects_.begin(), this->dropRects_.end(),
|
||||
[event](DropRect &rect) {
|
||||
return rect.rect.contains(event->pos());
|
||||
});
|
||||
if (it != this->dropRects_.end()) {
|
||||
if (it != this->dropRects_.end())
|
||||
{
|
||||
this->insertSplit(new Split(this), it->position);
|
||||
}
|
||||
}
|
||||
@@ -458,7 +521,8 @@ void SplitContainer::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
if (this->splits_.size() == 0) {
|
||||
if (this->splits_.size() == 0)
|
||||
{
|
||||
painter.fillRect(rect(), this->theme->splits.background);
|
||||
|
||||
painter.setPen(this->theme->splits.header.text);
|
||||
@@ -467,29 +531,40 @@ void SplitContainer::paintEvent(QPaintEvent *)
|
||||
|
||||
Notebook *notebook = dynamic_cast<Notebook *>(this->parentWidget());
|
||||
|
||||
if (notebook != nullptr) {
|
||||
if (notebook->getPageCount() > 1) {
|
||||
if (notebook != nullptr)
|
||||
{
|
||||
if (notebook->getPageCount() > 1)
|
||||
{
|
||||
text += "\n\nAfter adding hold <Ctrl+Alt> to move or split it.";
|
||||
}
|
||||
}
|
||||
|
||||
painter.drawText(rect(), text, QTextOption(Qt::AlignCenter));
|
||||
} else {
|
||||
if (getApp()->themes->isLightTheme()) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getApp()->themes->isLightTheme())
|
||||
{
|
||||
painter.fillRect(rect(), QColor("#999"));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
painter.fillRect(rect(), QColor("#555"));
|
||||
}
|
||||
}
|
||||
|
||||
for (DropRect &dropRect : this->dropRects_) {
|
||||
for (DropRect &dropRect : this->dropRects_)
|
||||
{
|
||||
QColor border = getApp()->themes->splits.dropTargetRectBorder;
|
||||
QColor background = getApp()->themes->splits.dropTargetRect;
|
||||
|
||||
if (!dropRect.rect.contains(this->mouseOverPoint_)) {
|
||||
if (!dropRect.rect.contains(this->mouseOverPoint_))
|
||||
{
|
||||
// border.setAlphaF(0.1);
|
||||
// background.setAlphaF(0.1);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// background.setAlphaF(0.1);
|
||||
border.setAlpha(255);
|
||||
}
|
||||
@@ -504,9 +579,12 @@ void SplitContainer::paintEvent(QPaintEvent *)
|
||||
int s =
|
||||
std::min<int>(dropRect.rect.width(), dropRect.rect.height()) - 12;
|
||||
|
||||
if (this->theme->isLightTheme()) {
|
||||
if (this->theme->isLightTheme())
|
||||
{
|
||||
painter.setPen(QColor(0, 0, 0));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
painter.setPen(QColor(255, 255, 255));
|
||||
}
|
||||
painter.drawLine(rect.left() + rect.width() / 2 - (s / 2),
|
||||
@@ -529,9 +607,11 @@ 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();
|
||||
@@ -543,7 +623,8 @@ void SplitContainer::dragEnterEvent(QDragEnterEvent *event)
|
||||
|
||||
void SplitContainer::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (Split::modifierStatus == showSplitOverlayModifiers) {
|
||||
if (Split::modifierStatus == showSplitOverlayModifiers)
|
||||
{
|
||||
this->setCursor(Qt::PointingHandCursor);
|
||||
}
|
||||
|
||||
@@ -559,12 +640,14 @@ void SplitContainer::leaveEvent(QEvent *)
|
||||
|
||||
void SplitContainer::focusInEvent(QFocusEvent *)
|
||||
{
|
||||
if (this->baseNode_.findNodeContainingSplit(this->selected_) != nullptr) {
|
||||
if (this->baseNode_.findNodeContainingSplit(this->selected_) != nullptr)
|
||||
{
|
||||
this->selected_->setFocus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->splits_.size() != 0) {
|
||||
if (this->splits_.size() != 0)
|
||||
{
|
||||
this->splits_.front()->setFocus();
|
||||
}
|
||||
}
|
||||
@@ -601,13 +684,16 @@ void SplitContainer::decodeNodeRecusively(QJsonObject &obj, Node *node)
|
||||
{
|
||||
QString type = obj.value("type").toString();
|
||||
|
||||
if (type == "split") {
|
||||
if (type == "split")
|
||||
{
|
||||
auto *split = new Split(this);
|
||||
split->setChannel(
|
||||
WindowManager::decodeChannel(obj.value("data").toObject()));
|
||||
|
||||
this->appendSplit(split);
|
||||
} else if (type == "horizontal" || type == "vertical") {
|
||||
}
|
||||
else if (type == "horizontal" || type == "vertical")
|
||||
{
|
||||
bool vertical = type == "vertical";
|
||||
|
||||
Direction direction = vertical ? Direction::Below : Direction::Right;
|
||||
@@ -615,11 +701,13 @@ void SplitContainer::decodeNodeRecusively(QJsonObject &obj, Node *node)
|
||||
node->type_ =
|
||||
vertical ? Node::VerticalContainer : Node::HorizontalContainer;
|
||||
|
||||
for (QJsonValue _val : obj.value("items").toArray()) {
|
||||
for (QJsonValue _val : obj.value("items").toArray())
|
||||
{
|
||||
auto _obj = _val.toObject();
|
||||
|
||||
auto _type = _obj.value("type");
|
||||
if (_type == "split") {
|
||||
if (_type == "split")
|
||||
{
|
||||
auto *split = new Split(this);
|
||||
split->setChannel(WindowManager::decodeChannel(
|
||||
_obj.value("data").toObject()));
|
||||
@@ -634,7 +722,9 @@ void SplitContainer::decodeNodeRecusively(QJsonObject &obj, Node *node)
|
||||
node->children_.emplace_back(_node);
|
||||
|
||||
this->addSplit(split);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Node *_node = new Node();
|
||||
_node->parent_ = node;
|
||||
node->children_.emplace_back(_node);
|
||||
@@ -642,8 +732,10 @@ void SplitContainer::decodeNodeRecusively(QJsonObject &obj, Node *node)
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (node->getChildren().size() < 2) {
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (node->getChildren().size() < 2)
|
||||
{
|
||||
auto *split = new Split(this);
|
||||
split->setChannel(
|
||||
WindowManager::decodeChannel(obj.value("data").toObject()));
|
||||
@@ -656,20 +748,24 @@ void SplitContainer::decodeNodeRecusively(QJsonObject &obj, Node *node)
|
||||
|
||||
void SplitContainer::refreshTabTitle()
|
||||
{
|
||||
if (this->tab_ == nullptr) {
|
||||
if (this->tab_ == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QString newTitle = "";
|
||||
bool first = true;
|
||||
|
||||
for (const auto &chatWidget : this->splits_) {
|
||||
for (const auto &chatWidget : this->splits_)
|
||||
{
|
||||
auto channelName = chatWidget->getChannel()->getName();
|
||||
if (channelName.isEmpty()) {
|
||||
if (channelName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!first) {
|
||||
if (!first)
|
||||
{
|
||||
newTitle += ", ";
|
||||
}
|
||||
newTitle += channelName;
|
||||
@@ -677,7 +773,8 @@ void SplitContainer::refreshTabTitle()
|
||||
first = false;
|
||||
}
|
||||
|
||||
if (newTitle.isEmpty()) {
|
||||
if (newTitle.isEmpty())
|
||||
{
|
||||
newTitle = "empty";
|
||||
}
|
||||
|
||||
@@ -686,14 +783,17 @@ void SplitContainer::refreshTabTitle()
|
||||
|
||||
void SplitContainer::refreshTabLiveStatus()
|
||||
{
|
||||
if (this->tab_ == nullptr) {
|
||||
if (this->tab_ == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool liveStatus = false;
|
||||
for (const auto &s : this->splits_) {
|
||||
for (const auto &s : this->splits_)
|
||||
{
|
||||
auto c = s->getChannel();
|
||||
if (c->isLive()) {
|
||||
if (c->isLive())
|
||||
{
|
||||
liveStatus = true;
|
||||
break;
|
||||
}
|
||||
@@ -752,7 +852,8 @@ SplitContainer::Node::Node(Split *_split, Node *_parent)
|
||||
|
||||
bool SplitContainer::Node::isOrContainsNode(SplitContainer::Node *_node)
|
||||
{
|
||||
if (this == _node) {
|
||||
if (this == _node)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -765,14 +866,17 @@ bool SplitContainer::Node::isOrContainsNode(SplitContainer::Node *_node)
|
||||
SplitContainer::Node *SplitContainer::Node::findNodeContainingSplit(
|
||||
Split *_split)
|
||||
{
|
||||
if (this->type_ == Type::_Split && this->split_ == _split) {
|
||||
if (this->type_ == Type::_Split && this->split_ == _split)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
for (std::unique_ptr<Node> &node : this->children_) {
|
||||
for (std::unique_ptr<Node> &node : this->children_)
|
||||
{
|
||||
Node *a = node->findNodeContainingSplit(_split);
|
||||
|
||||
if (a != nullptr) {
|
||||
if (a != nullptr)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
}
|
||||
@@ -782,29 +886,42 @@ SplitContainer::Node *SplitContainer::Node::findNodeContainingSplit(
|
||||
void SplitContainer::Node::insertSplitRelative(Split *_split,
|
||||
Direction _direction)
|
||||
{
|
||||
if (this->parent_ == nullptr) {
|
||||
switch (this->type_) {
|
||||
case Node::EmptyRoot: {
|
||||
if (this->parent_ == nullptr)
|
||||
{
|
||||
switch (this->type_)
|
||||
{
|
||||
case Node::EmptyRoot:
|
||||
{
|
||||
this->setSplit(_split);
|
||||
} break;
|
||||
case Node::_Split: {
|
||||
}
|
||||
break;
|
||||
case Node::_Split:
|
||||
{
|
||||
this->nestSplitIntoCollection(_split, _direction);
|
||||
} break;
|
||||
case Node::HorizontalContainer: {
|
||||
}
|
||||
break;
|
||||
case Node::HorizontalContainer:
|
||||
{
|
||||
this->nestSplitIntoCollection(_split, _direction);
|
||||
} break;
|
||||
case Node::VerticalContainer: {
|
||||
}
|
||||
break;
|
||||
case Node::VerticalContainer:
|
||||
{
|
||||
this->nestSplitIntoCollection(_split, _direction);
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// parent != nullptr
|
||||
if (parent_->type_ == toContainerType(_direction)) {
|
||||
if (parent_->type_ == toContainerType(_direction))
|
||||
{
|
||||
// hell yeah we'll just insert it next to outselves
|
||||
this->insertNextToThis(_split, _direction);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->nestSplitIntoCollection(_split, _direction);
|
||||
}
|
||||
}
|
||||
@@ -812,15 +929,19 @@ void SplitContainer::Node::insertSplitRelative(Split *_split,
|
||||
void SplitContainer::Node::nestSplitIntoCollection(Split *_split,
|
||||
Direction _direction)
|
||||
{
|
||||
if (toContainerType(_direction) == this->type_) {
|
||||
if (toContainerType(_direction) == this->type_)
|
||||
{
|
||||
this->children_.emplace_back(new Node(_split, this));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// we'll need to nest outselves
|
||||
// move all our data into a new node
|
||||
Node *clone = new Node();
|
||||
clone->type_ = this->type_;
|
||||
clone->children_ = std::move(this->children_);
|
||||
for (std::unique_ptr<Node> &node : clone->children_) {
|
||||
for (std::unique_ptr<Node> &node : clone->children_)
|
||||
{
|
||||
node->parent_ = clone;
|
||||
}
|
||||
clone->split_ = this->split_;
|
||||
@@ -842,7 +963,8 @@ void SplitContainer::Node::insertNextToThis(Split *_split, Direction _direction)
|
||||
qreal width = this->parent_->geometry_.width() / siblings.size();
|
||||
qreal height = this->parent_->geometry_.height() / siblings.size();
|
||||
|
||||
if (siblings.size() == 1) {
|
||||
if (siblings.size() == 1)
|
||||
{
|
||||
this->geometry_ = QRect(0, 0, int(width), int(height));
|
||||
}
|
||||
|
||||
@@ -850,7 +972,8 @@ void SplitContainer::Node::insertNextToThis(Split *_split, Direction _direction)
|
||||
[this](auto &node) { return this == node.get(); });
|
||||
|
||||
assert(it != siblings.end());
|
||||
if (_direction == Direction::Right || _direction == Direction::Below) {
|
||||
if (_direction == Direction::Right || _direction == Direction::Below)
|
||||
{
|
||||
it++;
|
||||
}
|
||||
|
||||
@@ -872,7 +995,8 @@ SplitContainer::Position SplitContainer::Node::releaseSplit()
|
||||
{
|
||||
assert(this->type_ == Type::_Split);
|
||||
|
||||
if (parent_ == nullptr) {
|
||||
if (parent_ == nullptr)
|
||||
{
|
||||
this->type_ = Type::EmptyRoot;
|
||||
this->split_ = nullptr;
|
||||
|
||||
@@ -880,7 +1004,9 @@ SplitContainer::Position SplitContainer::Node::releaseSplit()
|
||||
pos.relativeNode_ = nullptr;
|
||||
pos.direction_ = Direction::Right;
|
||||
return pos;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
auto &siblings = this->parent_->children_;
|
||||
|
||||
auto it =
|
||||
@@ -889,13 +1015,17 @@ SplitContainer::Position SplitContainer::Node::releaseSplit()
|
||||
assert(it != siblings.end());
|
||||
|
||||
Position position;
|
||||
if (siblings.size() == 2) {
|
||||
if (siblings.size() == 2)
|
||||
{
|
||||
// delete this and move split to parent
|
||||
position.relativeNode_ = this->parent_;
|
||||
if (this->parent_->type_ == Type::VerticalContainer) {
|
||||
if (this->parent_->type_ == Type::VerticalContainer)
|
||||
{
|
||||
position.direction_ = siblings.begin() == it ? Direction::Above
|
||||
: Direction::Below;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
position.direction_ =
|
||||
siblings.begin() == it ? Direction::Left : Direction::Right;
|
||||
}
|
||||
@@ -907,19 +1037,25 @@ SplitContainer::Position SplitContainer::Node::releaseSplit()
|
||||
_parent->split_ = sibling->split_;
|
||||
std::vector<std::unique_ptr<Node>> nodes =
|
||||
std::move(sibling->children_);
|
||||
for (auto &node : nodes) {
|
||||
for (auto &node : nodes)
|
||||
{
|
||||
node->parent_ = _parent;
|
||||
}
|
||||
_parent->children_ = std::move(nodes);
|
||||
} else {
|
||||
if (this == siblings.back().get()) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this == siblings.back().get())
|
||||
{
|
||||
position.direction_ =
|
||||
this->parent_->type_ == Type::VerticalContainer
|
||||
? Direction::Below
|
||||
: Direction::Right;
|
||||
siblings.erase(it);
|
||||
position.relativeNode_ = siblings.back().get();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
position.relativeNode_ = (it + 1)->get();
|
||||
position.direction_ =
|
||||
this->parent_->type_ == Type::VerticalContainer
|
||||
@@ -956,19 +1092,26 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale,
|
||||
std::vector<DropRect> &dropRects,
|
||||
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;
|
||||
for (std::unique_ptr<Node> &node : this->children_)
|
||||
{
|
||||
if (node->flexH_ <= 0)
|
||||
node->flexH_ = 0;
|
||||
if (node->flexV_ <= 0)
|
||||
node->flexV_ = 0;
|
||||
}
|
||||
|
||||
switch (this->type_) {
|
||||
case Node::_Split: {
|
||||
switch (this->type_)
|
||||
{
|
||||
case Node::_Split:
|
||||
{
|
||||
QRect rect = this->geometry_.toRect();
|
||||
this->split_->setGeometry(
|
||||
rect.marginsRemoved(QMargins(1, 1, 0, 0)));
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case Node::VerticalContainer:
|
||||
case Node::HorizontalContainer: {
|
||||
case Node::HorizontalContainer:
|
||||
{
|
||||
bool isVertical = this->type_ == Node::VerticalContainer;
|
||||
|
||||
// vars
|
||||
@@ -988,7 +1131,8 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale,
|
||||
QRectF childRect = this->geometry_;
|
||||
|
||||
// add spacing if reqested
|
||||
if (addSpacing) {
|
||||
if (addSpacing)
|
||||
{
|
||||
qreal offset = std::min<qreal>(this->getSize(!isVertical) * 0.1,
|
||||
qreal(_scale * 24));
|
||||
|
||||
@@ -1002,14 +1146,17 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale,
|
||||
isVertical ? Direction::Left : Direction::Above));
|
||||
|
||||
// droprect right / below
|
||||
if (isVertical) {
|
||||
if (isVertical)
|
||||
{
|
||||
dropRects.emplace_back(
|
||||
QRectF(this->geometry_.right() - offset,
|
||||
this->geometry_.top(), offset,
|
||||
this->geometry_.height())
|
||||
.toRect(),
|
||||
Position(this, Direction::Right));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
dropRects.emplace_back(
|
||||
QRectF(this->geometry_.left(),
|
||||
this->geometry_.bottom() - offset,
|
||||
@@ -1019,10 +1166,13 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale,
|
||||
}
|
||||
|
||||
// shrink childRect
|
||||
if (isVertical) {
|
||||
if (isVertical)
|
||||
{
|
||||
childRect.setLeft(childRect.left() + offset);
|
||||
childRect.setRight(childRect.right() - offset);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
childRect.setTop(childRect.top() + offset);
|
||||
childRect.setBottom(childRect.bottom() - offset);
|
||||
}
|
||||
@@ -1030,17 +1180,21 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale,
|
||||
|
||||
// iterate children
|
||||
auto pos = int(isVertical ? childRect.top() : childRect.left());
|
||||
for (std::unique_ptr<Node> &child : this->children_) {
|
||||
for (std::unique_ptr<Node> &child : this->children_)
|
||||
{
|
||||
// set rect
|
||||
QRect rect = childRect.toRect();
|
||||
if (isVertical) {
|
||||
if (isVertical)
|
||||
{
|
||||
rect.setTop(pos);
|
||||
rect.setHeight(
|
||||
std::max<qreal>(this->geometry_.height() / totalFlex *
|
||||
child->flexV_,
|
||||
minSize) *
|
||||
sizeMultiplier);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.setLeft(pos);
|
||||
rect.setWidth(std::max<qreal>(this->geometry_.width() /
|
||||
totalFlex * child->flexH_,
|
||||
@@ -1048,7 +1202,8 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale,
|
||||
sizeMultiplier);
|
||||
}
|
||||
|
||||
if (child == this->children_.back()) {
|
||||
if (child == this->children_.back())
|
||||
{
|
||||
rect.setRight(childRect.right() - 1);
|
||||
rect.setBottom(childRect.bottom() - 1);
|
||||
}
|
||||
@@ -1059,7 +1214,8 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale,
|
||||
pos += child->getSize(isVertical);
|
||||
|
||||
// add resize rect
|
||||
if (child != this->children_.front()) {
|
||||
if (child != this->children_.front())
|
||||
{
|
||||
QRectF r = isVertical ? QRectF(this->geometry_.left(),
|
||||
child->geometry_.top() - 4,
|
||||
this->geometry_.width(), 8)
|
||||
@@ -1071,17 +1227,21 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale,
|
||||
}
|
||||
|
||||
// normalize flex
|
||||
if (isVertical) {
|
||||
if (isVertical)
|
||||
{
|
||||
child->flexV_ =
|
||||
child->flexV_ / totalFlex * this->children_.size();
|
||||
child->flexH_ = 1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
child->flexH_ =
|
||||
child->flexH_ / totalFlex * this->children_.size();
|
||||
child->flexV_ = 1;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1121,12 +1281,16 @@ void SplitContainer::DropOverlay::paintEvent(QPaintEvent *)
|
||||
|
||||
bool foundMover = false;
|
||||
|
||||
for (DropRect &rect : this->rects_) {
|
||||
if (!foundMover && rect.rect.contains(this->mouseOverPoint_)) {
|
||||
for (DropRect &rect : this->rects_)
|
||||
{
|
||||
if (!foundMover && rect.rect.contains(this->mouseOverPoint_))
|
||||
{
|
||||
painter.setBrush(getApp()->themes->splits.dropPreview);
|
||||
painter.setPen(getApp()->themes->splits.dropPreviewBorder);
|
||||
foundMover = true;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
painter.setBrush(QColor(0, 0, 0, 0));
|
||||
painter.setPen(QColor(0, 0, 0, 0));
|
||||
// painter.setPen(getApp()->themes->splits.dropPreviewBorder);
|
||||
@@ -1159,14 +1323,17 @@ void SplitContainer::DropOverlay::dragLeaveEvent(QDragLeaveEvent *)
|
||||
void SplitContainer::DropOverlay::dropEvent(QDropEvent *event)
|
||||
{
|
||||
Position *position = nullptr;
|
||||
for (DropRect &rect : this->rects_) {
|
||||
if (rect.rect.contains(this->mouseOverPoint_)) {
|
||||
for (DropRect &rect : this->rects_)
|
||||
{
|
||||
if (rect.rect.contains(this->mouseOverPoint_))
|
||||
{
|
||||
position = &rect.position;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (position != nullptr) {
|
||||
if (position != nullptr)
|
||||
{
|
||||
this->parent_->insertSplit(SplitContainer::draggingSplit, *position);
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
@@ -1202,10 +1369,13 @@ void SplitContainer::ResizeHandle::paintEvent(QPaintEvent *)
|
||||
painter.fillRect(this->rect(),
|
||||
getApp()->themes->splits.resizeHandleBackground);
|
||||
|
||||
if (this->vertical_) {
|
||||
if (this->vertical_)
|
||||
{
|
||||
painter.drawLine(0, this->height() / 2, this->width(),
|
||||
this->height() / 2);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
painter.drawLine(this->width() / 2, 0, this->width() / 2,
|
||||
this->height());
|
||||
}
|
||||
@@ -1215,7 +1385,8 @@ void SplitContainer::ResizeHandle::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
this->isMouseDown_ = true;
|
||||
|
||||
if (event->button() == Qt::RightButton) {
|
||||
if (event->button() == Qt::RightButton)
|
||||
{
|
||||
this->resetFlex();
|
||||
}
|
||||
}
|
||||
@@ -1227,7 +1398,8 @@ void SplitContainer::ResizeHandle::mouseReleaseEvent(QMouseEvent *)
|
||||
|
||||
void SplitContainer::ResizeHandle::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!this->isMouseDown_) {
|
||||
if (!this->isMouseDown_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1259,7 +1431,8 @@ void SplitContainer::ResizeHandle::mouseMoveEvent(QMouseEvent *event)
|
||||
|
||||
QPoint mousePoint(globalX, globalY);
|
||||
|
||||
if (this->vertical_) {
|
||||
if (this->vertical_)
|
||||
{
|
||||
qreal totalFlexV = this->node->flexV_ + before->flexV_;
|
||||
before->flexV_ = totalFlexV * (mousePoint.y() - topLeft.y()) /
|
||||
(bottomRight.y() - topLeft.y());
|
||||
@@ -1269,7 +1442,9 @@ void SplitContainer::ResizeHandle::mouseMoveEvent(QMouseEvent *event)
|
||||
|
||||
// move handle
|
||||
this->move(this->x(), int(before->geometry_.bottom() - 4));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
qreal totalFlexH = this->node->flexH_ + before->flexH_;
|
||||
before->flexH_ = totalFlexH * (mousePoint.x() - topLeft.x()) /
|
||||
(bottomRight.x() - topLeft.x());
|
||||
@@ -1291,7 +1466,8 @@ void SplitContainer::ResizeHandle::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
|
||||
void SplitContainer::ResizeHandle::resetFlex()
|
||||
{
|
||||
for (auto &sibling : this->node->getParent()->getChildren()) {
|
||||
for (auto &sibling : this->node->getParent()->getChildren())
|
||||
{
|
||||
sibling->flexH_ = 1;
|
||||
sibling->flexV_ = 1;
|
||||
}
|
||||
|
||||
@@ -39,19 +39,24 @@ namespace {
|
||||
{
|
||||
auto modes = channel.accessRoomModes();
|
||||
|
||||
if (modes->r9k) text += "r9k, ";
|
||||
if (modes->r9k)
|
||||
text += "r9k, ";
|
||||
if (modes->slowMode)
|
||||
text +=
|
||||
QString("slow(%1), ").arg(QString::number(modes->slowMode));
|
||||
if (modes->emoteOnly) text += "emote, ";
|
||||
if (modes->submode) text += "sub, ";
|
||||
if (modes->emoteOnly)
|
||||
text += "emote, ";
|
||||
if (modes->submode)
|
||||
text += "sub, ";
|
||||
}
|
||||
|
||||
if (text.length() > 2) {
|
||||
if (text.length() > 2)
|
||||
{
|
||||
text = text.mid(0, text.size() - 2);
|
||||
}
|
||||
|
||||
if (!text.isEmpty()) {
|
||||
if (!text.isEmpty())
|
||||
{
|
||||
static QRegularExpression commaReplacement("^(.+?, .+?,) (.+)$");
|
||||
|
||||
auto match = commaReplacement.match(text);
|
||||
@@ -59,7 +64,8 @@ namespace {
|
||||
text = match.captured(1) + '\n' + match.captured(2);
|
||||
}
|
||||
|
||||
if (text.isEmpty() && channel.hasModRights()) return "none";
|
||||
if (text.isEmpty() && channel.hasModRights())
|
||||
return "none";
|
||||
|
||||
return text;
|
||||
}
|
||||
@@ -93,11 +99,14 @@ namespace {
|
||||
title += " (live)";
|
||||
|
||||
// description
|
||||
if (settings.showUptime) title += " - " + s.uptime;
|
||||
if (settings.showUptime)
|
||||
title += " - " + s.uptime;
|
||||
if (settings.showViewerCount)
|
||||
title += " - " + QString::number(s.viewerCount);
|
||||
if (settings.showGame) title += " - " + s.game;
|
||||
if (settings.showTitle) title += " - " + s.title;
|
||||
if (settings.showGame)
|
||||
title += " - " + s.game;
|
||||
if (settings.showTitle)
|
||||
title += " - " + s.title;
|
||||
|
||||
return title;
|
||||
}
|
||||
@@ -203,7 +212,8 @@ std::unique_ptr<QMenu> SplitHeader::createMainMenu()
|
||||
ChannelPtr _channel = this->split->getChannel();
|
||||
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(_channel.get());
|
||||
|
||||
if (tc != nullptr) {
|
||||
if (tc != nullptr)
|
||||
{
|
||||
StreamView *view = new StreamView(
|
||||
_channel, "https://player.twitch.tv/?channel=" + tc->name);
|
||||
view->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
@@ -280,7 +290,8 @@ std::unique_ptr<QMenu> SplitHeader::createChatModeMenu()
|
||||
[this, setSub, setEmote, setSlow, setR9k]() {
|
||||
auto twitchChannel =
|
||||
dynamic_cast<TwitchChannel *>(this->split_->getChannel().get());
|
||||
if (twitchChannel == nullptr) {
|
||||
if (twitchChannel == nullptr)
|
||||
{
|
||||
this->modeButton_->hide();
|
||||
return;
|
||||
}
|
||||
@@ -308,7 +319,8 @@ std::unique_ptr<QMenu> SplitHeader::createChatModeMenu()
|
||||
[setEmote, toggle]() mutable { toggle("/emoteonly", setEmote); });
|
||||
|
||||
QObject::connect(setSlow, &QAction::triggered, this, [setSlow, this]() {
|
||||
if (!setSlow->isChecked()) {
|
||||
if (!setSlow->isChecked())
|
||||
{
|
||||
this->split_->getChannel().get()->sendMessage("/slowoff");
|
||||
setSlow->setChecked(false);
|
||||
return;
|
||||
@@ -316,10 +328,13 @@ std::unique_ptr<QMenu> SplitHeader::createChatModeMenu()
|
||||
auto ok = bool();
|
||||
auto seconds = QInputDialog::getInt(this, "", "Seconds:", 10, 0, 500, 1,
|
||||
&ok, Qt::FramelessWindowHint);
|
||||
if (ok) {
|
||||
if (ok)
|
||||
{
|
||||
this->split_->getChannel().get()->sendMessage(
|
||||
QString("/slow %1").arg(seconds));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
setSlow->setChecked(false);
|
||||
}
|
||||
});
|
||||
@@ -347,7 +362,8 @@ void SplitHeader::initializeModeSignals(EffectLabel &label)
|
||||
// set the label text
|
||||
auto text = formatRoomMode(*twitchChannel);
|
||||
|
||||
if (!text.isEmpty()) {
|
||||
if (!text.isEmpty())
|
||||
{
|
||||
label.getLabel().setText(text);
|
||||
label.show();
|
||||
return;
|
||||
@@ -363,7 +379,8 @@ void SplitHeader::handleChannelChanged()
|
||||
this->channelConnections_.clear();
|
||||
|
||||
auto channel = this->split_->getChannel();
|
||||
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get())) {
|
||||
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
|
||||
{
|
||||
this->channelConnections_.emplace_back(
|
||||
twitchChannel->liveStatusChanged.connect(
|
||||
[this]() { this->updateChannelText(); }));
|
||||
@@ -397,10 +414,12 @@ void SplitHeader::updateChannelText()
|
||||
if (indirectChannel.getType() == Channel::Type::TwitchWatching)
|
||||
title = "watching: " + (title.isEmpty() ? "none" : title);
|
||||
|
||||
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get())) {
|
||||
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
|
||||
{
|
||||
const auto streamStatus = twitchChannel->accessStreamStatus();
|
||||
|
||||
if (streamStatus->live) {
|
||||
if (streamStatus->live)
|
||||
{
|
||||
this->isLive_ = true;
|
||||
this->tooltipText_ = formatTooltip(*streamStatus);
|
||||
title += formatTitle(*streamStatus, *getSettings());
|
||||
@@ -437,7 +456,8 @@ void SplitHeader::paintEvent(QPaintEvent *)
|
||||
|
||||
void SplitHeader::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
this->dragging_ = true;
|
||||
|
||||
this->dragStart_ = event->pos();
|
||||
@@ -448,14 +468,17 @@ void SplitHeader::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
void SplitHeader::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (this->dragging_ && event->button() == Qt::LeftButton) {
|
||||
if (this->dragging_ && event->button() == Qt::LeftButton)
|
||||
{
|
||||
auto pos = event->globalPos();
|
||||
|
||||
if (!showingHelpTooltip_) {
|
||||
if (!showingHelpTooltip_)
|
||||
{
|
||||
this->showingHelpTooltip_ = true;
|
||||
|
||||
QTimer::singleShot(400, this, [this, pos] {
|
||||
if (this->doubleClicked_) {
|
||||
if (this->doubleClicked_)
|
||||
{
|
||||
this->doubleClicked_ = false;
|
||||
this->showingHelpTooltip_ = false;
|
||||
return;
|
||||
@@ -484,8 +507,10 @@ void SplitHeader::mouseReleaseEvent(QMouseEvent *event)
|
||||
|
||||
void SplitHeader::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (this->dragging_) {
|
||||
if (distance(this->dragStart_, event->pos()) > 15 * this->getScale()) {
|
||||
if (this->dragging_)
|
||||
{
|
||||
if (distance(this->dragStart_, event->pos()) > 15 * this->getScale())
|
||||
{
|
||||
this->split_->drag();
|
||||
this->dragging_ = false;
|
||||
}
|
||||
@@ -494,7 +519,8 @@ void SplitHeader::mouseMoveEvent(QMouseEvent *event)
|
||||
|
||||
void SplitHeader::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
this->split_->changeChannel();
|
||||
}
|
||||
this->doubleClicked_ = true;
|
||||
@@ -502,7 +528,8 @@ void SplitHeader::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
|
||||
void SplitHeader::enterEvent(QEvent *event)
|
||||
{
|
||||
if (!this->tooltipText_.isEmpty()) {
|
||||
if (!this->tooltipText_.isEmpty())
|
||||
{
|
||||
auto tooltip = TooltipWidget::getInstance();
|
||||
tooltip->moveTo(this, this->mapToGlobal(this->rect().bottomLeft()),
|
||||
false);
|
||||
@@ -527,19 +554,25 @@ void SplitHeader::themeChangedEvent()
|
||||
{
|
||||
auto palette = QPalette();
|
||||
|
||||
if (this->split_->hasFocus()) {
|
||||
if (this->split_->hasFocus())
|
||||
{
|
||||
palette.setColor(QPalette::Foreground,
|
||||
this->theme->splits.header.focusedText);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
palette.setColor(QPalette::Foreground, this->theme->splits.header.text);
|
||||
}
|
||||
this->titleLabel_->setPalette(palette);
|
||||
|
||||
// --
|
||||
if (this->theme->isLightTheme()) {
|
||||
if (this->theme->isLightTheme())
|
||||
{
|
||||
this->dropdownButton_->setPixmap(getApp()->resources->buttons.menuDark);
|
||||
this->addButton_->setPixmap(getApp()->resources->buttons.addSplit);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->dropdownButton_->setPixmap(
|
||||
getApp()->resources->buttons.menuLight);
|
||||
this->addButton_->setPixmap(getApp()->resources->buttons.addSplitDark);
|
||||
|
||||
@@ -90,7 +90,8 @@ void SplitInput::initLayout()
|
||||
// clear channelview selection when selecting in the input
|
||||
QObject::connect(this->ui_.textEdit, &QTextEdit::copyAvailable,
|
||||
[this](bool available) {
|
||||
if (available) {
|
||||
if (available)
|
||||
{
|
||||
this->split_->view_->clearSelection();
|
||||
}
|
||||
});
|
||||
@@ -139,7 +140,8 @@ void SplitInput::updateEmoteButton()
|
||||
QString text = "<img src=':/buttons/emote.svg' width='xD' height='xD' />";
|
||||
text.replace("xD", QString::number(int(12 * scale)));
|
||||
|
||||
if (this->theme->isLightTheme()) {
|
||||
if (this->theme->isLightTheme())
|
||||
{
|
||||
text.replace("emote", "emoteDark");
|
||||
}
|
||||
|
||||
@@ -149,17 +151,20 @@ void SplitInput::updateEmoteButton()
|
||||
|
||||
void SplitInput::openEmotePopup()
|
||||
{
|
||||
if (!this->emotePopup_) {
|
||||
if (!this->emotePopup_)
|
||||
{
|
||||
this->emotePopup_ = std::make_unique<EmotePopup>();
|
||||
this->emotePopup_->linkClicked.connect([this](const Link &link) {
|
||||
if (link.type == Link::InsertText) {
|
||||
if (link.type == Link::InsertText)
|
||||
{
|
||||
QTextCursor cursor = this->ui_.textEdit->textCursor();
|
||||
QString textToInsert(link.value + " ");
|
||||
|
||||
// If symbol before cursor isn't space or empty
|
||||
// Then insert space before emote.
|
||||
if (cursor.position() > 0 &&
|
||||
!this->getInputText()[cursor.position() - 1].isSpace()) {
|
||||
!this->getInputText()[cursor.position() - 1].isSpace())
|
||||
{
|
||||
textToInsert = " " + textToInsert;
|
||||
}
|
||||
this->insertText(textToInsert);
|
||||
@@ -179,9 +184,11 @@ void SplitInput::installKeyPressedEvent()
|
||||
auto app = getApp();
|
||||
|
||||
this->ui_.textEdit->keyPressed.connect([this, app](QKeyEvent *event) {
|
||||
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
|
||||
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
|
||||
{
|
||||
auto c = this->split_->getChannel();
|
||||
if (c == nullptr) {
|
||||
if (c == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -198,28 +205,39 @@ void SplitInput::installKeyPressedEvent()
|
||||
this->prevMsg_.append(message);
|
||||
|
||||
event->accept();
|
||||
if (!(event->modifiers() == Qt::ControlModifier)) {
|
||||
if (!(event->modifiers() == Qt::ControlModifier))
|
||||
{
|
||||
this->currMsg_ = QString();
|
||||
this->ui_.textEdit->setText(QString());
|
||||
this->prevIndex_ = 0;
|
||||
} else if (message ==
|
||||
this->prevMsg_.at(this->prevMsg_.size() - 1)) {
|
||||
}
|
||||
else if (message == this->prevMsg_.at(this->prevMsg_.size() - 1))
|
||||
{
|
||||
this->prevMsg_.removeLast();
|
||||
}
|
||||
this->prevIndex_ = this->prevMsg_.size();
|
||||
} else if (event->key() == Qt::Key_Up) {
|
||||
if ((event->modifiers() & Qt::ShiftModifier) != 0) {
|
||||
}
|
||||
else if (event->key() == Qt::Key_Up)
|
||||
{
|
||||
if ((event->modifiers() & Qt::ShiftModifier) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event->modifiers() == Qt::AltModifier) {
|
||||
if (event->modifiers() == Qt::AltModifier)
|
||||
{
|
||||
SplitContainer *page = this->split_->getContainer();
|
||||
|
||||
if (page != nullptr) {
|
||||
if (page != nullptr)
|
||||
{
|
||||
page->selectNextSplit(SplitContainer::Above);
|
||||
}
|
||||
} else {
|
||||
if (this->prevMsg_.size() && this->prevIndex_) {
|
||||
if (this->prevIndex_ == (this->prevMsg_.size())) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->prevMsg_.size() && this->prevIndex_)
|
||||
{
|
||||
if (this->prevIndex_ == (this->prevMsg_.size()))
|
||||
{
|
||||
this->currMsg_ = ui_.textEdit->toPlainText();
|
||||
}
|
||||
|
||||
@@ -232,36 +250,50 @@ void SplitInput::installKeyPressedEvent()
|
||||
this->ui_.textEdit->setTextCursor(cursor);
|
||||
}
|
||||
}
|
||||
} else if (event->key() == Qt::Key_Down) {
|
||||
if ((event->modifiers() & Qt::ShiftModifier) != 0) {
|
||||
}
|
||||
else if (event->key() == Qt::Key_Down)
|
||||
{
|
||||
if ((event->modifiers() & Qt::ShiftModifier) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event->modifiers() == Qt::AltModifier) {
|
||||
if (event->modifiers() == Qt::AltModifier)
|
||||
{
|
||||
SplitContainer *page = this->split_->getContainer();
|
||||
|
||||
if (page != nullptr) {
|
||||
if (page != nullptr)
|
||||
{
|
||||
page->selectNextSplit(SplitContainer::Below);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// If user did not write anything before then just do nothing.
|
||||
if (this->prevMsg_.isEmpty()) {
|
||||
if (this->prevMsg_.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool cursorToEnd = true;
|
||||
QString message = ui_.textEdit->toPlainText();
|
||||
|
||||
if (this->prevIndex_ != (this->prevMsg_.size() - 1) &&
|
||||
this->prevIndex_ != this->prevMsg_.size()) {
|
||||
this->prevIndex_ != this->prevMsg_.size())
|
||||
{
|
||||
this->prevIndex_++;
|
||||
this->ui_.textEdit->setText(
|
||||
this->prevMsg_.at(this->prevIndex_));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->prevIndex_ = this->prevMsg_.size();
|
||||
if (message == this->prevMsg_.at(this->prevIndex_ - 1)) {
|
||||
if (message == this->prevMsg_.at(this->prevIndex_ - 1))
|
||||
{
|
||||
// If user has just come from a message history
|
||||
// Then simply get currMsg_.
|
||||
this->ui_.textEdit->setText(this->currMsg_);
|
||||
} else if (message != this->currMsg_) {
|
||||
}
|
||||
else if (message != this->currMsg_)
|
||||
{
|
||||
// If user are already in current message
|
||||
// And type something new
|
||||
// Then replace currMsg_ with new one.
|
||||
@@ -273,30 +305,42 @@ void SplitInput::installKeyPressedEvent()
|
||||
(message == this->prevMsg_.at(this->prevIndex_ - 1));
|
||||
}
|
||||
|
||||
if (cursorToEnd) {
|
||||
if (cursorToEnd)
|
||||
{
|
||||
QTextCursor cursor = this->ui_.textEdit->textCursor();
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
this->ui_.textEdit->setTextCursor(cursor);
|
||||
}
|
||||
}
|
||||
} else if (event->key() == Qt::Key_Left) {
|
||||
if (event->modifiers() == Qt::AltModifier) {
|
||||
}
|
||||
else if (event->key() == Qt::Key_Left)
|
||||
{
|
||||
if (event->modifiers() == Qt::AltModifier)
|
||||
{
|
||||
SplitContainer *page = this->split_->getContainer();
|
||||
|
||||
if (page != nullptr) {
|
||||
if (page != nullptr)
|
||||
{
|
||||
page->selectNextSplit(SplitContainer::Left);
|
||||
}
|
||||
}
|
||||
} else if (event->key() == Qt::Key_Right) {
|
||||
if (event->modifiers() == Qt::AltModifier) {
|
||||
}
|
||||
else if (event->key() == Qt::Key_Right)
|
||||
{
|
||||
if (event->modifiers() == Qt::AltModifier)
|
||||
{
|
||||
SplitContainer *page = this->split_->getContainer();
|
||||
|
||||
if (page != nullptr) {
|
||||
if (page != nullptr)
|
||||
{
|
||||
page->selectNextSplit(SplitContainer::Right);
|
||||
}
|
||||
}
|
||||
} else if (event->key() == Qt::Key_Tab) {
|
||||
if (event->modifiers() == Qt::ControlModifier) {
|
||||
}
|
||||
else if (event->key() == Qt::Key_Tab)
|
||||
{
|
||||
if (event->modifiers() == Qt::ControlModifier)
|
||||
{
|
||||
SplitContainer *page =
|
||||
static_cast<SplitContainer *>(this->split_->parentWidget());
|
||||
|
||||
@@ -305,9 +349,11 @@ void SplitInput::installKeyPressedEvent()
|
||||
|
||||
notebook->selectNextTab();
|
||||
}
|
||||
} else if (event->key() == Qt::Key_Backtab) {
|
||||
if (event->modifiers() ==
|
||||
(Qt::ControlModifier | Qt::ShiftModifier)) {
|
||||
}
|
||||
else if (event->key() == Qt::Key_Backtab)
|
||||
{
|
||||
if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier))
|
||||
{
|
||||
SplitContainer *page =
|
||||
static_cast<SplitContainer *>(this->split_->parentWidget());
|
||||
|
||||
@@ -316,14 +362,19 @@ void SplitInput::installKeyPressedEvent()
|
||||
|
||||
notebook->selectPreviousTab();
|
||||
}
|
||||
} else if (event->key() == Qt::Key_C &&
|
||||
event->modifiers() == Qt::ControlModifier) {
|
||||
if (this->split_->view_->hasSelection()) {
|
||||
}
|
||||
else if (event->key() == Qt::Key_C &&
|
||||
event->modifiers() == Qt::ControlModifier)
|
||||
{
|
||||
if (this->split_->view_->hasSelection())
|
||||
{
|
||||
this->split_->copyToClipboard();
|
||||
event->accept();
|
||||
}
|
||||
} else if (event->key() == Qt::Key_E &&
|
||||
event->modifiers() == Qt::ControlModifier) {
|
||||
}
|
||||
else if (event->key() == Qt::Key_E &&
|
||||
event->modifiers() == Qt::ControlModifier)
|
||||
{
|
||||
this->openEmotePopup();
|
||||
}
|
||||
});
|
||||
@@ -360,11 +411,14 @@ void SplitInput::editTextChanged()
|
||||
this->split_->getChannel()->isTwitchChannel()) //
|
||||
{
|
||||
QString lastUser = app->twitch.server->lastUserThatWhisperedMe.get();
|
||||
if (!lastUser.isEmpty()) {
|
||||
if (!lastUser.isEmpty())
|
||||
{
|
||||
this->ui_.textEdit->setPlainText("/w " + lastUser + text.mid(2));
|
||||
this->ui_.textEdit->moveCursor(QTextCursor::EndOfBlock);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->textChanged.invoke(text);
|
||||
|
||||
text = text.trimmed();
|
||||
@@ -377,9 +431,12 @@ void SplitInput::editTextChanged()
|
||||
|
||||
QString labelText;
|
||||
|
||||
if (text.length() == 0 || getSettings()->showMessageLength) {
|
||||
if (text.length() == 0 || getSettings()->showMessageLength)
|
||||
{
|
||||
labelText = "";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
labelText = QString::number(text.length());
|
||||
}
|
||||
|
||||
@@ -390,7 +447,8 @@ void SplitInput::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
if (this->theme->isLightTheme()) {
|
||||
if (this->theme->isLightTheme())
|
||||
{
|
||||
int s = int(3 * this->getScale());
|
||||
QRect rect = this->rect().marginsRemoved(QMargins(s - 1, s - 1, s, s));
|
||||
|
||||
@@ -398,7 +456,9 @@ void SplitInput::paintEvent(QPaintEvent *)
|
||||
|
||||
painter.setPen(QColor("#ccc"));
|
||||
painter.drawRect(rect);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
int s = int(1 * this->getScale());
|
||||
QRect rect = this->rect().marginsRemoved(QMargins(s - 1, s - 1, s, s));
|
||||
|
||||
@@ -416,9 +476,12 @@ void SplitInput::paintEvent(QPaintEvent *)
|
||||
|
||||
void SplitInput::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
if (this->height() == this->maximumHeight()) {
|
||||
if (this->height() == this->maximumHeight())
|
||||
{
|
||||
this->ui_.textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui_.textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,31 +95,43 @@ SplitOverlay::SplitOverlay(Split *parent)
|
||||
void SplitOverlay::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
if (this->theme->isLightTheme()) {
|
||||
if (this->theme->isLightTheme())
|
||||
{
|
||||
painter.fillRect(this->rect(), QColor(255, 255, 255, 200));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
painter.fillRect(this->rect(), QColor(0, 0, 0, 150));
|
||||
}
|
||||
|
||||
QRect rect;
|
||||
switch (this->hoveredElement_) {
|
||||
case SplitLeft: {
|
||||
switch (this->hoveredElement_)
|
||||
{
|
||||
case SplitLeft:
|
||||
{
|
||||
rect = QRect(0, 0, this->width() / 2, this->height());
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case SplitRight: {
|
||||
case SplitRight:
|
||||
{
|
||||
rect =
|
||||
QRect(this->width() / 2, 0, this->width() / 2, this->height());
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case SplitUp: {
|
||||
case SplitUp:
|
||||
{
|
||||
rect = QRect(0, 0, this->width(), this->height() / 2);
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case SplitDown: {
|
||||
case SplitDown:
|
||||
{
|
||||
rect =
|
||||
QRect(0, this->height() / 2, this->width(), this->height() / 2);
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:;
|
||||
}
|
||||
@@ -127,7 +139,8 @@ void SplitOverlay::paintEvent(QPaintEvent *)
|
||||
rect.setRight(rect.right() - 1);
|
||||
rect.setBottom(rect.bottom() - 1);
|
||||
|
||||
if (!rect.isNull()) {
|
||||
if (!rect.isNull())
|
||||
{
|
||||
painter.setPen(getApp()->themes->splits.dropPreviewBorder);
|
||||
painter.setBrush(getApp()->themes->splits.dropPreview);
|
||||
painter.drawRect(rect);
|
||||
@@ -169,46 +182,60 @@ SplitOverlay::ButtonEventFilter::ButtonEventFilter(SplitOverlay *_parent,
|
||||
bool SplitOverlay::ButtonEventFilter::eventFilter(QObject *watched,
|
||||
QEvent *event)
|
||||
{
|
||||
switch (event->type()) {
|
||||
case QEvent::Enter: {
|
||||
switch (event->type())
|
||||
{
|
||||
case QEvent::Enter:
|
||||
{
|
||||
QGraphicsOpacityEffect *effect =
|
||||
dynamic_cast<QGraphicsOpacityEffect *>(
|
||||
((QWidget *)watched)->graphicsEffect());
|
||||
|
||||
if (effect != nullptr) {
|
||||
if (effect != nullptr)
|
||||
{
|
||||
effect->setOpacity(0.99);
|
||||
}
|
||||
|
||||
this->parent->hoveredElement_ = this->hoveredElement;
|
||||
this->parent->update();
|
||||
} break;
|
||||
case QEvent::Leave: {
|
||||
}
|
||||
break;
|
||||
case QEvent::Leave:
|
||||
{
|
||||
QGraphicsOpacityEffect *effect =
|
||||
dynamic_cast<QGraphicsOpacityEffect *>(
|
||||
((QWidget *)watched)->graphicsEffect());
|
||||
|
||||
if (effect != nullptr) {
|
||||
if (effect != nullptr)
|
||||
{
|
||||
effect->setOpacity(0.7);
|
||||
}
|
||||
|
||||
this->parent->hoveredElement_ = HoveredElement::None;
|
||||
this->parent->update();
|
||||
} break;
|
||||
case QEvent::MouseButtonPress: {
|
||||
if (this->hoveredElement == HoveredElement::SplitMove) {
|
||||
}
|
||||
break;
|
||||
case QEvent::MouseButtonPress:
|
||||
{
|
||||
if (this->hoveredElement == HoveredElement::SplitMove)
|
||||
{
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
if (mouseEvent->button() == Qt::LeftButton) {
|
||||
if (mouseEvent->button() == Qt::LeftButton)
|
||||
{
|
||||
this->parent->split_->drag();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} break;
|
||||
case QEvent::MouseButtonRelease: {
|
||||
if (this->hoveredElement != HoveredElement::SplitMove) {
|
||||
}
|
||||
break;
|
||||
case QEvent::MouseButtonRelease:
|
||||
{
|
||||
if (this->hoveredElement != HoveredElement::SplitMove)
|
||||
{
|
||||
SplitContainer *container =
|
||||
this->parent->split_->getContainer();
|
||||
|
||||
if (container != nullptr) {
|
||||
if (container != nullptr)
|
||||
{
|
||||
auto *_split = new Split(container);
|
||||
auto dir = SplitContainer::Direction(this->hoveredElement +
|
||||
SplitContainer::Left -
|
||||
@@ -217,7 +244,8 @@ bool SplitOverlay::ButtonEventFilter::eventFilter(QObject *watched,
|
||||
this->parent->hide();
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
return QObject::eventFilter(watched, event);
|
||||
|
||||
Reference in New Issue
Block a user