Skip to content

Commit

Permalink
Continue systray and win32 testing
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Oct 4, 2023
1 parent d7ae97a commit 9728d48
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 36 deletions.
36 changes: 31 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ TARGETS += build/Qt5Core.dll
TARGETS += build/Qt5Gui.dll
TARGETS += build/Qt5Svg.dll
TARGETS += build/Qt5Widgets.dll
TARGETS += build/bearer/qgenericbearer.dll
TARGETS += build/generic/qtuiotouchplugin.dll
TARGETS += build/iconengines/qsvgicon.dll
TARGETS += build/imageformats/qsvg.dll
TARGETS += build/platforms/qwindows.dll
TARGETS += build/styles/qwindowsvistastyle.dll
else
TARGETS += build/libjack.so.0
TARGETS += build/libjackserver.so.0
Expand Down Expand Up @@ -210,6 +216,30 @@ build/Qt5%.dll: $(PAWPAW_PREFIX)/bin/Qt5%.dll
@mkdir -p build
ln -sf $(abspath $<) $@

build/bearer/q%.dll: $(PAWPAW_PREFIX)/lib/qt5/plugins/bearer/q%.dll
@mkdir -p build/bearer
ln -sf $(abspath $<) $@

build/generic/q%.dll: $(PAWPAW_PREFIX)/lib/qt5/plugins/generic/q%.dll
@mkdir -p build/generic
ln -sf $(abspath $<) $@

build/iconengines/q%.dll: $(PAWPAW_PREFIX)/lib/qt5/plugins/iconengines/q%.dll
@mkdir -p build/iconengines
ln -sf $(abspath $<) $@

build/imageformats/q%.dll: $(PAWPAW_PREFIX)/lib/qt5/plugins/imageformats/q%.dll
@mkdir -p build/imageformats
ln -sf $(abspath $<) $@

build/platforms/q%.dll: $(PAWPAW_PREFIX)/lib/qt5/plugins/platforms/q%.dll
@mkdir -p build/platforms
ln -sf $(abspath $<) $@

build/styles/q%.dll: $(PAWPAW_PREFIX)/lib/qt5/plugins/styles/q%.dll
@mkdir -p build/styles
ln -sf $(abspath $<) $@

build/libjack%: $(PAWPAW_PREFIX)/lib/libjack%
@mkdir -p build
ln -sf $(abspath $<) $@
Expand Down Expand Up @@ -246,10 +276,6 @@ build/default.pedalboard: mod-ui/default.pedalboard
@mkdir -p build
ln -sf $(abspath $<) $@

build/jackd.bat: utils/jackd.bat
@mkdir -p build
ln -sf $(abspath $<) $@

build/html: mod-ui/html
@mkdir -p build
ln -sf $(abspath $<) $@
Expand Down Expand Up @@ -287,7 +313,7 @@ mod-midi-merger/build/mod-midi-merger-standalone$(APP_EXT): mod-midi-merger/buil
mod-midi-merger/build/Makefile: $(BOOTSTRAP_FILES)
./utils/run.sh $(PAWPAW_TARGET) cmake -S mod-midi-merger -B mod-midi-merger/build

mod-ui/utils/libmod_utils.so: $(BOOTSTRAP_FILES)
mod-ui/utils/libmod_utils.so: $(BOOTSTRAP_FILES) mod-ui/utils/utils_lilv.cpp
./utils/run.sh $(PAWPAW_TARGET) $(MAKE) -C mod-ui/utils

systray/mod-app$(APP_EXT): systray/main.cpp systray/mod-app.hpp
Expand Down
2 changes: 1 addition & 1 deletion mod-ui
28 changes: 21 additions & 7 deletions systray/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ TARGET_MACHINE := $(shell $(CC) -dumpmachine)

