r22058 by craig - Some palette clean up

scribus-commit scribus-commit at lists.scribus.net
Fri Jun 9 21:48:22 UTC 2017


Author: craig
Date: Fri Jun  9 21:48:22 2017
New Revision: 22058

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22058
Log:
Some palette clean up

Modified:
    trunk/Scribus/scribus/ui/aligndistribute.cpp
    trunk/Scribus/scribus/undogui.cpp
    trunk/Scribus/scribus/undogui.h

Modified: trunk/Scribus/scribus/ui/aligndistribute.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22058&path=/trunk/Scribus/scribus/ui/aligndistribute.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/aligndistribute.cpp	(original)
+++ trunk/Scribus/scribus/ui/aligndistribute.cpp	Fri Jun  9 21:48:22 2017
@@ -492,7 +492,7 @@
 
 void AlignDistributePalette::enableGuideButtons()
 {
-	QString suffix="";
+	QString suffix;
 	double unitRatio=1.0;
 	int precision=1;
 	if (currDoc!=NULL)

Modified: trunk/Scribus/scribus/undogui.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22058&path=/trunk/Scribus/scribus/undogui.cpp
==============================================================================
--- trunk/Scribus/scribus/undogui.cpp	(original)
+++ trunk/Scribus/scribus/undogui.cpp	Fri Jun  9 21:48:22 2017
@@ -40,49 +40,23 @@
 
 UndoGui::UndoGui(QWidget* parent, const char* name, Qt::WindowFlags f) : ScDockPalette(parent, name, f)
 {
+	languageChange();
+}
+
+void UndoGui::languageChange()
+{
 	setWindowTitle( tr("Action History"));
 }
 
-void UndoGui::languageChange()
-{
-	setWindowTitle( tr("Action History"));
-}
-
 /*** UndoWidget ***************************************************************/
 
 UndoWidget::UndoWidget(QWidget* parent, const char* name) : UndoGui(parent, name)
 {
-	/* BnF standard toolbar buttons
-	QHBoxLayout* layout = new QHBoxLayout(this, 0, 0, "layout");
-
-
-	undoButton = new QToolButton(this, "undoButton");
-	undoButton->setIconSet(loadIcon("u_undo.png"));
-	undoButton->setUsesTextLabel(false);
-	undoButton->setToolTip(tr("Undo"));
-	layout->addWidget(undoButton);
-	undoMenu = new QPopupMenu(undoButton, "undoMenu");
-	undoButton->setPopup(undoMenu);
-	undoButton->setPopupDelay(0);
-	undoButton->setAutoRaise(true);
-
-	redoButton = new QToolButton(this, "redoButton");
-	redoButton->setIconSet(loadIcon("u_redo.png"));
-	redoButton->setUsesTextLabel(false);
-	redoButton->setToolTip(tr("Redo"));
-	layout->addWidget(redoButton);
-	redoMenu = new QPopupMenu(redoButton, "redoMenu");
-	redoButton->setPopup(redoMenu);
-	redoButton->setPopupDelay(0);
-	redoButton->setAutoRaise(true);
-	*/
 	//Scribus action based toolbar button construction
 	parent->addAction(ScCore->primaryMainWindow()->scrActions["editUndoAction"]);
 	parent->addAction(ScCore->primaryMainWindow()->scrActions["editRedoAction"]);
 	ScCore->primaryMainWindow()->scrMenuMgr->createMenu("undoButtonMenu", "undoButtonMenu");
 	ScCore->primaryMainWindow()->scrMenuMgr->createMenu("redoButtonMenu", "redoButtonMenu");
-	//undoMenu=ScCore->primaryMainWindow()->scrMenuMgr->getLocalPopupMenu("undoButtonMenu");
-	//redoMenu=ScCore->primaryMainWindow()->scrMenuMgr->getLocalPopupMenu("redoButtonMenu");
 	undoMenu=ScCore->primaryMainWindow()->scrMenuMgr->undoMenu();
 	redoMenu=ScCore->primaryMainWindow()->scrMenuMgr->redoMenu();
 	ScCore->primaryMainWindow()->scrMenuMgr->addMenuToWidgetOfAction("undoButtonMenu", ScCore->primaryMainWindow()->scrActions["editUndoAction"]);
@@ -92,11 +66,6 @@
 	parent->addAction(ScCore->primaryMainWindow()->scrActions["editCopy"]);
 	parent->addAction(ScCore->primaryMainWindow()->scrActions["editPaste"]);
 	ScCore->primaryMainWindow()->scrMenuMgr->addMenuToWidgetOfAction("EditPasteRecent", ScCore->primaryMainWindow()->scrActions["editPaste"]);
-
-	/* BnF Undo buttons
-	connect(undoButton, SIGNAL(clicked()), this, SLOT(undoClicked()));
-	connect(redoButton, SIGNAL(clicked()), this, SLOT(redoClicked()));
-	*/
 	connect(undoMenu, SIGNAL(triggered(QAction *)), this, SLOT(undoMenuClicked(QAction *)));
 	connect(redoMenu, SIGNAL(triggered(QAction *)), this, SLOT(redoMenuClicked(QAction *)));
 }
@@ -107,14 +76,10 @@
 	undoItems.clear();
 	//Scribus disable
 	ScCore->primaryMainWindow()->scrActions["editUndoAction"]->setEnabled(false);
-	// BnF disable
-	//undoButton->setEnabled(false);
 	redoMenu->clear();
 	redoItems.clear();
 	//Scribus disable;
 	ScCore->primaryMainWindow()->scrActions["editRedoAction"]->setEnabled(false);
-	// BnF disable
-	//redoButton->setEnabled(false);
 }
 
 void UndoWidget::undoClicked()
