| 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 | |
| 24 | 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 | |
| 37 | NewHeaderDialog::() |
| 38 | { |
| 39 | delete ui; |
| 40 | } |
| 41 | |
| 42 | QString NewHeaderDialog::() const |
| 43 | { |
| 44 | return ui->txtHeader->text(); |
| 45 | } |
| 46 | |
| 47 | QString NewHeaderDialog::() const |
| 48 | { |
| 49 | return ui->txtPath->text(); |
| 50 | } |
| 51 | |
| 52 | void NewHeaderDialog::(const QString &location) |
| 53 | { |
| 54 | ui->txtPath->setText(location); |
| 55 | } |
| 56 | |
| 57 | void NewHeaderDialog::() |
| 58 | { |
| 59 | pIconsManager->setIcon(ui->btnBrowse, IconsManager::ACTION_FILE_OPEN_FOLDER); |
| 60 | } |
| 61 | |
| 62 | void NewHeaderDialog::(QCloseEvent */*event*/) |
| 63 | { |
| 64 | reject(); |
| 65 | } |
| 66 | |
| 67 | void NewHeaderDialog::() |
| 68 | { |
| 69 | accept(); |
| 70 | } |
| 71 | |
| 72 | |
| 73 | void NewHeaderDialog::() |
| 74 | { |
| 75 | reject(); |
| 76 | } |
| 77 | |
| 78 | |
| 79 | void NewHeaderDialog::() |
| 80 | { |
| 81 | QString fileName = QFileDialog::getExistingDirectory( |
| 82 | this, |
| 83 | tr("Path" ), |
| 84 | ui->txtPath->text()); |
| 85 | ui->txtPath->setText(fileName); |
| 86 | } |
| 87 | |
| 88 | |