Skip to content

Commit

Permalink
Screenshot hotkey & Allow specifying screenshot folder
Browse files Browse the repository at this point in the history
Closes #223
  • Loading branch information
Avasam committed Jun 23, 2023
1 parent 7c9e1a5 commit 30259fc
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 67 deletions.
7 changes: 4 additions & 3 deletions res/about.ui
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author>Toufool</author>
<class>AboutAutoSplitWidget</class>
<widget class="QWidget" name="AboutAutoSplitWidget">
<property name="geometry">
Expand Down Expand Up @@ -126,12 +127,12 @@ Thank you!</string>
<bool>true</bool>
</property>
</widget>
<zorder>ok_button</zorder>
<zorder>donate_text_label</zorder>
<zorder>donate_button_label</zorder>
<zorder>icon_label</zorder>
<zorder>donate_text_label</zorder>
<zorder>version_label</zorder>
<zorder>created_by_label</zorder>
<zorder>ok_button</zorder>
<zorder>donate_button_label</zorder>
</widget>
<resources>
<include location="resources.qrc"/>
Expand Down
39 changes: 2 additions & 37 deletions res/design.ui
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author>Toufool</author>
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
Expand Down Expand Up @@ -473,7 +474,7 @@
<string>Select Window</string>
</property>
</widget>
<widget class="QPushButton" name="browse_button">
<widget class="QPushButton" name="split_image_folder_button">
<property name="geometry">
<rect>
<x>696</x>
Expand Down Expand Up @@ -894,42 +895,6 @@
<string>&gt;</string>
</property>
</widget>
<zorder>x_label</zorder>
<zorder>select_region_button</zorder>
<zorder>start_auto_splitter_button</zorder>
<zorder>reset_button</zorder>
<zorder>undo_split_button</zorder>
<zorder>skip_split_button</zorder>
<zorder>check_fps_button</zorder>
<zorder>fps_label</zorder>
<zorder>current_image_label</zorder>
<zorder>live_image</zorder>
<zorder>current_split_image</zorder>
<zorder>width_label</zorder>
<zorder>height_label</zorder>
<zorder>fps_value_label</zorder>
<zorder>width_spinbox</zorder>
<zorder>height_spinbox</zorder>
<zorder>capture_region_label</zorder>
<zorder>current_image_file_label</zorder>
<zorder>take_screenshot_button</zorder>
<zorder>x_spinbox</zorder>
<zorder>y_spinbox</zorder>
<zorder>y_label</zorder>
<zorder>align_region_button</zorder>
<zorder>select_window_button</zorder>
<zorder>browse_button</zorder>
<zorder>split_image_folder_label</zorder>
<zorder>split_image_folder_input</zorder>
<zorder>capture_region_window_label</zorder>
<zorder>image_loop_label</zorder>
<zorder>similarity_viewer_groupbox</zorder>
<zorder>reload_start_image_button</zorder>
<zorder>start_image_status_label</zorder>
<zorder>start_image_status_value_label</zorder>
<zorder>image_loop_value_label</zorder>
<zorder>previous_image_button</zorder>
<zorder>next_image_button</zorder>
</widget>
<widget class="QMenuBar" name="menu_bar">
<property name="geometry">
Expand Down
125 changes: 108 additions & 17 deletions res/settings.ui
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author>Toufool</author>
<class>SettingsWidget</class>
<widget class="QWidget" name="SettingsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>290</width>
<height>664</height>
<height>746</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>290</width>
<height>664</height>
<height>746</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>290</width>
<height>664</height>
<height>746</height>
</size>
</property>
<property name="font">
Expand All @@ -38,9 +39,9 @@
<property name="geometry">
<rect>
<x>10</x>
<y>200</y>
<y>230</y>
<width>270</width>
<height>181</height>
<height>231</height>
</rect>
</property>
<property name="title">
Expand Down Expand Up @@ -108,7 +109,7 @@
<rect>
<x>6</x>
<y>97</y>
<width>251</width>
<width>255</width>
<height>22</height>
</rect>
</property>
Expand Down Expand Up @@ -147,20 +148,62 @@
<rect>
<x>6</x>
<y>148</y>
<width>251</width>
<width>255</width>
<height>22</height>
</rect>
</property>
<property name="placeholderText">
<string>Scanning for existing devices...</string>
</property>
</widget>
<widget class="QLabel" name="screenshot_directory_label">
<property name="geometry">
<rect>
<x>6</x>
<y>182</y>
<width>151</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Screenshots folder:</string>
</property>
</widget>
<widget class="QLineEdit" name="screenshot_directory_input">
<property name="geometry">
<rect>
<x>6</x>
<y>204</y>
<width>255</width>
<height>22</height>
</rect>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="screenshot_directory_browse_button">
<property name="geometry">
<rect>
<x>190</x>
<y>178</y>
<width>71</width>
<height>24</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Browse...</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="image_settings_groupbox">
<property name="geometry">
<rect>
<x>10</x>
<y>390</y>
<y>470</y>
<width>270</width>
<height>266</height>
</rect>
Expand All @@ -177,7 +220,7 @@
<property name="checkable">
<bool>false</bool>
</property>
<widget class="QComboBox" name="default_comparison_method">
<widget class="QComboBox" name="default_comparison_method_combobox">
<property name="geometry">
<rect>
<x>170</x>
Expand Down Expand Up @@ -221,7 +264,7 @@ It is highly recommended to NOT use pHash if you use masked images, or it'll be
</property>
</item>
</widget>
<widget class="QLabel" name="default_comparison_method_label">
<widget class="QLabel" name="default_comparison_method_combobox_label">
<property name="geometry">
<rect>
<x>6</x>
Expand Down Expand Up @@ -438,7 +481,7 @@ It is highly recommended to NOT use pHash if you use masked images, or it'll be
<x>10</x>
<y>10</y>
<width>270</width>
<height>191</height>
<height>211</height>
</rect>
</property>
<property name="title">
Expand Down Expand Up @@ -551,7 +594,7 @@ It is highly recommended to NOT use pHash if you use masked images, or it'll be
<rect>
<x>6</x>
<y>54</y>
<width>41</width>
<width>71</width>
<height>16</height>
</rect>
</property>
Expand Down Expand Up @@ -596,7 +639,7 @@ It is highly recommended to NOT use pHash if you use masked images, or it'll be
<rect>
<x>6</x>
<y>132</y>
<width>41</width>
<width>71</width>
<height>16</height>
</rect>
</property>
Expand Down Expand Up @@ -654,7 +697,7 @@ It is highly recommended to NOT use pHash if you use masked images, or it'll be
<rect>
<x>6</x>
<y>106</y>
<width>61</width>
<width>71</width>
<height>16</height>
</rect>
</property>
Expand Down Expand Up @@ -682,7 +725,7 @@ It is highly recommended to NOT use pHash if you use masked images, or it'll be
<property name="geometry">
<rect>
<x>180</x>
<y>154</y>
<y>180</y>
<width>81</width>
<height>24</height>
</rect>
Expand All @@ -698,7 +741,7 @@ It is highly recommended to NOT use pHash if you use masked images, or it'll be
<property name="geometry">
<rect>
<x>6</x>
<y>151</y>
<y>177</y>
<width>71</width>
<height>32</height>
</rect>
Expand All @@ -709,6 +752,51 @@ reset image</string>
</property>
</widget>
<widget class="QLineEdit" name="toggle_auto_reset_image_input">
<property name="geometry">
<rect>
<x>80</x>
<y>181</y>
<width>94</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="screenshot_label">
<property name="geometry">
<rect>
<x>6</x>
<y>158</y>
<width>71</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Screenshot:</string>
</property>
</widget>
<widget class="QPushButton" name="set_screenshot_hotkey_button">
<property name="geometry">
<rect>
<x>180</x>
<y>154</y>
<width>81</width>
<height>24</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Set Hotkey</string>
</property>
</widget>
<widget class="QLineEdit" name="screenshot_input">
<property name="geometry">
<rect>
<x>80</x>
Expand All @@ -732,11 +820,14 @@ reset image</string>
<tabstop>set_undo_split_hotkey_button</tabstop>
<tabstop>set_skip_split_hotkey_button</tabstop>
<tabstop>set_pause_hotkey_button</tabstop>
<tabstop>set_screenshot_hotkey_button</tabstop>
<tabstop>set_toggle_auto_reset_image_hotkey_button</tabstop>
<tabstop>fps_limit_spinbox</tabstop>
<tabstop>live_capture_region_checkbox</tabstop>
<tabstop>capture_method_combobox</tabstop>
<tabstop>capture_device_combobox</tabstop>
<tabstop>default_comparison_method</tabstop>
<tabstop>screenshot_directory_browse_button</tabstop>
<tabstop>default_comparison_method_combobox</tabstop>
<tabstop>default_similarity_threshold_spinbox</tabstop>
<tabstop>default_delay_time_spinbox</tabstop>
<tabstop>default_pause_time_spinbox</tabstop>
Expand Down
1 change: 1 addition & 0 deletions res/update_checker.ui
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author>Toufool</author>
<class>UpdateChecker</class>
<widget class="QDialog" name="UpdateChecker">
<property name="enabled">
Expand Down
10 changes: 6 additions & 4 deletions src/AutoSplit.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class AutoSplit(QMainWindow, design.Ui_MainWindow):
skip_split_signal = QtCore.Signal()
undo_split_signal = QtCore.Signal()
pause_signal = QtCore.Signal()
screenshot_signal = QtCore.Signal()
after_setting_hotkey_signal = QtCore.Signal()
update_checker_widget_signal = QtCore.Signal(str, bool)
load_start_image_signal = QtCore.Signal(bool, bool)
Expand Down Expand Up @@ -163,7 +164,7 @@ def _show_error_signal_slot(error_message_box: Callable[..., object]):
self.action_load_profile.triggered.connect(lambda: user_profile.load_settings(self))

