diff --git a/backends/ui/qt/aboutwindow.cpp b/backends/ui/qt/aboutwindow.cpp index 6c4db5e..4d350ef 100644 --- a/backends/ui/qt/aboutwindow.cpp +++ b/backends/ui/qt/aboutwindow.cpp @@ -41,23 +41,23 @@ LicenseModel::~LicenseModel() { } AboutWindow::AboutWindow() { - license_text = new QTextBrowser(); - license_list = new QListView(); + license_text = new QTextBrowser(this); + license_list = new QListView(this); license_list->setModel(new LicenseModel()); QObject::connect(license_list, &QListView::clicked, [=,this](const QModelIndex &idx) { license_text->setText(license_list->model()->data(idx, Qt::UserRole).toString()); }); license_list->setSelectionMode(QAbstractItemView::SingleSelection); license_list->setSelectionBehavior(QAbstractItemView::SelectRows); - QBoxLayout *mainLayout = new QBoxLayout(QBoxLayout::TopToBottom); - QLabel *title = new QLabel("Looper"); + QBoxLayout *mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this); + QLabel *title = new QLabel("Looper", this); auto font = title->font(); font.setPointSize(24); title->setFont(font); mainLayout->addWidget(title); - QLabel *versionText = new QLabel(TAG); + QLabel *versionText = new QLabel(TAG, this); mainLayout->addWidget(versionText); - QSplitter *splitter = new QSplitter(Qt::Orientation::Horizontal); + QSplitter *splitter = new QSplitter(Qt::Orientation::Horizontal, this); splitter->addWidget(license_list); splitter->addWidget(license_text); mainLayout->addWidget(splitter); diff --git a/backends/ui/qt/main_window.cpp b/backends/ui/qt/main_window.cpp index 52ede56..aab0a66 100644 --- a/backends/ui/qt/main_window.cpp +++ b/backends/ui/qt/main_window.cpp @@ -46,7 +46,7 @@ LooperWindow::LooperWindow(Playback *playback) : QMainWindow() { this->layout()->setContentsMargins(QMargins(0, 0, 0, 0)); this->playback = playback; this->root_layout = new QBoxLayout(QBoxLayout::TopToBottom); - QWidget *central_widget = new QWidget(); + QWidget *central_widget = new QWidget(this); central_widget->setLayout(this->root_layout); this->setCentralWidget(central_widget); prefs_window = new PrefsWindow(); @@ -83,18 +83,18 @@ LooperWindow::LooperWindow(Playback *playback) : QMainWindow() { root_layout->addWidget(bar); QSpacerItem *spacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding); root_layout->addSpacerItem(spacer); - QBoxLayout *top_row = new QBoxLayout(QBoxLayout::LeftToRight); - pause_resume_btn = new QPushButton("Pause"); + QBoxLayout *top_row = new QBoxLayout(QBoxLayout::LeftToRight, this); + pause_resume_btn = new QPushButton("Pause", this); QObject::connect(pause_resume_btn, &QPushButton::pressed, [=,this]() { playback->Pause(); }); - restart_btn = new QPushButton("Restart"); + restart_btn = new QPushButton("Restart", this); QObject::connect(restart_btn, &QPushButton::pressed, [=,this]() { playback->Seek(0.0); }); top_row->addWidget(pause_resume_btn); top_row->addWidget(restart_btn); - slider = new LooperSlider("seek", "Position", 0.0, 1.0, 0.00000000001, false); + slider = new LooperSlider("seek", "Position", 0.0, 1.0, 0.00000000001, false, this); slider->DisableModeButton(); slider->UseSlider(); QObject::connect(slider, &LooperSlider::changed, [=,this](double value) { @@ -106,16 +106,16 @@ LooperWindow::LooperWindow(Playback *playback) : QMainWindow() { playback->Stop(); }); top_row->addWidget(stop_btn); - volume_slider = new LooperSlider("volume", "Volume", 0.0, 100.0, 1.0, false); + volume_slider = new LooperSlider("volume", "Volume", 0.0, 100.0, 1.0, false, this); volume_slider->SetLimitLabels("Muted", "Full Volume"); QObject::connect(volume_slider, &LooperSlider::changed, [=,this](double value) { playback->SetVolume(value); }); top_row->addWidget(volume_slider); - QWidget *top_row_widget = new QWidget(); + QWidget *top_row_widget = new QWidget(this); top_row_widget->setLayout(top_row); root_layout->addWidget(top_row_widget); - QBoxLayout *bottom_row = new QBoxLayout(QBoxLayout::LeftToRight); + QBoxLayout *bottom_row = new QBoxLayout(QBoxLayout::LeftToRight, this); speed_slider = new LooperSlider("speed", "Speed", 0.25, 4.0, 0.01, true); pitch_slider = new LooperSlider("pitch", "Pitch", 0.25, 4.0, 0.01, true); tempo_slider = new LooperSlider("tempo", "Tempo", 0.25, 4.0, 0.01, true); @@ -134,7 +134,7 @@ LooperWindow::LooperWindow(Playback *playback) : QMainWindow() { bottom_row->addWidget(speed_slider); bottom_row->addWidget(pitch_slider); bottom_row->addWidget(tempo_slider); - QWidget *bottom_row_widget = new QWidget(); + QWidget *bottom_row_widget = new QWidget(this); bottom_row_widget->setLayout(bottom_row); root_layout->addWidget(bottom_row_widget); QTimer *timer = new QTimer(this); diff --git a/backends/ui/qt/preferences.cpp b/backends/ui/qt/preferences.cpp index 95987ed..1d79225 100644 --- a/backends/ui/qt/preferences.cpp +++ b/backends/ui/qt/preferences.cpp @@ -5,12 +5,12 @@ #include using namespace Looper::Options; PrefsWindow::PrefsWindow() { - auto *root_layout = new QBoxLayout(QBoxLayout::TopToBottom); + auto *root_layout = new QBoxLayout(QBoxLayout::TopToBottom, this); this->setLayout(root_layout); - restart_warning = new QLabel("A restart is needed to apply some changes."); + restart_warning = new QLabel("A restart is needed to apply some changes.", this); restart_warning->hide(); root_layout->addWidget(restart_warning); - frontend_btn = new QPushButton(); + frontend_btn = new QPushButton(this); frontend_menu = new QMenu(); for (auto &kv : UIBackend::backends) { UIBackend *backend = kv.second; @@ -26,21 +26,21 @@ PrefsWindow::PrefsWindow() { } frontend_btn->setMenu(frontend_menu); root_layout->addWidget(frontend_btn); - QFrame *frame = new QFrame(); + QFrame *frame = new QFrame(this); frame->setWindowTitle("Labels and Icons"); - auto *label_settings_group = new QBoxLayout(QBoxLayout::TopToBottom); + auto *label_settings_group = new QBoxLayout(QBoxLayout::TopToBottom, this); frame->setLayout(label_settings_group); - labels_only = new QRadioButton("Labels Only"); + labels_only = new QRadioButton("Labels Only", frame); labels_only->connect(labels_only, &QRadioButton::pressed, [=,this]() { this->new_label_setting = "labels"; this->set_options_changed(true); }); - icons_only = new QRadioButton("Icons Only"); + icons_only = new QRadioButton("Icons Only", frame); icons_only->connect(icons_only, &QRadioButton::pressed, [=,this]() { this->new_label_setting = "icons"; this->set_options_changed(true); }); - both_labels_icons = new QRadioButton("Both"); + both_labels_icons = new QRadioButton("Both", frame); both_labels_icons->connect(both_labels_icons, &QRadioButton::pressed, [=,this]() { this->new_label_setting = "both"; this->set_options_changed(true); @@ -49,12 +49,12 @@ PrefsWindow::PrefsWindow() { label_settings_group->addWidget(icons_only); label_settings_group->addWidget(both_labels_icons); root_layout->addWidget(frame); - revert_btn = new QPushButton("Revert"); + QWidget *btn_view = new QWidget(this); + QBoxLayout *btn_box = new QBoxLayout(QBoxLayout::LeftToRight, this); + revert_btn = new QPushButton("Revert", btn_view); QObject::connect(revert_btn, &QPushButton::pressed, this, &PrefsWindow::revert); - apply_btn = new QPushButton("Apply"); + apply_btn = new QPushButton("Apply", btn_view); QObject::connect(apply_btn, &QPushButton::pressed, this, &PrefsWindow::apply); - QWidget *btn_view = new QWidget(); - QBoxLayout *btn_box = new QBoxLayout(QBoxLayout::LeftToRight); btn_view->setLayout(btn_box); btn_box->addWidget(revert_btn); btn_box->addWidget(apply_btn); diff --git a/backends/ui/qt/slider.cpp b/backends/ui/qt/slider.cpp index b9cd744..74b3332 100644 --- a/backends/ui/qt/slider.cpp +++ b/backends/ui/qt/slider.cpp @@ -1,12 +1,12 @@ #include "slider.hpp" -LooperSlider::LooperSlider(const char *name, const char *label, double min, double max, double tick, bool logarithmic) : QWidget() { +LooperSlider::LooperSlider(const char *name, const char *label, double min, double max, double tick, bool logarithmic, QWidget *parent) : QWidget(parent) { root_layout = new QBoxLayout(QBoxLayout::LeftToRight, this); text_layout_view = new QBoxLayout(QBoxLayout::TopToBottom); - QWidget *text_layout_widget = new QWidget(); + QWidget *text_layout_widget = new QWidget(this); text_layout_widget->setLayout(text_layout_view); root_layout->addWidget(text_layout_widget); - text_label = new QLabel(); - slider = new _looperSlider(Qt::Orientation::Horizontal); + text_label = new QLabel(text_layout_widget); + slider = new _looperSlider(Qt::Orientation::Horizontal, text_layout_widget); slider->connect(slider, &_looperSlider::mousePressed, [=,this]() { pressed = true; slider_value_changed_after_release = false; @@ -25,12 +25,12 @@ LooperSlider::LooperSlider(const char *name, const char *label, double min, doub slider_value_changed_after_release = true; }); text_layout_view->addWidget(slider); - btn = new QPushButton(); + btn = new QPushButton(this); btn->connect(btn, &QPushButton::pressed, [=,this]() { SwitchModes(); }); root_layout->addWidget(btn); - text = new QLineEdit(); + text = new QLineEdit(text_layout_widget); text->setVisible(false); text_layout_view->addWidget(text); text->connect(text, &QLineEdit::textChanged, [=,this]() { @@ -48,10 +48,10 @@ LooperSlider::LooperSlider(const char *name, const char *label, double min, doub this->SetValue(output); } }); - limits_view = new QBoxLayout(QBoxLayout::LeftToRight); - min_label_view = new QLabel(); + limits_view = new QBoxLayout(QBoxLayout::LeftToRight, text_layout_widget); + min_label_view = new QLabel(text_layout_widget); limits_view->addWidget(min_label_view, 0, Qt::Alignment::enum_type::AlignLeft); - max_label_view = new QLabel(); + max_label_view = new QLabel(text_layout_widget); limits_view->addWidget(max_label_view, 0, Qt::Alignment::enum_type::AlignRight); scaler = new LooperLogScaler(min, max); set_min(min); diff --git a/backends/ui/qt/slider.hpp b/backends/ui/qt/slider.hpp index fdfd947..9eb870f 100644 --- a/backends/ui/qt/slider.hpp +++ b/backends/ui/qt/slider.hpp @@ -109,7 +109,7 @@ class LooperSlider : public QWidget { inline void SwitchModes() { SetMode(!text_edit_mode); } - explicit LooperSlider(const char *name, const char *label, double min, double max, double tick = 0.0001, bool logarithmic = false); + explicit LooperSlider(const char *name, const char *label, double min, double max, double tick = 0.0001, bool logarithmic = false, QWidget *parent = nullptr); ~LooperSlider(); void changeEvent(QEvent *event) override; Q_SIGNALS: