-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassets.py
111 lines (88 loc) · 3.53 KB
/
assets.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
from PyQt5.QtWidgets import *
from PyQt5.QtCore import QFile, QTextStream, QTimer,Qt
from PyQt5.uic import loadUi
import public_functions
class NotiFication(QMainWindow):
def __init__(self,text,duration,main):
super().__init__()
self.main=main
self.duration = duration
self.text = text
self.init_ui()
def init_ui(self):
self.ui = loadUi(".\\UI\\uiFiles\\Notification.ui",self)
self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
self.ui.message.setText(self.text)
self.ui.message.setStyleSheet("""
background-color:rgb(7, 3, 122);
color: white;
""")
public_functions.centering(self.ui)
# Calculate the position of the window
parent_geometry = self.main.geometry()
# Calculate the position of the window
window_width = self.geometry().width()
window_height = self.geometry().height()
x = parent_geometry.right() - window_width
y = parent_geometry.bottom() - window_height
# Set the position of the window
self.move(x, y)
# Start the timer to close the window after the specified duration
self.timer = QTimer()
self.timer.timeout.connect(self.close_window)
self.timer.start(self.duration)
self.show()
def close_window(self):
self.timer.stop()
self.close()
class SongFile(QPushButton):
def __init__(self, i, song):
super().__init__()
self.setFixedHeight(80)
name, artist, duration = song.name, song.artist, song.duration
self.root_file=song
self.setObjectName(name)
self.label0 = QLabel(str(i))
self.label1 = QLabel(name)
self.label2 = QLabel(artist)
self.label3 = QLabel(duration)
self.label0.setObjectName("index")
self.label1.setObjectName("name")
self.label2.setObjectName("artist")
self.label3.setObjectName("duration")
self.label0.setFixedWidth(50)
self.label1.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
self.label2.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
public_functions.centering(self.label0)
spacer2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
filename = "UI/styleSheets/SongFile.qss"
file = QFile(filename)
style = ''
if file.open(QFile.ReadOnly | QFile.Text):
stream = QTextStream(file)
style = stream.readAll()
self.setStyleSheet(style)
layout = QHBoxLayout()
layout.setContentsMargins(30, 10, 30, 10)
layout.setSpacing(10)
vlayout = QVBoxLayout()
vlayout.setSpacing(0)
# Add the labels and spacer to the layout
vlayout.addWidget(self.label1)
vlayout.addWidget(self.label2)
layout.addWidget(self.label0)
layout.addLayout(vlayout)
layout.addItem(spacer2)
layout.addWidget(self.label3)
self.setLayout(layout)
class CustomScrollBar(QScrollBar):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Set the stylesheet to disable the default scrollbar
filename = "UI/styleSheets/CustomScrollBar.qss"
file = QFile(filename)
style = ''
if file.open(QFile.ReadOnly | QFile.Text):
stream = QTextStream(file)
style = stream.readAll()
self.setStyleSheet(style)