From b428bd54c4199843b2111164b5f40adfc5ec9bcb Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Tue, 30 Jan 2018 18:45:55 +0300 Subject: [PATCH] export history fixed --- toxygen/mainscreen.py | 19 +++++++++++-------- toxygen/util.py | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/toxygen/mainscreen.py b/toxygen/mainscreen.py index c76f19b..e0616b8 100644 --- a/toxygen/mainscreen.py +++ b/toxygen/mainscreen.py @@ -660,15 +660,18 @@ class MainWindow(QtWidgets.QMainWindow, Singleton): def export_history(self, num, as_text=True): s = self.profile.export_history(num, as_text) - directory = QtWidgets.QFileDialog.getExistingDirectory(None, - QtWidgets.QApplication.translate("MainWindow", - 'Choose folder'), - curr_directory(), - QtWidgets.QFileDialog.ShowDirsOnly | QtWidgets.QFileDialog.DontUseNativeDialog) + extension = 'txt' if as_text else 'html' + file_name, _ = QtWidgets.QFileDialog.getSaveFileName(None, + QtWidgets.QApplication.translate("MainWindow", + 'Choose file name'), + curr_directory(), + filter=extension, + options=QtWidgets.QFileDialog.ShowDirsOnly | QtWidgets.QFileDialog.DontUseNativeDialog) - if directory: - name = 'exported_history_{}.{}'.format(convert_time(time.time()), 'txt' if as_text else 'html') - with open(directory + '/' + name, 'wt') as fl: + if file_name: + if not file_name.endswith('.' + extension): + file_name += '.' + extension + with open(file_name, 'wt') as fl: fl.write(s) def set_alias(self, num): diff --git a/toxygen/util.py b/toxygen/util.py index e8d702a..d862d56 100644 --- a/toxygen/util.py +++ b/toxygen/util.py @@ -5,7 +5,7 @@ import sys import re -program_version = '0.4.1' +program_version = '0.4.2' def cached(func):