12
12
from PyQt6 .QtCore import Qt
13
13
from PyQt6 .QtGui import QIcon
14
14
from fileRenamer import FileRenamer
15
- from os import path
15
+ from os import path , startfile
16
16
17
17
# classes
18
18
class popup (QWidget ):
19
- def __init__ (self , popupText : str ) -> None :
19
+ def __init__ (self , popupText : str , path : str = ... ) -> None :
20
20
# default
21
21
super ().__init__ ()
22
- self .resize (160 , 80 ) ; self .setFixedSize (self .size ())
22
+ self .resize (200 , 80 ) ; self .setFixedSize (self .size ())
23
+ self .path = path
23
24
24
- # main layout
25
+ # layouts
25
26
self .mainLayout : QVBoxLayout = QVBoxLayout () ; self .setLayout (self .mainLayout )
27
+ self .buttonsLayout : QHBoxLayout = QHBoxLayout ()
26
28
27
29
# widgets
28
30
# --- warning message ---
@@ -39,15 +41,25 @@ def __init__(self, popupText: str) -> None:
39
41
self .mainLayout .addWidget (self .pText )
40
42
41
43
# --- close button ---
44
+ if (popupText == "done" ):
45
+ self .openFolderButton : QPushButton = QPushButton ("Open Folder" )
46
+ self .buttonsLayout .addWidget (self .openFolderButton )
47
+ # signal
48
+ self .openFolderButton .clicked .connect (self .openFolderCallback )
49
+
42
50
self .closeButton : QPushButton = QPushButton ("Close" )
43
- self .mainLayout .addWidget (self .closeButton )
51
+ self .buttonsLayout .addWidget (self .closeButton )
52
+
53
+ self .mainLayout .addLayout (self .buttonsLayout )
44
54
45
55
# signal
46
56
self .closeButton .clicked .connect (self .closeCallback )
47
57
48
- # callback
58
+ # callbacks
49
59
def closeCallback (self ):
50
60
self .close ()
61
+ def openFolderCallback (self ):
62
+ startfile (self .path )
51
63
52
64
class renameView (QWidget ):
53
65
def __init__ (self ) -> None :
@@ -128,7 +140,7 @@ def rename(self) -> None:
128
140
129
141
if (selectedFolderCheck and startFileCheck and startNumberCheck and renameFormatCheck and fileExtCheck ):
130
142
self .fr .rename (folder , fileExt , startFile , int (startNb ), renameFrmt )
131
- self .popUp : popup = popup ("done" ) ; self .popUp .show ()
143
+ self .popUp : popup = popup ("done" , folder ) ; self .popUp .show ()
132
144
else :
133
145
self .popUp : popup = popup ("warning" ) ; self .popUp .show ()
134
146
0 commit comments