⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 editviewbase.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* -*- 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 "EditViewBase.h"#include <qlayout.h>#include <kapplication.h>#include <klocale.h>#include <kstddirs.h>#include "misc/Debug.h"#include "base/Clipboard.h"#include "base/Event.h"#include "base/NotationTypes.h"#include "base/Segment.h"#include "commands/segment/SegmentReconfigureCommand.h"#include "document/MultiViewCommandHistory.h"#include "document/RosegardenGUIDoc.h"#include "EditToolBox.h"#include "EditTool.h"#include "EditView.h"#include "gui/dialogs/ConfigureDialog.h"#include "gui/dialogs/TimeDialog.h"#include "gui/general/EditViewTimeSigNotifier.h"#include "gui/kdeext/KTmpStatusMsg.h"#include <kaction.h>#include <kcommand.h>#include <kconfig.h>#include <kdockwidget.h>#include <kedittoolbar.h>#include <kglobal.h>#include <kkeydialog.h>#include <kmainwindow.h>#include <kstatusbar.h>#include <kstdaccel.h>#include <kstdaction.h>#include <kxmlguiclient.h>#include <qaccel.h>#include <qcanvas.h>#include <qdialog.h>#include <qframe.h>#include <qiconset.h>#include <qobject.h>#include <qpixmap.h>#include <qstring.h>#include <qwidget.h>namespace Rosegarden{bool EditViewBase::m_inPaintEvent = false;const unsigned int EditViewBase::ID_STATUS_MSG = 1;const unsigned int EditViewBase::NbLayoutRows = 6;EditViewBase::EditViewBase(RosegardenGUIDoc *doc,                           std::vector<Segment *> segments,                           unsigned int cols,                           QWidget *parent, const char *name) :        KDockMainWindow(parent, name),        m_viewNumber( -1),        m_viewLocalPropertyPrefix(makeViewLocalPropertyPrefix()),        m_config(kapp->config()),        m_doc(doc),        m_segments(segments),        m_tool(0),        m_toolBox(0),        m_mainDockWidget(0),        m_centralFrame(0),        m_grid(0),        m_mainCol(cols - 1),        m_compositionRefreshStatusId(doc->getComposition().getNewRefreshStatusId()),        m_needUpdate(false),        m_pendingPaintEvent(0),        m_havePendingPaintEvent(false),        m_accelerators(0),        m_configDialogPageIndex(0),        m_inCtor(true),        m_timeSigNotifier(new EditViewTimeSigNotifier(doc)){    QPixmap dummyPixmap; // any icon will do    m_mainDockWidget = createDockWidget("Rosegarden EditView DockWidget", dummyPixmap,                                        0L, "editview_dock_widget");    // allow others to dock to the left and right sides only    m_mainDockWidget->setDockSite(KDockWidget::DockLeft | KDockWidget::DockRight);    // forbit docking abilities of m_mainDockWidget itself    m_mainDockWidget->setEnableDocking(KDockWidget::DockNone);    setView(m_mainDockWidget); // central widget in a KDE mainwindow    setMainDockWidget(m_mainDockWidget); // master dockwidget    m_centralFrame = new QFrame(m_mainDockWidget, "centralframe");    m_grid = new QGridLayout(m_centralFrame, NbLayoutRows, cols);    m_mainDockWidget->setWidget(m_centralFrame);    initSegmentRefreshStatusIds();    m_doc->attachEditView(this);    QObject::connect    (getCommandHistory(), SIGNAL(commandExecuted()),     this, SLOT(update()));    QObject::connect    (getCommandHistory(), SIGNAL(commandExecuted()),     this, SLOT(slotTestClipboard()));    // create accelerators    //    m_accelerators = new QAccel(this);}EditViewBase::~EditViewBase(){    delete m_timeSigNotifier;    m_doc->detachEditView(this);    getCommandHistory()->detachView(actionCollection());    m_viewNumberPool.erase(m_viewNumber);    slotSaveOptions();}void EditViewBase::slotSaveOptions(){}void EditViewBase::readOptions(){    getToggleAction("options_show_statusbar")->setChecked(!statusBar()->isHidden());    getToggleAction("options_show_toolbar")->setChecked(!toolBar()->isHidden());}void EditViewBase::setupActions(QString rcFileName, bool haveClipboard){    setRCFileName(rcFileName);    // Actions all edit views will have    KStdAction::showToolbar(this, SLOT(slotToggleToolBar()),                            actionCollection(), "options_show_toolbar");    KStdAction::showStatusbar(this, SLOT(slotToggleStatusBar()),                              actionCollection(), "options_show_statusbar");    KStdAction::preferences(this,                            SLOT(slotConfigure()),                            actionCollection());    KStdAction::keyBindings(this,                            SLOT(slotEditKeys()),                            actionCollection());    KStdAction::configureToolbars(this,                                  SLOT(slotEditToolbars()),                                  actionCollection());    // File menu    KStdAction::save (this, SIGNAL(saveFile()), actionCollection());    KStdAction::close(this, SLOT(slotCloseWindow()), actionCollection());    if (haveClipboard) {        KStdAction::cut (this, SLOT(slotEditCut()), actionCollection());        KStdAction::copy (this, SLOT(slotEditCopy()), actionCollection());        KStdAction::paste (this, SLOT(slotEditPaste()), actionCollection());    }    new KToolBarPopupAction(i18n("Und&o"),                            "undo",                            KStdAccel::key(KStdAccel::Undo),                            actionCollection(),                            KStdAction::stdName(KStdAction::Undo));    new KToolBarPopupAction(i18n("Re&do"),                            "redo",                            KStdAccel::key(KStdAccel::Redo),                            actionCollection(),                            KStdAction::stdName(KStdAction::Redo));    QString pixmapDir = KGlobal::dirs()->findResource("appdata", "pixmaps/");    QCanvasPixmap pixmap(pixmapDir + "/toolbar/matrix.png");    QIconSet icon = QIconSet(pixmap);    new KAction(i18n("Open in Matri&x Editor"), icon, 0, this,                SLOT(slotOpenInMatrix()), actionCollection(),                "open_in_matrix");    pixmap.load(pixmapDir + "/toolbar/matrix-percussion.png");    icon = QIconSet(pixmap);    new KAction(i18n("Open in &Percussion Matrix Editor"), icon, 0, this,                SLOT(slotOpenInPercussionMatrix()), actionCollection(),                "open_in_percussion_matrix");    pixmap.load(pixmapDir + "/toolbar/notation.png");    icon = QIconSet(pixmap);    new KAction(i18n("Open in &Notation Editor"), icon, 0, this,                SLOT(slotOpenInNotation()), actionCollection(),                "open_in_notation");    pixmap.load(pixmapDir + "/toolbar/eventlist.png");    icon = QIconSet(pixmap);    new KAction(i18n("Open in &Event List Editor"), icon, 0, this,                SLOT(slotOpenInEventList()), actionCollection(),                "open_in_event_list");    new KAction(i18n("Set Segment Start Time..."), 0, this,                SLOT(slotSetSegmentStartTime()), actionCollection(),                "set_segment_start");    new KAction(i18n("Set Segment Duration..."), 0, this,                SLOT(slotSetSegmentDuration()), actionCollection(),                "set_segment_duration");    // add undo and redo to edit menu and toolbar    getCommandHistory()->attachView(actionCollection());}void EditViewBase::slotConfigure(){    ConfigureDialog *configDlg =        new ConfigureDialog(getDocument(), m_config, this);    configDlg->showPage(getConfigDialogPageIndex());    configDlg->show();}void EditViewBase::slotEditKeys(){    KKeyDialog::configure(actionCollection());}void EditViewBase::slotEditToolbars(){    KEditToolbar dlg(actionCollection(), getRCFileName());    connect(&dlg, SIGNAL(newToolbarConfig()),            SLOT(slotUpdateToolbars()));    dlg.exec();}void EditViewBase::slotUpdateToolbars(){    createGUI(getRCFileName());    //m_viewToolBar->setChecked(!toolBar()->isHidden());}voidEditViewBase::slotOpenInNotation(){    emit openInNotation(m_segments);}voidEditViewBase::slotOpenInMatrix(){    emit openInMatrix(m_segments);}voidEditViewBase::slotOpenInPercussionMatrix(){    emit openInPercussionMatrix(m_segments);}voidEditViewBase::slotOpenInEventList(){    emit openInEventList(m_segments);}std::set<int> EditViewBase::m_viewNumberPool;std::stringEditViewBase::makeViewLocalPropertyPrefix(){    static char buffer[100];    int i = 0;    while (m_viewNumberPool.find(i) != m_viewNumberPool.end())        ++i;    m_viewNumber = i;    m_viewNumberPool.insert(i);    sprintf(buffer, "View%d::", i);    return buffer;}void EditViewBase::paintEvent(QPaintEvent* e){    // It is possible for this function to be called re-entrantly,    // because a re-layout procedure may deliberately ask the event    // loop to process some more events so as to keep the GUI looking    // responsive.  If that happens, we remember the events that came    // in in the middle of one paintEvent call and process their union    // again at the end of the call.    /*        if (m_inPaintEvent) {    	NOTATION_DEBUG << "EditViewBase::paintEvent: in paint event already" << endl;    	if (e) {    	    if (m_havePendingPaintEvent) {    		if (m_pendingPaintEvent) {    		    QRect r = m_pendingPaintEvent->rect().unite(e->rect());    		    *m_pendingPaintEvent = QPaintEvent(r);    		} else {    		    m_pendingPaintEvent = new QPaintEvent(*e);    		}    	    } else {    		m_pendingPaintEvent = new QPaintEvent(*e);    	    }    	}    	m_havePendingPaintEvent = true;    	return;        }    */     //!!!    m_inPaintEvent = true;    if (isCompositionModified()) {        // Check if one of the segments we display has been removed        // from the composition.        //        // For the moment we'll have to close the view if any of the        // segments we handle has been deleted.        for (unsigned int i = 0; i < m_segments.size(); ++i) {            if (!m_segments[i]->getComposition()) {                // oops, I think we've been deleted                close();                return ;            }        }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -