Mercurial > hg > sonic-visualiser
comparison main/MainWindow.cpp @ 1516:47a18e281a93 3.0-integration
Add "What's New" to help menu; primp up About box
author | Chris Cannam |
---|---|
date | Tue, 10 Jan 2017 13:58:06 +0000 |
parents | e76f72565112 |
children | e528184a0ccc |
comparison
equal
deleted
inserted
replaced
1515:ea6c44afb68f | 1516:47a18e281a93 |
---|---|
122 #include <QScrollArea> | 122 #include <QScrollArea> |
123 #include <QCloseEvent> | 123 #include <QCloseEvent> |
124 #include <QDesktopServices> | 124 #include <QDesktopServices> |
125 #include <QDialogButtonBox> | 125 #include <QDialogButtonBox> |
126 #include <QFileSystemWatcher> | 126 #include <QFileSystemWatcher> |
127 #include <QTextEdit> | |
127 | 128 |
128 #include <iostream> | 129 #include <iostream> |
129 #include <cstdio> | 130 #include <cstdio> |
130 #include <errno.h> | 131 #include <errno.h> |
131 | 132 |
1783 action = new QAction(tr("%1 on the &Web").arg(name), this); | 1784 action = new QAction(tr("%1 on the &Web").arg(name), this); |
1784 action->setStatusTip(tr("Open the %1 website").arg(name)); | 1785 action->setStatusTip(tr("Open the %1 website").arg(name)); |
1785 connect(action, SIGNAL(triggered()), this, SLOT(website())); | 1786 connect(action, SIGNAL(triggered()), this, SLOT(website())); |
1786 menu->addAction(action); | 1787 menu->addAction(action); |
1787 | 1788 |
1789 action = new QAction(tr("What's &New?").arg(name), this); | |
1790 action->setStatusTip(tr("Show changes in this release of %1").arg(name)); | |
1791 connect(action, SIGNAL(triggered()), this, SLOT(whatsNew())); | |
1792 menu->addAction(action); | |
1793 | |
1788 action = new QAction(tr("&About %1").arg(name), this); | 1794 action = new QAction(tr("&About %1").arg(name), this); |
1789 action->setStatusTip(tr("Show information about %1").arg(name)); | 1795 action->setStatusTip(tr("Show information about %1").arg(name)); |
1790 connect(action, SIGNAL(triggered()), this, SLOT(about())); | 1796 connect(action, SIGNAL(triggered()), this, SLOT(about())); |
1791 menu->addAction(action); | 1797 menu->addAction(action); |
1792 } | 1798 } |
3275 if (QMessageBox::warning(this, | 3281 if (QMessageBox::warning(this, |
3276 tr("Template file exists"), | 3282 tr("Template file exists"), |
3277 tr("<b>Template file exists</b><p>The template \"%1\" already exists.<br>Overwrite it?").arg(name), | 3283 tr("<b>Template file exists</b><p>The template \"%1\" already exists.<br>Overwrite it?").arg(name), |
3278 QMessageBox::Ok | QMessageBox::Cancel, | 3284 QMessageBox::Ok | QMessageBox::Cancel, |
3279 QMessageBox::Cancel) != QMessageBox::Ok) { | 3285 QMessageBox::Cancel) != QMessageBox::Ok) { |
3286 delete d; | |
3280 return; | 3287 return; |
3281 } | 3288 } |
3282 } | 3289 } |
3283 | 3290 |
3284 if (saveSessionTemplate(filename)) { | 3291 if (saveSessionTemplate(filename)) { |
3285 if (makeDefault->isChecked()) { | 3292 if (makeDefault->isChecked()) { |
3286 setDefaultSessionTemplate(name); | 3293 setDefaultSessionTemplate(name); |
3287 } | 3294 } |
3288 } | 3295 } |
3289 } | 3296 } |
3297 | |
3298 delete d; | |
3290 } | 3299 } |
3291 | 3300 |
3292 void | 3301 void |
3293 MainWindow::manageSavedTemplates() | 3302 MainWindow::manageSavedTemplates() |
3294 { | 3303 { |
4742 { | 4751 { |
4743 openHelpUrl(tr("http://www.sonicvisualiser.org/doc/reference/%1/en/").arg(SV_VERSION)); | 4752 openHelpUrl(tr("http://www.sonicvisualiser.org/doc/reference/%1/en/").arg(SV_VERSION)); |
4744 } | 4753 } |
4745 | 4754 |
4746 void | 4755 void |
4756 MainWindow::whatsNew() | |
4757 { | |
4758 QFile changelog(":CHANGELOG"); | |
4759 changelog.open(QFile::ReadOnly); | |
4760 QByteArray content = changelog.readAll(); | |
4761 QString text = QString::fromUtf8(content); | |
4762 | |
4763 QDialog *d = new QDialog(this); | |
4764 d->setWindowTitle(tr("What's New")); | |
4765 | |
4766 QGridLayout *layout = new QGridLayout; | |
4767 d->setLayout(layout); | |
4768 | |
4769 int row = 0; | |
4770 | |
4771 QLabel *iconLabel = new QLabel; | |
4772 iconLabel->setPixmap(QApplication::windowIcon().pixmap(64, 64)); | |
4773 layout->addWidget(iconLabel, row, 0); | |
4774 | |
4775 layout->addWidget | |
4776 (new QLabel(tr("<h3>What's New in %1</h3>") | |
4777 .arg(QApplication::applicationName())), | |
4778 row++, 1); | |
4779 layout->setColumnStretch(2, 10); | |
4780 | |
4781 QTextEdit *textEdit = new QTextEdit; | |
4782 layout->addWidget(textEdit, row++, 1, 1, 2); | |
4783 | |
4784 if (m_newerVersionIs != "") { | |
4785 layout->addWidget(new QLabel(tr("<b>Note:</b> A newer version of Sonic Visualiser is available.<br>(Version %1 is available; you are using version %2)").arg(m_newerVersionIs).arg(SV_VERSION)), row++, 1, 1, 2); | |
4786 } | |
4787 | |
4788 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok); | |
4789 layout->addWidget(bb, row++, 0, 1, 3); | |
4790 connect(bb, SIGNAL(accepted()), d, SLOT(accept())); | |
4791 | |
4792 text.replace(QRegExp("(.)\n +(.)"), "\\1 \\2"); | |
4793 text.replace(QRegExp("\n - ([^\n]+)"), "\n<li>\\1</li>"); | |
4794 text.replace(QRegExp(": *\n"), ":\n<ul>\n"); | |
4795 text.replace(QRegExp("</li>\n\\s*\n"), "</li>\n</ul>\n\n"); | |
4796 text.replace(QRegExp("\n(\\w[^:\n]+:)"), "\n<p><b>\\1</b></p>"); | |
4797 // text.replace(QRegExp("<li>([^,.\n]+)([,.] +\\w)"), "<li><b>\\1</b>\\2"); | |
4798 | |
4799 textEdit->setHtml(text); | |
4800 textEdit->setReadOnly(true); | |
4801 | |
4802 d->setMinimumSize(m_viewManager->scalePixelSize(420), | |
4803 m_viewManager->scalePixelSize(400)); | |
4804 | |
4805 d->exec(); | |
4806 | |
4807 delete d; | |
4808 } | |
4809 | |
4810 void | |
4747 MainWindow::about() | 4811 MainWindow::about() |
4748 { | 4812 { |
4749 bool debug = false; | 4813 bool debug = false; |
4750 QString version = "(unknown version)"; | 4814 QString version = "(unknown version)"; |
4751 | 4815 |
4771 aboutText += tr("<p><small>%1 : %2 configuration, %3-bit build</small></p>") | 4835 aboutText += tr("<p><small>%1 : %2 configuration, %3-bit build</small></p>") |
4772 .arg(version) | 4836 .arg(version) |
4773 .arg(debug ? tr("Debug") : tr("Release")) | 4837 .arg(debug ? tr("Debug") : tr("Release")) |
4774 .arg(sizeof(void *) * 8); | 4838 .arg(sizeof(void *) * 8); |
4775 | 4839 |
4776 aboutText += "<small>"; | 4840 if (m_oscQueue && m_oscQueue->isOK()) { |
4841 aboutText += tr("</small><p><small>The OSC URL for this instance is: \"%1\"").arg(m_oscQueue->getOSCURL()); | |
4842 } | |
4843 | |
4844 aboutText += "</small><p><small>"; | |
4777 | 4845 |
4778 aboutText += tr("With Qt v%1 © The Qt Company").arg(QT_VERSION_STR); | 4846 aboutText += tr("With Qt v%1 © The Qt Company").arg(QT_VERSION_STR); |
4847 | |
4848 aboutText += "</small><small>"; | |
4779 | 4849 |
4780 #ifdef HAVE_JACK | 4850 #ifdef HAVE_JACK |
4781 #ifdef JACK_VERSION | 4851 #ifdef JACK_VERSION |
4782 aboutText += tr("<br>With JACK audio output library v%1 © Paul Davis and Jack O'Quin").arg(JACK_VERSION); | 4852 aboutText += tr("<br>With JACK audio output library v%1 © Paul Davis and Jack O'Quin").arg(JACK_VERSION); |
4783 #else // !JACK_VERSION | 4853 #else // !JACK_VERSION |
4854 aboutText += tr("<br>With liblo Lite OSC library v%1 © Steve Harris").arg(LIBLO_VERSION); | 4924 aboutText += tr("<br>With liblo Lite OSC library v%1 © Steve Harris").arg(LIBLO_VERSION); |
4855 #else // !LIBLO_VERSION | 4925 #else // !LIBLO_VERSION |
4856 aboutText += tr("<br>With liblo Lite OSC library © Steve Harris"); | 4926 aboutText += tr("<br>With liblo Lite OSC library © Steve Harris"); |
4857 #endif // LIBLO_VERSION | 4927 #endif // LIBLO_VERSION |
4858 | 4928 |
4859 if (m_oscQueue && m_oscQueue->isOK()) { | |
4860 aboutText += tr("</small><p><small>The OSC URL for this instance is: \"%1\"").arg(m_oscQueue->getOSCURL()); | |
4861 } | |
4862 | |
4863 aboutText += "</small></p>"; | 4929 aboutText += "</small></p>"; |
4864 #endif // HAVE_LIBLO | 4930 #endif // HAVE_LIBLO |
4865 | |
4866 #ifndef BUILD_STATIC | |
4867 aboutText.replace(tr("With "), tr("Using ")); | |
4868 #endif | |
4869 | 4931 |
4870 aboutText += | 4932 aboutText += |
4871 "<p><small>Sonic Visualiser Copyright © 2005–2017 Chris Cannam and " | 4933 "<p><small>Sonic Visualiser Copyright © 2005–2017 Chris Cannam and " |
4872 "Queen Mary, University of London.</small></p>" | 4934 "Queen Mary, University of London.</small></p>" |
4873 "<p><small>This program is free software; you can redistribute it and/or " | 4935 "<p><small>This program is free software; you can redistribute it and/or " |
4874 "modify it under the terms of the GNU General Public License as " | 4936 "modify it under the terms of the GNU General Public License as " |
4875 "published by the Free Software Foundation; either version 2 of the " | 4937 "published by the Free Software Foundation; either version 2 of the " |
4876 "License, or (at your option) any later version.<br>See the file " | 4938 "License, or (at your option) any later version.<br>See the file " |
4877 "COPYING included with this distribution for more information.</small></p>"; | 4939 "COPYING included with this distribution for more information.</small></p>"; |
4940 | |
4941 // use our own dialog so we can influence the size | |
4942 | |
4943 QDialog *d = new QDialog(this); | |
4944 | |
4945 d->setWindowTitle(tr("About %1").arg(QApplication::applicationName())); | |
4946 | |
4947 QGridLayout *layout = new QGridLayout; | |
4948 d->setLayout(layout); | |
4949 | |
4950 int row = 0; | |
4878 | 4951 |
4879 QMessageBox::about(this, tr("About Sonic Visualiser"), aboutText); | 4952 QLabel *iconLabel = new QLabel; |
4953 iconLabel->setPixmap(QApplication::windowIcon().pixmap(64, 64)); | |
4954 layout->addWidget(iconLabel, row, 0, Qt::AlignTop); | |
4955 | |
4956 QLabel *mainText = new QLabel(); | |
4957 layout->addWidget(mainText, row, 1, 1, 2); | |
4958 | |
4959 layout->setRowStretch(row, 10); | |
4960 layout->setColumnStretch(1, 10); | |
4961 | |
4962 ++row; | |
4963 | |
4964 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok); | |
4965 layout->addWidget(bb, row++, 0, 1, 3); | |
4966 connect(bb, SIGNAL(accepted()), d, SLOT(accept())); | |
4967 | |
4968 // mainText->setHtml(aboutText); | |
4969 // mainText->setReadOnly(true); | |
4970 mainText->setWordWrap(true); | |
4971 mainText->setOpenExternalLinks(true); | |
4972 mainText->setText(aboutText); | |
4973 | |
4974 d->setMinimumSize(m_viewManager->scalePixelSize(420), | |
4975 m_viewManager->scalePixelSize(200)); | |
4976 | |
4977 d->exec(); | |
4978 | |
4979 delete d; | |
4980 /* | |
4981 QMessageBox about(QMessageBox::Information, | |
4982 tr("About Sonic Visualiser"), | |
4983 aboutText, | |
4984 QMessageBox::StandardButtons(QMessageBox::Ok), | |
4985 this); | |
4986 | |
4987 QIcon icon = QApplication::windowIcon(); | |
4988 QSize size = icon.actualSize(QSize(64, 64)); | |
4989 about.setIconPixmap(icon.pixmap(size)); | |
4990 | |
4991 about.setMinimumSize(m_viewManager->scalePixelSize(400), | |
4992 m_viewManager->scalePixelSize(400)); | |
4993 | |
4994 about.exec(); | |
4995 */ | |
4880 } | 4996 } |
4881 | 4997 |
4882 void | 4998 void |
4883 MainWindow::keyReference() | 4999 MainWindow::keyReference() |
4884 { | 5000 { |
4886 } | 5002 } |
4887 | 5003 |
4888 void | 5004 void |
4889 MainWindow::newerVersionAvailable(QString version) | 5005 MainWindow::newerVersionAvailable(QString version) |
4890 { | 5006 { |
5007 m_newerVersionIs = version; | |
5008 | |
4891 QSettings settings; | 5009 QSettings settings; |
4892 settings.beginGroup("NewerVersionWarning"); | 5010 settings.beginGroup("NewerVersionWarning"); |
4893 QString tag = QString("version-%1-available-show").arg(version); | 5011 QString tag = QString("version-%1-available-show").arg(version); |
4894 if (settings.value(tag, true).toBool()) { | 5012 if (settings.value(tag, true).toBool()) { |
4895 QString title(tr("Newer version available")); | 5013 QString title(tr("Newer version available")); |