def set_max_results(self, value=None): """ Set maximum amount of results to add to the result browser. Parameters ---------- value: int, optional Number of results. If None an input dialog will be used. Default is None. """ if value is None: # Create dialog dialog = QInputDialog(self) # Set dialog properties dialog.setModal(False) dialog.setWindowTitle(self.get_name()) dialog.setLabelText(_('Set maximum number of results: ')) dialog.setInputMode(QInputDialog.IntInput) dialog.setIntRange(1, 10000) dialog.setIntStep(1) dialog.setIntValue(self.get_option('max_results')) # Connect slot dialog.intValueSelected.connect( lambda value: self.set_option('max_results', value)) dialog.show() else: self.set_option('max_results', value)
def change_history_depth(self, value=None): """ Set history maximum entries. Parameters ---------- value: int or None, optional The valur to set the maximum history depth. If no value is provided, an input dialog will be launched. Default is None. """ if value is None: dialog = QInputDialog(self) # Set dialog properties dialog.setModal(False) dialog.setWindowTitle(_("History")) dialog.setLabelText(_("Maximum entries")) dialog.setInputMode(QInputDialog.IntInput) dialog.setIntRange(MIN_HISTORY_ENTRIES, MAX_HISTORY_ENTRIES) dialog.setIntStep(1) dialog.setIntValue(self.get_option("max_entries")) # Connect slot dialog.intValueSelected.connect( lambda value: self.set_option("max_entries", value)) dialog.show() else: self.set_option("max_entries", value)