Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SOHViewer
Manage
Activity
Members
Labels
Plan
Issues
14
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
5
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software Public
PASSOFT
SOHViewer
Commits
66252307
Commit
66252307
authored
1 year ago
by
Kien Le
Browse files
Options
Downloads
Patches
Plain Diff
Refactored entry point to make it easier to read
parent
0f8db625
No related branches found
No related tags found
1 merge request
!218
Fix program not fitting on low resolution screens
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sohstationviewer/database/soh.db
+0
-0
0 additions, 0 deletions
sohstationviewer/database/soh.db
sohstationviewer/main.py
+30
-19
30 additions, 19 deletions
sohstationviewer/main.py
with
30 additions
and
19 deletions
sohstationviewer/database/soh.db
+
0
−
0
View file @
66252307
No preview for this file type
This diff is collapsed.
Click to expand it.
sohstationviewer/main.py
+
30
−
19
View file @
66252307
...
@@ -27,21 +27,17 @@ if os_name == 'macOS':
...
@@ -27,21 +27,17 @@ if os_name == 'macOS':
os
.
environ
[
'
QT_MAC_WANTS_LAYER
'
]
=
'
1
'
os
.
environ
[
'
QT_MAC_WANTS_LAYER
'
]
=
'
1
'
def
main
():
def
fix_relative_paths
()
->
None
:
# Change the working directory so that relative paths work correctly.
"""
Change the working director so that the relative paths in the code work
correctly.
"""
current_file_path
=
os
.
path
.
abspath
(
__file__
)
current_file_path
=
os
.
path
.
abspath
(
__file__
)
current_file_dir
=
Path
(
current_file_path
).
parent
current_file_dir
=
Path
(
current_file_path
).
parent
os
.
chdir
(
current_file_dir
)
os
.
chdir
(
current_file_dir
)
app
=
QtWidgets
.
QApplication
(
sys
.
argv
)
wnd
=
MainWindow
()
def
check_if_user_want_to_reset_config
():
config
=
ConfigProcessor
()
config
.
load_config
()
need_reset
=
False
try
:
config
.
validate_config
()
config
.
apply_config
(
wnd
)
except
(
BadConfigError
,
ValueError
)
as
e
:
bad_config_dialog
=
QMessageBox
()
bad_config_dialog
=
QMessageBox
()
bad_config_dialog
.
setText
(
'
Something went wrong when reading the
'
bad_config_dialog
.
setText
(
'
Something went wrong when reading the
'
'
config.
'
)
'
config.
'
)
...
@@ -53,20 +49,35 @@ def main():
...
@@ -53,20 +49,35 @@ def main():
bad_config_dialog
.
setDefaultButton
(
QMessageBox
.
Ok
)
bad_config_dialog
.
setDefaultButton
(
QMessageBox
.
Ok
)
bad_config_dialog
.
setIcon
(
QMessageBox
.
Critical
)
bad_config_dialog
.
setIcon
(
QMessageBox
.
Critical
)
reset_choice
=
bad_config_dialog
.
exec_
()
reset_choice
=
bad_config_dialog
.
exec_
()
if
reset_choice
==
QMessageBox
.
Ok
:
return
reset_choice
==
QMessageBox
.
Ok
need_reset
=
True
else
:
sys
.
exit
(
1
)
def
main
():
if
need_reset
:
# Change the working directory so that relative paths work correctly.
fix_relative_paths
()
app
=
QtWidgets
.
QApplication
(
sys
.
argv
)
wnd
=
MainWindow
()
config
=
ConfigProcessor
()
config
.
load_config
()
do_reset
=
False
try
:
config
.
validate_config
()
config
.
apply_config
(
wnd
)
except
(
BadConfigError
,
ValueError
)
as
e
:
do_reset
=
check_if_user_want_to_reset_config
()
if
do_reset
:
try
:
try
:
config
.
reset
()
config
.
reset
()
except
OSError
:
except
OSError
:
QMessageBox
.
critical
(
None
,
'
Cannot reset config
'
,
QMessageBox
.
critical
(
None
,
'
Cannot reset config
'
,
'
Config file cannot be reset. Please
'
'
Config file cannot be reset. Please ensure
'
'
ensure that it is not opened in another
'
'
that it is not opened in another program.
'
,
'
program.
'
,
QMessageBox
.
Close
)
QMessageBox
.
Close
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
else
:
sys
.
exit
(
1
)
config
.
apply_config
(
wnd
)
config
.
apply_config
(
wnd
)
screen_width
,
screen_height
=
app
.
primaryScreen
().
size
().
toTuple
()
screen_width
,
screen_height
=
app
.
primaryScreen
().
size
().
toTuple
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment