r22881 by jghali - #15564: Wrong color of guides inserted from guide manager colum/row tab

scribus-commit scribus-commit at lists.scribus.net
Sun Mar 10 23:18:29 UTC 2019


Author: jghali
Date: Sun Mar 10 23:18:29 2019
New Revision: 22881

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22881
Log:
#15564: Wrong color of guides inserted from guide manager colum/row tab

Modified:
    trunk/Scribus/scribus/guidemanagercore.cpp
    trunk/Scribus/scribus/ui/guidemanager.cpp
    trunk/Scribus/scribus/ui/guidemanager.h

Modified: trunk/Scribus/scribus/guidemanagercore.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22881&path=/trunk/Scribus/scribus/guidemanagercore.cpp
==============================================================================
--- trunk/Scribus/scribus/guidemanagercore.cpp	(original)
+++ trunk/Scribus/scribus/guidemanagercore.cpp	Sun Mar 10 23:18:29 2019
@@ -473,9 +473,10 @@
 void GuideManagerCore::drawPage(ScPainter *p, ScribusDoc *doc, double lineWidth)
 {
 	Guides::iterator it;
+	const GuideManager* guideManager = ScCore->primaryMainWindow()->guidePalette;
 	QColor color(doc->guidesPrefs().guideColor);
 
-	if (!m_page || ScCore->primaryMainWindow()->guidePalette->pageNr() < 0)
+	if (!m_page || guideManager->pageNr() < 0)
 		return;
 
 	// real painting margins including bleeds
@@ -494,24 +495,26 @@
 // 		if ((*it) >= 0 && (*it) <= m_page->height())
 // 			p->drawLine(FPoint(0, (*it)), FPoint(m_page->width(), (*it)));
 		p->drawLine(FPoint(horizontalFrom, (*it)), FPoint(horizontalTo, (*it)));
+
 	// highlight selected standards
-	if (ScCore->primaryMainWindow()->guidePalette->currentIndex() == 0
-		   && m_page->pageNr() == ScCore->primaryMainWindow()->guidePalette->pageNr())
+	if (guideManager->currentIndex() == 0
+		   && m_page->pageNr() == guideManager->pageNr())
 	{
 		p->setPen(Qt::red, lineWidth, Qt::DashDotLine, Qt::FlatCap, Qt::MiterJoin);
-		Guides highlight = ScCore->primaryMainWindow()->guidePalette->selectedVerticals();
+		Guides highlight = guideManager->selectedVerticals();
 		for (it = highlight.begin(); it != highlight.end(); ++it)
 // 			if ((*it) >= 0 && (*it) <= m_page->width())
 // 				p->drawLine(FPoint((*it), 0), FPoint((*it), m_page->height()));
 			p->drawLine(FPoint((*it), verticalFrom), FPoint((*it), verticalTo));
-		highlight = ScCore->primaryMainWindow()->guidePalette->selectedHorizontals();
+		highlight = guideManager->selectedHorizontals();
 		for (it = highlight.begin(); it != highlight.end(); ++it)
 // 			if ((*it) >= 0 && (*it) <= m_page->height())
 // 				p->drawLine(FPoint(0, (*it)), FPoint(m_page->width(), (*it)));
 			p->drawLine(FPoint(horizontalFrom, (*it)), FPoint(horizontalTo, (*it)));
 	}
+
 	// all auto
-	if (ScCore->primaryMainWindow()->guidePalette->currentIndex() == 1)
+	if (guideManager->currentIndex() == 1 && guideManager->isVisible())
 		color = Qt::red;
 	else
 		color = doc->guidesPrefs().guideColor;

Modified: trunk/Scribus/scribus/ui/guidemanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22881&path=/trunk/Scribus/scribus/ui/guidemanager.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/guidemanager.cpp	(original)
+++ trunk/Scribus/scribus/ui/guidemanager.cpp	Sun Mar 10 23:18:29 2019
@@ -103,6 +103,8 @@
 
 	connect(horizontalModel, SIGNAL(valueChanged()), this, SLOT(horizontalModel_valueChanged()));
 	connect(verticalModel, SIGNAL(valueChanged()), this, SLOT(verticalModel_valueChanged()));
+
+	connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabWidget_currentChanged(int)));
 }
 
 GuideManager::~GuideManager()
@@ -133,6 +135,12 @@
 	if (!m_Doc)
 		currentPage = nullptr;
 	tabWidget->setEnabled(doc != nullptr);
+}
+
+void GuideManager::setVisible(bool visible)
+{
+	ScrPaletteBase::setVisible(visible);
+	drawGuides();
 }
 
 void GuideManager::setupPage(bool storeValues)
@@ -426,7 +434,7 @@
 	m_Doc->changed();
 }
 
-void GuideManager::tabWidget_currentChanged(QWidget *)
+void GuideManager::tabWidget_currentChanged(int)
 {
 	drawGuides();
 	if (tabWidget->currentIndex() == 1)
@@ -436,7 +444,7 @@
 	}
 }
 
-Guides GuideManager::selectedHorizontals()
+Guides GuideManager::selectedHorizontals() const
 {
 	const QModelIndexList selectedIndexes = horizontalView->selectionModel()->selectedIndexes();
 	Guides ret;
@@ -448,7 +456,7 @@
 	return ret;
 }
 
-Guides GuideManager::selectedVerticals()
+Guides GuideManager::selectedVerticals() const
 {
 	const QModelIndexList selectedIndexes = verticalView->selectionModel()->selectedIndexes();
 	Guides ret;

Modified: trunk/Scribus/scribus/ui/guidemanager.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22881&path=/trunk/Scribus/scribus/ui/guidemanager.h
==============================================================================
--- trunk/Scribus/scribus/ui/guidemanager.h	(original)
+++ trunk/Scribus/scribus/ui/guidemanager.h	Sun Mar 10 23:18:29 2019
@@ -40,6 +40,9 @@
 	/*! \brief Set the doc fo the guidemanager to work on. */
 	void setDoc(ScribusDoc* doc);
 
+	/*! \brief Reimplement ScrPaletteBase::setVisible() */
+	virtual void setVisible(bool visible);
+
 	/*! \brief Set the widgets on the page change.
 	It has to be called on every page to page transition */
 	void setupPage(bool storeValues = true);
@@ -53,18 +56,18 @@
 	/*! \brief Get selected standard guides from GUI list.
 	Used in highlight painting.
 	\retval Guides a list with double values */
-	Guides selectedHorizontals();
+	Guides selectedHorizontals() const;
 	/*! \brief Get selected standard guides from GUI list.
 	Used in highlight painting.
 	\retval Guides a list with double values */
-	Guides selectedVerticals();
+	Guides selectedVerticals() const;
 
 	/*! \brief check the current page number to prevent drawing
 	marks on the others pages. See GuideManagerCore::drawPage.
 	\retval int page no */
 	int pageNr() const { return ((currentPage) ? currentPage->pageNr() : -1); }
 
-	int currentIndex() { return tabWidget->currentIndex(); }
+	int currentIndex() const { return tabWidget->currentIndex(); }
 
 	void setGuideLock(bool guidesLocked);
 	
@@ -155,7 +158,7 @@
 	void verticalPageAutoButton_toggled(bool);
 	void verticalMarginsAutoButton_toggled(bool);
 	void verticalSelectionAutoButton_toggled(bool);
-	void tabWidget_currentChanged( QWidget * );
+	void tabWidget_currentChanged(int);
 	void deletePageButton_clicked();
 	void deleteAllGuides_clicked();
 };




More information about the scribus-commit mailing list