svgui  1.9
LabelCounterInputDialog.cpp
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2007 QMUL.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #include "LabelCounterInputDialog.h"
00017 
00018 #include <QVBoxLayout>
00019 #include <QHBoxLayout>
00020 #include <QLabel>
00021 #include <QSpinBox>
00022 #include <QDialogButtonBox>
00023 
00024 LabelCounterInputDialog::LabelCounterInputDialog(Labeller *labeller,
00025                                                  QWidget *parent) :
00026     QDialog(parent),
00027     m_labeller(labeller)
00028 {
00029     setWindowTitle(tr("Set Counters"));
00030 
00031     QGridLayout *layout = new QGridLayout(this);
00032     
00033     QLabel *label = new QLabel(tr("Fine counter (beats):"));
00034     layout->addWidget(label, 1, 0);
00035 
00036     label = new QLabel(tr("Coarse counter (bars):"));
00037     layout->addWidget(label, 0, 0);
00038 
00039     QSpinBox *counter = new QSpinBox;
00040     counter->setMinimum(-10);
00041     counter->setMaximum(10000);
00042     counter->setSingleStep(1);
00043     m_origSecondCounter = m_labeller->getSecondLevelCounterValue();
00044     counter->setValue(m_origSecondCounter);
00045     connect(counter, SIGNAL(valueChanged(int)),
00046             this, SLOT(secondCounterChanged(int)));
00047     layout->addWidget(counter, 0, 1);
00048 
00049     counter = new QSpinBox;
00050     counter->setMinimum(-10);
00051     counter->setMaximum(10000);
00052     counter->setSingleStep(1);
00053     m_origCounter = m_labeller->getCounterValue();
00054     counter->setValue(m_origCounter);
00055     connect(counter, SIGNAL(valueChanged(int)),
00056             this, SLOT(counterChanged(int)));
00057     layout->addWidget(counter, 1, 1);
00058     
00059     QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok |
00060                                                 QDialogButtonBox::Cancel);
00061     layout->addWidget(bb, 2, 0, 1, 2);
00062     connect(bb, SIGNAL(accepted()), this, SLOT(accept()));
00063     connect(bb, SIGNAL(rejected()), this, SLOT(cancelClicked()));
00064 }
00065 
00066 LabelCounterInputDialog::~LabelCounterInputDialog()
00067 {
00068 }
00069 
00070 void
00071 LabelCounterInputDialog::counterChanged(int value)
00072 {
00073     m_labeller->setCounterValue(value);
00074 }
00075 
00076 void
00077 LabelCounterInputDialog::secondCounterChanged(int value)
00078 {
00079     m_labeller->setSecondLevelCounterValue(value);
00080 }
00081 
00082 void
00083 LabelCounterInputDialog::cancelClicked()
00084 {
00085     m_labeller->setCounterValue(m_origCounter);
00086     m_labeller->setSecondLevelCounterValue(m_origSecondCounter);
00087     reject();
00088 }
00089