Changeset 859d960 in sasview


Ignore:
Timestamp:
Nov 12, 2018 5:59:11 AM (6 years ago)
Author:
Piotr Rozyczko <piotr.rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
67346f9
Parents:
ebf86f1
git-author:
Piotr Rozyczko <piotr.rozyczko@…> (11/09/18 09:19:25)
git-committer:
Piotr Rozyczko <piotr.rozyczko@…> (11/12/18 05:59:11)
Message:

Directory/file load location is now separate from save report and from
save/load project SASVIEW-1186

Location:
src/sas/qtgui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/MainWindow/DataExplorer.py

    r1942f63 r859d960  
    4949        self.parent = guimanager 
    5050        self.loader = Loader() 
     51 
     52        # Read in default locations 
     53        self.default_save_location = None 
     54        self.default_load_location = os.path.join(os.path.dirname(sys.argv[0]), "test") 
     55        self.default_project_location = None 
     56 
    5157        self.manager = manager if manager is not None else DataManager() 
    5258        self.txt_widget = QtWidgets.QTextEdit(None) 
     
    207213        Opens the Qt "Open Folder..." dialog 
    208214        """ 
    209         folder = QtWidgets.QFileDialog.getExistingDirectory(self, "Choose a directory", "", 
    210               QtWidgets.QFileDialog.ShowDirsOnly | QtWidgets.QFileDialog.DontUseNativeDialog) 
     215        kwargs = { 
     216            'parent'    : self, 
     217            'caption'   : 'Choose a directory', 
     218            'options'   : QtWidgets.QFileDialog.ShowDirsOnly | QtWidgets.QFileDialog.DontUseNativeDialog, 
     219            'directory' : self.default_load_location 
     220        } 
     221        folder = QtWidgets.QFileDialog.getExistingDirectory(**kwargs) 
     222 
    211223        if folder is None: 
    212224            return 
    213225 
    214226        folder = str(folder) 
    215  
    216227        if not os.path.isdir(folder): 
    217228            return 
    218  
     229        self.default_load_location = folder 
    219230        # get content of dir into a list 
    220231        path_str = [os.path.join(os.path.abspath(folder), filename) 
     
    231242            'caption'   : 'Open Project', 
    232243            'filter'    : 'Project (*.json);;All files (*.*)', 
    233             'options'   : QtWidgets.QFileDialog.DontUseNativeDialog 
     244            'options'   : QtWidgets.QFileDialog.DontUseNativeDialog, 
     245            'directory' : self.default_project_location 
    234246        } 
    235247        filename = QtWidgets.QFileDialog.getOpenFileName(**kwargs)[0] 
    236248        if filename: 
     249            self.default_project_location = os.path.dirname(filename) 
    237250            load_thread = threads.deferToThread(self.readProject, filename) 
    238251            load_thread.addCallback(self.readProjectComplete) 
     
    283296            'caption'   : 'Save Project', 
    284297            'filter'    : 'Project (*.json)', 
    285             'options'   : QtWidgets.QFileDialog.DontUseNativeDialog 
     298            'options'   : QtWidgets.QFileDialog.DontUseNativeDialog, 
     299            'directory' : self.default_project_location 
    286300        } 
    287301        name_tuple = QtWidgets.QFileDialog.getSaveFileName(**kwargs) 
    288302        filename = name_tuple[0] 
    289303        if filename: 
     304            self.default_project_location = os.path.dirname(filename) 
    290305            _, extension = os.path.splitext(filename) 
    291306            if not extension: 
     
    818833        # List of known extensions 
    819834        wlist = self.getWlist() 
    820  
    821835        # Location is automatically saved - no need to keep track of the last dir 
    822836        # But only with Qt built-in dialog (non-platform native) 
    823         paths = QtWidgets.QFileDialog.getOpenFileNames(self, "Choose a file", "", 
    824                 wlist, None, QtWidgets.QFileDialog.DontUseNativeDialog)[0] 
     837        kwargs = { 
     838            'parent'    : self, 
     839            'caption'   : 'Choose files', 
     840            'filter'    : wlist, 
     841            'options'   : QtWidgets.QFileDialog.DontUseNativeDialog, 
     842            'directory' : self.default_load_location 
     843        } 
     844        paths = QtWidgets.QFileDialog.getOpenFileNames(**kwargs)[0] 
    825845        if not paths: 
    826846            return 
     
    829849            paths = [paths] 
    830850 
     851        self.default_load_location = os.path.dirname(paths[0]) 
    831852        return paths 
    832853 
  • src/sas/qtgui/Utilities/ReportDialog.py

    rcb90b65 r859d960  
    1010 
    1111import sas.qtgui.Utilities.GuiUtils as GuiUtils 
     12import sas.qtgui.Utilities.ObjectLibrary as ObjectLibrary 
    1213 
    1314from sas.qtgui.Utilities.UI.ReportDialogUI import Ui_ReportDialogUI 
     
    2728 
    2829        self.data_html, self.data_txt, self.data_images = report_list 
     30        #self.save_location = None 
     31        #if 'ReportDialog_directory' in ObjectLibrary.listObjects(): 
     32        self.save_location = ObjectLibrary.getObject('ReportDialog_directory') 
    2933 
    3034        # Fill in the table from input data 
     
    7074        """ 
    7175        # Choose user's home directory 
    72         location = os.path.expanduser('~') 
     76        if self.save_location is None: 
     77            location = os.path.expanduser('~') 
     78        else: 
     79            location = self.save_location 
    7380        # Use a sensible filename default 
    7481        default_name = os.path.join(location, 'fit_report.pdf') 
     
    7885            'caption'  : 'Save Report', 
    7986            # don't use 'directory' in order to remember the previous user choice 
    80             #'directory': default_name, 
     87            'directory': default_name, 
    8188            'filter'   : 'PDF file (*.pdf);;HTML file (*.html);;Text file (*.txt)', 
    8289            'options'  : QtWidgets.QFileDialog.DontUseNativeDialog} 
     
    8794            return 
    8895        extension = filename_tuple[1] 
     96        self.save_location = os.path.dirname(filename) 
     97        # lifetime of this widget is short - keep the reference elsewhere 
     98        ObjectLibrary.addObject('ReportDialog_directory', self.save_location) 
    8999 
    90100        try: 
Note: See TracChangeset for help on using the changeset viewer.