Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop app #2

Merged
merged 5 commits into from
Aug 15, 2024
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 desktop_app/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
from PySide6.QtGui import QIcon
from PySide6.QtWidgets import QApplication

from desktop_app.src.config import API_BASE_URL
from public_api.api import APIClient
from public_api.api import UsersAPI
from desktop_app.src.config import API_BASE_URL
from services.authentication import AuthenticationService
from services.offline_manager import OfflineManager
# from services.offline_manager import OfflineManager
from services.update_manager import UpdateManager
from ui.login_dialog import LoginDialog
from ui.main_window import MainWindow
from utils.config_manager import ConfigManager
from utils.logger import setup_logger


# from utils.logger import setup_logger


def load_stylesheet(filename):
Expand Down
7 changes: 4 additions & 3 deletions desktop_app/src/ui/audit_log_view.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from PySide6.QtCore import Qt, QDate
import time

from PySide6.QtCore import QDate
from PySide6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QTableWidget, QTableWidgetItem, QDateEdit, QLabel

from public_api.api import APIClient, AuditAPI
from desktop_app.src.ui.components import StyledButton
import time
from public_api.api import APIClient, AuditAPI


class AuditLogView(QWidget):
Expand Down
22 changes: 15 additions & 7 deletions desktop_app/src/ui/components/custom_widgets.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
from PySide6.QtCore import Qt, QPropertyAnimation, Property, QEasingCurve, Signal
from PySide6.QtGui import QPainter, QColor
from PySide6.QtWidgets import (
QPushButton, QLineEdit, QComboBox, QLabel, QWidget, QVBoxLayout, QHBoxLayout,
QGraphicsOpacityEffect, QFrame
QPushButton, QLineEdit, QComboBox, QLabel, QWidget, QVBoxLayout, QGraphicsOpacityEffect, QFrame
)
from PySide6.QtCore import Qt, QPropertyAnimation, Property, QEasingCurve, Signal, QSize
from PySide6.QtGui import QPainter, QColor, QPen


class StyledButton(QPushButton):
def __init__(self, text, parent=None):
super().__init__(text, parent)
self.setCursor(Qt.PointingHandCursor)
self.setMinimumHeight(40)


class StyledLineEdit(QLineEdit):
def __init__(self, parent=None):
super().__init__(parent)
self.setMinimumHeight(40)


class StyledComboBox(QComboBox):
def __init__(self, parent=None):
super().__init__(parent)
self.setMinimumHeight(40)


class StyledLabel(QLabel):
def __init__(self, text, parent=None):
super().__init__(text, parent)
self.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)


class CollapsibleBox(QWidget):
def __init__(self, title="", parent=None):
super().__init__(parent)
Expand Down Expand Up @@ -60,6 +64,7 @@ def setContentLayout(self, layout):
self.toggle_animation.setStartValue(collapsed_height)
self.toggle_animation.setEndValue(collapsed_height)


class ClickableLabel(QLabel):
clicked = Signal()

Expand All @@ -71,6 +76,7 @@ def mousePressEvent(self, event):
self.clicked.emit()
super().mousePressEvent(event)


class LoadingSpinner(QWidget):
def __init__(self, parent=None, size=40, num_dots=8, dot_size=10):
super().__init__(parent)
Expand All @@ -92,8 +98,8 @@ def paintEvent(self, event):

for i in range(self.num_dots):
x = self.width() / 2 + (self.width() / 2 - self.dot_size) * \
(1 - i / self.num_dots) * 0.7 * \
(1 - (self.counter + i) % self.num_dots / self.num_dots)
(1 - i / self.num_dots) * 0.7 * \
(1 - (self.counter + i) % self.num_dots / self.num_dots)
y = self.height() / 2
painter.setBrush(QColor(100, 100, 100, 255 * (1 - (self.counter + i) % self.num_dots / self.num_dots)))
painter.setPen(Qt.NoPen)
Expand All @@ -114,6 +120,7 @@ def set_rotation(self, value):

rotation = Property(int, get_rotation, set_rotation)


class CardWidget(QFrame):
def __init__(self, title, content, parent=None):
super().__init__(parent)
Expand All @@ -126,6 +133,7 @@ def __init__(self, title, content, parent=None):
layout.addWidget(title_label)
layout.addWidget(content)


class ToggleSwitch(QWidget):
toggled = Signal(bool)

Expand Down Expand Up @@ -169,4 +177,4 @@ def isChecked(self):

def setChecked(self, checked):
self._checked = checked
self.update()
self.update()
7 changes: 4 additions & 3 deletions desktop_app/src/ui/components/dialogs.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import markdown
from PySide6.QtGui import QFont, Qt
from PySide6.QtWidgets import (
QDialog, QVBoxLayout, QLabel, QLineEdit,
QProgressBar, QDialogButtonBox, QFileDialog, QMessageBox, QTextBrowser, QPushButton, QHBoxLayout, QTextEdit
)
from .custom_widgets import StyledButton, StyledLabel
import markdown


class ConfirmDialog(QDialog):
def __init__(self, title, message, parent=None):
Expand Down Expand Up @@ -105,6 +105,7 @@ def init_ui(self, content):
close_button.clicked.connect(self.accept)
layout.addWidget(close_button, alignment=Qt.AlignRight)


class AboutDialog(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
Expand Down Expand Up @@ -134,4 +135,4 @@ def __init__(self, parent=None):
button_layout.addStretch()
button_layout.addWidget(close_button)

layout.addLayout(button_layout)
layout.addLayout(button_layout)
Loading
Loading