# Connecting button clicks to functions
self.browse_button.clicked.connect(self.__browse)
self.split_image_folder_button.clicked.connect(self.__browse)
self.select_region_button.clicked.connect(lambda: select_region(self))
self.take_screenshot_button.clicked.connect(self.__take_screenshot)
self.start_auto_splitter_button.clicked.connect(self.__auto_splitter)
Expand Down Expand Up @@ -199,6 +200,7 @@ def _update_checker_widget_signal_slot(latest_version: str, check_on_open: bool)
self.skip_split_signal.connect(self.skip_split)
self.undo_split_signal.connect(self.undo_split)
self.pause_signal.connect(self.pause)
self.screenshot_signal.connect(self.__take_screenshot)

# live image checkbox
self.timer_live_image.timeout.connect(lambda: self.__update_live_image_details(None, True))
Expand Down Expand Up @@ -374,7 +376,7 @@ def __take_screenshot(self):
screenshot_index = 1
while True:
screenshot_path = os.path.join(
self.settings_dict["split_image_directory"],
self.settings_dict["screenshot_directory"] or self.settings_dict["split_image_directory"],
f"{screenshot_index:03}_SplitImage.png",
)
if not os.path.exists(screenshot_path):
Expand Down Expand Up @@ -720,7 +722,7 @@ def __pause_loop(self, stop_time: float, message: str):
def gui_changes_on_start(self):
self.timer_start_image.stop()
self.start_auto_splitter_button.setText("Running...")
self.browse_button.setEnabled(False)
self.split_image_folder_button.setEnabled(False)
self.reload_start_image_button.setEnabled(False)
self.previous_image_button.setEnabled(True)
self.next_image_button.setEnabled(True)
Expand Down Expand Up @@ -750,7 +752,7 @@ def gui_changes_on_reset(self, safe_to_reload_start_image: bool = False):
self.table_reset_image_live_label.setText("-")
self.table_reset_image_highest_label.setText("-")
self.table_reset_image_threshold_label.setText("-")
self.browse_button.setEnabled(True)
self.split_image_folder_button.setEnabled(True)
self.reload_start_image_button.setEnabled(True)
self.previous_image_button.setEnabled(False)
self.next_image_button.setEnabled(False)
Expand Down
Loading

0 comments on commit 30259fc

Please sign in to comment.