1/*
2 * Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
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 3 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, see <https://www.gnu.org/licenses/>.
16 */
17#include "newheaderdialog.h"
18#include "ui_newheaderdialog.h"
19#include "../iconsmanager.h"
20#include "../settings.h"
21
22#include <QFileDialog>
23
24NewHeaderDialog::NewHeaderDialog(QWidget *parent) :
25 QDialog(parent),
26 ui(new Ui::NewHeaderDialog)
27{
28 setWindowFlag(Qt::WindowContextHelpButtonHint,false);
29 ui->setupUi(this);
30 resize(pSettings->ui().newHeaderDialogWidth(),pSettings->ui().newHeaderDialogHeight());
31 onUpdateIcons();
32 connect(pIconsManager,&IconsManager::actionIconsUpdated,
33 this, &NewHeaderDialog::onUpdateIcons);
34 ui->txtHeader->setFocus();
35}
36
37NewHeaderDialog::~NewHeaderDialog()
38{
39 delete ui;
40}
41
42QString NewHeaderDialog::headerName() const
43{
44 return ui->txtHeader->text();
45}
46
47QString NewHeaderDialog::path() const
48{
49 return ui->txtPath->text();
50}
51
52void NewHeaderDialog::setPath(const QString &location)
53{
54 ui->txtPath->setText(location);
55}
56
57void NewHeaderDialog::onUpdateIcons()
58{
59 pIconsManager->setIcon(ui->btnBrowse, IconsManager::ACTION_FILE_OPEN_FOLDER);
60}
61
62void NewHeaderDialog::closeEvent(QCloseEvent */*event*/)
63{
64 reject();
65}
66
67void NewHeaderDialog::on_btnCreate_clicked()
68{
69 accept();
70}
71
72
73void NewHeaderDialog::on_btnCancel_clicked()
74{
75 reject();
76}
77
78
79void NewHeaderDialog::on_btnBrowse_clicked()
80{
81 QString fileName = QFileDialog::getExistingDirectory(
82 this,
83 tr("Path"),
84 ui->txtPath->text());
85 ui->txtPath->setText(fileName);
86}
87
88