mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
added stuff related to scaling
This commit is contained in:
parent
66e1952603
commit
866f868b54
|
@ -115,8 +115,9 @@ void NotebookButton::mouseReleaseEvent(QMouseEvent *event)
|
|||
|
||||
void NotebookButton::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
if (!event->mimeData()->hasFormat("chatterino/split"))
|
||||
if (!event->mimeData()->hasFormat("chatterino/split")) {
|
||||
return;
|
||||
}
|
||||
|
||||
event->acceptProposedAction();
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace chatterino {
|
|||
namespace widgets {
|
||||
|
||||
NotebookTab::NotebookTab(Notebook *notebook)
|
||||
: BaseWidget(notebook)
|
||||
: RippleEffectButton(notebook)
|
||||
, positionChangedAnimation_(this, "pos")
|
||||
, notebook_(notebook)
|
||||
, menu_(this)
|
||||
|
@ -68,6 +68,9 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
|||
void NotebookTab::themeRefreshEvent()
|
||||
{
|
||||
this->update();
|
||||
|
||||
// this->setMouseEffectColor(QColor("#999"));
|
||||
this->setMouseEffectColor(this->themeManager->tabs.regular.text);
|
||||
}
|
||||
|
||||
void NotebookTab::updateSize()
|
||||
|
@ -234,9 +237,9 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
|||
bool windowFocused = this->window() == QApplication::activeWindow();
|
||||
// || SettingsDialog::getHandle() == QApplication::activeWindow();
|
||||
|
||||
QBrush tabBackground = this->mouseOver_ ? colors.backgrounds.hover
|
||||
: (windowFocused ? colors.backgrounds.regular
|
||||
: colors.backgrounds.unfocused);
|
||||
QBrush tabBackground = /*this->mouseOver_ ? colors.backgrounds.hover
|
||||
:*/ (windowFocused ? colors.backgrounds.regular
|
||||
: colors.backgrounds.unfocused);
|
||||
|
||||
// painter.fillRect(rect(), this->mouseOver_ ? regular.backgrounds.hover
|
||||
// : (windowFocused ? regular.backgrounds.regular
|
||||
|
@ -312,6 +315,8 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
|||
// draw line at bottom
|
||||
if (!this->selected_) {
|
||||
painter.fillRect(0, this->height() - 1, this->width(), 1, app->themes->window.background);
|
||||
|
||||
this->fancyPaint(painter);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -373,19 +378,23 @@ void NotebookTab::mouseReleaseEvent(QMouseEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
void NotebookTab::enterEvent(QEvent *)
|
||||
void NotebookTab::enterEvent(QEvent *event)
|
||||
{
|
||||
this->mouseOver_ = true;
|
||||
|
||||
this->update();
|
||||
|
||||
RippleEffectButton::enterEvent(event);
|
||||
}
|
||||
|
||||
void NotebookTab::leaveEvent(QEvent *)
|
||||
void NotebookTab::leaveEvent(QEvent *event)
|
||||
{
|
||||
this->mouseOverX_ = false;
|
||||
this->mouseOver_ = false;
|
||||
|
||||
this->update();
|
||||
|
||||
RippleEffectButton::leaveEvent(event);
|
||||
}
|
||||
|
||||
void NotebookTab::dragEnterEvent(QDragEnterEvent *event)
|
||||
|
@ -429,6 +438,8 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event)
|
|||
this->notebook_->rearrangePage(this->page, index);
|
||||
}
|
||||
}
|
||||
|
||||
RippleEffectButton::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
QRect NotebookTab::getXRect()
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "common.hpp"
|
||||
#include "widgets/basewidget.hpp"
|
||||
#include "widgets/helper/rippleeffectbutton.hpp"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QPropertyAnimation>
|
||||
|
@ -17,7 +18,7 @@ namespace widgets {
|
|||
class Notebook;
|
||||
class SplitContainer;
|
||||
|
||||
class NotebookTab : public BaseWidget
|
||||
class NotebookTab : public RippleEffectButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ void RippleEffectButton::fancyPaint(QPainter &painter)
|
|||
QRadialGradient gradient(QPointF(mousePos_), this->width() / 2);
|
||||
|
||||
gradient.setColorAt(0,
|
||||
QColor(c.red(), c.green(), c.blue(), int(60 * this->hoverMultiplier_)));
|
||||
QColor(c.red(), c.green(), c.blue(), int(50 * this->hoverMultiplier_)));
|
||||
gradient.setColorAt(1,
|
||||
QColor(c.red(), c.green(), c.blue(), int(40 * this->hoverMultiplier_)));
|
||||
|
||||
|
@ -97,7 +97,7 @@ void RippleEffectButton::fancyPaint(QPainter &painter)
|
|||
|
||||
for (auto effect : this->clickEffects_) {
|
||||
QRadialGradient gradient(effect.position.x(), effect.position.y(),
|
||||
effect.progress * float(width()) * 2, effect.position.x(),
|
||||
effect.progress * qreal(width()) * 2, effect.position.x(),
|
||||
effect.position.y());
|
||||
|
||||
gradient.setColorAt(0,
|
||||
|
|
|
@ -91,7 +91,7 @@ void Label::paintEvent(QPaintEvent *)
|
|||
painter.setFont(
|
||||
app->fonts->getFont(this->getFontStyle(), this->getScale() * this->devicePixelRatioF()));
|
||||
|
||||
int offset = this->hasOffset_ ? int(8 * this->getScale()) : 0;
|
||||
int offset = this->getOffset();
|
||||
|
||||
// draw text
|
||||
QRect textRect(offset, 0, this->width() - offset - offset, this->height());
|
||||
|
@ -112,10 +112,17 @@ void Label::updateSize()
|
|||
|
||||
QFontMetrics metrics = app->fonts->getFontMetrics(this->fontStyle_, this->getScale());
|
||||
|
||||
this->preferedSize_ = QSize(metrics.width(this->text_), metrics.height());
|
||||
int width = metrics.width(this->text_) + (2 * this->getOffset());
|
||||
int height = metrics.height();
|
||||
this->preferedSize_ = QSize(width, height);
|
||||
|
||||
this->updateGeometry();
|
||||
}
|
||||
|
||||
int Label::getOffset()
|
||||
{
|
||||
return this->hasOffset_ ? int(8 * this->getScale()) : 0;
|
||||
}
|
||||
|
||||
} // namespace widgets
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -40,6 +40,7 @@ private:
|
|||
bool hasOffset_ = true;
|
||||
|
||||
void updateSize();
|
||||
int getOffset();
|
||||
};
|
||||
|
||||
} // namespace widgets
|
||||
|
|
|
@ -340,7 +340,7 @@ void Notebook::performLayout(bool animated)
|
|||
x += i->tab->width();
|
||||
}
|
||||
|
||||
x += int(scale * 2);
|
||||
x += int(scale * 1);
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "util/urlfetch.hpp"
|
||||
#include "widgets/helper/line.hpp"
|
||||
#include "widgets/helper/rippleeffectlabel.hpp"
|
||||
#include "widgets/label.hpp"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDesktopServices>
|
||||
|
@ -32,9 +33,8 @@ UserInfoPopup::UserInfoPopup()
|
|||
auto head = layout.emplace<QHBoxLayout>().withoutMargin();
|
||||
{
|
||||
// avatar
|
||||
// auto avatar = head.emplace<QLabel>("Avatar").assign(&this->ui_.avatarButtoAn);
|
||||
auto avatar = head.emplace<RippleEffectButton>(nullptr).assign(&this->ui_.avatarButton);
|
||||
avatar->setFixedSize(100, 100);
|
||||
avatar->setScaleIndependantSize(100, 100);
|
||||
QObject::connect(*avatar, &RippleEffectButton::clicked, [this] {
|
||||
QDesktopServices::openUrl(QUrl("https://twitch.tv/" + this->userName_));
|
||||
});
|
||||
|
@ -42,14 +42,14 @@ UserInfoPopup::UserInfoPopup()
|
|||
// items on the right
|
||||
auto vbox = head.emplace<QVBoxLayout>();
|
||||
{
|
||||
auto name = vbox.emplace<QLabel>().assign(&this->ui_.nameLabel);
|
||||
auto name = vbox.emplace<Label>().assign(&this->ui_.nameLabel);
|
||||
|
||||
auto font = name->font();
|
||||
font.setBold(true);
|
||||
name->setFont(font);
|
||||
vbox.emplace<QLabel>(TEXT_VIEWS).assign(&this->ui_.viewCountLabel);
|
||||
vbox.emplace<QLabel>(TEXT_FOLLOWERS).assign(&this->ui_.followerCountLabel);
|
||||
vbox.emplace<QLabel>(TEXT_CREATED).assign(&this->ui_.createdDateLabel);
|
||||
vbox.emplace<Label>(TEXT_VIEWS).assign(&this->ui_.viewCountLabel);
|
||||
vbox.emplace<Label>(TEXT_FOLLOWERS).assign(&this->ui_.followerCountLabel);
|
||||
vbox.emplace<Label>(TEXT_CREATED).assign(&this->ui_.createdDateLabel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -302,7 +302,6 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget()
|
|||
QColor color2(255, 255, 255, 0);
|
||||
|
||||
int buttonWidth = 32;
|
||||
int buttonWidth2 = 24;
|
||||
int buttonHeight = 32;
|
||||
|
||||
layout->setSpacing(16);
|
||||
|
@ -312,7 +311,7 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget()
|
|||
{
|
||||
auto title = vbox.emplace<QHBoxLayout>().withoutMargin();
|
||||
title->addStretch(1);
|
||||
auto label = title.emplace<QLabel>(text);
|
||||
auto label = title.emplace<Label>(text);
|
||||
label->setStyleSheet("color: #BBB");
|
||||
title->addStretch(1);
|
||||
|
||||
|
@ -337,7 +336,7 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget()
|
|||
{
|
||||
auto title = vbox.emplace<QHBoxLayout>().withoutMargin();
|
||||
title->addStretch(1);
|
||||
auto label = title.emplace<QLabel>(title_);
|
||||
auto label = title.emplace<Label>(title_);
|
||||
label->setStyleSheet("color: #BBB");
|
||||
title->addStretch(1);
|
||||
|
||||
|
|
|
@ -5,12 +5,13 @@
|
|||
|
||||
#include <pajlada/signals/signal.hpp>
|
||||
|
||||
class QLabel;
|
||||
class QCheckBox;
|
||||
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
|
||||
class Label;
|
||||
|
||||
class UserInfoPopup final : public BaseWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -43,10 +44,10 @@ private:
|
|||
struct {
|
||||
RippleEffectButton *avatarButton = nullptr;
|
||||
|
||||
QLabel *nameLabel = nullptr;
|
||||
QLabel *viewCountLabel = nullptr;
|
||||
QLabel *followerCountLabel = nullptr;
|
||||
QLabel *createdDateLabel = nullptr;
|
||||
Label *nameLabel = nullptr;
|
||||
Label *viewCountLabel = nullptr;
|
||||
Label *followerCountLabel = nullptr;
|
||||
Label *createdDateLabel = nullptr;
|
||||
|
||||
QCheckBox *follow = nullptr;
|
||||
QCheckBox *ignore = nullptr;
|
||||
|
|
Loading…
Reference in a new issue