1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 3 /* 4 Rosegarden 5 A MIDI and audio sequencer and musical notation editor. 6 Copyright 2000-2021 the Rosegarden development team. 7 8 Other copyrights also apply to some parts of this work. Please 9 see the AUTHORS file and individual file headers for details. 10 11 This program is free software; you can redistribute it and/or 12 modify it under the terms of the GNU General Public License as 13 published by the Free Software Foundation; either version 2 of the 14 License, or (at your option) any later version. See the file 15 COPYING included with this distribution for more information. 16 */ 17 18 #include "WarningDialog.h" 19 20 #include "gui/general/IconLoader.h" 21 22 #include <QDialog> 23 #include <QTabWidget> 24 #include <QVBoxLayout> 25 #include <QLabel> 26 #include <QDialogButtonBox> 27 #include <QIcon> 28 29 #include <iostream> 30 31 namespace Rosegarden 32 { 33 34 WarningDialog(QWidget * parent)35WarningDialog::WarningDialog(QWidget *parent) : 36 QDialog(parent) 37 { 38 QVBoxLayout *layout = new QVBoxLayout; 39 setLayout(layout); 40 41 m_tabWidget = new QTabWidget; 42 layout->addWidget(m_tabWidget); 43 44 QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok); 45 layout->addWidget(buttonBox); 46 connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); 47 48 setWindowTitle(tr("Performance Problems Detected")); 49 setWindowIcon(IconLoader::load("warning")); 50 } 51 ~WarningDialog()52WarningDialog::~WarningDialog() 53 { 54 } 55 56 void addWarning(Message message)57WarningDialog::addWarning(Message message) 58 { 59 QWidget *tab = new QWidget; 60 QVBoxLayout *layout = new QVBoxLayout; 61 layout->setAlignment(Qt::AlignTop); 62 tab->setLayout(layout); 63 64 QLabel *text = new QLabel(message.first.first); 65 text->setWordWrap(true); 66 layout->addWidget(text); 67 68 QLabel *informativeText = new QLabel(message.first.second); 69 informativeText->setWordWrap(true); 70 layout->addWidget(informativeText); 71 72 informativeText->setOpenExternalLinks(true); 73 74 QIcon icon = IconLoader::load("warning"); 75 QString headline(tr("Warning")); 76 77 switch (message.second) { 78 case Midi: 79 icon = IconLoader::load("midi-nok"); 80 headline = tr("MIDI"); 81 break; 82 case Audio: 83 icon = IconLoader::load("audio-nok"); 84 headline = tr("Audio"); 85 break; 86 case Timer: 87 icon = IconLoader::load("timer-nok"); 88 headline = tr("System timer"); 89 break; 90 case Info: 91 icon = IconLoader::load("messagebox-information"); 92 headline = tr("Information"); 93 break; 94 case Other: 95 default: 96 // icon and text were initialized suitable for this case, so there's 97 // nothing to do here 98 break; 99 } 100 101 m_tabWidget->addTab(tab, icon, headline); 102 } 103 104 105 } 106 107