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 19 #include "FileMergeDialog.h" 20 21 #include <QComboBox> 22 #include <QDialog> 23 #include <QDialogButtonBox> 24 #include <QCheckBox> 25 #include <QLabel> 26 #include <QString> 27 #include <QWidget> 28 #include <QVBoxLayout> 29 #include <QHBoxLayout> 30 #include <QUrl> 31 #include <QDesktopServices> 32 #include "document/RosegardenDocument.h" 33 34 35 namespace Rosegarden 36 { 37 38 FileMergeDialog::FileMergeDialog(QWidget *parent, 39 QString /*fileName*/, 40 bool timingsDiffer) : 41 QDialog(parent) 42 { 43 setModal(true); 44 setWindowTitle(tr("Merge File")); 45 46 QVBoxLayout *layout = new QVBoxLayout; 47 setLayout(layout); 48 49 50 QWidget *hbox = new QWidget; 51 QHBoxLayout *hboxLayout = new QHBoxLayout; 52 hbox->setLayout(hboxLayout); 53 layout->addWidget(hbox); 54 hboxLayout->addWidget(new QLabel(tr("Merge new file "))); 55 56 m_choice = new QComboBox; 57 hboxLayout->addWidget(m_choice); 58 hbox->setLayout(hboxLayout); 59 m_choice->addItem(tr("At start of existing composition")); 60 m_choice->addItem(tr("From end of existing composition")); 61 m_useTimings = nullptr; 62 63 if (timingsDiffer) { 64 layout->addWidget(new QLabel(tr("The file has different time signatures or tempos."))); 65 m_useTimings = new QCheckBox(tr("Import these as well")); 66 layout->addWidget(m_useTimings); 67 m_useTimings->setChecked(false); 68 } 69 QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help); 70 connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); 71 connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); 72 connect(buttonBox, &QDialogButtonBox::helpRequested, this, &FileMergeDialog::slotHelpRequested); 73 layout->addWidget(buttonBox); 74 } 75 76 int 77 FileMergeDialog::getMergeOptions() 78 { 79 int options = MERGE_KEEP_OLD_TIMINGS | MERGE_IN_NEW_TRACKS; 80 81 if (m_choice->currentIndex() == 1) { 82 options |= MERGE_AT_END; 83 } 84 85 if (m_useTimings && m_useTimings->isChecked()) { 86 options |= MERGE_KEEP_NEW_TIMINGS; 87 } 88 89 return options; 90 } 91 92 93 void 94 FileMergeDialog::slotHelpRequested() 95 { 96 // TRANSLATORS: if the manual is translated into your language, you can 97 // change the two-letter language code in this URL to point to your language 98 // version, eg. "http://rosegardenmusic.com/wiki/doc:fileMergeDialog-es" for the 99 // Spanish version. If your language doesn't yet have a translation, feel 100 // free to create one. 101 QString helpURL = tr("http://rosegardenmusic.com/wiki/doc:fileMergeDialog-en"); 102 QDesktopServices::openUrl(QUrl(helpURL)); 103 } 104 } 105