/src/gui/wizard/owncloudwizardresultpage.cpp

https://github.com/nextcloud/desktop · C++ · 99 lines · 64 code · 17 blank · 18 comment · 0 complexity · d2d7f59d65f48303b7aad0fba112402e MD5 · raw file

  1. /*
  2. * Copyright (C) by Klaas Freitag <freitag@owncloud.com>
  3. * Copyright (C) by Krzesimir Nowak <krzesimir@endocode.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 program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  12. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  13. * for more details.
  14. */
  15. #include <QDesktopServices>
  16. #include <QDir>
  17. #include <QUrl>
  18. #include "wizard/owncloudwizardresultpage.h"
  19. #include "wizard/owncloudwizardcommon.h"
  20. #include "theme.h"
  21. namespace OCC {
  22. OwncloudWizardResultPage::OwncloudWizardResultPage()
  23. : QWizardPage()
  24. {
  25. _ui.setupUi(this);
  26. // no fields to register.
  27. setTitle(WizardCommon::subTitleTemplate().arg(tr("Everything set up!")));
  28. // required to show header in QWizard's modern style
  29. setSubTitle(QLatin1String(" "));
  30. _ui.pbOpenLocal->setText(tr("Open Local Folder"));
  31. // TODO: File doesn't exist anymore - unneccessary or replacement needed?
  32. _ui.pbOpenLocal->setIcon(QIcon(QLatin1String(":/client/theme/folder-sync.png")));
  33. _ui.pbOpenLocal->setIconSize(QSize(48, 48));
  34. _ui.pbOpenLocal->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
  35. connect(_ui.pbOpenLocal, &QAbstractButton::clicked, this, &OwncloudWizardResultPage::slotOpenLocal);
  36. Theme *theme = Theme::instance();
  37. QIcon appIcon = theme->applicationIcon();
  38. _ui.pbOpenServer->setText(tr("Open %1 in Browser").arg(theme->appNameGUI()));
  39. _ui.pbOpenServer->setIcon(appIcon.pixmap(48));
  40. _ui.pbOpenServer->setIconSize(QSize(48, 48));
  41. _ui.pbOpenServer->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
  42. connect(_ui.pbOpenServer, &QAbstractButton::clicked, this, &OwncloudWizardResultPage::slotOpenServer);
  43. setupCustomization();
  44. }
  45. OwncloudWizardResultPage::~OwncloudWizardResultPage() = default;
  46. void OwncloudWizardResultPage::setComplete(bool complete)
  47. {
  48. _complete = complete;
  49. emit completeChanged();
  50. }
  51. bool OwncloudWizardResultPage::isComplete() const
  52. {
  53. return _complete;
  54. }
  55. void OwncloudWizardResultPage::initializePage()
  56. {
  57. _ui.localFolderLabel->setText(QString());
  58. }
  59. void OwncloudWizardResultPage::setRemoteFolder(const QString &remoteFolder)
  60. {
  61. _remoteFolder = remoteFolder;
  62. }
  63. void OwncloudWizardResultPage::setupCustomization()
  64. {
  65. // set defaults for the customize labels.
  66. _ui.topLabel->setText(QString());
  67. _ui.topLabel->hide();
  68. QVariant variant = Theme::instance()->customMedia(Theme::oCSetupResultTop);
  69. WizardCommon::setupCustomMedia(variant, _ui.topLabel);
  70. }
  71. void OwncloudWizardResultPage::slotOpenLocal()
  72. {
  73. const QString localFolder = wizard()->property("localFolder").toString();
  74. QDesktopServices::openUrl(QUrl::fromLocalFile(localFolder));
  75. }
  76. void OwncloudWizardResultPage::slotOpenServer()
  77. {
  78. Theme *theme = Theme::instance();
  79. QUrl url = QUrl(field("OCUrl").toString() + theme->wizardUrlPostfix());
  80. QDesktopServices::openUrl(url);
  81. }
  82. } // namespace OCC