simpleeventeditdialog.cpp

来自「LINUX下的混音软件」· C++ 代码 · 共 1,030 行 · 第 1/3 页

CPP
1,030
字号
/* -*- 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>     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 "SimpleEventEditDialog.h"#include <qlayout.h>#include "base/BaseProperties.h"#include "base/Event.h"#include "base/MidiTypes.h"#include "base/NotationTypes.h"#include "document/RosegardenGUIDoc.h"#include "gui/editors/guitar/Chord.h"#include "misc/Strings.h"#include "PitchDialog.h"#include "TimeDialog.h"#include <kcombobox.h>#include <kdialogbase.h>#include <kfiledialog.h>#include <klocale.h>#include <qcheckbox.h>#include <qdialog.h>#include <qfile.h>#include <qframe.h>#include <qgroupbox.h>#include <qlabel.h>#include <qlineedit.h>#include <qpushbutton.h>#include <qspinbox.h>#include <qstring.h>#include <qvbox.h>#include <qwidget.h>namespace Rosegarden{SimpleEventEditDialog::SimpleEventEditDialog(QWidget *parent,        RosegardenGUIDoc *doc,        const Event &event,        bool inserting) :        KDialogBase(parent, 0, true,                    i18n(inserting ? "Insert Event" : "Edit Event"), Ok | Cancel),        m_event(event),        m_doc(doc),        m_type(event.getType()),        m_absoluteTime(event.getAbsoluteTime()),        m_duration(event.getDuration()),        m_modified(false){    QVBox *vbox = makeVBoxMainWidget();    QGroupBox *groupBox = new QGroupBox                          (1, Horizontal, i18n("Event Properties"), vbox);    QFrame *frame = new QFrame(groupBox);    QGridLayout *layout = new QGridLayout(frame, 7, 3, 5, 5);    layout->addWidget(new QLabel(i18n("Event type:"), frame), 0, 0);    if (inserting) {        m_typeLabel = 0;        m_typeCombo = new KComboBox(frame);        layout->addWidget(m_typeCombo, 0, 1);        m_typeCombo->insertItem(strtoqstr(Note::EventType));        m_typeCombo->insertItem(strtoqstr(Controller::EventType));        m_typeCombo->insertItem(strtoqstr(KeyPressure::EventType));        m_typeCombo->insertItem(strtoqstr(ChannelPressure::EventType));        m_typeCombo->insertItem(strtoqstr(ProgramChange::EventType));        m_typeCombo->insertItem(strtoqstr(SystemExclusive::EventType));        m_typeCombo->insertItem(strtoqstr(PitchBend::EventType));        m_typeCombo->insertItem(strtoqstr(Indication::EventType));        m_typeCombo->insertItem(strtoqstr(Text::EventType));        m_typeCombo->insertItem(strtoqstr(Note::EventRestType));        m_typeCombo->insertItem(strtoqstr(Clef::EventType));        m_typeCombo->insertItem(strtoqstr(::Rosegarden::Key::EventType));        m_typeCombo->insertItem(strtoqstr(Guitar::Chord::EventType));        // Connect up the combos        //        connect(m_typeCombo, SIGNAL(activated(int)),                SLOT(slotEventTypeChanged(int)));    } else {        m_typeCombo = 0;        m_typeLabel = new QLabel(frame);        layout->addWidget(m_typeLabel, 0, 1);    }    m_timeLabel = new QLabel(i18n("Absolute time:"), frame);    layout->addWidget(m_timeLabel, 1, 0);    m_timeSpinBox = new QSpinBox(INT_MIN, INT_MAX, Note(Note::Shortest).getDuration(), frame);    m_timeEditButton = new QPushButton("edit", frame);    layout->addWidget(m_timeSpinBox, 1, 1);    layout->addWidget(m_timeEditButton, 1, 2);    connect(m_timeSpinBox, SIGNAL(valueChanged(int)),            SLOT(slotAbsoluteTimeChanged(int)));    connect(m_timeEditButton, SIGNAL(released()),            SLOT(slotEditAbsoluteTime()));    m_durationLabel = new QLabel(i18n("Duration:"), frame);    layout->addWidget(m_durationLabel, 2, 0);    m_durationSpinBox = new QSpinBox(0, INT_MAX, Note(Note::Shortest).getDuration(), frame);    m_durationEditButton = new QPushButton("edit", frame);    layout->addWidget(m_durationSpinBox, 2, 1);    layout->addWidget(m_durationEditButton, 2, 2);    connect(m_durationSpinBox, SIGNAL(valueChanged(int)),            SLOT(slotDurationChanged(int)));    connect(m_durationEditButton, SIGNAL(released()),            SLOT(slotEditDuration()));    m_pitchLabel = new QLabel(i18n("Pitch:"), frame);    layout->addWidget(m_pitchLabel, 3, 0);    m_pitchSpinBox = new QSpinBox(frame);    m_pitchEditButton = new QPushButton("edit", frame);    layout->addWidget(m_pitchSpinBox, 3, 1);    layout->addWidget(m_pitchEditButton, 3, 2);    connect(m_pitchSpinBox, SIGNAL(valueChanged(int)),            SLOT(slotPitchChanged(int)));    connect(m_pitchEditButton, SIGNAL(released()),            SLOT(slotEditPitch()));    m_pitchSpinBox->setMinValue(MidiMinValue);    m_pitchSpinBox->setMaxValue(MidiMaxValue);    m_controllerLabel = new QLabel(i18n("Controller name:"), frame);    m_controllerLabelValue = new QLabel(i18n("<none>"), frame);    m_controllerLabelValue->setAlignment(QLabel::AlignRight);    layout->addWidget(m_controllerLabel, 4, 0);    layout->addWidget(m_controllerLabelValue, 4, 1);    m_velocityLabel = new QLabel(i18n("Velocity:"), frame);    layout->addWidget(m_velocityLabel, 5, 0);    m_velocitySpinBox = new QSpinBox(frame);    layout->addWidget(m_velocitySpinBox, 5, 1);    connect(m_velocitySpinBox, SIGNAL(valueChanged(int)),            SLOT(slotVelocityChanged(int)));    m_velocitySpinBox->setMinValue(MidiMinValue);    m_velocitySpinBox->setMaxValue(MidiMaxValue);    m_metaLabel = new QLabel(i18n("Meta string:"), frame);    layout->addWidget(m_metaLabel, 6, 0);    m_metaEdit = new QLineEdit(frame);    layout->addWidget(m_metaEdit, 6, 1);    m_sysexLoadButton = new QPushButton(i18n("Load data"), frame);    layout->addWidget(m_sysexLoadButton, 6, 2);    m_sysexSaveButton = new QPushButton(i18n("Save data"), frame);    layout->addWidget(m_sysexSaveButton, 4, 2);    connect(m_metaEdit, SIGNAL(textChanged(const QString &)),            SLOT(slotMetaChanged(const QString &)));    connect(m_sysexLoadButton, SIGNAL(released()),            SLOT(slotSysexLoad()));    connect(m_sysexSaveButton, SIGNAL(released()),            SLOT(slotSysexSave()));    m_notationGroupBox = new QGroupBox                         (1, Horizontal, i18n("Notation Properties"), vbox);    frame = new QFrame(m_notationGroupBox);    layout = new QGridLayout(frame, 3, 3, 5, 5);    m_lockNotationValues = new QCheckBox(i18n("Lock to changes in performed values"), frame);    layout->addMultiCellWidget(m_lockNotationValues, 0, 0, 0, 2);    m_lockNotationValues->setChecked(true);    connect(m_lockNotationValues, SIGNAL(released()),            SLOT(slotLockNotationChanged()));    m_notationTimeLabel = new QLabel(i18n("Notation time:"), frame);    layout->addWidget(m_notationTimeLabel, 1, 0);    m_notationTimeSpinBox = new QSpinBox(INT_MIN, INT_MAX, Note(Note::Shortest).getDuration(), frame);    m_notationTimeEditButton = new QPushButton("edit", frame);    layout->addWidget(m_notationTimeSpinBox, 1, 1);    layout->addWidget(m_notationTimeEditButton, 1, 2);    connect(m_notationTimeSpinBox, SIGNAL(valueChanged(int)),            SLOT(slotNotationAbsoluteTimeChanged(int)));    connect(m_notationTimeEditButton, SIGNAL(released()),            SLOT(slotEditNotationAbsoluteTime()));    m_notationDurationLabel = new QLabel(i18n("Notation duration:"), frame);    layout->addWidget(m_notationDurationLabel, 2, 0);    m_notationDurationSpinBox = new QSpinBox(0, INT_MAX, Note(Note::Shortest).getDuration(), frame);    m_notationDurationEditButton = new QPushButton("edit", frame);    layout->addWidget(m_notationDurationSpinBox, 2, 1);    layout->addWidget(m_notationDurationEditButton, 2, 2);    connect(m_notationDurationSpinBox, SIGNAL(valueChanged(int)),            SLOT(slotNotationDurationChanged(int)));    connect(m_notationDurationEditButton, SIGNAL(released()),            SLOT(slotEditNotationDuration()));    setupForEvent();}voidSimpleEventEditDialog::setupForEvent(){    using BaseProperties::PITCH;    using BaseProperties::VELOCITY;    if (m_typeCombo) {        m_typeCombo->blockSignals(true);    }    m_timeSpinBox->blockSignals(true);    m_notationTimeSpinBox->blockSignals(true);    m_durationSpinBox->blockSignals(true);    m_notationDurationSpinBox->blockSignals(true);    m_pitchSpinBox->blockSignals(true);    m_velocitySpinBox->blockSignals(true);    m_metaEdit->blockSignals(true);    // Some common settings    //    m_durationLabel->setText(i18n("Absolute time:"));    m_timeLabel->show();    m_timeSpinBox->show();    m_timeEditButton->show();    m_timeSpinBox->setValue(m_event.getAbsoluteTime());    m_durationLabel->setText(i18n("Duration:"));    m_durationLabel->show();    m_durationSpinBox->show();    m_durationEditButton->show();    m_durationSpinBox->setValue(m_event.getDuration());    m_notationGroupBox->hide();    m_lockNotationValues->setChecked(true);    if (m_typeLabel)        m_typeLabel->setText(strtoqstr(m_event.getType()));    m_absoluteTime = m_event.getAbsoluteTime();    m_notationAbsoluteTime = m_event.getNotationAbsoluteTime();    m_duration = m_event.getDuration();    m_notationDuration = m_event.getNotationDuration();    m_sysexLoadButton->hide();    m_sysexSaveButton->hide();    if (m_type == Note::EventType) {        m_notationGroupBox->show();        m_notationTimeSpinBox->setValue(m_notationAbsoluteTime);        m_notationDurationSpinBox->setValue(m_notationDuration);        m_pitchLabel->show();        m_pitchLabel->setText(i18n("Note pitch:"));        m_pitchSpinBox->show();        m_pitchEditButton->show();        m_controllerLabel->hide();        m_controllerLabelValue->hide();        m_velocityLabel->show();        m_velocityLabel->setText(i18n("Note velocity:"));        m_velocitySpinBox->show();        m_metaLabel->hide();        m_metaEdit->hide();        try {            m_pitchSpinBox->setValue(m_event.get<Int>(PITCH));        } catch (Event::NoData) {            m_pitchSpinBox->setValue(60);        }        try {            m_velocitySpinBox->setValue(m_event.get<Int>(VELOCITY));        } catch (Event::NoData) {            m_velocitySpinBox->setValue(100);        }        if (m_typeCombo)            m_typeCombo->setCurrentItem(0);    } else if (m_type == Controller::EventType) {        m_durationLabel->hide();        m_durationSpinBox->hide();        m_durationEditButton->hide();        m_pitchLabel->show();        m_pitchLabel->setText(i18n("Controller number:"));        m_pitchSpinBox->show();        m_pitchEditButton->hide();        m_controllerLabel->show();        m_controllerLabelValue->show();        m_controllerLabel->setText(i18n("Controller name:"));        m_velocityLabel->show();        m_velocityLabel->setText(i18n("Controller value:"));        m_velocitySpinBox->show();        m_metaLabel->hide();        m_metaEdit->hide();        try {            m_pitchSpinBox->setValue(m_event.get<Int>                                     (Controller::NUMBER));        } catch (Event::NoData) {            m_pitchSpinBox->setValue(0);        }        try {            m_velocitySpinBox->setValue(m_event.get<Int>                                        (Controller::VALUE));        } catch (Event::NoData) {            m_velocitySpinBox->setValue(0);        }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?