Skip to content

Commit

Permalink
Merge pull request #50 from cannam/pluginchoice
Browse files Browse the repository at this point in the history
Fixes to button appearance and directory searches
  • Loading branch information
yucongj authored Jul 19, 2024
2 parents 4678981 + 94a1c6a commit ae9441f
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 47 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:
- name: repoint
run: PATH=$PATH:/usr/local/smlnj/bin ./repoint install
- name: configure
run: PATH=$PATH:/usr/local/opt/qt6/bin meson setup build --buildtype release
run: meson setup build --buildtype release
- name: make
run: ninja -C build
- name: test
run: meson test -C build
- name: deploy-app
run: |
QTDIR=/usr/local/opt/qt6 ./deploy/macos/deploy.sh build
QTDIR=/opt/homebrew ./deploy/macos/deploy.sh build
- name: check
run: |
otool -L ./"Piano Precision.app/Contents/MacOS/Piano Precision"
Expand Down
11 changes: 2 additions & 9 deletions main/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,22 +267,15 @@ MainWindow::MainWindow(AudioMode audioMode, MIDIMode midiMode, bool withOSCSuppo
m_alignButton->setEnabled(false);
m_subsetOfScoreSelected = false;

m_alignerChoice = new QToolButton();
m_alignerChoice->setPopupMode(QToolButton::InstantPopup);

#ifdef Q_OS_MAC
m_alignerChoice = new QPushButton();
QChar dot(0x00b7);
m_alignerChoice->setText(QString("%1%2%3").arg(dot).arg(dot).arg(dot));
m_alignerChoice->setFixedSize(22, 22);
#else
m_alignerChoice->setArrowType(Qt::DownArrow);
#endif

m_alignCommands = new QWidget;
QHBoxLayout *aclayout = new QHBoxLayout;
aclayout->addWidget(m_alignButton);
aclayout->addWidget(m_alignerChoice);
aclayout->setContentsMargins(0, 0, 0, 0);
aclayout->setContentsMargins(0, 2, 0, 0);
m_alignCommands->setLayout(aclayout);

m_alignAcceptButton = new QPushButton
Expand Down
2 changes: 1 addition & 1 deletion main/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ protected slots:
QScrollArea *m_mainScroll;
ScoreWidget *m_scoreWidget;
QPushButton *m_alignButton;
QToolButton *m_alignerChoice;
QPushButton *m_alignerChoice;
QWidget *m_alignCommands;
QPushButton *m_alignAcceptButton;
QPushButton *m_alignRejectButton;
Expand Down
93 changes: 59 additions & 34 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,64 @@ class SVApplication : public QApplication
bool event(QEvent *) override;
};

static void
setupPluginPaths()
{
PluginPathSetter::Paths paths = PluginPathSetter::getDefaultPaths();

PluginPathSetter::TypeKey vampPluginTypeKey
{ KnownPlugins::VampPlugin, KnownPlugins::FormatNative };

auto defaultVampConfig = paths.at(vampPluginTypeKey);

for (auto &config : paths) {
config.second.directories = {};
config.second.useEnvVariable = false;
};

QStringList bundledPluginPaths =
HelperExecPath(HelperExecPath::NativeArchitectureOnly)
.getBundledPluginPaths();

QString alignmentSuffix = "/AudioToScoreAlignment";

QStringList vampDirs =
defaultVampConfig.directories;

std::set<QString> vampDirSet;
for (auto s : vampDirs) {
vampDirSet.insert(s);
}

QStringList adjustedVampDirs;
std::set<QString> alreadySeen;

for (auto s : vampDirs) {
if (alreadySeen.find(s) == alreadySeen.end()) {
adjustedVampDirs << s;
alreadySeen.insert(s);
}
if (!s.endsWith(alignmentSuffix)) {
QString withSuffix = s + alignmentSuffix;
if (vampDirSet.find(withSuffix) == vampDirSet.end()) {
adjustedVampDirs << withSuffix;
}
}
}

paths[vampPluginTypeKey] = {
bundledPluginPaths << adjustedVampDirs,
defaultVampConfig.envVariable,
true // allow environment variable to override this one
};

PluginPathSetter::savePathSettings(paths);
PluginPathSetter::initialiseEnvironmentVariables();

TransformFactory::getInstance()->restrictTransformTypes
({ Transform::FeatureExtraction });
}

int
main(int argc, char **argv)
{
Expand Down Expand Up @@ -410,40 +468,7 @@ main(int argc, char **argv)
settings.setValue("rdf-indices", list);
settings.endGroup();

PluginPathSetter::Paths paths = PluginPathSetter::getDefaultPaths();

PluginPathSetter::TypeKey vampPluginTypeKey
{ KnownPlugins::VampPlugin, KnownPlugins::FormatNative };

auto defaultVampConfig = paths.at(vampPluginTypeKey);

for (auto &config : paths) {
config.second.directories = {};
config.second.useEnvVariable = false;
};

QStringList bundledPluginPaths =
HelperExecPath(HelperExecPath::NativeArchitectureOnly)
.getBundledPluginPaths();

QStringList vampDirectories =
defaultVampConfig.directories;

for (auto &s : vampDirectories) {
s += "/AudioToScoreAlignment";
}

paths[vampPluginTypeKey] = {
bundledPluginPaths << vampDirectories,
defaultVampConfig.envVariable,
true // allow environment variable to override this one
};

PluginPathSetter::savePathSettings(paths);
PluginPathSetter::initialiseEnvironmentVariables();

TransformFactory::getInstance()->restrictTransformTypes
({ Transform::FeatureExtraction });
setupPluginPaths();

ScoreFinder::initialiseAlignerEnvironmentVariables();
ScoreFinder::populateUserDirectoriesFromBundled();
Expand Down
2 changes: 1 addition & 1 deletion repoint-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"pin": "63e0c3b37b6fb9ce6f074ea8222b4903e4f5568a"
},
"svcore": {
"pin": "3289c5e8e506583ecb71797d15a984aeb1797920"
"pin": "a173a54cd5e7c61bf71332ebb6ab1417b4319e27"
},
"svgui": {
"pin": "2796d24d9e1918d3ed12057f801ca07c9c1032a3"
Expand Down

0 comments on commit ae9441f

Please sign in to comment.