Added a Live status indicator to tabs

This commit is contained in:
Rasmus Karlsson
2018-10-13 14:20:06 +02:00
parent 71a51d34c7
commit 49449379da
14 changed files with 104 additions and 51 deletions
+23 -4
View File
@@ -168,13 +168,20 @@ void NotebookTab::setSelected(bool value)
this->update();
}
void NotebookTab::setLive(bool isLive)
{
if (this->isLive_ != isLive) {
this->isLive_ = isLive;
this->update();
}
}
void NotebookTab::setHighlightState(HighlightState newHighlightStyle)
{
if (this->isSelected() || !this->highlightEnabled_) {
return;
}
if (this->highlightState_ != HighlightState::Highlighted &&
this->highlightState_ != HighlightState::Notification) {
if (this->highlightState_ != HighlightState::Highlighted) {
this->highlightState_ = newHighlightStyle;
this->update();
@@ -252,8 +259,6 @@ void NotebookTab::paintEvent(QPaintEvent *)
colors = this->theme->tabs.selected;
} else if (this->highlightState_ == HighlightState::Highlighted) {
colors = this->theme->tabs.highlighted;
} else if (this->highlightState_ == HighlightState::Notification) {
colors = this->theme->tabs.notified;
} else if (this->highlightState_ == HighlightState::NewMessage) {
colors = this->theme->tabs.newMessage;
} else {
@@ -297,6 +302,20 @@ void NotebookTab::paintEvent(QPaintEvent *)
? colors.line.hover
: (windowFocused ? colors.line.regular : colors.line.unfocused));
// draw live indicator
if (this->isLive_) {
painter.setPen(QColor(Qt::GlobalColor::red));
QBrush b;
b.setColor(QColor(Qt::GlobalColor::red));
b.setStyle(Qt::SolidPattern);
painter.setBrush(b);
auto x = this->width() - (6.f * scale);
auto y = 4.f * scale;
auto diameter = 4.f * scale;
painter.drawEllipse(QRectF(x, y, diameter, diameter));
}
// set the pen color
painter.setPen(colors.text);