Skip to content

Commit 2bf41c8

Browse files
committed
Fixed import structure
1 parent 8e9e360 commit 2bf41c8

20 files changed

+82
-57
lines changed

FreeRGB.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This file is part of FreeRGB, an app to control lighting devices.
2+
# Copyright (C) 2020 milan338.
3+
#
4+
# FreeRGB is free software: you can redistribute it and/or modify
5+
# it under the terms of the GNU General Public License as published by
6+
# the Free Software Foundation, either version 3 of the License, or
7+
# (at your option) any later version.
8+
#
9+
# FreeRGB is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with FreeRGB. If not, see <https://www.gnu.org/licenses/>.
16+
17+
from src.__main__ import init
18+
19+
if __name__ == "__main__":
20+
init()

src/resources.qrc resources.qrc

File renamed without changes.
File renamed without changes.

src/Globals.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with FreeRGB. If not, see <https://www.gnu.org/licenses/>.
1616

17-
# Logger
17+
# Logging
18+
has_logged = False
1819
logger = None
1920

2021
# Store currently hovered button
@@ -37,7 +38,7 @@
3738
advanced_mode_elements = []
3839

3940
# Import location for effect definitions
40-
effect_import_path = 'ui.effects.effect'
41+
effect_import_path = 'src.ui.effects.effect'
4142

4243
# Refresh menus from any package (called as function)
4344
refreshMenus = None

src/InitLogging.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with FreeRGB. If not, see <https://www.gnu.org/licenses/>.
1616

17-
import Globals
18-
1917
import logging
2018

19+
from src import Globals
20+
2121
from datetime import datetime
2222

2323
from logging.handlers import RotatingFileHandler

src/Settings.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with FreeRGB. If not, see <https://www.gnu.org/licenses/>.
1616

17-
import Globals
17+
from src import Globals
1818

19-
from rw.JsonIO import JsonIO
19+
from src.rw.JsonIO import JsonIO
2020

2121
# Store settings
2222
advanced_mode = None

src/__init__.py

Whitespace-only changes.

src/__main__.py

+20-16
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@
1818

1919
import sys
2020

21-
import Globals
22-
import Settings
21+
from src import Globals
22+
from src import Settings
2323

24-
from InitLogging import InitLogging
24+
from src.InitLogging import InitLogging
2525

26-
from rw.JsonIO import JsonIO
27-
from rw.QssRead import QssRead
26+
from src.rw.JsonIO import JsonIO
27+
from src.rw.QssRead import QssRead
2828

29-
from ui import getPath
30-
from ui.GenerateButtons import GenerateButtons
31-
from ui.effects.Effects import Effects
32-
from ui.generators.CreateMenuContext import CreateMenuContext
33-
from ui.generators.CreateMenuEffectEdit import CreateMenuEffectEdit
34-
from ui.generators.CreateMessageBox import CreateMessageBox
35-
from ui.views.input.InputDialogue import InputDialogue
36-
from ui.views.main.Ui_MainWindow import Ui_Form
37-
from ui.views.monitor.SerialMonitor import SerialMonitor
29+
from src.ui import getPath
30+
from src.ui.GenerateButtons import GenerateButtons
31+
from src.ui.effects.Effects import Effects
32+
from src.ui.generators.CreateMenuContext import CreateMenuContext
33+
from src.ui.generators.CreateMenuEffectEdit import CreateMenuEffectEdit
34+
from src.ui.generators.CreateMessageBox import CreateMessageBox
35+
from src.ui.views.input.InputDialogue import InputDialogue
36+
from src.ui.views.main.Ui_MainWindow import Ui_Form
37+
from src.ui.views.monitor.SerialMonitor import SerialMonitor
3838

3939
from PyQt5.QtGui import QCursor
4040
from PyQt5.QtWidgets import QWidget, QColorDialog, QMessageBox, QApplication
@@ -46,7 +46,7 @@ def __init__(self, *args, **kwargs):
4646
# Get application version
4747
self.version_name = JsonIO('app_Version.json').readEntry('version')
4848
# Setup logging
49-
InitLogging(10)
49+
InitLogging(10) # TODO only start logging once option selected, don't overwrite logs if already logged i.e. set already_logged to true once logged at all during session and prevent making new log while true (remainder of runtime)
5050
# Allow global access to refresh main menu using JSON
5151
Globals.refreshMenus = lambda: self.refreshMenus()
5252
# Initialise settings
@@ -197,7 +197,7 @@ def mousePressEvent(self, event):
197197
pass
198198

199199

200-
if __name__ == '__main__':
200+
def init():
201201
# Initialise application
202202
app = QApplication(sys.argv)
203203
# Setup main window
@@ -212,3 +212,7 @@ def mousePressEvent(self, event):
212212
window.show()
213213
# Run application and provide exit code
214214
sys.exit(app.exec())
215+
216+
217+
if __name__ == '__main__':
218+
init()

src/ui/ButtonActions.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with FreeRGB. If not, see <https://www.gnu.org/licenses/>.
1616

17-
import Globals
18-
import Settings
17+
from src import Globals
18+
from src import Settings
1919

20-
from ui.views.licenses.LicensesView import LicensesView
20+
from src.ui.views.licenses.LicensesView import LicensesView
2121

2222
import webbrowser
2323

src/ui/GenerateButtons.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with FreeRGB. If not, see <https://www.gnu.org/licenses/>.
1616

17-
import Globals
17+
from src import Globals
1818

19-
from rw.JsonIO import JsonIO
19+
from src.rw.JsonIO import JsonIO
2020

