⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timewidget.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* -*- 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 "TimeWidget.h"#include <qlayout.h>#include <klocale.h>#include "misc/Debug.h"#include "base/Composition.h"#include "base/NotationTypes.h"#include "base/RealTime.h"#include "gui/editors/notation/NotationStrings.h"#include "gui/editors/notation/NotePixmapFactory.h"#include <qcombobox.h>#include <qframe.h>#include <qgroupbox.h>#include <qlabel.h>#include <qlineedit.h>#include <qpixmap.h>#include <qspinbox.h>#include <qstring.h>#include <qwidget.h>namespace Rosegarden{TimeWidget::TimeWidget(QString title,                       QWidget *parent,                       Composition *composition,                       timeT absTime,                       bool editable,                       bool constrainToCompositionDuration) :        QGroupBox(1, Horizontal, title, parent),        m_composition(composition),        m_isDuration(false),        m_constrain(constrainToCompositionDuration),        m_time(absTime),        m_startTime(0),        m_defaultTime(absTime){    init(editable);}TimeWidget::TimeWidget(QString title,                       QWidget *parent,                       Composition *composition,                       timeT startTime,                       timeT duration,                       bool editable,                       bool constrainToCompositionDuration) :        QGroupBox(1, Horizontal, title, parent),        m_composition(composition),        m_isDuration(true),        m_constrain(constrainToCompositionDuration),        m_time(duration),        m_startTime(startTime),        m_defaultTime(duration){    init(editable);}voidTimeWidget::init(bool editable){    int denoms[] = {                       1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128                   };    bool savedEditable = editable;    editable = true;    QFrame *frame = new QFrame(this);    QGridLayout *layout = new QGridLayout(frame, 7, 3, 5, 5);    QLabel *label = 0;    if (m_isDuration) {        label = new QLabel(i18n("Note:"), frame);        label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);        layout->addWidget(label, 0, 0);        if (editable) {            m_note = new QComboBox(frame);            m_noteDurations.push_back(0);            m_note->insertItem(i18n("<inexact>"));            for (size_t i = 0; i < sizeof(denoms) / sizeof(denoms[0]); ++i) {                timeT duration =                    Note(Note::Breve).getDuration() / denoms[i];                if (denoms[i] > 1 && denoms[i] < 128 && (denoms[i] % 3) != 0) {                    // not breve or hemidemi, not a triplet                    timeT dottedDuration = duration * 3 / 2;                    m_noteDurations.push_back(dottedDuration);                    timeT error = 0;                    QString label = NotationStrings::makeNoteMenuLabel                                    (dottedDuration, false, error);                    QPixmap pmap = NotePixmapFactory::toQPixmap                                   (NotePixmapFactory::makeNoteMenuPixmap(dottedDuration, error));                    m_note->insertItem(pmap, label); // ignore error                }                m_noteDurations.push_back(duration);                timeT error = 0;                QString label = NotationStrings::makeNoteMenuLabel                                (duration, false, error);                QPixmap pmap = NotePixmapFactory::toQPixmap                               (NotePixmapFactory::makeNoteMenuPixmap(duration, error));                m_note->insertItem(pmap, label); // ignore error            }            connect(m_note, SIGNAL(activated(int)),                    this, SLOT(slotNoteChanged(int)));            layout->addMultiCellWidget(m_note, 0, 0, 1, 3);        } else {            m_note = 0;            timeT error = 0;            QString label = NotationStrings::makeNoteMenuLabel                            (m_time, false, error);            if (error != 0)                label = i18n("<inexact>");            QLineEdit *le = new QLineEdit(label, frame);            le->setReadOnly(true);            layout->addMultiCellWidget(le, 0, 0, 1, 3);        }        label = new QLabel(i18n("Units:"), frame);        label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);        layout->addWidget(label, 0, 4);        if (editable) {            m_timeT = new QSpinBox(frame);            m_timeT->setLineStep            (Note(Note::Shortest).getDuration());            connect(m_timeT, SIGNAL(valueChanged(int)),                    this, SLOT(slotTimeTChanged(int)));            layout->addWidget(m_timeT, 0, 5);        } else {            m_timeT = 0;            QLineEdit *le = new QLineEdit(QString("%1").arg(m_time), frame);            le->setReadOnly(true);            layout->addWidget(le, 0, 5);        }    } else {        m_note = 0;        label = new QLabel(i18n("Time:"), frame);        label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);        layout->addWidget(label, 0, 0);        if (editable) {            m_timeT = new QSpinBox(frame);            m_timeT->setLineStep            (Note(Note::Shortest).getDuration());            connect(m_timeT, SIGNAL(valueChanged(int)),                    this, SLOT(slotTimeTChanged(int)));            layout->addWidget(m_timeT, 0, 1);            layout->addWidget(new QLabel(i18n("units"), frame), 0, 2);        } else {            m_timeT = 0;            QLineEdit *le = new QLineEdit(QString("%1").arg(m_time), frame);            le->setReadOnly(true);            layout->addWidget(le, 0, 2);        }    }    label = new QLabel(m_isDuration ? i18n("Measures:") : i18n("Measure:"), frame);    label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);    layout->addWidget(label, 1, 0);    if (editable) {        m_barLabel = 0;        m_bar = new QSpinBox(frame);        if (m_isDuration)            m_bar->setMinValue(0);        connect(m_bar, SIGNAL(valueChanged(int)),                this, SLOT(slotBarBeatOrFractionChanged(int)));        layout->addWidget(m_bar, 1, 1);    } else {        m_bar = 0;        m_barLabel = new QLineEdit(frame);        m_barLabel->setReadOnly(true);        layout->addWidget(m_barLabel, 1, 1);    }    label = new QLabel(m_isDuration ? i18n("beats:") : i18n("beat:"), frame);    label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);    layout->addWidget(label, 1, 2);    if (editable) {        m_beatLabel = 0;        m_beat = new QSpinBox(frame);        m_beat->setMinValue(1);        connect(m_beat, SIGNAL(valueChanged(int)),                this, SLOT(slotBarBeatOrFractionChanged(int)));        layout->addWidget(m_beat, 1, 3);    } else {        m_beat = 0;        m_beatLabel = new QLineEdit(frame);        m_beatLabel->setReadOnly(true);        layout->addWidget(m_beatLabel, 1, 3);    }    label = new QLabel(i18n("%1:").arg(NotationStrings::getShortNoteName                                       (Note                                        (Note::Shortest), true)),                       frame);    label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);    layout->addWidget(label, 1, 4);    if (editable) {        m_fractionLabel = 0;        m_fraction = new QSpinBox(frame);        m_fraction->setMinValue(1);        connect(m_fraction, SIGNAL(valueChanged(int)),                this, SLOT(slotBarBeatOrFractionChanged(int)));        layout->addWidget(m_fraction, 1, 5);    } else {        m_fraction = 0;        m_fractionLabel = new QLineEdit(frame);        m_fractionLabel->setReadOnly(true);        layout->addWidget(m_fractionLabel, 1, 5);    }    m_timeSig = new QLabel(frame);    layout->addWidget(m_timeSig, 1, 6);    label = new QLabel(i18n("Seconds:"), frame);    label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);    layout->addWidget(label, 2, 0);    if (editable) {        m_secLabel = 0;        m_sec = new QSpinBox(frame);        if (m_isDuration)            m_sec->setMinValue(0);        connect(m_sec, SIGNAL(valueChanged(int)),                this, SLOT(slotSecOrMSecChanged(int)));        layout->addWidget(m_sec, 2, 1);    } else {        m_sec = 0;        m_secLabel = new QLineEdit(frame);        m_secLabel->setReadOnly(true);        layout->addWidget(m_secLabel, 2, 1);    }    label = new QLabel(i18n("msec:"), frame);    label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);    layout->addWidget(label, 2, 2);    if (editable) {        m_msecLabel = 0;        m_msec = new QSpinBox(frame);        m_msec->setMinValue(0);        m_msec->setLineStep(10);        connect(m_msec, SIGNAL(valueChanged(int)),                this, SLOT(slotSecOrMSecChanged(int)));        layout->addWidget(m_msec, 2, 3);    } else {        m_msec = 0;        m_msecLabel = new QLineEdit(frame);        m_msecLabel->setReadOnly(true);        layout->addWidget(m_msecLabel, 2, 3);    }    if (m_isDuration) {        m_tempo = new QLabel(frame);        layout->addWidget(m_tempo, 2, 6);    } else {        m_tempo = 0;    }    if (!savedEditable) {        if (m_note)            m_note ->setEnabled(false);        if (m_timeT)            m_timeT ->setEnabled(false);        if (m_bar)            m_bar ->setEnabled(false);        if (m_beat)            m_beat ->setEnabled(false);        if (m_fraction)            m_fraction ->setEnabled(false);        if (m_sec)            m_sec ->setEnabled(false);        if (m_msec)            m_msec ->setEnabled(false);    }    populate();}voidTimeWidget::populate(){    // populate everything from m_time and m_startTime    if (m_note)        m_note ->blockSignals(true);    if (m_timeT)        m_timeT ->blockSignals(true);    if (m_bar)        m_bar ->blockSignals(true);    if (m_beat)        m_beat ->blockSignals(true);    if (m_fraction)        m_fraction ->blockSignals(true);    if (m_sec)        m_sec ->blockSignals(true);

⌨️ 快捷键说明

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