-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parametres.cpp
112 lines (93 loc) · 3.72 KB
/
parametres.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "parametres.h"
#include "ui_parametres.h"
#include "umlo.h"
#include <QFileDialog>
#include <QStandardPaths>
Parametres::Parametres(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Parametres)
{
ui->setupUi(this);
QSettings settings;
QString FsSettings = settings.fileName();
settings.beginGroup("umlo");
Umlo::UserName = settings.value("UserName", Umlo::UserName).value<QString>();
Umlo::UserPass = Umlo::crypto.decryptToString(settings.value("Password", "hik12345").value<QString>());
Umlo::PrefixUser = settings.value("PrefixUser", Umlo::PrefixUser).value<QString>();
Umlo::RpmbuildPath = settings.value("RpmbuildPath", QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/rpmbuild").value<QString>().split(";");
Umlo::MloMount = settings.value("MloMount", Umlo::MloMount).value<QString>();
Umlo::LsRpmsServ = settings.value("LsRpmsServ", Umlo::LsRpmsServ).value<bool>();
settings.endGroup();
ui->UserEd->setText(Umlo::UserName);
ui->PassEd->setText(Umlo::UserPass);
ui->PrefixUserEd->setText(Umlo::PrefixUser);
// ui->RpmbuildEd->setText(Umlo::RpmbuildPath);
QStringList RpmBuildPathList = Umlo::RpmbuildPath;
foreach (QString Path, RpmBuildPathList)
ui->comboBoxRpmbuildDir->addItem(Path);
ui->RootEd->setText(Umlo::MloMount);
ui->LsDistRPMS->setChecked(Umlo::LsRpmsServ);
}
void Parametres::showEvent(QShowEvent *event)
{
// ui->BtnSshDirChoice->y() = ui->RootEd->y();
// ui->gridLayout->setDefaultPositioning(ui->formLayoutWidget->y(),Qt::Orientation::Horizontal);
// ui->gridLayout->setAlignment(ui->formLayout->alignment());
}
Parametres::~Parametres()
{
delete ui;
}
void Parametres::on_BtnSave_released()
{
Umlo::UserName = ui->UserEd->text();
Umlo::UserPass = ui->PassEd->text();
Umlo::PrefixUser = ui->PrefixUserEd->text();
QString RpmbuildPathClean = CmBxToStr();
QStringList test = Umlo::RpmbuildPath = RpmbuildPathClean.split(";");
Umlo::MloMount = ui->RootEd->text();
Umlo::LsRpmsServ = ui->LsDistRPMS->isChecked();
settings.beginGroup("umlo");
settings.setValue( "UserName", Umlo::UserName);
settings.setValue("Password",Umlo::crypto.encryptToString(Umlo::UserPass) );
settings.setValue( "PrefixUser", Umlo::PrefixUser);
settings.setValue("RpmbuildPath", RpmbuildPathClean);
settings.setValue("MloMount", Umlo::MloMount);
settings.setValue("LsRpmsServ", Umlo::LsRpmsServ);
settings.endGroup();
settings.sync();
//Umlo().Init();
close();
}
void Parametres::on_BtnCancel_released()
{
close();
}
void Parametres::on_BtnRpmbuilDirChoice_released()
{
QUrl _IntputFolder = QFileDialog::getExistingDirectory(this,
(tr("Choisir un dossier rpmbuild")), ui->comboBoxRpmbuildDir->currentText());
if (_IntputFolder.isEmpty() == false) {
// ui->RpmbuildEd->setText(_IntputFolder.path().toUtf8());
ui->comboBoxRpmbuildDir->addItem(_IntputFolder.path().toUtf8());
}
}
void Parametres::on_BtnSshDirChoice_released()
{
QUrl _IntputFolder = QFileDialog::getExistingDirectory(this,
(tr("Choisir un dossier de montage ssh/sftp")), ui->RootEd->text());
if (_IntputFolder.isEmpty() == false) {
ui->RootEd->setText(_IntputFolder.path().toUtf8());
}
}
void Parametres::on_BtnRpmbuilDirDel_released()
{
ui->comboBoxRpmbuildDir->removeItem(ui->comboBoxRpmbuildDir->currentIndex());
}
QString Parametres::CmBxToStr()
{
QString ListDir;
for (int i = 0; i < ui->comboBoxRpmbuildDir->count(); i++ )
ListDir += ui->comboBoxRpmbuildDir->itemText(i) + ";";
return ListDir.remove(ListDir.length() - 1,1);
}