Debian Codegraph @

src/gui/settingsDialog/uploader/FtpUploaderSettings.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2021 Damir Porobic <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #include "FtpUploaderSettings.h"
21
22 FtpUploaderSettings::FtpUploaderSettings(const QSharedPointer<IConfig> &config) :
23 mConfig(config),
24 mLayout(new QGridLayout(this)),
25 mForceAnonymousUploadCheckBox(new QCheckBox(this)),
26 mUrlLabel(new QLabel(this)),
27 mUsernameLabel(new QLabel(this)),
28 mPasswordLabel(new QLabel(this)),
29 mUrlLineEdit(new QLineEdit(this)),
30 mUsernameLineEdit(new QLineEdit(this)),
31 mPasswordLineEdit(new QLineEdit(this))
32 {
33 initGui();
34 loadConfig();
35 }
36
37 void FtpUploaderSettings::saveSettings()
38 {
39 mConfig->setFtpUploadForceAnonymous(mForceAnonymousUploadCheckBox->isChecked());
40 mConfig->setFtpUploadUrl(mUrlLineEdit->text());
41 mConfig->setFtpUploadUsername(mUsernameLineEdit->text());
42 mConfig->setFtpUploadPassword(mPasswordLineEdit->text());
43 }
44
45 void FtpUploaderSettings::initGui()
46 {
47 mForceAnonymousUploadCheckBox->setText(tr("Force anonymous upload."));
48
49 mUrlLabel->setText(tr("Url") + QLatin1String(":"));
50
51 mUsernameLabel->setText(tr("Username") + QLatin1String(":"));
52
53 mPasswordLabel->setText(tr("Password") + QLatin1String(":"));
54 mPasswordLineEdit->setEchoMode(QLineEdit::Password);
55
56 mLayout->setAlignment(Qt::AlignTop);
57 mLayout->addWidget(mForceAnonymousUploadCheckBox, 0, 0, 1, 3);
58 mLayout->setRowMinimumHeight(1, 15);
59 mLayout->addWidget(mUrlLabel, 2, 0, 1, 1);
60 mLayout->addWidget(mUrlLineEdit, 2, 1, 1, 2);
61 mLayout->setRowMinimumHeight(3, 15);
62 mLayout->addWidget(mUsernameLabel, 4, 0, 1, 1);
63 mLayout->addWidget(mUsernameLineEdit, 4, 1, 1, 1);
64 mLayout->addWidget(mPasswordLabel, 5, 0, 1, 1);
65 mLayout->addWidget(mPasswordLineEdit, 5, 1, 1, 1);
66
67 setTitle(tr("FTP Uploader"));
68 setLayout(mLayout);
69 }
70
71 void FtpUploaderSettings::loadConfig()
72 {
73 mForceAnonymousUploadCheckBox->setChecked(mConfig->ftpUploadForceAnonymous());
74 mUrlLineEdit->setText(mConfig->ftpUploadUrl());
75 mUsernameLineEdit->setText(mConfig->ftpUploadUsername());
76 mPasswordLineEdit->setText(mConfig->ftpUploadPassword());
77 }