diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 18:37:05 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 18:37:05 +0000 |
commit | 145364a8af6a1fec06556221e66d4b724a62fc9a (patch) | |
tree | 53bd71a544008c518034f208d64c932dc2883f50 /src/gui/configuration | |
download | rosegarden-145364a8af6a1fec06556221e66d4b724a62fc9a.tar.gz rosegarden-145364a8af6a1fec06556221e66d4b724a62fc9a.zip |
Added old abandoned KDE3 version of the RoseGarden MIDI tool
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/rosegarden@1097595 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/gui/configuration')
24 files changed, 4357 insertions, 0 deletions
diff --git a/src/gui/configuration/AudioConfigurationPage.cpp b/src/gui/configuration/AudioConfigurationPage.cpp new file mode 100644 index 0000000..28aff71 --- /dev/null +++ b/src/gui/configuration/AudioConfigurationPage.cpp @@ -0,0 +1,323 @@ +/* -*- 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 "AudioConfigurationPage.h" + +#include "sound/Midi.h" +#include "sound/SoundDriver.h" +#include "document/ConfigGroups.h" +#include "base/MidiProgram.h" +#include "base/Studio.h" +#include "ConfigurationPage.h" +#include "document/RosegardenGUIDoc.h" +#include "gui/dialogs/ShowSequencerStatusDialog.h" +#include "gui/seqmanager/SequenceManager.h" +#include "gui/application/RosegardenApplication.h" +#include "gui/studio/StudioControl.h" +#include "sound/MappedEvent.h" +#include "TabbedConfigurationPage.h" +#include <kcombobox.h> +#include <kconfig.h> +#include <kfiledialog.h> +#include <qcheckbox.h> +#include <qcombobox.h> +#include <qcstring.h> +#include <qdatastream.h> +#include <qframe.h> +#include <qlabel.h> +#include <qlineedit.h> +#include <qobject.h> +#include <qpushbutton.h> +#include <qlayout.h> +#include <qslider.h> +#include <qspinbox.h> +#include <qstring.h> +#include <qstringlist.h> +#include <qtabwidget.h> +#include <qtooltip.h> +#include <qwidget.h> +#include <kmessagebox.h> + + +namespace Rosegarden +{ + +AudioConfigurationPage::AudioConfigurationPage( + RosegardenGUIDoc *doc, + KConfig *cfg, + QWidget *parent, + const char *name): + TabbedConfigurationPage(cfg, parent, name), + m_externalAudioEditorPath(0) +{ + // set the document in the super class + m_doc = doc; + + m_cfg->setGroup(SequencerOptionsConfigGroup); + + QFrame *frame = new QFrame(m_tabWidget); + QGridLayout *layout = new QGridLayout(frame, 7, 2, 10, 5); + + QLabel *label = 0; + + int row = 0; + + m_cfg->setGroup(GeneralOptionsConfigGroup); + + layout->setRowSpacing(row, 15); + ++row; + + layout->addWidget(new QLabel(i18n("Audio preview scale"), + frame), row, 0); + + m_previewStyle = new KComboBox(frame); + m_previewStyle->insertItem(i18n("Linear - easier to see loud peaks")); + m_previewStyle->insertItem(i18n("Meter scaling - easier to see quiet activity")); + m_previewStyle->setCurrentItem(m_cfg->readUnsignedNumEntry("audiopreviewstyle", 1)); + layout->addMultiCellWidget(m_previewStyle, row, row, 1, 2); + ++row; + +#ifdef HAVE_LIBJACK + m_cfg->setGroup(SequencerOptionsConfigGroup); + + label = new QLabel(i18n("Record audio files as"), frame); + m_audioRecFormat = new KComboBox(frame); + m_audioRecFormat->insertItem(i18n("16-bit PCM WAV format (smaller files)")); + m_audioRecFormat->insertItem(i18n("32-bit float WAV format (higher quality)")); + m_audioRecFormat->setCurrentItem(m_cfg->readUnsignedNumEntry("audiorecordfileformat", 1)); + layout->addWidget(label, row, 0); + layout->addMultiCellWidget(m_audioRecFormat, row, row, 1, 2); + ++row; +#endif + + m_cfg->setGroup(GeneralOptionsConfigGroup); + + layout->addWidget(new QLabel(i18n("External audio editor"), frame), + row, 0); + + QString defaultAudioEditor = getBestAvailableAudioEditor(); + + std::cerr << "defaultAudioEditor = " << defaultAudioEditor << std::endl; + + QString externalAudioEditor = m_cfg->readEntry("externalaudioeditor", + defaultAudioEditor); + + if (externalAudioEditor == "") { + externalAudioEditor = defaultAudioEditor; + m_cfg->writeEntry("externalaudioeditor", externalAudioEditor); + } + + m_externalAudioEditorPath = new QLineEdit(externalAudioEditor, frame); +// m_externalAudioEditorPath->setMinimumWidth(150); + layout->addWidget(m_externalAudioEditorPath, row, 1); + + QPushButton *changePathButton = + new QPushButton(i18n("Choose..."), frame); + + layout->addWidget(changePathButton, row, 2); + connect(changePathButton, SIGNAL(clicked()), SLOT(slotFileDialog())); + ++row; + + m_cfg->setGroup(SequencerOptionsConfigGroup); + + layout->addWidget(new QLabel(i18n("Create JACK outputs"), frame), + row, 0); +// ++row; + +#ifdef HAVE_LIBJACK + m_createFaderOuts = new QCheckBox(i18n("for individual audio instruments"), frame); + m_createFaderOuts->setChecked(m_cfg->readBoolEntry("audiofaderouts", false)); + +// layout->addWidget(label, row, 0, Qt::AlignRight); + layout->addWidget(m_createFaderOuts, row, 1); + ++row; + + m_createSubmasterOuts = new QCheckBox(i18n("for submasters"), frame); + m_createSubmasterOuts->setChecked(m_cfg->readBoolEntry("audiosubmasterouts", + false)); + +// layout->addWidget(label, row, 0, Qt::AlignRight); + layout->addWidget(m_createSubmasterOuts, row, 1); + ++row; +#endif + + layout->setRowStretch(row, 10); + + addTab(frame, i18n("General")); + + // --------------------- Startup control ---------------------- + // +#ifdef HAVE_LIBJACK +#define OFFER_JACK_START_OPTION 1 +#ifdef OFFER_JACK_START_OPTION + + frame = new QFrame(m_tabWidget); + layout = new QGridLayout(frame, 8, 4, 10, 5); + + row = 0; + + layout->setRowSpacing(row, 15); + ++row; + + label = new QLabel(i18n("Rosegarden can start the JACK audio daemon (jackd) for you automatically if it isn't already running when Rosegarden starts.\n\nThis is recommended for beginners and those who use Rosegarden as their main audio application, but it might not be to the liking of advanced users.\n\nIf you want to start JACK automatically, make sure the command includes a full path where necessary as well as any command-line arguments you want to use.\n\nFor example: /usr/local/bin/jackd -d alsa -d hw -r44100 -p 2048 -n 2\n\n"), frame); + label->setAlignment(Qt::WordBreak); + + layout->addMultiCellWidget(label, row, row, 0, 3); + ++row; + + // JACK control things + // + bool startJack = m_cfg->readBoolEntry("jackstart", false); + m_startJack = new QCheckBox(frame); + m_startJack->setChecked(startJack); + + layout->addWidget(new QLabel(i18n("Start JACK when Rosegarden starts"), frame), 2, 0); + + layout->addWidget(m_startJack, row, 1); + ++row; + + layout->addWidget(new QLabel(i18n("JACK command"), frame), + row, 0); + + QString jackPath = m_cfg->readEntry("jackcommand", + // "/usr/local/bin/jackd -d alsa -d hw -r 44100 -p 2048 -n 2"); + "/usr/bin/qjackctl -s"); + m_jackPath = new QLineEdit(jackPath, frame); + + layout->addMultiCellWidget(m_jackPath, row, row, 1, 3); + ++row; + + layout->setRowStretch(row, 10); + + addTab(frame, i18n("JACK Startup")); + +#endif // OFFER_JACK_START_OPTION +#endif // HAVE_LIBJACK + +} + +void +AudioConfigurationPage::slotFileDialog() +{ + QString path = KFileDialog::getOpenFileName(QString::null, QString::null, this, i18n("External audio editor path")); + m_externalAudioEditorPath->setText(path); +} + +void +AudioConfigurationPage::apply() +{ + m_cfg->setGroup(SequencerOptionsConfigGroup); + +#ifdef HAVE_LIBJACK +#ifdef OFFER_JACK_START_OPTION + // Jack control + // + m_cfg->writeEntry("jackstart", m_startJack->isChecked()); + m_cfg->writeEntry("jackcommand", m_jackPath->text()); +#endif // OFFER_JACK_START_OPTION + + // Jack audio inputs + // + m_cfg->writeEntry("audiofaderouts", m_createFaderOuts->isChecked()); + m_cfg->writeEntry("audiosubmasterouts", m_createSubmasterOuts->isChecked()); + m_cfg->writeEntry("audiorecordfileformat", m_audioRecFormat->currentItem()); +#endif + + m_cfg->setGroup(GeneralOptionsConfigGroup); + + int previewstyle = m_previewStyle->currentItem(); + m_cfg->writeEntry("audiopreviewstyle", previewstyle); + + QString externalAudioEditor = getExternalAudioEditor(); + + QStringList extlist = QStringList::split(" ", externalAudioEditor); + QString extpath = ""; + if (extlist.size() > 0) extpath = extlist[0]; + + if (extpath != "") { + QFileInfo info(extpath); + if (!info.exists() || !info.isExecutable()) { + KMessageBox::error(0, i18n("External audio editor \"%1\" not found or not executable").arg(extpath)); + m_cfg->writeEntry("externalaudioeditor", ""); + } else { + m_cfg->writeEntry("externalaudioeditor", externalAudioEditor); + } + } else { + m_cfg->writeEntry("externalaudioeditor", ""); + } +} + +QString +AudioConfigurationPage::getBestAvailableAudioEditor() +{ + static QString result = ""; + static bool haveResult = false; + + if (haveResult) return result; + + QString path; + const char *cpath = getenv("PATH"); + if (cpath) path = cpath; + else path = "/usr/bin:/bin"; + + QStringList pathList = QStringList::split(":", path); + + const char *candidates[] = { + "mhwaveedit", + "rezound", + "audacity" + }; + + for (int i = 0; + i < sizeof(candidates)/sizeof(candidates[0]) && result == ""; + i++) { + + QString n(candidates[i]); + + for (int j = 0; + j < pathList.size() && result == ""; + j++) { + + QDir dir(pathList[j]); + QString fp(dir.filePath(n)); + QFileInfo fi(fp); + + if (fi.exists() && fi.isExecutable()) { + if (n == "rezound") { + result = QString("%1 --audio-method=jack").arg(fp); + } else { + result = fp; + } + } + } + } + + haveResult = true; + return result; +} + +} +#include "AudioConfigurationPage.moc" + diff --git a/src/gui/configuration/AudioConfigurationPage.h b/src/gui/configuration/AudioConfigurationPage.h new file mode 100644 index 0000000..bd71df6 --- /dev/null +++ b/src/gui/configuration/AudioConfigurationPage.h @@ -0,0 +1,107 @@ +/* -*- 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. +*/ + +#ifndef _RG_AUDIOCONFIGURATIONPAGE_H_ +#define _RG_AUDIOCONFIGURATIONPAGE_H_ + +#include "TabbedConfigurationPage.h" +#include <qstring.h> +#include <klocale.h> +#include <qlineedit.h> + +class QWidget; +class QSpinBox; +class QSlider; +class QPushButton; +class QLabel; +class QComboBox; +class QCheckBox; +class KConfig; +class KComboBox; + + +namespace Rosegarden +{ + +class RosegardenGUIDoc; + + +class AudioConfigurationPage : public TabbedConfigurationPage +{ + Q_OBJECT +public: + AudioConfigurationPage(RosegardenGUIDoc *doc, + KConfig *cfg, + QWidget *parent=0, + const char *name=0); + + virtual void apply(); + + static QString iconLabel() { return i18n("Audio"); } + static QString title() { return i18n("Audio Settings"); } + static QString iconName() { return "configure-audio"; } + +#ifdef HAVE_LIBJACK + QString getJackPath() { return m_jackPath->text(); } +#endif // HAVE_LIBJACK + + static QString getBestAvailableAudioEditor(); + +protected slots: + void slotFileDialog(); + +protected: + QString getExternalAudioEditor() { return m_externalAudioEditorPath->text(); } + + + //--------------- Data members --------------------------------- + +#ifdef HAVE_LIBJACK + QCheckBox *m_startJack; + QLineEdit *m_jackPath; +#endif // HAVE_LIBJACK + + +#ifdef HAVE_LIBJACK + // Number of JACK input ports our RG client creates - + // this decides how many audio input destinations + // we have. + // + QCheckBox *m_createFaderOuts; + QCheckBox *m_createSubmasterOuts; + + QComboBox *m_audioRecFormat; + +#endif // HAVE_LIBJACK + + QLineEdit* m_externalAudioEditorPath; + QComboBox* m_previewStyle; + +}; + + + +} + +#endif diff --git a/src/gui/configuration/AudioPropertiesPage.cpp b/src/gui/configuration/AudioPropertiesPage.cpp new file mode 100644 index 0000000..65d574e --- /dev/null +++ b/src/gui/configuration/AudioPropertiesPage.cpp @@ -0,0 +1,184 @@ +/* -*- 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 "AudioPropertiesPage.h" + +#include "misc/Strings.h" +#include "ConfigurationPage.h" +#include "document/RosegardenGUIDoc.h" +#include "gui/application/RosegardenApplication.h" +#include "gui/studio/AudioPluginManager.h" +#include "sound/AudioFileManager.h" +#include "TabbedConfigurationPage.h" +#include <kconfig.h> +#include <kdiskfreesp.h> +#include <kfiledialog.h> +#include <kfile.h> +#include <qcstring.h> +#include <qdatastream.h> +#include <qdialog.h> +#include <qframe.h> +#include <qlabel.h> +#include <qpushbutton.h> +#include <qstring.h> +#include <qtabwidget.h> +#include <qwidget.h> +#include <qlayout.h> + + +namespace Rosegarden +{ + +AudioPropertiesPage::AudioPropertiesPage(RosegardenGUIDoc *doc, + QWidget *parent, + const char *name) + : TabbedConfigurationPage(doc, parent, name) +{ + AudioFileManager &afm = doc->getAudioFileManager(); + + QFrame *frame = new QFrame(m_tabWidget); + QGridLayout *layout = new QGridLayout(frame, 4, 3, 10, 5); + layout->addWidget(new QLabel(i18n("Audio file path:"), frame), 0, 0); + m_path = new QLabel(QString(afm.getAudioPath().c_str()), frame); + layout->addWidget(m_path, 0, 1); + + m_changePathButton = + new QPushButton(i18n("Choose..."), frame); + + layout->addWidget(m_changePathButton, 0, 2); + + m_diskSpace = new QLabel(frame); + layout->addWidget(new QLabel(i18n("Disk space remaining:"), frame), 1, 0); + layout->addWidget(m_diskSpace, 1, 1); + + m_minutesAtStereo = new QLabel(frame); + layout->addWidget( + new QLabel(i18n("Equivalent minutes of 16-bit stereo:"), + frame), 2, 0); + + layout->addWidget(m_minutesAtStereo, 2, 1, AlignCenter); + + layout->setRowStretch(3, 2); + + calculateStats(); + + connect(m_changePathButton, SIGNAL(released()), + SLOT(slotFileDialog())); + + addTab(frame, i18n("Modify audio path")); +} + +void +AudioPropertiesPage::calculateStats() +{ + // This stolen from KDE libs kfile/kpropertiesdialog.cpp + // + QString mountPoint = KIO::findPathMountPoint(m_path->text()); + KDiskFreeSp * job = new KDiskFreeSp; + connect(job, SIGNAL(foundMountPoint(const QString&, unsigned long, unsigned long, + unsigned long)), + this, SLOT(slotFoundMountPoint(const QString&, unsigned long, unsigned long, + unsigned long))); + job->readDF(mountPoint); +} + +void +AudioPropertiesPage::slotFoundMountPoint(const QString&, + unsigned long kBSize, + unsigned long /*kBUsed*/, + unsigned long kBAvail ) +{ + m_diskSpace->setText(i18n("%1 out of %2 (%3% used)") + .arg(KIO::convertSizeFromKB(kBAvail)) + .arg(KIO::convertSizeFromKB(kBSize)) + .arg( 100 - (int)(100.0 * kBAvail / kBSize) )); + + + AudioPluginManager *apm = m_doc->getPluginManager(); + + int sampleRate = 48000; + QCString replyType; + QByteArray replyData; + + if (rgapp->sequencerCall("getSampleRate()", replyType, replyData)) { + + QDataStream streamIn(replyData, IO_ReadOnly); + unsigned int result; + streamIn >> result; + sampleRate = result; + } + + // Work out total bytes and divide this by the sample rate times the + // number of channels (2) times the number of bytes per sample (2) + // times 60 seconds. + // + float stereoMins = ( float(kBAvail) * 1024.0 ) / + ( float(sampleRate) * 2.0 * 2.0 * 60.0 ); + QString minsStr; + minsStr.sprintf("%8.1f", stereoMins); + + m_minutesAtStereo-> + setText(QString("%1 %2 %3Hz").arg(minsStr) + .arg(i18n("minutes at")) + .arg(sampleRate)); +} + +void +AudioPropertiesPage::slotFileDialog() +{ + AudioFileManager &afm = m_doc->getAudioFileManager(); + + KFileDialog *fileDialog = new KFileDialog(QString(afm.getAudioPath().c_str()), + QString::null, + this, "file dialog", true); + fileDialog->setMode(KFile::Directory); + + connect(fileDialog, SIGNAL(fileSelected(const QString&)), + SLOT(slotFileSelected(const QString&))); + + connect(fileDialog, SIGNAL(destroyed()), + SLOT(slotDirectoryDialogClosed())); + + if (fileDialog->exec() == QDialog::Accepted) { + m_path->setText(fileDialog->selectedFile()); + calculateStats(); + } + delete fileDialog; +} + +void +AudioPropertiesPage::apply() +{ + AudioFileManager &afm = m_doc->getAudioFileManager(); + QString newDir = m_path->text(); + + if (!newDir.isNull()) { + afm.setAudioPath(qstrtostr(newDir)); + m_doc->slotDocumentModified(); + } +} + +} +#include "AudioPropertiesPage.moc" diff --git a/src/gui/configuration/AudioPropertiesPage.h b/src/gui/configuration/AudioPropertiesPage.h new file mode 100644 index 0000000..f21fecc --- /dev/null +++ b/src/gui/configuration/AudioPropertiesPage.h @@ -0,0 +1,89 @@ + +/* -*- 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. +*/ + +#ifndef _RG_AUDIOPROPERTIESPAGE_H_ +#define _RG_AUDIOPROPERTIESPAGE_H_ + +#include "TabbedConfigurationPage.h" +#include <qstring.h> +#include <klocale.h> + + +class QWidget; +class QPushButton; +class QLabel; + + +namespace Rosegarden +{ + +class RosegardenGUIDoc; + + +/** + * Audio Properties page + * + * (document-wide settings) + */ +class AudioPropertiesPage : public TabbedConfigurationPage +{ + Q_OBJECT +public: + AudioPropertiesPage(RosegardenGUIDoc *doc, + QWidget *parent=0, const char *name=0); + virtual void apply(); + + static QString iconLabel() { return i18n("Audio"); } + static QString title() { return i18n("Audio Settings"); } + static QString iconName() { return "configure-audio"; } + +protected slots: + void slotFileDialog(); + + // Work out and display remaining disk space and time left + // at current path. + // + void calculateStats(); + + void slotFoundMountPoint(const QString&, + unsigned long kBSize, + unsigned long kBUsed, + unsigned long kBAvail); + +protected: + + //--------------- Data members --------------------------------- + + QLabel *m_path; + QLabel *m_diskSpace; + QLabel *m_minutesAtStereo; + + QPushButton *m_changePathButton; +}; + + +} + +#endif diff --git a/src/gui/configuration/ColourConfigurationPage.cpp b/src/gui/configuration/ColourConfigurationPage.cpp new file mode 100644 index 0000000..f87cf20 --- /dev/null +++ b/src/gui/configuration/ColourConfigurationPage.cpp @@ -0,0 +1,165 @@ +/* -*- 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 "ColourConfigurationPage.h" + +#include "misc/Debug.h" +#include "misc/Strings.h" +#include "base/Colour.h" +#include "base/ColourMap.h" +#include "commands/segment/SegmentColourMapCommand.h" +#include "ConfigurationPage.h" +#include "document/RosegardenGUIDoc.h" +#include "document/MultiViewCommandHistory.h" +#include "gui/general/GUIPalette.h" +#include "gui/widgets/ColourTable.h" +#include "TabbedConfigurationPage.h" +#include <kcolordialog.h> +#include <kconfig.h> +#include <kinputdialog.h> +#include <qcolor.h> +#include <qframe.h> +#include <qpushbutton.h> +#include <qstring.h> +#include <qtabwidget.h> +#include <qwidget.h> +#include <qlayout.h> + + +namespace Rosegarden +{ + +ColourConfigurationPage::ColourConfigurationPage(RosegardenGUIDoc *doc, + QWidget *parent, + const char *name) + : TabbedConfigurationPage(doc, parent, name) +{ + QFrame *frame = new QFrame(m_tabWidget); + QGridLayout *layout = new QGridLayout(frame, 2, 2, + 10, 5); + + m_map = m_doc->getComposition().getSegmentColourMap(); + + m_colourtable = new ColourTable(frame, m_map, m_listmap); + m_colourtable->setFixedHeight(280); + + layout->addMultiCellWidget(m_colourtable, 0, 0, 0, 1); + + QPushButton* addColourButton = new QPushButton(i18n("Add New Color"), + frame); + layout->addWidget(addColourButton, 1, 0, Qt::AlignHCenter); + + QPushButton* deleteColourButton = new QPushButton(i18n("Delete Color"), + frame); + layout->addWidget(deleteColourButton, 1, 1, Qt::AlignHCenter); + + connect(addColourButton, SIGNAL(clicked()), + this, SLOT(slotAddNew())); + + connect(deleteColourButton, SIGNAL(clicked()), + this, SLOT(slotDelete())); + + connect(this, SIGNAL(docColoursChanged()), + m_doc, SLOT(slotDocColoursChanged())); + + connect(m_colourtable, SIGNAL(entryTextChanged(unsigned int, QString)), + this, SLOT(slotTextChanged(unsigned int, QString))); + + connect(m_colourtable, SIGNAL(entryColourChanged(unsigned int, QColor)), + this, SLOT(slotColourChanged(unsigned int, QColor))); + + addTab(frame, i18n("Color Map")); + +} + +void +ColourConfigurationPage::slotTextChanged(unsigned int index, QString string) +{ + m_map.modifyNameByIndex(m_listmap[index], string.ascii()); + m_colourtable->populate_table(m_map, m_listmap); +} + +void +ColourConfigurationPage::slotColourChanged(unsigned int index, QColor color) +{ + m_map.modifyColourByIndex(m_listmap[index], GUIPalette::convertColour(color)); + m_colourtable->populate_table(m_map, m_listmap); +} + +void +ColourConfigurationPage::apply() +{ + SegmentColourMapCommand *command = new SegmentColourMapCommand(m_doc, m_map); + m_doc->getCommandHistory()->addCommand(command); + + RG_DEBUG << "ColourConfigurationPage::apply() emitting docColoursChanged()" << endl; + emit docColoursChanged(); +} + +void +ColourConfigurationPage::slotAddNew() +{ + QColor temp; + + bool ok = false; + + QString newName = KInputDialog::getText(i18n("New Color Name"), + i18n("Enter new name"), + i18n("New"), + &ok); + + if ((ok == true) && (!newName.isEmpty())) { + KColorDialog box(this, "", true); + + int result = box.getColor( temp ); + + if (result == KColorDialog::Accepted) { + Colour temp2 = GUIPalette::convertColour(temp); + m_map.addItem(temp2, qstrtostr(newName)); + m_colourtable->populate_table(m_map, m_listmap); + } + // Else we don't do anything as they either didn't give a name + // or didn't give a colour + } + +} + +void +ColourConfigurationPage::slotDelete() +{ + QTableSelection temp = m_colourtable->selection(0); + + if ((!temp.isActive()) || (temp.topRow() == 0)) + return ; + + unsigned int toDel = temp.topRow(); + + m_map.deleteItemByIndex(m_listmap[toDel]); + m_colourtable->populate_table(m_map, m_listmap); + +} + +} +#include "ColourConfigurationPage.moc" diff --git a/src/gui/configuration/ColourConfigurationPage.h b/src/gui/configuration/ColourConfigurationPage.h new file mode 100644 index 0000000..9ef4ae0 --- /dev/null +++ b/src/gui/configuration/ColourConfigurationPage.h @@ -0,0 +1,87 @@ + +/* -*- 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. +*/ + +#ifndef _RG_COLOURCONFIGURATIONPAGE_H_ +#define _RG_COLOURCONFIGURATIONPAGE_H_ + +#include "base/ColourMap.h" +#include "gui/widgets/ColourTable.h" +#include "TabbedConfigurationPage.h" +#include <qstring.h> +#include <klocale.h> + + +class QWidget; + + +namespace Rosegarden +{ + +class RosegardenGUIDoc; + + +/** + * Colour Configuration Page + * + * (document-wide settings) + */ +class ColourConfigurationPage : public TabbedConfigurationPage +{ + Q_OBJECT +public: + ColourConfigurationPage(RosegardenGUIDoc *doc, + QWidget *parent=0, const char *name=0); + virtual void apply(); + + void populate_table(); + + static QString iconLabel() { return i18n("Color"); } + static QString title() { return i18n("Color Settings"); } + static QString iconName() { return "colorize"; } + +signals: + void docColoursChanged(); + +protected slots: + void slotAddNew(); + void slotDelete(); + void slotTextChanged(unsigned int, QString); + void slotColourChanged(unsigned int, QColor); + +protected: + ColourTable *m_colourtable; + + ColourMap m_map; + ColourTable::ColourList m_listmap; + +}; + +// ----------- SequencerConfigurationage ----------------- +// + + +} + +#endif diff --git a/src/gui/configuration/ConfigurationPage.cpp b/src/gui/configuration/ConfigurationPage.cpp new file mode 100644 index 0000000..3f3730b --- /dev/null +++ b/src/gui/configuration/ConfigurationPage.cpp @@ -0,0 +1,37 @@ +/* -*- 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 "ConfigurationPage.h" + +#include "document/RosegardenGUIDoc.h" +#include <kconfig.h> +#include <qwidget.h> +#include <algorithm> + + +namespace Rosegarden +{ +} +#include "ConfigurationPage.moc" diff --git a/src/gui/configuration/ConfigurationPage.h b/src/gui/configuration/ConfigurationPage.h new file mode 100644 index 0000000..4a93195 --- /dev/null +++ b/src/gui/configuration/ConfigurationPage.h @@ -0,0 +1,104 @@ + +/* -*- 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. + + Parts of the configuration classes are taken from KMail. + Copyright (C) 2000 The KMail Development Team. + + 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. +*/ + +#ifndef _RG_CONFIGURATIONPAGE_H_ +#define _RG_CONFIGURATIONPAGE_H_ + +#include <qwidget.h> + + +class KConfig; + + +namespace Rosegarden +{ + +class RosegardenGUIDoc; + + +/** + * This class borrowed from KMail + * (c) 2000 The KMail Development Team + */ +class ConfigurationPage : public QWidget +{ + Q_OBJECT + +public: + ConfigurationPage(RosegardenGUIDoc *doc, + QWidget *parent=0, const char *name=0) + : QWidget(parent, name), m_doc(doc), m_cfg(0), m_pageIndex(0) {} + + ConfigurationPage(KConfig *cfg, + QWidget *parent=0, const char *name=0) + : QWidget(parent, name), m_doc(0), m_cfg(cfg), m_pageIndex(0) {} + + ConfigurationPage(RosegardenGUIDoc *doc, KConfig *cfg, + QWidget *parent=0, const char *name=0) + : QWidget(parent, name), m_doc(doc), m_cfg(cfg), m_pageIndex(0) {} + + virtual ~ConfigurationPage() {}; + + /** + * Should set the page up (ie. read the setting from the @ref + * KConfig object into the widgets) after creating it in the + * constructor. Called from @ref ConfigureDialog. + */ +// virtual void setup() = 0; + + /** + * Should apply the changed settings (ie. read the settings from + * the widgets into the @ref KConfig object). Called from @ref + * ConfigureDialog. + */ + virtual void apply() = 0; + + /** + * Should cleanup any temporaries after cancel. The default + * implementation does nothing. Called from @ref + * ConfigureDialog. + */ + virtual void dismiss() {} + + void setPageIndex( int aPageIndex ) { m_pageIndex = aPageIndex; } + int pageIndex() const { return m_pageIndex; } + +protected: + + //--------------- Data members --------------------------------- + + RosegardenGUIDoc* m_doc; + KConfig* m_cfg; + + int m_pageIndex; +}; + + +} + +#endif diff --git a/src/gui/configuration/DocumentMetaConfigurationPage.cpp b/src/gui/configuration/DocumentMetaConfigurationPage.cpp new file mode 100644 index 0000000..9f5064b --- /dev/null +++ b/src/gui/configuration/DocumentMetaConfigurationPage.cpp @@ -0,0 +1,366 @@ +/* -*- 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 "DocumentMetaConfigurationPage.h" + +#include "base/Event.h" +#include "base/BaseProperties.h" +#include "misc/Strings.h" +#include "base/Colour.h" +#include "base/Composition.h" +#include "base/Configuration.h" +#include "base/NotationTypes.h" +#include "base/PropertyName.h" +#include "base/BasicQuantizer.h" +#include "base/RealTime.h" +#include "base/Segment.h" +#include "ConfigurationPage.h" +#include "document/RosegardenGUIDoc.h" +#include "gui/editors/notation/NotationStrings.h" +#include "gui/configuration/HeadersConfigurationPage.h" +#include "gui/general/GUIPalette.h" +#include "TabbedConfigurationPage.h" +#include <kconfig.h> +#include <klistview.h> +#include <qframe.h> +#include <qlabel.h> +#include <qlistview.h> +#include <qpixmap.h> +#include <qpushbutton.h> +#include <qstring.h> +#include <qtable.h> +#include <qtabwidget.h> +#include <qwidget.h> +#include <qlayout.h> + + +namespace Rosegarden +{ + +static QString durationToString(Rosegarden::Composition &comp, + Rosegarden::timeT absTime, + Rosegarden::timeT duration, + Rosegarden::RealTime rt) +{ + return i18n("%1 minutes %2.%3%4 seconds (%5 units, %6 measures)") // TODO - PLURAL + .arg(rt.sec / 60).arg(rt.sec % 60) + .arg(rt.msec() / 100).arg((rt.msec() / 10) % 10) + .arg(duration).arg(comp.getBarNumber(absTime + duration) - + comp.getBarNumber(absTime)); +} + +class SegmentDataItem : public QTableItem +{ +public: + SegmentDataItem(QTable *t, QString s) : + QTableItem(t, QTableItem::Never, s) { } + virtual int alignment() const { return Qt::AlignCenter; } + + virtual QString key() const { + + // It doesn't seem to be possible to specify a comparator so + // as to get the right sorting for numeric items (what am I + // missing here?), only to override this function to return a + // string for comparison. So for integer items we'll return a + // string that starts with a single digit corresponding to the + // number of digits in the integer, which should ensure that + // dictionary sorting works correctly. + // + // This relies on the assumption that any item whose text + // starts with a digit will contain nothing other than a + // single non-negative integer of no more than 9 digits. That + // assumption should hold for all current uses of this class, + // but may need checking for future uses... + + QString s(text()); + if (s[0].digitValue() >= 0) { + return QString("%1%2").arg(s.length()).arg(s); + } else { + return s; + } + } +}; + +DocumentMetaConfigurationPage::DocumentMetaConfigurationPage(RosegardenGUIDoc *doc, + QWidget *parent, + const char *name) : + TabbedConfigurationPage(doc, parent, name) +{ + m_headersPage = new HeadersConfigurationPage(this, doc); + addTab(m_headersPage, i18n("Headers")); + + Composition &comp = doc->getComposition(); + std::set + <TrackId> usedTracks; + + int audioSegments = 0, internalSegments = 0; + for (Composition::iterator ci = comp.begin(); + ci != comp.end(); ++ci) { + usedTracks.insert((*ci)->getTrack()); + if ((*ci)->getType() == Segment::Audio) + ++audioSegments; + else + ++internalSegments; + } + + QFrame *frame = new QFrame(m_tabWidget); + QGridLayout *layout = new QGridLayout(frame, + 6, 2, + 10, 5); + + layout->addWidget(new QLabel(i18n("Filename:"), frame), 0, 0); + layout->addWidget(new QLabel(doc->getTitle(), frame), 0, 1); + + layout->addWidget(new QLabel(i18n("Formal duration (to end marker):"), frame), 1, 0); + timeT d = comp.getEndMarker(); + RealTime rtd = comp.getElapsedRealTime(d); + layout->addWidget(new QLabel(durationToString(comp, 0, d, rtd), frame), 1, 1); + + layout->addWidget(new QLabel(i18n("Playing duration:"), frame), 2, 0); + d = comp.getDuration(); + rtd = comp.getElapsedRealTime(d); + layout->addWidget(new QLabel(durationToString(comp, 0, d, rtd), frame), 2, 1); + + layout->addWidget(new QLabel(i18n("Tracks:"), frame), 3, 0); + layout->addWidget(new QLabel(i18n("%1 used, %2 total") + .arg(usedTracks.size()) + .arg(comp.getNbTracks()), + frame), 3, 1); + + layout->addWidget(new QLabel(i18n("Segments:"), frame), 4, 0); + layout->addWidget(new QLabel(i18n("%1 MIDI, %2 audio, %3 total") + .arg(internalSegments) + .arg(audioSegments) + .arg(internalSegments + audioSegments), + frame), 4, 1); + + layout->setRowStretch(5, 2); + + addTab(frame, i18n("Statistics")); + + frame = new QFrame(m_tabWidget); + layout = new QGridLayout(frame, 1, 1, 10, 5); + + QTable *table = new QTable(1, 11, frame, "Segment Table"); + table->setSelectionMode(QTable::NoSelection); + table->setSorting(true); + table->horizontalHeader()->setLabel(0, i18n("Type")); + table->horizontalHeader()->setLabel(1, i18n("Track")); + table->horizontalHeader()->setLabel(2, i18n("Label")); + table->horizontalHeader()->setLabel(3, i18n("Time")); + table->horizontalHeader()->setLabel(4, i18n("Duration")); + table->horizontalHeader()->setLabel(5, i18n("Events")); + table->horizontalHeader()->setLabel(6, i18n("Polyphony")); + table->horizontalHeader()->setLabel(7, i18n("Repeat")); + table->horizontalHeader()->setLabel(8, i18n("Quantize")); + table->horizontalHeader()->setLabel(9, i18n("Transpose")); + table->horizontalHeader()->setLabel(10, i18n("Delay")); + table->setNumRows(audioSegments + internalSegments); + + table->setColumnWidth(0, 50); + table->setColumnWidth(1, 50); + table->setColumnWidth(2, 150); + table->setColumnWidth(3, 80); + table->setColumnWidth(4, 80); + table->setColumnWidth(5, 80); + table->setColumnWidth(6, 80); + table->setColumnWidth(7, 80); + table->setColumnWidth(8, 80); + table->setColumnWidth(9, 80); + table->setColumnWidth(10, 80); + + int i = 0; + + for (Composition::iterator ci = comp.begin(); + ci != comp.end(); ++ci) { + + Segment *s = *ci; + + table->setItem(i, 0, new SegmentDataItem + (table, + s->getType() == Segment::Audio ? + i18n("Audio") : i18n("MIDI"))); + + table->setItem(i, 1, new SegmentDataItem + (table, + QString("%1").arg(s->getTrack() + 1))); + + QPixmap colourPixmap(16, 16); + Colour colour = + comp.getSegmentColourMap().getColourByIndex(s->getColourIndex()); + colourPixmap.fill(GUIPalette::convertColour(colour)); + + table->setItem(i, 2, + new QTableItem(table, QTableItem::Never, + strtoqstr(s->getLabel()), + colourPixmap)); + + table->setItem(i, 3, new SegmentDataItem + (table, + QString("%1").arg(s->getStartTime()))); + + table->setItem(i, 4, new SegmentDataItem + (table, + QString("%1").arg(s->getEndMarkerTime() - + s->getStartTime()))); + + std::set<long> notesOn; + std::multimap<timeT, long> noteOffs; + int events = 0, notes = 0, poly = 0, maxPoly = 0; + + for (Segment::iterator si = s->begin(); + s->isBeforeEndMarker(si); ++si) { + ++events; + if ((*si)->isa(Note::EventType)) { + ++notes; + timeT startTime = (*si)->getAbsoluteTime(); + timeT endTime = startTime + (*si)->getDuration(); + if (endTime == startTime) continue; + while (!noteOffs.empty() && + (startTime >= noteOffs.begin()->first)) { + notesOn.erase(noteOffs.begin()->second); + noteOffs.erase(noteOffs.begin()); + } + long pitch = 0; + (*si)->get<Int>(BaseProperties::PITCH, pitch); + notesOn.insert(pitch); + noteOffs.insert(std::multimap<timeT, long>::value_type(endTime, pitch)); + poly = notesOn.size(); + if (poly > maxPoly) maxPoly = poly; + } + } + + table->setItem(i, 5, new SegmentDataItem + (table, + QString("%1").arg(events))); + + table->setItem(i, 6, new SegmentDataItem + (table, + QString("%1").arg(maxPoly))); + + table->setItem(i, 7, new SegmentDataItem + (table, + s->isRepeating() ? i18n("Yes") : i18n("No"))); + + timeT discard; + + if (s->getQuantizer() && s->hasQuantization()) { + timeT unit = s->getQuantizer()->getUnit(); + table->setItem(i, 8, new SegmentDataItem + (table, + NotationStrings::makeNoteMenuLabel + (unit, true, discard, false))); + } else { + table->setItem(i, 8, new SegmentDataItem + (table, + i18n("Off"))); + } + + table->setItem(i, 9, new SegmentDataItem + (table, + QString("%1").arg(s->getTranspose()))); + + if (s->getDelay() != 0) { + if (s->getRealTimeDelay() != RealTime::zeroTime) { + table->setItem(i, 10, new SegmentDataItem + (table, + QString("%1 + %2 ms") + .arg(NotationStrings::makeNoteMenuLabel + (s->getDelay(), true, discard, false)) + .arg(s->getRealTimeDelay().sec * 1000 + + s->getRealTimeDelay().msec()))); + } else { + table->setItem(i, 10, new SegmentDataItem + (table, + NotationStrings::makeNoteMenuLabel + (s->getDelay(), true, discard, false))); + } + } else if (s->getRealTimeDelay() != RealTime::zeroTime) { + table->setItem(i, 10, new SegmentDataItem + (table, + QString("%2 ms") + .arg(s->getRealTimeDelay().sec * 1000 + + s->getRealTimeDelay().msec()))); + } else { + table->setItem(i, 10, new SegmentDataItem + (table, + i18n("None"))); + } + + ++i; + } + + layout->addWidget(table, 0, 0); + + addTab(frame, i18n("Segment Summary")); + +} + +void +DocumentMetaConfigurationPage::apply() +{ + m_headersPage->apply(); + + m_doc->slotDocumentModified(); +} + +/* hjj: WHAT TO DO WITH THIS ? +void +DocumentMetaConfigurationPage::selectMetadata(QString name) +{ + std::vector<PropertyName> fixedKeys = + CompositionMetadataKeys::getFixedKeys(); + std::vector<PropertyName>::iterator i = fixedKeys.begin(); + + for (QListViewItem *item = m_fixed->firstChild(); + item != 0; item = item->nextSibling()) { + + if (i == fixedKeys.end()) + break; + + if (name == strtoqstr(i->getName())) { + m_fixed->setSelected(item, true); + m_fixed->setCurrentItem(item); + return ; + } + + ++i; + } + + for (QListViewItem *item = m_metadata->firstChild(); + item != 0; item = item->nextSibling()) { + + if (item->text(0).lower() != name) + continue; + + m_metadata->setSelected(item, true); + m_metadata->setCurrentItem(item); + return ; + } +} +*/ + +} +#include "DocumentMetaConfigurationPage.moc" diff --git a/src/gui/configuration/DocumentMetaConfigurationPage.h b/src/gui/configuration/DocumentMetaConfigurationPage.h new file mode 100644 index 0000000..db26f54 --- /dev/null +++ b/src/gui/configuration/DocumentMetaConfigurationPage.h @@ -0,0 +1,76 @@ + +/* -*- 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. +*/ + +#ifndef _RG_DOCUMENTMETACONFIGURATIONPAGE_H_ +#define _RG_DOCUMENTMETACONFIGURATIONPAGE_H_ + +#include "TabbedConfigurationPage.h" +#include <qstring.h> +#include <klocale.h> + + +class QWidget; +class KListView; + + +namespace Rosegarden +{ + +class RosegardenGUIDoc; +class HeadersConfigurationPage; + +/** + * Document Meta-information page + * + * (document-wide settings) + */ +class DocumentMetaConfigurationPage : public TabbedConfigurationPage +{ + Q_OBJECT +public: + DocumentMetaConfigurationPage(RosegardenGUIDoc *doc, + QWidget *parent = 0, const char *name = 0); + virtual void apply(); + + static QString iconLabel() { return i18n("About"); } + static QString title() { return i18n("About"); } + static QString iconName() { return "contents"; } + +/* hjj: WHAT TO DO WITH THIS ? + void selectMetadata(QString name); +*/ + +protected: + + //--------------- Data members --------------------------------- + + HeadersConfigurationPage *m_headersPage; +}; + + + +} + +#endif diff --git a/src/gui/configuration/GeneralConfigurationPage.cpp b/src/gui/configuration/GeneralConfigurationPage.cpp new file mode 100644 index 0000000..22915ed --- /dev/null +++ b/src/gui/configuration/GeneralConfigurationPage.cpp @@ -0,0 +1,429 @@ +/* -*- 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 "GeneralConfigurationPage.h" + +#include "document/ConfigGroups.h" +#include "ConfigurationPage.h" +#include "document/RosegardenGUIDoc.h" +#include "gui/editors/eventlist/EventView.h" +#include "gui/editors/parameters/RosegardenParameterArea.h" +#include "gui/studio/StudioControl.h" +#include "gui/dialogs/ShowSequencerStatusDialog.h" +#include "gui/seqmanager/SequenceManager.h" +#include "sound/SoundDriver.h" +#include "TabbedConfigurationPage.h" +#include <kcombobox.h> +#include <kconfig.h> +#include <kfiledialog.h> +#include <kmessagebox.h> +#include <qcheckbox.h> +#include <qcombobox.h> +#include <qfileinfo.h> +#include <qframe.h> +#include <qlabel.h> +#include <qlineedit.h> +#include <qpushbutton.h> +#include <qspinbox.h> +#include <qstring.h> +#include <qtabwidget.h> +#include <qvbox.h> +#include <qwidget.h> +#include <qlayout.h> + + +namespace Rosegarden +{ + +GeneralConfigurationPage::GeneralConfigurationPage(RosegardenGUIDoc *doc, + KConfig *cfg, + QWidget *parent, const char *name) + : TabbedConfigurationPage(cfg, parent, name), + m_doc(doc), + m_client(0), + m_countIn(0), + m_nameStyle(0) +{ + m_cfg->setGroup(GeneralOptionsConfigGroup); + + QFrame *frame; + QGridLayout *layout; + QLabel *label = 0; + int row = 0; + + // + // "Behavior" tab + // + frame = new QFrame(m_tabWidget); + layout = new QGridLayout(frame, + 6, 2, // nbrow, nbcol + 10, 5); + + layout->setRowSpacing(row, 15); + ++row; + + layout->addWidget(new QLabel(i18n("Double-click opens segment in"), + frame), row, 0); + + m_client = new KComboBox(frame); + m_client->insertItem(i18n("Notation editor")); + m_client->insertItem(i18n("Matrix editor")); + m_client->insertItem(i18n("Event List editor")); + m_client->setCurrentItem(m_cfg->readUnsignedNumEntry("doubleclickclient", NotationView)); + + layout->addMultiCellWidget(m_client, row, row, 1, 2); + ++row; + + layout->addWidget(new QLabel(i18n("Number of count-in measures when recording"), + frame), row, 0); + + m_countIn = new QSpinBox(frame); + m_countIn->setValue(m_cfg->readUnsignedNumEntry("countinbars", 0)); + m_countIn->setMaxValue(10); + m_countIn->setMinValue(0); + layout->addMultiCellWidget(m_countIn, row, row, 1, 2); + ++row; + + layout->addWidget(new QLabel(i18n("Auto-save interval"), frame), row, 0); + + m_autoSave = new KComboBox(frame); + m_autoSave->insertItem(i18n("Every 30 seconds")); + m_autoSave->insertItem(i18n("Every minute")); + m_autoSave->insertItem(i18n("Every five minutes")); + m_autoSave->insertItem(i18n("Every half an hour")); + m_autoSave->insertItem(i18n("Never")); + + bool doAutoSave = m_cfg->readBoolEntry("autosave", true); + int autoSaveInterval = m_cfg->readUnsignedNumEntry("autosaveinterval", 300); + if (!doAutoSave || autoSaveInterval == 0) { + m_autoSave->setCurrentItem(4); // off + } else if (autoSaveInterval < 45) { + m_autoSave->setCurrentItem(0); + } else if (autoSaveInterval < 150) { + m_autoSave->setCurrentItem(1); + } else if (autoSaveInterval < 900) { + m_autoSave->setCurrentItem(2); + } else { + m_autoSave->setCurrentItem(3); + } + + layout->addMultiCellWidget(m_autoSave, row, row, 1, 2); + ++row; + + // JACK Transport + // +#ifdef HAVE_LIBJACK + m_cfg->setGroup(SequencerOptionsConfigGroup); + + label = new QLabel(i18n("Use JACK transport"), frame); + layout->addWidget(label, row, 0); + + m_jackTransport = new QCheckBox(frame); + layout->addMultiCellWidget(m_jackTransport, row, row, 1, 2); + +// m_jackTransport->insertItem(i18n("Ignore JACK transport")); +// m_jackTransport->insertItem(i18n("Sync")); + + /*!!! Removed as not yet implemented + m_jackTransport->insertItem(i18n("Sync, and offer timebase master")); + */ + + bool jackMaster = m_cfg->readBoolEntry("jackmaster", false); + bool jackTransport = m_cfg->readBoolEntry("jacktransport", false); +/* + if (jackTransport) + m_jackTransport->setCurrentItem(1); + else + m_jackTransport->setCurrentItem(0); +*/ + m_jackTransport->setChecked(jackTransport); + + ++row; + + m_cfg->setGroup(GeneralOptionsConfigGroup); +#endif + + layout->setRowSpacing(row, 20); + ++row; + + layout->addWidget(new QLabel(i18n("Sequencer status"), frame), row, 0); + + QString status(i18n("Unknown")); + SequenceManager *mgr = doc->getSequenceManager(); + if (mgr) { + int driverStatus = mgr->getSoundDriverStatus() & (AUDIO_OK | MIDI_OK); + switch (driverStatus) { + case AUDIO_OK: + status = i18n("No MIDI, audio OK"); + break; + case MIDI_OK: + status = i18n("MIDI OK, no audio"); + break; + case AUDIO_OK | MIDI_OK: + status = i18n("MIDI OK, audio OK"); + break; + default: + status = i18n("No driver"); + break; + } + } + + layout->addWidget(new QLabel(status, frame), row, 1); + + QPushButton *showStatusButton = new QPushButton(i18n("Details..."), + frame); + QObject::connect(showStatusButton, SIGNAL(clicked()), + this, SLOT(slotShowStatus())); + layout->addWidget(showStatusButton, row, 2, Qt::AlignRight); + ++row; + + layout->setRowStretch(row, 10); + + addTab(frame, i18n("Behavior")); + + // + // "Appearance" tab + // + frame = new QFrame(m_tabWidget); + layout = new QGridLayout(frame, + 7, 4, // nbrow, nbcol -- one extra row improves layout + 10, 5); + + row = 0; + + layout->setRowSpacing(row, 15); + ++row; + + layout->addWidget(new QLabel(i18n("Side-bar parameter box layout"), + frame), row, 0); + + m_sidebarStyle = new KComboBox(frame); + m_sidebarStyle->insertItem(i18n("Vertically stacked"), + RosegardenParameterArea::CLASSIC_STYLE); + m_sidebarStyle->insertItem(i18n("Tabbed"), + RosegardenParameterArea::TAB_BOX_STYLE); + + m_sidebarStyle->setCurrentItem(m_cfg->readUnsignedNumEntry("sidebarstyle", + 0)); + layout->addMultiCellWidget(m_sidebarStyle, row, row, 1, 3); + ++row; + + layout->addWidget(new QLabel(i18n("Note name style"), + frame), row, 0); + + m_nameStyle = new KComboBox(frame); + m_nameStyle->insertItem(i18n("Always use US names (e.g. quarter, 8th)")); + m_nameStyle->insertItem(i18n("Localized (where available)")); + m_nameStyle->setCurrentItem(m_cfg->readUnsignedNumEntry("notenamestyle", Local)); + layout->addMultiCellWidget(m_nameStyle, row, row, 1, 3); + ++row; +/* + layout->addWidget(new QLabel(i18n("Show tool context help in status bar"), frame), row, 0); + + m_toolContextHelp = new QCheckBox(frame); + layout->addWidget(m_toolContextHelp, row, 1); + m_toolContextHelp->setChecked(m_cfg->readBoolEntry + ("toolcontexthelp", true)); + ++row; +*/ + + layout->addWidget(new QLabel(i18n("Show textured background on"), frame), row, 0); + + m_backgroundTextures = new QCheckBox(i18n("Main window"), frame); + layout->addWidget(m_backgroundTextures, row, 1); + + m_matrixBackgroundTextures = new QCheckBox(i18n("Matrix"), frame); + layout->addWidget(m_matrixBackgroundTextures, row, 2); + + m_notationBackgroundTextures = new QCheckBox(i18n("Notation"), frame); + layout->addWidget(m_notationBackgroundTextures, row, 3); + + m_backgroundTextures->setChecked(m_cfg->readBoolEntry + ("backgroundtextures", true)); + + m_cfg->setGroup(MatrixViewConfigGroup); + m_matrixBackgroundTextures->setChecked(m_cfg->readBoolEntry + ("backgroundtextures-1.6-plus", true)); + m_cfg->setGroup(NotationViewConfigGroup); + m_notationBackgroundTextures->setChecked(m_cfg->readBoolEntry + ("backgroundtextures", true)); + m_cfg->setGroup(GeneralOptionsConfigGroup); + ++row; + + layout->addWidget(new QLabel(i18n("Use bundled Klearlook theme"), frame), row, 0); + m_globalStyle = new KComboBox(frame); + m_globalStyle->insertItem(i18n("Never")); + m_globalStyle->insertItem(i18n("When not running under KDE")); + m_globalStyle->insertItem(i18n("Always")); + m_globalStyle->setCurrentItem(m_cfg->readUnsignedNumEntry("Install Own Theme", 1)); + layout->addMultiCellWidget(m_globalStyle, row, row, 1, 3); + + ++row; + + layout->setRowStretch(row, 10); + + addTab(frame, i18n("Presentation")); + +} + +void +GeneralConfigurationPage::slotShowStatus() +{ + ShowSequencerStatusDialog dialog(this); + dialog.exec(); +} + +void GeneralConfigurationPage::apply() +{ + m_cfg->setGroup(GeneralOptionsConfigGroup); + + int countIn = getCountInSpin(); + m_cfg->writeEntry("countinbars", countIn); + + int client = getDblClickClient(); + m_cfg->writeEntry("doubleclickclient", client); + + int globalstyle = m_globalStyle->currentItem(); + m_cfg->writeEntry("Install Own Theme", globalstyle); + + int namestyle = getNoteNameStyle(); + m_cfg->writeEntry("notenamestyle", namestyle); +/* + m_cfg->writeEntry("toolcontexthelp", m_toolContextHelp->isChecked()); +*/ + bool texturesChanged = false; + bool mainTextureChanged = false; + m_cfg->setGroup(GeneralOptionsConfigGroup); + + if (m_cfg->readBoolEntry("backgroundtextures", true) != + m_backgroundTextures->isChecked()) { + texturesChanged = true; + mainTextureChanged = true; + } else { + m_cfg->setGroup(MatrixViewConfigGroup); + if (m_cfg->readBoolEntry("backgroundtextures-1.6-plus", false) != + m_matrixBackgroundTextures->isChecked()) { + texturesChanged = true; + } else { + m_cfg->setGroup(NotationViewConfigGroup); + if (m_cfg->readBoolEntry("backgroundtextures", true) != + m_notationBackgroundTextures->isChecked()) { + texturesChanged = true; + } + } + } + + m_cfg->setGroup(GeneralOptionsConfigGroup); + m_cfg->writeEntry("backgroundtextures", m_backgroundTextures->isChecked()); + + m_cfg->setGroup(MatrixViewConfigGroup); + m_cfg->writeEntry("backgroundtextures-1.6-plus", m_matrixBackgroundTextures->isChecked()); + + m_cfg->setGroup(NotationViewConfigGroup); + m_cfg->writeEntry("backgroundtextures", m_notationBackgroundTextures->isChecked()); + + m_cfg->setGroup(GeneralOptionsConfigGroup); + + int sidebarStyle = m_sidebarStyle->currentItem(); + m_cfg->writeEntry("sidebarstyle", sidebarStyle); + emit updateSidebarStyle(sidebarStyle); + + unsigned int interval = 0; + + if (m_autoSave->currentItem() == 4) { + m_cfg->writeEntry("autosave", false); + } else { + m_cfg->writeEntry("autosave", true); + if (m_autoSave->currentItem() == 0) { + interval = 30; + } else if (m_autoSave->currentItem() == 1) { + interval = 60; + } else if (m_autoSave->currentItem() == 2) { + interval = 300; + } else { + interval = 1800; + } + m_cfg->writeEntry("autosaveinterval", interval); + emit updateAutoSaveInterval(interval); + } + +#ifdef HAVE_LIBJACK + m_cfg->setGroup(SequencerOptionsConfigGroup); + + // Write the JACK entry + // +/* + int jackValue = m_jackTransport->currentItem(); + bool jackTransport, jackMaster; + + switch (jackValue) { + case 2: + jackTransport = true; + jackMaster = true; + break; + + case 1: + jackTransport = true; + jackMaster = false; + break; + + default: + jackValue = 0; + + case 0: + jackTransport = false; + jackMaster = false; + break; + } +*/ + + bool jackTransport = m_jackTransport->isChecked(); + bool jackMaster = false; + + int jackValue = 0; // 0 -> nothing, 1 -> sync, 2 -> master + if (jackTransport) jackValue = 1; + + // Write the items + // + m_cfg->writeEntry("jacktransport", jackTransport); + m_cfg->writeEntry("jackmaster", jackMaster); + + // Now send it + // + MappedEvent mEjackValue(MidiInstrumentBase, // InstrumentId + MappedEvent::SystemJackTransport, + MidiByte(jackValue)); + + StudioControl::sendMappedEvent(mEjackValue); +#endif // HAVE_LIBJACK + + if (mainTextureChanged) { + KMessageBox::information(this, i18n("Changes to the textured background in the main window will not take effect until you restart Rosegarden.")); + } + +} + +} +#include "GeneralConfigurationPage.moc" diff --git a/src/gui/configuration/GeneralConfigurationPage.h b/src/gui/configuration/GeneralConfigurationPage.h new file mode 100644 index 0000000..7d3203d --- /dev/null +++ b/src/gui/configuration/GeneralConfigurationPage.h @@ -0,0 +1,116 @@ + +/* -*- 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. +*/ + +#ifndef _RG_GENERALCONFIGURATIONPAGE_H_ +#define _RG_GENERALCONFIGURATIONPAGE_H_ + +#include "TabbedConfigurationPage.h" +#include "gui/editors/eventlist/EventView.h" +#include <qstring.h> +#include <qcheckbox.h> +#include <qspinbox.h> +#include <qcombobox.h> +#include <qlineedit.h> +#include <klocale.h> +#include <kiconloader.h> + +class QWidget; +class KConfig; + + +namespace Rosegarden +{ + +class RosegardenGUIDoc; + + +/** + * General Rosegarden Configuration page + * + * (application-wide settings) + */ +class GeneralConfigurationPage : public TabbedConfigurationPage +{ + Q_OBJECT + +public: + enum DoubleClickClient + { + NotationView, + MatrixView, + EventView + }; + + enum NoteNameStyle + { + American, + Local + }; + + GeneralConfigurationPage(RosegardenGUIDoc *doc, + KConfig *cfg, + QWidget *parent=0, const char *name=0); + + virtual void apply(); + + static QString iconLabel() { return i18n("General"); } + static QString title() { return i18n("General Configuration"); } + static QString iconName() { return "configure-general"; } + +signals: + void updateAutoSaveInterval(unsigned int); + void updateSidebarStyle(unsigned int); + +protected slots: + void slotShowStatus(); + +protected: + int getCountInSpin() { return m_countIn->value(); } + int getDblClickClient() { return m_client->currentItem(); } + int getNoteNameStyle() { return m_nameStyle->currentItem(); } + + //--------------- Data members --------------------------------- + RosegardenGUIDoc* m_doc; + + QComboBox* m_client; + QSpinBox* m_countIn; + QCheckBox* m_toolContextHelp; + QCheckBox* m_backgroundTextures; + QCheckBox* m_notationBackgroundTextures; + QCheckBox* m_matrixBackgroundTextures; + QComboBox *m_autoSave; + QComboBox* m_nameStyle; + QComboBox* m_sidebarStyle; + QComboBox* m_globalStyle; + QCheckBox *m_jackTransport; + +}; + + + + +} + +#endif diff --git a/src/gui/configuration/HeadersConfigurationPage.cpp b/src/gui/configuration/HeadersConfigurationPage.cpp new file mode 100644 index 0000000..0571fb5 --- /dev/null +++ b/src/gui/configuration/HeadersConfigurationPage.cpp @@ -0,0 +1,294 @@ + +/* -*- 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 "HeadersConfigurationPage.h" + +#include "document/ConfigGroups.h" +#include "document/RosegardenGUIDoc.h" +#include "document/io/LilyPondExporter.h" +#include "gui/widgets/CollapsingFrame.h" +#include "misc/Strings.h" + +#include <kapplication.h> +#include <kconfig.h> +#include <klistview.h> +#include <klocale.h> +#include <qgroupbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qlineedit.h> +#include <qpushbutton.h> +#include <qstring.h> +#include <qtabwidget.h> +#include <qtooltip.h> +#include <qvbox.h> +#include <qwidget.h> +#include <qfont.h> + +namespace Rosegarden +{ + +HeadersConfigurationPage::HeadersConfigurationPage(QWidget *parent, + RosegardenGUIDoc *doc) : + QVBox(parent), + m_doc(doc) +{ + // + // LilyPond export: Printable headers + // + + QGroupBox *headersBox = new QGroupBox + (1, Horizontal, + i18n("Printable headers"), this); + QFrame *frameHeaders = new QFrame(headersBox); + QGridLayout *layoutHeaders = new QGridLayout(frameHeaders, 10, 6, 10, 5); + + // grab user headers from metadata + Configuration metadata = (&m_doc->getComposition())->getMetadata(); + std::vector<std::string> propertyNames = metadata.getPropertyNames(); + std::vector<PropertyName> fixedKeys = + CompositionMetadataKeys::getFixedKeys(); + + std::set<std::string> shown; + + for (unsigned int index = 0; index < fixedKeys.size(); index++) { + std::string key = fixedKeys[index].getName(); + std::string header = ""; + for (unsigned int i = 0; i < propertyNames.size(); ++i) { + std::string property = propertyNames [i]; + if (property == key) { + header = metadata.get<String>(property); + } + } + + unsigned int row = 0, col = 0, width = 1; + QLineEdit *editHeader = new QLineEdit(strtoqstr( header ), frameHeaders); + QString trName; + if (key == headerDedication) { + m_editDedication = editHeader; + row = 0; col = 2; width = 2; + trName = i18n("Dedication"); + } else if (key == headerTitle) { + m_editTitle = editHeader; + row = 1; col = 1; width = 4; + trName = i18n("Title"); + } else if (key == headerSubtitle) { + m_editSubtitle = editHeader; + row = 2; col = 1; width = 4; + trName = i18n("Subtitle"); + } else if (key == headerSubsubtitle) { + m_editSubsubtitle = editHeader; + row = 3; col = 2; width = 2; + trName = i18n("Subsubtitle"); + } else if (key == headerPoet) { + m_editPoet = editHeader; + row = 4; col = 0; width = 2; + trName = i18n("Poet"); + } else if (key == headerInstrument) { + m_editInstrument = editHeader; + row = 4; col = 2; width = 2; + trName = i18n("Instrument"); + } else if (key == headerComposer) { + m_editComposer = editHeader; + row = 4; col = 4; width = 2; + trName = i18n("Composer"); + } else if (key == headerMeter) { + m_editMeter = editHeader; + row = 5; col = 0; width = 3; + trName = i18n("Meter"); + } else if (key == headerArranger) { + m_editArranger = editHeader; + row = 5; col = 3; width = 3; + trName = i18n("Arranger"); + } else if (key == headerPiece) { + m_editPiece = editHeader; + row = 6; col = 0; width = 3; + trName = i18n("Piece"); + } else if (key == headerOpus) { + m_editOpus = editHeader; + row = 6; col = 3; width = 3; + trName = i18n("Opus"); + } else if (key == headerCopyright) { + m_editCopyright = editHeader; + row = 8; col = 1; width = 4; + trName = i18n("Copyright"); + } else if (key == headerTagline) { + m_editTagline = editHeader; + row = 9; col = 1; width = 4; + trName = i18n("Tagline"); + } + + // editHeader->setReadOnly( true ); + editHeader->setAlignment( (col == 0 ? Qt::AlignLeft : (col >= 3 ? Qt::AlignRight : Qt::AlignCenter) )); + + layoutHeaders->addMultiCellWidget(editHeader, row, row, col, col+(width-1) ); + + // + // ToolTips + // + QToolTip::add( editHeader, trName ); + + shown.insert(key); + } + QLabel *separator = new QLabel(i18n("The composition comes here."), frameHeaders); + separator->setAlignment( Qt::AlignCenter ); + layoutHeaders->addMultiCellWidget(separator, 7, 7, 1, 4 ); + + // + // LilyPond export: Non-printable headers + // + + // set default expansion to false for this group -- what a faff + KConfig *config = kapp->config(); + QString groupTemp = config->group(); + config->setGroup("CollapsingFrame"); + bool expanded = config->readBoolEntry("nonprintableheaders", false); + config->writeEntry("nonprintableheaders", expanded); + config->setGroup(groupTemp); + + CollapsingFrame *otherHeadersBox = new CollapsingFrame + (i18n("Non-printable headers"), this, "nonprintableheaders"); + QFrame *frameOtherHeaders = new QFrame(otherHeadersBox); + otherHeadersBox->setWidgetFill(true); + QFont font(otherHeadersBox->font()); + font.setBold(false); + otherHeadersBox->setFont(font); + otherHeadersBox->setWidget(frameOtherHeaders); + + QGridLayout *layoutOtherHeaders = new QGridLayout(frameOtherHeaders, 2, 2, 10, 5); + + m_metadata = new KListView(frameOtherHeaders); + m_metadata->addColumn(i18n("Name")); + m_metadata->addColumn(i18n("Value")); + m_metadata->setFullWidth(true); + m_metadata->setItemsRenameable(true); + m_metadata->setRenameable(0); + m_metadata->setRenameable(1); + m_metadata->setItemMargin(5); + m_metadata->setDefaultRenameAction(QListView::Accept); + m_metadata->setShowSortIndicator(true); + + std::vector<std::string> names(metadata.getPropertyNames()); + + for (unsigned int i = 0; i < names.size(); ++i) { + + if (shown.find(names[i]) != shown.end()) + continue; + + QString name(strtoqstr(names[i])); + + // property names stored in lower case + name = name.left(1).upper() + name.right(name.length() - 1); + + new KListViewItem(m_metadata, name, + strtoqstr(metadata.get<String>(names[i]))); + + shown.insert(names[i]); + } + + layoutOtherHeaders->addMultiCellWidget(m_metadata, 0, 0, 0, 1); + + QPushButton* addPropButton = new QPushButton(i18n("Add New Property"), + frameOtherHeaders); + layoutOtherHeaders->addWidget(addPropButton, 1, 0, Qt::AlignHCenter); + + QPushButton* deletePropButton = new QPushButton(i18n("Delete Property"), + frameOtherHeaders); + layoutOtherHeaders->addWidget(deletePropButton, 1, 1, Qt::AlignHCenter); + + connect(addPropButton, SIGNAL(clicked()), + this, SLOT(slotAddNewProperty())); + + connect(deletePropButton, SIGNAL(clicked()), + this, SLOT(slotDeleteProperty())); +} + +void +HeadersConfigurationPage::slotAddNewProperty() +{ + QString propertyName; + int i = 0; + + while (1) { + propertyName = + (i > 0 ? i18n("{new property %1}").arg(i) : i18n("{new property}")); + if (!m_doc->getComposition().getMetadata().has(qstrtostr(propertyName)) && + m_metadata->findItem(qstrtostr(propertyName),0) == 0) + break; + ++i; + } + + new KListViewItem(m_metadata, propertyName, i18n("{undefined}")); +} + +void +HeadersConfigurationPage::slotDeleteProperty() +{ + delete m_metadata->currentItem(); +} + +void HeadersConfigurationPage::apply() +{ + KConfig *config = kapp->config(); + config->setGroup(NotationViewConfigGroup); + + // If one of the items still has focus, it won't remember edits. + // Switch between two fields in order to lose the current focus. + m_editTitle->setFocus(); + m_metadata->setFocus(); + + // + // Update header fields + // + + Configuration &metadata = (&m_doc->getComposition())->getMetadata(); + metadata.clear(); + + metadata.set<String>(CompositionMetadataKeys::Dedication, qstrtostr(m_editDedication->text())); + metadata.set<String>(CompositionMetadataKeys::Title, qstrtostr(m_editTitle->text())); + metadata.set<String>(CompositionMetadataKeys::Subtitle, qstrtostr(m_editSubtitle->text())); + metadata.set<String>(CompositionMetadataKeys::Subsubtitle, qstrtostr(m_editSubsubtitle->text())); + metadata.set<String>(CompositionMetadataKeys::Poet, qstrtostr(m_editPoet->text())); + metadata.set<String>(CompositionMetadataKeys::Composer, qstrtostr(m_editComposer->text())); + metadata.set<String>(CompositionMetadataKeys::Meter, qstrtostr(m_editMeter->text())); + metadata.set<String>(CompositionMetadataKeys::Opus, qstrtostr(m_editOpus->text())); + metadata.set<String>(CompositionMetadataKeys::Arranger, qstrtostr(m_editArranger->text())); + metadata.set<String>(CompositionMetadataKeys::Instrument, qstrtostr(m_editInstrument->text())); + metadata.set<String>(CompositionMetadataKeys::Piece, qstrtostr(m_editPiece->text())); + metadata.set<String>(CompositionMetadataKeys::Copyright, qstrtostr(m_editCopyright->text())); + metadata.set<String>(CompositionMetadataKeys::Tagline, qstrtostr(m_editTagline->text())); + + for (QListViewItem *item = m_metadata->firstChild(); + item != 0; item = item->nextSibling()) { + + metadata.set<String>(qstrtostr(item->text(0).lower()), + qstrtostr(item->text(1))); + } + + m_doc->slotDocumentModified(); +} + +} +#include "HeadersConfigurationPage.moc" diff --git a/src/gui/configuration/HeadersConfigurationPage.h b/src/gui/configuration/HeadersConfigurationPage.h new file mode 100644 index 0000000..403d412 --- /dev/null +++ b/src/gui/configuration/HeadersConfigurationPage.h @@ -0,0 +1,80 @@ + +/* -*- 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. +*/ + +#ifndef _RG_HEADERSCONFIGURATIONPAGE_H_ +#define _RG_HEADERSCONFIGURATIONPAGE_H_ + +#include <qvbox.h> + +class QVBox; +class QWidget; +class QLineEdit; +class KListView; + +namespace Rosegarden +{ + +class RosegardenGUIDoc; + +class HeadersConfigurationPage : public QVBox +{ + Q_OBJECT + +public: + HeadersConfigurationPage(QWidget *parent = 0, + RosegardenGUIDoc *doc = 0); + +public slots: + void apply(); + +protected slots: + void slotAddNewProperty(); + void slotDeleteProperty(); + +protected: + RosegardenGUIDoc *m_doc; + + // Header fields + QLineEdit *m_editDedication; + QLineEdit *m_editTitle; + QLineEdit *m_editSubtitle; + QLineEdit *m_editSubsubtitle; + QLineEdit *m_editPoet; + QLineEdit *m_editComposer; + QLineEdit *m_editMeter; + QLineEdit *m_editOpus; + QLineEdit *m_editArranger; + QLineEdit *m_editInstrument; + QLineEdit *m_editPiece; + QLineEdit *m_editCopyright; + QLineEdit *m_editTagline; + + KListView *m_metadata; +}; + + +} + +#endif diff --git a/src/gui/configuration/LatencyConfigurationPage.cpp b/src/gui/configuration/LatencyConfigurationPage.cpp new file mode 100644 index 0000000..ff89edb --- /dev/null +++ b/src/gui/configuration/LatencyConfigurationPage.cpp @@ -0,0 +1,157 @@ +/* -*- 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 "LatencyConfigurationPage.h" +#include <qlayout.h> + +#include "document/ConfigGroups.h" +#include "ConfigurationPage.h" +#include "document/RosegardenGUIDoc.h" +#include "TabbedConfigurationPage.h" +#include <kconfig.h> +#include <qframe.h> +#include <qlabel.h> +#include <qpushbutton.h> +#include <qslider.h> +#include <qstring.h> +#include <qtabwidget.h> +#include <qwidget.h> + + +namespace Rosegarden +{ + +LatencyConfigurationPage::LatencyConfigurationPage(RosegardenGUIDoc *doc, + KConfig *cfg, + QWidget *parent, + const char *name) + : TabbedConfigurationPage(doc, cfg, parent, name) +{ + // Configuration &config = doc->getConfiguration(); + m_cfg->setGroup(LatencyOptionsConfigGroup); + +#ifdef NOT_DEFINED +#ifdef HAVE_LIBJACK + + frame = new QFrame(m_tabWidget, i18n("JACK latency")); + layout = new QGridLayout(frame, 6, 5, 10, 10); + + layout->addMultiCellWidget(new QLabel(i18n("Use the \"Fetch JACK latencies\" button to discover the latency values set at\nthe sequencer. It's recommended that you use the returned values but it's also\npossible to override them manually using the sliders. Note that if you change\nyour JACK server parameters you should always fetch the latency values again.\nThe latency values will be stored by Rosegarden for use next time."), frame), + 0, 0, + 0, 3); + + layout->addWidget(new QLabel(i18n("JACK playback latency (in ms)"), frame), 1, 0); + layout->addWidget(new QLabel(i18n("JACK record latency (in ms)"), frame), 3, 0); + + m_fetchLatencyValues = new QPushButton(i18n("Fetch JACK latencies"), + frame); + + layout->addWidget(m_fetchLatencyValues, 1, 3); + + connect(m_fetchLatencyValues, SIGNAL(released()), + SLOT(slotFetchLatencyValues())); + + int jackPlaybackValue = (m_cfg->readLongNumEntry( + "jackplaybacklatencyusec", 0) / 1000) + + (m_cfg->readLongNumEntry( + "jackplaybacklatencysec", 0) * 1000); + + m_jackPlayback = new QSlider(Horizontal, frame); + m_jackPlayback->setTickmarks(QSlider::Below); + layout->addMultiCellWidget(m_jackPlayback, 3, 3, 2, 3); + + QLabel *jackPlaybackLabel = new QLabel(QString("%1").arg(jackPlaybackValue), + frame); + layout->addWidget(jackPlaybackLabel, 2, 2, Qt::AlignHCenter); + connect(m_jackPlayback, SIGNAL(valueChanged(int)), + jackPlaybackLabel, SLOT(setNum(int))); + + m_jackPlayback->setMinValue(0); + layout->addWidget(new QLabel("0", frame), 3, 1, Qt::AlignRight); + + m_jackPlayback->setMaxValue(500); + layout->addWidget(new QLabel("500", frame), 3, 4, Qt::AlignLeft); + + m_jackPlayback->setValue(jackPlaybackValue); + + int jackRecordValue = (m_cfg->readLongNumEntry( + "jackrecordlatencyusec", 0) / 1000) + + (m_cfg->readLongNumEntry( + "jackrecordlatencysec", 0) * 1000); + + m_jackRecord = new QSlider(Horizontal, frame); + m_jackRecord->setTickmarks(QSlider::Below); + layout->addMultiCellWidget(m_jackRecord, 5, 5, 2, 3); + + QLabel *jackRecordLabel = new QLabel(QString("%1").arg(jackRecordValue), + frame); + layout->addWidget(jackRecordLabel, 4, 2, Qt::AlignHCenter); + connect(m_jackRecord, SIGNAL(valueChanged(int)), + jackRecordLabel, SLOT(setNum(int))); + + m_jackRecord->setMinValue(0); + layout->addWidget(new QLabel("0", frame), 5, 1, Qt::AlignRight); + + m_jackRecord->setMaxValue(500); + m_jackRecord->setValue(jackRecordValue); + layout->addWidget(new QLabel("500", frame), 5, 4, Qt::AlignLeft); + + addTab(frame, i18n("JACK Latency")); +#endif // HAVE_LIBJACK +#endif // NOT_DEFINED + +} + +void LatencyConfigurationPage::apply() +{ + m_cfg->setGroup(LatencyOptionsConfigGroup); + +#ifdef HAVE_LIBJACK + + int jackPlayback = getJACKPlaybackValue(); + m_cfg->writeEntry("jackplaybacklatencysec", jackPlayback / 1000); + m_cfg->writeEntry("jackplaybacklatencyusec", jackPlayback * 1000); + + int jackRecord = getJACKRecordValue(); + m_cfg->writeEntry("jackrecordlatencysec", jackRecord / 1000); + m_cfg->writeEntry("jackrecordlatencyusec", jackRecord * 1000); + +#endif // HAVE_LIBJACK +} + +void LatencyConfigurationPage::slotFetchLatencyValues() +{ + int jackPlaybackValue = m_doc->getAudioPlayLatency().msec() + + m_doc->getAudioPlayLatency().sec * 1000; + + m_jackPlayback->setValue(jackPlaybackValue); + + int jackRecordValue = m_doc->getAudioRecordLatency().msec() + + m_doc->getAudioRecordLatency().sec * 1000; + m_jackRecord->setValue(jackRecordValue); +} + +} +#include "LatencyConfigurationPage.moc" diff --git a/src/gui/configuration/LatencyConfigurationPage.h b/src/gui/configuration/LatencyConfigurationPage.h new file mode 100644 index 0000000..6caba88 --- /dev/null +++ b/src/gui/configuration/LatencyConfigurationPage.h @@ -0,0 +1,87 @@ + +/* -*- 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. +*/ + +#ifndef _RG_LATENCYCONFIGURATIONPAGE_H_ +#define _RG_LATENCYCONFIGURATIONPAGE_H_ + +#include "TabbedConfigurationPage.h" +#include <qstring.h> +#include <klocale.h> +#include <qslider.h> + + +class QWidget; +class QPushButton; +class KConfig; + + +namespace Rosegarden +{ + +class RosegardenGUIDoc; + + +/** + * Latency Configuration page + * + * (application-wide settings) + */ +class LatencyConfigurationPage : public TabbedConfigurationPage +{ + Q_OBJECT + +public: + LatencyConfigurationPage(RosegardenGUIDoc *doc, + KConfig *cfg, + QWidget *parent=0, const char *name=0); + + virtual void apply(); + + static QString iconLabel() { return i18n("Latency"); } + static QString title() { return i18n("Sequencer Latency"); } + + int getJACKPlaybackValue() { return m_jackPlayback->value(); } + int getJACKRecordValue() { return m_jackRecord->value(); } + +protected slots: + // Get the latest latency values from the sequencer + // + void slotFetchLatencyValues(); + +protected: + + //--------------- Data members --------------------------------- + + QSlider* m_jackPlayback; + QSlider* m_jackRecord; + + QPushButton* m_fetchLatencyValues; +}; + + + +} + +#endif diff --git a/src/gui/configuration/MIDIConfigurationPage.cpp b/src/gui/configuration/MIDIConfigurationPage.cpp new file mode 100644 index 0000000..3d46841 --- /dev/null +++ b/src/gui/configuration/MIDIConfigurationPage.cpp @@ -0,0 +1,400 @@ +/* -*- 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 "MIDIConfigurationPage.h" + +#include "sound/Midi.h" +#include "sound/SoundDriver.h" +#include "document/ConfigGroups.h" +#include "base/MidiProgram.h" +#include "base/Studio.h" +#include "ConfigurationPage.h" +#include "document/RosegardenGUIDoc.h" +#include "gui/dialogs/ShowSequencerStatusDialog.h" +#include "gui/seqmanager/SequenceManager.h" +#include "gui/application/RosegardenApplication.h" +#include "gui/studio/StudioControl.h" +#include "sound/MappedEvent.h" +#include "TabbedConfigurationPage.h" +#include <kcombobox.h> +#include <kconfig.h> +#include <kfiledialog.h> +#include <qcheckbox.h> +#include <qcombobox.h> +#include <qcstring.h> +#include <qdatastream.h> +#include <qframe.h> +#include <qlabel.h> +#include <qlineedit.h> +#include <qobject.h> +#include <qpushbutton.h> +#include <qlayout.h> +#include <qslider.h> +#include <qspinbox.h> +#include <qstring.h> +#include <qstringlist.h> +#include <qtabwidget.h> +#include <qtooltip.h> +#include <qwidget.h> +#include <qcheckbox.h> +#include <qhbox.h> + +namespace Rosegarden +{ + +MIDIConfigurationPage::MIDIConfigurationPage( + RosegardenGUIDoc *doc, + KConfig *cfg, + QWidget *parent, + const char *name): + TabbedConfigurationPage(cfg, parent, name), + m_midiPitchOctave(0) +{ + // set the document in the super class + m_doc = doc; + + // ---------------- General tab ------------------ + // + QFrame *frame = new QFrame(m_tabWidget); + QGridLayout *layout = new QGridLayout(frame, 9, 4, 10, 5); + + int row = 0; + + layout->setRowSpacing(row, 15); + ++row; + + QLabel *label = 0; + + m_cfg->setGroup(GeneralOptionsConfigGroup); + + layout->addMultiCellWidget(new QLabel(i18n("Base octave number for MIDI pitch display"), + frame), row, row, 0, 1); + + m_midiPitchOctave = new QSpinBox(frame); + m_midiPitchOctave->setMaxValue(10); + m_midiPitchOctave->setMinValue( -10); + m_midiPitchOctave->setValue(m_cfg->readNumEntry("midipitchoctave", -2)); + layout->addMultiCellWidget(m_midiPitchOctave, row, row, 2, 3); + ++row; + + layout->setRowSpacing(row, 20); + ++row; + + m_cfg->setGroup(GeneralOptionsConfigGroup); + + layout->addMultiCellWidget(new QLabel(i18n("Always use default studio when loading files"), + frame), row, row, 0, 1); + + m_studio = new QCheckBox(frame); + m_studio->setChecked(m_cfg->readBoolEntry("alwaysusedefaultstudio", false)); + layout->addWidget(m_studio, row, 2); + ++row; + + // Send Controllers + // + m_cfg->setGroup(SequencerOptionsConfigGroup); + + label = new QLabel(i18n("Send all MIDI Controllers at start of each playback"), frame); + + QString controllerTip = i18n("Rosegarden can send all MIDI Controllers (Pan, Reverb etc) to all MIDI devices every\ntime you hit play if you so wish. Please note that this option will usually incur a\ndelay at the start of playback due to the amount of data being transmitted."); + QToolTip::add + (label, controllerTip); + layout->addMultiCellWidget(label, row, row, 0, 1); + + m_sendControllersAtPlay = new QCheckBox(frame); + bool sendControllers = m_cfg->readBoolEntry("alwayssendcontrollers", false); + m_sendControllersAtPlay->setChecked(sendControllers); + QToolTip::add + (m_sendControllersAtPlay, controllerTip); + layout->addWidget(m_sendControllersAtPlay, row, 2); + ++row; + + // Timer selection + // + m_cfg->setGroup(SequencerOptionsConfigGroup); + + label = new QLabel(i18n("Sequencer timing source"), frame); + layout->addMultiCellWidget(label, row, row, 0, 1); + + m_timer = new KComboBox(frame); + layout->addMultiCellWidget(m_timer, row, row, 2, 3); + + QStringList timers = m_doc->getTimers(); + m_origTimer = m_doc->getCurrentTimer(); + QString currentTimer = m_cfg->readEntry("timer", m_origTimer); + + for (unsigned int i = 0; i < timers.size(); ++i) { + m_timer->insertItem(timers[i]); + if (timers[i] == currentTimer) + m_timer->setCurrentItem(i); + } + + ++row; + + layout->setRowSpacing(row, 20); + ++row; + + m_cfg->setGroup(SequencerOptionsConfigGroup); + + // SoundFont loading + // + QLabel* lbl = new QLabel(i18n("Load SoundFont to SoundBlaster card at startup"), frame); + QString tooltip = i18n("Check this box to enable soundfont loading on EMU10K-based cards when Rosegarden is launched"); + QToolTip::add(lbl, tooltip); + layout->addMultiCellWidget(lbl, row, row, 0, 1); + + m_sfxLoadEnabled = new QCheckBox(frame); + layout->addWidget(m_sfxLoadEnabled, row, 2); + QToolTip::add(m_sfxLoadEnabled, tooltip); + ++row; + + layout->addWidget(new QLabel(i18n("Path to 'asfxload' or 'sfxload' command"), frame), row, 0); + m_sfxLoadPath = new QLineEdit(m_cfg->readEntry("sfxloadpath", "/bin/sfxload"), frame); + layout->addMultiCellWidget(m_sfxLoadPath, row, row, 1, 2); + m_sfxLoadChoose = new QPushButton("Choose...", frame); + layout->addWidget(m_sfxLoadChoose, row, 3); + ++row; + + layout->addWidget(new QLabel(i18n("SoundFont"), frame), row, 0); + m_soundFontPath = new QLineEdit(m_cfg->readEntry("soundfontpath", ""), frame); + layout->addMultiCellWidget(m_soundFontPath, row, row, 1, 2); + m_soundFontChoose = new QPushButton("Choose...", frame); + layout->addWidget(m_soundFontChoose, row, 3); + ++row; + + bool sfxLoadEnabled = m_cfg->readBoolEntry("sfxloadenabled", false); + m_sfxLoadEnabled->setChecked(sfxLoadEnabled); + if (!sfxLoadEnabled) { + m_sfxLoadPath->setEnabled(false); + m_sfxLoadChoose->setEnabled(false); + m_soundFontPath->setEnabled(false); + m_soundFontChoose->setEnabled(false); + } + + connect(m_sfxLoadEnabled, SIGNAL(toggled(bool)), + this, SLOT(slotSoundFontToggled(bool))); + + connect(m_sfxLoadChoose, SIGNAL(clicked()), + this, SLOT(slotSfxLoadPathChoose())); + + connect(m_soundFontChoose, SIGNAL(clicked()), + this, SLOT(slotSoundFontChoose())); + + layout->setRowStretch(row, 10); + + addTab(frame, i18n("General")); + + m_cfg->setGroup(SequencerOptionsConfigGroup); + + // -------------- Synchronisation tab ----------------- + // + frame = new QFrame(m_tabWidget); + layout = new QGridLayout(frame, 7, 2, 10, 5); + + row = 0; + + layout->setRowSpacing(row, 15); + ++row; + + // MIDI Clock and System Realtime Messages + // + label = new QLabel(i18n("MIDI Clock and System messages"), frame); + layout->addWidget(label, row, 0); + m_midiSync = new KComboBox(frame); + layout->addWidget(m_midiSync, row, 1); + + m_midiSync->insertItem(i18n("Off")); + m_midiSync->insertItem(i18n("Send MIDI Clock, Start and Stop")); + m_midiSync->insertItem(i18n("Accept Start, Stop and Continue")); + + int midiClock = m_cfg->readNumEntry("midiclock", 0); + if (midiClock < 0 || midiClock > 2) + midiClock = 0; + m_midiSync->setCurrentItem(midiClock); + + ++row; + + // MMC Transport + // + label = new QLabel(i18n("MIDI Machine Control mode"), frame); + layout->addWidget(label, row, 0); + + m_mmcTransport = new KComboBox(frame); + layout->addWidget(m_mmcTransport, row, 1); //, Qt::AlignHCenter); + + m_mmcTransport->insertItem(i18n("Off")); + m_mmcTransport->insertItem(i18n("MMC Master")); + m_mmcTransport->insertItem(i18n("MMC Slave")); + + int mmcMode = m_cfg->readNumEntry("mmcmode", 0); + if (mmcMode < 0 || mmcMode > 2) + mmcMode = 0; + m_mmcTransport->setCurrentItem(mmcMode); + + ++row; + + // MTC transport + // + label = new QLabel(i18n("MIDI Time Code mode"), frame); + layout->addWidget(label, row, 0); + + m_mtcTransport = new KComboBox(frame); + layout->addWidget(m_mtcTransport, row, 1); + + m_mtcTransport->insertItem(i18n("Off")); + m_mtcTransport->insertItem(i18n("MTC Master")); + m_mtcTransport->insertItem(i18n("MTC Slave")); + + int mtcMode = m_cfg->readNumEntry("mtcmode", 0); + if (mtcMode < 0 || mtcMode > 2) + mtcMode = 0; + m_mtcTransport->setCurrentItem(mtcMode); + + ++row; + + QHBox *hbox = new QHBox(frame); + hbox->setSpacing(5); + layout->addMultiCellWidget(hbox, row, row, 0, 1); + + label = new QLabel(i18n("Automatically connect sync output to all devices in use"), hbox); +// layout->addWidget(label, row, 0); + m_midiSyncAuto = new QCheckBox(hbox); +// layout->addWidget(m_midiSyncAuto, row, 1); + + m_midiSyncAuto->setChecked(m_cfg->readBoolEntry("midisyncautoconnect", false)); + + ++row; + + layout->setRowStretch(row, 10); + + addTab(frame, i18n("MIDI Sync")); +} + + +void +MIDIConfigurationPage::slotSoundFontToggled(bool isChecked) +{ + m_sfxLoadPath->setEnabled(isChecked); + m_sfxLoadChoose->setEnabled(isChecked); + m_soundFontPath->setEnabled(isChecked); + m_soundFontChoose->setEnabled(isChecked); +} + +void +MIDIConfigurationPage::slotSfxLoadPathChoose() +{ + QString path = KFileDialog::getOpenFileName(":SFXLOAD", QString::null, this, i18n("sfxload path")); + m_sfxLoadPath->setText(path); +} + +void +MIDIConfigurationPage::slotSoundFontChoose() +{ + QString path = KFileDialog::getOpenFileName(":SOUNDFONTS", "*.sb *.sf2 *.SF2 *.SB", this, i18n("Soundfont path")); + m_soundFontPath->setText(path); +} + +void +MIDIConfigurationPage::apply() +{ + m_cfg->setGroup(SequencerOptionsConfigGroup); + + m_cfg->writeEntry("alwayssendcontrollers", + m_sendControllersAtPlay->isChecked()); + + m_cfg->writeEntry("sfxloadenabled", m_sfxLoadEnabled->isChecked()); + m_cfg->writeEntry("sfxloadpath", m_sfxLoadPath->text()); + m_cfg->writeEntry("soundfontpath", m_soundFontPath->text()); + + m_cfg->writeEntry("timer", m_timer->currentText()); + if (m_timer->currentText() != m_origTimer) { + m_doc->setCurrentTimer(m_timer->currentText()); + } + + // Write the entries + // + m_cfg->writeEntry("mmcmode", m_mmcTransport->currentItem()); + m_cfg->writeEntry("mtcmode", m_mtcTransport->currentItem()); + m_cfg->writeEntry("midisyncautoconnect", m_midiSyncAuto->isChecked()); + + // Now send + // + MappedEvent mEmccValue(MidiInstrumentBase, // InstrumentId + MappedEvent::SystemMMCTransport, + MidiByte(m_mmcTransport->currentItem())); + + StudioControl::sendMappedEvent(mEmccValue); + + MappedEvent mEmtcValue(MidiInstrumentBase, // InstrumentId + MappedEvent::SystemMTCTransport, + MidiByte(m_mtcTransport->currentItem())); + + StudioControl::sendMappedEvent(mEmtcValue); + + MappedEvent mEmsaValue(MidiInstrumentBase, // InstrumentId + MappedEvent::SystemMIDISyncAuto, + MidiByte(m_midiSyncAuto->isChecked() ? 1 : 0)); + + StudioControl::sendMappedEvent(mEmsaValue); + + + // ------------- MIDI Clock and System messages ------------ + // + int midiClock = m_midiSync->currentItem(); + m_cfg->writeEntry("midiclock", midiClock); + + // Now send it (OLD METHOD - to be removed) + //!!! No, don't remove -- this controls SPP as well doesn't it? + // + MappedEvent mEMIDIClock(MidiInstrumentBase, // InstrumentId + MappedEvent::SystemMIDIClock, + MidiByte(midiClock)); + + StudioControl::sendMappedEvent(mEMIDIClock); + + + // Now update the metronome mapped segment with new clock ticks + // if needed. + // + Studio &studio = m_doc->getStudio(); + const MidiMetronome *metronome = studio. + getMetronomeFromDevice(studio.getMetronomeDevice()); + + if (metronome) { + InstrumentId instrument = metronome->getInstrument(); + m_doc->getSequenceManager()->metronomeChanged(instrument, true); + } + + m_cfg->setGroup(GeneralOptionsConfigGroup); + + bool deftstudio = getUseDefaultStudio(); + m_cfg->writeEntry("alwaysusedefaultstudio", deftstudio); + + int octave = m_midiPitchOctave->value(); + m_cfg->writeEntry("midipitchoctave", octave); +} + +} +#include "MIDIConfigurationPage.moc" diff --git a/src/gui/configuration/MIDIConfigurationPage.h b/src/gui/configuration/MIDIConfigurationPage.h new file mode 100644 index 0000000..243f041 --- /dev/null +++ b/src/gui/configuration/MIDIConfigurationPage.h @@ -0,0 +1,104 @@ +/* -*- 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. +*/ + +#ifndef _RG_MIDICONFIGURATIONPAGE_H_ +#define _RG_MIDICONFIGURATIONPAGE_H_ + +#include "TabbedConfigurationPage.h" +#include <qstring.h> +#include <klocale.h> +#include <qlineedit.h> +#include <qcheckbox.h> + + +class QWidget; +class QSpinBox; +class QSlider; +class QPushButton; +class QLabel; +class QComboBox; +class KConfig; +class KComboBox; + + +namespace Rosegarden +{ + +class RosegardenGUIDoc; + + +class MIDIConfigurationPage : public TabbedConfigurationPage +{ + Q_OBJECT +public: + MIDIConfigurationPage(RosegardenGUIDoc *doc, + KConfig *cfg, + QWidget *parent=0, + const char *name=0); + + virtual void apply(); + + static QString iconLabel() { return i18n("MIDI"); } + static QString title() { return i18n("MIDI Settings"); } + static QString iconName() { return "configure-midi"; } + +protected slots: + void slotSoundFontToggled(bool); + void slotSfxLoadPathChoose(); + void slotSoundFontChoose(); + +protected: + bool getUseDefaultStudio() { return m_studio->isChecked(); } + + //--------------- Data members --------------------------------- + + // General + QCheckBox *m_sendControllersAtPlay; + + QCheckBox *m_sfxLoadEnabled; + QLineEdit *m_sfxLoadPath; + QPushButton *m_sfxLoadChoose; + QLineEdit *m_soundFontPath; + QPushButton *m_soundFontChoose; + + // Sync and timing + // + //QCheckBox *m_midiClockEnabled; + QComboBox *m_midiSync; + QString m_origTimer; + QComboBox *m_timer; + QComboBox *m_mmcTransport; + QComboBox *m_mtcTransport; + QCheckBox *m_midiSyncAuto; + + QCheckBox* m_studio; + QSpinBox* m_midiPitchOctave; + +}; + + + +} + +#endif diff --git a/src/gui/configuration/MatrixConfigurationPage.cpp b/src/gui/configuration/MatrixConfigurationPage.cpp new file mode 100644 index 0000000..e21f3fd --- /dev/null +++ b/src/gui/configuration/MatrixConfigurationPage.cpp @@ -0,0 +1,68 @@ +/* -*- 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 "MatrixConfigurationPage.h" + +#include "document/ConfigGroups.h" +#include "ConfigurationPage.h" +#include "document/RosegardenGUIDoc.h" +#include "document/ConfigGroups.h" +#include "gui/editors/matrix/MatrixView.h" +#include "TabbedConfigurationPage.h" +#include <kconfig.h> +#include <qframe.h> +#include <qlabel.h> +#include <qstring.h> +#include <qtabwidget.h> +#include <qwidget.h> +#include <qlayout.h> + +namespace Rosegarden +{ + +MatrixConfigurationPage::MatrixConfigurationPage(KConfig *cfg, + QWidget *parent, + const char *name) : + TabbedConfigurationPage(cfg, parent, name) +{ + m_cfg->setGroup(MatrixViewConfigGroup); + + QFrame *frame = new QFrame(m_tabWidget); + QGridLayout *layout = new QGridLayout(frame, + 4, 2, // nbrow, nbcol + 10, 5); + + layout->addWidget(new QLabel("Nothing here yet", frame), 0, 0); + + addTab(frame, i18n("General")); +} + +void MatrixConfigurationPage::apply() +{ + m_cfg->setGroup(MatrixViewConfigGroup); +} + +} +#include "MatrixConfigurationPage.moc" diff --git a/src/gui/configuration/MatrixConfigurationPage.h b/src/gui/configuration/MatrixConfigurationPage.h new file mode 100644 index 0000000..9c4b3fc --- /dev/null +++ b/src/gui/configuration/MatrixConfigurationPage.h @@ -0,0 +1,69 @@ + +/* -*- 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. +*/ + +#ifndef _RG_MATRIXCONFIGURATIONPAGE_H_ +#define _RG_MATRIXCONFIGURATIONPAGE_H_ + +#include "TabbedConfigurationPage.h" +#include <qstring.h> +#include <klocale.h> + + +class QWidget; +class KConfig; + + +namespace Rosegarden +{ + + + +/** + * Notation Configuration page + */ +class MatrixConfigurationPage : public TabbedConfigurationPage +{ + Q_OBJECT + +public: + MatrixConfigurationPage(KConfig *cfg, + QWidget *parent = 0, const char *name=0); + + virtual void apply(); + + static QString iconLabel() { return i18n("Matrix"); } + static QString title() { return i18n("Matrix"); } + +protected slots: + +protected: + + //--------------- Data members --------------------------------- +}; + + +} + +#endif diff --git a/src/gui/configuration/NotationConfigurationPage.cpp b/src/gui/configuration/NotationConfigurationPage.cpp new file mode 100644 index 0000000..a828fe7 --- /dev/null +++ b/src/gui/configuration/NotationConfigurationPage.cpp @@ -0,0 +1,741 @@ +/* -*- 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 "NotationConfigurationPage.h" +#include <qlayout.h> + +#include "misc/Strings.h" +#include "document/ConfigGroups.h" +#include "base/Exception.h" +#include "base/NotationTypes.h" +#include "commands/edit/PasteEventsCommand.h" +#include "ConfigurationPage.h" +#include "document/RosegardenGUIDoc.h" +#include "gui/editors/notation/HeadersGroup.h" +#include "gui/editors/notation/NotationHLayout.h" +#include "gui/editors/notation/NoteFontFactory.h" +#include "gui/editors/notation/NoteFont.h" +#include "gui/editors/notation/NoteFontMap.h" +#include "gui/editors/notation/NoteFontViewer.h" +#include "gui/editors/notation/NotePixmapFactory.h" +#include "gui/editors/notation/NoteStyleFactory.h" +#include "gui/widgets/QuantizeParameters.h" +#include "TabbedConfigurationPage.h" +#include <kcombobox.h> +#include <kconfig.h> +#include <kfontrequester.h> +#include <kmessagebox.h> +#include <qcheckbox.h> +#include <qcombobox.h> +#include <qfont.h> +#include <qframe.h> +#include <qgroupbox.h> +#include <qhbox.h> +#include <qlabel.h> +#include <qobject.h> +#include <qpushbutton.h> +#include <qstring.h> +#include <qstringlist.h> +#include <qtabwidget.h> +#include <qwidget.h> +#include <qtooltip.h> +#include <algorithm> + +namespace Rosegarden +{ + +NotationConfigurationPage::NotationConfigurationPage(KConfig *cfg, + QWidget *parent, + const char *name) : + TabbedConfigurationPage(cfg, parent, name) +{ + m_cfg->setGroup(NotationViewConfigGroup); + + QFrame *frame; + QGridLayout *layout; + + frame = new QFrame(m_tabWidget); + layout = new QGridLayout(frame, 9, 3, 10, 5); + + int row = 0; + + layout->setRowSpacing(row, 15); + ++row; + + layout->addWidget(new QLabel(i18n("Default layout mode"), frame), row, 0); + + m_layoutMode = new KComboBox(frame); + m_layoutMode->setEditable(false); + m_layoutMode->insertItem(i18n("Linear layout")); + m_layoutMode->insertItem(i18n("Continuous page layout")); + m_layoutMode->insertItem(i18n("Multiple page layout")); + int defaultLayoutMode = m_cfg->readNumEntry("layoutmode", 0); + if (defaultLayoutMode >= 0 && defaultLayoutMode <= 2) { + m_layoutMode->setCurrentItem(defaultLayoutMode); + } + layout->addMultiCellWidget(m_layoutMode, row, row, 1, 2); + ++row; + + layout->addWidget(new QLabel(i18n("Default spacing"), frame), row, 0); + + m_spacing = new KComboBox(frame); + m_spacing->setEditable(false); + + std::vector<int> s = NotationHLayout::getAvailableSpacings(); + int defaultSpacing = m_cfg->readNumEntry("spacing", 100); + + for (std::vector<int>::iterator i = s.begin(); i != s.end(); ++i) { + + QString text("%1 %"); + if (*i == 100) + text = "%1 % (normal)"; + m_spacing->insertItem(text.arg(*i)); + + if (*i == defaultSpacing) { + m_spacing->setCurrentItem(m_spacing->count() - 1); + } + } + + layout->addMultiCellWidget(m_spacing, row, row, 1, 2); + + ++row; + + layout->addWidget(new QLabel(i18n("Default duration factor"), frame), row, 0); + + m_proportion = new KComboBox(frame); + m_proportion->setEditable(false); + + s = NotationHLayout::getAvailableProportions(); + int defaultProportion = m_cfg->readNumEntry("proportion", 60); + + for (std::vector<int>::iterator i = s.begin(); i != s.end(); ++i) { + + QString text = QString("%1 %").arg(*i); + if (*i == 40) + text = "40 % (normal)"; + else if (*i == 0) + text = i18n("None"); + else if (*i == 100) + text = i18n("Full"); + m_proportion->insertItem(text); + + if (*i == defaultProportion) { + m_proportion->setCurrentItem(m_proportion->count() - 1); + } + } + + layout->addMultiCellWidget(m_proportion, row, row, 1, 2); + ++row; + + layout->addWidget(new QLabel(i18n("Show track headers (linear layout only)"), + frame), row, 0); + + m_showTrackHeaders = new KComboBox(frame); + m_showTrackHeaders->setEditable(false); + m_showTrackHeaders->insertItem(i18n("Never"), HeadersGroup::ShowNever); + m_showTrackHeaders->insertItem(i18n("When needed"), HeadersGroup::ShowWhenNeeded); + m_showTrackHeaders->insertItem(i18n("Always"), HeadersGroup::ShowAlways); + int defaultShowTrackHeaders = m_cfg->readNumEntry("shownotationheader", + HeadersGroup::DefaultShowMode); + if (HeadersGroup::isValidShowMode(defaultShowTrackHeaders)) { + m_showTrackHeaders->setCurrentItem(defaultShowTrackHeaders); + } + QToolTip::add(m_showTrackHeaders, QString(i18n( + "\"Always\" and \"Never\" mean what they usually mean\n" + "\"When needed\" means \"when staves are too many to all fit" + " in the current window\""))); + + layout->addMultiCellWidget(m_showTrackHeaders, row, row, 1, 2); + ++row; + + layout->setRowSpacing(row, 20); + ++row; + + layout->addMultiCellWidget + (new QLabel + (i18n("Show non-notation events as question marks"), frame), + row, row, 0, 1); + m_showUnknowns = new QCheckBox(frame); + bool defaultShowUnknowns = m_cfg->readBoolEntry("showunknowns", false); + m_showUnknowns->setChecked(defaultShowUnknowns); + layout->addWidget(m_showUnknowns, row, 2); + ++row; + + layout->addMultiCellWidget + (new QLabel + (i18n("Show notation-quantized notes in a different color"), frame), + row, row, 0, 1); + m_colourQuantize = new QCheckBox(frame); + bool defaultColourQuantize = m_cfg->readBoolEntry("colourquantize", false); + m_colourQuantize->setChecked(defaultColourQuantize); + layout->addWidget(m_colourQuantize, row, 2); + ++row; + + layout->addMultiCellWidget + (new QLabel + (i18n("Show \"invisible\" events in grey"), frame), + row, row, 0, 1); + m_showInvisibles = new QCheckBox(frame); + bool defaultShowInvisibles = m_cfg->readBoolEntry("showinvisibles", true); + m_showInvisibles->setChecked(defaultShowInvisibles); + layout->addWidget(m_showInvisibles, row, 2); + ++row; + + layout->addMultiCellWidget + (new QLabel + (i18n("Show notes outside suggested playable range in red"), frame), + row, row, 0, 1); + m_showRanges = new QCheckBox(frame); + bool defaultShowRanges = m_cfg->readBoolEntry("showranges", true); + m_showRanges->setChecked(defaultShowRanges); + layout->addWidget(m_showRanges, row, 2); + ++row; + + layout->addMultiCellWidget + (new QLabel + (i18n("Highlight superimposed notes with a halo effect"), frame), + row, row, 0, 1); + m_showCollisions = new QCheckBox(frame); + bool defaultShowCollisions = m_cfg->readBoolEntry("showcollisions", true); + m_showCollisions->setChecked(defaultShowCollisions); + layout->addWidget(m_showCollisions, row, 2); + ++row; + + layout->setRowSpacing(row, 20); + ++row; + + layout->addMultiCellWidget + (new QLabel + (i18n("When recording MIDI, split-and-tie long notes at barlines"), frame), + row, row, 0, 1); + m_splitAndTie = new QCheckBox(frame); + bool defaultSplitAndTie = m_cfg->readBoolEntry("quantizemakeviable", false); + m_splitAndTie->setChecked(defaultSplitAndTie); + layout->addWidget(m_splitAndTie, row, 2); + ++row; + + layout->setRowStretch(row, 10); + + + addTab(frame, i18n("Layout")); + + + + frame = new QFrame(m_tabWidget); + layout = new QGridLayout(frame, 6, 3, 10, 5); + + row = 0; + + layout->setRowSpacing(row, 15); + ++row; + + layout->addMultiCellWidget + (new QLabel(i18n("Default note style for new notes"), frame), + row, row, 0, 1); + + layout->setColStretch(2, 10); + + m_noteStyle = new KComboBox(frame); + m_noteStyle->setEditable(false); + m_untranslatedNoteStyle.clear(); + + QString defaultStyle = + m_cfg->readEntry("style", strtoqstr(NoteStyleFactory::DefaultStyle)); + std::vector<NoteStyleName> styles + (NoteStyleFactory::getAvailableStyleNames()); + + for (std::vector<NoteStyleName>::iterator i = styles.begin(); + i != styles.end(); ++i) { + + QString styleQName(strtoqstr(*i)); + m_untranslatedNoteStyle.append(styleQName); + m_noteStyle->insertItem(i18n(styleQName.utf8())); + if (styleQName == defaultStyle) { + m_noteStyle->setCurrentItem(m_noteStyle->count() - 1); + } + } + + layout->addWidget(m_noteStyle, row, 2); + ++row; + + layout->setRowSpacing(row, 20); + ++row; + + layout->addWidget + (new QLabel(i18n("When inserting notes..."), frame), row, 0); + + int defaultInsertType = m_cfg->readNumEntry("inserttype", 0); + + m_insertType = new KComboBox(frame); + m_insertType->setEditable(false); + m_insertType->insertItem + (i18n("Split notes into ties to make durations match")); + m_insertType->insertItem(i18n("Ignore existing durations")); + m_insertType->setCurrentItem(defaultInsertType); + + layout->addMultiCellWidget(m_insertType, row, row, 1, 2); + ++row; + + bool autoBeam = m_cfg->readBoolEntry("autobeam", true); + + layout->addMultiCellWidget + (new QLabel + (i18n("Auto-beam on insert when appropriate"), frame), + row, row, 0, 1); + m_autoBeam = new QCheckBox(frame); + m_autoBeam->setChecked(autoBeam); + layout->addMultiCellWidget(m_autoBeam, row, row, 2, 2); + + ++row; + + bool collapse = m_cfg->readBoolEntry("collapse", false); + + layout->addMultiCellWidget + (new QLabel + (i18n("Collapse rests after erase"), frame), + row, row, 0, 1); + m_collapseRests = new QCheckBox(frame); + m_collapseRests->setChecked(collapse); + layout->addMultiCellWidget(m_collapseRests, row, row, 2, 2); + ++row; + + layout->setRowSpacing(row, 20); + ++row; + + layout->addWidget + (new QLabel(i18n("Default paste type"), frame), row, 0); + + m_pasteType = new KComboBox(frame); + m_pasteType->setEditable(false); + + unsigned int defaultPasteType = m_cfg->readUnsignedNumEntry + ("pastetype", PasteEventsCommand::Restricted); + + PasteEventsCommand::PasteTypeMap pasteTypes = + PasteEventsCommand::getPasteTypes(); + + for (PasteEventsCommand::PasteTypeMap::iterator i = pasteTypes.begin(); + i != pasteTypes.end(); ++i) { + m_pasteType->insertItem(i->second); + } + + m_pasteType->setCurrentItem(defaultPasteType); + layout->addMultiCellWidget(m_pasteType, row, row, 1, 2); + ++row; + + layout->setRowStretch(row, 10); + + addTab(frame, i18n("Editing")); + + + + frame = new QFrame(m_tabWidget); + layout = new QGridLayout(frame, 4, 2, 10, 5); + + row = 0; + + layout->setRowSpacing(row, 15); + ++row; + + layout->addWidget(new QLabel(i18n("Accidentals in one octave..."), frame), row, 0); + m_accOctavePolicy = new KComboBox(frame); + m_accOctavePolicy->insertItem(i18n("Affect only that octave")); + m_accOctavePolicy->insertItem(i18n("Require cautionaries in other octaves")); + m_accOctavePolicy->insertItem(i18n("Affect all subsequent octaves")); + int accOctaveMode = m_cfg->readNumEntry("accidentaloctavemode", 1); + if (accOctaveMode >= 0 && accOctaveMode < 3) { + m_accOctavePolicy->setCurrentItem(accOctaveMode); + } + layout->addWidget(m_accOctavePolicy, row, 1); + ++row; + + layout->addWidget(new QLabel(i18n("Accidentals in one bar..."), frame), row, 0); + m_accBarPolicy = new KComboBox(frame); + m_accBarPolicy->insertItem(i18n("Affect only that bar")); + m_accBarPolicy->insertItem(i18n("Require cautionary resets in following bar")); + m_accBarPolicy->insertItem(i18n("Require explicit resets in following bar")); + int accBarMode = m_cfg->readNumEntry("accidentalbarmode", 0); + if (accBarMode >= 0 && accBarMode < 3) { + m_accBarPolicy->setCurrentItem(accBarMode); + } + layout->addWidget(m_accBarPolicy, row, 1); + ++row; + + layout->addWidget(new QLabel(i18n("Key signature cancellation style"), frame), row, 0); + m_keySigCancelMode = new KComboBox(frame); + m_keySigCancelMode->insertItem(i18n("Cancel only when entering C major or A minor")); + m_keySigCancelMode->insertItem(i18n("Cancel whenever removing sharps or flats")); + m_keySigCancelMode->insertItem(i18n("Cancel always")); + int cancelMode = m_cfg->readNumEntry("keysigcancelmode", 1); + if (cancelMode >= 0 && cancelMode < 3) { + m_keySigCancelMode->setCurrentItem(cancelMode); + } + layout->addWidget(m_keySigCancelMode, row, 1); + ++row; + + layout->setRowStretch(row, 10); + + addTab(frame, i18n("Accidentals")); + +/* + QString preamble = + (i18n("Rosegarden can apply automatic quantization to recorded " + "or imported MIDI data for notation purposes only. " + "This does not affect playback, and does not affect " + "editing in any of the views except notation.")); + + // force to default of 2 if not used before + int quantizeType = m_cfg->readNumEntry("quantizetype", 2); + m_cfg->writeEntry("quantizetype", quantizeType); + m_cfg->writeEntry("quantizenotationonly", true); + + m_quantizeFrame = new QuantizeParameters + (m_tabWidget, QuantizeParameters::Notation, + false, false, "Notation Options", preamble); + + addTab(m_quantizeFrame, i18n("Quantize")); +*/ + row = 0; + +// QFrame *mainFrame = new QFrame(m_tabWidget); +// QGridLayout *mainLayout = new QGridLayout(mainFrame, 2, 4, 10, 5); + +// QGroupBox *noteFontBox = new QGroupBox(1, Horizontal, i18n("Notation font"), mainFrame); +// QGroupBox *otherFontBox = new QGroupBox(1, Horizontal, i18n("Other fonts"), mainFrame); +// QGroupBox *descriptionBox = new QGroupBox(1, Horizontal, i18n("Description"), mainFrame); + +// mainLayout->addWidget(noteFontBox, 0, 0); +// mainLayout->addWidget(otherFontBox, 1, 0); + +// QFrame *mainFrame = new QFrame(m_tabWidget); + frame = new QFrame(m_tabWidget); + layout = new QGridLayout(frame, 2, 4, 10, 5); + +// frame = new QFrame(noteFontBox); +// layout = new QGridLayout(frame, 5, 2, 10, 5); + + m_viewButton = 0; + + layout->addWidget(new QLabel(i18n("Notation font"), frame), 0, 0); + + m_font = new KComboBox(frame); + +#ifdef HAVE_XFT + m_viewButton = new QPushButton(i18n("View"), frame); + layout->addMultiCellWidget(m_font, row, row, 1, 2); + layout->addWidget(m_viewButton, row, 3); + QObject::connect(m_viewButton, SIGNAL(clicked()), + this, SLOT(slotViewButtonPressed())); +#else + layout->addMultiCellWidget(m_font, row, row, 1, 3); +#endif + m_font->setEditable(false); + QObject::connect(m_font, SIGNAL(activated(int)), + this, SLOT(slotFontComboChanged(int))); + ++row; + + QFrame *subFrame = new QFrame(frame); + QGridLayout *subLayout = new QGridLayout(subFrame, + 4, 2, // nbrow, nbcol + 12, 2); + + QFont font = m_font->font(); + font.setPointSize((font.pointSize() * 9) / 10); + + QLabel *originLabel = new QLabel(i18n("Origin:"), subFrame); + originLabel->setFont(font); + subLayout->addWidget(originLabel, 0, 0); + + QLabel *copyrightLabel = new QLabel(i18n("Copyright:"), subFrame); + copyrightLabel->setFont(font); + subLayout->addWidget(copyrightLabel, 1, 0); + + QLabel *mappedLabel = new QLabel(i18n("Mapped by:"), subFrame); + mappedLabel->setFont(font); + subLayout->addWidget(mappedLabel, 2, 0); + + QLabel *typeLabel = new QLabel(i18n("Type:"), subFrame); + typeLabel->setFont(font); + subLayout->addWidget(typeLabel, 3, 0); + + m_fontOriginLabel = new QLabel(subFrame); + m_fontOriginLabel->setAlignment(Qt::WordBreak); + m_fontOriginLabel->setFont(font); +// m_fontOriginLabel->setFixedWidth(250); + m_fontCopyrightLabel = new QLabel(subFrame); + m_fontCopyrightLabel->setAlignment(Qt::WordBreak); + m_fontCopyrightLabel->setFont(font); +// m_fontCopyrightLabel->setFixedWidth(250); + m_fontMappedByLabel = new QLabel(subFrame); + m_fontMappedByLabel->setFont(font); + m_fontTypeLabel = new QLabel(subFrame); + m_fontTypeLabel->setFont(font); + subLayout->addWidget(m_fontOriginLabel, 0, 1); + subLayout->addWidget(m_fontCopyrightLabel, 1, 1); + subLayout->addWidget(m_fontMappedByLabel, 2, 1); + subLayout->addWidget(m_fontTypeLabel, 3, 1); + + subLayout->setColStretch(1, 10); + + layout->addMultiCellWidget(subFrame, + row, row, + 0, 3); + ++row; + + layout->addMultiCellWidget + (new QLabel(i18n("Font size for single-staff views"), frame), + row, row, 0, 1); + m_singleStaffSize = new KComboBox(frame); + m_singleStaffSize->setEditable(false); + layout->addMultiCellWidget(m_singleStaffSize, row, row, 2, 2); + ++row; + + layout->addMultiCellWidget + (new QLabel(i18n("Font size for multi-staff views"), frame), + row, row, 0, 1); + m_multiStaffSize = new KComboBox(frame); + m_multiStaffSize->setEditable(false); + layout->addMultiCellWidget(m_multiStaffSize, row, row, 2, 2); + ++row; + + layout->addMultiCellWidget + (new QLabel(i18n("Font size for printing (pt)"), frame), + row, row, 0, 1); + m_printingSize = new KComboBox(frame); + m_printingSize->setEditable(false); + layout->addMultiCellWidget(m_printingSize, row, row, 2, 2); + ++row; + + slotPopulateFontCombo(false); + + layout->setRowSpacing(row, 15); + ++row; + + QFont defaultTextFont(NotePixmapFactory::defaultSerifFontFamily), + defaultSansFont(NotePixmapFactory::defaultSansSerifFontFamily), + defaultTimeSigFont(NotePixmapFactory::defaultTimeSigFontFamily); + + layout->addWidget + (new QLabel(i18n("Text font"), frame), row, 0); + m_textFont = new KFontRequester(frame); + QFont textFont = m_cfg->readFontEntry("textfont", &defaultTextFont); + m_textFont->setFont(textFont); + layout->addMultiCellWidget(m_textFont, row, row, 1, 3); + ++row; + + layout->addWidget + (new QLabel(i18n("Sans-serif font"), frame), row, 0); + m_sansFont = new KFontRequester(frame); + QFont sansFont = m_cfg->readFontEntry("sansfont", &defaultSansFont); + m_sansFont->setFont(sansFont); + layout->addMultiCellWidget(m_sansFont, row, row, 1, 3); + ++row; + +/*!!! No -- not much point in having the time sig font here: it's only + * used if the time sig characters are not found in the notation font, + * and our default notation font has all the characters we need + + layout->addWidget + (new QLabel(i18n("Time Signature font"), frame), row, 0); + m_timeSigFont = new KFontRequester(frame); + QFont timeSigFont = m_cfg->readFontEntry("timesigfont", &defaultTimeSigFont); + m_timeSigFont->setFont(timeSigFont); + layout->addMultiCellWidget(m_timeSigFont, row, row, 1, 3); + ++row; +*/ + +// addTab(mainFrame, i18n("Font")); + addTab(frame, i18n("Font")); + + +} + +void +NotationConfigurationPage::slotViewButtonPressed() +{ +#ifdef HAVE_XFT + std::string fontName = qstrtostr(m_untranslatedFont[m_font->currentItem()]); + + try { + NoteFont *noteFont = NoteFontFactory::getFont + (fontName, NoteFontFactory::getDefaultSize(fontName)); + const NoteFontMap &map(noteFont->getNoteFontMap()); + QStringList systemFontNames(map.getSystemFontNames()); + if (systemFontNames.count() == 0) { + m_viewButton->setEnabled(false); // oops + } else { + NoteFontViewer *viewer = + new NoteFontViewer(0, m_untranslatedFont[m_font->currentItem()], + systemFontNames, 24); + (void)viewer->exec(); // no return value + } + } catch (Exception f) { + KMessageBox::error(0, i18n(strtoqstr(f.getMessage()))); + } +#endif +} + +void +NotationConfigurationPage::slotPopulateFontCombo(bool rescan) +{ + QString defaultFont = m_cfg->readEntry + ("notefont", strtoqstr(NoteFontFactory::getDefaultFontName())); + + try { + (void)NoteFontFactory::getFont + (qstrtostr(defaultFont), + NoteFontFactory::getDefaultSize(qstrtostr(defaultFont))); + } catch (Exception e) { + defaultFont = strtoqstr(NoteFontFactory::getDefaultFontName()); + } + + std::set + <std::string> fs(NoteFontFactory::getFontNames(rescan)); + std::vector<std::string> f(fs.begin(), fs.end()); + std::sort(f.begin(), f.end()); + + m_untranslatedFont.clear(); + m_font->clear(); + + for (std::vector<std::string>::iterator i = f.begin(); i != f.end(); ++i) { + QString s(strtoqstr(*i)); + m_untranslatedFont.append(s); + m_font->insertItem(i18n(s.utf8())); + if (s == defaultFont) + m_font->setCurrentItem(m_font->count() - 1); + } + + slotFontComboChanged(m_font->currentItem()); +} + +void +NotationConfigurationPage::slotFontComboChanged(int index) +{ + std::string fontStr = qstrtostr(m_untranslatedFont[index]); + + populateSizeCombo(m_singleStaffSize, fontStr, + m_cfg->readUnsignedNumEntry + ("singlestaffnotesize", + NoteFontFactory::getDefaultSize(fontStr))); + populateSizeCombo(m_multiStaffSize, fontStr, + m_cfg->readUnsignedNumEntry + ("multistaffnotesize", + NoteFontFactory::getDefaultSize(fontStr))); + + int printpt = m_cfg->readUnsignedNumEntry("printingnotesize", 5); + for (int i = 2; i < 16; ++i) { + m_printingSize->insertItem(QString("%1").arg(i)); + if (i == printpt) { + m_printingSize->setCurrentItem(m_printingSize->count() - 1); + } + } + + try { + NoteFont *noteFont = NoteFontFactory::getFont + (fontStr, NoteFontFactory::getDefaultSize(fontStr)); + const NoteFontMap &map(noteFont->getNoteFontMap()); + m_fontOriginLabel->setText(i18n(strtoqstr(map.getOrigin()))); + m_fontCopyrightLabel->setText(i18n(strtoqstr(map.getCopyright()))); + m_fontMappedByLabel->setText(i18n(strtoqstr(map.getMappedBy()))); + if (map.isSmooth()) { + m_fontTypeLabel->setText( + i18n("%1 (smooth)").arg(i18n(strtoqstr(map.getType())))); + } else { + m_fontTypeLabel->setText( + i18n("%1 (jaggy)").arg(i18n(strtoqstr(map.getType())))); + } + if (m_viewButton) { + m_viewButton->setEnabled(map.getSystemFontNames().count() > 0); + } + } catch (Exception f) { + KMessageBox::error(0, i18n(strtoqstr(f.getMessage()))); + } +} + +void +NotationConfigurationPage::populateSizeCombo(QComboBox *combo, + std::string font, + int defaultSize) +{ + std::vector<int> sizes = NoteFontFactory::getScreenSizes(font); + combo->clear(); + + for (std::vector<int>::iterator i = sizes.begin(); i != sizes.end(); ++i) { + combo->insertItem(QString("%1").arg(*i)); + if (*i == defaultSize) + combo->setCurrentItem(combo->count() - 1); + } +} + +void +NotationConfigurationPage::apply() +{ + m_cfg->setGroup(NotationViewConfigGroup); + + m_cfg->writeEntry("notefont", m_untranslatedFont[m_font->currentItem()]); + m_cfg->writeEntry("singlestaffnotesize", + m_singleStaffSize->currentText().toUInt()); + m_cfg->writeEntry("multistaffnotesize", + m_multiStaffSize->currentText().toUInt()); + m_cfg->writeEntry("printingnotesize", + m_printingSize->currentText().toUInt()); + m_cfg->writeEntry("textfont", + m_textFont->font()); + m_cfg->writeEntry("sansfont", + m_sansFont->font()); +/*!!! + m_cfg->writeEntry("timesigfont", + m_timeSigFont->font()); +*/ + std::vector<int> s = NotationHLayout::getAvailableSpacings(); + m_cfg->writeEntry("spacing", s[m_spacing->currentItem()]); + + s = NotationHLayout::getAvailableProportions(); + m_cfg->writeEntry("proportion", s[m_proportion->currentItem()]); + + m_cfg->writeEntry("layoutmode", m_layoutMode->currentItem()); + m_cfg->writeEntry("colourquantize", m_colourQuantize->isChecked()); + m_cfg->writeEntry("showunknowns", m_showUnknowns->isChecked()); + m_cfg->writeEntry("showinvisibles", m_showInvisibles->isChecked()); + m_cfg->writeEntry("showranges", m_showRanges->isChecked()); + m_cfg->writeEntry("showcollisions", m_showCollisions->isChecked()); + m_cfg->writeEntry("shownotationheader", + m_showTrackHeaders->currentItem()); + m_cfg->writeEntry("style", m_untranslatedNoteStyle[m_noteStyle->currentItem()]); + m_cfg->writeEntry("inserttype", m_insertType->currentItem()); + m_cfg->writeEntry("autobeam", m_autoBeam->isChecked()); + m_cfg->writeEntry("collapse", m_collapseRests->isChecked()); + m_cfg->writeEntry("pastetype", m_pasteType->currentItem()); + m_cfg->writeEntry("accidentaloctavemode", m_accOctavePolicy->currentItem()); + m_cfg->writeEntry("accidentalbarmode", m_accBarPolicy->currentItem()); + m_cfg->writeEntry("keysigcancelmode", m_keySigCancelMode->currentItem()); + + m_cfg->writeEntry("quantizemakeviable", m_splitAndTie->isChecked()); + +// (void)m_quantizeFrame->getQuantizer(); // this also writes to the config +} + +} +#include "NotationConfigurationPage.moc" diff --git a/src/gui/configuration/NotationConfigurationPage.h b/src/gui/configuration/NotationConfigurationPage.h new file mode 100644 index 0000000..a3d3dc5 --- /dev/null +++ b/src/gui/configuration/NotationConfigurationPage.h @@ -0,0 +1,117 @@ + +/* -*- 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. +*/ + +#ifndef _RG_NOTATIONCONFIGURATIONPAGE_H_ +#define _RG_NOTATIONCONFIGURATIONPAGE_H_ + +#include <string> +#include "TabbedConfigurationPage.h" +#include <qstring.h> +#include <qstringlist.h> +#include <klocale.h> + + +class QWidget; +class QPushButton; +class QLabel; +class QComboBox; +class QCheckBox; +class KFontRequester; +class KConfig; + + +namespace Rosegarden +{ + +class QuantizeParameters; + + +/** + * Notation Configuration page + */ +class NotationConfigurationPage : public TabbedConfigurationPage +{ + Q_OBJECT + +public: + NotationConfigurationPage(KConfig *cfg, + QWidget *parent = 0, const char *name=0); + + virtual void apply(); + + static QString iconLabel() { return i18n("Notation"); } + static QString title() { return i18n("Notation"); } + static QString iconName() { return "configure-notation"; } + +protected slots: + void slotFontComboChanged(int); + void slotPopulateFontCombo(bool rescan); + void slotViewButtonPressed(); + +protected: + + //--------------- Data members --------------------------------- + + QComboBox *m_font; + QComboBox *m_singleStaffSize; + QComboBox *m_multiStaffSize; + QComboBox *m_printingSize; + KFontRequester* m_textFont; + KFontRequester* m_sansFont; + KFontRequester* m_timeSigFont; + QPushButton *m_viewButton; + QLabel *m_fontOriginLabel; + QLabel *m_fontCopyrightLabel; + QLabel *m_fontMappedByLabel; + QLabel *m_fontTypeLabel; + QComboBox *m_layoutMode; + QComboBox *m_spacing; + QComboBox *m_proportion; + QCheckBox *m_colourQuantize; + QCheckBox *m_showUnknowns; + QCheckBox *m_showInvisibles; + QCheckBox *m_showRanges; + QCheckBox *m_showCollisions; + QComboBox *m_showTrackHeaders; + QComboBox *m_noteStyle; + QComboBox *m_insertType; + QCheckBox *m_autoBeam; + QCheckBox *m_collapseRests; + QComboBox *m_pasteType; + QComboBox *m_accOctavePolicy; + QComboBox *m_accBarPolicy; + QComboBox *m_keySigCancelMode; + QCheckBox *m_splitAndTie; + QuantizeParameters *m_quantizeFrame; + QStringList m_untranslatedFont; + QStringList m_untranslatedNoteStyle; + + void populateSizeCombo(QComboBox *combo, std::string font, int dfltSize); +}; + + +} + +#endif diff --git a/src/gui/configuration/TabbedConfigurationPage.cpp b/src/gui/configuration/TabbedConfigurationPage.cpp new file mode 100644 index 0000000..cc808a9 --- /dev/null +++ b/src/gui/configuration/TabbedConfigurationPage.cpp @@ -0,0 +1,79 @@ +/* -*- 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 "TabbedConfigurationPage.h" + +#include "ConfigurationPage.h" +#include "document/RosegardenGUIDoc.h" +#include <kconfig.h> +#include <kdialog.h> +#include <qstring.h> +#include <qtabwidget.h> +#include <qwidget.h> +#include <qlayout.h> + + +namespace Rosegarden +{ + +TabbedConfigurationPage::TabbedConfigurationPage(RosegardenGUIDoc *doc, + QWidget *parent, + const char *name) + : ConfigurationPage(doc, parent, name) +{ + init(); +} + +TabbedConfigurationPage::TabbedConfigurationPage(KConfig *cfg, + QWidget *parent, + const char *name) + : ConfigurationPage(cfg, parent, name) +{ + init(); +} + +TabbedConfigurationPage::TabbedConfigurationPage(RosegardenGUIDoc *doc, + KConfig *cfg, + QWidget *parent, + const char *name) + : ConfigurationPage(doc, cfg, parent, name) +{ + init(); +} + +void TabbedConfigurationPage::init() +{ + QVBoxLayout *vlay = new QVBoxLayout(this, 0, KDialog::spacingHint()); + m_tabWidget = new QTabWidget(this); + vlay->addWidget(m_tabWidget); +} + +void TabbedConfigurationPage::addTab(QWidget *tab, const QString &title) +{ + m_tabWidget->addTab(tab, title); +} + +} +#include "TabbedConfigurationPage.moc" diff --git a/src/gui/configuration/TabbedConfigurationPage.h b/src/gui/configuration/TabbedConfigurationPage.h new file mode 100644 index 0000000..8c370d5 --- /dev/null +++ b/src/gui/configuration/TabbedConfigurationPage.h @@ -0,0 +1,78 @@ + +/* -*- 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. +*/ + +#ifndef _RG_TABBEDCONFIGURATIONPAGE_H_ +#define _RG_TABBEDCONFIGURATIONPAGE_H_ + +#include "ConfigurationPage.h" +#include <qstring.h> + + +class QWidget; +class QTabWidget; +class KConfig; + + +namespace Rosegarden +{ + +class RosegardenGUIDoc; + + +/** + * This class borrowed from KMail + * (c) 2000 The KMail Development Team + */ +class TabbedConfigurationPage : public ConfigurationPage +{ + Q_OBJECT + +public: + TabbedConfigurationPage(RosegardenGUIDoc *doc, + QWidget *parent=0, const char *name=0); + + TabbedConfigurationPage(KConfig *cfg, + QWidget *parent=0, const char *name=0); + + TabbedConfigurationPage(RosegardenGUIDoc *doc, + KConfig *cfg, + QWidget *parent=0, const char *name=0); + + static QString iconName() { return "misc"; } + +protected: + void init(); + void addTab(QWidget *tab, const QString &title); + + //--------------- Data members --------------------------------- + + QTabWidget *m_tabWidget; + +}; + + +} + +#endif |