Debian Codegraph @

gui/src/forms/frmnapisy24config.cpp

raw symbols SCIP
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/napisy24downloadengine.h"
19 #include "frmnapisy24config.h"
20
21 frmNapisy24Config::frmNapisy24Config(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 napisy24Icon = QIcon(QPixmap(Napisy24DownloadEngine::pixmapData));
30 setWindowIcon(napisy24Icon);
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 frmNapisy24Config::getConfig() const { return config; }
40
41 void frmNapisy24Config::accept() {
42 config = config.setNick(ui.leNick->text()).setPassword(ui.lePass->text());
43 QDialog::accept();
44 }
45
46 void frmNapisy24Config::pbRegisterClicked() {
47 Maybe<QUrl> maybeRegistrationUrl =
48 Napisy24DownloadEngine::metadata.registrationUrl();
49
50 if (maybeRegistrationUrl) {
51 QDesktopServices::openUrl(maybeRegistrationUrl.value());
52 }
53 }