/gui/src/forms/frmnapiprojektconfig.cpp

https://github.com/QNapi/qnapi · C++ · 53 lines · 29 code · 11 blank · 13 comment · 1 complexity · ad11795c82a806f4ab54fb755b32f336 MD5 · raw file

  1. /*****************************************************************************
  2. ** QNapi
  3. ** Copyright (C) 2008-2017 Piotr Krzemiński <pio.krzeminski@gmail.com>
  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. #include <QDesktopServices>
  15. #include <QDesktopWidget>
  16. #include "engines/napiprojektdownloadengine.h"
  17. #include "frmnapiprojektconfig.h"
  18. frmNapiProjektConfig::frmNapiProjektConfig(const EngineConfig &config,
  19. QWidget *parent, Qt::WindowFlags f)
  20. : QDialog(parent, f), config(config) {
  21. ui.setupUi(this);
  22. ui.leNick->setText(config.nick());
  23. ui.lePass->setText(config.password());
  24. QIcon napiProjektIcon = QIcon(QPixmap(NapiProjektDownloadEngine::pixmapData));
  25. setWindowIcon(napiProjektIcon);
  26. connect(ui.pbRegister, SIGNAL(clicked()), this, SLOT(pbRegisterClicked()));
  27. QRect position = frameGeometry();
  28. position.moveCenter(QDesktopWidget().availableGeometry().center());
  29. move(position.topLeft());
  30. }
  31. EngineConfig frmNapiProjektConfig::getConfig() const { return config; }
  32. void frmNapiProjektConfig::accept() {
  33. config = config.setNick(ui.leNick->text()).setPassword(ui.lePass->text());
  34. QDialog::accept();
  35. }
  36. void frmNapiProjektConfig::pbRegisterClicked() {
  37. Maybe<QUrl> maybeRegistrationUrl =
  38. NapiProjektDownloadEngine::metadata.registrationUrl();
  39. if (maybeRegistrationUrl) {
  40. QDesktopServices::openUrl(maybeRegistrationUrl.value());
  41. }
  42. }