~ubuntu-branches/ubuntu/karmic/kguitar/karmic

« back to all changes in this revision

Viewing changes to kguitar/kguitar_part.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Loic Pefferkorn
  • Date: 2005-08-19 15:22:41 UTC
  • Revision ID: james.westby@ubuntu.com-20050819152241-n24w9np4vblrm5as
Tags: upstream-0.5
ImportĀ upstreamĀ versionĀ 0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "global.h"
 
2
 
 
3
#include "kguitar_part.h"
 
4
 
 
5
#include "songprint.h"
 
6
#include "songview.h"
 
7
#include "trackview.h"
 
8
#include "tracklist.h"
 
9
#include "tabsong.h"
 
10
#include "setsong.h"
 
11
#include "options.h"
 
12
#include "melodyeditor.h"
 
13
#include "trackdrag.h"
 
14
#include "settings.h"
 
15
 
 
16
#include "convertkg.h"
 
17
#include "convertascii.h"
 
18
#include "convertxml.h"
 
19
#include "convertmidi.h"
 
20
#include "converttse3.h"
 
21
#include "converttex.h"
 
22
#include "convertgtp.h"
 
23
#include "convertgp3.h"
 
24
 
 
25
#include "optionsexportascii.h"
 
26
#include "optionsexportmusixtex.h"
 
27
 
 
28
// KDE system things
 
29
#include <kparts/genericfactory.h>
 
30
 
 
31
#include <kapp.h>
 
32
#include <kmenubar.h>
 
33
#include <ktoolbar.h>
 
34
#include <kaction.h>
 
35
#include <kstdaction.h>
 
36
#include <klocale.h>
 
37
#include <kfiledialog.h>
 
38
#include <kaccel.h>
 
39
#include <kmessagebox.h>
 
40
#include <kurl.h>
 
41
#include <kkeydialog.h>
 
42
#include <kdebug.h>
 
43
#include <kprinter.h>
 
44
 
 
45
#include <qwidget.h>
 
46
 
 
47
#include <qpixmap.h>
 
48
#include <qkeycode.h>
 
49
#include <qstatusbar.h>
 
50
#include <qclipboard.h>
 
51
 
 
52
#include <qbuttongroup.h>
 
53
#include <qradiobutton.h>
 
54
#include <qfileinfo.h>
 
55
 
 
56
typedef KParts::GenericFactory<KGuitarPart> KGuitarPartFactory;
 
57
K_EXPORT_COMPONENT_FACTORY(libkguitarpart, KGuitarPartFactory)
 
58
 
 
59
// Global variables - real declarations
 
60
 
 
61
QString drum_abbr[128];
 
62
 
 
63
KGuitarPart::KGuitarPart(QWidget *parentWidget,
 
64
                         const char * /*widgetName*/, QObject *parent, const char *name,
 
65
                         const QStringList & /*args*/)
 
66
        : KParts::ReadWritePart(parent, name)
 
67
{
 
68
        Settings::config = KGuitarPartFactory::instance()->config();
 
69
 
 
70
        cmdHist = new KCommandHistory();
 
71
 
 
72
        setInstance(KGuitarPartFactory::instance());
 
73
 
 
74
        // Custom main widget
 
75
        sv = new SongView(this, cmdHist, parentWidget);
 
76
 
 
77
        // notify the part that this is our internal widget
 
78
        setWidget(sv);
 
79
 
 
80
        setupActions();
 
81
        setupAccels();
 
82
 
 
83
        // SET UP RESPONSES FOR VARIOUS TRACK CHANGES
 
84
 
 
85
        connect(sv->tv, SIGNAL(trackChanged(TabTrack *)), SLOT(updateToolbars(TabTrack *)));
 
86
        connect(QApplication::clipboard(), SIGNAL(dataChanged()), SLOT(clipboardDataChanged()));
 
87
        connect(sv->tv, SIGNAL(barChanged()), SLOT(updateStatusBar()));
 
88
 
 
89
        setXMLFile("kguitar_part.rc");
 
90
 
 
91
        setReadWrite(true);
 
92
        setModified(false);
 
93
 
 
94
        // READ CONFIGS
 
95
        readOptions();
 
96
 
 
97
        readMidiNames();
 
98
}
 
99
 
 
100
KGuitarPart::~KGuitarPart()
 
101
{
 
102
        saveOptions();
 
103
        delete cmdHist;
 
104
}
 
105
 
 
106
void KGuitarPart::setReadWrite(bool rw)
 
107
{
 
108
        sv->setReadOnly(!rw);
 
109
        if (rw) {
 
110
                connect(sv, SIGNAL(songChanged()), this, SLOT(setModified()));
 
111
        } else {
 
112
                disconnect(sv, SIGNAL(songChanged()), this, SLOT(setModified()));
 
113
        }
 
114
 
 
115
        ReadWritePart::setReadWrite(rw);
 
116
}
 
117
 
 
118
void KGuitarPart::setModified(bool modified)
 
119
{
 
120
        // enable or disable Save action based on modified
 
121
        KAction *save = actionCollection()->action(KStdAction::stdName(KStdAction::Save));
 
122
        if (!save)
 
123
                return;
 
124
 
 
125
        save->setEnabled(modified);
 
126
 
 
127
        // in any event, we want our parent to do it's thing
 
128
        ReadWritePart::setModified(modified);
 
129
}
 
130
 
 
131
KAboutData *KGuitarPart::createAboutData()
 
132
{
 
133
        KAboutData *aboutData = new KAboutData("kguitar", I18N_NOOP("KGuitarPart"), VERSION);
 
134
        aboutData->addAuthor("KGuitar development team", 0, 0);
 
135
        return aboutData;
 
136
}
 
137
 
 
138
// Reimplemented method from KParts to open file m_file
 
139
bool KGuitarPart::openFile()
 
140
{
 
141
        QFileInfo fi(m_file);
 
142
 
 
143
        if (!fi.isFile()) {
 
144
                KMessageBox::sorry(0, i18n("No file specified, please select a file."));
 
145
                return FALSE;
 
146
        }
 
147
        if (!fi.isReadable()) {
 
148
                KMessageBox::sorry(0, i18n("You have no permission to read this file."));
 
149
                return FALSE;
 
150
        }
 
151
 
 
152
        bool success = FALSE;
 
153
 
 
154
        QString ext = fi.extension();
 
155
        ext = ext.lower();
 
156
 
 
157
        ConvertBase *converter = NULL;
 
158
 
 
159
        if (ext == "kg")   converter = new ConvertKg(sv->song());
 
160
        if (ext == "tab")  converter = new ConvertAscii(sv->song());
 
161
#ifdef WITH_TSE3
 
162
        if (ext == "mid")  converter = new ConvertMidi(sv->song());
 
163
#endif
 
164
        if (ext == "gp4")  converter = new ConvertGtp(sv->song());
 
165
        if (ext == "gp3")  converter = new ConvertGp3(sv->song());
 
166
        if (ext == "xml")  converter = new ConvertXml(sv->song());
 
167
        
 
168
        if (converter)  success = converter->load(m_file);
 
169
 
 
170
        if (success) {
 
171
                sv->refreshView();
 
172
                cmdHist->clear();
 
173
        } else {
 
174
                setWinCaption(i18n("Unnamed"));
 
175
                KMessageBox::sorry(0, i18n("Can't load or import song!"
 
176
                                           "It may be a damaged/wrong file format or, "
 
177
                                           "if you're trying experimental importers "
 
178
                                           "it may be a flaw with the import code."));
 
179
        }
 
180
 
 
181
        return success;
 
182
}
 
183
 
 
184
bool KGuitarPart::exportOptionsDialog(QString ext)
 
185
{
 
186
        // Skip dialog if user set appropriate option
 
187
        if (!Settings::config->readBoolEntry("AlwaysShow", TRUE))
 
188
                return TRUE;
 
189
 
 
190
        KDialogBase opDialog(0, 0, TRUE, i18n("Additional Export Options"),
 
191
                             KDialogBase::Help|KDialogBase::Default|
 
192
                             KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok);
 
193
 
 
194
        QVBox *box = opDialog.makeVBoxMainWidget();
 
195
 
 
196
        OptionsPage *op;
 
197
 
 
198
        if (ext == "tab") {
 
199
                op = new OptionsExportAscii(Settings::config, (QFrame *) box);
 
200
        } else if (ext == "tex") {
 
201
                op = new OptionsExportMusixtex(Settings::config, (QFrame *) box);
 
202
        } else {
 
203
                kdWarning() << "Weird exportOptionsDialog() call! Wrong extension " << ext << endl;
 
204
                return FALSE;
 
205
        }
 
206
 
 
207
        connect(&opDialog, SIGNAL(defaultClicked()), op, SLOT(defaultBtnClicked()));
 
208
        connect(&opDialog, SIGNAL(okClicked()), op, SLOT(applyBtnClicked()));
 
209
 
 
210
        bool res = (opDialog.exec() == QDialog::Accepted);
 
211
        delete op;
 
212
        return res;
 
213
}
 
214
 
 
215
// Reimplemented method from KParts to current song to file m_file
 
216
bool KGuitarPart::saveFile()
 
217
{
 
218
    // if we aren't read-write, return immediately
 
219
        if (isReadWrite() == false)
 
220
                return false;
 
221
 
 
222
        // GREYFIX: some sort of dirty hack - workaround the KDE default
 
223
        // save, not saveAs without file name
 
224
        if (m_file.isEmpty()) {
 
225
                fileSaveAs();
 
226
                return false;
 
227
        }
 
228
 
 
229
        QFileInfo *fi = new QFileInfo(m_file);
 
230
        QString ext = fi->extension().lower();
 
231
 
 
232
        bool success = FALSE;
 
233
 
 
234
        if (ext == "kg") {
 
235
                sv->tv->arrangeBars(); // GREYFIX !
 
236
                ConvertKg converter(sv->song());
 
237
                success = converter.save(m_file);
 
238
        }
 
239
        if (ext == "tab") {
 
240
                Settings::config->setGroup("ASCII");
 
241
                if (exportOptionsDialog(ext)) {
 
242
                        ConvertAscii converter(sv->song());
 
243
                        success = converter.save(m_file);
 
244
                } else {
 
245
                        return FALSE;
 
246
                }
 
247
        }
 
248
#ifdef WITH_TSE3
 
249
        if (ext == "mid") {
 
250
                ConvertMidi converter(sv->song());
 
251
                success = converter.save(m_file);
 
252
        }
 
253
        if (ext == "tse3") {
 
254
                ConvertTse3 converter(sv->song());
 
255
                success = converter.save(m_file);
 
256
        }
 
257
#endif
 
258
        if (ext == "gp4") {
 
259
                ConvertGtp converter(sv->song());
 
260
                success = converter.save(m_file);
 
261
        }
 
262
        if (ext == "gp3") {
 
263
                ConvertGp3 converter(sv->song());
 
264
                success = converter.save(m_file);
 
265
        }
 
266
        if (ext == "tex") {
 
267
                if (exportOptionsDialog(ext)) {
 
268
                        ConvertTex converter(sv->song());
 
269
                        success = converter.save(m_file);
 
270
                } else {
 
271
                        return FALSE;
 
272
                }
 
273
        }
 
274
        if (ext == "xml") {
 
275
                ConvertXml converter(sv->song());
 
276
                success = converter.save(m_file);
 
277
        }
 
278
 
 
279
        if (success) {
 
280
                setWinCaption(m_file);
 
281
                cmdHist->clear();
 
282
        } else {
 
283
                KMessageBox::sorry(0, i18n("Can't save song in %1 format").arg(ext));
 
284
        }
 
285
 
 
286
        return success;
 
287
}
 
288
 
 
289
void KGuitarPart::fileSaveAs()
 
290
{
 
291
        QString filter =
 
292
                "*.kg|" + i18n("KGuitar files") + " (*.kg)\n"
 
293
                "*.tab|" + i18n("ASCII files") + " (*.tab)\n"
 
294
                "*.mid|" + i18n("MIDI files") + " (*.mid)\n"
 
295
                "*.tse3|" + i18n("TSE3MDL files") + " (*.tse3)\n"
 
296
                "*.gp4|" + i18n("Guitar Pro 4 files") + " (*.gp4)\n"
 
297
                "*.gp3|" + i18n("Guitar Pro 3 files") + " (*.gp3)\n"
 
298
                "*.xml|" + i18n("MusicXML files") + " (*.xml)\n"
 
299
                "*.tex|" + i18n("MusiXTeX") + " (*.tex)\n"
 
300
                "*|" + i18n("All files");
 
301
        QString file_name = KFileDialog::getSaveFileName(QString::null, filter);
 
302
 
 
303
        if (file_name.isEmpty() == false)
 
304
                saveAs(file_name);
 
305
}
 
306
 
 
307
// Updates possibility of actions, depending on freshly selected
 
308
// track. For drum track, lots of actions are unavailable.
 
309
void KGuitarPart::updateToolbars(TabTrack *)
 
310
{
 
311
        switch (sv->tv->trk()->trackMode()) {
 
312
        case TabTrack::DrumTab:
 
313
                insChordAct->setEnabled(FALSE);
 
314
                natHarmAct->setEnabled(FALSE);
 
315
                artHarmAct->setEnabled(FALSE);
 
316
                break;
 
317
        default:
 
318
                insChordAct->setEnabled(TRUE);
 
319
                natHarmAct->setEnabled(TRUE);
 
320
                artHarmAct->setEnabled(TRUE);
 
321
        }
 
322
}
 
323
 
 
324
void KGuitarPart::filePrint()
 
325
{
 
326
// LVIFIX: enable status message
 
327
//  slotStatusMsg(i18n("Printing..."));
 
328
 
 
329
        KPrinter printer(true, QPrinter::HighResolution);
 
330
        if (printer.setup())
 
331
                sv->print(&printer);
 
332
 
 
333
//  slotStatusMsg(i18n("Ready."));
 
334
}
 
335
 
 
336
void KGuitarPart::options()
 
337
{
 
338
        Options op(
 
339
#ifdef WITH_TSE3
 
340
                sv->midiScheduler(),
 
341
#endif
 
342
                KGuitarPartFactory::instance()->config());
 
343
        op.exec();
 
344
        sv->me->drawBackground();
 
345
}
 
346
 
 
347
void KGuitarPart::readOptions()
 
348
{
 
349
        KConfig *config = KGuitarPartFactory::instance()->config();
 
350
 
 
351
//      config->setGroup("MusiXTeX");
 
352
//      globalTabSize = config->readNumEntry("TabSize", 2);
 
353
//      globalShowBarNumb = config->readBoolEntry("ShowBarNumb", TRUE);
 
354
//      globalShowStr = config->readBoolEntry("ShowStr", TRUE);
 
355
//      globalShowPageNumb = config->readBoolEntry("ShowPageNumb", TRUE);
 
356
//      globalTexExpMode = config->readNumEntry("TexExpMode", 0);
 
357
 
 
358
        viewMelodyEditorAct->setChecked(config->readBoolEntry("Visible", TRUE));
 
359
        viewMelodyEditor();
 
360
//      viewScoreAct->setChecked(TRUE);         // LVIFIX: read value from config, enable only if feta fonts found
 
361
        viewScoreAct->setChecked(FALSE);        // LVIFIX: enable before commit
 
362
        viewScore();
 
363
}
 
364
 
 
365
void KGuitarPart::saveOptions()
 
366
{
 
367
        Settings::config->setGroup("MelodyEditor");
 
368
        Settings::config->writeEntry("Visible", viewMelodyEditorAct->isChecked());
 
369
        Settings::config->sync();
 
370
}
 
371
 
 
372
void KGuitarPart::readMidiNames()
 
373
{
 
374
        drum_abbr[35] = QString("BD1");
 
375
        drum_abbr[36] = QString("BD2");
 
376
        drum_abbr[38] = QString("SD1");
 
377
        drum_abbr[40] = QString("SD2");
 
378
 
 
379
        drum_abbr[39] = QString("HCL"); // Hand clap
 
380
 
 
381
        drum_abbr[42] = QString("CHH");
 
382
        drum_abbr[44] = QString("PHH");
 
383
        drum_abbr[46] = QString("OHH");
 
384
 
 
385
        drum_abbr[49] = QString("CR1"); // Crash cymbal
 
386
        drum_abbr[57] = QString("CR2");
 
387
 
 
388
        drum_abbr[51] = QString("RI1"); // Ride cymbal
 
389
        drum_abbr[59] = QString("RI2");
 
390
 
 
391
        drum_abbr[54] = QString("TBR"); // Tamborine
 
392
        drum_abbr[55] = QString("SPL"); // Splash cymbal
 
393
 
 
394
        drum_abbr[41] = QString("TL2");
 
395
        drum_abbr[43] = QString("TL1");
 
396
        drum_abbr[45] = QString("TM2");
 
397
        drum_abbr[47] = QString("TM1");
 
398
        drum_abbr[48] = QString("TH2");
 
399
        drum_abbr[50] = QString("TH1");
 
400
}
 
401
 
 
402
void KGuitarPart::setWinCaption(const QString& caption)
 
403
{
 
404
        emit setWindowCaption(caption);
 
405
}
 
406
 
 
407
//-------------------------------------------------------------------
 
408
 
 
409
// KGuitarBrowserExtension::KGuitarBrowserExtension(KGuitarPart *parent)
 
410
//      : KParts::BrowserExtension(parent, "KGuitarBrowserExtension")
 
411
// {
 
412
// }
 
413
 
 
414
// void KGuitarBrowserExtension::print()
 
415
// {
 
416
//      ((KGuitarPart *)parent())->filePrint();
 
417
// }
 
418
 
 
419
void KGuitarPart::viewMelodyEditor()
 
420
{
 
421
        if (viewMelodyEditorAct->isChecked())
 
422
                sv->me->show();
 
423
        else
 
424
                sv->me->hide();
 
425
}
 
426
 
 
427
void KGuitarPart::viewScore()
 
428
{
 
429
        if (viewScoreAct->isChecked() /* && sv->sp->fFeta LVIFIX: enable after drawing code merge */)
 
430
                sv->tv->viewScore(true);
 
431
        else
 
432
                sv->tv->viewScore(false);
 
433
}
 
434
 
 
435
void KGuitarPart::setupActions()
 
436
{
 
437
        // SET UP STANDARD ACTIONS
 
438
        KStdAction::saveAs(this, SLOT(fileSaveAs()), actionCollection());
 
439
        KStdAction::save(this, SLOT(save()), actionCollection());
 
440
 
 
441
        (void) KStdAction::print(this, SLOT(filePrint()), actionCollection());
 
442
        (void) KStdAction::preferences(this, SLOT(options()), actionCollection());
 
443
 
 
444
        (void) new KAction(i18n("P&roperties..."), 0, sv, SLOT(songProperties()),
 
445
                           actionCollection(), "song_properties");
 
446
 
 
447
        // EDIT ACTIONS
 
448
        (void) KStdAction::undo(cmdHist, SLOT(undo()), actionCollection());
 
449
        (void) KStdAction::redo(cmdHist, SLOT(redo()), actionCollection());
 
450
        (void) KStdAction::cut(sv, SLOT(slotCut()), actionCollection());
 
451
        (void) KStdAction::copy(sv, SLOT(slotCopy()), actionCollection());
 
452
        (void) KStdAction::paste(sv, SLOT(slotPaste()), actionCollection());
 
453
        (void) KStdAction::selectAll(sv, SLOT(slotSelectAll()), actionCollection());
 
454
 
 
455
        // VIEW ACTIONS
 
456
        (void) KStdAction::zoomIn(sv->tv, SLOT(zoomIn()), actionCollection());
 
457
        (void) KStdAction::zoomOut(sv->tv, SLOT(zoomOut()), actionCollection());
 
458
        (void) KStdAction::zoom(sv->tv, SLOT(zoomLevelDialog()), actionCollection());
 
459
        viewMelodyEditorAct = new KToggleAction(i18n("Show Melody Editor"), "melodyeditor",
 
460
                                                SHIFT + Key_M, this, SLOT(viewMelodyEditor()),
 
461
                                                actionCollection(), "view_melodyEditor");
 
462
        viewScoreAct = new KToggleAction(i18n("Show Score"), "score", SHIFT + Key_S,
 
463
                                         this, SLOT(viewScore()),
 
464
                                         actionCollection(), "view_score");
 
465
 
 
466
        // TRACK ACTIONS
 
467
        trkNewAct = new KAction(i18n("&New..."), 0, sv, SLOT(trackNew()),
 
468
                                actionCollection(), "track_new");
 
469
        trkDeleteAct = new KAction(i18n("&Delete"), 0, sv, SLOT(trackDelete()),
 
470
                                   actionCollection(), "track_delete");
 
471
        trkBassLineAct = new KAction(i18n("&Generate Bass Line"), 0, sv, SLOT(trackBassLine()),
 
472
                                     actionCollection(), "track_bassline");
 
473
        trkPropAct = new KAction(i18n("P&roperties..."), 0, sv, SLOT(trackProperties()),
 
474
                                 actionCollection(), "track_properties");
 
475
        rhythmerAct = new KAction(i18n("&Rhythm..."), "rhythmer", SHIFT + Key_R,
 
476
                                  sv->tv, SLOT(rhythmer()), actionCollection(), "rhythmer");
 
477
        insChordAct = new KAction(i18n("&Chord..."), "chord", SHIFT + Key_C,
 
478
                                  sv->tv, SLOT(insertChord()), actionCollection(), "insert_chord");
 
479
 
 
480
        saveOptionAct = new KAction(i18n("&Save Options"), 0, this,
 
481
                                    SLOT(saveOptions()), actionCollection(), "save_options");
 
482
 
 
483
        arrTrkAct = new KAction(i18n("&Arrange Track"), SHIFT + Key_A, sv->tv,
 
484
                                SLOT(arrangeTracks()), actionCollection(), "arrange_trk");
 
485
 
 
486
        // LESS THAN TRIVIAL MOVING STUFF ACTIONS
 
487
        (void) new KAction(i18n("Transpose up"), 0, CTRL + Key_Up,
 
488
                                           sv->tv, SLOT(transposeUp()), actionCollection(), "transpose_up");
 
489
        (void) new KAction(i18n("Transpose down"), 0, CTRL + Key_Down,
 
490
                                           sv->tv, SLOT(transposeDown()), actionCollection(), "transpose_down");
 
491
 
 
492
        // SET UP DURATION
 
493
        (void) new KAction(i18n("Whole"), "note1", CTRL + Key_1,
 
494
                           sv->tv, SLOT(setLength1()), actionCollection(), "set_len1");
 
495
        (void) new KAction("1/2", "note2", CTRL + Key_2,
 
496
                           sv->tv, SLOT(setLength2()), actionCollection(), "set_len2");
 
497
        (void) new KAction("1/4", "note4", CTRL + Key_3,
 
498
                           sv->tv, SLOT(setLength4()), actionCollection(), "set_len4");
 
499
        (void) new KAction("1/8", "note8", CTRL + Key_4,
 
500
                           sv->tv, SLOT(setLength8()), actionCollection(), "set_len8");
 
501
        (void) new KAction("1/16", "note16", CTRL + Key_5,
 
502
                           sv->tv, SLOT(setLength16()), actionCollection(), "set_len16");
 
503
        (void) new KAction("1/32", "note32", CTRL + Key_6,
 
504
                           sv->tv, SLOT(setLength32()), actionCollection(), "set_len32");
 
505
        (void) new KAction(i18n("Dotted note"), "dotted_note", Key_Period,
 
506
                           sv->tv, SLOT(dotNote()), actionCollection(), "dotted_note");
 
507
        (void) new KAction(i18n("Triplet note"), "triplet", Key_T,
 
508
                           sv->tv, SLOT(tripletNote()), actionCollection(), "triplet");
 
509
        (void) new KAction(i18n("More duration"), 0, Key_Equal,
 
510
                           sv->tv, SLOT(keyPlus()), actionCollection(), "more_duration");
 
511
        (void) new KAction(i18n("Less duration"), 0, Key_Minus,
 
512
                           sv->tv, SLOT(keyMinus()), actionCollection(), "less_duration");
 
513
 
 
514
        // SET UP EFFECTS
 
515
        keySigAct = new KAction(i18n("Key signature"), "keysig", SHIFT + Key_K,
 
516
                                sv->tv, SLOT(keySig()), actionCollection(), "key_sig");
 
517
        timeSigAct = new KAction(i18n("Time signature"), "timesig", SHIFT + Key_T,
 
518
                                 sv->tv, SLOT(timeSig()), actionCollection(), "time_sig");
 
519
        arcAct = new KAction(i18n("Link with previous column"), "arc", Key_L,
 
520
                             sv->tv, SLOT(linkPrev()), actionCollection(), "link_prev");
 
521
        legatoAct = new KAction(i18n("Legato (hammer on/pull off)"), "fx_legato", Key_P,
 
522
                                sv->tv, SLOT(addLegato()), actionCollection(), "fx_legato");
 
523
        slideAct = new KAction(i18n("Slide"), "fx_slide", Key_S,
 
524
                               sv->tv, SLOT(addSlide()), actionCollection(), "fx_slide");
 
525
        letRingAct = new KAction(i18n("Let Ring"), "fx_let_ring", Key_I,
 
526
                                 sv->tv, SLOT(addLetRing()), actionCollection(), "fx_let_ring");
 
527
        natHarmAct = new KAction(i18n("Natural harmonic"), "fx_harmonic", Key_H,
 
528
                                 sv->tv, SLOT(addHarmonic()), actionCollection(), "fx_nat_harm"); 
 
529
        artHarmAct = new KAction(i18n("Artificial harmonic"), "fx_harmonic", Key_R,
 
530
                                 sv->tv, SLOT(addArtHarm()), actionCollection(), "fx_art_harm");
 
531
        palmMuteAct = new KAction(i18n("Palm muting"), "fx_palmmute", Key_M,
 
532
                                  sv->tv, SLOT(palmMute()), actionCollection(), "fx_palmmute");
 
533
        (void) new KAction(i18n("Dead note"), 0, Key_X,
 
534
                           sv->tv, SLOT(deadNote()), actionCollection(), "deadnote");
 
535
 
 
536
        // SET UP 'Note Names'
 
537
 
 
538
    // SET UP MIDI-PLAY
 
539
        midiPlaySongAct = new KAction(i18n("&Play / stop"), "1rightarrow", Key_Space,
 
540
                                      sv, SLOT(playSong()), actionCollection(), "midi_playsong");
 
541
        midiStopPlayAct = new KAction(i18n("&Stop"), "player_stop", CTRL + SHIFT + Key_P,
 
542
                                      sv, SLOT(stopPlay()), actionCollection(), "midi_stopplay");
 
543
#ifndef WITH_TSE3
 
544
        midiPlaySongAct->setEnabled(FALSE);
 
545
        midiStopPlayAct->setEnabled(FALSE);
 
546
#endif
 
547
}
 
