comparison widgets/LabelCounterInputDialog.cpp @ 311:fee76aa923d8

* Add Reset Counters... function
author Chris Cannam
date Wed, 10 Oct 2007 10:22:34 +0000
parents
children 63971199663a
comparison
equal deleted inserted replaced
310:f4458c8bffa6 311:fee76aa923d8
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2007 QMUL.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #include "LabelCounterInputDialog.h"
17
18 #include <QVBoxLayout>
19 #include <QHBoxLayout>
20 #include <QLabel>
21 #include <QSpinBox>
22 #include <QDialogButtonBox>
23
24 LabelCounterInputDialog::LabelCounterInputDialog(Labeller *labeller,
25 QWidget *parent) :
26 QDialog(parent),
27 m_labeller(labeller)
28 {
29 setWindowTitle(tr("Set Counters"));
30
31 QGridLayout *layout = new QGridLayout(this);
32
33 QLabel *label = new QLabel(tr("Fine counter (beats):"));
34 layout->addWidget(label, 1, 0);
35
36 label = new QLabel(tr("Coarse counter (bars):"));
37 layout->addWidget(label, 0, 0);
38
39 QSpinBox *counter = new QSpinBox;
40 counter->setMinimum(1);
41 counter->setMaximum(10000);
42 counter->setSingleStep(1);
43 m_origSecondCounter = m_labeller->getSecondLevelCounterValue();
44 counter->setValue(m_origSecondCounter);
45 connect(counter, SIGNAL(valueChanged(int)),
46 this, SLOT(secondCounterChanged(int)));
47 layout->addWidget(counter, 0, 1);
48
49 counter = new QSpinBox;
50 counter->setMinimum(1);
51 counter->setMaximum(10000);
52 counter->setSingleStep(1);
53 m_origCounter = m_labeller->getCounterValue();
54 counter->setValue(m_origCounter);
55 connect(counter, SIGNAL(valueChanged(int)),
56 this, SLOT(counterChanged(int)));
57 layout->addWidget(counter, 1, 1);
58
59 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok |
60 QDialogButtonBox::Cancel);
61 layout->addWidget(bb, 2, 0, 1, 2);
62 connect(bb, SIGNAL(accepted()), this, SLOT(accept()));
63 connect(bb, SIGNAL(rejected()), this, SLOT(cancelClicked()));
64 }
65
66 LabelCounterInputDialog::~LabelCounterInputDialog()
67 {
68 }
69
70 void
71 LabelCounterInputDialog::counterChanged(int value)
72 {
73 m_labeller->setCounterValue(value);
74 }
75
76 void
77 LabelCounterInputDialog::secondCounterChanged(int value)
78 {
79 m_labeller->setSecondLevelCounterValue(value);
80 }
81
82 void
83 LabelCounterInputDialog::cancelClicked()
84 {
85 m_labeller->setCounterValue(m_origCounter);
86 m_labeller->setSecondLevelCounterValue(m_origSecondCounter);
87 reject();
88 }
89