Merge remote-tracking branch 'main_repo/master' into git_is_pepega

check if works with new changes from master
This commit is contained in:
Mm2PL 2020-04-29 00:42:12 +02:00
commit 84007d2edb
17 changed files with 108 additions and 56 deletions

View file

@ -24,8 +24,18 @@ jobs:
with: with:
submodules: true submodules: true
- name: Cache Qt
id: cache-qt
uses: actions/cache@v1
with:
path: ../Qt
key: ${{ runner.os }}-QtCache
- name: Install Qt - name: Install Qt
uses: jurplel/install-qt-action@v1 uses: jurplel/install-qt-action@v2
with:
mirror: 'http://mirrors.ocf.berkeley.edu/qt/'
cached: ${{ steps.cache-qt.outputs.cache-hit }}
# WINDOWS # WINDOWS
- name: Cache conan - name: Cache conan

View file

@ -120,14 +120,16 @@ void HighlightModel::afterInit()
std::vector<QStandardItem *> redeemedRow = this->createRow(); std::vector<QStandardItem *> redeemedRow = this->createRow();
setBoolItem(redeemedRow[Column::Pattern], setBoolItem(redeemedRow[Column::Pattern],
getSettings()->enableRedeemedHighlight.getValue(), true, false); getSettings()->enableRedeemedHighlight.getValue(), true, false);
redeemedRow[Column::Pattern]->setData("Highlights redeemed with Bits", redeemedRow[Column::Pattern]->setData(
Qt::DisplayRole); "Highlights redeemed with Channel Points", Qt::DisplayRole);
setBoolItem(redeemedRow[Column::FlashTaskbar], // setBoolItem(redeemedRow[Column::FlashTaskbar],
getSettings()->enableRedeemedHighlightTaskbar.getValue(), true, // getSettings()->enableRedeemedHighlightTaskbar.getValue(), true,
false); // false);
setBoolItem(redeemedRow[Column::PlaySound], // setBoolItem(redeemedRow[Column::PlaySound],
getSettings()->enableRedeemedHighlightSound.getValue(), true, // getSettings()->enableRedeemedHighlightSound.getValue(), true,
false); // false);
redeemedRow[Column::FlashTaskbar]->setFlags(0);
redeemedRow[Column::PlaySound]->setFlags(0);
redeemedRow[Column::UseRegex]->setFlags(0); redeemedRow[Column::UseRegex]->setFlags(0);
redeemedRow[Column::CaseSensitive]->setFlags(0); redeemedRow[Column::CaseSensitive]->setFlags(0);
@ -192,8 +194,8 @@ void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
} }
else if (rowIndex == 3) else if (rowIndex == 3)
{ {
getSettings()->enableRedeemedHighlightTaskbar.setValue( // getSettings()->enableRedeemedHighlightTaskbar.setValue(
value.toBool()); // value.toBool());
} }
} }
} }
@ -218,8 +220,8 @@ void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
} }
else if (rowIndex == 3) else if (rowIndex == 3)
{ {
getSettings()->enableRedeemedHighlightSound.setValue( // getSettings()->enableRedeemedHighlightSound.setValue(
value.toBool()); // value.toBool());
} }
} }
} }

View file

@ -46,8 +46,16 @@ namespace detail {
this->items_.begin(), this->items_.end(), 0UL, this->items_.begin(), this->items_.end(), 0UL,
[](auto init, auto &&frame) { return init + frame.duration; }); [](auto init, auto &&frame) { return init + frame.duration; });
if (totalLength == 0)
{
this->durationOffset_ = 0;
}
else
{
this->durationOffset_ = std::min<int>( this->durationOffset_ = std::min<int>(
int(getApp()->emotes->gifTimer.position() % totalLength), 60000); int(getApp()->emotes->gifTimer.position() % totalLength),
60000);
}
this->processOffset(); this->processOffset();
} }
@ -72,6 +80,11 @@ namespace detail {
void Frames::processOffset() void Frames::processOffset()
{ {
if (this->items_.isEmpty())
{
return;
}
while (true) while (true)
{ {
this->index_ %= this->items_.size(); this->index_ %= this->items_.size();

View file

@ -53,7 +53,10 @@ static float relativeSimilarity(const QString &str1, const QString &str2)
} }
} }
return z == 0 ? 0.f : float(z) / std::max(str1.size(), str2.size()); // ensure that no div by 0
return z == 0 ? 0.f
: float(z) /
std::max<int>(1, std::max(str1.size(), str2.size()));
}; };
float IrcMessageHandler::similarity( float IrcMessageHandler::similarity(

View file

@ -60,6 +60,7 @@ QColor getRandomColor(const QVariant &userId)
colorSeed = std::rand(); colorSeed = std::rand();
} }
assert(twitchUsernameColors.size() != 0);
const auto colorIndex = colorSeed % twitchUsernameColors.size(); const auto colorIndex = colorSeed % twitchUsernameColors.size();
return twitchUsernameColors[colorIndex]; return twitchUsernameColors[colorIndex];
} }

