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

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

#
C++ | 131 lines | 85 code | 25 blank | 21 comment | 6 complexity | 8870ca992dd92055b44cabc4a15b86f2 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 "PasteNotationDialog.h"
  15. #include "commands/edit/PasteEventsCommand.h"
  16. #include <QDialog>
  17. #include <QDialogButtonBox>
  18. #include <QGroupBox>
  19. #include <QCheckBox>
  20. #include <QObject>
  21. #include <QRadioButton>
  22. #include <QWidget>
  23. #include <QVBoxLayout>
  24. #include <QUrl>
  25. #include <QDesktopServices>
  26. namespace Rosegarden
  27. {
  28. PasteNotationDialog::PasteNotationDialog(QWidget *parent,
  29. PasteEventsCommand::PasteType defaultType) :
  30. QDialog(parent),
  31. m_defaultType(defaultType)
  32. {
  33. //setHelp("nv-paste-types");
  34. setModal(true);
  35. setWindowTitle(tr("Paste"));
  36. QGridLayout *metagrid = new QGridLayout;
  37. setLayout(metagrid);
  38. QWidget *vbox = new QWidget(this);
  39. QVBoxLayout *vboxLayout = new QVBoxLayout;
  40. metagrid->addWidget(vbox, 0, 0);
  41. QGroupBox *pasteTypeGroup = new QGroupBox( tr("Paste type"), vbox );
  42. QVBoxLayout *pasteTypeGroupLayout = new QVBoxLayout;
  43. vboxLayout->addWidget(pasteTypeGroup);
  44. PasteEventsCommand::PasteTypeMap pasteTypes =
  45. PasteEventsCommand::getPasteTypes();
  46. for (PasteEventsCommand::PasteTypeMap::iterator i = pasteTypes.begin();
  47. i != pasteTypes.end(); ++i) {
  48. QRadioButton *button = new QRadioButton(i->second, pasteTypeGroup);
  49. pasteTypeGroupLayout->addWidget(button);
  50. button->setChecked(m_defaultType == i->first);
  51. QObject::connect(button, SIGNAL(clicked()),
  52. this, SLOT(slotPasteTypeChanged()));
  53. m_pasteTypeButtons.push_back(button);
  54. }
  55. pasteTypeGroup->setLayout(pasteTypeGroupLayout);
  56. QGroupBox *setAsDefaultGroup = new QGroupBox( tr("Options"), vbox );
  57. QVBoxLayout *setAsDefaultGroupLayout = new QVBoxLayout;
  58. vboxLayout->addWidget(setAsDefaultGroup);
  59. vbox->setLayout(vboxLayout);
  60. m_setAsDefaultButton = new QCheckBox
  61. (tr("Make this the default paste type"), setAsDefaultGroup);
  62. setAsDefaultGroupLayout->addWidget(m_setAsDefaultButton);
  63. m_setAsDefaultButton->setChecked(true);
  64. setAsDefaultGroup->setLayout(setAsDefaultGroupLayout);
  65. QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help );
  66. metagrid->addWidget(buttonBox, 1, 0);
  67. metagrid->setRowStretch(0, 10);
  68. connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
  69. connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
  70. connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(slotHelpRequested()));
  71. }
  72. PasteEventsCommand::PasteType
  73. PasteNotationDialog::getPasteType() const
  74. {
  75. for (unsigned int i = 0; i < m_pasteTypeButtons.size(); ++i) {
  76. if (m_pasteTypeButtons[i]->isChecked()) {
  77. return (PasteEventsCommand::PasteType)i;
  78. }
  79. }
  80. return PasteEventsCommand::Restricted;
  81. }
  82. bool
  83. PasteNotationDialog::setAsDefault() const
  84. {
  85. return m_setAsDefaultButton->isChecked();
  86. }
  87. void
  88. PasteNotationDialog::slotPasteTypeChanged()
  89. {
  90. m_setAsDefaultButton->setChecked(m_defaultType == getPasteType());
  91. }
  92. void
  93. PasteNotationDialog::slotHelpRequested()
  94. {
  95. // TRANSLATORS: if the manual is translated into your language, you can
  96. // change the two-letter language code in this URL to point to your language
  97. // version, eg. "http://rosegardenmusic.com/wiki/doc:pasteNotationDialog-es" for the
  98. // Spanish version. If your language doesn't yet have a translation, feel
  99. // free to create one.
  100. QString helpURL = tr("http://rosegardenmusic.com/wiki/doc:pasteNotationDialog-en");
  101. QDesktopServices::openUrl(QUrl(helpURL));
  102. }
  103. }
  104. #include "PasteNotationDialog.moc"