Merge branch 'master' of ssh://git.axiodl.com:6431/AxioDL/amuse

This commit is contained in:
Jack Andersen 2018-08-29 22:23:00 -10:00
commit 2d4fd3493e
9 changed files with 617 additions and 517 deletions

View File

@ -25,6 +25,7 @@ MainWindow::MainWindow(QWidget* parent)
m_navIt(m_navList.begin()), m_navIt(m_navList.begin()),
m_treeDelegate(*this, this), m_treeDelegate(*this, this),
m_mainMessenger(this), m_mainMessenger(this),
m_fileDialog(this),
m_undoStack(new QUndoStack(this)), m_undoStack(new QUndoStack(this)),
m_backgroundThread(this) m_backgroundThread(this)
{ {
@ -82,7 +83,7 @@ MainWindow::MainWindow(QWidget* parent)
connect(m_ui.actionImport_C_Headers, SIGNAL(triggered()), this, SLOT(importHeadersAction())); connect(m_ui.actionImport_C_Headers, SIGNAL(triggered()), this, SLOT(importHeadersAction()));
connect(m_ui.actionExport_C_Headers, SIGNAL(triggered()), this, SLOT(exportHeadersAction())); connect(m_ui.actionExport_C_Headers, SIGNAL(triggered()), this, SLOT(exportHeadersAction()));
m_ui.actionQuit->setShortcut(QKeySequence::Quit); m_ui.actionQuit->setShortcut(QKeySequence::Quit);
connect(m_ui.actionQuit, SIGNAL(triggered()), qApp, SLOT(quit())); connect(m_ui.actionQuit, SIGNAL(triggered()), this, SLOT(close()));
for (int i = 0; i < MaxRecentFiles; ++i) for (int i = 0; i < MaxRecentFiles; ++i)
{ {
@ -165,7 +166,7 @@ MainWindow::MainWindow(QWidget* parent)
m_voxEngine = boo::NewAudioVoiceEngine(); m_voxEngine = boo::NewAudioVoiceEngine();
m_voxAllocator = std::make_unique<VoiceAllocator>(*m_voxEngine); m_voxAllocator = std::make_unique<VoiceAllocator>(*m_voxEngine);
m_engine = std::make_unique<amuse::Engine>(*m_voxAllocator); m_engine = std::make_unique<amuse::Engine>(*m_voxAllocator);
m_voxEngine->setVolume(0.7f); m_engine->setVolume(0.7f);
m_studioSetup->loadData(m_engine->getDefaultStudio().get()); m_studioSetup->loadData(m_engine->getDefaultStudio().get());
m_ctrlVals[7] = 127; m_ctrlVals[7] = 127;
@ -302,6 +303,7 @@ bool MainWindow::setProjectPath(const QString& path)
connect(m_ui.projectOutline->selectionModel(), connect(m_ui.projectOutline->selectionModel(),
SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
this, SLOT(onOutlineSelectionChanged(const QItemSelection&, const QItemSelection&))); this, SLOT(onOutlineSelectionChanged(const QItemSelection&, const QItemSelection&)));
m_fileDialog.setDirectory(path);
m_ui.actionSave_Project->setEnabled(true); m_ui.actionSave_Project->setEnabled(true);
m_ui.actionRevert_Project->setEnabled(true); m_ui.actionRevert_Project->setEnabled(true);
m_ui.actionReload_Sample_Data->setEnabled(true); m_ui.actionReload_Sample_Data->setEnabled(true);
@ -399,8 +401,14 @@ void MainWindow::timerEvent(QTimerEvent* ev)
if (m_voxEngine && m_engine) if (m_voxEngine && m_engine)
{ {
m_voxEngine->pumpAndMixVoices(); m_voxEngine->pumpAndMixVoices();
if (!(m_timerFireCount % 10)) /* Rate limit voice counter */
m_ui.statusbar->setVoiceCount(int(m_engine->getNumTotalActiveVoices())); m_peakVoices = std::max(int(m_engine->getNumTotalActiveVoices()), m_peakVoices);
if (!(m_timerFireCount % 10))
{
/* Rate limit voice counter */
m_ui.statusbar->setVoiceCount(m_peakVoices);
m_peakVoices = 0;
}
if (m_engine->getActiveVoices().empty() && m_uiDisabled) if (m_engine->getActiveVoices().empty() && m_uiDisabled)
{ {
m_ui.projectOutline->setEnabled(true); m_ui.projectOutline->setEnabled(true);
@ -793,7 +801,16 @@ void MainWindow::newAction()
if (!askAboutSave()) if (!askAboutSave())
return; return;
QString path = QFileDialog::getSaveFileName(this, tr("New Project")); m_fileDialog.setWindowTitle(tr("New Project"));
m_fileDialog.setAcceptMode(QFileDialog::AcceptSave);
m_fileDialog.setFileMode(QFileDialog::AnyFile);
m_fileDialog.setOption(QFileDialog::ShowDirsOnly, false);
m_fileDialog.open(this, SLOT(_newAction(const QString&)));
}
void MainWindow::_newAction(const QString& path)
{
m_fileDialog.close();
if (path.isEmpty()) if (path.isEmpty())
return; return;
if (!MkPath(path, m_mainMessenger)) if (!MkPath(path, m_mainMessenger))
@ -864,7 +881,16 @@ void MainWindow::openAction()
if (!askAboutSave()) if (!askAboutSave())
return; return;
QString path = QFileDialog::getExistingDirectory(this, tr("Open Project")); m_fileDialog.setWindowTitle(tr("Open Project"));
m_fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
m_fileDialog.setFileMode(QFileDialog::Directory);
m_fileDialog.setOption(QFileDialog::ShowDirsOnly, true);
m_fileDialog.open(this, SLOT(_openAction(const QString&)));
}
void MainWindow::_openAction(const QString& path)
{
m_fileDialog.close();
if (path.isEmpty()) if (path.isEmpty())
return; return;
openProject(path); openProject(path);
@ -963,8 +989,16 @@ void MainWindow::reloadSampleDataAction()
void MainWindow::importAction() void MainWindow::importAction()
{ {
QString path = QFileDialog::getOpenFileName(this, tr("Import Project"), m_fileDialog.setWindowTitle(tr("Import Project"));
m_projectModel ? m_projectModel->dir().path() : QString()); m_fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
m_fileDialog.setFileMode(QFileDialog::ExistingFile);
m_fileDialog.setOption(QFileDialog::ShowDirsOnly, false);
m_fileDialog.open(this, SLOT(_importAction(const QString&)));
}
void MainWindow::_importAction(const QString& path)
{
m_fileDialog.close();
if (path.isEmpty()) if (path.isEmpty())
return; return;
@ -980,11 +1014,11 @@ void MainWindow::importAction()
/* Ask user about sample conversion */ /* Ask user about sample conversion */
int impMode = m_mainMessenger.question(tr("Sample Import Mode"), int impMode = m_mainMessenger.question(tr("Sample Import Mode"),
tr("Amuse can import samples as WAV files for ease of editing, " tr("Amuse can import samples as WAV files for ease of editing, "
"import original compressed data for lossless repacking, or both. " "import original compressed data for lossless repacking, or both. "
"Exporting the project will prefer whichever version was modified " "Exporting the project will prefer whichever version was modified "
"most recently."), "most recently."),
tr("Import Compressed"), tr("Import WAVs"), tr("Import Both")); tr("Import Compressed"), tr("Import WAVs"), tr("Import Both"));
switch (impMode) switch (impMode)
{ {
@ -1001,8 +1035,8 @@ void MainWindow::importAction()
if (tp == amuse::ContainerRegistry::Type::Raw4) if (tp == amuse::ContainerRegistry::Type::Raw4)
{ {
int scanMode = m_mainMessenger.question(tr("Raw Import Mode"), int scanMode = m_mainMessenger.question(tr("Raw Import Mode"),
tr("Would you like to scan for all MusyX group files in this directory?"), tr("Would you like to scan for all MusyX group files in this directory?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No); QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (scanMode == QMessageBox::Yes) if (scanMode == QMessageBox::Yes)
{ {
/* Auto-create project */ /* Auto-create project */
@ -1097,7 +1131,16 @@ void MainWindow::importSongsAction()
if (!m_projectModel) if (!m_projectModel)
return; return;
QString path = QFileDialog::getOpenFileName(this, tr("Import Songs"), m_projectModel->dir().path()); m_fileDialog.setWindowTitle(tr("Import Songs"));
m_fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
m_fileDialog.setFileMode(QFileDialog::ExistingFile);
m_fileDialog.setOption(QFileDialog::ShowDirsOnly, false);
m_fileDialog.open(this, SLOT(_importSongsAction(const QString&)));
}
void MainWindow::_importSongsAction(const QString& path)
{
m_fileDialog.close();
if (path.isEmpty()) if (path.isEmpty())
return; return;
@ -1149,13 +1192,22 @@ void MainWindow::importHeadersAction()
"<p>Group, Song and SFX definitions are matched according to the following forms:" "<p>Group, Song and SFX definitions are matched according to the following forms:"
"<pre>#define GRP&lt;name&gt; &lt;id&gt;\n#define SNG&lt;name&gt; &lt;id&gt;\n" "<pre>#define GRP&lt;name&gt; &lt;id&gt;\n#define SNG&lt;name&gt; &lt;id&gt;\n"
"#define SFX&lt;name> &lt;id&gt;</pre></p>" "#define SFX&lt;name> &lt;id&gt;</pre></p>"
"<p><strong>This operation cannot be undone! Is is recommended to " "<p><strong>This operation cannot be undone! It is recommended to "
"make a backup of the project directory before proceeding.</strong></p>" "make a backup of the project directory before proceeding.</strong></p>"
"<p>Continue?</p>"), QMessageBox::Yes | QMessageBox::No); "<p>Continue?</p>"), QMessageBox::Yes | QMessageBox::No);
if (confirm == QMessageBox::No) if (confirm == QMessageBox::No)
return; return;
QString path = QFileDialog::getExistingDirectory(this, tr("Import C Headers"), m_projectModel->dir().path()); m_fileDialog.setWindowTitle(tr("Import C Headers"));
m_fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
m_fileDialog.setFileMode(QFileDialog::Directory);
m_fileDialog.setOption(QFileDialog::ShowDirsOnly, true);
m_fileDialog.open(this, SLOT(_importHeadersAction(const QString&)));
}
void MainWindow::_importHeadersAction(const QString& path)
{
m_fileDialog.close();
if (path.isEmpty()) if (path.isEmpty())
return; return;
@ -1174,7 +1226,16 @@ void MainWindow::exportHeadersAction()
if (!m_projectModel) if (!m_projectModel)
return; return;
QString path = QFileDialog::getExistingDirectory(this, tr("Export C Headers"), m_projectModel->dir().path()); m_fileDialog.setWindowTitle(tr("Export C Headers"));
m_fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
m_fileDialog.setFileMode(QFileDialog::Directory);
m_fileDialog.setOption(QFileDialog::ShowDirsOnly, true);
m_fileDialog.open(this, SLOT(_exportHeadersAction(const QString&)));
}
void MainWindow::_exportHeadersAction(const QString& path)
{
m_fileDialog.close();
if (path.isEmpty()) if (path.isEmpty())
return; return;
@ -1457,6 +1518,7 @@ void MainWindow::newSoundMacroAction()
while (result == QDialog::Accepted && newName.isEmpty()) while (result == QDialog::Accepted && newName.isEmpty())
{ {
NewSoundMacroDialog dialog(groupName, this); NewSoundMacroDialog dialog(groupName, this);
dialog.setWindowModality(Qt::WindowModal);
result = dialog.exec(); result = dialog.exec();
newName = dialog.getName(); newName = dialog.getName();
templ = dialog.getSelectedTemplate(); templ = dialog.getSelectedTemplate();
@ -1931,6 +1993,7 @@ void MainWindow::studioSetupShown()
void MainWindow::onBackgroundTaskFinished(int id) void MainWindow::onBackgroundTaskFinished(int id)
{ {
m_backgroundDialog->close();
m_backgroundDialog->reset(); m_backgroundDialog->reset();
m_backgroundDialog->deleteLater(); m_backgroundDialog->deleteLater();
m_backgroundDialog = nullptr; m_backgroundDialog = nullptr;
@ -1942,8 +2005,7 @@ void MainWindow::onBackgroundTaskFinished(int id)
if (m_mainMessenger.question(tr("Export Complete"), tr("%1?"). if (m_mainMessenger.question(tr("Export Complete"), tr("%1?").
arg(ShowInGraphicalShellString())) == QMessageBox::Yes) arg(ShowInGraphicalShellString())) == QMessageBox::Yes)
{ {
QFileInfo QFileInfo dirInfo(m_projectModel->dir(), QStringLiteral("out"));
dirInfo(m_projectModel->dir(), QStringLiteral("out"));
QDir dir(dirInfo.filePath()); QDir dir(dirInfo.filePath());
QStringList entryList = dir.entryList(QDir::Files); QStringList entryList = dir.entryList(QDir::Files);
ShowInGraphicalShell(this, ShowInGraphicalShell(this,

View File

@ -8,6 +8,7 @@
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QLinkedList> #include <QLinkedList>
#include <QFileDialog>
#include "ui_MainWindow.h" #include "ui_MainWindow.h"
#include "amuse/Engine.hpp" #include "amuse/Engine.hpp"
#include "amuse/BooBackend.hpp" #include "amuse/BooBackend.hpp"
@ -116,6 +117,7 @@ class MainWindow : public QMainWindow
LayersEditor* m_layersEditor = nullptr; LayersEditor* m_layersEditor = nullptr;
SampleEditor* m_sampleEditor = nullptr; SampleEditor* m_sampleEditor = nullptr;
StudioSetupWidget* m_studioSetup = nullptr; StudioSetupWidget* m_studioSetup = nullptr;
QFileDialog m_fileDialog;
std::unique_ptr<boo::IAudioVoiceEngine> m_voxEngine; std::unique_ptr<boo::IAudioVoiceEngine> m_voxEngine;
std::unique_ptr<VoiceAllocator> m_voxAllocator; std::unique_ptr<VoiceAllocator> m_voxAllocator;
@ -143,6 +145,7 @@ class MainWindow : public QMainWindow
QThread m_backgroundThread; QThread m_backgroundThread;
uint64_t m_timerFireCount = 0; uint64_t m_timerFireCount = 0;
int m_peakVoices = 0;
void connectMessenger(UIMessenger* messenger, Qt::ConnectionType type); void connectMessenger(UIMessenger* messenger, Qt::ConnectionType type);
@ -186,6 +189,7 @@ public:
amuse::ObjToken<amuse::Sequencer> startSong(amuse::GroupId groupId, amuse::SongId songId, amuse::ObjToken<amuse::Sequencer> startSong(amuse::GroupId groupId, amuse::SongId songId,
const unsigned char* arrData); const unsigned char* arrData);
void pushUndoCommand(EditorUndoCommand* cmd); void pushUndoCommand(EditorUndoCommand* cmd);
QFileDialog& fileDialog() { return m_fileDialog; }
void updateFocus(); void updateFocus();
void aboutToDeleteNode(ProjectModel::INode* node); void aboutToDeleteNode(ProjectModel::INode* node);
bool askAboutSave(); bool askAboutSave();
@ -209,17 +213,23 @@ public:
public slots: public slots:
void newAction(); void newAction();
void _newAction(const QString& path);
void openAction(); void openAction();
void _openAction(const QString& path);
void openRecentFileAction(); void openRecentFileAction();
void clearRecentFilesAction(); void clearRecentFilesAction();
void saveAction(); void saveAction();
void revertAction(); void revertAction();
void reloadSampleDataAction(); void reloadSampleDataAction();
void importAction(); void importAction();
void _importAction(const QString& path);
void importSongsAction(); void importSongsAction();
void _importSongsAction(const QString& path);
void exportAction(); void exportAction();
void importHeadersAction(); void importHeadersAction();
void _importHeadersAction(const QString& path);
void exportHeadersAction(); void exportHeadersAction();
void _exportHeadersAction(const QString& path);
void newSubprojectAction(); void newSubprojectAction();
void newSFXGroupAction(); void newSFXGroupAction();

View File

@ -347,6 +347,7 @@ MIDIFileFieldWidget::MIDIFileFieldWidget(QWidget* parent)
connect(&m_button, SIGNAL(clicked(bool)), this, SLOT(buttonPressed())); connect(&m_button, SIGNAL(clicked(bool)), this, SLOT(buttonPressed()));
m_dialog.setFileMode(QFileDialog::ExistingFile); m_dialog.setFileMode(QFileDialog::ExistingFile);
m_dialog.setAcceptMode(QFileDialog::AcceptOpen);
} }
QWidget* MIDIFileDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const QWidget* MIDIFileDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
@ -427,7 +428,7 @@ void MIDIFileDelegate::doExportMIDI()
return; return;
QString inPath = g_MainWindow->projectModel()->dir().absoluteFilePath(path); QString inPath = g_MainWindow->projectModel()->dir().absoluteFilePath(path);
std::vector<uint8_t> data; m_exportData.clear();
{ {
QFile fi(inPath); QFile fi(inPath);
if (!fi.open(QFile::ReadOnly)) if (!fi.open(QFile::ReadOnly))
@ -437,41 +438,48 @@ void MIDIFileDelegate::doExportMIDI()
return; return;
} }
auto d = fi.readAll(); auto d = fi.readAll();
data.resize(d.size()); m_exportData.resize(d.size());
memcpy(&data[0], d.data(), d.size()); memcpy(&m_exportData[0], d.data(), d.size());
} }
if (!memcmp(data.data(), "MThd", 4)) if (!memcmp(m_exportData.data(), "MThd", 4))
{ {
//data = amuse::SongConverter::MIDIToSong(data, 1, true); //data = amuse::SongConverter::MIDIToSong(data, 1, true);
} }
else else
{ {
bool isBig; bool isBig;
if (amuse::SongState::DetectVersion(data.data(), isBig) < 0) if (amuse::SongState::DetectVersion(m_exportData.data(), isBig) < 0)
{ {
g_MainWindow->uiMessenger().critical(tr("File Error"), g_MainWindow->uiMessenger().critical(tr("File Error"),
tr("Invalid song data at %1").arg(inPath)); tr("Invalid song data at %1").arg(inPath));
return; return;
} }
int version; int version;
data = amuse::SongConverter::SongToMIDI(data.data(), version, isBig); m_exportData = amuse::SongConverter::SongToMIDI(m_exportData.data(), version, isBig);
} }
QFileInfo inInfo(inPath); QFileInfo inInfo(inPath);
QString outPath = m_fileDialogMid.setDirectory(QFileInfo(inInfo.path(), inInfo.completeBaseName() + QStringLiteral(".mid")).filePath());
QFileDialog::getSaveFileName(g_MainWindow, tr("Export MIDI"), m_fileDialogMid.setAcceptMode(QFileDialog::AcceptSave);
QFileInfo(inInfo.path(), inInfo.completeBaseName() + QStringLiteral(".mid")).filePath(), tr("MIDI(*.mid)")); m_fileDialogMid.setFileMode(QFileDialog::AnyFile);
if (outPath.isEmpty()) m_fileDialogMid.setOption(QFileDialog::ShowDirsOnly, false);
m_fileDialogMid.open(this, SLOT(_doExportMIDI(const QString&)));
}
void MIDIFileDelegate::_doExportMIDI(const QString& path)
{
m_fileDialogMid.close();
if (path.isEmpty())
return; return;
QFile fo(outPath); QFile fo(path);
if (!fo.open(QFile::WriteOnly)) if (!fo.open(QFile::WriteOnly))
{ {
g_MainWindow->uiMessenger().critical(tr("File Error"), g_MainWindow->uiMessenger().critical(tr("File Error"),
tr("Unable to open %1 for writing: %1").arg(outPath).arg(fo.errorString())); tr("Unable to open %1 for writing: %1").arg(path).arg(fo.errorString()));
return; return;
} }
fo.write((char*)data.data(), data.size()); fo.write((char*)m_exportData.data(), m_exportData.size());
} }
void MIDIFileDelegate::doExportSNG() void MIDIFileDelegate::doExportSNG()
@ -482,7 +490,7 @@ void MIDIFileDelegate::doExportSNG()
return; return;
QString inPath = g_MainWindow->projectModel()->dir().absoluteFilePath(path); QString inPath = g_MainWindow->projectModel()->dir().absoluteFilePath(path);
std::vector<uint8_t> data; m_exportData.clear();
{ {
QFile fi(inPath); QFile fi(inPath);
if (!fi.open(QFile::ReadOnly)) if (!fi.open(QFile::ReadOnly))
@ -492,14 +500,14 @@ void MIDIFileDelegate::doExportSNG()
return; return;
} }
auto d = fi.readAll(); auto d = fi.readAll();
data.resize(d.size()); m_exportData.resize(d.size());
memcpy(&data[0], d.data(), d.size()); memcpy(&m_exportData[0], d.data(), d.size());
} }
if (!memcmp(data.data(), "MThd", 4)) if (!memcmp(m_exportData.data(), "MThd", 4))
{ {
data = amuse::SongConverter::MIDIToSong(data, 1, true); m_exportData = amuse::SongConverter::MIDIToSong(m_exportData, 1, true);
if (data.empty()) if (m_exportData.empty())
{ {
g_MainWindow->uiMessenger().critical(tr("File Error"), g_MainWindow->uiMessenger().critical(tr("File Error"),
tr("Invalid MIDI data at %1").arg(inPath)); tr("Invalid MIDI data at %1").arg(inPath));
@ -509,7 +517,7 @@ void MIDIFileDelegate::doExportSNG()
else else
{ {
bool isBig; bool isBig;
if (amuse::SongState::DetectVersion(data.data(), isBig) < 0) if (amuse::SongState::DetectVersion(m_exportData.data(), isBig) < 0)
{ {
g_MainWindow->uiMessenger().critical(tr("File Error"), g_MainWindow->uiMessenger().critical(tr("File Error"),
tr("Invalid song data at %1").arg(inPath)); tr("Invalid song data at %1").arg(inPath));
@ -518,19 +526,26 @@ void MIDIFileDelegate::doExportSNG()
} }
QFileInfo inInfo(inPath); QFileInfo inInfo(inPath);
QString outPath = m_fileDialogSng.setDirectory(QFileInfo(inInfo.path(), inInfo.completeBaseName() + QStringLiteral(".sng")).filePath());
QFileDialog::getSaveFileName(g_MainWindow, tr("Export SNG"), m_fileDialogSng.setAcceptMode(QFileDialog::AcceptSave);
QFileInfo(inInfo.path(), inInfo.completeBaseName() + QStringLiteral(".sng")).filePath(), tr("Song(*.sng)")); m_fileDialogSng.setFileMode(QFileDialog::AnyFile);
if (outPath.isEmpty()) m_fileDialogSng.setOption(QFileDialog::ShowDirsOnly, false);
m_fileDialogSng.open(this, SLOT(_doExportSNG(const QString&)));
}
void MIDIFileDelegate::_doExportSNG(const QString& path)
{
m_fileDialogSng.close();
if (path.isEmpty())
return; return;
QFile fo(outPath); QFile fo(path);
if (!fo.open(QFile::WriteOnly)) if (!fo.open(QFile::WriteOnly))
{ {
g_MainWindow->uiMessenger().critical(tr("File Error"), g_MainWindow->uiMessenger().critical(tr("File Error"),
tr("Unable to open %1 for writing: %1").arg(outPath).arg(fo.errorString())); tr("Unable to open %1 for writing: %1").arg(path).arg(fo.errorString()));
return; return;
} }
fo.write((char*)data.data(), data.size()); fo.write((char*)m_exportData.data(), m_exportData.size());
} }
void MIDIFileDelegate::pathChanged() void MIDIFileDelegate::pathChanged()
@ -538,8 +553,10 @@ void MIDIFileDelegate::pathChanged()
emit commitData(static_cast<MIDIFileFieldWidget*>(sender())); emit commitData(static_cast<MIDIFileFieldWidget*>(sender()));
} }
MIDIFileDelegate::MIDIFileDelegate(QObject* parent) MIDIFileDelegate::MIDIFileDelegate(SetupTableView* parent)
: QStyledItemDelegate(parent) {} : QStyledItemDelegate(parent),
m_fileDialogMid(parent, tr("Export MIDI"), {}, tr("MIDI(*.mid)")),
m_fileDialogSng(parent, tr("Export Song"), {}, tr("Song(*.sng)")) {}
std::unordered_map<uint8_t, amuse::SongGroupIndex::PageEntry>& PageModel::_getMap() const std::unordered_map<uint8_t, amuse::SongGroupIndex::PageEntry>& PageModel::_getMap() const
{ {
@ -1316,7 +1333,7 @@ void SetupTableView::showEvent(QShowEvent* event)
} }
SetupTableView::SetupTableView(QWidget* parent) SetupTableView::SetupTableView(QWidget* parent)
: QSplitter(parent), m_listView(new QTableView), m_tableView(new QTableView) : QSplitter(parent), m_listView(new QTableView), m_tableView(new QTableView), m_midiDelegate(this)
{ {
setChildrenCollapsible(false); setChildrenCollapsible(false);
setStretchFactor(0, 1); setStretchFactor(0, 1);

View File

@ -15,6 +15,8 @@
#include <QProxyStyle> #include <QProxyStyle>
#include "amuse/Sequencer.hpp" #include "amuse/Sequencer.hpp"
class SetupTableView;
class PageObjectDelegate : public BaseObjectDelegate class PageObjectDelegate : public BaseObjectDelegate
{ {
Q_OBJECT Q_OBJECT
@ -49,8 +51,10 @@ signals:
class MIDIFileDelegate : public QStyledItemDelegate class MIDIFileDelegate : public QStyledItemDelegate
{ {
Q_OBJECT Q_OBJECT
QFileDialog m_fileDialogMid, m_fileDialogSng;
std::vector<uint8_t> m_exportData;
public: public:
explicit MIDIFileDelegate(QObject* parent = Q_NULLPTR); explicit MIDIFileDelegate(SetupTableView* parent = Q_NULLPTR);
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const; QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
void destroyEditor(QWidget *editor, const QModelIndex &index) const; void destroyEditor(QWidget *editor, const QModelIndex &index) const;
void setEditorData(QWidget* editor, const QModelIndex& index) const; void setEditorData(QWidget* editor, const QModelIndex& index) const;
@ -59,7 +63,9 @@ public:
const QStyleOptionViewItem &option, const QModelIndex &index); const QStyleOptionViewItem &option, const QModelIndex &index);
private slots: private slots:
void doExportMIDI(); void doExportMIDI();
void _doExportMIDI(const QString& path);
void doExportSNG(); void doExportSNG();
void _doExportSNG(const QString& path);
public slots: public slots:
void pathChanged(); void pathChanged();
}; };

View File

@ -128,7 +128,7 @@ CommandWidget::CommandWidget(QWidget* parent, amuse::SoundMacro::ICmd* cmd,
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
m_numberFont.setWeight(QFont::Bold); m_numberFont.setWeight(QFont::Bold);
m_numberFont.setStyleHint(QFont::Monospace); m_numberFont.setStyleHint(QFont::Monospace);
m_numberFont.setPointSize(16); m_numberFont.setPointSize(m_numberFont.pointSize() * 2);
setContentsMargins(QMargins()); setContentsMargins(QMargins());
setFixedHeight(100); setFixedHeight(100);
@ -186,6 +186,7 @@ CommandWidget::CommandWidget(QWidget* parent, amuse::SoundMacro::ICmd* cmd,
case amuse::SoundMacro::CmdIntrospection::Field::Type::UInt32: case amuse::SoundMacro::CmdIntrospection::Field::Type::UInt32:
{ {
FieldSpinBox* sb = new FieldSpinBox(this); FieldSpinBox* sb = new FieldSpinBox(this);
sb->setFixedHeight(30);
sb->setProperty("fieldIndex", f); sb->setProperty("fieldIndex", f);
sb->setProperty("fieldName", fieldName); sb->setProperty("fieldName", fieldName);
sb->setMinimum(int(field.m_min)); sb->setMinimum(int(field.m_min));
@ -253,6 +254,7 @@ CommandWidget::CommandWidget(QWidget* parent, amuse::SoundMacro::ICmd* cmd,
case amuse::SoundMacro::CmdIntrospection::Field::Type::SoundMacroStep: case amuse::SoundMacro::CmdIntrospection::Field::Type::SoundMacroStep:
{ {
FieldSoundMacroStep* sb = new FieldSoundMacroStep(nf, this); FieldSoundMacroStep* sb = new FieldSoundMacroStep(nf, this);
sb->setFixedHeight(30);
sb->setProperty("fieldIndex", f); sb->setProperty("fieldIndex", f);
sb->setProperty("fieldName", fieldName); sb->setProperty("fieldName", fieldName);
sb->m_spinBox.setValue(amuse::AccessField<amuse::SoundMacroStepDNA<athena::Little>>(m_cmd, field).step); sb->m_spinBox.setValue(amuse::AccessField<amuse::SoundMacroStepDNA<athena::Little>>(m_cmd, field).step);
@ -264,6 +266,7 @@ CommandWidget::CommandWidget(QWidget* parent, amuse::SoundMacro::ICmd* cmd,
case amuse::SoundMacro::CmdIntrospection::Field::Type::Choice: case amuse::SoundMacro::CmdIntrospection::Field::Type::Choice:
{ {
FieldComboBox* cb = new FieldComboBox(this); FieldComboBox* cb = new FieldComboBox(this);
cb->setFixedHeight(30);
cb->setProperty("fieldIndex", f); cb->setProperty("fieldIndex", f);
cb->setProperty("fieldName", fieldName); cb->setProperty("fieldName", fieldName);
for (int j = 0; j < 4; ++j) for (int j = 0; j < 4; ++j)

View File

@ -16,10 +16,10 @@ StatusBarWidget::StatusBarWidget(QWidget* parent)
m_killButton.setVisible(false); m_killButton.setVisible(false);
m_killButton.setToolTip(tr("Immediately kill active voices")); m_killButton.setToolTip(tr("Immediately kill active voices"));
m_voiceCount.setVisible(false); m_voiceCount.setVisible(false);
m_volumeIcons[0] = QIcon(QStringLiteral(":/icons/IconVolume0")); m_volumeIcons[0] = QIcon(QStringLiteral(":/icons/IconVolume0.svg"));
m_volumeIcons[1] = QIcon(QStringLiteral(":/icons/IconVolume1")); m_volumeIcons[1] = QIcon(QStringLiteral(":/icons/IconVolume1.svg"));
m_volumeIcons[2] = QIcon(QStringLiteral(":/icons/IconVolume2")); m_volumeIcons[2] = QIcon(QStringLiteral(":/icons/IconVolume2.svg"));
m_volumeIcons[3] = QIcon(QStringLiteral(":/icons/IconVolume3")); m_volumeIcons[3] = QIcon(QStringLiteral(":/icons/IconVolume3.svg"));
m_aIcon.setFixedSize(16, 16); m_aIcon.setFixedSize(16, 16);
m_aIcon.setPixmap(QIcon(QStringLiteral(":/icons/IconA.svg")).pixmap(16, 16)); m_aIcon.setPixmap(QIcon(QStringLiteral(":/icons/IconA.svg")).pixmap(16, 16));
QString aTip = tr("Aux A send level for all voices"); QString aTip = tr("Aux A send level for all voices");

View File

@ -351,7 +351,7 @@ EffectWidget::EffectWidget(QWidget* parent, amuse::EffectBaseTypeless* effect, a
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
m_numberFont.setWeight(QFont::Bold); m_numberFont.setWeight(QFont::Bold);
m_numberFont.setStyleHint(QFont::Monospace); m_numberFont.setStyleHint(QFont::Monospace);
m_numberFont.setPointSize(16); m_numberFont.setPointSize(m_numberFont.pointSize() * 2);
setContentsMargins(QMargins()); setContentsMargins(QMargins());
setFixedHeight(100); setFixedHeight(100);

File diff suppressed because it is too large Load Diff

View File

@ -318,6 +318,8 @@ std::string AudioGroupDatabase::exportCHeader(std::string_view projectName, std:
char curTmStr[26]; char curTmStr[26];
asctime_s(curTmStr, &curTm); asctime_s(curTmStr, &curTm);
#endif #endif
if (char* ch = strchr(curTmStr, '\n'))
*ch = '\0';
ret += curTmStr; ret += curTmStr;
ret += "\n" ret += "\n"
" */\n\n\n"sv; " */\n\n\n"sv;