View file

@ -207,10 +207,10 @@ public:
BoolSetting enableRedeemedHighlight = { BoolSetting enableRedeemedHighlight = {
"/highlighting/redeemedHighlight/highlighted", true}; "/highlighting/redeemedHighlight/highlighted", true};
BoolSetting enableRedeemedHighlightSound = { // BoolSetting enableRedeemedHighlightSound = {
"/highlighting/redeemedHighlight/enableSound", false}; // "/highlighting/redeemedHighlight/enableSound", false};
BoolSetting enableRedeemedHighlightTaskbar = { // BoolSetting enableRedeemedHighlightTaskbar = {
"/highlighting/redeemedHighlight/enableTaskbarFlashing", false}; // "/highlighting/redeemedHighlight/enableTaskbarFlashing", false};
QStringSetting redeemedHighlightSoundUrl = { QStringSetting redeemedHighlightSoundUrl = {
"/highlighting/redeemedHighlightSoundUrl", ""}; "/highlighting/redeemedHighlightSoundUrl", ""};
QStringSetting redeemedHighlightColor = { QStringSetting redeemedHighlightColor = {

View file

@ -445,6 +445,8 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
[this](auto, auto) { this->forceLayoutChannelViews(); }); [this](auto, auto) { this->forceLayoutChannelViews(); });
settings.collpseMessagesMinLines.connect( settings.collpseMessagesMinLines.connect(
[this](auto, auto) { this->forceLayoutChannelViews(); }); [this](auto, auto) { this->forceLayoutChannelViews(); });
settings.enableRedeemedHighlight.connect(
[this](auto, auto) { this->forceLayoutChannelViews(); });
this->initialized_ = true; this->initialized_ = true;
} }

View file

