implemented automated system of panel focus

This commit is contained in:
itsmattkc
2019-06-24 18:07:14 -07:00
parent fb7e9766fa
commit dfb75c5d2b
8 changed files with 137 additions and 2 deletions
+28
View File
@@ -20,9 +20,14 @@
#include "panel.h"
#include <QPainter>
#include "panel/panelfocusmanager.h"
PanelWidget::PanelWidget(QWidget *parent) :
QDockWidget(parent)
{
setFocusPolicy(Qt::ClickFocus);
}
void PanelWidget::SetTitle(const QString &t)
@@ -37,6 +42,29 @@ void PanelWidget::SetSubtitle(const QString &t)
UpdateTitle();
}
void PanelWidget::paintEvent(QPaintEvent *event)
{
// Perform default behavior
QDockWidget::paintEvent(event);
// Check if this panel (or a child of it) has focus using PanelFocusManager
if (olive::panel_focus_manager->CurrentlyFocused() == this) {
// Draw a highlight border if so
QPainter p(this);
// We need to adjust the rect by 1 pixel since the bottom and right are "offscreen"
QRect highlight_border = rect();
highlight_border.adjust(0, 0, -1, -1);
// Set the color to the palette's highlight color
p.setPen(QPen(palette().highlight().color()));
// Draw the highlight border
p.drawRect(highlight_border);
}
}
void PanelWidget::UpdateTitle()
{
if (subtitle_.isEmpty()) {