PageRenderTime 43ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/rosegarden-12.04/src/gui/dialogs/InterpretDialog.cpp

#
C++ | 153 lines | 109 code | 23 blank | 21 comment | 6 complexity | 89da87af64fed8df647327aca4ed3dd9 MD5 | raw file
Possible License(s): GPL-2.0
  1. /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
  2. /*
  3. Rosegarden
  4. A MIDI and audio sequencer and musical notation editor.
  5. Copyright 2000-2012 the Rosegarden development team.
  6. Other copyrights also apply to some parts of this work. Please
  7. see the AUTHORS file and individual file headers for details.
  8. This program is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU General Public License as
  10. published by the Free Software Foundation; either version 2 of the
  11. License, or (at your option) any later version. See the file
  12. COPYING included with this distribution for more information.
  13. */
  14. #include "InterpretDialog.h"
  15. #include <QApplication>
  16. #include "misc/ConfigGroups.h"
  17. #include "commands/notation/InterpretCommand.h"
  18. #include "misc/Strings.h"
  19. #include <QSettings>
  20. #include <QDialog>
  21. #include <QDialogButtonBox>
  22. #include <QCheckBox>
  23. #include <QGroupBox>
  24. #include <QWidget>
  25. #include <QVBoxLayout>
  26. #include <QUrl>
  27. #include <QDesktopServices>
  28. namespace Rosegarden
  29. {
  30. InterpretDialog::InterpretDialog(QWidget *parent) :
  31. QDialog(parent)
  32. {
  33. //setHelp("nv-interpret");
  34. setModal(true);
  35. setWindowTitle(tr("Interpret"));
  36. QGridLayout *metagrid = new QGridLayout;
  37. setLayout(metagrid);
  38. QGroupBox *vbox = new QGroupBox(tr("Interpretations to apply"), this);
  39. QVBoxLayout *vboxLayout = new QVBoxLayout;
  40. metagrid->addWidget(vbox, 0, 0);
  41. m_applyTextDynamics = new QCheckBox
  42. (tr("Apply text dynamics (p, mf, ff etc)"));
  43. vboxLayout->addWidget(m_applyTextDynamics);
  44. m_applyHairpins = new QCheckBox
  45. (tr("Apply hairpin dynamics"));
  46. vboxLayout->addWidget(m_applyHairpins);
  47. m_stressBeats = new QCheckBox
  48. (tr("Stress beats"));
  49. vboxLayout->addWidget(m_stressBeats);
  50. m_articulate = new QCheckBox
  51. (tr("Articulate slurs, staccato, tenuto etc"));
  52. vboxLayout->addWidget(m_articulate);
  53. m_allInterpretations = new QCheckBox
  54. (tr("All available interpretations"));
  55. vboxLayout->addWidget(m_allInterpretations);
  56. vbox->setLayout(vboxLayout);
  57. QSettings settings;
  58. settings.beginGroup( NotationViewConfigGroup );
  59. m_allInterpretations->setChecked
  60. ( qStrToBool( settings.value("interpretall", "true" ) ) );
  61. m_applyTextDynamics->setChecked
  62. ( qStrToBool( settings.value("interprettextdynamics", "true" ) ) );
  63. m_applyHairpins->setChecked
  64. ( qStrToBool( settings.value("interprethairpins", "true" ) ) );
  65. m_stressBeats->setChecked
  66. ( qStrToBool( settings.value("interpretstressbeats", "true" ) ) );
  67. m_articulate->setChecked
  68. ( qStrToBool( settings.value("interpretarticulate", "true" ) ) );
  69. connect(m_allInterpretations,
  70. SIGNAL(clicked()), this, SLOT(slotAllBoxChanged()));
  71. slotAllBoxChanged();
  72. QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help);
  73. metagrid->addWidget(buttonBox, 1, 0);
  74. metagrid->setRowStretch(0, 10);
  75. connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
  76. connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
  77. connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(slotHelpRequested()));
  78. settings.endGroup();
  79. }
  80. void
  81. InterpretDialog::slotAllBoxChanged()
  82. {
  83. bool all = m_allInterpretations->isChecked();
  84. m_applyTextDynamics->setEnabled(!all);
  85. m_applyHairpins->setEnabled(!all);
  86. m_stressBeats->setEnabled(!all);
  87. m_articulate->setEnabled(!all);
  88. }
  89. int
  90. InterpretDialog::getInterpretations()
  91. {
  92. QSettings settings;
  93. settings.beginGroup( NotationViewConfigGroup );
  94. settings.setValue("interpretall", m_allInterpretations->isChecked());
  95. settings.setValue("interprettextdynamics", m_applyTextDynamics->isChecked());
  96. settings.setValue("interprethairpins", m_applyHairpins->isChecked());
  97. settings.setValue("interpretstressbeats", m_stressBeats->isChecked());
  98. settings.setValue("interpretarticulate", m_articulate->isChecked());
  99. settings.endGroup();
  100. if (m_allInterpretations->isChecked()) {
  101. return InterpretCommand::AllInterpretations;
  102. } else {
  103. int in = 0;
  104. if (m_applyTextDynamics->isChecked())
  105. in |= InterpretCommand::ApplyTextDynamics;
  106. if (m_applyHairpins->isChecked())
  107. in |= InterpretCommand::ApplyHairpins;
  108. if (m_stressBeats->isChecked())
  109. in |= InterpretCommand::StressBeats;
  110. if (m_articulate->isChecked()) {
  111. in |= InterpretCommand::Articulate;
  112. }
  113. return in;
  114. }
  115. }
  116. void
  117. InterpretDialog::slotHelpRequested()
  118. {
  119. // TRANSLATORS: if the manual is translated into your language, you can
  120. // change the two-letter language code in this URL to point to your language
  121. // version, eg. "http://rosegardenmusic.com/wiki/doc:interpretDialog-es" for the
  122. // Spanish version. If your language doesn't yet have a translation, feel
  123. // free to create one.
  124. QString helpURL = tr("http://rosegardenmusic.com/wiki/doc:interpretDialog-en");
  125. QDesktopServices::openUrl(QUrl(helpURL));
  126. }
  127. }
  128. #include "InterpretDialog.moc"