def __init__(self): super(FiltersWidget, self).__init__(None, Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint) log_method_name() load_styles(self) # Setup layout self.treeView = QTreeView() layout = QVBoxLayout() layout.addWidget(self.treeView) btn_hide = QPushButton("Close") btn_hide.clicked.connect(self.hide) layout.addWidget(btn_hide) self.setLayout(layout) self.setMinimumSize(WINDOW_WIDTH, WINDOW_HEIGHT) self.model = QStandardItemModel() self.treeView.setModel(self.model) self.treeView.setSelectionMode(QAbstractItemView.SingleSelection) self.treeView.setHeaderHidden(True) # Set delegate to grab mod value before it is changed, need it to modify xml and dictionary values self.treeView.setItemDelegate(ItemDelegate()) self.model.itemChanged.connect(self.process_item_changed) self.xml_path = DEFAULT_FILTER_PATH self.xml_root = None self.load_mods(self.xml_path)
def _prepare_stashes_window(self): self.window_stashes = DragWidget() self.window_stashes.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint) load_styles(self.window_stashes) self.window_stashes.setFixedWidth( 400) # maybe some day I will make it to resize to columns width... self.widget_stashes = QTableWidget(0, 2) self.widget_stashes.itemChanged.connect( self._process_stash_item_changed) self.widget_stashes.setHorizontalHeaderLabels(["Name", "Normal/Quad"]) self.widget_stashes.verticalHeader().hide() header = self.widget_stashes.horizontalHeader() header.setSectionResizeMode(0, QHeaderView.ResizeToContents) header.setSectionResizeMode(1, QHeaderView.ResizeToContents) self.widget_stashes.adjustSize() self.stashes_ui = [] for stash in self.stashes: if stash["name"]: self._add_stash_item_to_table(stash["name"], stash["type"]) self._add_stash_item_to_table(stash_default_text, "normal") load_styles(self.widget_stashes) layout = QVBoxLayout() layout.addWidget(self.widget_stashes) close_button = QPushButton("Close") close_button.clicked.connect(self.window_stashes.hide) layout.addWidget(close_button) self.window_stashes.setLayout(layout)
def __init__(self, screen_geometry: QRect): super(PainterWidget, self).__init__() self.image_path = "img/" self.stash_type = "Quad" self.colors = [] self.stash_cells = stash_cells_root[self.stash_type] self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) self.setAttribute(Qt.WA_NoSystemBackground, True) self.setAttribute(Qt.WA_TranslucentBackground, True) self.screen_geometry = screen_geometry self.layout = QVBoxLayout() self.layout.setContentsMargins(0, 0, 0, 0) self.move(250, 250) self.setFixedWidth(500) self.setFixedHeight(500) self.qp = QPainter() self.config_change_mode = False # True when modifying net size and position self.drag_button = DragButton(self, False) load_styles(self.drag_button) self.drag_button.setFixedWidth(25) self.drag_button.setFixedHeight(25) icon = QIcon() icon.addPixmap(QPixmap(self.image_path + 'move.png')) self.drag_button.setIcon(icon) self.resize_button = ResizeButton(self) load_styles(self.resize_button) self.resize_button.setFixedWidth(25) self.resize_button.setFixedHeight(25) icon.addPixmap(QPixmap(self.image_path + 'resize.png')) self.resize_button.setIcon(icon) layout_buttons = QHBoxLayout() layout_buttons.addWidget(self.drag_button, Qt.AlignTop) layout_buttons.addStretch() layout_buttons.addWidget(self.resize_button, Qt.AlignTop) layout_buttons.setAlignment(Qt.AlignBottom) layout_buttons.setContentsMargins(0, 0, 0, 0) self.layout.addLayout(layout_buttons) self.drag_button.hide() self.resize_button.hide() self.setLayout(self.layout) self.number_of_mods_to_draw = 1 self.items = []
def __init__(self, settings_widget: SettingsWidget): super(FiltersWidget, self).__init__(None, Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint) log_method_name() load_styles(self) self.xml_root = None # Setup layout self.treeView = QTreeView() layout = QVBoxLayout() layout.addWidget(self.treeView) btn_hide = QPushButton("Close") btn_hide.clicked.connect(self.hide) layout.addWidget(btn_hide) self.setLayout(layout) self.setMinimumSize(WINDOW_WIDTH, WINDOW_HEIGHT) self._init_tree() # this isn't requester, but same data works self._reload_settings(settings_widget.get_settings_for_requester()) settings_widget.configuration_changed.connect(self._reload_settings)
def _prepare_stash_switch(self, layout): stash_switch_layout = QHBoxLayout() self.stash_switch_button_left = QPushButton() self.stash_switch_button_right = QPushButton() self.stash_switch_button_left.clicked.connect(self.set_prev_stash) self.stash_switch_button_right.clicked.connect(self.set_next_stash) self.stash_switch_button_left.setFixedWidth(int(self.buttons_size.width()/2)) self.stash_switch_button_left.setFixedHeight(self.buttons_size.height()) self.stash_switch_button_right.setFixedWidth(int(self.buttons_size.width()/2)) self.stash_switch_button_right.setFixedHeight(self.buttons_size.height()) load_styles(self.stash_switch_button_left) load_styles(self.stash_switch_button_right) icon = QIcon() icon.addPixmap(QPixmap(self.image_path + 'next.png')) self.stash_switch_button_right.setIcon(icon) icon.addPixmap(QPixmap(self.image_path + 'next.png').transformed(QTransform().rotate(180))) self.stash_switch_button_left.setIcon(icon) self.stash_switch_button_right.setIconSize(QSize(self.buttons_size.width(), int(self.buttons_size.height()/3))) self.stash_switch_button_left.setIconSize(QSize(self.buttons_size.width(), int(self.buttons_size.height()/3))) stash_switch_layout.addWidget(self.stash_switch_button_left) stash_switch_layout.addWidget(self.stash_switch_button_right) self.stash_name = QLabel("") self.stash_name.setFixedHeight(12) self.stash_name.hide() load_styles(self.stash_name) stash_switch_layout.addWidget(self.stash_name) layout.addLayout(stash_switch_layout)
def __init__(self, screen_geometry: QRect): super(PainterWidget, self).__init__() self.image_path = PROJECT_ROOT + "/img/" self.stash_type = "quad" self.colors = [] self.stash_cells = stash_cells_root[self.stash_type] self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) self.setAttribute(Qt.WA_NoSystemBackground, True) self.setAttribute(Qt.WA_TranslucentBackground, True) self.screen_geometry = screen_geometry self.layout = QVBoxLayout() self.layout.setContentsMargins(0, 0, 0, 0) self.move(250, 250) self.setFixedWidth(500) self.setFixedHeight(500) self.qp = QPainter() # Setup window focus checking thread self.focus_check = FocusCheck(self) self.focus_check_thread = QThread() self.focus_check.moveToThread(self.focus_check_thread) self.focus_check_thread.started.connect(self.focus_check.run) self.focus_check_thread.start() # Setup mouse monitor thread self.mouse_monitor = MouseMonitor(self) self.mouse_monitor_thread = QThread() self.mouse_monitor.moveToThread(self.mouse_monitor_thread) self.mouse_monitor_thread.started.connect(self.mouse_monitor.run) self.mouse_monitor_thread.start() self.config_change_mode = False # True when modifying net size and position self.drag_button = DragButton(self, False) load_styles(self.drag_button) self.drag_button.setFixedWidth(25) self.drag_button.setFixedHeight(25) icon = QIcon() icon.addPixmap(QPixmap(self.image_path + 'move.png')) self.drag_button.setIcon(icon) self.resize_button = ResizeButton(self) load_styles(self.resize_button) self.resize_button.setFixedWidth(25) self.resize_button.setFixedHeight(25) icon.addPixmap(QPixmap(self.image_path + 'resize.png')) self.resize_button.setIcon(icon) layout_buttons = QHBoxLayout() layout_buttons.addWidget(self.drag_button, Qt.AlignTop) layout_buttons.addStretch() layout_buttons.addWidget(self.resize_button, Qt.AlignTop) layout_buttons.setAlignment(Qt.AlignBottom) layout_buttons.setContentsMargins(0, 0, 0, 0) self.layout.addLayout(layout_buttons) self.drag_button.hide() self.resize_button.hide() self.setLayout(self.layout) self.number_of_mods_to_draw = 1 self.items = [] self.chaos_sets = [] self.current_chaos_set = {} self.chaos_item = None self.mode = "chaos_recipe"
def __init__(self, screen_geometry: QRect): super(MainWidget, self).__init__(None) self.image_path = PROJECT_ROOT + "/img/" # initialize_logging() log_method_name() # Setup main widget UI self.screen_geometry = screen_geometry self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | Qt.Tool) self.setAttribute(Qt.WA_NoSystemBackground, True) self.setAttribute(Qt.WA_TranslucentBackground, True) self.buttons_size = QSize(26, 26) self.error_widget = DragWidget() load_styles(self.error_widget) self.error_widget.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) # Initialize other classes, order is important self.painter_widget = PainterWidget(screen_geometry) self.settings_widget = SettingsWidget(self.painter_widget) self.filters_widget = FiltersWidget(self.settings_widget) self.requester = Requester(self.settings_widget, self.painter_widget) self.last_requested_time = 0 self.logListener = LogListener(self.settings_widget) self.filter_manager = FilterManager(self.settings_widget) # Load mod configuration ModsContainer.load_mods_config(self.settings_widget.mod_file) # Setup Requester thread self.objThread_requester = QThread() self.requester.moveToThread(self.objThread_requester) self.requester.finished.connect(self.objThread_requester.quit) self.requester.failed.connect(self._requester_failed) self.objThread_requester.started.connect(self.requester.run) self.objThread_requester.finished.connect(self._requester_finished) # self.requester.start() # Setup log listener and filter manager self.objThread_logListener = QThread() self.logListener.moveToThread(self.objThread_logListener) self.logListener.entered_map.connect(self._request_count_chaos_items) self.requester.finished_counting_chaos.connect(self._request_process_chaos_counters) self.logListener.start() # Setup main widget UI self.screen_geometry = screen_geometry self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint) self.setAttribute(Qt.WA_NoSystemBackground, True) self.setAttribute(Qt.WA_TranslucentBackground, True) self.move(0, self.settings_widget.main_widget_y) layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setAlignment(Qt.AlignTop) layout.setSpacing(0) # Setup buttons self.drag_button = DragButton(self, True) icon = QIcon() icon.addPixmap(QPixmap(self.image_path + 'move.png')) self.drag_button.setIcon(icon) self.mode_switch_button = QPushButton() self.mode_switch_button.clicked.connect(lambda: self.show_hide_widget(self.painter_widget)) font = QFont() font.setBold(True) self.mode_switch_button.setFont(font) if self.settings_widget.mode == "chaos_recipe": self.mode_switch_button.setText("C") else: self.mode_switch_button.setText("R") self.mode_switch_button.clicked.connect(self._switch_mode) self.mode_switch_button.setToolTip("Chaos recipe / Rare scanner") self.run_button = QPushButton() icon.addPixmap(QPixmap(self.image_path + 'run.png')) self.run_button.setIcon(icon) self.run_button.clicked.connect(self._run_requester) self.painter_button = QPushButton() self.painter_button.clicked.connect(lambda: self.show_hide_widget(self.painter_widget)) icon.addPixmap(QPixmap(self.image_path + 'draw1.png')) self.painter_button.setIcon(icon) self.filter_reload_button = QPushButton() icon.addPixmap(QPixmap(self.image_path + 'refresh.png')) self.filter_reload_button.setIcon(icon) self.filter_reload_button.clicked.connect(self._request_count_chaos_items) self.filter_reload_button.setToolTip("Refresh chaos recipe filter") self.filters_button = QPushButton() self.filters_button.clicked.connect(lambda: self.show_hide_widget(self.filters_widget)) icon.addPixmap(QPixmap(self.image_path + 'filter.png')) self.filters_button.setIcon(icon) self.filters_button.setToolTip("Manage rare scanner filters") self.settings_button = QPushButton() self.settings_button.clicked.connect(lambda: self.show_hide_widget(self.settings_widget)) icon.addPixmap(QPixmap(self.image_path + 'settings.png')) self.settings_button.setIcon(icon) self.exit_button = QPushButton() self.exit_button.clicked.connect(QCoreApplication.quit) icon.addPixmap(QPixmap(self.image_path + 'exit.png')) self.exit_button.setIcon(icon) self.buttons = [ self.drag_button, self.mode_switch_button, self.run_button, self.painter_button, self.filter_reload_button, self.filters_button, self.settings_button, self.exit_button ] for button in self.buttons: button.setFixedWidth(self.buttons_size.width()) button.setFixedHeight(self.buttons_size.height()) button.setWindowFlags(Qt.Dialog) load_styles(button) if button is self.mode_switch_button: layout.addWidget(button, 0, Qt.AlignTop) else: layout.addWidget(button, 0, Qt.AlignTop) if button is self.drag_button: self._prepare_stash_switch(layout) widget = QWidget(flags=Qt.Widget) widget.setLayout(layout) self.setCentralWidget(widget)
def _setup_ui(self) -> None: log_method_name() self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) load_styles(self) layout_main = QVBoxLayout() label_id = QLabel("Account name") layout_main.addWidget(label_id) self.edit_account_name = QLineEdit(self.account_name) self.edit_account_name.textChanged.connect(self.save_cfg) layout_main.addWidget(self.edit_account_name) label_stash = QLabel("Stash name") layout_main.addWidget(label_stash) self.edit_stash = QLineEdit(self.stash_name) self.edit_stash.textChanged.connect(self.save_cfg) layout_main.addWidget(self.edit_stash) label_base_league_name = QLabel("League base name") layout_main.addWidget(label_base_league_name) self.edit_base_league_name = QLineEdit(self.league_base_name) self.edit_base_league_name.textChanged.connect(self._update_leagues_combo) self.edit_base_league_name.textChanged.connect(self.save_cfg) layout_main.addWidget(self.edit_base_league_name) label_league = QLabel("League") layout_main.addWidget(label_league) self.combo_league = QComboBox() self._update_leagues_combo() self.combo_league.currentTextChanged.connect(self.save_cfg) layout_main.addWidget(self.combo_league) label_session = QLabel("Session ID") layout_main.addWidget(label_session) self.edit_session = QLineEdit(self.session_id) self.edit_session.textChanged.connect(self.save_cfg) layout_main.addWidget(self.edit_session) label_session = QLabel("Stash type") layout_main.addWidget(label_session) layout_radio = QHBoxLayout() self.radio_stash_normal = QRadioButton("Normal") self.radio_stash_normal.toggled.connect(self.save_cfg) radio_stash_quad = QRadioButton("Quad") radio_stash_quad.toggled.connect(self.save_cfg) if self.stash_type == "Normal": self.radio_stash_normal.setChecked(True) else: radio_stash_quad.setChecked(True) layout_radio.addWidget(self.radio_stash_normal) layout_radio.addWidget(radio_stash_quad) layout_main.addLayout(layout_radio) btn_adjust_net = QPushButton("Adjust net position and size") btn_adjust_net.clicked.connect(self.painter_widget.show_hide_config) layout_main.addWidget(btn_adjust_net) label_session = QLabel("Item tiers to detect") layout_main.addWidget(label_session) layout_slider = QHBoxLayout() self.slider.set_range(1, 5) self.slider.set_value(self.slider_value) load_styles(self.slider) layout_slider.addWidget(self.slider) layout_main.addLayout(layout_slider) self.slider.on_value_changed_call(self.save_cfg) self.btn_hide = QPushButton("Close") self.btn_hide.clicked.connect(self.close) layout_main.addWidget(self.btn_hide) self.setLayout(layout_main)
def _setup_ui(self) -> None: log_method_name() self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) load_styles(self) layout_main = QVBoxLayout() button_stashes = QPushButton("Add/remove stashes") layout_main.addWidget(button_stashes) self._prepare_stashes_window() button_stashes.clicked.connect(self.window_stashes.show) label_mod_config = QLabel("Mod Filter") layout_main.addWidget(label_mod_config) self.combo_mod_file = QComboBox() self._update_mod_file_combo() self.combo_mod_file.activated.connect(self.save_cfg) self.combo_mod_file.installEventFilter(self) layout_main.addWidget(self.combo_mod_file) label_base_league_name = QLabel("League base name") layout_main.addWidget(label_base_league_name) self.edit_base_league_name = QLineEdit(self.league_base_name) self.edit_base_league_name.textChanged.connect( self._update_leagues_combo) self.edit_base_league_name.textChanged.connect(self.save_cfg) layout_main.addWidget(self.edit_base_league_name) label_league = QLabel("League") layout_main.addWidget(label_league) self.combo_league = QComboBox() self._update_leagues_combo() self.combo_league.currentTextChanged.connect(self.save_cfg) layout_main.addWidget(self.combo_league) self.button_show_account_session = QPushButton( "Show/hide account name and session") layout_main.addWidget(self.button_show_account_session) self.label_account_name = QLabel("Account name") layout_main.addWidget(self.label_account_name) self.edit_account_name = QLineEdit(self.account_name) self.edit_account_name.textChanged.connect(self.save_cfg) layout_main.addWidget(self.edit_account_name) self.label_session = QLabel("Session ID") layout_main.addWidget(self.label_session) self.edit_session = QLineEdit(self.session_id) self.edit_session.textChanged.connect(self.save_cfg) layout_main.addWidget(self.edit_session) # Hide account name and session ID if any of them was provided before if self.account_name or self.session_id: self.hide_account_session(True) self.button_show_account_session.clicked.connect( self.hide_account_session) btn_adjust_net = QPushButton("Adjust net position and size") btn_adjust_net.clicked.connect(self.painter_widget.show_hide_config) layout_main.addWidget(btn_adjust_net) label_session = QLabel("Minimum number of item mods to draw a frame") layout_main.addWidget(label_session) layout_slider = QHBoxLayout() self.slider.set_range(1, 5) self.slider.set_value(self.slider_value) load_styles(self.slider) layout_slider.addWidget(self.slider) layout_main.addLayout(layout_slider) self.slider.on_value_changed_call(self.save_cfg) self.radio_allow_identified = QRadioButton() self.radio_allow_identified.setAutoExclusive(False) self.radio_allow_identified.setChecked(self.allow_identified) self.radio_allow_identified.clicked.connect( self.switch_allow_identified) layout_radio = QHBoxLayout() layout_radio.setAlignment(Qt.AlignLeft) layout_radio.addWidget(self.radio_allow_identified) layout_radio.addWidget( QLabel("Allow identified items in chaos recipe")) layout_main.addLayout(layout_radio) self.radio_fill_greedy = QRadioButton() self.radio_fill_greedy.setAutoExclusive(False) self.radio_fill_greedy.setChecked(self.fill_greedy) self.radio_fill_greedy.clicked.connect(self.switch_fill_greedy) layout_radio = QHBoxLayout() layout_radio.setAlignment(Qt.AlignLeft) layout_radio.addWidget(self.radio_fill_greedy) layout_radio.addWidget( QLabel("Fill chaos recipe with more than one ilvl < 75 item")) layout_main.addLayout(layout_radio) self.radio_show_amulets = QRadioButton() self.radio_show_amulets.setAutoExclusive(False) self.radio_show_amulets.setChecked(self.show_amulets) self.radio_show_amulets.clicked.connect(self.switch_show_amulets) layout_radio = QHBoxLayout() layout_radio.setAlignment(Qt.AlignLeft) layout_radio.addWidget(self.radio_show_amulets) layout_radio.addWidget(QLabel("Always show amulets")) layout_main.addLayout(layout_radio) self.radio_show_rings = QRadioButton() self.radio_show_rings.setAutoExclusive(False) self.radio_show_rings.setChecked(self.show_rings) self.radio_show_rings.clicked.connect(self.switch_show_rings) layout_radio = QHBoxLayout() layout_radio.setAlignment(Qt.AlignLeft) layout_radio.addWidget(self.radio_show_rings) layout_radio.addWidget(QLabel("Always show rings")) layout_main.addLayout(layout_radio) self.radio_show_belts = QRadioButton() self.radio_show_belts.setAutoExclusive(False) self.radio_show_belts.setChecked(self.show_belts) self.radio_show_belts.clicked.connect(self.switch_show_belts) layout_radio = QHBoxLayout() layout_radio.setAlignment(Qt.AlignLeft) layout_radio.addWidget(self.radio_show_belts) layout_radio.addWidget(QLabel("Always show belts")) layout_main.addLayout(layout_radio) self.radio_auto_reload = QRadioButton() self.radio_auto_reload.setAutoExclusive(False) self.radio_auto_reload.setChecked(self.auto_reload_filter) self.radio_auto_reload.clicked.connect(self.switch_auto_reload) layout_radio = QHBoxLayout() layout_radio.setAlignment(Qt.AlignLeft) layout_radio.addWidget(self.radio_auto_reload) layout_radio.addWidget( QLabel("Reload filter automatically after entering a map")) layout_main.addLayout(layout_radio) layout_main.addWidget(QLabel("PoE log file location")) self.poe_log_path_button = QPushButton() self.poe_log_path_button.clicked.connect(self.select_poe_log_file) if self.poe_log_path: self.poe_log_path_button.setText( self.path_for_button(self.poe_log_path)) else: self.poe_log_path_button.setText("Set PoE log file location") self.poe_log_path_button.setToolTip("PoE log file location") layout_main.addWidget(self.poe_log_path_button) layout_main.addWidget(QLabel("PoE filter file location")) self.poe_filter_path_button = QPushButton() self.poe_filter_path_button.clicked.connect( self.select_poe_filter_file) if self.poe_filter_path: self.poe_filter_path_button.setText( self.path_for_button(self.poe_filter_path)) else: self.poe_filter_path_button.setText("Set PoE filter file location") self.poe_filter_path_button.setToolTip("PoE filter file location") layout_main.addWidget(self.poe_filter_path_button) layout_main.addWidget( QLabel("Max number of chaos recipe sets in stash")) self.maximum_chaos_sets_text = QLineEdit(str(self.maximum_chaos_sets)) self.maximum_chaos_sets_text.textChanged.connect(self.save_cfg) layout_main.addWidget(self.maximum_chaos_sets_text) self.btn_hide = QPushButton("Close") self.btn_hide.clicked.connect(self.close) layout_main.addWidget(self.btn_hide) self.setLayout(layout_main)