forked from MrBesen/soundboard
highlight border
This commit is contained in:
parent
a9ff7e1e6a
commit
3585f6a538
|
@ -48,7 +48,10 @@ private:
|
||||||
uint64_t lengthms = 0; // ignored when length = 0
|
uint64_t lengthms = 0; // ignored when length = 0
|
||||||
float volume = 1.f;
|
float volume = 1.f;
|
||||||
|
|
||||||
|
bool highlighted = false;
|
||||||
bool disabled = false;
|
bool disabled = false;
|
||||||
|
|
||||||
|
const static uint8_t HIGHLIGHTBORDEROFFSET = 5;
|
||||||
|
|
||||||
QxtGlobalShortcut* globalShortcut = nullptr;
|
QxtGlobalShortcut* globalShortcut = nullptr;
|
||||||
};
|
};
|
|
@ -66,26 +66,29 @@ void SoundButton::setVolume(float v) {
|
||||||
volume = v;
|
volume = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundButton::setHighlighted(bool highlighted) {
|
void SoundButton::setHighlighted(bool highlighted_) {
|
||||||
if(highlighted) {
|
highlighted = highlighted_;
|
||||||
setStyleSheet("SoundButton { color: red; }");
|
|
||||||
//setText("-> " + getInfo());
|
repaint();
|
||||||
} else {
|
|
||||||
setStyleSheet("SoundButton {}");
|
|
||||||
//setText(getInfo());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundButton::paintEvent(QPaintEvent* event) {
|
void SoundButton::paintEvent(QPaintEvent* event) {
|
||||||
QPushButton::paintEvent(event);
|
QPushButton::paintEvent(event);
|
||||||
|
|
||||||
|
QPainter painter(this);
|
||||||
|
if(highlighted) {
|
||||||
|
QSize s = size();
|
||||||
|
QRect rect(HIGHLIGHTBORDEROFFSET, HIGHLIGHTBORDEROFFSET, s.width()-HIGHLIGHTBORDEROFFSET*2, s.height()-HIGHLIGHTBORDEROFFSET*2);
|
||||||
|
painter.setPen(QPen(Qt::red));
|
||||||
|
painter.drawRect(rect);
|
||||||
|
}
|
||||||
|
|
||||||
QString text = "";
|
QString text = "";
|
||||||
|
|
||||||
// cancel if nothing to print
|
// cancel if nothing to print
|
||||||
if(text.isEmpty())
|
if(text.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QPainter painter(this);
|
|
||||||
painter.setPen(QPen(Qt::white));
|
painter.setPen(QPen(Qt::white));
|
||||||
QPoint textPos(0, painter.fontMetrics().height());
|
QPoint textPos(0, painter.fontMetrics().height());
|
||||||
textPos.rx() = width() - painter.fontMetrics().horizontalAdvance(text) - 6;
|
textPos.rx() = width() - painter.fontMetrics().horizontalAdvance(text) - 6;
|
||||||
|
|
Loading…
Reference in New Issue