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

📄 notationview.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                    done = true;                } else {                    if (aimFor == -1)                        aimFor = rowsPerPage + 1;                    // we can perhaps accommodate another row, with care                    if (legerLines > 5)                        --legerLines;                    else if (rowGapPercent > 20)                        rowGapPercent -= 10;                    else if (legerLines > 3)                        --legerLines;                    else if (rowGapPercent > 0)                        rowGapPercent -= 10;                    else { // no, we can't                        rowGapPercent = 0;                        legerLines = 8;                        done = true;                    }                }            }        }    }    m_hlayout->setPageWidth(pageWidth - leftMargin * 2);    int topGutter = 0;    if (m_pageMode == LinedStaff::MultiPageMode) {        topGutter = 20;    } else if (m_pageMode == LinedStaff::ContinuousPageMode) {        // fewer leger lines above staff than in linear mode --        // compensate for this on the top staff        topGutter = m_notePixmapFactory->getLineSpacing() * 2;    }    for (unsigned int i = 0; i < m_staffs.size(); ++i) {        TrackId trackId = m_staffs[i]->getSegment().getTrack();        Track *track =            m_staffs[i]->getSegment().getComposition()->            getTrackById(trackId);        if (!track)            continue; // Once Again, My Friend, You Should Never See Me Here        int trackPosition = track->getPosition();        m_staffs[i]->setTitleHeight(titleHeight);        m_staffs[i]->setRowSpacing(accumulatedHeight);        if (trackPosition < maxTrack) {            m_staffs[i]->setConnectingLineLength(trackHeights[trackPosition]);        }        if (trackPosition == minTrack &&                m_pageMode != LinedStaff::LinearMode) {            m_staffs[i]->setBarNumbersEvery(5);        } else {            m_staffs[i]->setBarNumbersEvery(0);        }        m_staffs[i]->setX(m_leftGutter);        m_staffs[i]->setY(topGutter + trackCoords[trackPosition] + topMargin);        m_staffs[i]->setPageWidth(pageWidth - leftMargin * 2);        m_staffs[i]->setRowsPerPage(rowsPerPage);        m_staffs[i]->setPageMode(m_pageMode);        m_staffs[i]->setMargin(leftMargin);        NOTATION_DEBUG << "NotationView::positionStaffs: set staff's page width to "        << (pageWidth - leftMargin * 2) << endl;    }}void NotationView::positionPages(){    if (m_printMode)        return ;    QPixmap background;    QPixmap deskBackground;    bool haveBackground = false;    m_config->setGroup(NotationViewConfigGroup);    if (m_config->readBoolEntry("backgroundtextures", true)) {        QString pixmapDir =            KGlobal::dirs()->findResource("appdata", "pixmaps/");        if (background.load(QString("%1/misc/bg-paper-cream.xpm").                            arg(pixmapDir))) {            haveBackground = true;        }        // we're happy to ignore errors from this one:        deskBackground.load(QString("%1/misc/bg-desktop.xpm").arg(pixmapDir));    }    int pageWidth = getPageWidth();    int pageHeight = getPageHeight();    int leftMargin = 0, topMargin = 0;    getPageMargins(leftMargin, topMargin);    int maxPageCount = 1;    for (unsigned int i = 0; i < m_staffs.size(); ++i) {        int pageCount = m_staffs[i]->getPageCount();        if (pageCount > maxPageCount)            maxPageCount = pageCount;    }    for (unsigned int i = 0; i < m_pages.size(); ++i) {        delete m_pages[i];        delete m_pageNumbers[i];    }    m_pages.clear();    m_pageNumbers.clear();    if (m_pageMode != LinedStaff::MultiPageMode) {        if (haveBackground) {            canvas()->setBackgroundPixmap(background);            getCanvasView()->setBackgroundMode(Qt::FixedPixmap);            getCanvasView()->setPaletteBackgroundPixmap(background);            getCanvasView()->setErasePixmap(background);        }    } else {        if (haveBackground) {            canvas()->setBackgroundPixmap(deskBackground);            getCanvasView()->setBackgroundMode(Qt::FixedPixmap);            getCanvasView()->setPaletteBackgroundPixmap(background);            getCanvasView()->setErasePixmap(background);        }        QFont pageNumberFont;        pageNumberFont.setPixelSize(m_fontSize * 2);        QFontMetrics pageNumberMetrics(pageNumberFont);        for (int page = 0; page < maxPageCount; ++page) {            int x = m_leftGutter + pageWidth * page + leftMargin / 4;            int y = 20;            int w = pageWidth - leftMargin / 2;            int h = pageHeight;            QString str = QString("%1").arg(page + 1);            QCanvasText *text = new QCanvasText(str, pageNumberFont, canvas());            text->setX(m_leftGutter + pageWidth * page + pageWidth - pageNumberMetrics.width(str) - leftMargin);            text->setY(y + h - pageNumberMetrics.descent() - topMargin);            text->setZ( -999);            text->show();            m_pageNumbers.push_back(text);            QCanvasRectangle *rect = new QCanvasRectangle(x, y, w, h, canvas());            if (haveBackground)                rect->setBrush(QBrush(Qt::white, background));            rect->setPen(Qt::black);            rect->setZ( -1000);            rect->show();            m_pages.push_back(rect);        }        updateThumbnails(false);    }    m_config->setGroup(NotationViewConfigGroup);}void NotationView::slotUpdateStaffName(){    LinedStaff *staff = getLinedStaff(m_currentStaff);    staff->drawStaffName();}void NotationView::slotSaveOptions(){    m_config->setGroup(NotationViewConfigGroup);    m_config->writeEntry("Show Chord Name Ruler", getToggleAction("show_chords_ruler")->isChecked());    m_config->writeEntry("Show Raw Note Ruler", getToggleAction("show_raw_note_ruler")->isChecked());    m_config->writeEntry("Show Tempo Ruler", getToggleAction("show_tempo_ruler")->isChecked());    m_config->writeEntry("Show Annotations", m_annotationsVisible);    m_config->writeEntry("Show LilyPond Directives", m_lilypondDirectivesVisible);    m_config->sync();}void NotationView::setOneToolbar(const char *actionName,                                 const char *toolbarName){    KToggleAction *action = getToggleAction(actionName);    if (!action) {        std::cerr << "WARNING: No such action as " << actionName << std::endl;        return ;    }    QWidget *toolbar = toolBar(toolbarName);    if (!toolbar) {        std::cerr << "WARNING: No such toolbar as " << toolbarName << std::endl;        return ;    }    action->setChecked(!toolbar->isHidden());}void NotationView::readOptions(){    EditView::readOptions();    setOneToolbar("show_tools_toolbar", "Tools Toolbar");    setOneToolbar("show_notes_toolbar", "Notes Toolbar");    setOneToolbar("show_rests_toolbar", "Rests Toolbar");    setOneToolbar("show_clefs_toolbar", "Clefs Toolbar");    setOneToolbar("show_group_toolbar", "Group Toolbar");    setOneToolbar("show_marks_toolbar", "Marks Toolbar");    setOneToolbar("show_layout_toolbar", "Layout Toolbar");    setOneToolbar("show_transport_toolbar", "Transport Toolbar");    setOneToolbar("show_accidentals_toolbar", "Accidentals Toolbar");    setOneToolbar("show_meta_toolbar", "Meta Toolbar");    m_config->setGroup(NotationViewConfigGroup);    bool opt;    opt = m_config->readBoolEntry("Show Chord Name Ruler", false);    getToggleAction("show_chords_ruler")->setChecked(opt);    slotToggleChordsRuler();    opt = m_config->readBoolEntry("Show Raw Note Ruler", true);    getToggleAction("show_raw_note_ruler")->setChecked(opt);    slotToggleRawNoteRuler();    opt = m_config->readBoolEntry("Show Tempo Ruler", true);    getToggleAction("show_tempo_ruler")->setChecked(opt);    slotToggleTempoRuler();    opt = m_config->readBoolEntry("Show Annotations", true);    m_annotationsVisible = opt;    getToggleAction("show_annotations")->setChecked(opt);    slotUpdateAnnotationsStatus();    //    slotToggleAnnotations();    opt = m_config->readBoolEntry("Show LilyPond Directives", true);    m_lilypondDirectivesVisible = opt;    getToggleAction("show_lilypond_directives")->setChecked(opt);    slotUpdateLilyPondDirectivesStatus();}void NotationView::setupActions(){    KStdAction::print(this, SLOT(slotFilePrint()), actionCollection());    KStdAction::printPreview(this, SLOT(slotFilePrintPreview()),                             actionCollection());    new KAction(i18n("Print &with LilyPond..."), 0, 0, this,                SLOT(slotPrintLilypond()), actionCollection(),                "file_print_lilypond");    new KAction(i18n("Preview with Lil&yPond..."), 0, 0, this,                SLOT(slotPreviewLilypond()), actionCollection(),                "file_preview_lilypond");    EditViewBase::setupActions("notation.rc");    EditView::setupActions();    KRadioAction* noteAction = 0;    // View menu stuff    KActionMenu *fontActionMenu =        new KActionMenu(i18n("Note &Font"), this, "note_font_actionmenu");    std::set        <std::string> fs(NoteFontFactory::getFontNames());    std::vector<std::string> f(fs.begin(), fs.end());    std::sort(f.begin(), f.end());    for (std::vector<std::string>::iterator i = f.begin(); i != f.end(); ++i) {        QString fontQName(strtoqstr(*i));        KToggleAction *fontAction =            new KToggleAction            (fontQName, 0, this, SLOT(slotChangeFontFromAction()),             actionCollection(), "note_font_" + fontQName);        fontAction->setChecked(*i == m_fontName);        fontActionMenu->insert(fontAction);    }    actionCollection()->insert(fontActionMenu);    m_fontSizeActionMenu =        new KActionMenu(i18n("Si&ze"), this, "note_font_size_actionmenu");    setupFontSizeMenu();    actionCollection()->insert(m_fontSizeActionMenu);    KActionMenu *spacingActionMenu =        new KActionMenu(i18n("S&pacing"), this, "stretch_actionmenu");    int defaultSpacing = m_hlayout->getSpacing();    std::vector<int> spacings = NotationHLayout::getAvailableSpacings();    for (std::vector<int>::iterator i = spacings.begin();            i != spacings.end(); ++i) {        KToggleAction *spacingAction =            new KToggleAction            (QString("%1%").arg(*i), 0, this,             SLOT(slotChangeSpacingFromAction()),             actionCollection(), QString("spacing_%1").arg(*i));        spacingAction->setExclusiveGroup("spacing");        spacingAction->setChecked(*i == defaultSpacing);        spacingActionMenu->insert(spacingAction);    }    actionCollection()->insert(spacingActionMenu);    KActionMenu *proportionActionMenu =        new KActionMenu(i18n("Du&ration Factor"), this, "proportion_actionmenu");    int defaultProportion = m_hlayout->getProportion();    std::vector<int> proportions = NotationHLayout::getAvailableProportions();    for (std::vector<int>::iterator i = proportions.begin();            i != proportions.end(); ++i) {        QString name = QString("%1%").arg(*i);        if (*i == 0)            name = i18n("None");        KToggleAction *proportionAction =            new KToggleAction            (name, 0, this,             SLOT(slotChangeProportionFromAction()),             actionCollection(), QString("proportion_%1").arg(*i));        proportionAction->setExclusiveGroup("proportion");        proportionAction->setChecked(*i == defaultProportion);        proportionActionMenu->insert(proportionAction);    }    actionCollection()->insert(proportionActionMenu);    KActionMenu *styleActionMenu =        new KActionMenu(i18n("Note &Style"), this, "note_style_actionmenu");    std::vector<NoteStyleName> styles    (NoteStyleFactory::getAvailableStyleNames());    for (std::vector<NoteStyleName>::iterator i = styles.begin();            i != styles.end(); ++i) {        QString styleQName(strtoqstr(*i));        KAction *styleAction =            new KAction            (styleQName, 0, this, SLOT(slotSetStyleFromAction()),             actionCollection(), "style_" + styleQName);        styleActionMenu->insert(styleAction);    }    actionCollection()->insert(styleActionMenu);    KActionMenu *ornamentActionMenu =        new KActionMenu(i18n("Use Ornament"), this, "ornament_actionmenu");

⌨️ 快捷键说明

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