You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
4.1 KiB
Python
130 lines
4.1 KiB
Python
from PyQt5.QtWidgets import QMainWindow, QVBoxLayout, QHBoxLayout, QWidget, QPushButton, QLabel
|
|
from PyQt5.QtGui import QColor, QIcon
|
|
from job_list_widget import JobListWidget
|
|
from log_widget import LogWidget
|
|
from info_widget import InfoWidget
|
|
import sys, os
|
|
|
|
class MainWindow(QMainWindow):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.setWindowTitle("Bunny Sync Application")
|
|
self.setGeometry(100, 100, 800, 600)
|
|
image_path = self.resource_path("images/realrabbit.ico")
|
|
self.setWindowIcon(QIcon(image_path))
|
|
self.setup_ui()
|
|
|
|
def resource_path(self, relative_path):
|
|
if hasattr(sys, '_MEIPASS'):
|
|
return os.path.join(sys._MEIPASS, relative_path)
|
|
return os.path.join(os.path.abspath("."), relative_path)
|
|
|
|
def setup_ui(self):
|
|
main_widget = QWidget()
|
|
main_layout = QHBoxLayout()
|
|
main_widget.setLayout(main_layout)
|
|
self.setCentralWidget(main_widget)
|
|
|
|
left_panel = QWidget()
|
|
left_layout = QVBoxLayout()
|
|
left_panel.setLayout(left_layout)
|
|
left_panel.setObjectName('menu')
|
|
left_panel.setFixedWidth(80)
|
|
|
|
self.list_button = QPushButton("List")
|
|
self.log_button = QPushButton("Log")
|
|
self.info_button = QPushButton("Info")
|
|
left_layout.addWidget(self.list_button)
|
|
left_layout.addWidget(self.log_button)
|
|
left_layout.addWidget(self.info_button)
|
|
left_layout.addStretch()
|
|
|
|
self.right_panel = QWidget()
|
|
self.right_layout = QVBoxLayout()
|
|
self.right_panel.setLayout(self.right_layout)
|
|
|
|
main_layout.addWidget(left_panel)
|
|
main_layout.addWidget(self.right_panel)
|
|
|
|
self.job_list_widget = JobListWidget(self)
|
|
self.log_widget = LogWidget(self)
|
|
self.info_widget = InfoWidget(self)
|
|
|
|
self.right_layout.addWidget(self.job_list_widget)
|
|
self.right_layout.addWidget(self.log_widget)
|
|
self.right_layout.addWidget(self.info_widget)
|
|
|
|
self.list_button.clicked.connect(self.show_job_list)
|
|
self.log_button.clicked.connect(self.show_log)
|
|
self.info_button.clicked.connect(self.show_info)
|
|
|
|
self.setStyleSheet("""
|
|
QWidget {
|
|
background-color: #C8F0F0;
|
|
border-radius: 10px;
|
|
padding: 10px;
|
|
}
|
|
QTextEdit {
|
|
background-color: #ffffff;
|
|
color: #333333;
|
|
border-radius: 10px;
|
|
padding: 10px;
|
|
}
|
|
QLineEdit {
|
|
background-color: #56BFF0;
|
|
color: #333333;
|
|
border-radius: 10px;
|
|
padding: 10px;
|
|
}
|
|
QLabel {
|
|
color: #333333;
|
|
font-size: 14px;
|
|
}
|
|
QLabel#jobset {
|
|
font-size: 14px;
|
|
font-weight: bold;
|
|
}
|
|
QLabel#jobitem {
|
|
background-color: #ffffff;
|
|
font-size: 10px;
|
|
font-weight: bold;
|
|
}
|
|
QPushButton {
|
|
background-color: #558DED;
|
|
color: white;
|
|
border: none;
|
|
padding: 5px 10px;
|
|
border-radius: 5px;
|
|
font-size: 14px;
|
|
}
|
|
QPushButton:hover {
|
|
background-color: #55ED86;
|
|
}
|
|
QListWidget {
|
|
background-color: #56BFF0;
|
|
}
|
|
QWidget#menu {
|
|
background-color: #55EDED;
|
|
}
|
|
""")
|
|
|
|
self.show_job_list()
|
|
|
|
def show_job_list(self):
|
|
self.job_list_widget.show()
|
|
self.log_widget.hide()
|
|
self.info_widget.hide()
|
|
|
|
def show_log(self):
|
|
self.job_list_widget.hide()
|
|
self.log_widget.show()
|
|
self.info_widget.hide()
|
|
|
|
def show_info(self):
|
|
self.job_list_widget.hide()
|
|
self.log_widget.hide()
|
|
self.info_widget.show()
|
|
|
|
def add_log(self, message, foreground=QColor("black"), background=QColor("white")):
|
|
self.log_widget.add_log(message, foreground, background)
|