@@ -167,10 +132,6 @@
 	undoMenu->clear();
 	for (uint i = 0; i < MENU_HEIGHT && i < undoItems.size(); ++i)
 		undoMenu->addAction(undoItems[i]);
-	//BnF
-	//undoButton->setEnabled(undoMenu->count() != 0);
-	//SCribus
-	//ScMW->scrActions["editUndoAction"]->setEnabled(undoMenu->count() != 0);
 	updateUndoActions();
 }
 
@@ -179,10 +140,6 @@
 	redoMenu->clear();
 	for (uint i = 0; i < MENU_HEIGHT && i < redoItems.size(); ++i)
 		redoMenu->addAction(redoItems[i]);
-	//BnF
-	//redoButton->setEnabled(redoMenu->count() != 0);
-	//Scribus
-	//ScMW->scrActions["editRedoAction"]->setEnabled(redoMenu->count() != 0);
 	updateUndoActions();
 }
 
@@ -243,11 +200,8 @@
 	layout->setSpacing(5);
 	objectBox = new QCheckBox(this);
 	layout->addWidget(objectBox);
-// 	objectBox->setEnabled(false);
 
 	undoList = new QListWidget(this);
-// 	undoList->setMultiSelection(false);
-// 	undoList->setSelectionMode(QListWidget::Single);
 	undoList->setSelectionMode(QAbstractItemView::SingleSelection);
 	undoList->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
 	layout->addWidget(undoList);
@@ -270,11 +224,8 @@
 	connect(PrefsManager::instance(), SIGNAL(prefsChanged()), this, SLOT(updateFromPrefs()));
 	connect(undoButton, SIGNAL(clicked()), this, SLOT(undoClicked()));
 	connect(redoButton, SIGNAL(clicked()), this, SLOT(redoClicked()));
-// 	connect(undoList, SIGNAL(highlighted(int)), this, SLOT(undoListClicked(int)));
 	connect(undoList, SIGNAL(currentRowChanged(int)), this, SLOT(undoListClicked(int)));
-// 	connect(undoList, SIGNAL(onItem(Q3ListBoxItem*)), this, SLOT(showToolTip(Q3ListBoxItem*)));
 	connect(undoList, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(showToolTip(QListWidgetItem*)));
-// 	connect(undoList, SIGNAL(onViewport()), this, SLOT(removeToolTip()));
 	connect(undoList, SIGNAL(viewportEntered()), this, SLOT(removeToolTip()));
 	connect(objectBox, SIGNAL(toggled(bool)), this, SLOT(objectCheckBoxClicked(bool)));
 	connect(ScCore->primaryMainWindow()->scrActions["editActionMode"], SIGNAL(toggled(bool)),
@@ -285,30 +236,24 @@
 
 void UndoPalette::clear()
 {
-// 	qDebug() << "UndoPalette::clear start";
 	disconnect(undoList, SIGNAL(currentRowChanged(int)), this, SLOT(undoListClicked(int)));
 	undoList->clear();
 	undoList->addItem( tr("Initial State"));
 	undoButton->setEnabled(false);
 	redoButton->setEnabled(false);
 	connect(undoList, SIGNAL(currentRowChanged(int)), this, SLOT(undoListClicked(int)));
-// 	qDebug() << "UndoPalette::clear end";
 }
 
 void UndoPalette::updateFromPrefs()
 {
-// 	qDebug() << "UndoPalette::updateFromPrefs start";
 	undoButton->setShortcut(ScCore->primaryMainWindow()->scrActions["editUndoAction"]->shortcut());
 	redoButton->setShortcut(ScCore->primaryMainWindow()->scrActions["editRedoAction"]->shortcut());
-// 	qDebug() << "UndoPalette::updateFromPrefs end";
 }
 
 void UndoPalette::changeEvent(QEvent *e)
 {
 	if (e->type() == QEvent::LanguageChange)
-	{
 		languageChange();
-	}
 	else
 		UndoGui::changeEvent(e);
 }
@@ -328,23 +273,18 @@
 
 void UndoPalette::insertUndoItem(UndoObject* target, UndoState* state)
 {
-// 	qDebug() << "UndoPalette::insertUndoItem start";
 	clearRedo();
 	undoList->addItem(new UndoItem(target->getUName(), state->getName(),
                          state->getDescription(), target->getUPixmap(),
                          state->getPixmap(), true));
 	currentSelection = undoList->count() - 1;
 	updateList();
-// 	qDebug() << "UndoPalette::insertUndoItem end";
 }
 
 void UndoPalette::insertRedoItem(UndoObject* target, UndoState* state)
 {
-// 	qDebug() << "UndoPalette::insertRedoItem start";
 	if (undoList->count() == 1)
 	{
-// 		qDebug() << "UndoPalette::insertRedoItem undoList->count == 1";
-// 		undoList->setSelected(0, true);
 		undoList->setCurrentItem(undoList->item(0));
 		currentSelection = 0;
 	}
@@ -352,53 +292,40 @@
                          state->getDescription(), target->getUPixmap(),
                          state->getPixmap(), false));
 	updateList();
-// 	qDebug() << "UndoPalette::insertRedoItem end";
 }
 
 void UndoPalette::updateUndo(int steps)
 {
-// 	qDebug() << "UndoPalette::updateUndo start";
 	if (undoList->row(undoList->currentItem()) == currentSelection)
 	{
 		currentSelection -= steps;
 		updateList();
 	}
-// 	qDebug() << "UndoPalette::updateUndo end";
 }
 
 void UndoPalette::updateRedo(int steps)
 {
-// 	qDebug() << "UndoPalette::updateRedo start";
 	if (undoList->row(undoList->currentItem()) == currentSelection)
 	{
 		currentSelection += steps;
 		updateList();
 	}
-// 	qDebug() << "UndoPalette::updateRedo end";
 }
 
 void UndoPalette::popBack()
 {
-// 	qDebug() << "UndoPalette::popBack start";
 	if (undoList->count() > 1)
 	{
-// 		undoList->removeItem(0);
 		delete undoList->takeItem(0);
 		currentSelection = undoList->count() - 1;
 	}
-// 	qDebug() << "UndoPalette::popBack end";
 }
 
 void UndoPalette::updateList()
 {
-// 	qDebug() << "UndoPalette::updateList start";
-// 	undoList->setCurrentItem(currentSelection);
 	undoList->setCurrentRow(currentSelection);
-// 	undoList->setSelected(currentSelection, true);
 	redoButton->setEnabled(currentSelection < undoList->count() - 1);
 	undoButton->setEnabled(currentSelection > 0);
-// 	if (!undoList->item(currentSelection)->isVisible()) //itemVisible(currentSelection))
-// 		undoList->setBottomItem(currentSelection);
 	undoList->scrollToItem(undoList->item(currentSelection));
 	for (int i = 0; i < undoList->count(); ++i)
 	{
@@ -408,7 +335,6 @@
 
 		item->setUndoAction(currentSelection >= i);
 	}
-// 	qDebug() << "UndoPalette::updateList end";
 }
 
 void UndoPalette::updateUndoActions()
@@ -419,28 +345,22 @@
 
 void UndoPalette::clearRedo()
 {
-// 	qDebug() << "UndoPalette::clearRedo start";
 	for (int i = (undoList->count() - 1); i > currentSelection; --i)
-// 		undoList->removeItem(i);
 		delete undoList->takeItem(i);
-// 	qDebug() << "UndoPalette::clearRedo end";
 }
 
 void UndoPalette::undoClicked()
 {
-// 	qDebug() << "UndoPalette::undoClicked emitted";
 	emit undo(1);
 }
 
 void UndoPalette::redoClicked()
 {
-// 	qDebug() << "UndoPalette::redoClicked emitted";
 	emit redo(1);
 }
 
 void UndoPalette::undoListClicked(int i)
 {
-// 	qDebug() << "UndoPalette::undoListClicked start";
 	if (i == currentSelection || (i == 0 && undoList->count() == 1))
 		return;
 	if (i > currentSelection)
@@ -449,19 +369,15 @@
 		emit undo(currentSelection - i);
 	currentSelection = i;
 	updateList();
-// 	qDebug() << "UndoPalette::undoListClicked end";
 }
 
 void UndoPalette::objectCheckBoxClicked(bool on)
 {
-// 	qDebug() << "UndoPalette::objectCheckBoxClicked start";
 	emit objectMode(on);
-// 	qDebug() << "UndoPalette::objectCheckBoxClicked end";
 }
 
 void UndoPalette::showToolTip(QListWidgetItem *i)
 {
-// 	qDebug() << "UndoPalette::showToolTip start";
 	UndoItem *item = dynamic_cast<UndoItem*>(i);
 	if (item)
 	{
@@ -471,14 +387,11 @@
 	}
 	else
 		removeToolTip();
-// 	qDebug() << "UndoPalette::showToolTip end";
 }
 
 void UndoPalette::removeToolTip()
 {
-// 	qDebug() << "UndoPalette::removeToolTip start";
 	undoList->setToolTip("");
-// 	qDebug() << "UndoPalette::removeToolTip end";
 }
 
 UndoPalette::~UndoPalette()
