mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Fixed stuff in user popup
This commit is contained in:
parent
b441e3e159
commit
5c0f81defd
8 changed files with 65 additions and 54 deletions
|
@ -161,6 +161,8 @@ Fonts::FontData Fonts::createFontData(FontStyle type, float scale)
|
||||||
{FontStyle::Tiny, {8, "Monospace", false, QFont::Normal}},
|
{FontStyle::Tiny, {8, "Monospace", false, QFont::Normal}},
|
||||||
{FontStyle::UiMedium,
|
{FontStyle::UiMedium,
|
||||||
{int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Normal}},
|
{int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Normal}},
|
||||||
|
{FontStyle::UiMediumBold,
|
||||||
|
{int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Bold}},
|
||||||
{FontStyle::UiTabs,
|
{FontStyle::UiTabs,
|
||||||
{int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Normal}},
|
{int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Normal}},
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,6 +28,7 @@ enum class FontStyle : uint8_t {
|
||||||
ChatVeryLarge,
|
ChatVeryLarge,
|
||||||
|
|
||||||
UiMedium,
|
UiMedium,
|
||||||
|
UiMediumBold,
|
||||||
UiTabs,
|
UiTabs,
|
||||||
|
|
||||||
// don't remove this value
|
// don't remove this value
|
||||||
|
|
|
@ -100,6 +100,8 @@ void Label::paintEvent(QPaintEvent *)
|
||||||
? Qt::AlignLeft | Qt::AlignVCenter
|
? Qt::AlignLeft | Qt::AlignVCenter
|
||||||
: Qt::AlignCenter;
|
: Qt::AlignCenter;
|
||||||
|
|
||||||
|
painter.setBrush(this->palette().windowText());
|
||||||
|
|
||||||
QTextOption option(alignment);
|
QTextOption option(alignment);
|
||||||
option.setWrapMode(QTextOption::NoWrap);
|
option.setWrapMode(QTextOption::NoWrap);
|
||||||
painter.drawText(textRect, this->text_, option);
|
painter.drawText(textRect, this->text_, option);
|
||||||
|
|
|
@ -38,14 +38,14 @@ const QPixmap &Button::getPixmap() const
|
||||||
return this->pixmap_;
|
return this->pixmap_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::setDim(bool value)
|
void Button::setDim(Dim value)
|
||||||
{
|
{
|
||||||
this->dimPixmap_ = value;
|
this->dimPixmap_ = value;
|
||||||
|
|
||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Button::getDim() const
|
Button::Dim Button::getDim() const
|
||||||
{
|
{
|
||||||
return this->dimPixmap_;
|
return this->dimPixmap_;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,12 @@ bool Button::getEnableMargin() const
|
||||||
|
|
||||||
qreal Button::getCurrentDimAmount() const
|
qreal Button::getCurrentDimAmount() const
|
||||||
{
|
{
|
||||||
return this->dimPixmap_ && !this->mouseOver_ ? 0.7 : 1;
|
if (this->dimPixmap_ == Dim::None || this->mouseOver_)
|
||||||
|
return 1;
|
||||||
|
else if (this->dimPixmap_ == Dim::Some)
|
||||||
|
return 0.7;
|
||||||
|
else
|
||||||
|
return 0.15;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::setBorderColor(const QColor &color)
|
void Button::setBorderColor(const QColor &color)
|
||||||
|
@ -114,13 +119,13 @@ void Button::paintEvent(QPaintEvent *)
|
||||||
|
|
||||||
if (!this->pixmap_.isNull())
|
if (!this->pixmap_.isNull())
|
||||||
{
|
{
|
||||||
if (!this->mouseOver_ && this->dimPixmap_ && this->enabled_)
|
painter.setOpacity(this->getCurrentDimAmount());
|
||||||
{
|
|
||||||
painter.setOpacity(this->getCurrentDimAmount());
|
|
||||||
}
|
|
||||||
|
|
||||||
QRect rect = this->rect();
|
QRect rect = this->rect();
|
||||||
int s = this->enableMargin_ ? int(6 * this->scale()) : 0;
|
|
||||||
|
int margin = this->height() < 22 * this->scale() ? 3 : 6;
|
||||||
|
|
||||||
|
int s = this->enableMargin_ ? int(margin * this->scale()) : 0;
|
||||||
|
|
||||||
rect.moveLeft(s);
|
rect.moveLeft(s);
|
||||||
rect.setRight(rect.right() - s - s);
|
rect.setRight(rect.right() - s - s);
|
||||||
|
|
|
@ -28,14 +28,16 @@ class Button : public BaseWidget
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum class Dim { None, Some, Lots };
|
||||||
|
|
||||||
Button(BaseWidget *parent = nullptr);
|
Button(BaseWidget *parent = nullptr);
|
||||||
|
|
||||||
void setMouseEffectColor(boost::optional<QColor> color);
|
void setMouseEffectColor(boost::optional<QColor> color);
|
||||||
void setPixmap(const QPixmap &pixmap_);
|
void setPixmap(const QPixmap &pixmap_);
|
||||||
const QPixmap &getPixmap() const;
|
const QPixmap &getPixmap() const;
|
||||||
|
|
||||||
void setDim(bool value);
|
void setDim(Dim value);
|
||||||
bool getDim() const;
|
Dim getDim() const;
|
||||||
qreal getCurrentDimAmount() const;
|
qreal getCurrentDimAmount() const;
|
||||||
|
|
||||||
void setEnable(bool value);
|
void setEnable(bool value);
|
||||||
|
@ -76,7 +78,7 @@ private:
|
||||||
|
|
||||||
QColor borderColor_{};
|
QColor borderColor_{};
|
||||||
QPixmap pixmap_{};
|
QPixmap pixmap_{};
|
||||||
bool dimPixmap_{true};
|
Dim dimPixmap_{Dim::Some};
|
||||||
bool enableMargin_{true};
|
bool enableMargin_{true};
|
||||||
QPoint mousePos_{};
|
QPoint mousePos_{};
|
||||||
double hoverMultiplier_{0.0};
|
double hoverMultiplier_{0.0};
|
||||||
|
|
|
@ -24,9 +24,23 @@
|
||||||
#define TEXT_FOLLOWERS "Followers: "
|
#define TEXT_FOLLOWERS "Followers: "
|
||||||
#define TEXT_VIEWS "Views: "
|
#define TEXT_VIEWS "Views: "
|
||||||
#define TEXT_CREATED "Created: "
|
#define TEXT_CREATED "Created: "
|
||||||
#define TEXT_USER_ID "User ID: "
|
#define TEXT_USER_ID "ID: "
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace {
|
||||||
|
void addCopyableLabel(LayoutCreator<QHBoxLayout> box, Label **assign)
|
||||||
|
{
|
||||||
|
auto label = box.emplace<Label>().assign(assign);
|
||||||
|
auto button = box.emplace<Button>();
|
||||||
|
button->setPixmap(getApp()->resources->buttons.copyDark);
|
||||||
|
button->setScaleIndependantSize(18, 18);
|
||||||
|
button->setDim(Button::Dim::Lots);
|
||||||
|
QObject::connect(button.getElement(), &Button::leftClicked,
|
||||||
|
[label = label.getElement()] {
|
||||||
|
qApp->clipboard()->setText(label->getText());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
UserInfoPopup::UserInfoPopup()
|
UserInfoPopup::UserInfoPopup()
|
||||||
: BaseWindow(nullptr, BaseWindow::Flags(BaseWindow::Frameless |
|
: BaseWindow(nullptr, BaseWindow::Flags(BaseWindow::Frameless |
|
||||||
|
@ -51,6 +65,7 @@ UserInfoPopup::UserInfoPopup()
|
||||||
auto avatar =
|
auto avatar =
|
||||||
head.emplace<Button>(nullptr).assign(&this->ui_.avatarButton);
|
head.emplace<Button>(nullptr).assign(&this->ui_.avatarButton);
|
||||||
avatar->setScaleIndependantSize(100, 100);
|
avatar->setScaleIndependantSize(100, 100);
|
||||||
|
avatar->setDim(Button::Dim::None);
|
||||||
QObject::connect(avatar.getElement(), &Button::leftClicked, [this] {
|
QObject::connect(avatar.getElement(), &Button::leftClicked, [this] {
|
||||||
QDesktopServices::openUrl(
|
QDesktopServices::openUrl(
|
||||||
QUrl("https://twitch.tv/" + this->userName_.toLower()));
|
QUrl("https://twitch.tv/" + this->userName_.toLower()));
|
||||||
|
@ -59,50 +74,24 @@ UserInfoPopup::UserInfoPopup()
|
||||||
// items on the right
|
// items on the right
|
||||||
auto vbox = head.emplace<QVBoxLayout>();
|
auto vbox = head.emplace<QVBoxLayout>();
|
||||||
{
|
{
|
||||||
auto name_box = vbox.emplace<QHBoxLayout>();
|
{
|
||||||
name_box.withoutMargin();
|
auto box = vbox.emplace<QHBoxLayout>()
|
||||||
|
.withoutMargin()
|
||||||
auto name = name_box.emplace<Label>().assign(&this->ui_.nameLabel);
|
.withoutSpacing();
|
||||||
LayoutCreator<EffectLabel2> copyUserName =
|
addCopyableLabel(box, &this->ui_.nameLabel);
|
||||||
name_box.emplace<EffectLabel2>(this);
|
this->ui_.nameLabel->setFontStyle(FontStyle::UiMediumBold);
|
||||||
copyUserName->setPixmap(app->resources->buttons.copyDark);
|
box->addStretch(1);
|
||||||
// TODO(mm2pl): change this when the card get themed.
|
addCopyableLabel(box, &this->ui_.userIDLabel);
|
||||||
|
auto palette = QPalette();
|
||||||
copyUserName->setScaleIndependantSize(32, 32);
|
palette.setColor(QPalette::WindowText, QColor("#aaa"));
|
||||||
|
this->ui_.userIDLabel->setPalette(palette);
|
||||||
auto font = name->font();
|
}
|
||||||
font.setBold(true);
|
|
||||||
name->setFont(font);
|
|
||||||
|
|
||||||
name_box->addStretch(1);
|
|
||||||
|
|
||||||
QObject::connect(
|
|
||||||
copyUserName.getElement(), &Button::leftClicked, [this] {
|
|
||||||
QClipboard *clipboard = QGuiApplication::clipboard();
|
|
||||||
clipboard->setText(this->userName_);
|
|
||||||
});
|
|
||||||
|
|
||||||
vbox.emplace<Label>(TEXT_VIEWS).assign(&this->ui_.viewCountLabel);
|
vbox.emplace<Label>(TEXT_VIEWS).assign(&this->ui_.viewCountLabel);
|
||||||
vbox.emplace<Label>(TEXT_FOLLOWERS)
|
vbox.emplace<Label>(TEXT_FOLLOWERS)
|
||||||
.assign(&this->ui_.followerCountLabel);
|
.assign(&this->ui_.followerCountLabel);
|
||||||
vbox.emplace<Label>(TEXT_CREATED)
|
vbox.emplace<Label>(TEXT_CREATED)
|
||||||
.assign(&this->ui_.createdDateLabel);
|
.assign(&this->ui_.createdDateLabel);
|
||||||
|
|
||||||
auto userIDBox = vbox.emplace<QHBoxLayout>().withoutMargin();
|
|
||||||
userIDBox.emplace<Label>(TEXT_USER_ID)
|
|
||||||
.assign(&this->ui_.userIDLabel);
|
|
||||||
LayoutCreator<EffectLabel2> copyUserID =
|
|
||||||
userIDBox.emplace<EffectLabel2>(this);
|
|
||||||
copyUserID->setPixmap(app->resources->buttons.copyDark);
|
|
||||||
// this will need to be changed too if there will be theming.
|
|
||||||
copyUserID->setScaleIndependantSize(32, 32);
|
|
||||||
userIDBox->addStretch(1);
|
|
||||||
|
|
||||||
QObject::connect(
|
|
||||||
copyUserID.getElement(), &Button::leftClicked, [this] {
|
|
||||||
QClipboard *clipboard = QGuiApplication::clipboard();
|
|
||||||
clipboard->setText(this->userId_);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +223,7 @@ UserInfoPopup::UserInfoPopup()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this->setStyleSheet("font-size: 11pt;");
|
// this->setStyleSheet("font-size: 11pt;");
|
||||||
|
|
||||||
this->installEvents();
|
this->installEvents();
|
||||||
}
|
}
|
||||||
|
@ -243,7 +232,17 @@ void UserInfoPopup::themeChangedEvent()
|
||||||
{
|
{
|
||||||
BaseWindow::themeChangedEvent();
|
BaseWindow::themeChangedEvent();
|
||||||
|
|
||||||
this->setStyleSheet("background: #333");
|
this->setStyleSheet(
|
||||||
|
"background: #333; font-size: " +
|
||||||
|
QString::number(getFonts()
|
||||||
|
->getFont(FontStyle::UiMediumBold, this->scale())
|
||||||
|
.pixelSize()) +
|
||||||
|
"px;");
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserInfoPopup::scaleChangedEvent(float /*scale*/)
|
||||||
|
{
|
||||||
|
themeChangedEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserInfoPopup::installEvents()
|
void UserInfoPopup::installEvents()
|
||||||
|
|
|
@ -23,6 +23,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void themeChangedEvent() override;
|
virtual void themeChangedEvent() override;
|
||||||
|
virtual void scaleChangedEvent(float scale) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void installEvents();
|
void installEvents();
|
||||||
|
|
|
@ -189,7 +189,6 @@ void SplitHeader::initializeLayout()
|
||||||
SettingsDialogPreference::
|
SettingsDialogPreference::
|
||||||
ModerationActions);
|
ModerationActions);
|
||||||
this->split_->setModerationMode(true);
|
this->split_->setModerationMode(true);
|
||||||
w->setDim(true);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -198,7 +197,7 @@ void SplitHeader::initializeLayout()
|
||||||
|
|
||||||
this->split_->setModerationMode(
|
this->split_->setModerationMode(
|
||||||
!moderationMode);
|
!moderationMode);
|
||||||
w->setDim(moderationMode);
|
w->setDim(Button::Dim(moderationMode));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue