Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,6 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.

.idea/
src/common/resource.py
Empty file added zone_model_1/__init__.py
Empty file.
51 changes: 51 additions & 0 deletions zone_model_1/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# coding:utf-8
import os
import sys

from PySide6.QtCore import Qt
from PySide6.QtWidgets import QApplication

from zone_model_1.common.config import cfg
from zone_model_1.main_window import MainWindow

if __name__ == '__main__':
import argparse

parser = argparse.ArgumentParser()
parser.add_argument(
'-e', '--execute',
help='Automatically execute all widgets in the input file. Require filepath.',
action='store_true')
parser.add_argument(
'--qianjishen',
help=argparse.SUPPRESS, # Run in debug mode
action='store_true')
parser.add_argument(
'filepath', type=str, nargs='?', help='Full input path in *.fse format', default=None)

args = parser.parse_args()

# enable dpi scale
if cfg.get(cfg.dpiScale) != "Auto":
os.environ["QT_ENABLE_HIGHDPI_SCALING"] = "0"
os.environ["QT_SCALE_FACTOR"] = str(cfg.get(cfg.dpiScale))

# create application
app = QApplication(sys.argv)
app.setAttribute(Qt.ApplicationAttribute.AA_DontCreateNativeWidgetSiblings)
app.aboutToQuit.connect(app.deleteLater)

# internationalization
# locale = cfg.get(cfg.language).value
# translator = FluentTranslator(locale)
# galleryTranslator = QTranslator()
# galleryTranslator.load(locale, "gallery", ".", ":/gallery/i18n")

# app.installTranslator(translator)
# app.installTranslator(galleryTranslator)

# create main window
w = MainWindow(debug=args.qianjishen)
w.show()

sys.exit(app.exec())
Empty file added zone_model_1/common/__init__.py
Empty file.
Empty file.
180 changes: 180 additions & 0 deletions zone_model_1/common/chart/chart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
from PySide6 import QtCore, QtWidgets
from qfluentwidgets import (
RoundMenu, FluentIcon, VerticalSeparator, ScrollArea, ToolButton
)

from .common import ChartSettingCommonBase, ChartWidget
from .setting import SettingWidget
from ..mask_dialog_base import MaskDialogBase


class ChartWithSettingWidget(QtWidgets.QWidget, ChartSettingCommonBase):
def __init__(self, parent=None):
self.fp_fds = None
self.current_state_is_moving_average_applied: bool = False
super().__init__(parent)
self._chart = ChartWidget(self)
self._setting = SettingWidget(self)
self._setting.widget_layout.addStretch(1)
self._setting.widget_layout.setContentsMargins(0, 0, 12, 0)
scroll_area = ScrollArea()
scroll_area.setWidget(self._setting)
scroll_area.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
scroll_area.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAsNeeded)
scroll_area.setWidgetResizable(True)
scroll_area.setStyleSheet('background-color: transparent;')

layout = QtWidgets.QHBoxLayout(self)
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(0)
layout.addWidget(self._chart, stretch=1)
layout.addWidget(VerticalSeparator(self))
layout.addSpacing(12)
layout.addWidget(scroll_area)

self.connect_signals()

@property
def chart(self) -> ChartWidget:
return self._chart

@property
def setting(self) -> SettingWidget:
return self._setting


class ChartDialog(QtWidgets.QDialog, ChartSettingCommonBase):
def __init__(self, parent=None):
self.fp_fds = None
self.current_state_is_moving_average_applied: bool = False
super().__init__(parent)
self._chart = ChartWidget(self)
self._setting = SettingWidget(self)
self._setting.widget_layout.addStretch(1)
self._setting.widget_layout.setContentsMargins(0, 0, 12, 0)
scroll_area = ScrollArea()
scroll_area.setWidget(self._setting)
scroll_area.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
scroll_area.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAsNeeded)
scroll_area.setWidgetResizable(True)
scroll_area.setStyleSheet('ScrollArea{border:none;}')

layout = QtWidgets.QHBoxLayout(self)
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(0)
layout.addWidget(self._chart, stretch=1)
layout.addWidget(VerticalSeparator(self))
layout.addSpacing(12)
layout.addWidget(scroll_area)

self.connect_signals()

@property
def chart(self) -> ChartWidget:
return self._chart

@property
def setting(self) -> SettingWidget:
return self._setting

def sizeHint(self):
return QtCore.QSize(1200, 800)


class CompactChartDialog(QtWidgets.QDialog, ChartSettingCommonBase):
def __init__(self, parent=None):
self.fp_fds = None
self.current_state_is_moving_average_applied: bool = False
super().__init__(parent)
self._chart = ChartWidget(self)

self._setting = SettingWidget(self)
self._setting.widget_layout.addStretch(1)
self._setting.widget_layout.setContentsMargins(0, 0, 0, 0)
scroll_area = ScrollArea()
scroll_area.setWidget(self._setting)
scroll_area.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
scroll_area.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAsNeeded)
scroll_area.setWidgetResizable(True)
scroll_area.setStyleSheet('ScrollArea{border:none;}')

self.show_x_axis_setting_button = ToolButton()
self.show_x_axis_setting_button.setIcon(FluentIcon.MORE)

menu_widget = QtWidgets.QWidget(self)
menu_widget.setContentsMargins(0, 0, 0, 0)
menu_widget_layout = QtWidgets.QHBoxLayout(menu_widget)
menu_widget_layout.addWidget(scroll_area)
menu_widget.setFixedHeight(600)
menu_widget.setFixedWidth(350)
self.menu = RoundMenu(parent=self)
self.menu.addWidget(menu_widget, selectable=False)

layout = QtWidgets.QGridLayout(self)
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(0)
layout.addWidget(self._chart, 0, 0)
# layout.addWidget(VerticalSeparator(self))
# layout.addSpacing(12)
layout.addWidget(
self.show_x_axis_setting_button, 0, 0,
alignment=QtCore.Qt.AlignmentFlag.AlignTop | QtCore.Qt.AlignmentFlag.AlignRight
)

self.show_x_axis_setting_button.clicked.connect(lambda: self.menu.exec(
self.show_x_axis_setting_button.mapToGlobal(QtCore.QPoint(self.show_x_axis_setting_button.width() + 3, -12))
))

self.connect_signals()

@property
def chart(self) -> ChartWidget:
return self._chart

@property
def setting(self) -> SettingWidget:
return self._setting

def show_setting_dialog(self, pos):
self.menu.exec(pos)

def sizeHint(self):
return QtCore.QSize(800, 600)


class MaskChartDialog(MaskDialogBase, ChartSettingCommonBase):
""" Custom message box """

def __init__(self, parent=None):
self.fp_fds = None
self.current_state_is_moving_average_applied: bool = False
super().__init__(parent)
self._chart = ChartWidget(self)
self._setting = SettingWidget(self)
self._setting.widget_layout.addStretch(1)
self._setting.widget_layout.setContentsMargins(0, 0, 12, 0)
scroll_area = ScrollArea(self)
scroll_area.setWidget(self._setting)
scroll_area.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
scroll_area.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAsNeeded)
scroll_area.setWidgetResizable(True)
scroll_area.setStyleSheet(
'ScrollArea{border:1px solid transparent;border-radius:5px;}QWidget{background-color:transparent;}'
)

self.widget_layout.setContentsMargins(0, 0, 0, 0)
self.widget_layout.setSpacing(0)
self.widget_layout.addWidget(self._chart, stretch=1)
self.widget_layout.addWidget(VerticalSeparator(self))
self.widget_layout.addSpacing(12)
self.widget_layout.addWidget(scroll_area)

self.connect_signals()

@property
def chart(self) -> ChartWidget:
return self._chart

@property
def setting(self) -> SettingWidget:
return self._setting
Loading