-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes grid preferences in settings window
- Loading branch information
Showing
4 changed files
with
128 additions
and
40 deletions.
There are no files selected for viewing
57 changes: 26 additions & 31 deletions
57
src/airunner/windows/grid_widget.py → ...id_preferences/grid_preferences_widget.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,50 @@ | ||
from airunner.widgets.grid_preferences.templates.grid_preferences_ui import Ui_grid_preferences | ||
from airunner.windows.custom_widget import CustomWidget | ||
|
||
from PyQt6.QtWidgets import QColorDialog | ||
|
||
from airunner.widgets.base_widget import BaseWidget | ||
from airunner.widgets.grid_preferences.templates.grid_preferences_ui import Ui_grid_preferences | ||
|
||
class GridWidget(CustomWidget): | ||
def __init__(self, **kwargs): | ||
super().__init__(**kwargs) | ||
|
||
self.ui = Ui_grid_preferences() | ||
self.ui.setupUi(self) | ||
class GridPreferencesWidget(BaseWidget): | ||
widget_class_ = Ui_grid_preferences | ||
|
||
self.ui.gridLineColorButton.clicked.connect(self.handle_grid_line_color_button) | ||
self.ui.canvas_color.clicked.connect(self.handle_canvas_color_button) | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
|
||
self.ui.grid_size_spinbox.setValue(self.settings_manager.grid_settings.size) | ||
self.ui.grid_size_spinbox.valueChanged.connect(self.handle_grid_size_change) | ||
self.ui.grid_line_width_spinbox.blockSignals(True) | ||
self.ui.grid_size_spinbox.blockSignals(True) | ||
self.ui.show_grid_checkbox.blockSignals(True) | ||
self.ui.snap_to_grid_checkbox.blockSignals(True) | ||
|
||
self.ui.grid_line_width_spinbox.setValue(self.settings_manager.grid_settings.line_width) | ||
self.ui.grid_line_width_spinbox.valueChanged.connect(self.handle_line_width_change) | ||
|
||
self.ui.grid_size_spinbox.setValue(self.settings_manager.grid_settings.size) | ||
self.ui.show_grid_checkbox.setChecked(self.settings_manager.grid_settings.show_grid is True) | ||
self.ui.show_grid_checkbox.stateChanged.connect(self.handle_show_grid_checkbox) | ||
|
||
self.ui.snap_to_grid_checkbox.setChecked(self.settings_manager.grid_settings.snap_to_grid is True) | ||
self.ui.snap_to_grid_checkbox.stateChanged.connect(self.handle_snap_to_grid_checkbox) | ||
|
||
def handle_grid_line_color_button(self): | ||
self.ui.grid_line_width_spinbox.blockSignals(False) | ||
self.ui.grid_size_spinbox.blockSignals(False) | ||
self.ui.show_grid_checkbox.blockSignals(False) | ||
self.ui.snap_to_grid_checkbox.blockSignals(False) | ||
|
||
def action_toggled_snap_to_grid(self, val): | ||
self.settings_manager.set_value("grid_settings.snap_to_grid", val) | ||
|
||
def action_toggled_show_grid(self, val): | ||
self.settings_manager.set_value("grid_settings.show_grid", val) | ||
|
||
def action_button_clicked_grid_line_color(self): | ||
color = QColorDialog.getColor() | ||
if color.isValid(): | ||
self.settings_manager.set_value("grid_settings.line_color", color.name()) | ||
self.app.canvas.update_grid_pen() | ||
|
||
def handle_canvas_color_button(self): | ||
def action_button_clicked_canvas_color(self): | ||
color = QColorDialog.getColor() | ||
if color.isValid(): | ||
self.settings_manager.set_value("grid_settings.canvas_color", color.name()) | ||
self.app.canvas.update_canvas_color(color.name()) | ||
|
||
def handle_grid_size_change(self, val): | ||
def grid_size_changed(self, val): | ||
self.settings_manager.set_value("grid_settings.size", val) | ||
self.app.canvas.update() | ||
|
||
def handle_line_width_change(self, val): | ||
def line_width_changed(self, val): | ||
self.settings_manager.set_value("grid_settings.line_width", val) | ||
self.app.canvas.update() | ||
|
||
def handle_show_grid_checkbox(self, val): | ||
self.settings_manager.set_value("grid_settings.show_grid", val == 2) | ||
self.app.canvas.update() | ||
|
||
def handle_snap_to_grid_checkbox(self, val): | ||
self.settings_manager.set_value("grid_settings.snap_to_grid", val == 2) | ||
self.app.canvas.update() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters