summaryrefslogtreecommitdiffstats
path: root/src/gui/dialogs/InterpretDialog.cpp
blob: 75889c6e978a8a73fb1ab23bb5b41c8453c62c61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */

/*
    Rosegarden
    A MIDI and audio sequencer and musical notation editor.
 
    This program is Copyright 2000-2008
        Guillaume Laurent   <[email protected]>,
        Chris Cannam        <[email protected]>,
        Richard Bown        <[email protected]>
 
    The moral rights of Guillaume Laurent, Chris Cannam, and Richard
    Bown to claim authorship of this work have been asserted.
 
    Other copyrights also apply to some parts of this work.  Please
    see the AUTHORS file and individual file headers for details.
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
    published by the Free Software Foundation; either version 2 of the
    License, or (at your option) any later version.  See the file
    COPYING included with this distribution for more information.
*/


#include "InterpretDialog.h"
#include <kapplication.h>

#include <klocale.h>
#include "document/ConfigGroups.h"
#include "commands/notation/InterpretCommand.h"
#include <kconfig.h>
#include <kdialogbase.h>
#include <tqcheckbox.h>
#include <tqgroupbox.h>
#include <tqvbox.h>
#include <tqwidget.h>


namespace Rosegarden
{

InterpretDialog::InterpretDialog(TQWidget *tqparent) :
        KDialogBase(tqparent, 0, true, i18n("Interpret"), Ok | Cancel | Help)
{
    setHelp("nv-interpret");

    TQVBox *vbox = makeVBoxMainWidget();
    TQGroupBox *groupBox = new TQGroupBox
                          (1, Qt::Horizontal, i18n("Interpretations to apply"), vbox);

    m_applyTextDynamics = new TQCheckBox
                          (i18n("Apply text dynamics (p, mf, ff etc)"), groupBox);
    m_applyHairpins = new TQCheckBox
                      (i18n("Apply hairpin dynamics"), groupBox);
    m_stressBeats = new TQCheckBox
                    (i18n("Stress beats"), groupBox);
    m_articulate = new TQCheckBox
                   (i18n("Articulate slurs, staccato, tenuto etc"), groupBox);
    m_allInterpretations = new TQCheckBox
                           (i18n("All available interpretations"), groupBox);

    KConfig *config = kapp->config();
    config->setGroup(NotationViewConfigGroup);

    m_allInterpretations->setChecked
    (config->readBoolEntry("interpretall", true));
    m_applyTextDynamics->setChecked
    (config->readBoolEntry("interprettextdynamics", true));
    m_applyHairpins->setChecked
    (config->readBoolEntry("interprethairpins", true));
    m_stressBeats->setChecked
    (config->readBoolEntry("interpretstressbeats", true));
    m_articulate->setChecked
    (config->readBoolEntry("interpretarticulate", true));

    connect(m_allInterpretations,
            TQT_SIGNAL(clicked()), this, TQT_SLOT(slotAllBoxChanged()));

    slotAllBoxChanged();
}

void
InterpretDialog::slotAllBoxChanged()
{
    bool all = m_allInterpretations->isChecked();
    m_applyTextDynamics->setEnabled(!all);
    m_applyHairpins->setEnabled(!all);
    m_stressBeats->setEnabled(!all);
    m_articulate->setEnabled(!all);
}

int
InterpretDialog::getInterpretations()
{
    KConfig *config = kapp->config();
    config->setGroup(NotationViewConfigGroup);

    config->writeEntry("interpretall", m_allInterpretations->isChecked());
    config->writeEntry("interprettextdynamics", m_applyTextDynamics->isChecked());
    config->writeEntry("interprethairpins", m_applyHairpins->isChecked());
    config->writeEntry("interpretstressbeats", m_stressBeats->isChecked());
    config->writeEntry("interpretarticulate", m_articulate->isChecked());

    if (m_allInterpretations->isChecked()) {
        return InterpretCommand::AllInterpretations;
    } else {
        int in = 0;
        if (m_applyTextDynamics->isChecked())
            in |= InterpretCommand::ApplyTextDynamics;
        if (m_applyHairpins->isChecked())
            in |= InterpretCommand::ApplyHairpins;
        if (m_stressBeats->isChecked())
            in |= InterpretCommand::StressBeats;
        if (m_articulate->isChecked()) {
            in |= InterpretCommand::Articulate;
        }
        return in;
    }
}

}
#include "InterpretDialog.moc"