ifneq (,$(findstring linux,$(TARGET_MACHINE)))
LINUX = true
WINDOWS = false
PAWPAW_TARGET = linux-$(shell uname -m)
else ifneq (,$(findstring apple,$(TARGET_MACHINE)))
MACOS = true
WINDOWS = false
PAWPAW_TARGET = macos-universal-10.15
else ifneq (,$(findstring mingw,$(TARGET_MACHINE)))
WINDOWS = true
PAWPAW_TARGET = win64
else ifneq (,$(findstring wasm,$(TARGET_MACHINE)))
WASM = true
WINDOWS = false
PAWPAW_TARGET = wasm
else
$(error unknown target, cannot continue)
Expand All @@ -39,15 +42,17 @@ TARGET = mod-app.exe
EXTRAS = Qt5Core.dll Qt5Gui.dll Qt5Svg.dll Qt5Widgets.dll
CXXFLAGS += $(shell pkg-config --cflags portaudio-2.0)
LDFLAGS += $(shell pkg-config --libs portaudio-2.0)
LDFLAGS += -Wl,-subsystem,windows
WINDRES = $(subst gcc,windres,$(CC))
else
TARGET = mod-app
endif

# ifeq ($(shell pkg-config --exists Qt5Core Qt5Gui Qt5Svg Qt5Widgets && echo true),true)
# QT5_HOSTBINS = $(shell pkg-config --variable=host_bins Qt5Core)
# QT5_FLAGS = $(shell pkg-config --cflags Qt5Core Qt5Gui Qt5Svg Qt5Widgets)
# QT5_LIBS = $(shell pkg-config --libs Qt5Core Qt5Gui Qt5Svg Qt5Widgets)
# else
ifeq ($(shell pkg-config --exists Qt5Core Qt5Gui Qt5Svg Qt5Widgets && echo true)$(WINDOWS),truefalse)
QT5_HOSTBINS = $(shell pkg-config --variable=host_bins Qt5Core)
QT5_FLAGS = $(shell pkg-config --cflags Qt5Core Qt5Gui Qt5Svg Qt5Widgets)
QT5_LIBS = $(shell pkg-config --libs Qt5Core Qt5Gui Qt5Svg Qt5Widgets)
else
QT5_PREFIX = $(shell pkg-config --variable=prefix Qt5OpenGLExtensions)
QT5_HOSTBINS = $(QT5_PREFIX)/bin
QT5_FLAGS = -DQT_CORE_LIB -DQT_GUI_LIB -DQT_SVG_LIB -DQT_WIDGETS_LIB -I$(QT5_PREFIX)/include/qt5
Expand All @@ -56,7 +61,13 @@ QT5_LIBS = -F$(QT5_PREFIX)/lib -framework QtCore -framework QtGui -framework
else
QT5_LIBS = -L$(QT5_PREFIX)/lib -lQt5Core -lQt5Gui -lQt5Svg -lQt5Widgets
endif
# endif
endif

OBJS = main.cpp.o

ifeq ($(WINDOWS),true)
OBJS += mod-app.rc.o
endif

# ---------------------------------------------------------------------------------------------------------------------

Expand All @@ -65,12 +76,15 @@ all: $(TARGET) $(EXTRAS)
clean:
rm -f $(TARGET) $(EXTRAS) qrc_mod-app.hpp ui_mod-app.hpp

$(TARGET): main.cpp.o
$(TARGET): $(OBJS)
$(CXX) $^ $(LDFLAGS) $(QT5_LIBS) -o $@

main.cpp.o: main.cpp mod-app.hpp qrc_mod-app.hpp ui_mod-app.hpp
$(CXX) $< $(CXXFLAGS) $(QT5_FLAGS) -c -o $@

mod-app.rc.o: mod-app.rc mod-logo.ico
$(WINDRES) $< -O coff -o $@

qrc_mod-app.hpp: mod-app.qrc
$(QT5_HOSTBINS)/rcc $< -o $@

