-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Button upgrades, added storage tab (but did not finished), updated re…
…adme
- Loading branch information
Showing
14 changed files
with
207 additions
and
23 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import mega | ||
|
||
class MegaCloud: | ||
def __init__(self): | ||
self.mega = mega.Mega() | ||
self.account = None | ||
|
||
def LoginToAccount(self, email: str, password: str) -> str: | ||
try: | ||
self.account = self.mega.login(email, password) | ||
except Exception as e: | ||
return e | ||
|
||
return "success" | ||
|
||
def GetAccountInfo(self) -> dict(): | ||
quota = self.account.get_quota() | ||
space = self.account.get_storage_space(giga=True) | ||
return {"quota": quota, "space": space} | ||
|
||
def GetFiles(self): | ||
files = self.account.get_files() | ||
return files | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from PySide6.QtWidgets import QWidget, QLabel, QVBoxLayout, QHBoxLayout, QFrame | ||
from PySide6.QtGui import QPixmap | ||
from PySide6.QtCore import Qt | ||
from ui.gui.custom_widgets.dark_style_button import DarkStyleButton | ||
from shared import icon_size, assets_folder_path | ||
|
||
|
||
class AbstractStorageWidget(QWidget): | ||
def __init__(self, icon_path: str, storage_class): | ||
super().__init__() | ||
main_layout = QVBoxLayout() | ||
self.setLayout(main_layout) | ||
self.setFixedHeight(85) | ||
|
||
container_widget = QFrame() | ||
container_widget.setStyleSheet("background-color: #272727; border-radius: 10px;") | ||
basic_info = QHBoxLayout(container_widget) | ||
|
||
cloud_storage_icon = QLabel() | ||
cloud_storage_icon.setPixmap(QPixmap(icon_path).scaled(icon_size)) | ||
cloud_storage_icon.setAlignment(Qt.AlignCenter) | ||
|
||
overview_layout = QVBoxLayout() | ||
self.label_status = QLabel("Nothing to do now") | ||
self.label_status.setAlignment(Qt.AlignRight) | ||
|
||
buttons_layout = QHBoxLayout() # start buttons layout | ||
|
||
button_push = DarkStyleButton("Push") | ||
button_push.setToolTip("Pushes folder to the cloud") | ||
button_push.clicked.connect(self.pushPressed) | ||
|
||
button_pull = DarkStyleButton("Pull") | ||
button_pull.setToolTip("Pulls folder from the cloud") | ||
button_pull.clicked.connect(self.pullPressed) | ||
|
||
buttons_layout.addWidget(button_push) | ||
buttons_layout.addWidget(button_pull) # end buttons layout | ||
|
||
overview_layout.addWidget(self.label_status) | ||
overview_layout.addLayout(buttons_layout) | ||
|
||
self.current_status_icon = QLabel() | ||
self.current_status_icon.setPixmap(QPixmap(assets_folder_path + "information.png").scaled(icon_size)) #! IMPLEMENT | ||
self.current_status_icon.setAlignment(Qt.AlignCenter) | ||
|
||
basic_info.addWidget(cloud_storage_icon) | ||
basic_info.addLayout(overview_layout) | ||
basic_info.addWidget(self.current_status_icon) | ||
|
||
main_layout.addWidget(container_widget) | ||
|
||
self.cloud_storage = storage_class | ||
|
||
def pullPressed(self): | ||
print("Button pull pressed") | ||
|
||
def pushPressed(self): | ||
print("Button push pressed") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from PySide6.QtWidgets import QPushButton | ||
from PySide6.QtGui import QPainter, QColor, QPen | ||
from PySide6.QtCore import Qt | ||
|
||
|
||
class DarkStyleButton(QPushButton): | ||
def __init__(self, text, parent=None): | ||
super().__init__(text, parent) | ||
self.setStyleSheet("border: none; padding: 5px;") | ||
# Background color of button | ||
self.active_button_color = QColor("#303030") | ||
self.disabled_button_color = QColor("#464646") | ||
self.hovered_button_color = QColor("#000") | ||
self.clicked_button_color = QColor("#464646") | ||
# Flags | ||
self.isButtonClicked = False | ||
|
||
def redrawBackgroundColor(self, painter, bg_color): | ||
# Draw the rounded background | ||
rounded_rect = self.rect().adjusted(1, 1, -1, -1) | ||
painter.setBrush(bg_color) | ||
painter.setPen(QPen(QColor("#FFF"), 1)) | ||
painter.drawRoundedRect(rounded_rect, 10, 10) | ||
|
||
def redrawText(self, painter, align=Qt.AlignCenter, text="None"): | ||
# Draw the text | ||
painter.setPen(QColor("#FFF")) | ||
painter.drawText(self.rect(), align, text) | ||
|
||
def paintEvent(self, event): | ||
painter = QPainter(self) | ||
painter.setRenderHint(QPainter.Antialiasing) | ||
painter.setRenderHint(QPainter.TextAntialiasing) | ||
|
||
# Determine the background color based on the hover state | ||
if self.isButtonClicked: | ||
bg_color = self.disabled_button_color | ||
elif self.underMouse() and self.isEnabled(): | ||
bg_color = self.hovered_button_color | ||
elif not self.isEnabled(): | ||
bg_color = self.disabled_button_color | ||
else: | ||
bg_color = self.active_button_color | ||
|
||
# Draw the rounded background | ||
self.redrawBackgroundColor(painter, bg_color) | ||
# Draw the text | ||
self.redrawText(painter, Qt.AlignCenter, self.text()) | ||
|
||
def mousePressEvent(self, event): | ||
if event.button() == Qt.LeftButton: | ||
self.isButtonClicked = True | ||
self.repaint() | ||
super().mousePressEvent(event) | ||
|
||
def mouseReleaseEvent(self, event): | ||
if event.button() == Qt.LeftButton: | ||
self.isButtonClicked = False | ||
self.repaint() | ||
super().mouseReleaseEvent(event) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from ui.gui.tabs.abstract_tab import AbstractTabWidget | ||
from ui.gui.custom_widgets.abstract_storage_cloud import AbstractStorageWidget | ||
from PySide6.QtWidgets import QVBoxLayout, QLabel, QScrollArea, QWidget, QSpacerItem, QSizePolicy | ||
from PySide6.QtCore import Qt | ||
from shared import assets_folder_path | ||
from CloudStorages.mega import MegaCloud | ||
|
||
|
||
class StorageTab(AbstractTabWidget): | ||
def __init__(self, ParentClass, tab_name): | ||
super().__init__(ParentClass, tab_name) | ||
main_layout = QVBoxLayout() | ||
self.setLayout(main_layout) | ||
|
||
scroll_area = QScrollArea() | ||
main_layout.addWidget(scroll_area) | ||
scroll_area.setWidgetResizable(True) | ||
|
||
content_widget = QWidget() | ||
scroll_area.setWidget(content_widget) | ||
|
||
self.content_layout = QVBoxLayout(content_widget) | ||
|
||
self.status_label = QLabel() | ||
self.status_label.setText("Nothing to do now") | ||
self.status_label.setAlignment(Qt.AlignCenter) | ||
self.status_label.setStyleSheet("font-size: 16px; font-weight: bold") | ||
|
||
self.content_layout.addWidget(self.status_label) | ||
self.content_layout.addWidget(AbstractStorageWidget(assets_folder_path + "mega-icon-logo.png", MegaCloud())) | ||
verticalSpacer = QSpacerItem(1, self.height(), QSizePolicy.Minimum, QSizePolicy.Expanding) | ||
self.content_layout.addSpacerItem(verticalSpacer) | ||
|
||
def UserSelectedTab(self) -> None: | ||
pass |