r20326 by fschmid - WIP to fix Bug #12297 Color Code Master Pages like in Layers dialog
scribus-commit
scribus-commit at lists.scribus.net
Sun Aug 16 07:46:21 UTC 2015
Author: fschmid
Date: Sun Aug 16 07:46:21 2015
New Revision: 20326
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20326
Log:
WIP to fix Bug #12297 Color Code Master Pages like in Layers dialog
Modified:
trunk/Scribus/scribus/canvas.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
trunk/Scribus/scribus/scpage.cpp
trunk/Scribus/scribus/scpage.h
trunk/Scribus/scribus/scribus.cpp
trunk/Scribus/scribus/ui/margindialog.cpp
trunk/Scribus/scribus/ui/margindialog.h
trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp
trunk/Scribus/scribus/ui/pagepalette_pages.cpp
trunk/Scribus/scribus/ui/pagepalette_pages.h
Modified: trunk/Scribus/scribus/canvas.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20326&path=/trunk/Scribus/scribus/canvas.cpp
==============================================================================
--- trunk/Scribus/scribus/canvas.cpp (original)
+++ trunk/Scribus/scribus/canvas.cpp Sun Aug 16 07:46:21 2015
@@ -990,7 +990,10 @@
ScPainter *painter=0;
QImage img = QImage(clipw, cliph, QImage::Format_ARGB32_Premultiplied);
painter = new ScPainter(&img, img.width(), img.height(), 1.0, 0);
- painter->clear(palette().color(QPalette::Window));
+ if (m_doc->masterPageMode())
+ painter->clear(m_doc->currentPage()->getMarkColor());
+ else
+ painter->clear(palette().color(QPalette::Window));
painter->newPath();
painter->moveTo(0, 0);
painter->lineTo(clipw, 0);
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20326&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp Sun Aug 16 07:46:21 2015
@@ -3585,6 +3585,8 @@
ef.M = attrs.valueAsInt("M", 0);
ef.Di = attrs.valueAsInt("Di", 0);
newPage->PresentVals = ef;
+ if (attrs.hasAttribute("markC"))
+ newPage->setMarkColor(QColor(attrs.valueAsString("markC")));
return true;
}
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20326&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp Sun Aug 16 07:46:21 2015
@@ -1519,6 +1519,7 @@
docu.writeAttribute("Dm", page->PresentVals.Dm);
docu.writeAttribute("M", page->PresentVals.M);
docu.writeAttribute("Di", page->PresentVals.Di);
+ docu.writeAttribute("markC", page->getMarkColor().name());
docu.writeEndElement();
}
}
Modified: trunk/Scribus/scribus/scpage.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20326&path=/trunk/Scribus/scribus/scpage.cpp
==============================================================================
--- trunk/Scribus/scribus/scpage.cpp (original)
+++ trunk/Scribus/scribus/scpage.cpp Sun Aug 16 07:46:21 2015
@@ -62,6 +62,7 @@
PresentVals.Dm = 0;
PresentVals.M = 0;
PresentVals.Di = 0;
+ m_markColor = Qt::blue;
}
ScPage::~ScPage()
@@ -98,6 +99,11 @@
m_PageName = newName;
if (!newName.isEmpty())
setUName(QObject::tr("Master Page ") + newName);
+}
+
+void ScPage::setMarkColor(QColor color)
+{
+ m_markColor = color;
}
void ScPage::restore(UndoState* state, bool isUndo)
Modified: trunk/Scribus/scribus/scpage.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20326&path=/trunk/Scribus/scribus/scpage.h
==============================================================================
--- trunk/Scribus/scribus/scpage.h (original)
+++ trunk/Scribus/scribus/scpage.h Sun Aug 16 07:46:21 2015
@@ -68,6 +68,8 @@
double topMargin() const { return Margins.top(); }
double bottomMargin() const { return Margins.bottom(); }
double rightMargin() const { return Margins.right(); }
+ void setMarkColor(QColor color);
+ QColor getMarkColor() const { return m_markColor; }
MarginStruct Margins;
MarginStruct initialMargins;
@@ -119,6 +121,7 @@
QString m_PageName;
ScribusDoc* m_Doc;
QString m_pageSectionNumber;
+ QColor m_markColor;
};
Q_DECLARE_METATYPE(ScPage*);
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20326&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Sun Aug 16 07:46:21 2015
@@ -6214,6 +6214,8 @@
double pageHeight = dia->getPageHeight();
double pageWidth = dia->getPageWidth();
QString pageSizeName = dia->getpPrefsPageSizeName();
+ if (doc->masterPageMode())
+ doc->currentPage()->setMarkColor(dia->markerColor());
int lp=0;
if (doc->masterPageMode() && doc->pagePositioning() != singlePage)
lp = dia->pageOrder();
Modified: trunk/Scribus/scribus/ui/margindialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20326&path=/trunk/Scribus/scribus/ui/margindialog.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/margindialog.cpp (original)
+++ trunk/Scribus/scribus/ui/margindialog.cpp Sun Aug 16 07:46:21 2015
@@ -13,6 +13,7 @@
#include <QGroupBox>
#include <QComboBox>
#include <QCheckBox>
+#include <QColorDialog>
#include "commonstrings.h"
#include "iconmanager.h"
@@ -123,24 +124,39 @@
masterLayout->setSpacing( 5 );
masterLayout->setMargin( 10 );
masterPageLabel = new QLabel( groupMaster );
- masterPageLabel->setText( tr( "Master Page:" ) );
masterLayout->addWidget( masterPageLabel );
- masterPageComboBox = new QComboBox( groupMaster );
- QString Nam = doc->currentPage()->MPageNam;
- QString na = Nam == CommonStrings::masterPageNormal ? CommonStrings::trMasterPageNormal : Nam, in;
- int cc = 0;
- for (QMap<QString,int>::Iterator it = doc->MasterNames.begin(); it != doc->MasterNames.end(); ++it)
- {
- in = it.key() == CommonStrings::masterPageNormal ? CommonStrings::trMasterPageNormal : it.key();
- masterPageComboBox->addItem(in);
- if (in == na)
- masterPageComboBox->setCurrentIndex(cc);
- ++cc;
- }
- masterLayout->addWidget( masterPageComboBox );
+ if (!doc->masterPageMode())
+ {
+ masterPageLabel->setText( tr( "Master Page:" ) );
+ masterPageComboBox = new QComboBox( groupMaster );
+ QString Nam = doc->currentPage()->MPageNam;
+ QString na = Nam == CommonStrings::masterPageNormal ? CommonStrings::trMasterPageNormal : Nam, in;
+ int cc = 0;
+ for (QMap<QString,int>::Iterator it = doc->MasterNames.begin(); it != doc->MasterNames.end(); ++it)
+ {
+ in = it.key() == CommonStrings::masterPageNormal ? CommonStrings::trMasterPageNormal : it.key();
+ masterPageComboBox->addItem(in);
+ if (in == na)
+ masterPageComboBox->setCurrentIndex(cc);
+ ++cc;
+ }
+ masterLayout->addWidget( masterPageComboBox );
+ pageFillColor = QColor();
+ }
+ else
+ {
+ masterPageComboBox = NULL;
+ masterPageLabel->setText( tr( "Page Marker Color:" ) );
+ QPixmap pm(100, 30);
+ pm.fill(doc->currentPage()->getMarkColor());
+ pageFillColor = doc->currentPage()->getMarkColor();
+ pageFillColorButton = new QPushButton(this);
+ pageFillColorButton->setText( QString::null );
+ pageFillColorButton->setIcon(pm);
+ masterLayout->addWidget( pageFillColorButton );
+ connect(pageFillColorButton, SIGNAL(clicked()), this, SLOT(changeMarkerColor()));
+ }
dialogLayout->addWidget( groupMaster );
- if (doc->masterPageMode())
- groupMaster->hide();
okCancelLayout = new QHBoxLayout;
okCancelLayout->setSpacing( 5 );
@@ -282,6 +298,18 @@
connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageHeight(double)));
}
+void MarginDialog::changeMarkerColor()
+{
+ QColor newColor(QColorDialog::getColor(pageFillColor, this));
+ if (newColor.isValid())
+ {
+ QPixmap pm(100, 30);
+ pm.fill(newColor);
+ pageFillColor = newColor;
+ pageFillColorButton->setIcon(pm);
+ }
+}
+
int MarginDialog::pageOrder()
{
int lp=0;
@@ -343,7 +371,14 @@
QString MarginDialog::masterPage()
{
- return masterPageComboBox->currentText();
+ if (masterPageComboBox != NULL)
+ return masterPageComboBox->currentText();
+ return "";
+}
+
+QColor MarginDialog::markerColor()
+{
+ return pageFillColor;
}
int MarginDialog::getMarginPreset()
Modified: trunk/Scribus/scribus/ui/margindialog.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20326&path=/trunk/Scribus/scribus/ui/margindialog.h
==============================================================================
--- trunk/Scribus/scribus/ui/margindialog.h (original)
+++ trunk/Scribus/scribus/ui/margindialog.h Sun Aug 16 07:46:21 2015
@@ -69,6 +69,7 @@
/*! \brief Master Page
\retval QString Master Page Name */
QString masterPage();
+ QColor markerColor();
int getMarginPreset();
public slots:
@@ -88,6 +89,7 @@
It's called from width spinbox.
\param v new height */
virtual void setPageHeight(double v);
+ void changeMarkerColor();
private:
MarginWidget* GroupRand;
@@ -106,6 +108,7 @@
QComboBox* Links;
QLabel* TextLabel3;
QCheckBox* moveObjects;
+ QPushButton* pageFillColorButton;
QPushButton* cancelButton;
QPushButton* okButton;
double unitRatio;
@@ -118,6 +121,7 @@
QVBoxLayout* dialogLayout;
QHBoxLayout* okCancelLayout;
QHBoxLayout* masterLayout;
+ QColor pageFillColor;
};
Modified: trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20326&path=/trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp (original)
+++ trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp Sun Aug 16 07:46:21 2015
@@ -499,6 +499,7 @@
mpItem->setFlags(mpItem->flags() &= ~Qt::ItemIsEditable);
}
mpItem->setData(Qt::UserRole, it.key());
+ mpItem->setForeground(m_doc->MasterPages.at(it.value())->getMarkColor());
masterPageListBox->addItem(mpItem);
}
deleteButton->setEnabled(m_doc->MasterNames.count() == 1 ? false : true);
Modified: trunk/Scribus/scribus/ui/pagepalette_pages.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20326&path=/trunk/Scribus/scribus/ui/pagepalette_pages.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/pagepalette_pages.cpp (original)
+++ trunk/Scribus/scribus/ui/pagepalette_pages.cpp Sun Aug 16 07:46:21 2015
@@ -130,7 +130,7 @@
currView->DrawNew();
SeItem* pageItem = pageView->GetPageItem(pageIndex);
if (pageItem)
- pageItem->setIcon(createIcon(pageIndex, masterpageName, pix));
+ pageItem->setIcon(createIcon(pageIndex, masterpageName, pix, currView->Doc->MasterPages.at(currView->Doc->MasterNames[masterpageName])->getMarkColor()));
}
void PagePalette_Pages::pageView_movePage(int r, int c)
@@ -205,6 +205,7 @@
else
item = new QListWidgetItem(pageLabel, masterPageList);
item->setData(Qt::UserRole, pageName);
+ item->setForeground(currView->Doc->MasterPages.at(it.value())->getMarkColor());
}
}
@@ -272,7 +273,7 @@
for (int a = 0; a < currView->Doc->DocPages.count(); ++a)
{
str = currView->Doc->DocPages.at(a)->MPageNam;
- SeItem *it = new SeItem(str, a, createIcon(a, str, pix));
+ SeItem *it = new SeItem(str, a, createIcon(a, str, pix, currView->Doc->MasterPages.at(currView->Doc->MasterNames[str])->getMarkColor()));
pageList.append(it);
pageView->setItem(rowcounter*rowmult+rowadd, counter*colmult+coladd, (QTableWidgetItem *)it);
pageView->setColumnWidth(counter*colmult+coladd, pix.width());
@@ -352,7 +353,7 @@
}
}
-QPixmap PagePalette_Pages::createIcon(int nr, QString masterPage, QPixmap pixin)
+QPixmap PagePalette_Pages::createIcon(int nr, QString masterPage, QPixmap pixin, QColor color)
{
QPainter p;
// Necessary on windows to ensure the pixmap is drawable
@@ -375,6 +376,7 @@
if (Exp.indexIn(masterPage) != -1)
masterPage = Exp.cap(1);
QRect d = QRect(0, 0, ret.width(), ret.height());
+ p.fillRect(d.adjusted(-1, -1, -1, -1), color);
p.setFont(QFont("Helvetica", 7, QFont::Normal));
p.drawText(d, Qt::AlignCenter, tmp+"\n"+masterPage);
p.end();
Modified: trunk/Scribus/scribus/ui/pagepalette_pages.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20326&path=/trunk/Scribus/scribus/ui/pagepalette_pages.h
==============================================================================
--- trunk/Scribus/scribus/ui/pagepalette_pages.h (original)
+++ trunk/Scribus/scribus/ui/pagepalette_pages.h Sun Aug 16 07:46:21 2015
@@ -67,7 +67,7 @@
QList<SeItem*> pageList;
QPixmap pix;
- QPixmap createIcon(int nr, QString mp, QPixmap pixin);
+ QPixmap createIcon(int nr, QString mp, QPixmap pixin, QColor color);
};
#endif // SEITENPAL_H
More information about the scribus-commit
mailing list