Expand Down
11 changes: 7 additions & 4 deletions systray/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ int main(int argc, char* argv[])
if (wchar_t* const wcc = wcsrchr(wc, '\\'))
*wcc = 0;

SetCurrentDirectoryW(wc);

const QString cwd(QString::fromWCharArray(wc));
SetCurrentDirectoryW(wc);

std::wcscat(wc, L"\\plugins");
SetEnvironmentVariableW(L"LV2_PATH", wc);
WCHAR lv2path[(MAX_PATH + 256) * 2] = {};
std::wcscat(lv2path, wc);
std::wcscat(lv2path, L"\\data\\lv2;");
std::wcscat(lv2path, wc);
std::wcscat(lv2path, L"\\plugins");
SetEnvironmentVariableW(L"LV2_PATH", lv2path);
#else
// TODO
const QString cwd;
Expand Down
44 changes: 27 additions & 17 deletions systray/mod-app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ class AppProcess : public QProcess
if (! waitForFinished(500))
kill();
}

public slots:
void startSlot()
{
start();
}
};

class AppWindow : public QMainWindow
Expand Down Expand Up @@ -90,11 +96,13 @@ class AppWindow : public QMainWindow

sysmenu = new QMenu(this);
sysmenu->addAction(openAction);
sysmenu->addAction(settingsAction);
sysmenu->addSeparator();
sysmenu->addAction(quitAction);

systray = new QSystemTrayIcon(icon, this);
systray->setContextMenu(sysmenu);
// systray->setIcon(QPixmap(":/mod-logo.svg"));
connect(systray, &QSystemTrayIcon::messageClicked, this, &AppWindow::messageClicked);
connect(systray, &QSystemTrayIcon::activated, this, &AppWindow::iconActivated);

Expand Down Expand Up @@ -207,23 +215,23 @@ class AppWindow : public QMainWindow

void timerEvent(QTimerEvent* const event) override
{
if (event->timerId() == timerId)
if (timerId != 0 && event->timerId() == timerId)
{
if (startingHost || stoppingHost || processHost.state() != QProcess::NotRunning)
// if (startingHost || stoppingHost || processHost.state() != QProcess::NotRunning)
{
const QByteArray text = processHost.readAll().trimmed();
if (! text.isEmpty())
ui.text_host->appendPlainText(text);
}

if (startingUI || stoppingUI || processUI.state() != QProcess::NotRunning)
// if (startingUI || stoppingUI || processUI.state() != QProcess::NotRunning)
{
const QByteArray text = processUI.readAll().trimmed();
if (! text.isEmpty())
ui.text_ui->appendPlainText(text);
}

startingHost = startingUI = false;
// startingHost = startingUI = false;
}

QMainWindow::timerEvent(event);
Expand Down Expand Up @@ -266,15 +274,15 @@ class AppWindow : public QMainWindow
if (settings.contains("Geometry"))
restoreGeometry(settings.value("Geometry").toByteArray());

if (settings.value("FirstRun", true).toBool())
// if (settings.value("FirstRun", true).toBool())
{
setStopped();
QTimer::singleShot(0, this, &QMainWindow::show);
}
else
{
QTimer::singleShot(100, this, &AppWindow::start);
}
// else
// {
// QTimer::singleShot(100, this, &AppWindow::start);
// }

QTimer::singleShot(1, systray, &QSystemTrayIcon::show);
}
Expand All @@ -286,7 +294,7 @@ class AppWindow : public QMainWindow
ui.b_start->setEnabled(false);
ui.b_stop->setEnabled(true);
ui.b_opengui->setEnabled(true);
systray->setToolTip(tr("Running"));
systray->setToolTip(tr("MOD App: Running"));
}

void setStopped()
Expand All @@ -296,7 +304,7 @@ class AppWindow : public QMainWindow
ui.b_start->setEnabled(true);
ui.b_stop->setEnabled(false);
ui.b_opengui->setEnabled(false);
systray->setToolTip(tr("Stopped"));
systray->setToolTip(tr("MOD App: Stopped"));
}

QString getProcessErrorAsString(QProcess::ProcessError error)
Expand Down Expand Up @@ -359,7 +367,7 @@ private slots:
"-R",
"-S",
#if defined(Q_OS_WIN)
// "-X", "winmme",
// "-X", "winmme",
#elif defined(Q_OS_MAC)
"-X", "coremidi",
#endif
Expand Down Expand Up @@ -431,8 +439,7 @@ private slots:
processUI.terminate();
}

// setRunning();

setStopped();
showErrorMessage(tr("Could not start MOD Host.\n") + getProcessErrorAsString(error));
}

Expand All @@ -451,34 +458,37 @@ private slots:
processHost.terminate();
}

setStopped();
showErrorMessage(tr("Could not start MOD UI.\n") + getProcessErrorAsString(error));
}

void hostStartSuccess()
{
printf("----------- %s %d\n", __FUNCTION__, __LINE__);
startingHost = false;
startingUI = true;
processUI.start();
QTimer::singleShot(1000, &processUI, &AppProcess::startSlot);
}

void uiStartSuccess()
{
printf("----------- %s %d\n", __FUNCTION__, __LINE__);
startingUI = false;
setRunning();
}

void hostFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
printf("----------- %s %d\n", __FUNCTION__, __LINE__);
stoppingHost = false;
startingHost = stoppingHost = false;
stopUIIfNeeded();
setStopped();
}

void uiFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
printf("----------- %s %d\n", __FUNCTION__, __LINE__);
stoppingUI = false;
startingUI = stoppingUI = false;
stopHostIfNeeded();
}

Expand Down
2 changes: 2 additions & 0 deletions systray/mod-app.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id ICON "mod-logo.ico"
401 ICON "mod-logo.ico"
Binary file added systray/mod-logo.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion utils/jack-session.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
l mod-midi-merger mod-midi-merger
l mod-midi-broadcaster mod-midi-broadcaster
l mod-host mod-host 5555
l mod-host mod-host 18182
6 changes: 5 additions & 1 deletion utils/mod-ui-wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@

sys.path = [ROOT] + sys.path

os.environ['LV2_PATH'] = os.path.join(ROOT, 'plugins')
os.environ['LV2_PATH'] = os.path.join(DATA_DIR, 'lv2') + os.path.pathsep + os.path.join(ROOT, 'plugins')
os.environ['MOD_APP'] = '1'
os.environ['MOD_DATA_DIR'] = DATA_DIR
os.environ['MOD_DEFAULT_PEDALBOARD'] = os.path.join(ROOT, 'default.pedalboard')
os.environ['MOD_DEV_ENVIRONMENT'] = '0'
os.environ['MOD_DEVICE_HOST_PORT'] = '18182'
os.environ['MOD_DEVICE_WEBSERVER_PORT'] = '18181'
os.environ['MOD_LOG'] = os.environ.get("MOD_LOG", '1')
os.environ['MOD_KEY_PATH'] = os.path.join(DATA_DIR, 'keys')
os.environ['MOD_HTML_DIR'] = os.path.join(ROOT, 'html')
os.environ['MOD_USER_FILES_DIR'] = os.path.join(DATA_DIR, 'user-files')
os.environ['MOD_USER_PEDALBOARDS_DIR'] = os.path.join(DATA_DIR, 'pedalboards')
os.environ['MOD_USER_PLUGINS_DIR'] = os.path.join(DATA_DIR, 'lv2')

os.makedirs(os.path.join(DATA_DIR, 'user-files', 'Audio Loops'), exist_ok=True)
os.makedirs(os.path.join(DATA_DIR, 'user-files', 'Audio Recordings'), exist_ok=True)
Expand Down

0 comments on commit 9728d48

Please sign in to comment.