Chris@311: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@311: Chris@311: /* Chris@311: Sonic Visualiser Chris@311: An audio file viewer and annotation editor. Chris@311: Centre for Digital Music, Queen Mary, University of London. Chris@311: This file copyright 2007 QMUL. Chris@311: Chris@311: This program is free software; you can redistribute it and/or Chris@311: modify it under the terms of the GNU General Public License as Chris@311: published by the Free Software Foundation; either version 2 of the Chris@311: License, or (at your option) any later version. See the file Chris@311: COPYING included with this distribution for more information. Chris@311: */ Chris@311: Chris@311: #include "LabelCounterInputDialog.h" Chris@311: Chris@311: #include Chris@311: #include Chris@311: #include Chris@311: #include Chris@311: #include Chris@311: Chris@311: LabelCounterInputDialog::LabelCounterInputDialog(Labeller *labeller, Chris@311: QWidget *parent) : Chris@311: QDialog(parent), Chris@311: m_labeller(labeller) Chris@311: { Chris@311: setWindowTitle(tr("Set Counters")); Chris@311: Chris@311: QGridLayout *layout = new QGridLayout(this); Chris@311: Chris@311: QLabel *label = new QLabel(tr("Fine counter (beats):")); Chris@311: layout->addWidget(label, 1, 0); Chris@311: Chris@311: label = new QLabel(tr("Coarse counter (bars):")); Chris@311: layout->addWidget(label, 0, 0); Chris@311: Chris@311: QSpinBox *counter = new QSpinBox; Chris@311: counter->setMinimum(1); Chris@311: counter->setMaximum(10000); Chris@311: counter->setSingleStep(1); Chris@311: m_origSecondCounter = m_labeller->getSecondLevelCounterValue(); Chris@311: counter->setValue(m_origSecondCounter); Chris@311: connect(counter, SIGNAL(valueChanged(int)), Chris@311: this, SLOT(secondCounterChanged(int))); Chris@311: layout->addWidget(counter, 0, 1); Chris@311: Chris@311: counter = new QSpinBox; Chris@311: counter->setMinimum(1); Chris@311: counter->setMaximum(10000); Chris@311: counter->setSingleStep(1); Chris@311: m_origCounter = m_labeller->getCounterValue(); Chris@311: counter->setValue(m_origCounter); Chris@311: connect(counter, SIGNAL(valueChanged(int)), Chris@311: this, SLOT(counterChanged(int))); Chris@311: layout->addWidget(counter, 1, 1); Chris@311: Chris@311: QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok | Chris@311: QDialogButtonBox::Cancel); Chris@311: layout->addWidget(bb, 2, 0, 1, 2); Chris@311: connect(bb, SIGNAL(accepted()), this, SLOT(accept())); Chris@311: connect(bb, SIGNAL(rejected()), this, SLOT(cancelClicked())); Chris@311: } Chris@311: Chris@311: LabelCounterInputDialog::~LabelCounterInputDialog() Chris@311: { Chris@311: } Chris@311: Chris@311: void Chris@311: LabelCounterInputDialog::counterChanged(int value) Chris@311: { Chris@311: m_labeller->setCounterValue(value); Chris@311: } Chris@311: Chris@311: void Chris@311: LabelCounterInputDialog::secondCounterChanged(int value) Chris@311: { Chris@311: m_labeller->setSecondLevelCounterValue(value); Chris@311: } Chris@311: Chris@311: void Chris@311: LabelCounterInputDialog::cancelClicked() Chris@311: { Chris@311: m_labeller->setCounterValue(m_origCounter); Chris@311: m_labeller->setSecondLevelCounterValue(m_origSecondCounter); Chris@311: reject(); Chris@311: } Chris@311: