aboutsummaryrefslogtreecommitdiffstats
path: root/main.py
blob: d30ad5e56a7579a514316e535242ed0647d105f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Soundboard Engine - customizable soundboard
# Copyright (C) 2026  Vidhu Kant Sharma <vidhukant@vidhukant.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

import os
import platform
import sys
from pathlib import Path

from PySide6.QtWidgets import QApplication

from Soundboard import Soundboard
from SoundboardEngine import SoundboardEngineWindow
from SoundboardUpdater import SoundboardUpdaterWindow

APP_VERSION = "0.3.3"

if __name__ == "__main__":
    config_path = (
        Path(sys.argv[1]).resolve()
        if len(sys.argv) > 1 and sys.argv[1].endswith(".json")
        else Path("soundboard.json").resolve()
    )

    if not config_path.exists():
        print(f"Error: Could not find soundboard JSON at {config_path}")
        sys.exit(1)

    os.chdir(config_path.parent)

    _soundboard = Soundboard(config_path)
    _soundboard.build()

    if platform.system() == "Linux":
        os.environ["QT_QPA_PLATFORMTHEME"] = "gtk3"

    app = QApplication(sys.argv)
    app.setStyle("Fusion")

    app.setOrganizationName("VidhuKant")
    app.setApplicationName(_soundboard.soundboard_id)

    main_window = SoundboardEngineWindow(_soundboard, APP_VERSION)

    updater = SoundboardUpdaterWindow(_soundboard)
    updater.start_soundboard.connect(main_window.show)

    updater.show()

    sys.exit(app.exec())