Skip to content

Commit 4fa4b97

Browse files
committed
impl: The export dialog will ask for file path of unnamed files
1 parent 32ca348 commit 4fa4b97

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

main.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,10 @@ def currentMax(self, value: int) -> None:
10041004

10051005
@property
10061006
def totalMax(self) -> int:
1007-
return self.builder.get_object('totalProgressBar')['maximum']
1007+
try:
1008+
return self.builder.get_object('totalProgressBar')['maximum']
1009+
except Exception:
1010+
return -1
10081011

10091012
@totalMax.setter
10101013
def totalMax(self, value: int) -> None:
@@ -1108,10 +1111,20 @@ async def work(dialog: ProgressDialog):
11081111
dialog.totalText.set(f"Exporting {i+1} / {len(indexes)} files")
11091112
dialog.currentProgress.set(0)
11101113
origPath = filePaths[i]
1114+
if not origPath:
1115+
origPath = asksaveasfilename(
1116+
filetypes=((self.fileExt+' files', self.fileExt),),
1117+
initialfile=path.basename(songsData[i].header.import_name).rsplit('.', 1)[0],
1118+
defaultextension=self.fileExt)
1119+
if not origPath:
1120+
if self.d.toplevel:
1121+
self.d.toplevel.after(1, self.d.destroy) # type: ignore
1122+
return
11111123
baseName = path.basename(origPath)
11121124
if baseName.endswith('.nbs'):
11131125
baseName = baseName[:-4]
1114-
baseName += self.fileExt
1126+
if not baseName.endswith(self.fileExt):
1127+
baseName += self.fileExt
11151128

11161129
filePath = ''
11171130
if not self.isFolderMode:
@@ -1121,8 +1134,9 @@ async def work(dialog: ProgressDialog):
11211134
try:
11221135
dialog.currentText.set(f"Current file: {filePath}")
11231136
# Prevent data from unintended changes
1124-
songData = deepcopy(songsData[i])
1137+
songData: NbsSong = deepcopy(songsData[i])
11251138
compactNotes(songData, True)
1139+
songData.correctData()
11261140
dialog.currentProgress.set(10) # 10%
11271141
await func(songData, filePath, dialog)
11281142
except CancelledError:

0 commit comments

Comments
 (0)