export history fixed

This commit is contained in:
ingvar1995 2018-01-30 18:45:55 +03:00
parent f76a1c0fbe
commit b428bd54c4
2 changed files with 12 additions and 9 deletions

View File

@ -660,15 +660,18 @@ class MainWindow(QtWidgets.QMainWindow, Singleton):
def export_history(self, num, as_text=True): def export_history(self, num, as_text=True):
s = self.profile.export_history(num, as_text) s = self.profile.export_history(num, as_text)
directory = QtWidgets.QFileDialog.getExistingDirectory(None, extension = 'txt' if as_text else 'html'
file_name, _ = QtWidgets.QFileDialog.getSaveFileName(None,
QtWidgets.QApplication.translate("MainWindow", QtWidgets.QApplication.translate("MainWindow",
'Choose folder'), 'Choose file name'),
curr_directory(), curr_directory(),
QtWidgets.QFileDialog.ShowDirsOnly | QtWidgets.QFileDialog.DontUseNativeDialog) filter=extension,
options=QtWidgets.QFileDialog.ShowDirsOnly | QtWidgets.QFileDialog.DontUseNativeDialog)
if directory: if file_name:
name = 'exported_history_{}.{}'.format(convert_time(time.time()), 'txt' if as_text else 'html') if not file_name.endswith('.' + extension):
with open(directory + '/' + name, 'wt') as fl: file_name += '.' + extension
with open(file_name, 'wt') as fl:
fl.write(s) fl.write(s)
def set_alias(self, num): def set_alias(self, num):

View File

@ -5,7 +5,7 @@ import sys
import re import re
program_version = '0.4.1' program_version = '0.4.2'
def cached(func): def cached(func):