r18303 by jghali - some cleanup of "new from template" code

scribus-commit scribus-commit at lists.scribus.net
Sat Jun 8 23:31:19 UTC 2013


Author: jghali
Date: Sat Jun  8 23:31:18 2013
New Revision: 18303

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18303
Log:
some cleanup of "new from template" code

Modified:
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/ui/nftdialog.cpp
    trunk/Scribus/scribus/ui/nftdialog.h
    trunk/Scribus/scribus/ui/nftwidget.cpp
    trunk/Scribus/scribus/ui/nftwidget.h

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18303&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Sat Jun  8 23:31:18 2013
@@ -2136,22 +2136,20 @@
 void ScribusMainWindow::newFileFromTemplate()
 {
 	nftdialog* nftdia = new nftdialog(this, ScCore->getGuiLanguage());
-	if (nftdia->exec())
-	{
-		if (nftdia->nftGui->currentDocumentTemplate)
-		{
-			qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
-			if (loadDoc(QDir::cleanPath(nftdia->nftGui->currentDocumentTemplate->file)))
-			{
-				doc->hasName = false;
-				UndoManager::instance()->renameStack(nftdia->nftGui->currentDocumentTemplate->name);
-				doc->DocName = nftdia->nftGui->currentDocumentTemplate->name;
-				updateActiveWindowCaption(QObject::tr("Document Template: ") + nftdia->nftGui->currentDocumentTemplate->name);
-				QDir::setCurrent(PrefsManager::instance()->documentDir());
-				removeRecent(QDir::cleanPath(nftdia->nftGui->currentDocumentTemplate->file));
-			}
-			qApp->restoreOverrideCursor();
-		}
+	if (nftdia->exec() && nftdia->isTemplateSelected())
+	{
+		qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
+		nfttemplate* currentTemplate = nftdia->currentTemplate();
+		if (loadDoc(QDir::cleanPath(currentTemplate->file)))
+		{
+			doc->hasName = false;
+			UndoManager::instance()->renameStack(currentTemplate->name);
+			doc->DocName = currentTemplate->name;
+			updateActiveWindowCaption(QObject::tr("Document Template: ") + currentTemplate->name);
+			QDir::setCurrent(PrefsManager::instance()->documentDir());
+			removeRecent(QDir::cleanPath(currentTemplate->file));
+		}
+		qApp->restoreOverrideCursor();
 	}
 	delete nftdia;
 }

Modified: trunk/Scribus/scribus/ui/nftdialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18303&path=/trunk/Scribus/scribus/ui/nftdialog.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/nftdialog.cpp (original)
+++ trunk/Scribus/scribus/ui/nftdialog.cpp Sat Jun  8 23:31:18 2013
@@ -25,6 +25,18 @@
 	connect(nftGui, SIGNAL(ButtonBoxEnable(bool)), this, SLOT(enableButtonBox(bool)));
 }
 
+bool nftdialog::isTemplateSelected()
+{
+	if (nftGui->currentDocumentTemplate)
+		return true;
+	return false;
+}
+
+nfttemplate* nftdialog::currentTemplate()
+{
+	return (nftGui->currentDocumentTemplate);
+}
+
 void nftdialog::enableButtonBox(bool setter)
 {
 	buttonBox->button(QDialogButtonBox::Ok)->setEnabled(setter);

Modified: trunk/Scribus/scribus/ui/nftdialog.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18303&path=/trunk/Scribus/scribus/ui/nftdialog.h
==============================================================================
--- trunk/Scribus/scribus/ui/nftdialog.h (original)
+++ trunk/Scribus/scribus/ui/nftdialog.h Sat Jun  8 23:31:18 2013
@@ -17,12 +17,16 @@
 #include "ui_nftdialog.h"
 #include "nftsettings.h"
 
-class nftdialog: public QDialog, public Ui::nftdialog
+class nftdialog: public QDialog, Ui::nftdialog
 {
 	Q_OBJECT
 public:
 	nftdialog(QWidget* parent, QString lang);
 	~nftdialog() {};
+
+	bool isTemplateSelected();
+	nfttemplate* currentTemplate();
+
 public slots:
 	void enableButtonBox(bool);
 };

Modified: trunk/Scribus/scribus/ui/nftwidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18303&path=/trunk/Scribus/scribus/ui/nftwidget.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/nftwidget.cpp (original)
+++ trunk/Scribus/scribus/ui/nftwidget.cpp Sat Jun  8 23:31:18 2013
@@ -37,11 +37,11 @@
 	toolBox->setItemIcon(2, loadIcon("16/help-browser.png"));
 	tnailGrid->setIconSize(QSize(60, 60));
 	// Signals and Slots Connections
-	connect(categoryList, SIGNAL(itemSelectionChanged()), this, SLOT(setTNails()));
+	connect(categoryList, SIGNAL(itemSelectionChanged()), this, SLOT(setThumbnails()));
+	connect(tnailGrid, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SIGNAL(leaveOK()));
 	connect(tnailGrid, SIGNAL(itemSelectionChanged()), this, SLOT(setInfo()));
 	connect(removeAction, SIGNAL(triggered()), this, SLOT(removeTemplate()));
 	connect(openAction, SIGNAL(triggered()), this, SIGNAL(leaveOK()));
-	connect(tnailGrid, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SIGNAL(leaveOK()));
 	setupListItems();
 	setupCategories();
 }
@@ -77,7 +77,7 @@
 	}
 }
 
-void nftwidget::setTNails()
+void nftwidget::setThumbnails()
 {
 	if (categoryList->currentRow() == 0)
 	{
@@ -206,7 +206,7 @@
 	emit ButtonBoxEnable(false);
 	setupListItems();
 	setupCategories();
-	setTNails();
+	setThumbnails();
 }
 
 void nftwidget::getCurrentDocumentTemplate(QListWidgetItem* item)

Modified: trunk/Scribus/scribus/ui/nftwidget.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18303&path=/trunk/Scribus/scribus/ui/nftwidget.h
==============================================================================
--- trunk/Scribus/scribus/ui/nftwidget.h (original)
+++ trunk/Scribus/scribus/ui/nftwidget.h Sat Jun  8 23:31:18 2013
@@ -41,8 +41,8 @@
 	void setupSettings(QString lang);
 	~nftwidget();
 private slots: 
-	void setTNails();
 	void setInfo();
+	void setThumbnails();
 	void getCurrentDocumentTemplate(QListWidgetItem* item);
 	void removeTemplate();
 signals:




More information about the scribus-commit mailing list