Changeset 9a1f34d in sasview


Ignore:
Timestamp:
Nov 15, 2018 8:07:32 AM (5 years ago)
Author:
wojciech
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:
3b0b17e
Parents:
5f9e874 (diff), 67346f9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'ESS_GUI' of https://github.com/SasView/sasview into ESS_GUI

Files:
5 edited

Legend:

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

    r1942f63 r67346f9  
    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 = GuiUtils.DEFAULT_OPEN_FOLDER 
     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/MainWindow/GuiManager.py

    r1942f63 r67346f9  
    354354        # Exit if yes 
    355355        if reply == QMessageBox.Yes: 
     356            # save the paths etc. 
     357            self.saveCustomConfig() 
    356358            reactor.callFromThread(reactor.stop) 
    357359            return True 
     
    10711073        elif isinstance(perspective, Perspectives.PERSPECTIVES["Corfunc"]): 
    10721074            self.checkAnalysisOption(self._workspace.actionCorfunc) 
     1075 
     1076    def saveCustomConfig(self): 
     1077        """ 
     1078        Save the config file based on current session values 
     1079        """ 
     1080        # Load the current file 
     1081        config_content = GuiUtils.custom_config 
     1082 
     1083        changed = self.customSavePaths(config_content) 
     1084        changed = changed or self.customSaveOpenCL(config_content) 
     1085 
     1086        if changed: 
     1087            self.writeCustomConfig(config_content) 
     1088 
     1089    def customSavePaths(self, config_content): 
     1090        """ 
     1091        Update the config module with current session paths 
     1092        Returns True if update was done, False, otherwise 
     1093        """ 
     1094        changed = False 
     1095        # Find load path 
     1096        open_path = GuiUtils.DEFAULT_OPEN_FOLDER 
     1097        defined_path = self.filesWidget.default_load_location 
     1098        if open_path != defined_path: 
     1099            # Replace the load path 
     1100            config_content.DEFAULT_OPEN_FOLDER = defined_path 
     1101            changed = True 
     1102        return changed 
     1103 
     1104    def customSaveOpenCL(self, config_content): 
     1105        """ 
     1106        Update the config module with current session OpenCL choice 
     1107        Returns True if update was done, False, otherwise 
     1108        """ 
     1109        changed = False 
     1110        # Find load path 
     1111        file_value = GuiUtils.SAS_OPENCL 
     1112        session_value = os.environ.get("SAS_OPENCL", "") 
     1113        if file_value != session_value: 
     1114            # Replace the load path 
     1115            config_content.SAS_OPENCL = session_value 
     1116            changed = True 
     1117        return changed 
     1118 
     1119    def writeCustomConfig(self, config): 
     1120        """ 
     1121        Write custom configuration 
     1122        """ 
     1123        from sas import make_custom_config_path 
     1124        path = make_custom_config_path() 
     1125        # Just clobber the file - we already have its content read in 
     1126        with open(path, 'w') as out_f: 
     1127            out_f.write("#Application appearance custom configuration\n") 
     1128            for key, item in config.__dict__.items(): 
     1129                if key[:2] != "__": 
     1130                    if isinstance(item, str): 
     1131                        item = '"' + item + '"' 
     1132                    out_f.write("%s = %s\n" % (key, str(item))) 
     1133        pass # debugger anchor 
  • src/sas/qtgui/Utilities/GuiUtils.py

    rb9ab979 r67346f9  
    151151    DEFAULT_PERSPECTIVE = custom_config.DEFAULT_PERSPECTIVE 
    152152    CLEANUP_PLOT = custom_config.CLEANUP_PLOT 
     153    SAS_OPENCL = custom_config.SAS_OPENCL 
    153154    # custom open_path 
    154155    open_folder = custom_config.DEFAULT_OPEN_FOLDER 
     
    171172    CLEANUP_PLOT = False 
    172173    DEFAULT_OPEN_FOLDER = PATH_APP 
     174    SAS_OPENCL = config.SAS_OPENCL 
    173175 
    174176#DEFAULT_STYLE = config.DEFAULT_STYLE 
  • 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: 
  • docs/sphinx-docs/build_sphinx.py

    rf1b696d r5f9e874  
    3030SPHINX_BUILD = joinpath(SPHINX_ROOT, "build") 
    3131SPHINX_SOURCE = joinpath(SPHINX_ROOT, "source-temp") 
    32 SPHINX_PERSPECTIVES = joinpath(SPHINX_SOURCE, "user", "qtgui", "perspectives") 
     32SPHINX_PERSPECTIVES = joinpath(SPHINX_SOURCE, "user", "qtgui", "Perspectives") 
    3333 
    3434# sasview paths 
     
    5151SASMODELS_DEV_TARGET = joinpath(SPHINX_SOURCE, "dev", "sasmodels-dev") 
    5252SASMODELS_GUIDE_SOURCE = joinpath(SASMODELS_DOCS, "guide") 
    53 SASMODELS_GUIDE_TARGET = joinpath(SPHINX_PERSPECTIVES, "fitting") 
     53SASMODELS_GUIDE_TARGET = joinpath(SPHINX_PERSPECTIVES, "Fitting") 
    5454SASMODELS_GUIDE_EXCLUDE = [ 
    5555    "index.rst", "install.rst", "intro.rst", 
     
    5959BUMPS_DOCS = joinpath(SASVIEW_ROOT, "..", "bumps", "doc") 
    6060BUMPS_SOURCE = joinpath(BUMPS_DOCS, "guide") 
    61 BUMPS_TARGET = joinpath(SPHINX_PERSPECTIVES, "fitting") 
     61BUMPS_TARGET = joinpath(SPHINX_PERSPECTIVES, "Fitting") 
    6262 
    6363run = imp.load_source('run', joinpath(SASVIEW_ROOT, 'run.py')) 
Note: See TracChangeset for help on using the changeset viewer.