Skip to content

Commit f1066ec

Browse files
committed
improved dbus activation
1 parent e17e0b2 commit f1066ec

18 files changed

+257
-93
lines changed

CMakeLists.txt

+11-1
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,29 @@ endif()
6363
set(id "dsnote")
6464
set(info_name "Speech Note")
6565
set(info_org "net.mkiol")
66+
set(info_domain "mkiol.net")
6667
set(info_dbus_speech_service "net.mkiol.Speech")
6768
set(info_dbus_speech_interface "net.mkiol.Speech")
68-
set(info_dbus_app_interface "org.freedesktop.Application")
69+
set(info_dbus_app_service "net.mkiol.dsnote")
6970
set(info_dbus_app_path "/net/mkiol/dsnote")
71+
set(info_dbus_app_id ${id})
7072
set(info_id ${id})
7173
set(info_binary_id ${id})
7274
set(info_translations_id ${id})
7375
if(WITH_SFOS)
7476
set(info_org "org.mkiol")
77+
set(info_domain "mkiol.org")
7578
set(info_dbus_speech_service "org.mkiol.Speech")
7679
set(info_dbus_speech_interface "org.mkiol.Speech")
7780
set(info_dbus_app_service "org.mkiol.dsnote")
7881
set(info_dbus_app_path "/org/mkiol/dsnote")
7982
set(info_binary_id "harbour-dsnote")
8083
endif()
84+
if(WITH_FLATPAK)
85+
set(info_dbus_app_service "net.mkiol.SpeechNote")
86+
set(info_dbus_app_path "/net/mkiol/SpeechNote")
87+
set(info_dbus_app_id "SpeechNote")
88+
endif()
8189
set(info_author "Michal Kosciesza")
8290
set(info_author_email "[email protected]")
8391
set(info_copyright_year "2021-2023")
@@ -357,6 +365,8 @@ list(APPEND deps_libs Qt5::Core Qt5::Network Qt5::Multimedia Qt5::Gui Qt5::Quick
357365
if(WITH_DESKTOP)
358366
find_package(Qt5 COMPONENTS QuickControls2 Widgets REQUIRED)
359367
list(APPEND deps_libs Qt5::QuickControls2 Qt5::Widgets)
368+
369+
include(${cmake_path}/kdbusservice.cmake)
360370
endif()
361371

362372
if(BUILD_PYTHON_MODULE)

cmake/install_desktop.cmake

+11-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ install(FILES "${desktop_dir}/icons/128x128/${info_binary_id}.png" DESTINATION s
1212
install(FILES "${desktop_dir}/icons/256x256/${info_binary_id}.png" DESTINATION share/icons/hicolor/256x256/apps)
1313
install(FILES "${desktop_dir}/icons/512x512/${info_binary_id}.png" DESTINATION share/icons/hicolor/512x512/apps)
1414

15+
configure_file("${desktop_dir}/dbus_app.service.in" "${PROJECT_BINARY_DIR}/dbus_app.service")
16+
if(WITH_FLATPAK)
17+
install(FILES "${PROJECT_BINARY_DIR}/dbus_app.service" DESTINATION share/dbus-1/services RENAME ${info_dbus_app_service}.service)
18+
else()
19+
install(FILES "${PROJECT_BINARY_DIR}/dbus_app.service" DESTINATION share/dbus-1/services RENAME ${info_binary_id}.service)
20+
endif()
21+
1522
if(BUILD_WHISPERCPP)
1623
install(FILES "${external_lib_dir}/libwhisper-openblas.so" DESTINATION lib)
1724
install(FILES "${external_lib_dir}/libwhisper-fallback.so" DESTINATION lib)
@@ -69,9 +76,9 @@ if(BUILD_UROMAN)
6976
endif()
7077

7178
if(WITH_SYSTEMD_SERVICE)
72-
configure_file("${systemd_dir}/${id}.service" "${PROJECT_BINARY_DIR}/${info_binary_id}.service")
73-
install(FILES "${PROJECT_BINARY_DIR}/${info_binary_id}.service" DESTINATION lib/systemd/user)
79+
configure_file("${systemd_dir}/speech.service.in" "${PROJECT_BINARY_DIR}/speech.service")
80+
install(FILES "${PROJECT_BINARY_DIR}/speech.service" DESTINATION lib/systemd/user RENAME ${info_binary_id}.service)
7481

75-
configure_file("${dbus_dir}/${info_dbus_service}.service" "${PROJECT_BINARY_DIR}/${info_dbus_service}.service")
76-
install(FILES "${PROJECT_BINARY_DIR}/${info_dbus_service}.service" DESTINATION lib/systemd/user)
82+
configure_file("${dbus_dir}/dbus_speech.service.in" "${PROJECT_BINARY_DIR}/dbus_speech.service")
83+
install(FILES "${PROJECT_BINARY_DIR}/dbus_speech.service" DESTINATION share/dbus-1/services RENAME ${info_dbus_service}.service)
7784
endif()

cmake/install_sfos.cmake

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ install(TARGETS ${info_binary_id} RUNTIME DESTINATION bin)
22

33
install(FILES "${sfos_dir}/${info_binary_id}.desktop" DESTINATION share/applications)
44

5+
configure_file("${sfos_dir}/dbus_app.service.in" "${PROJECT_BINARY_DIR}/dbus_app.service")
6+
install(FILES "${PROJECT_BINARY_DIR}/dbus_app.service" DESTINATION share/dbus-1/services RENAME ${info_dbus_app_service}.service)
7+
58
if(BUILD_WHISPERCPP)
69
install(FILES "${external_lib_dir}/libwhisper-openblas.so" DESTINATION share/${info_binary_id}/lib)
710
install(FILES "${external_lib_dir}/libwhisper-fallback.so" DESTINATION DESTINATION share/${info_binary_id}/lib)
@@ -60,12 +63,9 @@ install(FILES ${qm_files} DESTINATION "share/${info_binary_id}/translations")
6063
install(DIRECTORY "${sfos_dir}/qml" DESTINATION share/${info_binary_id})
6164

6265
if(WITH_SYSTEMD_SERVICE)
63-
configure_file("${systemd_dir}/${id}.service" "${PROJECT_BINARY_DIR}/${info_binary_id}.service")
64-
install(FILES "${PROJECT_BINARY_DIR}/${info_binary_id}.service" DESTINATION lib/systemd/user)
65-
66-
configure_file("${dbus_dir}/${info_dbus_speech_service}.service" "${PROJECT_BINARY_DIR}/${info_dbus_speech_service}.service")
67-
install(FILES "${PROJECT_BINARY_DIR}/${info_dbus_speech_service}.service" DESTINATION "share/dbus-1/services")
66+
configure_file("${systemd_dir}/speech.service.in" "${PROJECT_BINARY_DIR}/speech.service")
67+
install(FILES "${PROJECT_BINARY_DIR}/speech.service" DESTINATION lib/systemd/user RENAME ${info_binary_id}.service)
6868

69-
configure_file("${dbus_dir}/${info_dbus_app_service}.service" "${PROJECT_BINARY_DIR}/${info_dbus_app_service}.service")
70-
install(FILES "${PROJECT_BINARY_DIR}/${info_dbus_app_service}.service" DESTINATION "share/dbus-1/services")
69+
configure_file("${dbus_dir}/dbus_speech.service.in" "${PROJECT_BINARY_DIR}/dbus_speech.service")
70+
install(FILES "${PROJECT_BINARY_DIR}/dbus_speech.service" DESTINATION share/dbus-1/services RENAME ${info_dbus_speech_service}.service)
7171
endif()

cmake/kdbusservice.cmake

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set(KDE_INSTALL_LIBDIR ${external_lib_dir})
2+
3+
find_package(ECM REQUIRED NO_MODULE)
4+
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
5+
6+
include(KDECMakeSettings)
7+
8+
find_package(KF5 COMPONENTS DBusAddons REQUIRED)
9+
10+
list(APPEND deps_libs KF5::DBusAddons)

config.h.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define APP_NAME "@info_name@"
1414
#define APP_VERSION "@PROJECT_VERSION@"
1515
#define APP_ORG "@info_org@"
16+
#define APP_DOMAIN "@info_domain@"
1617
#define APP_AUTHOR "@info_author@"
1718
#define APP_AUTHOR_EMAIL "@info_author_email@"
1819
#define APP_COPYRIGHT_YEAR "@info_copyright_year@"
@@ -25,8 +26,8 @@
2526
#define APP_DBUS_SPEECH_SERVICE "@info_dbus_speech_service@"
2627
#define APP_DBUS_SPEECH_INTERFACE "@info_dbus_speech_interface@"
2728
#define APP_DBUS_APP_SERVICE "@info_dbus_app_service@"
28-
#define APP_DBUS_APP_INTERFACE "@info_dbus_app_interface@"
2929
#define APP_DBUS_APP_PATH "@info_dbus_app_path@"
30+
#define APP_DBUS_APP_ID "@info_dbus_app_id@"
3031
#define APP_TRANSLATORS_STR "@info_translators_str@"
3132
#define APP_LIBS_STR "@info_libs_str@"
3233
#define APP_CONF_VERSION "@info_conf_version@"
File renamed without changes.

desktop/dbus_app.service.in

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[D-BUS Service]
2+
Name=@info_dbus_app_service@
3+
Exec=@binary_path@

desktop/dsnote.metainfo.xml

+18-9
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,18 @@
1919
</categories>
2020
<keywords>
2121
<keyword>speech</keyword>
22+
<keyword>offline</keyword>
2223
<keyword>voice</keyword>
2324
<keyword>stt</keyword>
2425
<keyword>asr</keyword>
26+
<keyword>speech-to-text</keyword>
27+
<keyword>speech-recognition</keyword>
2528
<keyword>tts</keyword>
29+
<keyword>text-to-speech</keyword>
30+
<keyword>speech-synthesis</keyword>
2631
<keyword>nmt</keyword>
32+
<keyword>neural-machine-translation</keyword>
33+
<keyword>machine-translation</keyword>
2734
<keyword>translator</keyword>
2835
<keyword>deepspeech</keyword>
2936
<keyword>vosk</keyword>
@@ -33,7 +40,6 @@
3340
<keyword>espeak</keyword>
3441
<keyword>mbrola</keyword>
3542
<keyword>coqui</keyword>
36-
<keyword>offline</keyword>
3743
<keyword>bergamot</keyword>
3844
</keywords>
3945
<screenshots>
@@ -82,7 +88,7 @@
8288
<mediatype>text/plain</mediatype>
8389
</provides>
8490
<releases>
85-
<release version="4.2.0" date="2023-09-20">
91+
<release version="4.2.0" date="2023-09-24">
8692
<description>
8793
<p>Translator:</p>
8894
<ul>
@@ -101,18 +107,18 @@
101107
Following Whisper accelerators are currently enabled:
102108
OpenCL (for most Nvidia cards, few AMD cards and Intel GPUs),
103109
CUDA (for most Nvidia cards).
104-
Support for AMD ROCm is implemented as well but right now it doesn't work due to Flatpak sandboxing isolation.
105110
GPU hardware acceleration might not work well on your system, therefore is not enabled by default.
106111
Use the option in 'Settings' to turn it on.
107112
Disable, if you observe any problems when using Speech to Text with Whisper models.
108113
</li>
109114
</ul>
110115
<p>Text to Speech:</p>
111116
<ul>
112-
<li>Save audio in compressed formats (MP3 or Ogg Vorbis). You can also save metadata tags to the audio file,
113-
such as track number, title, artist or album.</li>
117+
<li>Save audio in compressed formats (MP3 or Ogg Vorbis). You can also save metadata tags
118+
to the audio file, such as track number, title, artist or album.</li>
114119
<li>Pause option. Note reading can be paused and resumed.</li>
115-
<li>New models from Massively Multilingual Speech (MMS) project: Hungarian, Catalan, German, Spanish, Romanian, Russian and Swedish.
120+
<li>New models from Massively Multilingual Speech (MMS) project: Hungarian, Catalan, German,
121+
Spanish, Romanian, Russian and Swedish.
116122
If you would like any other MMS model to be included, please let us know.</li>
117123
<li>Update of RHVoice voice for Uzbek.</li>
118124
<li>Fix: Many Coqui models couldn't read the numbers or the reading wasn't correct.</li>
@@ -121,11 +127,14 @@
121127
<ul>
122128
<li>Menu options: 'Open a text file' and 'Save to a text file'</li>
123129
<li>Command line option to open files. If you want to associate text, audio or video files
124-
with Speech Note app, now it is possible. Your system may detect this new capability and
125-
show Speech Note under 'Open With' menu in the file manager.</li>
130+
with Speech Note, now it is possible. Your system may detect this new capability and
131+
show Speech Note under 'Open With' menu in the file manager.
132+
Please note that Flatpak app only has permission to access files in the following folders:
133+
Desktop, Documents, Downloads, Music and Videos.</li>
126134
<li>Improved UI colors when app is running under GNOME dark theme.</li>
127135
<li>Advanced settings option 'Graphical style'. This option let you select any
128-
Qt interface style installed in your system. Changing the style might make app look better under GNOME.</li>
136+
Qt interface style installed in your system. Changing the style might make
137+
app look better under GNOME.</li>
129138
</ul>
130139
</description>
131140
</release>

desktop/qml/ChangelogPage.qml

+5-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ DialogPage {
4646
<li>Save audio in compressed formats (MP3 or Ogg Vorbis). You can also save metadata tags to the audio file,
4747
such as track number, title, artist or album.</li>
4848
<li>Pause option. Note reading can be paused and resumed.</li>
49-
<li>New models from Massively Multilingual Speech (MMS) project: Hungarian, Catalan, German, Spanish, Romanian, Russian and Swedish.
49+
<li>New models from Massively Multilingual Speech (MMS) project: Hungarian, Catalan, German, Spanish,
50+
Romanian, Russian and Swedish.
5051
If you would like any other MMS model to be included, please let us know.</li>
5152
<li>Update of RHVoice voice for Uzbek.</li>
5253
<li>Fix: Many Coqui models couldn't read the numbers or the reading wasn't correct.</li>
@@ -56,7 +57,9 @@ DialogPage {
5657
<li>Menu options: <i>Open a text file</i> and <i>Save to a text file</i></li>
5758
<li>Command line option to open files. If you want to associate text, audio or video files
5859
with Speech Note, now it is possible. Your system may detect this new capability and
59-
show Speech Note under <i>Open With</i> menu in the file manager.</li>
60+
show Speech Note under <i>Open With</i> menu in the file manager.
61+
Please note that Flatpak app only has permission to access files in the following folders:
62+
Desktop, Documents, Downloads, Music and Videos.</li>
6063
<li>Improved UI colors when app is running under GNOME dark theme.</li>
6164
<li>Advanced settings option <i>Graphical style</i>. This option let you select any
6265
Qt interface style installed in your system. Changing the style might make app

desktop/qml/main.qml

+11-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ ApplicationWindow {
111111
return 0
112112
})
113113

114-
console.log("_dummyButton:",list[0])
115-
116114
return list[0]
117115
}
118116
}
@@ -161,6 +159,17 @@ ApplicationWindow {
161159
onTranslator_modeChanged: appWin.update()
162160
}
163161

162+
Connections {
163+
target: _app_server
164+
onActivate_requested: {
165+
appWin.raise()
166+
}
167+
onFiles_to_open_requested: {
168+
app.open_files(files)
169+
appWin.raise()
170+
}
171+
}
172+
164173
SpeechConfig {
165174
id: service
166175

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[D-BUS Service]
22
Name=@info_dbus_app_service@
3-
Interface=@info_dbus_app_interface@
3+
Interface=org.freedesktop.Application
44
Exec=@binary_path@ --app

sfos/harbour-dsnote.desktop

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ MimeType=audio/aac;audio/mpeg;audio/x-mp3;audio/ogg;audio/vorbis;audio/x-vorbis;
77
X-Nemo-Application-Type=silica-qt5
88
X-Share-Methods=files;
99
X-DBusActivatable=true
10-
X-Maemo-Service=org.mkiol.dsnote
11-
X-Maemo-Method=org.freedesktop.Application.Open
1210

1311
[X-Sailjail]
1412
Sandboxing=Disabled

sfos/qml/main.qml

+11
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,17 @@ ApplicationWindow {
219219
onTranslator_modeChanged: root.update()
220220
}
221221

222+
Connections {
223+
target: _app_server
224+
onActivate_requested: {
225+
appWin.raise()
226+
}
227+
onFiles_to_open_requested: {
228+
app.open_files(files)
229+
appWin.raise()
230+
}
231+
}
232+
222233
Connections {
223234
target: service
224235
onModel_download_finished: toast.show(qsTr("The model download is complete!"))

0 commit comments

Comments
 (0)