Upgrade to qt 6

This commit is contained in:
Phillip Stephens 2021-01-23 16:27:34 -08:00
parent d3c4f568bb
commit 2ec749e6c7
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
20 changed files with 267 additions and 245 deletions

View File

@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR) # because of c++17
project(amuse) project(amuse)
if(POLICY CMP0072)
cmake_policy(SET CMP0072 NEW)
endif()
if (NOT MSVC) if (NOT MSVC)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
@ -159,11 +163,11 @@ if(TARGET boo AND NOT WINDOWS_STORE AND NOT NX)
endif() endif()
# Editor # Editor
find_package(Qt5 COMPONENTS Widgets PATHS /usr/local/opt/qt) find_package(Qt6 COMPONENTS Widgets PATHS /usr/local/opt/qt)
if (Qt5Widgets_FOUND) if (Qt6Widgets_FOUND)
message(STATUS "Qt5 found, amuse-gui will be built") message(STATUS "Qt6 found, amuse-gui will be built")
add_subdirectory(Editor) add_subdirectory(Editor)
else() else()
message(STATUS "Qt5 not found, amuse-gui will not be built") message(STATUS "Qt6 not found, amuse-gui will not be built")
endif() endif()
endif() endif()

View File

@ -153,9 +153,9 @@ void ADSRView::mousePressEvent(QMouseEvent* ev) {
QPointF((width() - 30.0) * ((adTime + 1.0) / totalTime) + 30.0, sustainY), QPointF((width() - 30.0) * ((adTime + 1.0) / totalTime) + 30.0, sustainY),
}; };
const qreal dists[] = { const qreal dists[] = {
PointDistance(ev->localPos(), points[0]), PointDistance(ev->position(), points[0]),
PointDistance(ev->localPos(), points[1]), PointDistance(ev->position(), points[1]),
PointDistance(ev->localPos(), points[2]), PointDistance(ev->position(), points[2]),
}; };
int minDist = 0; int minDist = 0;
@ -196,16 +196,16 @@ void ADSRView::mouseMoveEvent(QMouseEvent* ev) {
qreal totalTime = adTime + 1.0 + relTime; qreal totalTime = adTime + 1.0 + relTime;
if (m_dragPoint == 0) { if (m_dragPoint == 0) {
const qreal newAttack = std::max(0.0, (ev->localPos().x() - 30.0) / (width() - 30.0) * totalTime); const qreal newAttack = std::max(0.0, (ev->position().x() - 30.0) / (width() - 30.0) * totalTime);
const qreal delta = newAttack - aTime; const qreal delta = newAttack - aTime;
ctrls->setAttackAndDecay(newAttack, std::max(0.0, ctrls->m_decay->value() - delta), m_cycleIdx); ctrls->setAttackAndDecay(newAttack, std::max(0.0, ctrls->m_decay->value() - delta), m_cycleIdx);
} else if (m_dragPoint == 1) { } else if (m_dragPoint == 1) {
const qreal newDecay = std::max(0.0, (ev->localPos().x() - 30.0) * totalTime / (width() - 30.0) - aTime); const qreal newDecay = std::max(0.0, (ev->position().x() - 30.0) * totalTime / (width() - 30.0) - aTime);
const qreal newSustain = (-ev->localPos().y() + (height() - 16.0)) / (height() - 16.0); const qreal newSustain = (-ev->position().y() + (height() - 16.0)) / (height() - 16.0);
ctrls->setDecayAndSustain(newDecay, newSustain * 100.0, m_cycleIdx); ctrls->setDecayAndSustain(newDecay, newSustain * 100.0, m_cycleIdx);
} else if (m_dragPoint == 2) { } else if (m_dragPoint == 2) {
const qreal newRelease = const qreal newRelease =
std::max(0.0, (width() - 30.0) * (adTime + 1.0) / (ev->localPos().x() - 30.0) - (adTime + 1.0)); std::max(0.0, (width() - 30.0) * (adTime + 1.0) / (ev->position().x() - 30.0) - (adTime + 1.0));
ctrls->setRelease(newRelease, m_cycleIdx); ctrls->setRelease(newRelease, m_cycleIdx);
ctrls->m_release->setValue(newRelease); ctrls->m_release->setValue(newRelease);
} }

View File

@ -7,13 +7,13 @@ set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Qt5 COMPONENTS LinguistTools Network Qml Svg Widgets Xml REQUIRED) find_package(Qt6 COMPONENTS LinguistTools Network Qml SvgWidgets Widgets Xml REQUIRED)
configure_file(resources/translation_res.qrc translation_res.qrc @ONLY) configure_file(resources/translation_res.qrc translation_res.qrc @ONLY)
set(TRANSLATIONS set(TRANSLATIONS
resources/lang_de.ts resources/lang_de.ts
) )
QT5_CREATE_TRANSLATION(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../lib ${TRANSLATIONS}) QT6_CREATE_TRANSLATION(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../lib ${TRANSLATIONS})
add_executable(amuse-gui WIN32 MACOSX_BUNDLE add_executable(amuse-gui WIN32 MACOSX_BUNDLE
ADSREditor.cpp ADSREditor.cpp
@ -137,11 +137,11 @@ set_target_properties(amuse-gui PROPERTIES
target_link_libraries(amuse-gui target_link_libraries(amuse-gui
${PLAT_LIBS} ${PLAT_LIBS}
Qt5::Network Qt6::Network
Qt5::Qml Qt6::Qml
Qt5::Svg Qt6::SvgWidgets
Qt5::Widgets Qt6::Widgets
Qt5::Xml Qt6::Xml
amuse amuse
athena-core athena-core

View File

@ -137,11 +137,11 @@ void CurveView::mouseMoveEvent(QMouseEvent* ev) {
} }
const qreal xIncrement = (width() - 30.0) / 127.0; const qreal xIncrement = (width() - 30.0) / 127.0;
const int idx = int(std::round((ev->localPos().x() - 30.0) / xIncrement)); const int idx = int(std::round((ev->position().x() - 30.0) / xIncrement));
if (idx < 0 || idx > 127) { if (idx < 0 || idx > 127) {
return; return;
} }
const int val = 127 - std::clamp(0, int(std::round(ev->localPos().y() / (height() - 16.0) * 127.0)), 127); const int val = 127 - std::clamp(0, int(std::round(ev->position().y() / (height() - 16.0) * 127.0)), 127);
CurveEditUndoCommand::RedoData newData; CurveEditUndoCommand::RedoData newData;
auto& curve = static_cast<amuse::Curve&>(table); auto& curve = static_cast<amuse::Curve&>(table);

View File

@ -226,7 +226,7 @@ AddRemoveButtons::AddRemoveButtons(QWidget* parent)
static QIcon ListingDeleteIcon; static QIcon ListingDeleteIcon;
static QIcon ListingDeleteHoveredIcon; static QIcon ListingDeleteHoveredIcon;
void ListingDeleteButton::enterEvent(QEvent* event) { setIcon(ListingDeleteHoveredIcon); } void ListingDeleteButton::enterEvent(QEnterEvent* event) { setIcon(ListingDeleteHoveredIcon); }
void ListingDeleteButton::leaveEvent(QEvent* event) { setIcon(ListingDeleteIcon); } void ListingDeleteButton::leaveEvent(QEvent* event) { setIcon(ListingDeleteIcon); }
@ -264,7 +264,7 @@ bool BaseObjectDelegate::editorEvent(QEvent* event, QAbstractItemModel* model, c
connect(findUsagesAction, &QAction::triggered, this, &BaseObjectDelegate::doFindUsages); connect(findUsagesAction, &QAction::triggered, this, &BaseObjectDelegate::doFindUsages);
menu->addAction(findUsagesAction); menu->addAction(findUsagesAction);
menu->popup(ev->globalPos()); menu->popup(ev->globalPosition().toPoint());
} }
} }
return false; return false;

View File

@ -229,7 +229,7 @@ class ListingDeleteButton : public QPushButton {
Q_OBJECT Q_OBJECT
public: public:
explicit ListingDeleteButton(QWidget* parent = Q_NULLPTR); explicit ListingDeleteButton(QWidget* parent = Q_NULLPTR);
void enterEvent(QEvent* event) override; void enterEvent(QEnterEvent* event) override;
void leaveEvent(QEvent* event) override; void leaveEvent(QEvent* event) override;
}; };

View File

@ -151,7 +151,7 @@ void KeyboardWidget::mouseReleaseEvent(QMouseEvent* event) {
m_holding = false; m_holding = false;
} }
void KeyboardWidget::enterEvent(QEvent* event) { void KeyboardWidget::enterEvent(QEnterEvent* event) {
if (m_statusFocus) if (m_statusFocus)
m_statusFocus->enter(); m_statusFocus->enter();
} }
@ -179,7 +179,7 @@ KeyboardSlider::KeyboardSlider(QWidget* parent) : QSlider(parent) {}
KeyboardSlider::~KeyboardSlider() = default; KeyboardSlider::~KeyboardSlider() = default;
void KeyboardSlider::enterEvent(QEvent* event) { void KeyboardSlider::enterEvent(QEnterEvent* event) {
if (m_statusFocus) if (m_statusFocus)
m_statusFocus->enter(); m_statusFocus->enter();
} }

View File

@ -54,7 +54,7 @@ public:
void mouseMoveEvent(QMouseEvent* event) override; void mouseMoveEvent(QMouseEvent* event) override;
void mousePressEvent(QMouseEvent* event) override; void mousePressEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override; void mouseReleaseEvent(QMouseEvent* event) override;
void enterEvent(QEvent* event) override; void enterEvent(QEnterEvent* event) override;
void leaveEvent(QEvent* event) override; void leaveEvent(QEvent* event) override;
void wheelEvent(QWheelEvent* event) override; void wheelEvent(QWheelEvent* event) override;
void showEvent(QShowEvent* event) override; void showEvent(QShowEvent* event) override;
@ -74,7 +74,7 @@ public:
explicit KeyboardSlider(QWidget* parent = Q_NULLPTR); explicit KeyboardSlider(QWidget* parent = Q_NULLPTR);
~KeyboardSlider() override; ~KeyboardSlider() override;
void enterEvent(QEvent* event) override; void enterEvent(QEnterEvent* event) override;
void leaveEvent(QEvent* event) override; void leaveEvent(QEvent* event) override;
void setStatusFocus(StatusBarFocus* statusFocus); void setStatusFocus(StatusBarFocus* statusFocus);
void sliderChange(SliderChange change) override; void sliderChange(SliderChange change) override;

