transportdialog.cpp
来自「LINUX下的混音软件」· C++ 代码 · 共 1,086 行 · 第 1/3 页
CPP
1,086 行
/* -*- 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-2007 Guillaume Laurent <glaurent@telegraph-road.org>, Chris Cannam <cannam@all-day-breakfast.com>, Richard Bown <richard.bown@ferventsoftware.com> 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 "TransportDialog.h"#include <klocale.h>#include <kstddirs.h>#include "base/Composition.h"#include "base/NotationTypes.h"#include "base/RealTime.h"#include "gui/application/RosegardenApplication.h"#include "gui/general/MidiPitchLabel.h"#include "gui/studio/StudioControl.h"#include "gui/widgets/Label.h"#include "sound/MappedEvent.h"#include "document/ConfigGroups.h"#include <kconfig.h>#include <kglobal.h>#include <qaccel.h>#include <qcolor.h>#include <qcstring.h>#include <qdatastream.h>#include <qfont.h>#include <qhbox.h>#include <qlabel.h>#include <qpalette.h>#include <qpixmap.h>#include <qpushbutton.h>#include <qstring.h>#include <qtimer.h>#include <qwidget.h>namespace Rosegarden{TransportDialog::TransportDialog(QWidget *parent, const char *name, WFlags flags): QWidget(parent, name, WType_TopLevel | WStyle_DialogBorder | WStyle_Minimize | WStyle_SysMenu | WDestructiveClose), m_transport(0), m_lastTenHours(0), m_lastUnitHours(0), m_lastTenMinutes(0), m_lastUnitMinutes(0), m_lastTenSeconds(0), m_lastUnitSeconds(0), m_lastTenths(0), m_lastHundreths(0), m_lastThousandths(0), m_lastTenThousandths(0), m_lastNegative(false), m_lastMode(RealMode), m_currentMode(RealMode), m_tempo(0), m_numerator(0), m_denominator(0), m_framesPerSecond(24), m_bitsPerFrame(80), m_isExpanded(false), m_haveOriginalBackground(false), m_isBackgroundSet(false), m_sampleRate(0){ m_transport = new RosegardenTransport(this); setCaption(i18n("Rosegarden Transport")); resetFonts(); // set the LCD frame background to black // m_transport->LCDBoxFrame->setBackgroundColor(Qt::black); // set all the pixmap backgrounds to black to avoid // flickering when we update // m_transport->TenThousandthsPixmap->setBackgroundColor(Qt::black); m_transport->ThousandthsPixmap->setBackgroundColor(Qt::black); m_transport->HundredthsPixmap->setBackgroundColor(Qt::black); m_transport->TenthsPixmap->setBackgroundColor(Qt::black); m_transport->UnitSecondsPixmap->setBackgroundColor(Qt::black); m_transport->TenSecondsPixmap->setBackgroundColor(Qt::black); m_transport->UnitMinutesPixmap->setBackgroundColor(Qt::black); m_transport->TenMinutesPixmap->setBackgroundColor(Qt::black); m_transport->UnitHoursPixmap->setBackgroundColor(Qt::black); m_transport->TenHoursPixmap->setBackgroundColor(Qt::black); m_transport->NegativePixmap->setBackgroundColor(Qt::black); // unset the negative sign to begin with m_transport->NegativePixmap->clear(); // Set our toggle buttons // m_transport->PlayButton->setToggleButton(true); m_transport->RecordButton->setToggleButton(true);// Disable the loop button if JACK transport enabled, because this// causes a nasty race condition, and it just seems our loops are not JACK compatible// #1240039 - DMM// KConfig* config = rgapp->config();// config->setGroup(SequencerOptionsConfigGroup);// if (config->readBoolEntry("jacktransport", false))// {// m_transport->LoopButton->setEnabled(false);// } // fix and hold the size of the dialog // setMinimumSize(m_transport->width(), m_transport->height()); setMaximumSize(m_transport->width(), m_transport->height()); loadPixmaps(); // Create Midi label timers m_midiInTimer = new QTimer(this); m_midiOutTimer = new QTimer(this); m_clearMetronomeTimer = new QTimer(this); connect(m_midiInTimer, SIGNAL(timeout()), SLOT(slotClearMidiInLabel())); connect(m_midiOutTimer, SIGNAL(timeout()), SLOT(slotClearMidiOutLabel())); connect(m_clearMetronomeTimer, SIGNAL(timeout()), SLOT(slotResetBackground())); m_transport->TimeDisplayLabel->hide(); m_transport->ToEndLabel->hide(); connect(m_transport->TimeDisplayButton, SIGNAL(clicked()), SLOT(slotChangeTimeDisplay())); connect(m_transport->ToEndButton, SIGNAL(clicked()), SLOT(slotChangeToEnd())); connect(m_transport->LoopButton, SIGNAL(clicked()), SLOT(slotLoopButtonClicked())); connect(m_transport->PanelOpenButton, SIGNAL(clicked()), SLOT(slotPanelOpenButtonClicked())); connect(m_transport->PanelCloseButton, SIGNAL(clicked()), SLOT(slotPanelCloseButtonClicked())); connect(m_transport->PanicButton, SIGNAL(clicked()), SIGNAL(panic())); m_panelOpen = *m_transport->PanelOpenButton->pixmap(); m_panelClosed = *m_transport->PanelCloseButton->pixmap(); connect(m_transport->SetStartLPButton, SIGNAL(clicked()), SLOT(slotSetStartLoopingPointAtMarkerPos())); connect(m_transport->SetStopLPButton, SIGNAL(clicked()), SLOT(slotSetStopLoopingPointAtMarkerPos())); // clear labels // slotClearMidiInLabel(); slotClearMidiOutLabel(); // and by default we close the lower panel // int rfh = m_transport->RecordingFrame->height(); m_transport->RecordingFrame->hide(); setFixedSize(width(), height() - rfh); m_transport->PanelOpenButton->setPixmap(m_panelClosed); // and since by default we show real time (not SMPTE), by default // we hide the small colon pixmaps // m_transport->SecondColonPixmap->hide(); m_transport->HundredthColonPixmap->hide(); // We have to specify these settings in this class (copied // from rosegardentransport.cpp) as we're using a specialised // widgets for TempoDisplay. Ugly but works - does mean that // if the rest of the Transport ever changes then this code // will have to as well. // QPalette pal; pal.setColor(QColorGroup::Foreground, QColor(192, 216, 255)); m_transport->TempoDisplay->setPalette(pal); m_transport->TempoDisplay->setAlignment(int(QLabel::AlignVCenter | QLabel::AlignRight)); m_transport->TimeSigDisplay->setPalette(pal); m_transport->TimeSigDisplay->setAlignment(int(QLabel::AlignVCenter | QLabel::AlignRight)); QFont localFont(m_transport->OutDisplay->font() ); localFont.setFamily( "lucida" ); localFont.setBold( TRUE ); m_transport->TempoDisplay->setFont( localFont ); m_transport->TimeSigDisplay->setFont( localFont ); connect(m_transport->TempoDisplay, SIGNAL(doubleClicked()), this, SLOT(slotEditTempo())); connect(m_transport->TempoDisplay, SIGNAL(scrollWheel(int)), this, SIGNAL(scrollTempo(int))); connect(m_transport->TimeSigDisplay, SIGNAL(doubleClicked()), this, SLOT(slotEditTimeSignature())); // toil through the individual pixmaps connect(m_transport->NegativePixmap, SIGNAL(doubleClicked()), this, SLOT(slotEditTime())); connect(m_transport->TenHoursPixmap, SIGNAL(doubleClicked()), this, SLOT(slotEditTime())); connect(m_transport->UnitHoursPixmap, SIGNAL(doubleClicked()), this, SLOT(slotEditTime())); connect(m_transport->HourColonPixmap, SIGNAL(doubleClicked()), this, SLOT(slotEditTime())); connect(m_transport->TenMinutesPixmap, SIGNAL(doubleClicked()), this, SLOT(slotEditTime())); connect(m_transport->UnitMinutesPixmap, SIGNAL(doubleClicked()), this, SLOT(slotEditTime())); connect(m_transport->MinuteColonPixmap, SIGNAL(doubleClicked()), this, SLOT(slotEditTime())); connect(m_transport->TenSecondsPixmap, SIGNAL(doubleClicked()), this, SLOT(slotEditTime())); connect(m_transport->UnitSecondsPixmap, SIGNAL(doubleClicked()), this, SLOT(slotEditTime())); connect(m_transport->SecondColonPixmap, SIGNAL(doubleClicked()), this, SLOT(slotEditTime())); connect(m_transport->TenthsPixmap, SIGNAL(doubleClicked()), this, SLOT(slotEditTime())); connect(m_transport->HundredthsPixmap, SIGNAL(doubleClicked()), this, SLOT(slotEditTime())); connect(m_transport->HundredthColonPixmap, SIGNAL(doubleClicked()), this, SLOT(slotEditTime())); connect(m_transport->TenThousandthsPixmap, SIGNAL(doubleClicked()), this, SLOT(slotEditTime())); connect(m_transport->ThousandthsPixmap, SIGNAL(doubleClicked()), this, SLOT(slotEditTime())); // accelerator object // m_accelerators = new QAccel(this);}TransportDialog::~TransportDialog(){ if (isVisible()) { KConfig* config = rgapp->config(); config->setGroup(GeneralOptionsConfigGroup); config->writeEntry("transportx", x()); config->writeEntry("transporty", y()); }}voidTransportDialog::show(){ KConfig* config = rgapp->config(); config->setGroup(GeneralOptionsConfigGroup); int x = config->readNumEntry("transportx", -1); int y = config->readNumEntry("transporty", -1); if (x >= 0 && y >= 0) { int dw = QApplication::desktop()->availableGeometry(QPoint(x, y)).width(); int dh = QApplication::desktop()->availableGeometry(QPoint(x, y)).height(); if (x + m_transport->width() > dw) x = dw - m_transport->width(); if (y + m_transport->height() > dh) y = dh - m_transport->height(); move(x, y);// std::cerr << "TransportDialog::show(): moved to " << x << "," << y << std::endl; QWidget::show();// std::cerr << "TransportDialog::show(): now at " << this->x() << "," << this->y() << std::endl; } else { QWidget::show(); }}voidTransportDialog::hide(){ if (isVisible()) { KConfig* config = rgapp->config(); config->setGroup(GeneralOptionsConfigGroup); config->writeEntry("transportx", x()); config->writeEntry("transporty", y()); } QWidget::hide();}voidTransportDialog::loadPixmaps(){ m_lcdList.clear(); QString fileName; QString pixmapDir = KGlobal::dirs()->findResource("appdata", "pixmaps/"); for (int i = 0; i < 10; i++) { fileName = QString("%1/transport/led-%2.xpm").arg(pixmapDir).arg(i); if (!m_lcdList[i].load(fileName)) { std::cerr << "TransportDialog - failed to load pixmap \"" << fileName << "\"" << std::endl; } } // Load the "negative" sign pixmap // fileName = QString("%1/transport/led--.xpm").arg(pixmapDir); m_lcdNegative.load(fileName);}voidTransportDialog::resetFonts(){ resetFont(m_transport->TimeSigLabel); resetFont(m_transport->TimeSigDisplay); resetFont(m_transport->TempoLabel); resetFont(m_transport->TempoDisplay); resetFont(m_transport->DivisionLabel); resetFont(m_transport->DivisionDisplay); resetFont(m_transport->InLabel); resetFont(m_transport->InDisplay); resetFont(m_transport->OutLabel); resetFont(m_transport->OutDisplay); resetFont(m_transport->ToEndLabel); resetFont(m_transport->TimeDisplayLabel);}voidTransportDialog::resetFont(QWidget *w){ QFont font = w->font(); font.setPixelSize(10); w->setFont(font);}voidTransportDialog::setSMPTEResolution(int framesPerSecond, int bitsPerFrame){ m_framesPerSecond = framesPerSecond; m_bitsPerFrame = bitsPerFrame;}void
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?