@@ -490,9 +403,6 @@
 
 UndoPalette::UndoItem::UndoItem() : QListWidgetItem()
 {
-	target = "";
-	action = "";
-	description = "";
 	targetpixmap = NULL;
 	actionpixmap = NULL;
 	isUndoAction_ = true;
@@ -526,13 +436,16 @@
 {
 	/*TODO: 16x16 is hardcoded, because images automatically scaled by QIcon are no longer recognizable 
 	would be better to have the icons designed for 16x16*/
-	if (!targetPixmap) {
-		if (actionPixmap) {
+	if (!targetPixmap)
+	{
+		if (actionPixmap)
 			setIcon(actionPixmap->scaled(16,16));
-		}
-	} else {
-		QPixmap pixmap = targetPixmap->scaled(16,16);
-		if (actionPixmap) {
+	}
+	else
+	{
+		QPixmap pixmap(targetPixmap->scaled(16,16));
+		if (actionPixmap)
+		{
 			QPainter p;
 			p.begin(&pixmap);
 			p.drawPixmap(0,0, actionPixmap->scaled(16,16));
@@ -543,61 +456,6 @@
 	setText(tr("%1 - %2\n%3").arg(targetName, actionName, actionDescription));
 }
 
-//void UndoPalette::UndoItem::paint(QPainter *painter)
-//{
-// 	if (targetpixmap)
-// 		painter->drawPixmap(5, 5, *targetpixmap);
-// 	if (actionpixmap)
-// 		painter->drawPixmap(5, 5, *actionpixmap);
-// 	QPen  p = QPen(painter->pen());
-// 	QFont f = QFont(painter->font());
-// 	painter->setFont(f);
-// 	if (isUndoAction_)
-// 	{
-// 		p.setColor(QColor("black"));
-// 		f.setItalic(false);
-// 	}
-// 	else
-// 	{
-// 		p.setColor(QColor("darkGray"));
-// 		f.setItalic(true);
-// 	}
-// 	painter->setPen(p);
-// 	painter->setFont(f);
-// 	painter->drawText(32, QFontMetrics(f).height(), target);
-// 	painter->drawText(32, (2 * QFontMetrics(painter->font()).height()), action);
-//}
-
-/*
-int UndoPalette::UndoItem::height(const QListWidget *lb) const
-{
-	if (lb)
-	{
-		int fontHeight = 2 * QFontMetrics(lb->font()).lineSpacing() + 2;
-		if (actionpixmap)
-			return fontHeight > (10 + actionpixmap->height()) ?
-                   fontHeight : (10 + actionpixmap->height());
-		else if (targetpixmap)
-			return fontHeight > (10 + targetpixmap->height()) ?
-                   fontHeight : (10 + targetpixmap->height());
-		else
-			return fontHeight;
-	}
-	else
-		return 0;
-}
-
-int UndoPalette::UndoItem::width(const QListWidget *lb) const
-{
-	if (lb)
-		return target.length() > action.length() ?
-               39 + QFontMetrics(lb->font()).width(target) :
-               39 + QFontMetrics(lb->font()).width(action);
-	else
-		return 0;
-}
-*/
-
 QString UndoPalette::UndoItem::getDescription()
 {
   return description;

Modified: trunk/Scribus/scribus/undogui.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22058&path=/trunk/Scribus/scribus/undogui.h
==============================================================================
--- trunk/Scribus/scribus/undogui.h	(original)
+++ trunk/Scribus/scribus/undogui.h	Fri Jun  9 21:48:22 2017
@@ -70,7 +70,7 @@
 	UndoGui(QWidget* parent = 0, const char* name = "UndoGui", Qt::WindowFlags f = 0);
 
 	/** @brief Destroys the widget */
-	virtual ~UndoGui() {};
+	virtual ~UndoGui() {}
 
 	/** @brief Empties the undo stack representation. */
 	virtual void clear() = 0;




More information about the scribus-commit mailing list