Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #21205: don't show page number on first page #756

Merged
merged 3 commits into from
Mar 12, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions libmscore/page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,13 +602,16 @@ void Page::doRebuildBspTree()

//---------------------------------------------------------
// replaceTextMacros
// $p - page number
// $$ - $
// $p - page number, except on first page
// $P - page number, on all pages
// $n - number of pages
// $f - file name
// $F - file path+name
// $d - current date
// $D - creation date
// $C - copyright, on first page only
// $c - copyright, on all pages
// $$ - the $ sign itself
// $:tag: - meta data tag
// already defined tags:
// movementNumber
Expand All @@ -621,19 +624,19 @@ void Page::doRebuildBspTree()

QString Page::replaceTextMacros(const QString& s) const
{
int pageno = no() + 1 + _score->pageNumberOffset();
QString d;
int n = s.size();
for (int i = 0; i < n; ++i) {
for (int i = 0, n = s.size(); i < n; ++i) {
QChar c = s[i];
if (c == '$' && (i < (n-1))) {
QChar c = s[i+1];
switch(c.toLatin1()) {
case 'p':
d += QString("%1").arg(pageno);
case 'p': // not on first page 1
if (_no) // FALLTHROUGH
case 'P': // on all pages
d += QString("%1").arg(_no + 1 + _score->pageNumberOffset());
break;
case 'n':
d += QString("%1").arg(_score->pages().size() + _score->pageNumberOffset());
d += QString("%1").arg(_score->npages() + _score->pageNumberOffset());
break;
case 'f':
d += _score->name();
Expand All @@ -646,12 +649,16 @@ QString Page::replaceTextMacros(const QString& s) const
break;
case 'D':
{
QString creationDate = score()->metaTag("creationDate");
if(!creationDate.isNull()) {
QString creationDate = _score->metaTag("creationDate");
if (!creationDate.isNull())
d += QDate::fromString(creationDate, Qt::ISODate).toString(Qt::DefaultLocaleShortDate);
}
}
break;
case 'C': // only on first page
if (!_no) // FALLTHROUGH
case 'c':
d += _score->metaTag("copyright");
break;
case '$':
d += '$';
break;
Expand All @@ -665,7 +672,7 @@ QString Page::replaceTextMacros(const QString& s) const
tag += s[k];
}
if (k != n) { // found ':' ?
d += score()->metaTag(tag);
d += _score->metaTag(tag);
i = k-1;
}
}
Expand All @@ -689,7 +696,7 @@ QString Page::replaceTextMacros(const QString& s) const

bool Page::isOdd() const
{
return (_no + 1 + score()->pageNumberOffset()) & 1;
return (_no + 1 + _score->pageNumberOffset()) & 1;
}

//---------------------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion libmscore/read114.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,10 +639,14 @@ Score::FileError Score::read114(XmlReader& e)
style()->set(ST_lyricsDistance, 2.0f);
if (style(ST_voltaY) == MScore::baseStyle()->value(ST_voltaY))
style()->set(ST_voltaY, -2.0f);
if (style(ST_hideEmptyStaves).toBool() == true) // http://musescore.org/en/node/16228
if (style(ST_hideEmptyStaves).toBool()) // http://musescore.org/en/node/16228
style()->set(ST_dontHideStavesInFirstSystem, false);
if (style(ST_useGermanNoteNames).toBool())
style()->set(ST_useStandardNoteNames, false);
if (style(ST_showPageNumberOne).toBool()) { // http://musescore.org/en/node/21207
style()->set(ST_evenFooterL, QString("$P"));
style()->set(ST_oddFooterR, QString("$P"));
}

_showOmr = false;

Expand Down
39 changes: 39 additions & 0 deletions mscore/editstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,43 @@

namespace Ms {

// keep in sync with implementation in Page::replaceTextMacros (page.cpp)
// jumping thru hoops here to make the job of translators easier, yet have a nice display
static QString toolTipHeaderFooter
= QString("<html><head></head><body><p><b>")
+ QT_TRANSLATE_NOOP("toolTipHeaderFooter", "Special symbols in header/footer")
+ QString("</b></p>")
+ QString("<table><tr><td>$p</td><td>-</td><td><i>")
+ QT_TRANSLATE_NOOP("toolTipHeaderFooter", "page number, except on first page")
+ QString("</i></td></tr><tr><td>$P</td><td>-</td><td><i>")
+ QT_TRANSLATE_NOOP("toolTipHeaderFooter", "page number, on all pages")
+ QString("</i></td></tr><tr><td>$n</td><td>-</td><td><i>")
+ QT_TRANSLATE_NOOP("toolTipHeaderFooter", "number of pages")
+ QString("</i></td></tr><tr><td>$f</td><td>-</td><td><i>")
+ QT_TRANSLATE_NOOP("toolTipHeaderFooter", "file name")
+ QString("</i></td></tr><tr><td>$F</td><td>-</td><td><i>")
+ QT_TRANSLATE_NOOP("toolTipHeaderFooter", "file path+name")
+ QString("</i></td></tr><tr><td>$d</td><td>-</td><td><i>")
+ QT_TRANSLATE_NOOP("toolTipHeaderFooter", "current date")
+ QString("</i></td></tr><tr><td>$D</td><td>-</td><td><i>")
+ QT_TRANSLATE_NOOP("toolTipHeaderFooter", "creation date")
+ QString("</i></td></tr><tr><td>$C</td><td>-</td><td><i>")
+ QT_TRANSLATE_NOOP("toolTipHeaderFooter", "copyright, on first page only")
+ QString("</i></td></tr><tr><td>$c</td><td>-</td><td><i>")
+ QT_TRANSLATE_NOOP("toolTipHeaderFooter", "copyright, on all pages")
+ QString("</i></td></tr><tr><td>$$</td><td>-</td><td><i>")
+ QT_TRANSLATE_NOOP("toolTipHeaderFooter", "the $ sign itself")
+ QString("</i></td></tr><tr><td>$:tag:</td><td>-</td><td><i>")
+ QT_TRANSLATE_NOOP("toolTipHeaderFooter", "meta data tag")
+ QString("</i></td></tr></table><p>")
+ QT_TRANSLATE_NOOP("toolTipHeaderFooter", "already defined tags:")
+ QString("</p><table><tr><td>movementNumber</td></tr>")
+ QString("<tr><td>movementTitle</td></tr>")
+ QString("<tr><td>workNumber</td></tr>")
+ QString("<tr><td>workTitle</td></tr>")
+ QString("<tr><td>source</td></tr>")
+ QString("<tr><td>copyright</td></tr></table></body></html>");

//---------------------------------------------------------
// EditStyle
//---------------------------------------------------------
Expand Down Expand Up @@ -111,6 +148,8 @@ EditStyle::EditStyle(Score* s, QWidget* parent)
connect(comboFBFont, SIGNAL(currentIndexChanged(int)), SLOT(on_comboFBFont_currentIndexChanged(int)));

setValues();
showHeader->setToolTip(toolTipHeaderFooter);
showFooter->setToolTip(toolTipHeaderFooter);
connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), SLOT(buttonClicked(QAbstractButton*)));
connect(chordDescriptionFileButton, SIGNAL(clicked()), SLOT(selectChordDescriptionFile()));
connect(chordsStandard, SIGNAL(toggled(bool)), SLOT(setChordStyle(bool)));
Expand Down
30 changes: 0 additions & 30 deletions mscore/editstyle.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1205,9 +1205,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string/>
</property>
<property name="title">
<string>Footer text</string>
</property>
Expand Down Expand Up @@ -1446,33 +1443,6 @@
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_68">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:8pt; font-weight:600;&quot;&gt;Special symbols in header/footer:&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:8pt;&quot;&gt;$p &lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:8pt; font-style:italic;&quot;&gt;- page number &lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:8pt;&quot;&gt;$n&lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:8pt; font-style:italic;&quot;&gt; - number of last page &lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:8pt;&quot;&gt;$$&lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:8pt; font-style:italic;&quot;&gt; - the character $&lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:8pt;&quot;&gt; $f - &lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:8pt; font-style:italic;&quot;&gt;score name&lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:8pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:8pt; font-style:italic;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:8pt;&quot;&gt;$F - &lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:8pt; font-style:italic;&quot;&gt;file path&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:8pt;&quot;&gt;$d - &lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:8pt; font-style:italic;&quot;&gt;current date &lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:8pt;&quot;&gt;$D - &lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:8pt; font-style:italic;&quot;&gt;creation date&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:8pt;&quot;&gt;$:tag: - &lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:8pt; font-style:italic;&quot;&gt;meta tag (copyright etc.)&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down