| 1 | /***************************************************************************** |
| 2 | ** QNapi |
| 3 | ** Copyright (C) 2008-2017 Piotr KrzemiĆski <[email protected]> |
| 4 | ** |
| 5 | ** This program is free software; you can redistribute it and/or modify |
| 6 | ** it under the terms of the GNU General Public License as published by |
| 7 | ** the Free Software Foundation; either version 2 of the License, or |
| 8 | ** (at your option) any later version. |
| 9 | ** |
| 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
| 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 12 | ** |
| 13 | *****************************************************************************/ |
| 14 | |
| 15 | #include <QDesktopServices> |
| 16 | #include <QDesktopWidget> |
| 17 | |
| 18 | #include "engines/napiprojektdownloadengine.h" |
| 19 | #include "frmnapiprojektconfig.h" |
| 20 | |
| 21 | frmNapiProjektConfig::frmNapiProjektConfig(const EngineConfig &config, |
| 22 | QWidget *parent, Qt::WindowFlags f) |
| 23 | : QDialog(parent, f), config(config) { |
| 24 | ui.setupUi(this); |
| 25 | |
| 26 | ui.leNick->setText(config.nick()); |
| 27 | ui.lePass->setText(config.password()); |
| 28 | |
| 29 | QIcon napiProjektIcon = QIcon(QPixmap(NapiProjektDownloadEngine::pixmapData)); |
| 30 | setWindowIcon(napiProjektIcon); |
| 31 | |
| 32 | connect(ui.pbRegister, SIGNAL(clicked()), this, SLOT(pbRegisterClicked())); |
| 33 | |
| 34 | QRect position = frameGeometry(); |
| 35 | position.moveCenter(QDesktopWidget().availableGeometry().center()); |
| 36 | move(position.topLeft()); |
| 37 | } |
| 38 | |
| 39 | EngineConfig frmNapiProjektConfig::getConfig() const { return config; } |
| 40 | |
| 41 | void frmNapiProjektConfig::accept() { |
| 42 | config = config.setNick(ui.leNick->text()).setPassword(ui.lePass->text()); |
| 43 | QDialog::accept(); |
| 44 | } |
| 45 | |
| 46 | void frmNapiProjektConfig::pbRegisterClicked() { |
| 47 | Maybe<QUrl> maybeRegistrationUrl = |
| 48 | NapiProjektDownloadEngine::metadata.registrationUrl(); |
| 49 | |
| 50 | if (maybeRegistrationUrl) { |
| 51 | QDesktopServices::openUrl(maybeRegistrationUrl.value()); |
| 52 | } |
| 53 | } |