PageRenderTime 94ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/src/tiled/patreondialog.cpp

http://github.com/bjorn/tiled
C++ | 96 lines | 62 code | 15 blank | 19 comment | 2 complexity | f0b4117f2174b399788f32b09a621286 MD5 | raw file
Possible License(s): Apache-2.0, GPL-2.0, LGPL-2.1, AGPL-1.0
  1. /*
  2. * patreondialog.cpp
  3. * Copyright 2015, Thorbjørn Lindeijer <thorbjorn@lindeijer.nl>
  4. *
  5. * This file is part of Tiled.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the Free
  9. * Software Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. * more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along with
  18. * this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include "patreondialog.h"
  21. #include "ui_patreondialog.h"
  22. #include "preferences.h"
  23. #include <QDesktopServices>
  24. using namespace Tiled::Internal;
  25. PatreonDialog::PatreonDialog(QWidget *parent) :
  26. QDialog(parent),
  27. ui(new Ui::PatreonDialog)
  28. {
  29. setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
  30. ui->setupUi(this);
  31. ui->maybeLaterButton->setVisible(false);
  32. connect(ui->gotoPatreon, SIGNAL(clicked()), SLOT(openPatreonPage()));
  33. connect(ui->alreadyPatron, SIGNAL(clicked()), SLOT(togglePatreonStatus()));
  34. Preferences *prefs = Preferences::instance();
  35. connect(prefs, SIGNAL(isPatronChanged()), SLOT(updatePatreonStatus()));
  36. updatePatreonStatus();
  37. }
  38. PatreonDialog::~PatreonDialog()
  39. {
  40. delete ui;
  41. }
  42. void PatreonDialog::openPatreonPage()
  43. {
  44. QDesktopServices::openUrl(QUrl(QLatin1String("https://www.patreon.com/bjorn")));
  45. }
  46. void PatreonDialog::togglePatreonStatus()
  47. {
  48. Preferences *prefs = Preferences::instance();
  49. prefs->setPatron(!prefs->isPatron());
  50. setFocus();
  51. }
  52. void PatreonDialog::updatePatreonStatus()
  53. {
  54. if (Preferences::instance()->isPatron()) {
  55. ui->textBrowser->setHtml(tr(
  56. "<html><head/><body>\n"
  57. "<h3>Thank you for support!</h3>\n"
  58. "<p>Your support as a patron makes a big difference to me as the "
  59. "main developer and maintainer of Tiled. It allows me to spend "
  60. "less time working for money elsewhere and spend more time working "
  61. "on Tiled instead.</p>\n"
  62. "<p>Keep an eye out for exclusive updates in the Activity feed on "
  63. "my Patreon page to find out what I've been up to in the time I "
  64. "could spend on Tiled thanks to your support!</p>\n"
  65. "<p><i>Thorbj&oslash;rn Lindeijer</i></p></body></html>"));
  66. ui->alreadyPatron->setText(tr("I'm no longer a patron"));
  67. } else {
  68. ui->textBrowser->setHtml(tr(
  69. "<html><head/><body>\n"
  70. "<h3>With your help I can continue to improve Tiled!</h3>\n"
  71. "<p>Please consider supporting me as a patron. Your support would "
  72. "make a big difference to me, the main developer and maintainer of "
  73. "Tiled. I could spend less time working for money elsewhere and "
  74. "spend more time working on Tiled instead.</p>\n"
  75. "<p>Every little bit helps. Tiled has a lot of users and if each "
  76. "would contribute a small donation each month I will have time to "
  77. "make sure Tiled keeps getting better.</p>\n"
  78. "<p><i>Thorbj&oslash;rn Lindeijer</i></p></body></html>"));
  79. ui->alreadyPatron->setText(tr("I'm already a patron!"));
  80. }
  81. }