📄 eventfilterdialog.cpp
字号:
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: *//* Rosegarden A MIDI and audio sequencer and musical notation editor. This program is Copyright 2000-2007 Guillaume Laurent <glaurent@telegraph-road.org>, Chris Cannam <cannam@all-day-breakfast.com>, Richard Bown <richard.bown@ferventsoftware.com> This file is Copyright 2003-2006 D. Michael McIntyre <dmmcintyr@users.sourceforge.net> The moral rights of Guillaume Laurent, Chris Cannam, and Richard Bown to claim authorship of this work have been asserted. Other copyrights also apply to some parts of this work. Please see the AUTHORS file and individual file headers for details. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the file COPYING included with this distribution for more information.*/#include "EventFilterDialog.h"#include "misc/Debug.h"#include "base/BaseProperties.h"#include "base/Event.h"#include "base/NotationTypes.h"#include "base/BasicQuantizer.h"#include "gui/dialogs/PitchPickerDialog.h"#include "gui/editors/notation/NotationStrings.h"#include "gui/editors/notation/NotePixmapFactory.h"#include "document/ConfigGroups.h"#include <kapplication.h>#include <kconfig.h>#include <kdialogbase.h>#include <klocale.h>#include <qcheckbox.h>#include <qcombobox.h>#include <qdialog.h>#include <qframe.h>#include <qgroupbox.h>#include <qlabel.h>#include <qlayout.h>#include <qpixmap.h>#include <qpushbutton.h>#include <qsizepolicy.h>#include <qspinbox.h>#include <qstring.h>#include <qtooltip.h>#include <qvbox.h>#include <qwidget.h>namespace Rosegarden{EventFilterDialog::EventFilterDialog(QWidget* parent) : KDialogBase(parent, "eventfilerdialog", true, i18n("Event Filter"), Ok | Cancel, Ok), m_standardQuantizations(BasicQuantizer::getStandardQuantizations()){ cfg = kapp->config(); initDialog();}EventFilterDialog::~EventFilterDialog(){ // nothing here}voidEventFilterDialog::initDialog(){ QVBox* mainWidget = makeVBoxMainWidget(); //----------[ Note Filter Widgets ]------------------------- // Frame QGroupBox* noteFrame = new QGroupBox(i18n("Note Events"), mainWidget); QGridLayout* noteFrameLayout = new QGridLayout(noteFrame, 1, 1, 20, 6); // Labels QLabel* pitchFromLabel = new QLabel(i18n("lowest:"), noteFrame); noteFrameLayout->addWidget(pitchFromLabel, 0, 2); QLabel* pitchToLabel = new QLabel(i18n("highest:"), noteFrame); noteFrameLayout->addWidget(pitchToLabel, 0, 4); QLabel* pitchLabel = new QLabel(i18n("Pitch:"), noteFrame); noteFrameLayout->addWidget(pitchLabel, 1, 1); QLabel* velocityLabel = new QLabel(i18n("Velocity:"), noteFrame); noteFrameLayout->addWidget(velocityLabel, 2, 1); QLabel* durationLabel = new QLabel(i18n("Duration:"), noteFrame); noteFrameLayout->addWidget(durationLabel, 3, 1); // Include Boxes m_notePitchIncludeComboBox = new QComboBox(0, noteFrame); m_notePitchIncludeComboBox->insertItem(i18n("include")); m_notePitchIncludeComboBox->insertItem(i18n("exclude")); cfg->setGroup(EventFilterDialogConfigGroup); m_notePitchIncludeComboBox->setCurrentItem(cfg->readBoolEntry("pitchinclude", 0)); noteFrameLayout->addWidget(m_notePitchIncludeComboBox, 1, 0); m_noteVelocityIncludeComboBox = new QComboBox(0, noteFrame); m_noteVelocityIncludeComboBox->insertItem(i18n("include")); m_noteVelocityIncludeComboBox->insertItem(i18n("exclude")); cfg->setGroup(EventFilterDialogConfigGroup); m_noteVelocityIncludeComboBox->setCurrentItem(cfg->readBoolEntry("velocityinclude", 0)); noteFrameLayout->addWidget(m_noteVelocityIncludeComboBox, 2, 0); m_noteDurationIncludeComboBox = new QComboBox(0, noteFrame); m_noteDurationIncludeComboBox->insertItem(i18n("include")); m_noteDurationIncludeComboBox->insertItem(i18n("exclude")); cfg->setGroup(EventFilterDialogConfigGroup); m_noteDurationIncludeComboBox->setCurrentItem(cfg->readBoolEntry("durationinclude", 0)); noteFrameLayout->addWidget(m_noteDurationIncludeComboBox, 3, 0); // Pitch From m_pitchFromSpinBox = new QSpinBox(noteFrame); m_pitchFromSpinBox->setMaxValue(127); cfg->setGroup(EventFilterDialogConfigGroup); m_pitchFromSpinBox->setValue(cfg->readUnsignedNumEntry("pitchfrom", 0)); noteFrameLayout->addWidget(m_pitchFromSpinBox, 1, 2); connect(m_pitchFromSpinBox, SIGNAL(valueChanged(int)), SLOT(slotPitchFromChanged(int))); m_pitchFromChooserButton = new QPushButton(i18n("edit"), noteFrame); m_pitchFromChooserButton->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, m_pitchFromChooserButton-> sizePolicy().hasHeightForWidth())); QToolTip::add (m_pitchFromChooserButton, i18n("choose a pitch using a staff")); noteFrameLayout->addWidget(m_pitchFromChooserButton, 1, 3); connect(m_pitchFromChooserButton, SIGNAL(clicked()), SLOT(slotPitchFromChooser())); // Pitch To m_pitchToSpinBox = new QSpinBox(noteFrame); m_pitchToSpinBox->setMaxValue(127); cfg->setGroup(EventFilterDialogConfigGroup); m_pitchToSpinBox->setValue(cfg->readUnsignedNumEntry("pitchto", 127)); noteFrameLayout->addWidget(m_pitchToSpinBox, 1, 4); connect(m_pitchToSpinBox, SIGNAL(valueChanged(int)), SLOT(slotPitchToChanged(int))); m_pitchToChooserButton = new QPushButton(i18n("edit"), noteFrame); QToolTip::add (m_pitchToChooserButton, i18n("choose a pitch using a staff")); noteFrameLayout->addWidget(m_pitchToChooserButton, 1, 5); connect(m_pitchToChooserButton, SIGNAL(clicked()), SLOT(slotPitchToChooser())); // Velocity From/To m_velocityFromSpinBox = new QSpinBox(noteFrame); m_velocityFromSpinBox->setMaxValue(127); cfg->setGroup(EventFilterDialogConfigGroup); m_velocityFromSpinBox->setValue(cfg->readUnsignedNumEntry("velocityfrom", 0)); noteFrameLayout->addWidget(m_velocityFromSpinBox, 2, 2); connect(m_velocityFromSpinBox, SIGNAL(valueChanged(int)), SLOT(slotVelocityFromChanged(int))); m_velocityToSpinBox = new QSpinBox(noteFrame); m_velocityToSpinBox->setMaxValue(127); cfg->setGroup(EventFilterDialogConfigGroup); m_velocityToSpinBox->setValue(cfg->readUnsignedNumEntry("velocityto", 127)); noteFrameLayout->addWidget( m_velocityToSpinBox, 2, 4 ); connect(m_velocityToSpinBox, SIGNAL(valueChanged(int)), SLOT(slotVelocityToChanged(int))); // Duration From/To m_noteDurationFromComboBox = new QComboBox(0, noteFrame); m_noteDurationFromComboBox->insertItem(i18n("longest")); noteFrameLayout->addWidget(m_noteDurationFromComboBox, 3, 2); connect(m_noteDurationFromComboBox, SIGNAL(activated(int)), SLOT(slotDurationFromChanged(int))); m_noteDurationToComboBox = new QComboBox(0, noteFrame); m_noteDurationToComboBox->insertItem(i18n("longest")); noteFrameLayout->addWidget(m_noteDurationToComboBox, 3, 4); connect(m_noteDurationToComboBox, SIGNAL(activated(int)), SLOT(slotDurationToChanged(int))); populateDurationCombos(); //---------[ Buttons ]-------------------------------------- QFrame* privateLayoutWidget = new QFrame(mainWidget); QGridLayout* buttonLayout = new QGridLayout(privateLayoutWidget, 1, 1, 20, 6); m_buttonAll = new QPushButton(i18n("Include all"), privateLayoutWidget); m_buttonAll->setAutoDefault(true); QToolTip::add (m_buttonAll, i18n("Include entire range of values")); buttonLayout->addWidget( m_buttonAll, 0, 0 ); m_buttonNone = new QPushButton(i18n("Exclude all"), privateLayoutWidget); m_buttonNone->setAutoDefault(true); QToolTip::add (m_buttonNone, i18n("Exclude entire range of values")); buttonLayout->addWidget( m_buttonNone, 0, 1 ); connect(m_buttonAll, SIGNAL(clicked()), this, SLOT(slotToggleAll())); connect(m_buttonNone, SIGNAL(clicked()), this, SLOT(slotToggleNone()));}voidEventFilterDialog::populateDurationCombos(){ QPixmap noMap = NotePixmapFactory::toQPixmap (NotePixmapFactory::makeToolbarPixmap("menu-no-note")); for (unsigned int i = 0; i < m_standardQuantizations.size(); ++i) { timeT time = m_standardQuantizations[i]; timeT error = 0; QString label = NotationStrings::makeNoteMenuLabel(time, true, error); QPixmap pmap = NotePixmapFactory::toQPixmap (NotePixmapFactory::makeNoteMenuPixmap(time, error)); m_noteDurationFromComboBox->insertItem(error ? noMap : pmap, label); m_noteDurationToComboBox ->insertItem(error ? noMap : pmap, label); } m_noteDurationFromComboBox->insertItem(noMap, i18n("shortest")); m_noteDurationToComboBox->insertItem(noMap, i18n("shortest")); cfg->setGroup(EventFilterDialogConfigGroup); m_noteDurationFromComboBox->setCurrentItem( cfg->readUnsignedNumEntry("durationfrom", 0)); m_noteDurationToComboBox->setCurrentItem(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -