Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions qt/logviewdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ class LogViewDialog(QDialog): # pylint: disable=too-many-instance-attributes
"""A log file viewer dialog"""

def __init__(self,
parent: QWidget,
sid: snapshots.SID = None):
parent: QWidget | qtsystrayicon.QtSysTrayIcon = None,
sid: snapshots.SID = None,
decode: bool = False):
"""
Args:
parent: Parent widget.
sid: Backup ID whose log file shall be shown. If ``None`` the last
log is shown.
"""
super().__init__(parent)
super().__init__(parent if isinstance(parent, QWidget) else None)

self.config = parent.config
# self.snapshots = parent.snapshots
Expand Down Expand Up @@ -101,6 +102,7 @@ def __init__(self,
# decode path
self._checkbox_decode = QCheckBox(_('decode paths'), self)
self._checkbox_decode.stateChanged.connect(self._slot_decode_changed)
self._checkbox_decode.setChecked(decode)
main_layout.addWidget(self._checkbox_decode)

btn_box = QDialogButtonBox(QDialogButtonBox.StandardButton.Close)
Expand Down
36 changes: 24 additions & 12 deletions qt/qtsystrayicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ def __init__(self):
self.btnStop.triggered.connect(self.onBtnStop)
self.contextMenu.addSeparator()

# Dev note (2025-12, buhtz): I wondered why this decode checkbox is
# visible only in ssh_encfs mode but not in local_encfs. Still not
# sure but I think the reason is that in ssh_encfs there is no
# "double-mounting": First SSH and then EncFS. In consequence this
# decode button is a workaround. Explicit decoding in local_encfs
# is not necessary because this happens via encfs-mounting. This
# step is missing when using ssh_encfs.
self.btnDecode = self.contextMenu.addAction(
icon.VIEW_SNAPSHOT_LOG, _('decode paths'))
self.btnDecode.setCheckable(True)
Expand Down Expand Up @@ -171,20 +178,22 @@ def prepareExit(self):
self.qapp.processEvents()

def run(self):
if not self.snapshots.busy():
sys.exit()
if '--keep-alive' not in sys.argv:
if not self.snapshots.busy():
sys.exit()

self.status_icon.show()
self.timer.start(500)
self.qapp.exec()
self.prepareExit()

def updateInfo(self):

# Exit this systray icon "app" when the snapshots is taken
if not self.snapshots.busy():
self.prepareExit()
self.qapp.exit(0)
return
if '--keep-alive' not in sys.argv:
if not self.snapshots.busy():
self.prepareExit()
self.qapp.exit(0)
return

paused = tools.processPaused(self.snapshots.pid())
self.btnPause.setVisible(not paused)
Expand Down Expand Up @@ -255,18 +264,19 @@ def onStartBIT(self):
_proc = subprocess.Popen(cmd)

def onOpenLog(self):
dlg = logviewdialog.LogViewDialog(self, systray = True)
dlg.decode = self.decode
dlg.cbDecode.setChecked(self.btnDecode.isChecked())
dlg = logviewdialog.LogViewDialog(
parent=self,
decode=self.btnDecode.isChecked())
dlg.exec()

def onBtnDecode(self, checked):
if checked:
self.decode = encfstools.Decode(self.config)
self.last_message = None
self.updateInfo()
else:
self.decode = None
return

self.decode = None

def onBtnStop(self):
os.kill(self.snapshots.pid(), signal.SIGKILL)
Expand All @@ -292,6 +302,8 @@ def get_light_icon() -> QIcon:


if __name__ == '__main__':
# Use '--keep-alive' to keep the systray icon alive. This is for debug
# purpose only.

logger.openlog('SYSTRAY')

Expand Down