21-
from ui.views.input.InputDialogue import InputDialogue
22-
from ui.generators.CreateLargeButton import CreateLargeButton
23-
from ui.generators.CreateMessageBox import CreateMessageBox
21+
from src.ui.views.input.InputDialogue import InputDialogue
22+
from src.ui.generators.CreateLargeButton import CreateLargeButton
23+
from src.ui.generators.CreateMessageBox import CreateMessageBox
2424

2525

2626
class GenerateButtons():

src/ui/effects/Effects.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with FreeRGB. If not, see <https://www.gnu.org/licenses/>.
1616

17-
import Globals
18-
1917
from os import listdir, path
2018

21-
from rw.JsonIO import JsonIO
19+
from src import Globals
20+
21+
from src.rw.JsonIO import JsonIO
2222

2323

2424
class Effects():

src/ui/effects/effect/SolidColour.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with FreeRGB. If not, see <https://www.gnu.org/licenses/>.
1616

17-
import Globals
17+
from src import Globals
1818

1919

2020
class SolidColour():

src/ui/generators/CreateLargeButton.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with FreeRGB. If not, see <https://www.gnu.org/licenses/>.
1616

17-
import Globals
17+
from src import Globals
1818

19-
from rw.JsonIO import JsonIO
19+
from src.rw.JsonIO import JsonIO
2020

21-
from ui.ButtonActions import ButtonActions
22-
from ui.widgets.HoverButton import HoverButton
23-
from ui.widgets.ToggleSwitch import ToggleSwitch
21+
from src.ui.ButtonActions import ButtonActions
22+
from src.ui.widgets.HoverButton import HoverButton
23+
from src.ui.widgets.ToggleSwitch import ToggleSwitch
2424

2525
from PyQt5.QtCore import Qt, QCoreApplication, QSize, QRect
2626
from PyQt5.QtGui import QCursor

src/ui/generators/CreateMenuContext.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with FreeRGB. If not, see <https://www.gnu.org/licenses/>.
1616

17-
import Globals
17+
from src import Globals
1818

19-
from ui.generators.CreateMenuPopup import CreateMenuPopup
19+
from src.ui.generators.CreateMenuPopup import CreateMenuPopup
2020

2121

2222
class CreateMenuContext(CreateMenuPopup):

src/ui/generators/CreateMenuEffectEdit.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with FreeRGB. If not, see <https://www.gnu.org/licenses/>.
1616

17-
import Globals
17+
from src import Globals
1818

19-
from ui.GenerateButtons import GenerateButtons
20-
from ui.generators.CreateMenuPopup import CreateMenuPopup
19+
from src.ui.GenerateButtons import GenerateButtons
20+
from src.ui.generators.CreateMenuPopup import CreateMenuPopup
2121

2222

2323
class CreateMenuEffectEdit(CreateMenuPopup):

src/ui/generators/CreateMenuPopup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with FreeRGB. If not, see <https://www.gnu.org/licenses/>.
1616

17-
from ui import getPath
17+
from src.ui import getPath
1818

1919
from PyQt5.QtWidgets import QMenu, QAction
2020

src/ui/generators/CreateMessageBox.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with FreeRGB. If not, see <https://www.gnu.org/licenses/>.
1616

17-
import Globals
18-
import Settings
17+
from src import Globals
18+
from src import Settings
1919

20-
from rw.JsonIO import JsonIO
20+
from src.rw.JsonIO import JsonIO
2121

2222
from PyQt5.QtWidgets import QMessageBox
2323

src/ui/views/input/InputDialogue.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with FreeRGB. If not, see <https://www.gnu.org/licenses/>.
1616

17-
import Globals
17+
from src import Globals
1818

19-
from ui.generators.CreateMenuContext import CreateMenuContext
20-
from ui.views.input.Ui_InputDialogue import Ui_Form
19+
from src.ui.generators.CreateMenuContext import CreateMenuContext
20+
from src.ui.views.input.Ui_InputDialogue import Ui_Form
2121

22-
from rw.JsonIO import JsonIO
22+
from src.rw.JsonIO import JsonIO
2323

2424
from PyQt5.QtWidgets import QWidget
2525
from PyQt5.QtGui import QCursor

src/ui/views/licenses/LicensesView.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with FreeRGB. If not, see <https://www.gnu.org/licenses/>.
1616

17-
from ui import getPath
18-
from ui.views.licenses.Ui_LicensesView import Ui_Form
17+
from src.ui import getPath
18+
from src.ui.views.licenses.Ui_LicensesView import Ui_Form
1919

2020
from PyQt5.QtWidgets import QWidget, QSpacerItem, QSizePolicy
2121
from PyQt5.QtCore import Qt
@@ -37,7 +37,7 @@ def __init__(self, *args, **kwargs):
3737

3838
def addLicenses(self):
3939
# Imports done here to prevent circular imports
40-
from ui.GenerateButtons import GenerateButtons
40+
from src.ui.GenerateButtons import GenerateButtons
4141
GenerateButtons('licenses.json', 'licenses').generateGenericButtons(
4242
self.ui.license_button_layout, self.ui.license_scroll_region, 'primary', spacer=True)
4343
# Additional spacer below buttons for better separation between border and bottom button

src/ui/views/monitor/SerialMonitor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
from datetime import datetime
2222

23-
from ui.widgets.ToggleSwitch import ToggleSwitch
24-
from ui.views.monitor.Ui_SerialMonitor import Ui_Form
23+
from src.ui.widgets.ToggleSwitch import ToggleSwitch
24+
from src.ui.views.monitor.Ui_SerialMonitor import Ui_Form
2525

2626
from PyQt5.QtWidgets import QWidget
2727
from PyQt5.QtCore import Qt

0 commit comments

Comments
 (0)