From 3369750b97c61b9dfce16f136a82c57db6bfb250 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 9 Feb 2016 15:33:27 +0100 Subject: [PATCH 1/2] Make sure Machine names are always unique and non-zerolength Applies the same rename behavior introduced in the profiles rework to machine names. Machine names are always accepted, but if they are non-unique a number is added (recursively). If no name is specified, a logical default is chosen. Robust against leading/trailing spaces, and case insensitive. Contributes to CURA-425 --- resources/qml/WizardPages/AddMachine.qml | 68 +++--------------------- 1 file changed, 6 insertions(+), 62 deletions(-) diff --git a/resources/qml/WizardPages/AddMachine.qml b/resources/qml/WizardPages/AddMachine.qml index 524b4c30de..9bce4f3210 100644 --- a/resources/qml/WizardPages/AddMachine.qml +++ b/resources/qml/WizardPages/AddMachine.qml @@ -20,42 +20,12 @@ Item onVisibilityChanged: { machineName.text = getMachineName() - errorMessage.show = false - } - - function editMachineName(word) - { - //Adds '#2' at the end or increases the number by 1 if the word ends with '#' and 1 or more digits - var regEx = /[#][\d]+$///ends with '#' and then 1 or more digit - var result = word.match(regEx) - - if (result != null) - { - result = result[0].split('') - - var numberString = '' - for (var i = 1; i < result.length; i++){//starting at 1, makes it ignore the '#' - numberString += result[i] - } - var newNumber = Number(numberString) + 1 - - var newWord = word.replace(/[\d]+$/, newNumber)//replaces the last digits in the string by the same number + 1 - return newWord - } - else { - return word + ' #2' - } } function getMachineName() { var name = machineList.model.getItem(machineList.currentIndex).name - //if the automatically assigned name is not unique, the editMachineName function keeps editing it untill it is. - while (UM.MachineManager.checkInstanceExists(name) != false) - { - name = editMachineName(name) - } return name } @@ -65,20 +35,14 @@ Item onNextClicked: //You can add functions here that get triggered when the final button is clicked in the wizard-element { var name = machineName.text - if (UM.MachineManager.checkInstanceExists(name) != false) + + var old_page_count = base.wizard.getPageCount() + // Delete old pages (if any) + for (var i = old_page_count - 1; i > 0; i--) { - errorMessage.show = true - } - else - { - var old_page_count = base.wizard.getPageCount() - // Delete old pages (if any) - for (var i = old_page_count - 1; i > 0; i--) - { - base.wizard.removePage(i) - } - saveMachine() + base.wizard.removePage(i) } + saveMachine() } onBackClicked: { @@ -218,26 +182,6 @@ Item { id: machineNameHolder anchors.bottom: parent.bottom; - //height: insertNameLabel.lineHeight * (2 + errorMessage.lineCount) - - Item - { - height: errorMessage.lineHeight - anchors.bottom: insertNameLabel.top - anchors.bottomMargin: insertNameLabel.height * errorMessage.lineCount - Label - { - id: errorMessage - property bool show: false - width: base.width - height: errorMessage.show ? errorMessage.lineHeight : 0 - visible: errorMessage.show - text: catalog.i18nc("@label", "This printer name has already been used. Please choose a different printer name."); - wrapMode: Text.WordWrap - Behavior on height {NumberAnimation {duration: 75; }} - color: UM.Theme.colors.error - } - } Label { From 15aec5914a9c8dfde075fb66d4ed5e346e15a3f9 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Tue, 9 Feb 2016 16:24:44 +0100 Subject: [PATCH 2/2] Use a preference for the autosave delay and reduce it to 10 seconds It only triggers after we have stopped changing things, so having a shorter delay is not that dangerous. Using preference as per @ghostkeeper 's suggestion. Contributes to CURA-511 --- plugins/AutoSave/AutoSave.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/AutoSave/AutoSave.py b/plugins/AutoSave/AutoSave.py index a631628bba..b6251addcd 100644 --- a/plugins/AutoSave/AutoSave.py +++ b/plugins/AutoSave/AutoSave.py @@ -26,8 +26,10 @@ class AutoSave(Extension): Application self._onActiveProfileChanged() + Preferences.getInstance().addPreference("cura/autosave_delay", 1000 * 10) + self._change_timer = QTimer() - self._change_timer.setInterval(1000 * 60) + self._change_timer.setInterval(Preferences.getInstance().getValue("cura/autosave_delay")) self._change_timer.setSingleShot(True) self._change_timer.timeout.connect(self._onTimeout)