View File

@ -138,7 +138,7 @@ int KeymapView::getKey(const QPoint& localPos) const {
} }
void KeymapView::mouseMoveEvent(QMouseEvent* ev) { void KeymapView::mouseMoveEvent(QMouseEvent* ev) {
const int octave = ev->x() / 280; const int octave = ev->position().x() / 280;
const int key = getKey(ev->pos() - QPoint(octave * 280, height() / 2 - 100)); const int key = getKey(ev->pos() - QPoint(octave * 280, height() / 2 - 100));
if (octave >= 0 && key >= 0) { if (octave >= 0 && key >= 0) {

View File

@ -29,6 +29,8 @@
#include <amuse/Engine.hpp> #include <amuse/Engine.hpp>
#include <boo/audiodev/IAudioVoiceEngine.hpp> #include <boo/audiodev/IAudioVoiceEngine.hpp>
#include <cmath>
MainWindow::MainWindow(QWidget* parent) MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent) : QMainWindow(parent)
, m_navIt(m_navList.begin()) , m_navIt(m_navList.begin())
@ -261,7 +263,7 @@ void MainWindow::updateWindowTitle() {
void MainWindow::updateRecentFileActions() { void MainWindow::updateRecentFileActions() {
const QSettings settings; const QSettings settings;
const QStringList files = settings.value(QStringLiteral("recentFileList")).toStringList(); const QStringList files = settings.value(QStringLiteral("recentFileList")).toStringList();
const int numRecentFiles = std::min(files.size(), int(MaxRecentFiles)); const int numRecentFiles = std::min(files.size(), qsizetype(MaxRecentFiles));
for (int i = 0; i < numRecentFiles; ++i) { for (int i = 0; i < numRecentFiles; ++i) {
const QString text = QStringLiteral("&%1 %2").arg(i + 1).arg(QDir(files[i]).dirName()); const QString text = QStringLiteral("&%1 %2").arg(i + 1).arg(QDir(files[i]).dirName());
@ -1190,7 +1192,7 @@ bool TreeDelegate::editorEvent(QEvent* event, QAbstractItemModel* __model, const
connect(renameAction, &QAction::triggered, this, &TreeDelegate::doRename); connect(renameAction, &QAction::triggered, this, &TreeDelegate::doRename);
menu->addAction(renameAction); menu->addAction(renameAction);
menu->popup(ev->globalPos()); menu->popup(ev->globalPosition().toPoint());
} }
} }

View File

@ -5,7 +5,6 @@
#include <memory> #include <memory>
#include <QFileDialog> #include <QFileDialog>
#include <QLinkedList>
#include <QMainWindow> #include <QMainWindow>
#include <QMessageBox> #include <QMessageBox>
#include <QStyledItemDelegate> #include <QStyledItemDelegate>

View File

@ -22,7 +22,7 @@ QIcon ProjectModel::SongGroupNode::Icon;
QIcon ProjectModel::SoundGroupNode::Icon; QIcon ProjectModel::SoundGroupNode::Icon;
OutlineFilterProxyModel::OutlineFilterProxyModel(ProjectModel* source) OutlineFilterProxyModel::OutlineFilterProxyModel(ProjectModel* source)
: QSortFilterProxyModel(source), m_usageKey({}, Qt::CaseInsensitive) { : QSortFilterProxyModel(source), m_usageKey({}, QRegularExpression::CaseInsensitiveOption) {
setSourceModel(source); setSourceModel(source);
setRecursiveFilteringEnabled(true); setRecursiveFilteringEnabled(true);
setFilterCaseSensitivity(Qt::CaseInsensitive); setFilterCaseSensitivity(Qt::CaseInsensitive);
@ -31,10 +31,10 @@ OutlineFilterProxyModel::OutlineFilterProxyModel(ProjectModel* source)
void OutlineFilterProxyModel::setFilterRegExp(const QString& pattern) { void OutlineFilterProxyModel::setFilterRegExp(const QString& pattern) {
if (pattern.startsWith(QStringLiteral("usages:"))) { if (pattern.startsWith(QStringLiteral("usages:"))) {
m_usageKey.setPattern(pattern.mid(7)); m_usageKey.setPattern(pattern.mid(7));
QSortFilterProxyModel::setFilterRegExp(QString()); QSortFilterProxyModel::setFilterRegularExpression(QString());
} else { } else {
m_usageKey.setPattern(QString()); m_usageKey.setPattern(QString());
QSortFilterProxyModel::setFilterRegExp(pattern); QSortFilterProxyModel::setFilterRegularExpression(pattern);
} }
} }
@ -498,8 +498,12 @@ ProjectModel::BasePoolObjectNode* ProjectModel::CollectionNode::nodeOfId(amuse::
} }
ProjectModel::ProjectModel(const QString& path, QObject* parent) ProjectModel::ProjectModel(const QString& path, QObject* parent)
: QAbstractItemModel(parent), m_dir(path), m_outlineProxy(this), m_nullProxy(this), m_pageObjectProxy(this) { : QAbstractItemModel(parent)
m_root = amuse::MakeObj<RootNode>(); , m_dir(path)
, m_root(amuse::MakeObj<RootNode>())
, m_outlineProxy(this)
, m_nullProxy(this)
, m_pageObjectProxy(this) {
GroupNode::Icon = QIcon(QStringLiteral(":/icons/IconGroup.svg")); GroupNode::Icon = QIcon(QStringLiteral(":/icons/IconGroup.svg"));
SongGroupNode::Icon = QIcon(QStringLiteral(":/icons/IconSongGroup.svg")); SongGroupNode::Icon = QIcon(QStringLiteral(":/icons/IconSongGroup.svg"));

View File

@ -38,7 +38,7 @@ enum AmuseItemEditFlags {
class OutlineFilterProxyModel : public QSortFilterProxyModel { class OutlineFilterProxyModel : public QSortFilterProxyModel {
Q_OBJECT Q_OBJECT
QRegExp m_usageKey; QRegularExpression m_usageKey;
public: public:
explicit OutlineFilterProxyModel(ProjectModel* source); explicit OutlineFilterProxyModel(ProjectModel* source);
@ -91,10 +91,6 @@ public:
private: private:
QDir m_dir; QDir m_dir;
OutlineFilterProxyModel m_outlineProxy;
NullItemProxyModel m_nullProxy;
PageObjectProxyModel m_pageObjectProxy;
amuse::ProjectDatabase m_projectDatabase; amuse::ProjectDatabase m_projectDatabase;
std::unordered_map<QString, std::unique_ptr<amuse::AudioGroupDatabase>> m_groups; std::unordered_map<QString, std::unique_ptr<amuse::AudioGroupDatabase>> m_groups;
@ -380,6 +376,11 @@ public:
QString MakeDedupedSubprojectName(const QString& origName); QString MakeDedupedSubprojectName(const QString& origName);
static QString MakeDedupedName(const QString& origName, amuse::NameDB* db); static QString MakeDedupedName(const QString& origName, amuse::NameDB* db);
private:
OutlineFilterProxyModel m_outlineProxy;
NullItemProxyModel m_nullProxy;
PageObjectProxyModel m_pageObjectProxy;
public: public:
explicit ProjectModel(const QString& path, QObject* parent = Q_NULLPTR); explicit ProjectModel(const QString& path, QObject* parent = Q_NULLPTR);
~ProjectModel() override; ~ProjectModel() override;

View File

@ -390,7 +390,7 @@ bool MIDIFileDelegate::editorEvent(QEvent* event, QAbstractItemModel* model, con
connect(sngAction, &QAction::triggered, this, &MIDIFileDelegate::doExportSNG); connect(sngAction, &QAction::triggered, this, &MIDIFileDelegate::doExportSNG);
menu->addAction(sngAction); menu->addAction(sngAction);
menu->popup(ev->globalPos()); menu->popup(ev->globalPosition().toPoint());
} }
} }
return false; return false;

View File

@ -514,7 +514,10 @@ void SoundMacroListing::startAutoscroll(QWidget* source, QMouseEvent* event, int
m_autoscrollTimer = startTimer(50); m_autoscrollTimer = startTimer(50);
m_autoscrollDelta = delta; m_autoscrollDelta = delta;
m_autoscrollSource = source; m_autoscrollSource = source;
m_autoscrollEvent = *event; if (m_autoscrollEvent) {
delete m_autoscrollEvent;
}
m_autoscrollEvent = event->clone();
} }
void SoundMacroListing::stopAutoscroll() { void SoundMacroListing::stopAutoscroll() {
@ -523,6 +526,9 @@ void SoundMacroListing::stopAutoscroll() {
m_autoscrollTimer = -1; m_autoscrollTimer = -1;
} }
m_autoscrollDelta = 0; m_autoscrollDelta = 0;
if (m_autoscrollEvent) {
delete m_autoscrollEvent;
}
m_autoscrollSource = nullptr; m_autoscrollSource = nullptr;
} }
@ -534,7 +540,7 @@ void SoundMacroListing::timerEvent(QTimerEvent* event) {
int valueDelta = bar->value() - oldValue; int valueDelta = bar->value() - oldValue;
if (valueDelta != 0) { if (valueDelta != 0) {
if (m_autoscrollSource) if (m_autoscrollSource)
QApplication::sendEvent(m_autoscrollSource, &m_autoscrollEvent); QApplication::sendEvent(m_autoscrollSource, m_autoscrollEvent);
update(); update();
} }
} }

View File

@ -115,7 +115,7 @@ class SoundMacroListing : public QWidget {
int m_autoscrollTimer = -1; int m_autoscrollTimer = -1;
int m_autoscrollDelta = 0; int m_autoscrollDelta = 0;
QWidget* m_autoscrollSource = nullptr; QWidget* m_autoscrollSource = nullptr;
QMouseEvent m_autoscrollEvent = {{}, {}, {}, {}, {}}; QMouseEvent* m_autoscrollEvent = nullptr;
void startAutoscroll(QWidget* source, QMouseEvent* event, int delta); void startAutoscroll(QWidget* source, QMouseEvent* event, int delta);
void stopAutoscroll(); void stopAutoscroll();
bool beginDrag(CommandWidget* widget); bool beginDrag(CommandWidget* widget);

View File

@ -496,7 +496,10 @@ void EffectListing::startAutoscroll(QWidget* source, QMouseEvent* event, int del
m_autoscrollTimer = startTimer(50); m_autoscrollTimer = startTimer(50);
m_autoscrollDelta = delta; m_autoscrollDelta = delta;
m_autoscrollSource = source; m_autoscrollSource = source;
m_autoscrollEvent = *event; if (m_autoscrollEvent != nullptr) {
delete m_autoscrollEvent;
}
m_autoscrollEvent = event->clone();
} }
void EffectListing::stopAutoscroll() { void EffectListing::stopAutoscroll() {
@ -505,6 +508,9 @@ void EffectListing::stopAutoscroll() {
m_autoscrollTimer = -1; m_autoscrollTimer = -1;
} }
m_autoscrollDelta = 0; m_autoscrollDelta = 0;
if (m_autoscrollEvent != nullptr) {
delete m_autoscrollEvent;
}
m_autoscrollSource = nullptr; m_autoscrollSource = nullptr;
} }
@ -516,7 +522,7 @@ void EffectListing::timerEvent(QTimerEvent* event) {
int valueDelta = bar->value() - oldValue; int valueDelta = bar->value() - oldValue;
if (valueDelta != 0) { if (valueDelta != 0) {
if (m_autoscrollSource) if (m_autoscrollSource)
QApplication::sendEvent(m_autoscrollSource, &m_autoscrollEvent); QApplication::sendEvent(m_autoscrollSource, m_autoscrollEvent);
update(); update();
} }
} }

View File

@ -126,7 +126,7 @@ class EffectListing : public QWidget {
int m_autoscrollTimer = -1; int m_autoscrollTimer = -1;
int m_autoscrollDelta = 0; int m_autoscrollDelta = 0;
QWidget* m_autoscrollSource = nullptr; QWidget* m_autoscrollSource = nullptr;
QMouseEvent m_autoscrollEvent = {{}, {}, {}, {}, {}}; QMouseEvent* m_autoscrollEvent = nullptr;
void startAutoscroll(QWidget* source, QMouseEvent* event, int delta); void startAutoscroll(QWidget* source, QMouseEvent* event, int delta);
void stopAutoscroll(); void stopAutoscroll();
bool beginDrag(EffectWidget* widget); bool beginDrag(EffectWidget* widget);

View File

@ -56,7 +56,7 @@ MainWindow* g_MainWindow = nullptr;
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
QApplication::setAttribute(Qt::AA_Use96Dpi); QApplication::setAttribute(Qt::AA_Use96Dpi);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif #endif

File diff suppressed because it is too large Load Diff