added brace wrapping after if and for
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user