Merge pull request #6779 from michaelgregorius/2510-SetupDialogWithLayouts

Solve the HiDPI issues of the setup dialog (#2510)
This commit is contained in:
Michael Gregorius
2023-10-01 21:53:50 +02:00
committed by GitHub
17 changed files with 240 additions and 270 deletions

View File

@@ -3,7 +3,7 @@
********************/
/* most foreground text items */
QLabel, QTreeWidget, QListWidget, QGroupBox, QMenuBar {
QLabel, QTreeWidget, QListWidget, QGroupBox, QMenuBar, QCheckBox {
color: #d1d8e4;
}
@@ -464,6 +464,10 @@ lmms--gui--EffectSelectDialog QScrollArea {
background: #262b30;
}
lmms--gui--SetupDialog QScrollArea {
border: 0px;
}
/* the inner boxes in LADSPA effect windows */
lmms--gui--EffectControlDialog QGroupBox {

View File

@@ -2,6 +2,7 @@
* AudioDeviceSetupWidget.h - Base class for audio device setup widgets
*
* Copyright (c) 2004-2015 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2023- Michael Gregorius
*
* This file is part of LMMS - https://lmms.io
*
@@ -25,12 +26,12 @@
#ifndef LMMS_GUI_AUDIO_DEVICE_SETUP_WIDGET_H
#define LMMS_GUI_AUDIO_DEVICE_SETUP_WIDGET_H
#include "TabWidget.h"
#include <QGroupBox>
namespace lmms::gui
{
class AudioDeviceSetupWidget : public TabWidget
class AudioDeviceSetupWidget : public QGroupBox
{
Q_OBJECT
public:

View File

@@ -25,7 +25,7 @@
#ifndef LMMS_GUI_MIDI_SETUP_WIDGET_H
#define LMMS_GUI_MIDI_SETUP_WIDGET_H
#include "TabWidget.h"
#include <QGroupBox>
class QLineEdit;
@@ -33,7 +33,7 @@ namespace lmms::gui
{
class MidiSetupWidget : public TabWidget
class MidiSetupWidget : public QGroupBox
{
Q_OBJECT
MidiSetupWidget( const QString & caption, const QString & configSection,

View File

@@ -30,12 +30,12 @@
#include "AudioDevice.h"
#include "AudioDeviceSetupWidget.h"
#include "LedCheckBox.h"
#include "lmmsconfig.h"
#include "MidiClient.h"
#include "MidiSetupWidget.h"
class QCheckBox;
class QComboBox;
class QLabel;
class QLineEdit;
@@ -156,14 +156,14 @@ private:
bool m_enableRunningAutoSave;
QSlider * m_saveIntervalSlider;
QLabel * m_saveIntervalLbl;
LedCheckBox * m_autoSave;
LedCheckBox * m_runningAutoSave;
QCheckBox * m_autoSave;
QCheckBox * m_runningAutoSave;
bool m_smoothScroll;
bool m_animateAFP;
QLabel * m_vstEmbedLbl;
QComboBox* m_vstEmbedComboBox;
QString m_vstEmbedMethod;
LedCheckBox * m_vstAlwaysOnTopCheckBox;
QCheckBox * m_vstAlwaysOnTopCheckBox;
bool m_vstAlwaysOnTop;
bool m_disableAutoQuit;

View File

@@ -49,7 +49,12 @@ public:
TabButton * addTab( QWidget * _w, const QString & _text,
int _id, bool _add_stretch = false,
bool _text_is_tooltip = false );
bool _text_is_tooltip = false,
// TODO Remove fixWidgetToParentSize once it is used
// with false everywhere.
// At the time of writing it is only used in
// LadspaBrowser with default parameters.
bool fixWidgetToParentSize = true );
void removeTab( int _id );
inline void setExclusive( bool _on )

View File

@@ -26,8 +26,8 @@
#ifdef LMMS_HAVE_JACK
#include <QFormLayout>
#include <QLineEdit>
#include <QLabel>
#include <QMessageBox>
#include "Engine.h"
@@ -454,17 +454,16 @@ void AudioJack::shutdownCallback( void * _udata )
AudioJack::setupWidget::setupWidget( QWidget * _parent ) :
AudioDeviceSetupWidget( AudioJack::name(), _parent )
{
QFormLayout * form = new QFormLayout(this);
QString cn = ConfigManager::inst()->value( "audiojack", "clientname" );
if( cn.isEmpty() )
{
cn = "lmms";
}
m_clientName = new QLineEdit( cn, this );
m_clientName->setGeometry( 10, 20, 160, 20 );
auto cn_lbl = new QLabel(tr("Client name"), this);
cn_lbl->setFont( pointSize<7>( cn_lbl->font() ) );
cn_lbl->setGeometry( 10, 40, 160, 10 );
form->addRow(tr("Client name"), m_clientName);
auto m = new gui::LcdSpinBoxModel(/* this */);
m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS );
@@ -474,8 +473,8 @@ AudioJack::setupWidget::setupWidget( QWidget * _parent ) :
m_channels = new gui::LcdSpinBox( 1, this );
m_channels->setModel( m );
m_channels->setLabel( tr( "Channels" ) );
m_channels->move( 180, 20 );
form->addRow(tr("Channels"), m_channels);
}

View File

@@ -27,7 +27,7 @@
#ifdef LMMS_HAVE_OSS
#include <QFileInfo>
#include <QLabel>
#include <QFormLayout>
#include <QLineEdit>
#include "endian_handling.h"
@@ -320,12 +320,11 @@ void AudioOss::run()
AudioOss::setupWidget::setupWidget( QWidget * _parent ) :
AudioDeviceSetupWidget( AudioOss::name(), _parent )
{
m_device = new QLineEdit( probeDevice(), this );
m_device->setGeometry( 10, 20, 160, 20 );
QFormLayout * form = new QFormLayout(this);
auto dev_lbl = new QLabel(tr("Device"), this);
dev_lbl->setFont( pointSize<7>( dev_lbl->font() ) );
dev_lbl->setGeometry( 10, 40, 160, 10 );
m_device = new QLineEdit( probeDevice(), this );
form->addRow(tr("Device"), m_device);
auto m = new gui::LcdSpinBoxModel(/* this */);
m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS );
@@ -335,9 +334,8 @@ AudioOss::setupWidget::setupWidget( QWidget * _parent ) :
m_channels = new gui::LcdSpinBox( 1, this );
m_channels->setModel( m );
m_channels->setLabel( tr( "Channels" ) );
m_channels->move( 180, 20 );
form->addRow(tr("Channels"), m_channels);
}

View File

@@ -49,7 +49,7 @@ void AudioPortAudioSetupUtil::updateChannels()
#ifdef LMMS_HAVE_PORTAUDIO
#include <QLabel>
#include <QFormLayout>
#include "Engine.h"
#include "ConfigManager.h"
@@ -419,19 +419,13 @@ AudioPortAudio::setupWidget::setupWidget( QWidget * _parent ) :
{
using gui::ComboBox;
m_backend = new ComboBox( this, "BACKEND" );
m_backend->setGeometry( 64, 15, 260, ComboBox::DEFAULT_HEIGHT );
QFormLayout * form = new QFormLayout(this);
auto backend_lbl = new QLabel(tr("Backend"), this);
backend_lbl->setFont( pointSize<7>( backend_lbl->font() ) );
backend_lbl->move( 8, 18 );
m_backend = new ComboBox( this, "BACKEND" );
form->addRow(tr("Backend"), m_backend);
m_device = new ComboBox( this, "DEVICE" );
m_device->setGeometry( 64, 35, 260, ComboBox::DEFAULT_HEIGHT );
auto dev_lbl = new QLabel(tr("Device"), this);
dev_lbl->setFont( pointSize<7>( dev_lbl->font() ) );
dev_lbl->move( 8, 38 );
form->addRow(tr("Device"), m_device);
/* LcdSpinBoxModel * m = new LcdSpinBoxModel( );
m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS );

View File

@@ -22,8 +22,8 @@
*
*/
#include <QFormLayout>
#include <QLineEdit>
#include <QLabel>
#include "AudioPulseAudio.h"
@@ -312,24 +312,21 @@ void AudioPulseAudio::signalConnected( bool connected )
AudioPulseAudio::setupWidget::setupWidget( QWidget * _parent ) :
AudioDeviceSetupWidget( AudioPulseAudio::name(), _parent )
{
QFormLayout * form = new QFormLayout(this);
m_device = new QLineEdit( AudioPulseAudio::probeDevice(), this );
m_device->setGeometry( 10, 20, 160, 20 );
form->addRow(tr("Device"), m_device);
auto dev_lbl = new QLabel(tr("Device"), this);
dev_lbl->setFont( pointSize<7>( dev_lbl->font() ) );
dev_lbl->setGeometry( 10, 40, 160, 10 );
auto m = new gui::LcdSpinBoxModel(/* this */);
auto m = new gui::LcdSpinBoxModel();
m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS );
m->setStep( 2 );
m->setValue( ConfigManager::inst()->value( "audiopa",
"channels" ).toInt() );
"channels" ).toInt() );
m_channels = new gui::LcdSpinBox( 1, this );
m_channels->setModel( m );
m_channels->setLabel( tr( "Channels" ) );
m_channels->move( 180, 20 );
form->addRow(tr("Channels"), m_channels);
}

View File

@@ -26,7 +26,7 @@
#ifdef LMMS_HAVE_SDL
#include <QLabel>
#include <QFormLayout>
#include <QLineEdit>
#include <SDL.h>
@@ -327,14 +327,12 @@ void AudioSdl::sdlInputAudioCallback(Uint8 *_buf, int _len) {
AudioSdl::setupWidget::setupWidget( QWidget * _parent ) :
AudioDeviceSetupWidget( AudioSdl::name(), _parent )
{
QFormLayout * form = new QFormLayout(this);
QString dev = ConfigManager::inst()->value( "audiosdl", "device" );
m_device = new QLineEdit( dev, this );
m_device->setGeometry( 10, 20, 160, 20 );
auto dev_lbl = new QLabel(tr("Device"), this);
dev_lbl->setFont( pointSize<7>( dev_lbl->font() ) );
dev_lbl->setGeometry( 10, 40, 160, 10 );
form->addRow(tr("Device"), m_device);
}

View File

@@ -28,7 +28,7 @@
#ifdef LMMS_HAVE_SNDIO
#include <cstdlib>
#include <QLabel>
#include <QFormLayout>
#include <QLineEdit>
#include "endian_handling.h"
@@ -183,12 +183,10 @@ void AudioSndio::run()
AudioSndio::setupWidget::setupWidget( QWidget * _parent ) :
AudioDeviceSetupWidget( AudioSndio::name(), _parent )
{
m_device = new QLineEdit( "", this );
m_device->setGeometry( 10, 20, 160, 20 );
QFormLayout * form = new QFormLayout(this);
QLabel * dev_lbl = new QLabel( tr( "Device" ), this );
dev_lbl->setFont( pointSize<6>( dev_lbl->font() ) );
dev_lbl->setGeometry( 10, 40, 160, 10 );
m_device = new QLineEdit( "", this );
form->addRow(tr("Device"), m_device);
gui::LcdSpinBoxModel * m = new gui::LcdSpinBoxModel( /* this */ );
m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS );
@@ -198,9 +196,8 @@ AudioSndio::setupWidget::setupWidget( QWidget * _parent ) :
m_channels = new gui::LcdSpinBox( 1, this );
m_channels->setModel( m );
m_channels->setLabel( tr( "Channels" ) );
m_channels->move( 180, 20 );
form->addRow(tr("Channels"), m_channels);
}

View File

@@ -26,7 +26,7 @@
#ifdef LMMS_HAVE_SOUNDIO
#include <QLabel>
#include <QFormLayout>
#include <QLineEdit>
#include "Engine.h"
@@ -451,19 +451,13 @@ AudioSoundIo::setupWidget::setupWidget( QWidget * _parent ) :
{
m_setupUtil.m_setupWidget = this;
m_backend = new gui::ComboBox( this, "BACKEND" );
m_backend->setGeometry( 64, 15, 260, 20 );
QFormLayout * form = new QFormLayout(this);
QLabel * backend_lbl = new QLabel( tr( "Backend" ), this );
backend_lbl->setFont( pointSize<7>( backend_lbl->font() ) );
backend_lbl->move( 8, 18 );
m_backend = new gui::ComboBox( this, "BACKEND" );
form->addRow(tr("Backend"), m_backend);
m_device = new gui::ComboBox( this, "DEVICE" );
m_device->setGeometry( 64, 35, 260, 20 );
QLabel * dev_lbl = new QLabel( tr( "Device" ), this );
dev_lbl->setFont( pointSize<7>( dev_lbl->font() ) );
dev_lbl->move( 8, 38 );
form->addRow(tr("Device"), m_device);
// Setup models
m_soundio = soundio_create();

View File

@@ -23,7 +23,7 @@
*/
#include <QComboBox>
#include <QLabel>
#include <QFormLayout>
#include "AudioAlsaSetupWidget.h"
@@ -40,6 +40,8 @@ AudioAlsaSetupWidget::AudioAlsaSetupWidget( QWidget * _parent ) :
AudioDeviceSetupWidget( AudioAlsa::name(), _parent ),
m_selectedDevice(-1)
{
QFormLayout * form = new QFormLayout(this);
m_deviceInfos = AudioAlsa::getAvailableDevices();
QString deviceText = ConfigManager::inst()->value( "audioalsa", "device" );
@@ -62,14 +64,11 @@ AudioAlsaSetupWidget::AudioAlsaSetupWidget( QWidget * _parent ) :
m_selectedDevice = m_deviceComboBox->currentIndex();
m_deviceComboBox->setGeometry( 10, 20, 160, 20 );
connect(m_deviceComboBox,
SIGNAL(currentIndexChanged(int)),
SLOT(onCurrentIndexChanged(int)));
auto dev_lbl = new QLabel(tr("DEVICE"), this);
dev_lbl->setFont( pointSize<7>( dev_lbl->font() ) );
dev_lbl->setGeometry( 10, 40, 160, 10 );
form->addRow(tr("Device"), m_deviceComboBox);
auto m = new LcdSpinBoxModel(/* this */);
m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS );
@@ -79,9 +78,8 @@ AudioAlsaSetupWidget::AudioAlsaSetupWidget( QWidget * _parent ) :
m_channels = new LcdSpinBox( 1, this );
m_channels->setModel( m );
m_channels->setLabel( tr( "CHANNELS" ) );
m_channels->move( 180, 20 );
form->addRow(tr("Channels"), m_channels);
}

View File

@@ -28,7 +28,7 @@ namespace lmms::gui
{
AudioDeviceSetupWidget::AudioDeviceSetupWidget(const QString & caption, QWidget * parent) :
TabWidget(TabWidget::tr("Settings for %1").arg(tr(caption.toUtf8())), parent)
QGroupBox(QGroupBox::tr("Settings for %1").arg(tr(caption.toUtf8())), parent)
{
}
@@ -38,4 +38,4 @@ void AudioDeviceSetupWidget::show()
QWidget::show();
}
} // namespace lmms::gui
} // namespace lmms::gui

View File

@@ -24,7 +24,7 @@
#include "MidiSetupWidget.h"
#include <QLabel>
#include <QFormLayout>
#include <QLineEdit>
#include "ConfigManager.h"
@@ -37,7 +37,7 @@ namespace lmms::gui
MidiSetupWidget::MidiSetupWidget(const QString & caption, const QString & configSection,
const QString & devName, QWidget * parent) :
TabWidget(TabWidget::tr("Settings for %1").arg(tr(caption.toUtf8())), parent),
QGroupBox(QGroupBox::tr("Settings for %1").arg(tr(caption.toUtf8())), parent),
m_configSection(configSection),
m_device(nullptr)
{
@@ -45,12 +45,11 @@ MidiSetupWidget::MidiSetupWidget(const QString & caption, const QString & config
// to indicate that there is no editable device field
if (!devName.isNull())
{
m_device = new QLineEdit(devName, this);
m_device->setGeometry(10, 20, 160, 20);
QFormLayout * form = new QFormLayout(this);
auto dev_lbl = new QLabel(tr("Device"), this);
dev_lbl->setFont(pointSize<7>(dev_lbl->font()));
dev_lbl->setGeometry(10, 40, 160, 10);
m_device = new QLineEdit(devName, this);
form->addRow(tr("Device"), m_device);
}
}

View File

@@ -23,14 +23,15 @@
*/
#include <QCheckBox>
#include <QComboBox>
#include <QGroupBox>
#include <QImageReader>
#include <QLabel>
#include <QLayout>
#include <QLineEdit>
#include <QScrollArea>
#include "AudioDeviceSetupWidget.h"
#include "AudioEngine.h"
#include "debug.h"
#include "embed.h"
@@ -79,13 +80,12 @@ inline void labelWidget(QWidget * w, const QString & txt)
auto title = new QLabel(txt, w);
QFont f = title->font();
f.setBold(true);
title->setFont(pointSize<12>(f));
title->setFont(f);
QBoxLayout * boxLayout = dynamic_cast<QBoxLayout *>(w->layout());
assert(boxLayout);
assert(dynamic_cast<QBoxLayout *>(w->layout()) != nullptr);
dynamic_cast<QBoxLayout *>(w->layout())->addSpacing(5);
dynamic_cast<QBoxLayout *>(w->layout())->addWidget(title);
boxLayout->addWidget(title);
}
@@ -162,15 +162,10 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
// TODO: Equivalent to the new setWindowFlag(Qt::WindowContextHelpButtonHint, false)
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setModal(true);
setFixedSize(454, 400);
Engine::projectJournal()->setJournalling(false);
// Constants for positioning LED check boxes.
constexpr int XDelta = 10;
constexpr int YDelta = 18;
// Main widget.
auto main_w = new QWidget(this);
@@ -191,7 +186,8 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
// Settings widget.
auto settings_w = new QWidget(main_w);
settings_w->setFixedSize(360, 360);
QVBoxLayout * settingsLayout = new QVBoxLayout(settings_w);
// General widget.
auto general_w = new QWidget(settings_w);
@@ -211,77 +207,79 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
// Path selectors layout.
auto generalControlsLayout = new QVBoxLayout;
generalControlsLayout->setSpacing(10);
generalControlsLayout->setContentsMargins(0, 0, 0, 0);
auto addLedCheckBox = [&](const QString& ledText, TabWidget* tw, int& counter,
bool initialState, const char* toggledSlot, bool showRestartWarning) {
auto checkBox = new LedCheckBox(ledText, tw);
counter++;
checkBox->move(XDelta, YDelta * counter);
auto addCheckBox = [&](const QString& ledText, QWidget* parent, QBoxLayout * layout,
bool initialState, const char* toggledSlot, bool showRestartWarning) -> QCheckBox * {
auto checkBox = new QCheckBox(ledText, parent);
checkBox->setChecked(initialState);
connect(checkBox, SIGNAL(toggled(bool)), this, toggledSlot);
if (showRestartWarning)
{
connect(checkBox, SIGNAL(toggled(bool)), this, SLOT(showRestartWarning()));
}
if (layout)
{
layout->addWidget(checkBox);
}
return checkBox;
};
int counter = 0;
// GUI tab.
auto gui_tw = new TabWidget(tr("Graphical user interface (GUI)"), generalControls);
QGroupBox * guiGroupBox = new QGroupBox(tr("Graphical user interface (GUI)"), generalControls);
QVBoxLayout * guiGroupLayout = new QVBoxLayout(guiGroupBox);
addLedCheckBox(tr("Display volume as dBFS "), gui_tw, counter,
addCheckBox(tr("Display volume as dBFS "), guiGroupBox, guiGroupLayout,
m_displaydBFS, SLOT(toggleDisplaydBFS(bool)), true);
addLedCheckBox(tr("Enable tooltips"), gui_tw, counter,
addCheckBox(tr("Enable tooltips"), guiGroupBox, guiGroupLayout,
m_tooltips, SLOT(toggleTooltips(bool)), true);
addLedCheckBox(tr("Enable master oscilloscope by default"), gui_tw, counter,
addCheckBox(tr("Enable master oscilloscope by default"), guiGroupBox, guiGroupLayout,
m_displayWaveform, SLOT(toggleDisplayWaveform(bool)), true);
addLedCheckBox(tr("Enable all note labels in piano roll"), gui_tw, counter,
addCheckBox(tr("Enable all note labels in piano roll"), guiGroupBox, guiGroupLayout,
m_printNoteLabels, SLOT(toggleNoteLabels(bool)), false);
addLedCheckBox(tr("Enable compact track buttons"), gui_tw, counter,
addCheckBox(tr("Enable compact track buttons"), guiGroupBox, guiGroupLayout,
m_compactTrackButtons, SLOT(toggleCompactTrackButtons(bool)), true);
addLedCheckBox(tr("Enable one instrument-track-window mode"), gui_tw, counter,
addCheckBox(tr("Enable one instrument-track-window mode"), guiGroupBox, guiGroupLayout,
m_oneInstrumentTrackWindow, SLOT(toggleOneInstrumentTrackWindow(bool)), true);
addLedCheckBox(tr("Show sidebar on the right-hand side"), gui_tw, counter,
addCheckBox(tr("Show sidebar on the right-hand side"), guiGroupBox, guiGroupLayout,
m_sideBarOnRight, SLOT(toggleSideBarOnRight(bool)), true);
addLedCheckBox(tr("Let sample previews continue when mouse is released"), gui_tw, counter,
addCheckBox(tr("Let sample previews continue when mouse is released"), guiGroupBox, guiGroupLayout,
m_letPreviewsFinish, SLOT(toggleLetPreviewsFinish(bool)), false);
addLedCheckBox(tr("Mute automation tracks during solo"), gui_tw, counter,
addCheckBox(tr("Mute automation tracks during solo"), guiGroupBox, guiGroupLayout,
m_soloLegacyBehavior, SLOT(toggleSoloLegacyBehavior(bool)), false);
addLedCheckBox(tr("Show warning when deleting tracks"), gui_tw, counter,
addCheckBox(tr("Show warning when deleting tracks"), guiGroupBox, guiGroupLayout,
m_trackDeletionWarning, SLOT(toggleTrackDeletionWarning(bool)), false);
addLedCheckBox(tr("Show warning when deleting a mixer channel that is in use"), gui_tw, counter,
addCheckBox(tr("Show warning when deleting a mixer channel that is in use"), guiGroupBox, guiGroupLayout,
m_mixerChannelDeletionWarning, SLOT(toggleMixerChannelDeletionWarning(bool)), false);
gui_tw->setFixedHeight(YDelta + YDelta * counter);
generalControlsLayout->addWidget(guiGroupBox);
generalControlsLayout->addWidget(gui_tw);
generalControlsLayout->addSpacing(10);
counter = 0;
// Projects tab.
auto projects_tw = new TabWidget(tr("Projects"), generalControls);
QGroupBox * projectsGroupBox = new QGroupBox(tr("Projects"), generalControls);
QVBoxLayout * projectsGroupLayout = new QVBoxLayout(projectsGroupBox);
addLedCheckBox(tr("Compress project files by default"), projects_tw, counter,
addCheckBox(tr("Compress project files by default"), projectsGroupBox, projectsGroupLayout,
m_MMPZ, SLOT(toggleMMPZ(bool)), true);
addLedCheckBox(tr("Create a backup file when saving a project"), projects_tw, counter,
addCheckBox(tr("Create a backup file when saving a project"), projectsGroupBox, projectsGroupLayout,
m_disableBackup, SLOT(toggleDisableBackup(bool)), false);
addLedCheckBox(tr("Reopen last project on startup"), projects_tw, counter,
addCheckBox(tr("Reopen last project on startup"), projectsGroupBox, projectsGroupLayout,
m_openLastProject, SLOT(toggleOpenLastProject(bool)), false);
projects_tw->setFixedHeight(YDelta + YDelta * counter);
generalControlsLayout->addWidget(projectsGroupBox);
generalControlsLayout->addWidget(projects_tw);
generalControlsLayout->addSpacing(10);
// Language tab.
auto lang_tw = new TabWidget(tr("Language"), generalControls);
lang_tw->setFixedHeight(48);
auto changeLang = new QComboBox(lang_tw);
changeLang->move(XDelta, 20);
QGroupBox * languageGroupBox = new QGroupBox(tr("Language"), generalControls);
QVBoxLayout * languageGroupLayout = new QVBoxLayout(languageGroupBox);
auto changeLang = new QComboBox(languageGroupBox);
languageGroupLayout->addWidget(changeLang);
QDir dir(ConfigManager::inst()->localeDir());
QStringList fileNames = dir.entryList(QStringList("*.qm"));
@@ -333,7 +331,7 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
connect(changeLang, SIGNAL(currentIndexChanged(int)),
this, SLOT(showRestartWarning()));
generalControlsLayout->addWidget(lang_tw);
generalControlsLayout->addWidget(languageGroupBox);
generalControlsLayout->addSpacing(10);
// General layout ordering.
@@ -341,9 +339,7 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
generalControls->setLayout(generalControlsLayout);
generalScroll->setWidget(generalControls);
generalScroll->setWidgetResizable(true);
general_layout->addWidget(generalScroll);
general_layout->addStretch();
general_layout->addWidget(generalScroll, 1);
@@ -357,71 +353,63 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
// Autosave tab.
auto auto_save_tw = new TabWidget(tr("Autosave"), performance_w);
auto_save_tw->setFixedHeight(106);
QGroupBox * autoSaveBox = new QGroupBox(tr("Autosave"), performance_w);
QVBoxLayout * autoSaveLayout = new QVBoxLayout(autoSaveBox);
QHBoxLayout * autoSaveSubLayout = new QHBoxLayout();
m_saveIntervalSlider = new QSlider(Qt::Horizontal, auto_save_tw);
m_saveIntervalSlider = new QSlider(Qt::Horizontal, autoSaveBox);
m_saveIntervalSlider->setValue(m_saveInterval);
m_saveIntervalSlider->setRange(1, 20);
m_saveIntervalSlider->setTickInterval(1);
m_saveIntervalSlider->setPageStep(1);
m_saveIntervalSlider->setGeometry(10, 18, 340, 18);
m_saveIntervalSlider->setTickPosition(QSlider::TicksBelow);
connect(m_saveIntervalSlider, SIGNAL(valueChanged(int)),
this, SLOT(setAutoSaveInterval(int)));
m_saveIntervalLbl = new QLabel(auto_save_tw);
m_saveIntervalLbl->setGeometry(10, 40, 200, 24);
setAutoSaveInterval(m_saveIntervalSlider->value());
m_autoSave = new LedCheckBox(
tr("Enable autosave"), auto_save_tw);
m_autoSave->move(10, 70);
m_autoSave->setChecked(m_enableAutoSave);
connect(m_autoSave, SIGNAL(toggled(bool)),
this, SLOT(toggleAutoSave(bool)));
m_runningAutoSave = new LedCheckBox(
tr("Allow autosave while playing"), auto_save_tw);
m_runningAutoSave->move(20, 88);
m_runningAutoSave->setChecked(m_enableRunningAutoSave);
connect(m_runningAutoSave, SIGNAL(toggled(bool)),
this, SLOT(toggleRunningAutoSave(bool)));
auto autoSaveResetBtn = new QPushButton(embed::getIconPixmap("reload"), "", auto_save_tw);
autoSaveResetBtn->setGeometry(320, 70, 28, 28);
auto autoSaveResetBtn = new QPushButton(embed::getIconPixmap("reload"), "", autoSaveBox);
autoSaveResetBtn->setFixedSize(32, 32);
connect(autoSaveResetBtn, SIGNAL(clicked()),
this, SLOT(resetAutoSave()));
this, SLOT(resetAutoSave()));
autoSaveSubLayout->addWidget(m_saveIntervalSlider);
autoSaveSubLayout->addWidget(autoSaveResetBtn);
autoSaveLayout->addLayout(autoSaveSubLayout);
m_saveIntervalLbl = new QLabel(autoSaveBox);
setAutoSaveInterval(m_saveIntervalSlider->value());
autoSaveLayout->addWidget(m_saveIntervalLbl);
m_autoSave = addCheckBox(tr("Enable autosave"), autoSaveBox, autoSaveLayout,
m_enableAutoSave, SLOT(toggleAutoSave(bool)), false);
m_runningAutoSave = addCheckBox(tr("Allow autosave while playing"), autoSaveBox, autoSaveLayout,
m_enableRunningAutoSave, SLOT(toggleRunningAutoSave(bool)), false);
m_saveIntervalSlider->setEnabled(m_enableAutoSave);
m_runningAutoSave->setVisible(m_enableAutoSave);
counter = 0;
// UI effect vs. performance tab.
auto ui_fx_tw = new TabWidget(tr("User interface (UI) effects vs. performance"), performance_w);
QGroupBox * uiFxBox = new QGroupBox(tr("User interface (UI) effects vs. performance"), performance_w);
QVBoxLayout * uiFxLayout = new QVBoxLayout(uiFxBox);
addLedCheckBox(tr("Smooth scroll in song editor"), ui_fx_tw, counter,
addCheckBox(tr("Smooth scroll in song editor"), uiFxBox, uiFxLayout,
m_smoothScroll, SLOT(toggleSmoothScroll(bool)), false);
addLedCheckBox(tr("Display playback cursor in AudioFileProcessor"), ui_fx_tw, counter,
addCheckBox(tr("Display playback cursor in AudioFileProcessor"), uiFxBox, uiFxLayout,
m_animateAFP, SLOT(toggleAnimateAFP(bool)), false);
ui_fx_tw->setFixedHeight(YDelta + YDelta * counter);
// Plugins group
QGroupBox * pluginsBox = new QGroupBox(tr("Plugins"), performance_w);
QVBoxLayout * pluginsLayout = new QVBoxLayout(pluginsBox);
counter = 0;
// Plugins tab.
auto plugins_tw = new TabWidget(tr("Plugins"), performance_w);
m_vstEmbedLbl = new QLabel(plugins_tw);
m_vstEmbedLbl->move(XDelta, YDelta * ++counter);
m_vstEmbedLbl = new QLabel(pluginsBox);
m_vstEmbedLbl->setText(tr("VST plugins embedding:"));
pluginsLayout->addWidget(m_vstEmbedLbl);
m_vstEmbedComboBox = new QComboBox(plugins_tw);
m_vstEmbedComboBox->move(XDelta, YDelta * ++counter);
m_vstEmbedComboBox = new QComboBox(pluginsBox);
QStringList embedMethods = ConfigManager::availableVstEmbedMethods();
m_vstEmbedComboBox->addItem(tr("No embedding"), "none");
@@ -440,27 +428,19 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
m_vstEmbedComboBox->setCurrentIndex(m_vstEmbedComboBox->findData(m_vstEmbedMethod));
connect(m_vstEmbedComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(vstEmbedMethodChanged()));
pluginsLayout->addWidget(m_vstEmbedComboBox);
counter += 2;
m_vstAlwaysOnTopCheckBox = addCheckBox(tr("Keep plugin windows on top when not embedded"), pluginsBox, pluginsLayout,
m_vstAlwaysOnTop, SLOT(toggleVSTAlwaysOnTop(bool)), false);
m_vstAlwaysOnTopCheckBox = new LedCheckBox(
tr("Keep plugin windows on top when not embedded"), plugins_tw);
m_vstAlwaysOnTopCheckBox->move(20, 66);
m_vstAlwaysOnTopCheckBox->setChecked(m_vstAlwaysOnTop);
m_vstAlwaysOnTopCheckBox->setVisible(m_vstEmbedMethod == "none");
connect(m_vstAlwaysOnTopCheckBox, SIGNAL(toggled(bool)),
this, SLOT(toggleVSTAlwaysOnTop(bool)));
addLedCheckBox(tr("Keep effects running even without input"), plugins_tw, counter,
addCheckBox(tr("Keep effects running even without input"), pluginsBox, pluginsLayout,
m_disableAutoQuit, SLOT(toggleDisableAutoQuit(bool)), false);
plugins_tw->setFixedHeight(YDelta + YDelta * counter);
// Performance layout ordering.
performance_layout->addWidget(auto_save_tw);
performance_layout->addWidget(ui_fx_tw);
performance_layout->addWidget(plugins_tw);
performance_layout->addWidget(autoSaveBox);
performance_layout->addWidget(uiFxBox);
performance_layout->addWidget(pluginsBox);
performance_layout->addStretch();
@@ -473,17 +453,15 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
labelWidget(audio_w,
tr("Audio"));
// Audio interface tab.
auto audioiface_tw = new TabWidget(tr("Audio interface"), audio_w);
audioiface_tw->setFixedHeight(56);
m_audioInterfaces = new QComboBox(audioiface_tw);
m_audioInterfaces->setGeometry(10, 20, 240, 28);
// Audio interface group
QGroupBox * audioInterfaceBox = new QGroupBox(tr("Audio interface"), audio_w);
QVBoxLayout * audioInterfaceLayout = new QVBoxLayout(audioInterfaceBox);
m_audioInterfaces = new QComboBox(audioInterfaceBox);
audioInterfaceLayout->addWidget(m_audioInterfaces);
// Ifaces-settings-widget.
auto as_w = new QWidget(audio_w);
as_w->setFixedHeight(60);
auto as_w_layout = new QHBoxLayout(as_w);
as_w_layout->setSpacing(0);
@@ -563,61 +541,58 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
this, SLOT(audioInterfaceChanged(const QString&)));
// Advanced setting, hidden for now
if(false)
{
auto useNaNHandler = new LedCheckBox(tr("Use built-in NaN handler"), audio_w);
useNaNHandler->setChecked(m_NaNHandler);
}
// // TODO Handle or remove.
// auto useNaNHandler = new LedCheckBox(tr("Use built-in NaN handler"), audio_w);
// audio_layout->addWidget(useNaNHandler);
// useNaNHandler->setChecked(m_NaNHandler);
// HQ mode LED.
auto hqaudio = new LedCheckBox(tr("HQ mode for output audio device"), audio_w);
hqaudio->move(10, 0);
hqaudio->setChecked(m_hqAudioDev);
connect(hqaudio, SIGNAL(toggled(bool)),
this, SLOT(toggleHQAudioDev(bool)));
// HQ mode checkbox
auto hqaudio = addCheckBox(tr("HQ mode for output audio device"), audioInterfaceBox, nullptr,
m_hqAudioDev, SLOT(toggleHQAudioDev(bool)), false);
// Buffer size group
QGroupBox * bufferSizeBox = new QGroupBox(tr("Buffer size"), audio_w);
QVBoxLayout * bufferSizeLayout = new QVBoxLayout(bufferSizeBox);
QHBoxLayout * bufferSizeSubLayout = new QHBoxLayout();
// Buffer size tab.
auto bufferSize_tw = new TabWidget(tr("Buffer size"), audio_w);
auto bufferSize_layout = new QVBoxLayout(bufferSize_tw);
bufferSize_layout->setSpacing(10);
bufferSize_layout->setContentsMargins(10, 18, 10, 10);
m_bufferSizeSlider = new QSlider(Qt::Horizontal, bufferSize_tw);
m_bufferSizeSlider = new QSlider(Qt::Horizontal, bufferSizeBox);
m_bufferSizeSlider->setRange(1, 128);
m_bufferSizeSlider->setTickInterval(8);
m_bufferSizeSlider->setPageStep(8);
m_bufferSizeSlider->setValue(m_bufferSize / BUFFERSIZE_RESOLUTION);
m_bufferSizeSlider->setTickPosition(QSlider::TicksBelow);
m_bufferSizeLbl = new QLabel(bufferSize_tw);
m_bufferSizeWarnLbl = new QLabel(bufferSize_tw);
m_bufferSizeWarnLbl->setWordWrap(true);
connect(m_bufferSizeSlider, SIGNAL(valueChanged(int)),
this, SLOT(setBufferSize(int)));
connect(m_bufferSizeSlider, SIGNAL(valueChanged(int)),
this, SLOT(showRestartWarning()));
setBufferSize(m_bufferSizeSlider->value());
bufferSizeSubLayout->addWidget(m_bufferSizeSlider, 1);
auto bufferSize_reset_btn = new QPushButton(embed::getIconPixmap("reload"), "", bufferSize_tw);
auto bufferSize_reset_btn = new QPushButton(embed::getIconPixmap("reload"), "", bufferSizeBox);
bufferSize_reset_btn->setFixedSize(32, 32);
connect(bufferSize_reset_btn, SIGNAL(clicked()),
this, SLOT(resetBufferSize()));
this, SLOT(resetBufferSize()));
bufferSize_reset_btn->setToolTip(
tr("Reset to default value"));
tr("Reset to default value"));
bufferSize_layout->addWidget(m_bufferSizeSlider);
bufferSize_layout->addWidget(m_bufferSizeLbl);
bufferSize_layout->addWidget(m_bufferSizeWarnLbl);
bufferSize_layout->addWidget(bufferSize_reset_btn);
bufferSizeSubLayout->addWidget(bufferSize_reset_btn);
bufferSizeLayout->addLayout(bufferSizeSubLayout);
m_bufferSizeLbl = new QLabel(bufferSizeBox);
bufferSizeLayout->addWidget(m_bufferSizeLbl);
m_bufferSizeWarnLbl = new QLabel(bufferSizeBox);
m_bufferSizeWarnLbl->setWordWrap(true);
bufferSizeLayout->addWidget(m_bufferSizeWarnLbl);
setBufferSize(m_bufferSizeSlider->value());
// Audio layout ordering.
audio_layout->addWidget(audioiface_tw);
audio_layout->addWidget(audioInterfaceBox);
audio_layout->addWidget(as_w);
audio_layout->addWidget(hqaudio);
audio_layout->addWidget(bufferSize_tw);
audio_layout->addWidget(bufferSizeBox);
audio_layout->addStretch();
@@ -627,19 +602,17 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
auto midi_layout = new QVBoxLayout(midi_w);
midi_layout->setSpacing(10);
midi_layout->setContentsMargins(0, 0, 0, 0);
labelWidget(midi_w,
tr("MIDI"));
labelWidget(midi_w, tr("MIDI"));
// MIDI interface tab.
auto midiiface_tw = new TabWidget(tr("MIDI interface"), midi_w);
midiiface_tw->setFixedHeight(56);
// MIDI interface group
QGroupBox * midiInterfaceBox = new QGroupBox(tr("MIDI interface"), midi_w);
QVBoxLayout * midiInterfaceLayout = new QVBoxLayout(midiInterfaceBox);
m_midiInterfaces = new QComboBox(midiiface_tw);
m_midiInterfaces->setGeometry(10, 20, 240, 28);
m_midiInterfaces = new QComboBox(midiInterfaceBox);
midiInterfaceLayout->addWidget(m_midiInterfaces);
// Ifaces-settings-widget.
auto ms_w = new QWidget(midi_w);
ms_w->setFixedHeight(60);
auto ms_w_layout = new QHBoxLayout(ms_w);
ms_w_layout->setSpacing(0);
@@ -709,12 +682,12 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
this, SLOT(midiInterfaceChanged(const QString&)));
// MIDI autoassign tab.
auto midiAutoAssign_tw = new TabWidget(tr("Automatically assign MIDI controller to selected track"), midi_w);
midiAutoAssign_tw->setFixedHeight(56);
// MIDI autoassign group
QGroupBox * midiAutoAssignBox = new QGroupBox(tr("Automatically assign MIDI controller to selected track"), midi_w);
QVBoxLayout * midiAutoAssignLayout = new QVBoxLayout(midiAutoAssignBox);
m_assignableMidiDevices = new QComboBox(midiAutoAssign_tw);
m_assignableMidiDevices->setGeometry(10, 20, 240, 28);
m_assignableMidiDevices = new QComboBox(midiAutoAssignBox);
midiAutoAssignLayout->addWidget(m_assignableMidiDevices);
m_assignableMidiDevices->addItem("none");
if ( !Engine::audioEngine()->midiClient()->isRaw() )
{
@@ -731,9 +704,9 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
}
// MIDI layout ordering.
midi_layout->addWidget(midiiface_tw);
midi_layout->addWidget(midiInterfaceBox);
midi_layout->addWidget(ms_w);
midi_layout->addWidget(midiAutoAssign_tw);
midi_layout->addWidget(midiAutoAssignBox);
midi_layout->addStretch();
@@ -756,29 +729,29 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
// Path selectors widget.
auto pathSelectors = new QWidget(paths_w);
const int txtLength = 284;
const int btnStart = 300;
// Path selectors layout.
auto pathSelectorsLayout = new QVBoxLayout;
pathSelectorsLayout->setSpacing(10);
pathSelectorsLayout->setContentsMargins(0, 0, 0, 0);
auto addPathEntry = [&](const QString& caption, const QString& content, const char* setSlot, const char* openSlot,
QLineEdit*& lineEdit, const char* pixmap = "project_open") {
auto newTw = new TabWidget(caption, pathSelectors);
newTw->setFixedHeight(48);
auto pathEntryGroupBox = new QGroupBox(caption, pathSelectors);
QHBoxLayout * pathEntryLayout = new QHBoxLayout(pathEntryGroupBox);
lineEdit = new QLineEdit(content, newTw);
lineEdit->setGeometry(10, 20, txtLength, 16);
lineEdit = new QLineEdit(content, pathEntryGroupBox);
connect(lineEdit, SIGNAL(textChanged(const QString&)),
this, setSlot);
auto selectBtn = new QPushButton(embed::getIconPixmap(pixmap, 16, 16), "", newTw);
pathEntryLayout->addWidget(lineEdit, 1);
auto selectBtn = new QPushButton(embed::getIconPixmap(pixmap, 16, 16), "", pathEntryGroupBox);
selectBtn->setFixedSize(24, 24);
selectBtn->move(btnStart, 16);
connect(selectBtn, SIGNAL(clicked()), this, openSlot);
pathSelectorsLayout->addWidget(newTw);
pathEntryLayout->addWidget(selectBtn, 0);
pathSelectorsLayout->addWidget(pathEntryGroupBox);
pathSelectorsLayout->addSpacing(10);
};
@@ -824,24 +797,32 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
pathsScroll->setWidget(pathSelectors);
pathsScroll->setWidgetResizable(true);
paths_layout->addWidget(pathsScroll);
paths_layout->addWidget(pathsScroll, 1);
paths_layout->addStretch();
// Add all main widgets to the layout of the settings widget
// This is needed so that we automatically get the correct sizes.
settingsLayout->addWidget(general_w);
settingsLayout->addWidget(performance_w);
settingsLayout->addWidget(audio_w);
settingsLayout->addWidget(midi_w);
settingsLayout->addWidget(paths_w);
// Major tabs ordering.
m_tabBar->addTab(general_w,
tr("General"), 0, false, true)->setIcon(
tr("General"), 0, false, true, false)->setIcon(
embed::getIconPixmap("setup_general"));
m_tabBar->addTab(performance_w,
tr("Performance"), 1, false, true)->setIcon(
tr("Performance"), 1, false, true, false)->setIcon(
embed::getIconPixmap("setup_performance"));
m_tabBar->addTab(audio_w,
tr("Audio"), 2, false, true)->setIcon(
tr("Audio"), 2, false, true, false)->setIcon(
embed::getIconPixmap("setup_audio"));
m_tabBar->addTab(midi_w,
tr("MIDI"), 3, false, true)->setIcon(
tr("MIDI"), 3, false, true, false)->setIcon(
embed::getIconPixmap("setup_midi"));
m_tabBar->addTab(paths_w,
tr("Paths"), 4, true, true)->setIcon(
tr("Paths"), 4, true, true, false)->setIcon(
embed::getIconPixmap("setup_directories"));
m_tabBar->setActiveTab(static_cast<int>(tab_to_open));
@@ -884,11 +865,14 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
extras_layout->addSpacing(10);
// Vertical layout ordering.
vlayout->addWidget(main_w);
vlayout->addWidget(main_w, 1);
vlayout->addSpacing(10);
vlayout->addWidget(extras_w);
vlayout->addSpacing(10);
// Ensure that we cannot make the dialog smaller than it wants to be
setMinimumWidth(width());
show();
}

View File

@@ -44,7 +44,7 @@ TabBar::TabBar( QWidget * _parent, QBoxLayout::Direction _dir ) :
}
TabButton * TabBar::addTab( QWidget * _w, const QString & _text, int _id,
bool _add_stretch, bool _text_is_tooltip )
bool _add_stretch, bool _text_is_tooltip, bool fixWidgetToParentSize )
{
// already tab with id?
if( m_tabs.contains( _id ) )
@@ -83,10 +83,12 @@ TabButton * TabBar::addTab( QWidget * _w, const QString & _text, int _id,
m_layout->addStretch();
}
// we assume, parent-widget is a widget acting as widget-stack so all
// widgets have the same size and only the one on the top is visible
_w->setFixedSize( _w->parentWidget()->size() );
if (fixWidgetToParentSize)
{
// we assume, parent-widget is a widget acting as widget-stack so all
// widgets have the same size and only the one on the top is visible
_w->setFixedSize( _w->parentWidget()->size() );
}
b->setFont( pointSize<8>( b->font() ) );