2014-06-27 23:54:17 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (c) 2013 "Filippo Scognamiglio"
|
2014-09-03 22:19:34 +02:00
|
|
|
* https://github.com/Swordfish90/cool-retro-term
|
2014-06-27 23:54:17 +02:00
|
|
|
*
|
2014-09-03 22:19:34 +02:00
|
|
|
* This file is part of cool-retro-term.
|
2014-06-27 23:54:17 +02:00
|
|
|
*
|
2014-09-03 22:19:34 +02:00
|
|
|
* cool-retro-term is free software: you can redistribute it and/or modify
|
2014-06-27 23:54:17 +02:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
import QtQuick 2.2
|
2014-05-18 22:23:19 +02:00
|
|
|
import QtQuick.Window 2.0
|
|
|
|
import QtQuick.Controls 1.1
|
|
|
|
import QtQuick.Layouts 1.1
|
2014-08-04 01:46:07 +02:00
|
|
|
import QtQuick.Dialogs 1.1
|
2014-05-18 22:23:19 +02:00
|
|
|
|
|
|
|
Window{
|
|
|
|
id: insertnamedialog
|
|
|
|
width: 400
|
|
|
|
height: 100
|
|
|
|
modality: Qt.ApplicationModal
|
2014-08-04 01:46:07 +02:00
|
|
|
title: qsTr("Save new profile")
|
2014-05-18 22:23:19 +02:00
|
|
|
|
2014-12-26 17:19:34 +01:00
|
|
|
property alias profileName: namefield.text
|
2014-05-18 22:23:19 +02:00
|
|
|
signal nameSelected(string name)
|
|
|
|
|
2014-08-04 01:46:07 +02:00
|
|
|
MessageDialog {
|
|
|
|
id: errorDialog
|
|
|
|
title: qsTr("Error")
|
|
|
|
visible: false
|
|
|
|
|
|
|
|
function showError(message){
|
|
|
|
text = message;
|
|
|
|
open();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function validateName(name){
|
2014-12-23 18:13:34 +01:00
|
|
|
var profile_list = appSettings.profilesList;
|
2014-08-04 01:46:07 +02:00
|
|
|
if (name === "")
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-18 22:23:19 +02:00
|
|
|
ColumnLayout{
|
|
|
|
anchors.margins: 10
|
|
|
|
anchors.fill: parent
|
|
|
|
RowLayout{
|
|
|
|
Label{text: qsTr("Name")}
|
|
|
|
TextField{
|
|
|
|
id: namefield
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Component.onCompleted: forceActiveFocus()
|
2014-08-04 01:46:07 +02:00
|
|
|
onAccepted: okbutton.clickAction()
|
2014-05-18 22:23:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
RowLayout{
|
2018-10-28 01:08:21 +02:00
|
|
|
Layout.alignment: Qt.AlignBottom | Qt.AlignRight
|
2014-05-18 22:23:19 +02:00
|
|
|
Button{
|
2014-08-04 01:46:07 +02:00
|
|
|
id: okbutton
|
2014-05-18 22:23:19 +02:00
|
|
|
text: qsTr("OK")
|
2014-08-04 01:46:07 +02:00
|
|
|
onClicked: clickAction()
|
|
|
|
function clickAction(){
|
|
|
|
var name = namefield.text;
|
|
|
|
switch(validateName(name)){
|
|
|
|
case 1:
|
|
|
|
errorDialog.showError(qsTr("The name you inserted is empty. Please choose a different one."));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
nameSelected(name);
|
|
|
|
close();
|
|
|
|
}
|
2014-05-18 22:23:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Button{
|
|
|
|
text: qsTr("Cancel")
|
|
|
|
onClicked: close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|