forked from MrBesen/soundboard
Buttons do resize now correctly with the window, prepared some custom rendering with the buttons
This commit is contained in:
parent
8d0ff7e918
commit
a9ff7e1e6a
|
@ -29,6 +29,8 @@ public:
|
|||
|
||||
void setHighlighted(bool highlighted);
|
||||
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
|
||||
public slots:
|
||||
void play();
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ void MainWindow::loadButtonsFromConfig() {
|
|||
|
||||
x += bc.width;
|
||||
}
|
||||
ui->gridLayout->setRowMinimumHeight(y, 60);
|
||||
//ui->gridLayout->setRowMinimumHeight(y, 60);
|
||||
x = 0;
|
||||
y++;
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ void MainWindow::loadButtonsFromConfig() {
|
|||
((SoundButton*) item->widget())->setHighlighted(true);
|
||||
}
|
||||
|
||||
// ui->gridLayoutWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
||||
// ui->gridLayout->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
|
||||
}
|
||||
|
||||
void MainWindow::reselectNext(std::function<void(uint8_t&,uint8_t&)> stepf) {
|
||||
|
|
|
@ -140,7 +140,7 @@ void Sound::init() {
|
|||
|
||||
void Sound::backgroundThreadLoop() {
|
||||
while(threadShouldrun) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
cleanAllDecoders();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "soundbutton.h"
|
||||
|
||||
#include <QTextItem>
|
||||
|
||||
#include "sound.h"
|
||||
|
||||
#include <Log.h>
|
||||
|
@ -12,10 +14,10 @@ SoundButton::SoundButton(const std::string& filename, const std::string& name_,
|
|||
QString info = getInfo();
|
||||
setText(info);
|
||||
setObjectName(QString::fromStdString("soundButton" + std::to_string(id)));
|
||||
setMinimumHeight(50);
|
||||
setMinimumSize(QSize(80, 20));
|
||||
setToolTip(info);
|
||||
|
||||
// button->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum));
|
||||
setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
|
||||
|
||||
QKeySequence seq(QString::fromStdString(keycombo));
|
||||
globalShortcut = new QxtGlobalShortcut(seq);
|
||||
|
@ -74,6 +76,22 @@ void SoundButton::setHighlighted(bool highlighted) {
|
|||
}
|
||||
}
|
||||
|
||||
void SoundButton::paintEvent(QPaintEvent* event) {
|
||||
QPushButton::paintEvent(event);
|
||||
|
||||
QString text = "";
|
||||
|
||||
// cancel if nothing to print
|
||||
if(text.isEmpty())
|
||||
return;
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setPen(QPen(Qt::white));
|
||||
QPoint textPos(0, painter.fontMetrics().height());
|
||||
textPos.rx() = width() - painter.fontMetrics().horizontalAdvance(text) - 6;
|
||||
painter.drawText(textPos, text);
|
||||
}
|
||||
|
||||
void SoundButton::play() {
|
||||
if(disabled) return;
|
||||
|
||||
|
|
110
ui/mainwindow.ui
110
ui/mainwindow.ui
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>824</width>
|
||||
<height>675</height>
|
||||
<width>615</width>
|
||||
<height>639</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -15,72 +15,68 @@
|
|||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<widget class="QWidget" name="gridLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>791</width>
|
||||
<height>561</height>
|
||||
</rect>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetNoConstraint</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout" rowminimumheight="0">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="reloadButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>141</width>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>reload Config</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="stopButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>160</x>
|
||||
<y>10</y>
|
||||
<width>100</width>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Stop</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="allwaysOnTop">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>660</x>
|
||||
<y>10</y>
|
||||
<width>141</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>AllwaysOnTop</string>
|
||||
</property>
|
||||
</widget>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="topRow">
|
||||
<item>
|
||||
<widget class="QPushButton" name="reloadButton">
|
||||
<property name="text">
|
||||
<string>reload Config</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="stopButton">
|
||||
<property name="text">
|
||||
<string>Stop</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="allwaysOnTop">
|
||||
<property name="text">
|
||||
<string>AllwaysOnTop</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout" rowminimumheight="0">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>824</width>
|
||||
<width>615</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
|
Loading…
Reference in New Issue