@ -9,6 +9,7 @@
#include <QIcon> #include <QIcon>
#include <QLayout> #include <QLayout>
#include <QtGlobal> #include <QtGlobal>
#include <algorithm>
namespace chatterino { namespace chatterino {
@ -113,7 +114,8 @@ float BaseWidget::qtFontScale() const
{ {
if (auto window = dynamic_cast<BaseWindow *>(this->window())) if (auto window = dynamic_cast<BaseWindow *>(this->window()))
{ {
return this->scale() / window->nativeScale_; // ensure no div by 0
return this->scale() / std::max<float>(0.01f, window->nativeScale_);
} }
else else
{ {

View file

@ -104,12 +104,12 @@ QRect BaseWindow::getBounds()
float BaseWindow::scale() const float BaseWindow::scale() const
{ {
return this->overrideScale().value_or(this->scale_); return std::max<float>(0.01f, this->overrideScale().value_or(this->scale_));
} }
float BaseWindow::qtFontScale() const float BaseWindow::qtFontScale() const
{ {
return this->scale() / this->nativeScale_; return this->scale() / std::max<float>(0.01, this->nativeScale_);
} }
void BaseWindow::init() void BaseWindow::init()

View file

@ -93,10 +93,12 @@ void Label::paintEvent(QPaintEvent *)
QFontMetrics metrics = getFonts()->getFontMetrics( QFontMetrics metrics = getFonts()->getFontMetrics(
this->getFontStyle(), this->getFontStyle(),
this->scale() * 96.f / this->logicalDpiX() * deviceDpi); this->scale() * 96.f /
std::max<float>(0.01, this->logicalDpiX() * deviceDpi));
painter.setFont(getFonts()->getFont( painter.setFont(getFonts()->getFont(
this->getFontStyle(), this->getFontStyle(),
this->scale() * 96.f / this->logicalDpiX() * deviceDpi)); this->scale() * 96.f /
std::max<float>(0.02, this->logicalDpiX() * deviceDpi)));
int offset = this->getOffset(); int offset = this->getOffset();

View file

@ -357,7 +357,9 @@ void Scrollbar::mouseMoveEvent(QMouseEvent *event)
int delta = event->pos().y() - this->lastMousePosition_.y(); int delta = event->pos().y() - this->lastMousePosition_.y();
setDesiredValue(this->desiredValue_ + setDesiredValue(this->desiredValue_ +
qreal(delta) / this->trackHeight_ * this->maximum_); qreal(delta) /
std::max<qreal>(0.00000002, this->trackHeight_ *
this->maximum_));
} }
this->lastMousePosition_ = event->pos(); this->lastMousePosition_ = event->pos();
@ -442,13 +444,14 @@ void Scrollbar::updateScroll()
this->trackHeight_ = this->height() - this->buttonHeight_ - this->trackHeight_ = this->height() - this->buttonHeight_ -
this->buttonHeight_ - MIN_THUMB_HEIGHT - 1; this->buttonHeight_ - MIN_THUMB_HEIGHT - 1;
this->thumbRect_ = auto div = std::max<qreal>(0.0000001, this->maximum_);
QRect(0,
int(this->currentValue_ / this->maximum_ * this->trackHeight_) + this->thumbRect_ = QRect(
1 + this->buttonHeight_, 0,
int(this->currentValue_ / div * this->trackHeight_) + 1 +
this->buttonHeight_,
this->width(), this->width(),
int(this->largeChange_ / this->maximum_ * this->trackHeight_) + int(this->largeChange_ / div * this->trackHeight_) + MIN_THUMB_HEIGHT);
MIN_THUMB_HEIGHT);
this->update(); this->update();
} }

View file

@ -210,6 +210,7 @@ void ColorPickerDialog::initRecentColors(LayoutCreator<QWidget> &creator)
this->ui_.recent.colors.push_back(new ColorButton(*it, this)); this->ui_.recent.colors.push_back(new ColorButton(*it, this));
auto *button = this->ui_.recent.colors[ind]; auto *button = this->ui_.recent.colors[ind];
static_assert(RECENT_COLORS_PER_ROW != 0);
const int rowInd = (ind / RECENT_COLORS_PER_ROW) + 1; const int rowInd = (ind / RECENT_COLORS_PER_ROW) + 1;
const int columnInd = ind % RECENT_COLORS_PER_ROW; const int columnInd = ind % RECENT_COLORS_PER_ROW;

View file

@ -319,7 +319,9 @@ void ChannelView::scaleChangedEvent(float scale)
{ {
auto factor = this->qtFontScale(); auto factor = this->qtFontScale();
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
factor = scale * 80.f / this->logicalDpiX() * this->devicePixelRatioF(); factor = scale * 80.f /
std::max<float>(
0.01, this->logicalDpiX() * this->devicePixelRatioF());
#endif #endif
this->goToBottom_->getLabel().setFont( this->goToBottom_->getLabel().setFont(
getFonts()->getFont(FontStyle::UiMedium, factor)); getFonts()->getFont(FontStyle::UiMedium, factor));
@ -426,8 +428,9 @@ void ChannelView::updateScrollbar(
if (h < 0) // break condition if (h < 0) // break condition
{ {
this->scrollBar_->setLargeChange((messages.size() - i) + this->scrollBar_->setLargeChange(
qreal(h) / message->getHeight()); (messages.size() - i) +
qreal(h) / std::max<int>(1, message->getHeight()));
showScrollbar = true; showScrollbar = true;
break; break;
@ -964,8 +967,8 @@ void ChannelView::wheelEvent(QWheelEvent *event)
if (delta > 0) if (delta > 0)
{ {
qreal scrollFactor = fmod(desired, 1); qreal scrollFactor = fmod(desired, 1);
qreal currentScrollLeft = qreal currentScrollLeft = std::max<qreal>(
int(scrollFactor * snapshot[i]->getHeight()); 0.01, int(scrollFactor * snapshot[i]->getHeight()));
for (; i >= 0; i--) for (; i >= 0; i--)
{ {
@ -997,8 +1000,8 @@ void ChannelView::wheelEvent(QWheelEvent *event)
{ {
delta = -delta; delta = -delta;
qreal scrollFactor = 1 - fmod(desired, 1); qreal scrollFactor = 1 - fmod(desired, 1);
qreal currentScrollLeft = qreal currentScrollLeft = std::max<qreal>(
int(scrollFactor * snapshot[i]->getHeight()); 0.01, int(scrollFactor * snapshot[i]->getHeight()));
for (; i < snapshotLength; i++) for (; i < snapshotLength; i++)
{ {

View file

@ -282,12 +282,11 @@ void NotebookTab::paintEvent(QPaintEvent *)
QPainter painter(this); QPainter painter(this);
float scale = this->scale(); float scale = this->scale();
painter.setFont(getApp()->fonts->getFont( auto div = std::max<float>(0.01f, this->logicalDpiX() * deviceDpi(this));
FontStyle::UiTabs, painter.setFont(
scale * 96.f / this->logicalDpiX() * deviceDpi(this))); getApp()->fonts->getFont(FontStyle::UiTabs, scale * 96.f / div));
QFontMetrics metrics = app->fonts->getFontMetrics( QFontMetrics metrics =
FontStyle::UiTabs, app->fonts->getFontMetrics(FontStyle::UiTabs, scale * 96.f / div);
scale * 96.f / this->logicalDpiX() * deviceDpi(this));
int height = int(scale * NOTEBOOK_TAB_HEIGHT); int height = int(scale * NOTEBOOK_TAB_HEIGHT);

View file

@ -32,8 +32,11 @@ AboutPage::AboutPage()
auto logo = layout.emplace<QLabel>().assign(&this->logo_); auto logo = layout.emplace<QLabel>().assign(&this->logo_);
logo->setPixmap(pixmap); logo->setPixmap(pixmap);
if (pixmap.width() != 0)
{
logo->setFixedSize(PIXMAP_WIDTH, logo->setFixedSize(PIXMAP_WIDTH,
PIXMAP_WIDTH * pixmap.height() / pixmap.width()); PIXMAP_WIDTH * pixmap.height() / pixmap.width());
}
logo->setScaledContents(true); logo->setScaledContents(true);
// this does nothing // this does nothing

View file

@ -359,6 +359,8 @@ void GeneralPage::initLayout(SettingsLayout &layout)
// layout.addCheckbox("Mark last message you read"); // layout.addCheckbox("Mark last message you read");
// layout.addDropdown("Last read message style", {"Default"}); // layout.addDropdown("Last read message style", {"Default"});
layout.addCheckbox("Show deleted messages", s.hideModerated, true); layout.addCheckbox("Show deleted messages", s.hideModerated, true);
layout.addCheckbox("Highlight messages redeemed with Channel Points",
s.enableRedeemedHighlight);
layout.addDropdown<QString>( layout.addDropdown<QString>(
"Timestamps", "Timestamps",
{"Disable", "h:mm", "hh:mm", "h:mm a", "hh:mm a", "h:mm:ss", "hh:mm:ss", {"Disable", "h:mm", "hh:mm", "h:mm a", "hh:mm a", "h:mm:ss", "hh:mm:ss",

View file

@ -962,8 +962,10 @@ void SplitContainer::Node::insertNextToThis(Split *_split, Direction _direction)
{ {
auto &siblings = this->parent_->children_; auto &siblings = this->parent_->children_;
qreal width = this->parent_->geometry_.width() / siblings.size(); qreal width = this->parent_->geometry_.width() /
qreal height = this->parent_->geometry_.height() / siblings.size(); std::max<qreal>(0.0001, siblings.size());
qreal height = this->parent_->geometry_.height() /
std::max<qreal>(0.0001, siblings.size());
if (siblings.size() == 1) if (siblings.size() == 1)
{ {
@ -1117,16 +1119,20 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale,
// vars // vars
qreal minSize = qreal(48 * _scale); qreal minSize = qreal(48 * _scale);
qreal totalFlex = this->getChildrensTotalFlex(isVertical); qreal totalFlex = std::max<qreal>(
0.0001, this->getChildrensTotalFlex(isVertical));
qreal totalSize = std::accumulate( qreal totalSize = std::accumulate(
this->children_.begin(), this->children_.end(), qreal(0), this->children_.begin(), this->children_.end(), qreal(0),
[=](int val, std::unique_ptr<Node> &node) { [=](int val, std::unique_ptr<Node> &node) {
return val + std::max<qreal>(this->getSize(isVertical) / return val + std::max<qreal>(
totalFlex * this->getSize(isVertical) /
std::max<qreal>(0.0001, totalFlex) *
node->getFlex(isVertical), node->getFlex(isVertical),
minSize); minSize);
}); });
totalSize = std::max<qreal>(0.0001, totalSize);
qreal sizeMultiplier = this->getSize(isVertical) / totalSize; qreal sizeMultiplier = this->getSize(isVertical) / totalSize;
QRectF childRect = this->geometry_; QRectF childRect = this->geometry_;
@ -1242,7 +1248,7 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale,
} }
} }
break; break;
}; }
} }
SplitContainer::Node::Type SplitContainer::Node::toContainerType(Direction _dir) SplitContainer::Node::Type SplitContainer::Node::toContainerType(Direction _dir)