548
 
 
549
void KGuitarPart::setupAccels()
 
550
{
 
551
        // SET UP ACCEL...
 
552
        mainAccel = new KAccel(sv->tv);
 
553
 
 
554
        // ...FOR CURSOR
 
555
        mainAccel->insert("prev_column", i18n("Move cursor left"), QString::null,
 
556
                          Key_Left, sv->tv, SLOT(keyLeft()));
 
557
        mainAccel->insert("next_column", i18n("Move cursor right"), QString::null,
 
558
                          Key_Right, sv->tv, SLOT(keyRight()));
 
559
        mainAccel->insert("start_bar", i18n("Move cursor to the beginning of bar"), QString::null,
 
560
                          Key_Home, sv->tv, SLOT(keyHome()));
 
561
        mainAccel->insert("end_bar", i18n("Move cursor to the end of bar"), QString::null,
 
562
                          Key_End, sv->tv, SLOT(keyEnd()));
 
563
        mainAccel->insert("prev_bar", i18n("Move cursor to the previous bar"), QString::null,
 
564
                          CTRL + Key_Left, sv->tv, SLOT(keyLeftBar()));
 
565
        mainAccel->insert("next_bar", i18n("Move cursor to the next bar"), QString::null,
 
566
                          CTRL + Key_Right, sv->tv, SLOT(keyRightBar()));
 
567
        mainAccel->insert("start_track", i18n("Move cursor to the beginning of track"), QString::null,
 
568
                          CTRL + Key_Home, sv->tv, SLOT(keyCtrlHome()));
 
569
        mainAccel->insert("end_track", i18n("Move cursor to the end of track"), QString::null,
 
570
                          CTRL + Key_End, sv->tv, SLOT(keyCtrlEnd()));
 
571
        mainAccel->insert("select_prev_column", i18n("Move and select left"), QString::null,
 
572
                          SHIFT + Key_Left, sv->tv, SLOT(selectLeft()));
 
573
        mainAccel->insert("select_next_column", i18n("Move and select right"), QString::null,
 
574
                          SHIFT + Key_Right, sv->tv, SLOT(selectRight()));
 
575
        mainAccel->insert("key_up", i18n("Move cursor up"), QString::null,
 
576
                          Key_Up, sv->tv, SLOT(moveUp()));
 
577
        mainAccel->insert("key_down", i18n("Move cursor down"), QString::null,
 
578
                          Key_Down, sv->tv, SLOT(moveDown()));
 
579
 
 
580
        // ...FOR OTHER KEYS
 
581
        mainAccel->insert("key_del", i18n("Delete note"), QString::null,
 
582
                          Key_Delete, sv->tv, SLOT(deleteNote()));
 
583
        mainAccel->insert("key_CtrlDel", i18n("Delete column"), QString::null,
 
584
                          CTRL + Key_Delete, sv->tv, SLOT(deleteColumn()));
 
585
        mainAccel->insert("key_ins", i18n("Insert column"), QString::null,
 
586
                          Key_Insert, sv->tv, SLOT(insertColumn()));
 
587
 
 
588
        // ...FOR KEY '0' - '9'
 
589
        mainAccel->insert("key_1", i18n("Key 1"), QString::null, Key_1, sv->tv, SLOT(key1()));
 
590
        mainAccel->insert("key_2", i18n("Key 2"), QString::null, Key_2, sv->tv, SLOT(key2()));
 
591
        mainAccel->insert("key_3", i18n("Key 3"), QString::null, Key_3, sv->tv, SLOT(key3()));
 
592
        mainAccel->insert("key_4", i18n("Key 4"), QString::null, Key_4, sv->tv, SLOT(key4()));
 
593
        mainAccel->insert("key_5", i18n("Key 5"), QString::null, Key_5, sv->tv, SLOT(key5()));
 
594
        mainAccel->insert("key_6", i18n("Key 6"), QString::null, Key_6, sv->tv, SLOT(key6()));
 
595
        mainAccel->insert("key_7", i18n("Key 7"), QString::null, Key_7, sv->tv, SLOT(key7()));
 
596
        mainAccel->insert("key_8", i18n("Key 8"), QString::null, Key_8, sv->tv, SLOT(key8()));
 
597
        mainAccel->insert("key_9", i18n("Key 9"), QString::null, Key_9, sv->tv, SLOT(key9()));
 
598
        mainAccel->insert("key_0", i18n("Key 0"), QString::null, Key_0, sv->tv, SLOT(key0()));
 
599
}
 
600
 
 
601
void KGuitarPart::clipboardDataChanged()
 
602
{
 
603
        KAction *paste = actionCollection()->action(KStdAction::stdName(KStdAction::Paste));
 
604
        if (!paste)
 
605
                return;
 
606
        paste->setEnabled(TrackDrag::canDecode(QApplication::clipboard()->data()));
 
607
}
 
608
 
 
609
void KGuitarPart::updateStatusBar()
 
610
{
 
611
        QString tmp;
 
612
        tmp.setNum(sv->tv->trk()->xb + 1);
 
613
        tmp = i18n("Bar: ") + tmp;
 
614
        emit setStatusBarText(tmp);
 
615
}