PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/qt-creator-2.5.0-src/src/plugins/qt4projectmanager/qt-s60/s60publishingresultspageovi.cpp

#
C++ | 115 lines | 69 code | 12 blank | 34 comment | 2 complexity | 3b05d321b50067e166ef4569b4ab39d8 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, CC0-1.0
  1. /**************************************************************************
  2. **
  3. ** This file is part of Qt Creator
  4. **
  5. ** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
  6. **
  7. ** Contact: Nokia Corporation (qt-info@nokia.com)
  8. **
  9. **
  10. ** GNU Lesser General Public License Usage
  11. **
  12. ** This file may be used under the terms of the GNU Lesser General Public
  13. ** License version 2.1 as published by the Free Software Foundation and
  14. ** appearing in the file LICENSE.LGPL included in the packaging of this file.
  15. ** Please review the following information to ensure the GNU Lesser General
  16. ** Public License version 2.1 requirements will be met:
  17. ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  18. **
  19. ** In addition, as a special exception, Nokia gives you certain additional
  20. ** rights. These rights are described in the Nokia Qt LGPL Exception
  21. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  22. **
  23. ** Other Usage
  24. **
  25. ** Alternatively, this file may be used in accordance with the terms and
  26. ** conditions contained in a signed written agreement between you and Nokia.
  27. **
  28. ** If you have questions regarding the use of this file, please contact
  29. ** Nokia at qt-info@nokia.com.
  30. **
  31. **************************************************************************/
  32. #include "s60publishingresultspageovi.h"
  33. #include "s60publisherovi.h"
  34. #include "ui_s60publishingresultspageovi.h"
  35. #include <QDesktopServices>
  36. #include <QAbstractButton>
  37. #include <QScrollBar>
  38. #include <QProcess>
  39. namespace Qt4ProjectManager {
  40. namespace Internal {
  41. S60PublishingResultsPageOvi::S60PublishingResultsPageOvi(S60PublisherOvi *publisher, QWidget *parent) :
  42. QWizardPage(parent),
  43. ui(new Ui::S60PublishingResultsPageOvi),
  44. m_publisher(publisher)
  45. {
  46. ui->setupUi(this);
  47. connect(m_publisher, SIGNAL(progressReport(QString,QColor)), SLOT(updateResultsPage(QString,QColor)));
  48. }
  49. S60PublishingResultsPageOvi::~S60PublishingResultsPageOvi()
  50. {
  51. delete ui;
  52. }
  53. void S60PublishingResultsPageOvi::initializePage()
  54. {
  55. wizard()->setButtonText(QWizard::FinishButton, tr("Open Containing Folder"));
  56. connect(m_publisher, SIGNAL(finished()), SIGNAL(completeChanged()));
  57. connect(m_publisher, SIGNAL(finished()), SLOT(packageCreationFinished()));
  58. connect(wizard()->button(QWizard::FinishButton), SIGNAL(clicked()), SLOT(openFileLocation()));
  59. m_publisher->buildSis();
  60. }
  61. bool S60PublishingResultsPageOvi::isComplete() const
  62. {
  63. return m_publisher->hasSucceeded();
  64. }
  65. void S60PublishingResultsPageOvi::packageCreationFinished()
  66. {
  67. wizard()->setButtonText(QWizard::CancelButton, tr("Close"));
  68. }
  69. void S60PublishingResultsPageOvi::updateResultsPage(const QString& status, QColor c)
  70. {
  71. const bool atBottom = isScrollbarAtBottom();
  72. QTextCursor cur(ui->resultsTextBrowser->document());
  73. QTextCharFormat tcf = cur.charFormat();
  74. tcf.setForeground(c);
  75. cur.movePosition(QTextCursor::End);
  76. cur.insertText(status, tcf);
  77. if (atBottom)
  78. scrollToBottom();
  79. }
  80. bool S60PublishingResultsPageOvi::isScrollbarAtBottom() const
  81. {
  82. QScrollBar *scrollBar = ui->resultsTextBrowser->verticalScrollBar();
  83. return scrollBar->value() == scrollBar->maximum();
  84. }
  85. void S60PublishingResultsPageOvi::scrollToBottom()
  86. {
  87. QScrollBar *scrollBar = ui->resultsTextBrowser->verticalScrollBar();
  88. scrollBar->setValue(scrollBar->maximum());
  89. // QPlainTextEdit destroys the first calls value in case of multiline
  90. // text, so make sure that the scroll bar actually gets the value set.
  91. // Is a noop if the first call succeeded.
  92. scrollBar->setValue(scrollBar->maximum());
  93. }
  94. void S60PublishingResultsPageOvi::openFileLocation()
  95. {
  96. #ifdef Q_OS_WIN
  97. QProcess::startDetached(QLatin1String("explorer /select,")+ m_publisher->createdSisFilePath());
  98. #else
  99. QDesktopServices::openUrl(QUrl(QLatin1String("file:///") + m_publisher->createdSisFileContainingFolder()));
  100. #endif
  101. }
  102. } // namespace Internal
  103. } // namespace Qt4ProjectManager