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
28 changes: 22 additions & 6 deletions automation_file/ui/tabs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
QHBoxLayout,
QLineEdit,
QPushButton,
QTabWidget,
QVBoxLayout,
QWidget,
)
Expand Down Expand Up @@ -92,20 +93,35 @@ class RemoteBackendTab(BaseTab):
"""Shared layout template for cloud/SFTP tabs.

Subclasses supply ``_init_group`` (credentials / session setup) and
``_ops_group`` (file transfer actions). The base class stacks both
inside a ``QVBoxLayout`` with a trailing stretch so the groups pin
to the top of the tab.
``_ops_group`` (file transfer actions). The base class places each
group on its own inner sub-tab ("Credentials" / "Operations") so
the two concerns aren't crammed together on a single vertical page.
"""

def __init__(self, log: LogPanel, pool: QThreadPool) -> None:
super().__init__(log, pool)
root = QVBoxLayout(self)
root.addWidget(self._init_group())
root.addWidget(self._ops_group())
root.addStretch()
root.setContentsMargins(12, 12, 12, 12)
root.setSpacing(12)

inner = QTabWidget()
inner.addTab(self._page(self._init_group()), "Credentials")
inner.addTab(self._page(self._ops_group()), "Operations")
root.addWidget(inner)

def _init_group(self) -> QGroupBox:
raise NotImplementedError

def _ops_group(self) -> QGroupBox:
raise NotImplementedError

@staticmethod
def _page(group: QGroupBox) -> QWidget:
"""Wrap a group box in a padded page so the sub-tab has breathing room."""
page = QWidget()
layout = QVBoxLayout(page)
layout.setContentsMargins(12, 12, 12, 12)
layout.setSpacing(12)
layout.addWidget(group)
layout.addStretch()
return page
12 changes: 2 additions & 10 deletions automation_file/ui/tabs/drive_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,19 @@
QGroupBox,
QLineEdit,
QPushButton,
QVBoxLayout,
)

from automation_file.remote.google_drive.client import driver_instance
from automation_file.remote.google_drive.delete_ops import drive_delete_file
from automation_file.remote.google_drive.download_ops import drive_download_file
from automation_file.remote.google_drive.search_ops import drive_search_all_file
from automation_file.remote.google_drive.upload_ops import drive_upload_to_drive
from automation_file.ui.tabs.base import BaseTab
from automation_file.ui.tabs.base import RemoteBackendTab


class GoogleDriveTab(BaseTab):
class GoogleDriveTab(RemoteBackendTab):
"""Initialise Drive credentials and dispatch a subset of FA_drive_* ops."""

def __init__(self, log, pool) -> None:
super().__init__(log, pool)
root = QVBoxLayout(self)
root.addWidget(self._init_group())
root.addWidget(self._ops_group())
root.addStretch()

def _init_group(self) -> QGroupBox:
box = QGroupBox("Credentials")
form = QFormLayout(box)
Expand Down
3 changes: 3 additions & 0 deletions automation_file/ui/tabs/home_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ def __init__(self, log: LogPanel, pool: QThreadPool) -> None:
self._status_labels: dict[str, QLabel] = {}

root = QVBoxLayout(self)
root.setContentsMargins(12, 12, 12, 12)
root.setSpacing(12)
root.addWidget(self._overview_group())
row = QHBoxLayout()
row.setSpacing(12)
row.addWidget(self._status_group(), 1)
row.addWidget(self._actions_group(), 1)
root.addLayout(row)
Expand Down
4 changes: 4 additions & 0 deletions automation_file/ui/tabs/http_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ class HTTPDownloadTab(BaseTab):
def __init__(self, log, pool) -> None:
super().__init__(log, pool)
root = QVBoxLayout(self)
root.setContentsMargins(12, 12, 12, 12)
root.setSpacing(12)
form = QFormLayout()
form.setVerticalSpacing(10)
form.setHorizontalSpacing(12)
self._url = QLineEdit()
self._url.setPlaceholderText("https://example.com/file.bin")
self._dest = QLineEdit()
Expand Down
2 changes: 2 additions & 0 deletions automation_file/ui/tabs/json_editor_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ def __init__(self, log, pool) -> None:
splitter.setStretchFactor(1, 2)

root = QVBoxLayout(self)
root.setContentsMargins(12, 12, 12, 12)
root.setSpacing(12)
root.addWidget(self._build_toolbar())
root.addWidget(splitter)
root.addWidget(self._build_run_bar())
Expand Down
Loading
Loading