예제 #1
0
TempoDialog::TempoDialog(QWidget *parent, RosegardenDocument *doc,
                         bool timeEditable):
        QDialog(parent),
        m_doc(doc),
        m_tempoTime(0)
{
    setModal(true);
    setWindowTitle(tr("Insert Tempo Change"));
    setObjectName("MinorDialog");

    QWidget* vbox = dynamic_cast<QWidget*>(this);
    QVBoxLayout *vboxLayout = new QVBoxLayout;
    vbox->setLayout(vboxLayout);

    // group box for tempo
    QGroupBox *frame = new QGroupBox(tr("Tempo"), vbox);
    frame->setContentsMargins(5, 5, 5, 5);
    QGridLayout *layout = new QGridLayout;
    layout->setSpacing(5);
    vboxLayout->addWidget(frame);

    // Set tempo
    layout->addWidget(new QLabel(tr("New tempo:"), frame), 0, 1);
    m_tempoValueSpinBox = new QDoubleSpinBox(frame);
    m_tempoValueSpinBox->setDecimals(3);
    m_tempoValueSpinBox->setMaximum(1000);
    m_tempoValueSpinBox->setMinimum(1);
    m_tempoValueSpinBox->setSingleStep(1);
    m_tempoValueSpinBox->setValue(120); // will set properly below
    layout->addWidget(m_tempoValueSpinBox, 0, 2);

    connect(m_tempoValueSpinBox, SIGNAL(valueChanged(double)),
            SLOT(slotTempoChanged(double)));

    m_tempoTap= new QPushButton(tr("Tap"), frame);
    layout->addWidget(m_tempoTap, 0, 3);
    connect(m_tempoTap, SIGNAL(clicked()), SLOT(slotTapClicked()));


    m_tempoConstant = new QRadioButton(tr("Tempo is fixed until the following tempo change"), frame);
    m_tempoRampToNext = new QRadioButton(tr("Tempo ramps to the following tempo"), frame);
    m_tempoRampToTarget = new QRadioButton(tr("Tempo ramps to:"), frame);

    //    m_tempoTargetCheckBox = new QCheckBox(tr("Ramping to:"), frame);
    m_tempoTargetSpinBox = new QDoubleSpinBox(frame);
    m_tempoTargetSpinBox->setDecimals(3);
    m_tempoTargetSpinBox->setMaximum(1000);
    m_tempoTargetSpinBox->setMinimum(1);
    m_tempoTargetSpinBox->setSingleStep(1);
    m_tempoTargetSpinBox->setValue(120);

    //    layout->addWidget(m_tempoTargetCheckBox, 1, 0, 0+1, 1- 1, AlignRight);
    //    layout->addWidget(m_tempoTargetSpinBox, 1, 2);

    layout->addWidget(m_tempoConstant, 1, 1, 1, 2);
    layout->addWidget(m_tempoRampToNext, 2, 1, 1, 2);
    layout->addWidget(m_tempoRampToTarget, 3, 1);
    layout->addWidget(m_tempoTargetSpinBox, 3, 2);

    //    connect(m_tempoTargetCheckBox, SIGNAL(clicked()),
    //            SLOT(slotTargetCheckBoxClicked()));
    connect(m_tempoConstant, SIGNAL(clicked()),
            SLOT(slotTempoConstantClicked()));
    connect(m_tempoRampToNext, SIGNAL(clicked()),
            SLOT(slotTempoRampToNextClicked()));
    connect(m_tempoRampToTarget, SIGNAL(clicked()),
            SLOT(slotTempoRampToTargetClicked()));
    connect(m_tempoTargetSpinBox, SIGNAL(valueChanged(double)),
            SLOT(slotTargetChanged(double)));

    m_tempoBeatLabel = new QLabel(frame);
    layout->addWidget(m_tempoBeatLabel, 0, 4);

    m_tempoBeat = new QLabel(frame);
    layout->addWidget(m_tempoBeat, 0, 5);

    m_tempoBeatsPerMinute = new QLabel(frame);
    layout->addWidget(m_tempoBeatsPerMinute, 0, 6);

    frame->setLayout(layout);

    m_timeEditor = 0;

    if (timeEditable) {

        m_timeEditor = new TimeWidget
            (tr("Time of tempo change"),
             vbox, &m_doc->getComposition(), 0, true);
        vboxLayout->addWidget(m_timeEditor);

    } else {
    
        // group box for scope (area)
        QGroupBox *scopeGroup = new QGroupBox(tr("Scope"), vbox);
        vboxLayout->addWidget(scopeGroup);

        QVBoxLayout * scopeBoxLayout = new QVBoxLayout(scopeGroup);
        scopeBoxLayout->setSpacing(5);
        scopeBoxLayout->setMargin(5);

        QVBoxLayout * currentBoxLayout = scopeBoxLayout;
        QWidget * currentBox = scopeGroup;
        
        QLabel *child_15 = new QLabel(tr("The pointer is currently at "), currentBox);
        currentBoxLayout->addWidget(child_15);
        m_tempoTimeLabel = new QLabel(currentBox);
        currentBoxLayout->addWidget(m_tempoTimeLabel);
        m_tempoBarLabel = new QLabel(currentBox);
        currentBoxLayout->addWidget(m_tempoBarLabel);
        QLabel *spare = new QLabel(currentBox);
        currentBoxLayout->addWidget(spare);
        currentBox->setLayout(currentBoxLayout);
        currentBoxLayout->setStretchFactor(spare, 20);

        m_tempoStatusLabel = new QLabel(scopeGroup);
        scopeBoxLayout->addWidget(m_tempoStatusLabel);
        scopeGroup->setLayout(scopeBoxLayout);

        QWidget * changeWhereBox = scopeGroup;
        QVBoxLayout * changeWhereBoxLayout = scopeBoxLayout;
        
        spare = new QLabel("      ", changeWhereBox);
        changeWhereBoxLayout->addWidget(spare);
        
        QWidget *changeWhereVBox = new QWidget(changeWhereBox);
        QVBoxLayout *changeWhereVBoxLayout = new QVBoxLayout;
        changeWhereBoxLayout->addWidget(changeWhereVBox);
        changeWhereBox->setLayout(changeWhereBoxLayout);
        changeWhereBoxLayout->setStretchFactor(changeWhereVBox, 20);

        m_tempoChangeHere = new QRadioButton(tr("Apply this tempo from here onwards"), changeWhereVBox);
        changeWhereVBoxLayout->addWidget(m_tempoChangeHere);

        m_tempoChangeBefore = new QRadioButton(tr("Replace the last tempo change"), changeWhereVBox);
        changeWhereVBoxLayout->addWidget(m_tempoChangeBefore);
        m_tempoChangeBeforeAt = new QLabel(changeWhereVBox);
        changeWhereVBoxLayout->addWidget(m_tempoChangeBeforeAt);
        m_tempoChangeBeforeAt->hide();

        m_tempoChangeStartOfBar = new QRadioButton(tr("Apply this tempo from the start of this bar"), changeWhereVBox);
        changeWhereVBoxLayout->addWidget(m_tempoChangeStartOfBar);

        m_tempoChangeGlobal = new QRadioButton(tr("Apply this tempo to the whole composition"), changeWhereVBox);
        changeWhereVBoxLayout->addWidget(m_tempoChangeGlobal);

        QWidget *optionHBox = new QWidget(changeWhereVBox);
        changeWhereVBoxLayout->addWidget(optionHBox);
        changeWhereVBox->setLayout(changeWhereVBoxLayout);
        QHBoxLayout *optionHBoxLayout = new QHBoxLayout;
        QLabel *child_6 = new QLabel("         ", optionHBox);
        optionHBoxLayout->addWidget(child_6);
        m_defaultBox = new QCheckBox(tr("Also make this the default tempo"), optionHBox);
        optionHBoxLayout->addWidget(m_defaultBox);
        spare = new QLabel(optionHBox);
        optionHBoxLayout->addWidget(spare);
        optionHBox->setLayout(optionHBoxLayout);
        optionHBoxLayout->setStretchFactor(spare, 20);

        connect(m_tempoChangeHere, SIGNAL(clicked()),
                SLOT(slotActionChanged()));
        connect(m_tempoChangeBefore, SIGNAL(clicked()),
                SLOT(slotActionChanged()));
        connect(m_tempoChangeStartOfBar, SIGNAL(clicked()),
                SLOT(slotActionChanged()));
        connect(m_tempoChangeGlobal, SIGNAL(clicked()),
                SLOT(slotActionChanged()));

        m_tempoChangeBefore->setChecked(true);

        // disable initially
        m_defaultBox->setEnabled(false);
    }

    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help);
    vboxLayout->addWidget(buttonBox);
    
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
    connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(slotHelpRequested()));

    populateTempo();    
}
예제 #2
0
SpeedDial::SpeedDial(QWidget* parent)
    : QGroupBox(parent)
    , m_timer(new QTimer(this))
    , m_dial(NULL)
    , m_hrs(NULL)
    , m_min(NULL)
    , m_sec(NULL)
    , m_ms(NULL)
    , m_focus(NULL)
    , m_previousDialValue(0)
    , m_preventSignals(false)
    , m_value(0)
    , m_tapTime(NULL)
    , m_tapTickTimer(NULL)
    , m_tapTick(false)
{
    QGridLayout* grid = new QGridLayout(this);
    grid->setSpacing(0);
    grid->setMargin(2);

    m_plus = new QToolButton(this);
    m_plus->setIconSize(QSize(32, 32));
    m_plus->setIcon(QIcon(":/edit_add.png"));
    grid->addWidget(m_plus, 0, 0, Qt::AlignVCenter | Qt::AlignLeft);
    connect(m_plus, SIGNAL(pressed()), this, SLOT(slotPlusMinus()));
    connect(m_plus, SIGNAL(released()), this, SLOT(slotPlusMinus()));

    m_minus = new QToolButton(this);
    m_minus->setIconSize(QSize(32, 32));
    m_minus->setIcon(QIcon(":/edit_remove.png"));
    grid->addWidget(m_minus, 1, 0, Qt::AlignVCenter | Qt::AlignLeft);
    connect(m_minus, SIGNAL(pressed()), this, SLOT(slotPlusMinus()));
    connect(m_minus, SIGNAL(released()), this, SLOT(slotPlusMinus()));

    m_dial = new QDial(this);
    m_dial->setWrapping(true);
    m_dial->setNotchesVisible(true);
    m_dial->setTracking(true);
    grid->addWidget(m_dial, 0, 1, 2, 2, Qt::AlignHCenter);
    connect(m_dial, SIGNAL(valueChanged(int)), this, SLOT(slotDialChanged(int)));

    m_tap = new QPushButton(tr("Tap"), this);
    m_tap->setStyleSheet(tapDefaultSS);
    m_tap->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
    grid->addWidget(m_tap, 0, 3, 2, 1);
    connect(m_tap, SIGNAL(clicked()), this, SLOT(slotTapClicked()));

    m_hrs = new FocusSpinBox(this);
    m_hrs->setRange(0, HRS_MAX);
    m_hrs->setSuffix("h");
    m_hrs->setButtonSymbols(QSpinBox::NoButtons);
    m_hrs->setToolTip(tr("Hours"));
    grid->addWidget(m_hrs, 2, 0);
    connect(m_hrs, SIGNAL(valueChanged(int)), this, SLOT(slotHoursChanged()));
    connect(m_hrs, SIGNAL(focusGained()), this, SLOT(slotSpinFocusGained()));

    m_min = new FocusSpinBox(this);
    m_min->setRange(0, MIN_MAX);
    m_min->setSuffix("m");
    m_min->setButtonSymbols(QSpinBox::NoButtons);
    m_min->setToolTip(tr("Minutes"));
    grid->addWidget(m_min, 2, 1);
    connect(m_min, SIGNAL(valueChanged(int)), this, SLOT(slotMinutesChanged()));
    connect(m_min, SIGNAL(focusGained()), this, SLOT(slotSpinFocusGained()));

    m_sec = new FocusSpinBox(this);
    m_sec->setRange(0, SEC_MAX);
    m_sec->setSuffix("s");
    m_sec->setButtonSymbols(QSpinBox::NoButtons);
    m_sec->setToolTip(tr("Seconds"));
    grid->addWidget(m_sec, 2, 2);
    connect(m_sec, SIGNAL(valueChanged(int)), this, SLOT(slotSecondsChanged()));
    connect(m_sec, SIGNAL(focusGained()), this, SLOT(slotSpinFocusGained()));

    m_ms = new FocusSpinBox(this);
    m_ms->setRange(0, MS_MAX / MS_DIV);
    m_ms->setPrefix(".");
    m_ms->setButtonSymbols(QSpinBox::NoButtons);
    m_ms->setToolTip(tr("Milliseconds"));
    grid->addWidget(m_ms, 2, 3);
    connect(m_ms, SIGNAL(valueChanged(int)), this, SLOT(slotMSChanged()));
    connect(m_ms, SIGNAL(focusGained()), this, SLOT(slotSpinFocusGained()));

    m_infiniteCheck = new QCheckBox(this);
    m_infiniteCheck->setText(tr("Infinite"));
    grid->addWidget(m_infiniteCheck, 3, 0, 1, 4);
    connect(m_infiniteCheck, SIGNAL(toggled(bool)), this, SLOT(slotInfiniteChecked(bool)));

    m_focus = m_ms;
    m_dial->setRange(m_focus->minimum(), m_focus->maximum());
    m_dial->setSingleStep(m_focus->singleStep());

    m_timer->setInterval(TIMER_HOLD);
    connect(m_timer, SIGNAL(timeout()), this, SLOT(slotPlusMinusTimeout()));
}
예제 #3
0
SpeedDial::SpeedDial(QWidget* parent)
    : QGroupBox(parent)
    , m_timer(new QTimer(this))
    , m_dial(NULL)
    , m_hrs(NULL)
    , m_min(NULL)
    , m_sec(NULL)
    , m_ms(NULL)
    , m_focus(NULL)
    , m_previousDialValue(0)
    , m_preventSignals(false)
    , m_value(0)
    , m_tapTick(false)
    , m_tapTime(NULL)
    , m_tapTickTimer(NULL)
    , m_tapTickElapseTimer(NULL)
    , m_visibilityMask(DEFAULT_VISIBILITY_MASK)
{
    new QVBoxLayout(this);
    layout()->setSpacing(0);
    layout()->setMargin(2);

    QHBoxLayout* topHBox = new QHBoxLayout();
    QVBoxLayout* pmVBox1 = new QVBoxLayout();
    QVBoxLayout* taVBox3 = new QVBoxLayout();
    layout()->addItem(topHBox);

    m_plus = new QToolButton(this);
    m_plus->setIconSize(QSize(32, 32));
    m_plus->setIcon(QIcon(":/edit_add.png"));
    pmVBox1->addWidget(m_plus, Qt::AlignVCenter | Qt::AlignLeft);
    connect(m_plus, SIGNAL(pressed()), this, SLOT(slotPlusMinus()));
    connect(m_plus, SIGNAL(released()), this, SLOT(slotPlusMinus()));

    m_minus = new QToolButton(this);
    m_minus->setIconSize(QSize(32, 32));
    m_minus->setIcon(QIcon(":/edit_remove.png"));
    pmVBox1->addWidget(m_minus, Qt::AlignVCenter | Qt::AlignLeft);
    connect(m_minus, SIGNAL(pressed()), this, SLOT(slotPlusMinus()));
    connect(m_minus, SIGNAL(released()), this, SLOT(slotPlusMinus()));
    topHBox->addItem(pmVBox1);

    m_dial = new QDial(this);
    m_dial->setWrapping(true);
    m_dial->setNotchesVisible(true);
    m_dial->setNotchTarget(15);
    m_dial->setTracking(true);
    topHBox->addWidget(m_dial);
    connect(m_dial, SIGNAL(valueChanged(int)), this, SLOT(slotDialChanged(int)));

    m_tap = new QPushButton(tr("Tap"), this);
    m_tap->setStyleSheet(tapDefaultSS);
    m_tap->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
    taVBox3->addWidget(m_tap);
    connect(m_tap, SIGNAL(clicked()), this, SLOT(slotTapClicked()));

    topHBox->addItem (taVBox3);

    QHBoxLayout* timeHBox = new QHBoxLayout();
    layout()->addItem(timeHBox);

    m_hrs = new FocusSpinBox(this);
    m_hrs->setRange(0, HRS_MAX);
    m_hrs->setSuffix("h");
    m_hrs->setButtonSymbols(QSpinBox::NoButtons);
    m_hrs->setToolTip(tr("Hours"));
    timeHBox->addWidget(m_hrs);
    connect(m_hrs, SIGNAL(valueChanged(int)), this, SLOT(slotHoursChanged()));
    connect(m_hrs, SIGNAL(focusGained()), this, SLOT(slotSpinFocusGained()));

    m_min = new FocusSpinBox(this);
    m_min->setRange(0, MIN_MAX);
    m_min->setSuffix("m");
    m_min->setButtonSymbols(QSpinBox::NoButtons);
    m_min->setToolTip(tr("Minutes"));
    timeHBox->addWidget(m_min);
    connect(m_min, SIGNAL(valueChanged(int)), this, SLOT(slotMinutesChanged()));
    connect(m_min, SIGNAL(focusGained()), this, SLOT(slotSpinFocusGained()));

    m_sec = new FocusSpinBox(this);
    m_sec->setRange(0, SEC_MAX);
    m_sec->setSuffix("s");
    m_sec->setButtonSymbols(QSpinBox::NoButtons);
    m_sec->setToolTip(tr("Seconds"));
    timeHBox->addWidget(m_sec);
    connect(m_sec, SIGNAL(valueChanged(int)), this, SLOT(slotSecondsChanged()));
    connect(m_sec, SIGNAL(focusGained()), this, SLOT(slotSpinFocusGained()));

    m_ms = new FocusSpinBox(this);
    m_ms->setRange(0, MS_MAX);
    m_ms->setSuffix("ms");
    m_ms->setButtonSymbols(QSpinBox::NoButtons);
    m_ms->setToolTip(tr("Milliseconds"));
    timeHBox->addWidget(m_ms);
    connect(m_ms, SIGNAL(valueChanged(int)), this, SLOT(slotMSChanged()));
    connect(m_ms, SIGNAL(focusGained()), this, SLOT(slotSpinFocusGained()));

    m_infiniteCheck = new QCheckBox(this);
    m_infiniteCheck->setText(tr("Infinite"));
    layout()->addWidget(m_infiniteCheck);
    connect(m_infiniteCheck, SIGNAL(toggled(bool)), this, SLOT(slotInfiniteChecked(bool)));

    m_focus = m_ms;
    m_dial->setRange(m_focus->minimum(), m_focus->maximum());
    m_dial->setSingleStep(m_focus->singleStep());

    m_timer->setInterval(TIMER_HOLD);
    connect(m_timer, SIGNAL(timeout()), this, SLOT(slotPlusMinusTimeout()));

    m_tapTickElapseTimer = new QTimer();
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
    m_tapTickElapseTimer->setTimerType(Qt::PreciseTimer);
#endif
    m_tapTickElapseTimer->setSingleShot(true);
    connect(m_tapTickElapseTimer, SIGNAL(timeout()),
                this, SLOT(slotTapTimeout()));

    //Hide elements according to current visibility mask
    setVisibilityMask(m_visibilityMask);
}