diff --git a/pymead/gui/airfoil_canvas.py b/pymead/gui/airfoil_canvas.py index 14a073c0..c4f7ee2c 100644 --- a/pymead/gui/airfoil_canvas.py +++ b/pymead/gui/airfoil_canvas.py @@ -700,7 +700,7 @@ def selectPointsToDeepcopy(self): self.clearSelectedObjects() def exportPlot(self): - dialog = PlotExportDialog(self, gui_obj=self.gui_obj) + dialog = PlotExportDialog(self, gui_obj=self.gui_obj, theme=self.gui_obj.themes[self.gui_obj.current_theme]) if dialog.exec_(): # Get the inputs from the dialog inputs = dialog.valuesFromWidgets() @@ -735,6 +735,10 @@ def exportPlot(self): def contextMenuEvent(self, event): menu = QtWidgets.QMenu(self) + menu.setStyleSheet(f""" + QMenu::item:selected {{ background-color: + {self.gui_obj.themes[self.gui_obj.current_theme]['menu-item-selected-color']} }} + """) create_geometry_menu = menu.addMenu("Create Geometry") modify_geometry_menu = menu.addMenu("Modify Geometry") add_constraint_menu = menu.addMenu("Add Constraint") diff --git a/pymead/gui/gui.py b/pymead/gui/gui.py index 5817ccfc..ef278151 100644 --- a/pymead/gui/gui.py +++ b/pymead/gui/gui.py @@ -370,7 +370,7 @@ def closeEvent(self, a0) -> None: Qt CloseEvent object """ if self.shape_opt_process is not None: - dialog = ExitOptimizationDialog(self) + dialog = ExitOptimizationDialog(self, theme=self.themes[self.current_theme]) if dialog.exec_(): self.stop_optimization() else: @@ -586,7 +586,7 @@ def take_screenshot(self): "Console": self.text_area.winId() } - dialog = ScreenshotDialog(self) + dialog = ScreenshotDialog(self, theme=self.themes[self.current_theme]) if dialog.exec_(): inputs = dialog.getInputs() @@ -896,7 +896,8 @@ def plot_field(self): default_field_dir = self.last_analysis_dir else: default_field_dir = "" - dlg = MSESFieldPlotDialog(parent=self, default_field_dir=default_field_dir) + dlg = MSESFieldPlotDialog(parent=self, default_field_dir=default_field_dir, + theme=self.themes[self.current_theme]) if dlg.exec_(): inputs = dlg.valuesFromWidgets() else: @@ -1189,7 +1190,7 @@ def show_help(self): HelpBrowserWindow(parent=self) def export_IGES(self): - self.dialog = ExportIGESDialog(parent=self) + self.dialog = ExportIGESDialog(parent=self, theme=self.themes[self.current_theme]) if self.dialog.exec_(): inputs = self.dialog.valuesFromWidgets() iges_file_path = self.geo_col.write_to_iges(base_dir=inputs["dir"], file_name=inputs["file_name"], @@ -1199,7 +1200,8 @@ def export_IGES(self): self.disp_message_box(f"Airfoil geometry saved to {iges_file_path}", message_mode="info") def single_airfoil_viscous_analysis(self): - self.dialog = XFOILDialog(parent=self, current_airfoils=[k for k in self.geo_col.container()["airfoils"]]) + self.dialog = XFOILDialog(parent=self, current_airfoils=[k for k in self.geo_col.container()["airfoils"]], + theme=self.themes[self.current_theme]) current_airfoils = [k for k in self.geo_col.container()["airfoils"].keys()] self.dialog.w.widget_dict["airfoil"]["widget"].addItems(current_airfoils) if self.dialog.exec(): @@ -1292,7 +1294,8 @@ def multi_airfoil_analysis_setup(self): return self.dialog = MultiAirfoilDialog( - parent=self, geo_col=self.geo_col, settings_override=self.multi_airfoil_analysis_settings + parent=self, geo_col=self.geo_col, theme=self.themes[self.current_theme], + settings_override=self.multi_airfoil_analysis_settings ) self.dialog.accepted.connect(self.multi_airfoil_analysis_accepted) self.dialog.rejected.connect(self.multi_airfoil_analysis_rejected) @@ -1451,7 +1454,7 @@ def multi_airfoil_analysis(self, mset_settings: dict, mses_settings: dict, def match_airfoil(self): airfoil_names = [a for a in self.geo_col.container()["airfoils"].keys()] - dialog = AirfoilMatchingDialog(self, airfoil_names=airfoil_names) + dialog = AirfoilMatchingDialog(self, airfoil_names=airfoil_names, theme=self.themes[self.current_theme]) if dialog.exec_(): airfoil_match_settings = dialog.valuesFromWidgets() # res = match_airfoil_ga(self.mea, target_airfoil, airfoil_name) @@ -1471,7 +1474,7 @@ def match_airfoil(self): self.disp_message_box(message=res.message, message_mode=msg_mode) def plot_airfoil_from_airfoiltools(self): - dialog = AirfoilPlotDialog(self) + dialog = AirfoilPlotDialog(self, theme=self.themes[self.current_theme]) if dialog.exec_(): airfoil_name = dialog.valuesFromWidgets() airfoil = extract_data_from_airfoiltools(airfoil_name) @@ -1479,7 +1482,7 @@ def plot_airfoil_from_airfoiltools(self): def setup_optimization(self): self.dialog = OptimizationSetupDialog(self, settings_override=self.opt_settings, - geo_col=self.geo_col) + geo_col=self.geo_col, theme=self.themes[self.current_theme]) self.dialog.accepted.connect(self.optimization_accepted) self.dialog.rejected.connect(self.optimization_rejected) self.dialog.exec_() diff --git a/pymead/gui/input_dialog.py b/pymead/gui/input_dialog.py index 20ee53fc..9ce756b9 100644 --- a/pymead/gui/input_dialog.py +++ b/pymead/gui/input_dialog.py @@ -914,11 +914,11 @@ def change_airfoils(self, _): current_airfoil_list = [a for a in get_parent(self, 4).geo_col.container()["airfoils"].keys()] else: current_airfoil_list = self.widget_dict["airfoils"]["widget"].text().split(",") - dialog = AirfoilListDialog(self, current_airfoil_list=current_airfoil_list) - if dialog.exec_(): - airfoils = dialog.getData() - self.widget_dict["airfoils"]["widget"].setText(",".join(airfoils)) - self.airfoilsChanged.emit(",".join(airfoils)) + # dialog = AirfoilListDialog(self, current_airfoil_list=current_airfoil_list) + # if dialog.exec_(): + # airfoils = dialog.getData() + # self.widget_dict["airfoils"]["widget"].setText(",".join(airfoils)) + # self.airfoilsChanged.emit(",".join(airfoils)) def select_directory(self, line_edit: QLineEdit): select_directory(parent=self.parent(), line_edit=line_edit) @@ -2048,7 +2048,8 @@ class PymeadDialog(QDialog): _gripSize = 2 """This subclass of QDialog forces the selection of a WindowTitle and matches the visual format of the GUI""" - def __init__(self, parent, window_title: str, widget: PymeadDialogWidget or PymeadDialogVTabWidget): + def __init__(self, parent, window_title: str, widget: PymeadDialogWidget or PymeadDialogVTabWidget, + theme: dict): super().__init__(parent=parent) self.setWindowTitle(" " + window_title) self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint) @@ -2065,8 +2066,9 @@ def __init__(self, parent, window_title: str, widget: PymeadDialogWidget or Pyme # mandatory for cursor updates self.setMouseTracking(True) - theme = self.parent().themes[self.parent().current_theme] - self.title_bar = DialogTitleBar(self, theme=self.parent().themes[self.parent().current_theme]) + self.theme = theme + + self.title_bar = DialogTitleBar(self, theme=theme) self.sideGrips = [ SideGrip(self, Qt.LeftEdge), @@ -2149,20 +2151,22 @@ def resizeEvent(self, event): class XFOILDialog(PymeadDialog): - def __init__(self, parent: QWidget, current_airfoils: typing.List[str], settings_override: dict = None): + def __init__(self, parent: QWidget, current_airfoils: typing.List[str], theme: dict, + settings_override: dict = None): self.w = XFOILDialogWidget(current_airfoils=current_airfoils) - super().__init__(parent=parent, window_title="Single Airfoil Viscous Analysis", widget=self.w) + super().__init__(parent=parent, window_title="Single Airfoil Viscous Analysis", widget=self.w, + theme=theme) class MultiAirfoilDialog(PymeadDialog): - def __init__(self, parent: QWidget, geo_col: GeometryCollection, settings_override: dict = None): + def __init__(self, parent: QWidget, geo_col: GeometryCollection, theme: dict, settings_override: dict = None): mset_dialog_widget = MSETDialogWidget2(geo_col=geo_col) mses_dialog_widget = MSESDialogWidget2(geo_col=geo_col) mset_dialog_widget.sigMEAChanged.connect(mses_dialog_widget.widget_dict["xtrs"].onMEAChanged) mplot_dialog_widget = MPLOTDialogWidget() tab_widgets = {"MSET": mset_dialog_widget, "MSES": mses_dialog_widget, "MPLOT": mplot_dialog_widget} widget = PymeadDialogVTabWidget(parent=None, widgets=tab_widgets, settings_override=settings_override) - super().__init__(parent=parent, window_title="Multi-Element-Airfoil Analysis", widget=widget) + super().__init__(parent=parent, window_title="Multi-Element-Airfoil Analysis", widget=widget, theme=theme) class SettingsDialog(QDialog): @@ -2188,10 +2192,10 @@ def __init__(self, parent=None): class ScreenshotDialog(PymeadDialog): - def __init__(self, parent: QWidget): + def __init__(self, parent: QWidget, theme: dict): widget = QWidget() - super().__init__(parent=parent, window_title="Screenshot", widget=widget) + super().__init__(parent=parent, window_title="Screenshot", widget=widget, theme=theme) self.grid_widget = {} self.grid_layout = QGridLayout() @@ -2546,7 +2550,7 @@ def __init__(self, parent, widgets: dict, settings_override: dict): class OptimizationSetupDialog(PymeadDialog): - def __init__(self, parent, geo_col: GeometryCollection, settings_override: dict = None): + def __init__(self, parent, geo_col: GeometryCollection, theme: dict, settings_override: dict = None): w0 = GAGeneralSettingsDialogWidget() w3 = XFOILDialogWidget(current_airfoils=[k for k in geo_col.container()["airfoils"]]) w4 = MSETDialogWidget2(geo_col=geo_col) @@ -2562,7 +2566,7 @@ def __init__(self, parent, geo_col: GeometryCollection, settings_override: dict 'Multi-Point Optimization': w7, 'XFOIL': w3, 'MSET': w4, 'MSES': w5, 'MPLOT': w6}, settings_override=settings_override) - super().__init__(parent=parent, window_title='Optimization Setup', widget=w) + super().__init__(parent=parent, window_title='Optimization Setup', widget=w, theme=theme) w.objectives = self.parent().objectives w.constraints = self.parent().constraints @@ -2713,9 +2717,9 @@ def select_directory(self, line_edit: QLineEdit): class ExportIGESDialog(PymeadDialog): - def __init__(self, parent): + def __init__(self, parent, theme: dict): widget = QWidget() - super().__init__(parent=parent, window_title="Export IGES", widget=widget) + super().__init__(parent=parent, window_title="Export IGES", widget=widget, theme=theme) self.grid_widget = {} self.grid_layout = QGridLayout(self) @@ -2775,10 +2779,10 @@ def select_directory(self, line_edit: QLineEdit): class AirfoilMatchingDialog(PymeadDialog): - def __init__(self, parent, airfoil_names: typing.List[str]): + def __init__(self, parent, airfoil_names: typing.List[str], theme: dict): widget = QWidget() - super().__init__(parent, window_title="Choose Airfoil to Match", widget=widget) + super().__init__(parent, window_title="Choose Airfoil to Match", widget=widget, theme=theme) self.airfoil_names = airfoil_names @@ -2803,9 +2807,9 @@ def valuesFromWidgets(self): class AirfoilPlotDialog(PymeadDialog): - def __init__(self, parent): + def __init__(self, parent, theme: dict): widget = QWidget() - super().__init__(parent, window_title="Select Airfoil to Plot", widget=widget) + super().__init__(parent, window_title="Select Airfoil to Plot", widget=widget, theme=theme) self.lay = QFormLayout(self) widget.setLayout(self.lay) @@ -2839,9 +2843,9 @@ def updateDialog(self, new_inputs: dict, w_name: str): class MSESFieldPlotDialog(PymeadDialog): - def __init__(self, parent: QWidget, default_field_dir: str = None): + def __init__(self, parent: QWidget, theme: dict, default_field_dir: str = None): w = MSESFieldPlotDialogWidget(default_field_dir=default_field_dir) - super().__init__(parent=parent, window_title="MSES Field Plot Settings", widget=w) + super().__init__(parent=parent, window_title="MSES Field Plot Settings", widget=w, theme=theme) class PymeadMessageBox(QMessageBox): @@ -2997,12 +3001,12 @@ def valuesFromWidgets(self) -> dict: class PlotExportDialog(PymeadDialog): - def __init__(self, parent, gui_obj): + def __init__(self, parent, gui_obj, theme: dict): widget = PlotExportDialogWidget(gui_obj=gui_obj) - super().__init__(parent, window_title="Plot Export", widget=widget) + super().__init__(parent, window_title="Plot Export", widget=widget, theme=theme) class ExitOptimizationDialog(PymeadDialog): - def __init__(self, parent): + def __init__(self, parent, theme: dict): widget = QLabel("An optimization task is running. Quit?") - super().__init__(parent=parent, window_title="Terminate Optimization?", widget=widget) + super().__init__(parent=parent, window_title="Terminate Optimization?", widget=widget, theme=theme)