From 7a3e98b7695946750dc5ac87d61aadb9f4c07cd6 Mon Sep 17 00:00:00 2001 From: Joey Payne Date: Mon, 29 Sep 2014 21:21:01 +1300 Subject: [PATCH] Added ability to open the export folder. Makes it easier when testing instead of browsing like a sucker. --- files/images/folder_open.png | Bin 0 -> 855 bytes main.py | 15 ++++++++++++++- utils.py | 10 ++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 files/images/folder_open.png diff --git a/files/images/folder_open.png b/files/images/folder_open.png new file mode 100644 index 0000000000000000000000000000000000000000..f25d930272fcf20699240a595c8be22e3a906826 GIT binary patch literal 855 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GXl47#jk7LR|j?!5M~FD~1`V43iTW z{{LtA|CHhX6^5xv4F69uTv^C4C6VF(Iff|-3~zQa9Gk@O|2e~%nGF9=F#JEu@N6@~ z|BDPKr!s77V5kdbm>kb=b{50`yZ-;LTm3)9@c7(>;}e1ETb^uWc)f$+?rR@ zf1LUM|NQ^Qc9UZn{-0*JvC#zRMWC+-C*VHkz8dH<-;yA|U{G983ou;H5^Mk(%$Vfu z?o#iuzwjxL!&%@FSq!8-z}W3%wjD^YtiUlHNQ2V{L(H+Yhk=|0o-U3d5|?w&U*|hy zz~c}&TP(v<~$R0?G&mINRPa2 z_r%2awrAc99;T4U_+{bO`?MNvaL-K3xxJU!-8nwr)cm1UPt&F~93`sv@-_szxrJ1$ z2<1w)@=;o(yun?(*yGNGjXH8|D<=nkEq)`=5ts1(F;8=Q>B~2@h5Ee}_xkGVf3xgh zQ)kN98u^7(8A5T-G@yGywogn@#ip literal 0 HcmV?d00001 diff --git a/main.py b/main.py index 29ec2ef..abc15dd 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,4 @@ -from utils import zip_files, join_files, log, get_temp_dir +from utils import zip_files, join_files, log, get_temp_dir, open_folder_in_explorer import urllib2, re import sys, os, glob, json, re, shutil, stat, tarfile @@ -320,6 +320,9 @@ class MainWindow(QtGui.QWidget): self.get_files_to_download() self.try_to_download_files() + def open_export(self, open_export_button): + open_folder_in_explorer(self.outputDir()) + def delete_files_if_forced(self): forced = self.getSetting('force_download').value @@ -439,10 +442,18 @@ class MainWindow(QtGui.QWidget): cancel_button = QtGui.QPushButton('Cancel Download') cancel_button.setEnabled(False) + open_export_button = QtGui.QPushButton() + open_export_button.setEnabled(False) + open_export_button.setIcon(QtGui.QIcon(os.path.join('files','images','folder_open.png'))) + open_export_button.setToolTip('Open Export Folder') + open_export_button.setMaximumWidth(30) + ex_button.clicked.connect(self.callWithObject('export', ex_button, cancel_button)) cancel_button.clicked.connect(self.cancelDownload) + open_export_button.clicked.connect(self.callWithObject('open_export', open_export_button)) buttonBox = QtGui.QDialogButtonBox() + buttonBox.addButton(open_export_button, QtGui.QDialogButtonBox.NoRole) buttonBox.addButton(cancel_button, QtGui.QDialogButtonBox.RejectRole) buttonBox.addButton(ex_button, QtGui.QDialogButtonBox.AcceptRole) @@ -452,6 +463,7 @@ class MainWindow(QtGui.QWidget): self.progress_label = progress_label self.progress_bar = progress_bar self.cancel_button = cancel_button + self.open_export_button = open_export_button http = QHttp(self) http.requestFinished.connect(self.httpRequestFinished) @@ -754,6 +766,7 @@ class MainWindow(QtGui.QWidget): title_input.setText(proj_name) self.loadPackageJson() + self.open_export_button.setEnabled(True) self.update_json = True def browseOutDir(self): diff --git a/utils.py b/utils.py index ab32ce0..d88319a 100644 --- a/utils.py +++ b/utils.py @@ -1,6 +1,7 @@ from __future__ import print_function import os, zipfile, io, platform import sys, tempfile +import subprocess DEBUG = False @@ -14,6 +15,15 @@ def log(*args): if DEBUG: print(*args) + +def open_folder_in_explorer(path): + if platform.system() == "Windows": + os.startfile(path) + elif platform.system() == "Darwin": + subprocess.Popen(["open", path]) + else: + subprocess.Popen(["xdg-open", path]) + def zip_files(zip_file_name, *args, **kwargs): zip_file = zipfile.ZipFile(zip_file_name, 'w') verbose = kwargs.pop('verbose', False)