qmm.manager module

Handles the Qt main window.

class qmm.manager.ArchiveAddedEventHandler(moved_cb, created_cb, deleted_cb, modified_cb)[source]

Bases: qmm.manager.QmmWdEventHandler, watchdog.events.PatternMatchingEventHandler, QObject

on_created(event)[source]

Called when a file or directory is created.

Parameters

event (DirCreatedEvent or FileCreatedEvent) – Event representing file/directory creation.

on_deleted(event)[source]

Called when a file or directory is deleted.

Parameters

event (DirDeletedEvent or FileDeletedEvent) – Event representing file/directory deletion.

on_modified(event)[source]

Called when a file or directory is modified.

Parameters

event (DirModifiedEvent or FileModifiedEvent) – Event representing file/directory modification.

on_moved(event)[source]

Called when a file or a directory is moved or renamed.

Parameters

event (DirMovedEvent or FileMovedEvent) – Event representing file/directory movement.

class qmm.manager.GameModEventHandler(moved_cb, created_cb, deleted_cb, modified_cb)[source]

Bases: qmm.manager.QmmWdEventHandler, watchdog.events.PatternMatchingEventHandler, QObject

on_created(event)[source]

Called when a file or directory is created.

Parameters

event (DirCreatedEvent or FileCreatedEvent) – Event representing file/directory creation.

on_deleted(event)[source]

Called when a file or directory is deleted.

Parameters

event (DirDeletedEvent or FileDeletedEvent) – Event representing file/directory deletion.

on_modified(event)[source]

Called when a file or directory is modified.

Parameters

event (DirModifiedEvent or FileModifiedEvent) – Event representing file/directory modification.

on_moved(event)[source]

Called when a file or a directory is moved or renamed.

Parameters

event (DirMovedEvent or FileMovedEvent) – Event representing file/directory movement.

class qmm.manager.MainWindow[source]

Bases: QMainWindow, qmm.manager.QEventFilter, qmm.ui_mainwindow.Ui_MainWindow

add_callbacks_post_show(items)[source]
closeEvent(self, QCloseEvent)[source]
do_about()[source]

Show the about window.

do_settings()[source]

Show the settings window.

MainWindow.fswatch_clear(QString,QString)
MainWindow.fswatch_ignore(QString,QString)
get_row_index_by_name(name)[source]

Return row if name is found in the list.

Parameters

name (str) – Filename of the archive to find, matches content of the ListRowItem text method.

Returns

index of item found, None if name matches nothing.

Return type

int or None

property is_mod_repo_dirty
on_selection_change() None[source]

Change the tab color to match the selected element in linked list.

on_window_activate()[source]
on_window_deactivate()[source]
post_show_setup()[source]

Actions to be triggered only after mainwindow show method is triggered

refresh_list_item_state()[source]

Refresh the listwidget whenever an item is added or removed.

set_tab_color(index, color: Optional[QColor] = None) None[source]

Manage tab text color.

Helper to MainWindow._on_selection_change.

Store the default text color of a tab in order to restore it whenever the selected element in the linked list changes.

Parameters
  • index (int) – index of the tab

  • color (QColor) – new color of the text

setup_schedulers()[source]
class qmm.manager.QAppEventFilter[source]

Bases: QObject

Detect if the application is active then triggers to appropriate events.

The purpose of this object is to enable or disable WatchDog related procedures. We want to disable file system watch on the modules directory when the window is inactive (user has alt-tabbed outside of it or minimized the application), as such delay any activity until the user comes back to the application itself. The intent is to minimize uneeded operations as the user could move and rename multiple files in the folder. We only need to scan the module’s repository once the user has finished, thus once the application becomes active.

The detection of activity needs to be done at the Session Manager, namely QApplication (QGuiApplication or QCoreApplication). That object handles every window and widgets of the application. Each of those window and widgets could become inactive regardless of the status of the whole application. Inactivity could be defined as whenever the application loose focus (keyboard input). This loss also happen whenever the window is being dragged around by the user, which means we need to make sure to not trigger any refresh of the database for those user cases. To achieve that we track the geometry and coordinates of the window and trigger the callback only if those parameters remains the same between an inactive and active event.

Callbacks are on_window_activate and on_window_deactivate.

eventFilter(self, QObject, QEvent) bool[source]
get_coords() Tuple[int, int][source]

Return the coordinates of the top window.

get_geometry() Tuple[int, int][source]

Return the geometry of the top window.

set_coords()[source]
set_geometry()[source]
set_top_window(window: qmm.manager.MainWindow)[source]

Define the widget that is considered as top window.

class qmm.manager.QEventFilter[source]

Bases: object

eventFilter(o, e)[source]
setup_filters(objects)[source]
class qmm.manager.QmmWdEventHandler(moved_cb, created_cb, deleted_cb, modified_cb)[source]

Bases: object

clear(src_path, event_type)[source]

Remove a path from the event’s ignore tuple.

ignore(src_path, event_type)[source]

Ignore an event if path is found in it’s ignore tuple.

sgn_created(PyQt_PyObject)
sgn_deleted(PyQt_PyObject)
sgn_modified(PyQt_PyObject)
sgn_moved(PyQt_PyObject)
exception qmm.manager.UnknownContext[source]

Bases: Exception

class qmm.manager.WatchDogSchedules(value)[source]

Bases: enum.Enum

An enumeration.

ARCHIVES = 'archives'
MODULES = 'modules'
qmm.manager.main()[source]

Start the application proper.