1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4     Rosegarden
5     A MIDI and audio sequencer and musical notation editor.
6     Copyright 2000-2021 the Rosegarden development team.
7 
8     Other copyrights also apply to some parts of this work.  Please
9     see the AUTHORS file and individual file headers for details.
10 
11     This program is free software; you can redistribute it and/or
12     modify it under the terms of the GNU General Public License as
13     published by the Free Software Foundation; either version 2 of the
14     License, or (at your option) any later version.  See the file
15     COPYING included with this distribution for more information.
16 */
17 
18 
19 #include "PitchDialog.h"
20 
21 #include "gui/widgets/PitchChooser.h"
22 #include <QDialog>
23 #include <QDialogButtonBox>
24 #include <QString>
25 #include <QWidget>
26 #include <QVBoxLayout>
27 #include <QPushButton>
28 
29 
30 namespace Rosegarden
31 {
32 
PitchDialog(QWidget * parent,QString title,int defaultPitch)33 PitchDialog::PitchDialog(QWidget *parent, QString title, int defaultPitch) :
34         QDialog(parent)
35 {
36     setModal(true);
37     setWindowTitle(title);
38 
39     QGridLayout *metagrid = new QGridLayout;
40     setLayout(metagrid);
41     QWidget *vbox = new QWidget(this);
42     QVBoxLayout *vboxLayout = new QVBoxLayout;
43     metagrid->addWidget(vbox, 0, 0);
44 
45     m_pitchChooser = new PitchChooser(title, vbox , defaultPitch);
46     vboxLayout->addWidget(m_pitchChooser);
47     vbox->setLayout(vboxLayout);
48 
49     QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
50     QPushButton *user1
51         = buttonBox->addButton(tr("Reset"), QDialogButtonBox::ActionRole);
52     metagrid->addWidget(buttonBox, 1, 0);
53     metagrid->setRowStretch(0, 10);
54     connect(user1, &QAbstractButton::clicked,
55             m_pitchChooser, &PitchChooser::slotResetToDefault);
56     connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
57     connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
58 }
59 
60 int
getPitch() const61 PitchDialog::getPitch() const
62 {
63     return m_pitchChooser->getPitch();
64 }
65 
66 }
67