Skip to content

Commit 63f0b7a

Browse files
committed
GUI - experimental - try ensuring only one instance of Sonic Pi can run at once
uses https://github.com/itay-grudev/SingleApplication/ needs thorough testing on macOS and Linux in addition to user testing on school Windows clusters
1 parent 9eb6ace commit 63f0b7a

32 files changed

+2772
-3
lines changed

app/gui/qt/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ project("Sonic Pi"
1313
HOMEPAGE_URL "https://sonic-pi.net"
1414
)
1515

16-
16+
set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication")
1717
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1818

1919
set(QTAPP_ROOT ${CMAKE_CURRENT_LIST_DIR})
@@ -68,6 +68,8 @@ else()
6868
add_subdirectory(QScintilla_src-2.13.3)
6969
endif()
7070

71+
add_subdirectory(vendor/SingleApplication)
72+
7173
set(APP_NAME sonic-pi)
7274
set(MACOS_APP_NAME "Sonic Pi")
7375

@@ -295,7 +297,8 @@ target_link_libraries(${APP_NAME}
295297
PRIVATE
296298
SonicPi::API
297299
QScintilla
298-
Threads::Threads)
300+
Threads::Threads
301+
SingleApplication::SingleApplication)
299302

300303
if(Qt5_FOUND)
301304
target_link_libraries(${APP_NAME}

app/gui/qt/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <QLabel>
2121
#include <QLibraryInfo>
2222

23+
#include <singleapplication.h>
2324
#include "mainwindow.h"
2425

2526
#include "widgets/sonicpilog.h"
@@ -62,7 +63,7 @@ int main(int argc, char *argv[])
6263
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
6364
#endif
6465

65-
QApplication app(argc, argv);
66+
SingleApplication app(argc, argv);
6667

6768
QFontDatabase::addApplicationFont(":/fonts/Hack-Regular.ttf");
6869
QFontDatabase::addApplicationFont(":/fonts/Hack-Italic.ttf");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: itay-grudev
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "Documentation"
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
8+
jobs:
9+
doxygen:
10+
name: Doxygen
11+
runs-on: ubuntu-22.04
12+
steps:
13+
- name: Clone repo
14+
uses: actions/checkout@v3
15+
16+
- name: Install doxygen and pre-requsites packages
17+
run: |
18+
sudo apt-get update
19+
sudo apt-get install doxygen qtbase5-dev
20+
21+
- name: Generate documentation
22+
run: |
23+
cmake -B build -D SINGLEAPPLICATION_DOCUMENTATION=ON -D DOXYGEN_WARN_AS_ERROR=YES
24+
cmake --build build --target SingleApplicationDocumentation
25+
find build/html/ -name *.html -type f -exec sed -i 's+https://github.com/jothepro/doxygen-awesome-css+https://github.com/itay-grudev/SingleApplication+g' {} \;
26+
27+
- name: Deploy to GitHub pages
28+
uses: crazy-max/ghaction-github-pages@v3
29+
with:
30+
target_branch: gh-pages
31+
build_dir: build/html
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: "CI: Build Test"
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- "releases/**"
7+
paths-ignore:
8+
- "**.md"
9+
pull_request:
10+
paths-ignore:
11+
- "**.md"
12+
13+
jobs:
14+
build:
15+
name: Build
16+
strategy:
17+
matrix:
18+
qt_version: [5.12.6, 5.15.0, 6.0.0, 6.2.0]
19+
platform: [ubuntu-20.04, windows-latest, macos-latest]
20+
include:
21+
- qt_version: 6.0.0
22+
additional_arguments: -D QT_DEFAULT_MAJOR_VERSION=6
23+
- qt_version: 6.2.0
24+
additional_arguments: -D QT_DEFAULT_MAJOR_VERSION=6
25+
- platform: ubuntu-20.04
26+
make: make
27+
CXXFLAGS: -Wall -Wextra -pedantic -Werror
28+
MAKEFLAGS: -j2
29+
- platform: macos-latest
30+
make: make
31+
CXXFLAGS: -Wall -Wextra -pedantic -Werror
32+
MAKEFLAGS: -j3
33+
- platform: windows-latest
34+
make: nmake
35+
CXXFLAGS: /W4 /WX /MP
36+
37+
runs-on: ${{ matrix.platform }}
38+
env:
39+
CXXFLAGS: ${{ matrix.CXXFLAGS }}
40+
MAKEFLAGS: ${{ matrix.MAKEFLAGS }}
41+
42+
steps:
43+
- name: Clone repo
44+
uses: actions/checkout@v2.3.4
45+
46+
- name: Install Qt
47+
uses: jurplel/install-qt-action@v2.14.0
48+
with:
49+
version: ${{ matrix.qt_version }}
50+
51+
- name: Build library with CMake
52+
run: |
53+
cmake . ${{ matrix.additional_arguments }}
54+
cmake --build .
55+
56+
- name: Build basic example with CMake
57+
working-directory: examples/basic/
58+
run: |
59+
cmake . ${{ matrix.additional_arguments }}
60+
cmake --build .
61+
62+
- name: Build calculator example CMake
63+
working-directory: examples/calculator/
64+
run: |
65+
cmake . ${{ matrix.additional_arguments }}
66+
cmake --build .
67+
68+
- name: Build sending_arguments example with CMake
69+
working-directory: examples/sending_arguments/
70+
run: |
71+
cmake . ${{ matrix.additional_arguments }}
72+
cmake --build .
73+
74+
- name: Setup MSVC environment for QMake
75+
uses: ilammy/msvc-dev-cmd@v1
76+
77+
- name: Build basic example with QMake
78+
working-directory: examples/basic/
79+
run: |
80+
qmake
81+
${{ matrix.make }}
82+
83+
- name: Build calculator example QMake
84+
working-directory: examples/calculator/
85+
run: |
86+
qmake
87+
${{ matrix.make }}
88+
89+
- name: Build sending_arguments example with QMake
90+
working-directory: examples/sending_arguments/
91+
run: |
92+
qmake
93+
${{ matrix.make }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/examples/*/*.o
2+
/examples/*/Makefile
3+
/examples/*/moc_*.cpp
4+
/examples/*/moc_predefs.h
5+
/examples/*/*.qmake.stash
6+
/examples/basic/basic
7+
/examples/calculator/calculator
8+
/examples/sending_arguments/sending_arguments
9+
/**/CMakeLists.txt.user
10+
/**/CMakeCache.txt
11+
/**/CMakeCache/*
12+
/**/CMakeFiles/*
13+
/**/Makefile
14+
/**/cmake_install.cmake
15+
/**/*_autogen/
16+
libSingleApplication.a

0 commit comments

Comments
 (0)