Bump minimum Qt version to 5.15 (#8129)

This commit is contained in:
Dalton Messmer
2025-11-11 12:57:14 -05:00
committed by GitHub
parent c79d6af3ab
commit 478f5345dd
39 changed files with 41 additions and 306 deletions

View File

@@ -185,7 +185,7 @@ if(WANT_QT6)
set(STATUS_QT6 "Enabled")
else()
set(QT_VERSION_MAJOR 5)
set(LMMS_QT_MIN_VERSION 5.9.0)
set(LMMS_QT_MIN_VERSION 5.15.0)
set(STATUS_QT6 "Disabled")
endif()

View File

@@ -226,11 +226,7 @@ private:
// Mutex to make methods involving automation clips thread safe
// Mutable so we can lock it from const objects
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
mutable QRecursiveMutex m_clipMutex;
#else
mutable QMutex m_clipMutex;
#endif
AutomationTrack * m_autoTrack;
std::vector<jo_id_t> m_idsToResolve;

View File

@@ -38,37 +38,6 @@
namespace lmms
{
/**
* @brief horizontalAdvance is a backwards-compatible adapter for
* QFontMetrics::horizontalAdvance and width functions.
* @param metrics
* @param text
* @return text's horizontal advance based on metrics.
*/
inline int horizontalAdvance(const QFontMetrics& metrics, const QString& text)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
return metrics.horizontalAdvance(text);
#else
return metrics.width(text);
#endif
}
/**
* @brief position is a backwards-compatible adapter for
* QWheelEvent::position and pos functions.
* @param wheelEvent
* @return the position of wheelEvent
*/
inline QPoint position(const QWheelEvent* wheelEvent)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
return wheelEvent->position().toPoint();
#else
return wheelEvent->pos();
#endif
}
/**
* @brief position is a backwards-compatible adapter for
* QDropEvent::position and pos functions.

View File

@@ -63,18 +63,10 @@ protected:
QString name = sourceModel()->data(nameIndex, Qt::DisplayRole).toString();
QString type = sourceModel()->data(typeIndex, Qt::DisplayRole).toString();
// TODO: cleanup once we drop Qt5 support
#if (QT_VERSION >= QT_VERSION_CHECK(5,12,0))
QRegularExpression nameRegularExpression(filterRegularExpression());
nameRegularExpression.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
bool nameFilterPassed = nameRegularExpression.match(name).capturedStart() != -1;
#else
QRegExp nameRegularExpression(filterRegExp());
nameRegularExpression.setCaseSensitivity(Qt::CaseInsensitive);
bool nameFilterPassed = nameRegularExpression.indexIn(name) != -1;
#endif
bool typeFilterPassed = type.contains(m_effectTypeFilter, Qt::CaseInsensitive);

View File

@@ -164,12 +164,8 @@ private:
//! This should only be accessed or modified when m_pphMutex is held
PlayHandle* m_previewPlayHandle;
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
QRecursiveMutex m_pphMutex;
#else
QMutex m_pphMutex;
#endif
QList<QAction*> getContextActions(FileItem* item, bool songEditor);

View File

@@ -27,9 +27,7 @@
#include <QThread>
#include <QProcess>
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
#include <QRecursiveMutex> // IWYU pragma: keep
#endif
#include <QRecursiveMutex>
#include "RemotePluginBase.h"
#include "SharedMemory.h"
@@ -166,11 +164,7 @@ private:
QString m_exec;
QStringList m_args;
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
QRecursiveMutex m_commMutex;
#else
QMutex m_commMutex;
#endif
bool m_splitChannels;
SharedMemory<float[]> m_audioBuffer;

View File

@@ -846,17 +846,6 @@ CarlaParamsView::CarlaParamsView(CarlaInstrumentView* const instrumentView, QWid
splitter->addWidget(outputFrame);
verticalLayout->addWidget(splitter);
#if QT_VERSION < 0x50C00
// Workaround for a bug in Qt versions below 5.12,
// where argument-dependent-lookup fails for QFlags operators
// declared inside a namespace.
// This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h
// See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348
using ::operator|;
#endif
// -- Sub window
auto win = new CarlaParamsSubWindow(getGUI()->mainWindow()->workspace()->viewport(),
Qt::SubWindow | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
@@ -1051,17 +1040,6 @@ void CarlaParamsView::windowResized()
void CarlaParamsView::addKnob(uint32_t index)
{
#if QT_VERSION < 0x50C00
// Workaround for a bug in Qt versions below 5.12,
// where argument-dependent-lookup fails for QFlags operators
// declared inside a namespace.
// This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h
// See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348
using ::operator|;
#endif
bool output = m_carlaInstrument->m_paramModels[index]->isOutput();
if (output)
{

View File

@@ -139,10 +139,6 @@ QString GranularPitchShifterHelpView::s_helpText=
GranularPitchShifterHelpView::GranularPitchShifterHelpView():QTextEdit(s_helpText)
{
#if (QT_VERSION < QT_VERSION_CHECK(5,12,0))
// Bug workaround: https://codereview.qt-project.org/c/qt/qtbase/+/225348
using ::operator|;
#endif
setWindowTitle("Granular Pitch Shifter Help");
setTextInteractionFlags(Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse);
getGUI()->mainWindow()->addWindowedWidget(this);

View File

@@ -441,11 +441,8 @@ QString Lb302Synth::nodeName() const
// OBSOLETE. Break apart once we get Q_OBJECT to work. >:[
void Lb302Synth::recalcFilter()
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
vcf.loadRelaxed()->recalc();
#else
vcf.load()->recalc();
#endif
// THIS IS OLD 3pole/24dB code, I may reintegrate it. Don't need it
// right now. Should be toggled by LB_24_RES_TRICK at the moment.
@@ -700,11 +697,8 @@ void Lb302Synth::initNote( Lb302Note *n)
if(n->dead ==0){
// Swap next two blocks??
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
vcf.loadRelaxed()->playNote();
#else
vcf.load()->playNote();
#endif
// Ensure envelope is recalculated
vcf_envpos = ENVINC;

View File

@@ -474,10 +474,6 @@ QString SlewDistortionHelpView::s_helpText = tr(
SlewDistortionHelpView::SlewDistortionHelpView() : QTextEdit(s_helpText)
{
#if (QT_VERSION < QT_VERSION_CHECK(5,12,0))
// Bug workaround: https://codereview.qt-project.org/c/qt/qtbase/+/225348
using ::operator|;
#endif
setWindowTitle("Slew Distortion Help");
setTextInteractionFlags(Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse);
getGUI()->mainWindow()->addWindowedWidget(this);

View File

@@ -922,17 +922,6 @@ ManageVestigeInstrumentView::ManageVestigeInstrumentView( Instrument * _instrume
QWidget * _parent, VestigeInstrument * m_vi2 ) :
InstrumentViewFixedSize( _instrument, _parent )
{
#if QT_VERSION < 0x50C00
// Workaround for a bug in Qt versions below 5.12,
// where argument-dependent-lookup fails for QFlags operators
// declared inside a namespace.
// This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h
// See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348
using ::operator|;
#endif
m_vi = m_vi2;
m_vi->m_scrollArea = new QScrollArea( this );
widget = new QWidget(this);

View File

@@ -48,16 +48,6 @@ VstEffectControlDialog::VstEffectControlDialog( VstEffectControls * _ctl ) :
m_plugin( nullptr ),
tbLabel( nullptr )
{
#if QT_VERSION < 0x50C00
// Workaround for a bug in Qt versions below 5.12,
// where argument-dependent-lookup fails for QFlags operators
// declared inside a namespace.
// This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h
// See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348
using ::operator|;
#endif
auto l = new QGridLayout(this);
l->setContentsMargins( 10, 10, 10, 10 );
l->setVerticalSpacing( 2 );

View File

@@ -315,19 +315,9 @@ namespace gui
ManageVSTEffectView::ManageVSTEffectView( VstEffect * _eff, VstEffectControls * m_vi ) :
m_effect( _eff )
{
#if QT_VERSION < 0x50C00
// Workaround for a bug in Qt versions below 5.12,
// where argument-dependent-lookup fails for QFlags operators
// declared inside a namespace.
// This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h
// See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348
using ::operator|;
#endif
m_vi2 = m_vi;
widget = new QWidget();
m_vi->m_scrollArea = new QScrollArea( widget );
m_vi->m_scrollArea = new QScrollArea(widget);
l = new QGridLayout( widget );
m_vi->m_subWindow = getGUI()->mainWindow()->addWindowedWidget(nullptr, Qt::SubWindow |

View File

@@ -861,18 +861,6 @@ QString XpressiveHelpView::s_helpText=
XpressiveHelpView::XpressiveHelpView():QTextEdit(s_helpText)
{
#if QT_VERSION < 0x50C00
// Workaround for a bug in Qt versions below 5.12,
// where argument-dependent-lookup fails for QFlags operators
// declared inside a namespace.
// This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h
// See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348
using ::operator|;
#endif
setWindowTitle ( "Xpressive Help" );
setTextInteractionFlags ( Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse );
getGUI()->mainWindow()->addWindowedWidget( this );

View File

@@ -47,9 +47,6 @@ const float AutomationClip::DEFAULT_MAX_VALUE = 1;
AutomationClip::AutomationClip( AutomationTrack * _auto_track ) :
Clip( _auto_track ),
#if (QT_VERSION < QT_VERSION_CHECK(5,14,0))
m_clipMutex(QMutex::Recursive),
#endif
m_autoTrack( _auto_track ),
m_objects(),
m_tension( 1.0 ),
@@ -66,9 +63,6 @@ AutomationClip::AutomationClip( AutomationTrack * _auto_track ) :
AutomationClip::AutomationClip( const AutomationClip & _clip_to_copy ) :
Clip(_clip_to_copy),
#if (QT_VERSION < QT_VERSION_CHECK(5,14,0))
m_clipMutex(QMutex::Recursive),
#endif
m_autoTrack( _clip_to_copy.m_autoTrack ),
m_objects( _clip_to_copy.m_objects ),
m_tension( _clip_to_copy.m_tension ),

View File

@@ -150,12 +150,8 @@ void PluginFactory::discoverPlugins()
QSet<QFileInfo> files;
for (const QString& searchPath : QDir::searchPaths("plugins"))
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
auto discoveredPluginList = QDir(searchPath).entryInfoList(nameFilters);
files.unite(QSet<QFileInfo>(discoveredPluginList.begin(), discoveredPluginList.end()));
#else
files.unite(QDir(searchPath).entryInfoList(nameFilters).toSet());
#endif
}
// Apply any plugin filters from environment LMMS_EXCLUDE_PLUGINS

View File

@@ -139,9 +139,6 @@ RemotePlugin::RemotePlugin() :
#endif
m_failed( true ),
m_watcher( this ),
#if (QT_VERSION < QT_VERSION_CHECK(5,14,0))
m_commMutex(QMutex::Recursive),
#endif
m_splitChannels( false ),
m_audioBufferSize( 0 ),
m_inputCount( DEFAULT_CHANNELS ),

View File

@@ -1057,11 +1057,7 @@ void Song::loadProject( const QString & fileName )
{
QTextStream(stderr) << tr("Can't load project: "
"Project file contains local paths to plugins.")
#if (QT_VERSION >= QT_VERSION_CHECK(5,15,0))
<< Qt::endl;
#else
<< endl;
#endif
}
}
}
@@ -1216,11 +1212,7 @@ void Song::loadProject( const QString & fileName )
}
else
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,15,0))
QTextStream(stderr) << Engine::getSong()->errorSummary() << Qt::endl;
#else
QTextStream(stderr) << Engine::getSong()->errorSummary() << endl;
#endif
}
}

View File

@@ -461,9 +461,6 @@ FileBrowserTreeWidget::FileBrowserTreeWidget(QWidget * parent ) :
m_mousePressed( false ),
m_pressPos(),
m_previewPlayHandle( nullptr )
#if (QT_VERSION < QT_VERSION_CHECK(5,14,0))
,m_pphMutex(QMutex::Recursive)
#endif
{
setColumnCount( 1 );
headerItem()->setHidden( true );
@@ -475,14 +472,6 @@ FileBrowserTreeWidget::FileBrowserTreeWidget(QWidget * parent ) :
SLOT(updateDirectory(QTreeWidgetItem*)));
connect( this, SIGNAL(itemExpanded(QTreeWidgetItem*)),
SLOT(updateDirectory(QTreeWidgetItem*)));
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 2) && defined LMMS_BUILD_WIN32
// Set the font for the QTreeWidget to the Windows System font to make sure that
// truncated (elided) items use the same font as non-truncated items.
// This is a workaround for this qt bug, fixed in 5.12.2: https://bugreports.qt.io/browse/QTBUG-29232
// TODO: remove this when all builds use a recent enough version of qt.
setFont( GuiApplication::getWin32SystemFont() );
#endif
}

View File

@@ -64,16 +64,6 @@ MicrotunerConfig::MicrotunerConfig() :
m_baseKeyModel(DefaultBaseKey, 0, NumKeys - 1, nullptr, tr("Base key")),
m_baseFreqModel(DefaultBaseFreq, 0.1f, 9999.999f, 0.001f, nullptr, tr("Base note frequency"))
{
#if QT_VERSION < 0x50C00
// Workaround for a bug in Qt versions below 5.12,
// where argument-dependent-lookup fails for QFlags operators
// declared inside a namespace.
// This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h
// See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348
using ::operator|;
#endif
setWindowIcon(embed::getIconPixmap("microtuner"));
setWindowTitle(tr("Microtuner Configuration"));
@@ -333,11 +323,7 @@ bool MicrotunerConfig::validateScaleForm()
if (name.contains('\n')) {fail(tr("Scale name cannot contain a new-line character")); return false;}
// check intervals
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
QStringList input = m_scaleTextEdit->toPlainText().split('\n', Qt::SkipEmptyParts);
#else
QStringList input = m_scaleTextEdit->toPlainText().split('\n', QString::SkipEmptyParts);
#endif
QStringList input = m_scaleTextEdit->toPlainText().split('\n', Qt::SkipEmptyParts);
for (auto &line: input)
{
if (line.isEmpty()) {continue;}
@@ -381,11 +367,7 @@ bool MicrotunerConfig::validateKeymapForm()
if (name.contains('\n')) {fail(tr("Keymap name cannot contain a new-line character")); return false;}
// check key mappings
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
QStringList input = m_keymapTextEdit->toPlainText().split('\n', Qt::SkipEmptyParts);
#else
QStringList input = m_keymapTextEdit->toPlainText().split('\n', QString::SkipEmptyParts);
#endif
QStringList input = m_keymapTextEdit->toPlainText().split('\n', Qt::SkipEmptyParts);
for (auto &line: input)
{
if (line.isEmpty()) {continue;}
@@ -415,11 +397,7 @@ bool MicrotunerConfig::applyScale()
std::vector<Interval> newIntervals;
newIntervals.emplace_back(1, 1);
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
QStringList input = m_scaleTextEdit->toPlainText().split('\n', Qt::SkipEmptyParts);
#else
QStringList input = m_scaleTextEdit->toPlainText().split('\n', QString::SkipEmptyParts);
#endif
for (auto &line: input)
{
if (line.isEmpty()) {continue;}
@@ -461,11 +439,7 @@ bool MicrotunerConfig::applyKeymap()
std::vector<int> newMap;
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
QStringList input = m_keymapTextEdit->toPlainText().split('\n', Qt::SkipEmptyParts);
#else
QStringList input = m_keymapTextEdit->toPlainText().split('\n', QString::SkipEmptyParts);
#endif
for (auto &line: input)
{
if (line.isEmpty()) {continue;}

View File

@@ -61,16 +61,6 @@ MixerView::MixerView(Mixer* mixer) :
SerializingObjectHook(),
m_mixer(mixer)
{
#if QT_VERSION < 0x50C00
// Workaround for a bug in Qt versions below 5.12,
// where argument-dependent-lookup fails for QFlags operators
// declared inside a namespace.
// This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h
// See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348
using ::operator|;
#endif
mixer->setHook(this);
//QPalette pal = palette();

View File

@@ -148,13 +148,7 @@ void ProjectNotes::setupActions()
QFontDatabase db;
m_comboFont->addItems( db.families() );
connect(m_comboFont,
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
QOverload<const QString&>::of(&QComboBox::activated),
#else
&QComboBox::textActivated,
#endif
m_edit, &QTextEdit::setFontFamily);
connect(m_comboFont, &QComboBox::textActivated, m_edit, &QTextEdit::setFontFamily);
m_comboFont->lineEdit()->setText( QApplication::font().family() );
@@ -167,13 +161,7 @@ void ProjectNotes::setupActions()
m_comboSize->addItem( QString::number( *it ) );
}
connect(m_comboSize,
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
QOverload<const QString&>::of(&QComboBox::activated),
#else
&QComboBox::textActivated,
#endif
this, &ProjectNotes::textSize);
connect(m_comboSize, &QComboBox::textActivated, this, &ProjectNotes::textSize);
m_comboSize->lineEdit()->setText( QString::number(
QApplication::font().pointSize() ) );

View File

@@ -53,16 +53,6 @@ SampleTrackWindow::SampleTrackWindow(SampleTrackView * tv) :
m_track(tv->model()),
m_stv(tv)
{
#if QT_VERSION < 0x50C00
// Workaround for a bug in Qt versions below 5.12,
// where argument-dependent-lookup fails for QFlags operators
// declared inside a namespace.
// This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h
// See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348
using ::operator|;
#endif
// init own layout + widgets
setFocusPolicy(Qt::StrongFocus);
auto vlayout = new QVBoxLayout(this);

View File

@@ -495,13 +495,14 @@ void MidiClipView::mouseDoubleClickEvent(QMouseEvent *_me)
void MidiClipView::wheelEvent(QWheelEvent * we)
{
const auto pos = we->position().toPoint();
if(m_clip->m_clipType == MidiClip::Type::BeatClip &&
(fixedClips() || pixelsPerBar() >= 96) &&
position(we).y() > height() - m_stepBtnOff.height())
pos.y() > height() - m_stepBtnOff.height())
{
// get the step number that was wheeled on and
// do calculations in floats to prevent rounding errors...
float tmp = ((float(position(we).x()) - BORDER_WIDTH) *
float tmp = ((float(pos.x()) - BORDER_WIDTH) *
float(m_clip -> m_steps)) / float(width() - BORDER_WIDTH*2);
int step = int( tmp );

View File

@@ -1644,7 +1644,7 @@ void AutomationEditor::wheelEvent(QWheelEvent * we )
}
x = qBound( 0, x, m_zoomingXModel.size() - 1 );
int mouseX = (position( we ).x() - VALUES_WIDTH)* TimePos::ticksPerBar();
int mouseX = (we->position().toPoint().x() - VALUES_WIDTH) * TimePos::ticksPerBar();
// ticks based on the mouse x-position where the scroll wheel was used
int ticks = mouseX / m_ppb;
// what would be the ticks in the new zoom level on the very same mouse x

View File

@@ -3882,13 +3882,14 @@ void PianoRoll::wheelEvent(QWheelEvent * we )
{
we->accept();
// handle wheel events for note edit area - for editing note vol/pan with mousewheel
if(position(we).x() > noteEditLeft() && position(we).x() < noteEditRight()
&& position(we).y() > noteEditTop() && position(we).y() < noteEditBottom())
const auto pos = we->position().toPoint();
if (pos.x() > noteEditLeft() && pos.x() < noteEditRight()
&& pos.y() > noteEditTop() && pos.y() < noteEditBottom())
{
if (!hasValidMidiClip()) {return;}
// get values for going through notes
int pixel_range = 8;
int x = position(we).x() - m_whiteKeyWidth;
int x = pos.x() - m_whiteKeyWidth;
int ticks_start = ( x - pixel_range / 2 ) *
TimePos::ticksPerBar() / m_ppb + m_currentPosition;
int ticks_end = ( x + pixel_range / 2 ) *
@@ -3925,7 +3926,7 @@ void PianoRoll::wheelEvent(QWheelEvent * we )
{
// show the volume hover-text only if all notes have the
// same volume
showVolTextFloat(nv[0]->getVolume(), position(we), 1000);
showVolTextFloat(nv[0]->getVolume(), pos, 1000);
}
}
else if( m_noteEditMode == NoteEditMode::Panning )
@@ -3944,7 +3945,7 @@ void PianoRoll::wheelEvent(QWheelEvent * we )
{
// show the pan hover-text only if all notes have the same
// panning
showPanTextFloat( nv[0]->getPanning(), position( we ), 1000 );
showPanTextFloat(nv[0]->getPanning(), pos, 1000);
}
}
update();
@@ -3994,7 +3995,7 @@ void PianoRoll::wheelEvent(QWheelEvent * we )
}
z = qBound( 0, z, m_zoomingModel.size() - 1 );
int x = (position(we).x() - m_whiteKeyWidth) * TimePos::ticksPerBar();
int x = (pos.x() - m_whiteKeyWidth) * TimePos::ticksPerBar();
// ticks based on the mouse x-position where the scroll wheel was used
int ticks = x / m_ppb;
// what would be the ticks in the new zoom level on the very same mouse x

View File

@@ -528,9 +528,10 @@ void SongEditor::adjustLeftRightScoll(int value)
void SongEditor::wheelEvent( QWheelEvent * we )
{
if ((we->modifiers() & Qt::ControlModifier) && (position(we).x() > m_trackHeadWidth))
const auto posX = we->position().toPoint().x();
if ((we->modifiers() & Qt::ControlModifier) && (posX > m_trackHeadWidth))
{
int x = position(we).x() - m_trackHeadWidth;
int x = posX - m_trackHeadWidth;
// tick based on the mouse x-position where the scroll wheel was used
int tick = x / pixelsPerBar() * TimePos::ticksPerBar();

View File

@@ -125,11 +125,7 @@ auto getIconPixmap(std::string_view name, int width, int height, const char* con
auto getText(std::string_view name) -> QString
{
const auto resource = QResource{":/" + QString::fromUtf8(name.data(), name.size())};
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
return QString::fromUtf8(resource.uncompressedData());
#else
return QString::fromUtf8(reinterpret_cast<const char*>(resource.data()), resource.size());
#endif
}
} // namespace lmms::embed

View File

@@ -127,17 +127,6 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) :
basicControlsLayout->setVerticalSpacing(0);
basicControlsLayout->setContentsMargins(0, 0, 0, 0);
#if QT_VERSION < 0x50C00
// Workaround for a bug in Qt versions below 5.12,
// where argument-dependent-lookup fails for QFlags operators
// declared inside a namespace.
// This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h
// See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348
using ::operator|;
#endif
QString labelStyleSheet = "font-size: 10px;";
Qt::Alignment labelAlignment = Qt::AlignHCenter | Qt::AlignTop;
Qt::Alignment widgetAlignment = Qt::AlignHCenter | Qt::AlignCenter;

View File

@@ -131,13 +131,8 @@ EffectSelectDialog::EffectSelectDialog(QWidget* parent) :
mainLayout->addLayout(leftSectionLayout);
m_filterEdit = new QLineEdit(this);
connect(m_filterEdit, &QLineEdit::textChanged, this, [this](const QString &text) {
// TODO: Cleanup when we don't support Qt5 anymore
#if (QT_VERSION >= QT_VERSION_CHECK(5,12,0))
connect(m_filterEdit, &QLineEdit::textChanged, this, [this](const QString& text) {
m_model.setFilterRegularExpression(QRegularExpression(text, QRegularExpression::CaseInsensitiveOption));
#else
m_model.setFilterRegExp(QRegExp(text, Qt::CaseInsensitive));
#endif
});
connect(m_filterEdit, &QLineEdit::textChanged, this, &EffectSelectDialog::updateSelection);
m_filterEdit->setFocus();

View File

@@ -40,10 +40,7 @@ FileDialog::FileDialog( QWidget *parent, const QString &caption,
const QString &directory, const QString &filter ) :
QFileDialog( parent, caption, directory, filter )
{
#if QT_VERSION > 0x050200
setOption( QFileDialog::DontUseCustomDirectoryIcons );
#endif
setOption( QFileDialog::DontUseNativeDialog );
#ifdef LMMS_BUILD_LINUX

View File

@@ -550,13 +550,7 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
setCurrentIndex(m_audioInterfaces->findText(audioDevName));
m_audioIfaceSetupWidgets[audioDevName]->show();
connect(m_audioInterfaces,
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
QOverload<const QString&>::of(&QComboBox::activated),
#else
&QComboBox::textActivated,
#endif
this, &SetupDialog::audioInterfaceChanged);
connect(m_audioInterfaces, &QComboBox::textActivated, this, &SetupDialog::audioInterfaceChanged);
// Advanced setting, hidden for now
// // TODO Handle or remove.
@@ -730,13 +724,7 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
m_midiInterfaces->setCurrentIndex(m_midiInterfaces->findText(midiDevName));
m_midiIfaceSetupWidgets[midiDevName]->show();
connect(m_midiInterfaces,
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
QOverload<const QString&>::of(&QComboBox::activated),
#else
&QComboBox::textActivated,
#endif
this, &SetupDialog::midiInterfaceChanged);
connect(m_midiInterfaces, &QComboBox::textActivated, this, &SetupDialog::midiInterfaceChanged);
// MIDI autoassign group
QGroupBox * midiAutoAssignBox = new QGroupBox(tr("Automatically assign MIDI controller to selected track"), midi_w);

View File

@@ -54,8 +54,8 @@ VersionedSaveDialog::VersionedSaveDialog( QWidget *parent,
plusButton->setToolTip( tr( "Increment version number" ) );
auto minusButton(new QPushButton("-", this));
minusButton->setToolTip( tr( "Decrement version number" ) );
plusButton->setFixedWidth(horizontalAdvance(plusButton->fontMetrics(), "+") + 30);
minusButton->setFixedWidth(horizontalAdvance(minusButton->fontMetrics(), "+") + 30);
plusButton->setFixedWidth(plusButton->fontMetrics().horizontalAdvance("+") + 30);
minusButton->setFixedWidth(minusButton->fontMetrics().horizontalAdvance("+") + 30);
// Add buttons to grid layout. For doing this, remove the lineEdit and
// replace it with a HBox containing lineEdit and the buttons.

View File

@@ -35,12 +35,6 @@
#include "FontHelper.h"
#include "DeprecationHelper.h"
#define QT_SUPPORTS_WIDGET_SCREEN (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
#if !QT_SUPPORTS_WIDGET_SCREEN
#include <QApplication>
#include <QDesktopWidget>
#endif
namespace lmms::gui
{
const int CB_ARROW_BTN_WIDTH = 18;
@@ -125,12 +119,7 @@ void ComboBox::mousePressEvent( QMouseEvent* event )
QPoint gpos = mapToGlobal(QPoint(0, height()));
#if (QT_SUPPORTS_WIDGET_SCREEN)
bool const menuCanBeFullyShown = screen()->geometry().contains(QRect(gpos, m_menu.sizeHint()));
#else
bool const menuCanBeFullyShown = gpos.y() + m_menu.sizeHint().height() < qApp->desktop()->height();
#endif
if (menuCanBeFullyShown)
{
m_menu.exec(gpos);

View File

@@ -175,7 +175,7 @@ void Knob::updateFixedSize()
if (m_knobPixmap)
{
// In legacy mode only the width of the label is taken into account while the height is not
const int labelWidth = horizontalAdvance(QFontMetrics(adjustedToPixelSize(font(), SMALL_FONT_SIZE)), m_label);
const int labelWidth = QFontMetrics(adjustedToPixelSize(font(), SMALL_FONT_SIZE)).horizontalAdvance(m_label);
const int width = std::max(m_knobPixmap->width(), labelWidth);
// Legacy mode assumes that the label will fit into 10 pixels plus some of the pixmap area
@@ -196,7 +196,7 @@ void Knob::updateFixedSize()
auto fm = QFontMetrics(font());
const int width = std::max(pixmapSize.width(), horizontalAdvance(fm, m_label));
const int width = std::max(pixmapSize.width(), fm.horizontalAdvance(m_label));
const int height = pixmapSize.height() + fm.height();
setFixedSize(width, height);
@@ -491,7 +491,7 @@ void Knob::drawLabel(QPainter& p)
p.setFont(adjustedToPixelSize(p.font(), SMALL_FONT_SIZE));
}
auto fm = p.fontMetrics();
const auto x = (width() - horizontalAdvance(fm, m_label)) / 2;
const auto x = (width() - fm.horizontalAdvance(m_label)) / 2;
const auto descent = fixedFontSizeLabelRendering() ? 2 : fm.descent();
const auto y = height() - descent;

View File

@@ -192,7 +192,7 @@ void LcdFloatSpinBox::mouseReleaseEvent(QMouseEvent*)
void LcdFloatSpinBox::wheelEvent(QWheelEvent *event)
{
// switch between integer and fractional step based on cursor position
if (position(event).x() < m_wholeDisplay.width()) { m_intStep = true; }
if (event->position().toPoint().x() < m_wholeDisplay.width()) { m_intStep = true; }
else { m_intStep = false; }
event->accept();

View File

@@ -212,11 +212,11 @@ void LcdWidget::paintEvent( QPaintEvent* )
p.setFont(adjustedToPixelSize(p.font(), DEFAULT_FONT_SIZE));
p.setPen( textShadowColor() );
p.drawText(width() / 2 -
horizontalAdvance(p.fontMetrics(), m_label) / 2 + 1,
p.fontMetrics().horizontalAdvance(m_label) / 2 + 1,
height(), m_label);
p.setPen( textColor() );
p.drawText(width() / 2 -
horizontalAdvance(p.fontMetrics(), m_label) / 2,
p.fontMetrics().horizontalAdvance(m_label) / 2,
height() - 1, m_label);
}
@@ -261,7 +261,7 @@ void LcdWidget::updateSize()
setFixedSize(
qMax<int>(
m_cellWidth * m_numDigits + marginX1 + marginX2,
horizontalAdvance(QFontMetrics(adjustedToPixelSize(font(), DEFAULT_FONT_SIZE)), m_label)
QFontMetrics(adjustedToPixelSize(font(), DEFAULT_FONT_SIZE)).horizontalAdvance(m_label)
),
m_cellHeight + (2 * marginY) + 9
);

View File

@@ -105,7 +105,7 @@ void LedCheckBox::onTextUpdated()
{
QFontMetrics const fm = fontMetrics();
int const width = m_ledOffPixmap.width() + 5 + horizontalAdvance(fm, text());
int const width = m_ledOffPixmap.width() + 5 + fm.horizontalAdvance(text());
int const height = m_legacyMode ? m_ledOffPixmap.height() : qMax(m_ledOffPixmap.height(), fm.height());
setFixedSize(width, height);

View File

@@ -79,7 +79,7 @@ void TabWidget::addTab(QWidget* w, const QString& name, const char* pixmap, int
}
// Tab's width when it is a text tab. This isn't correct for artwork tabs, but it's fixed later during the PaintEvent
int tab_width = horizontalAdvance(fontMetrics(), name) + 10;
int tab_width = fontMetrics().horizontalAdvance(name) + 10;
// Register new tab
widgetDesc d = {w, pixmap, name, tab_width};
@@ -128,7 +128,7 @@ int TabWidget::findTabAtPos(const QPoint& pos)
if (pos.y() > 1 && pos.y() < m_tabbarHeight - 1)
{
int cx = ((m_caption == "") ? 4 : 14) + horizontalAdvance(fontMetrics(), m_caption);
int cx = ((m_caption == "") ? 4 : 14) + fontMetrics().horizontalAdvance(m_caption);
for (widgetStack::iterator it = m_widgets.begin(); it != m_widgets.end(); ++it)
{
@@ -233,7 +233,7 @@ void TabWidget::paintEvent(QPaintEvent* pe)
}
// Calculate the tabs' x (tabs are painted next to the caption)
int tab_x_offset = m_caption.isEmpty() ? 4 : 14 + horizontalAdvance(fontMetrics(), m_caption);
int tab_x_offset = m_caption.isEmpty() ? 4 : 14 + fontMetrics().horizontalAdvance(m_caption);
// Compute tabs' width depending on the number of tabs (only applicable for artwork tabs)
widgetStack::iterator first = m_widgets.begin();
@@ -296,7 +296,7 @@ void TabWidget::paintEvent(QPaintEvent* pe)
// Switch between tabs with mouse wheel
void TabWidget::wheelEvent(QWheelEvent* we)
{
if (position(we).y() > m_tabheight)
if (we->position().toPoint().y() > m_tabheight)
{
return;
}