r23520 by craig - #15951: Preselect first item in master page import dialog

scribus-commit scribus-commit at lists.scribus.net
Fri Mar 20 23:50:06 UTC 2020


Author: craig
Date: Fri Mar 20 23:50:06 2020
New Revision: 23520

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23520
Log:
#15951: Preselect first item in master page import dialog

Modified:
    trunk/Scribus/scribus/ui/mergedoc.cpp
    trunk/Scribus/scribus/ui/mergedoc.h

Modified: trunk/Scribus/scribus/ui/mergedoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23520&path=/trunk/Scribus/scribus/ui/mergedoc.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/mergedoc.cpp	(original)
+++ trunk/Scribus/scribus/ui/mergedoc.cpp	Fri Mar 20 23:50:06 2020
@@ -39,7 +39,6 @@
 	setWindowTitle((masterPages) ? tr("Import Master Page") : tr( "Import Page(s)" ));
 	setWindowIcon(IconManager::instance().loadIcon("AppIcon.png"));
 
-	count = 0;
 	dialogLayout = new QVBoxLayout(this);
 	dialogLayout->setMargin(10);
 	dialogLayout->setSpacing(5);
@@ -47,7 +46,7 @@
 	fromInfoLayout->setMargin(0);
 	fromInfoLayout->setSpacing(5);
 	fromDocData = new QLineEdit( this );
-	fromDocData->setMinimumWidth(QWidget::fontMetrics().width('a')*50);
+	fromDocData->setMinimumWidth(QWidget::fontMetrics().horizontalAdvance('a') * 50);
 	fromDocLabel = new QLabel( tr( "&From Document:"), this );
 	fromDocLabel->setBuddy( fromDocData );
 	fromInfoLayout->addWidget( fromDocLabel, 0, 0 );
@@ -58,11 +57,6 @@
 	importPageLabel = new QLabel( tr( "&Import Page(s):" ), this );
 	fromInfoLayout->addWidget( importPageLabel, 1, 0 );
 
-	fromLabel = nullptr;
-	pageNumberData = nullptr;
-	createPageData = nullptr;
-	importWhereData = nullptr;
-	importWherePageData = nullptr;
 	if (masterPages)
 	{
 		importPageLabel->setText( tr("&Import Master Page:") );
@@ -137,8 +131,6 @@
 
 void MergeDoc::changeFile()
 {
-	QString fn;
-	int dummy;
 	count = 0;
 	PrefsContext* dirs = PrefsManager::instance().prefsFile->getContext("dirs");
 	QString wdir = dirs->get("merge", ".");
@@ -147,7 +139,7 @@
 		dia->setSelection(fromDocData->text());
 	if (dia->exec() == QDialog::Accepted)
 	{
-		fn = dia->selectedFile();
+		QString fn(dia->selectedFile());
 		if (!fn.isEmpty())
 		{
 			dirs->set("merge", fn.left(fn.lastIndexOf("/")));
@@ -158,12 +150,13 @@
 				return;
 			QStringList masterPageNames;
 			bool ret = false;
+			int dummy;
 			if (masterPages)
 				ret = fl.readPageCount(&dummy, &count, masterPageNames);
 			else
 				ret = fl.readPageCount(&count, &dummy, masterPageNames);
 			qApp->restoreOverrideCursor();
-			if ((ret) && (count != 0))
+			if (ret && count > 0)
 			{
 				fromDocData->setText( QDir::toNativeSeparators(fn) );
 				importButton->setEnabled(true);
@@ -172,6 +165,7 @@
 					masterPageNameData->clear();
 					masterPageNameData->setEnabled(true);
 					masterPageNameData->addItems(masterPageNames);
+					masterPageNameData->setCurrentRow(0);
 				}
 				else
 				{

Modified: trunk/Scribus/scribus/ui/mergedoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23520&path=/trunk/Scribus/scribus/ui/mergedoc.h
==============================================================================
--- trunk/Scribus/scribus/ui/mergedoc.h	(original)
+++ trunk/Scribus/scribus/ui/mergedoc.h	Fri Mar 20 23:50:06 2020
@@ -44,23 +44,23 @@
 	const int getPageCounter();
 
 private:
-	QLabel* fromDocLabel;
-	QLabel* importPageLabel;
-	QLabel* fromLabel;
-	QLineEdit* pageNumberData;
-	QLineEdit* fromDocData;
-	QPushButton* importButton;
-	QPushButton* cancelButton;
-	QPushButton* changeButton;
-	QCheckBox* createPageData;
-	QListWidget* masterPageNameData;
-	QComboBox* importWhereData;
-	QSpinBox* importWherePageData;
-	QVBoxLayout* dialogLayout;
-	QGridLayout* fromInfoLayout;
-	QHBoxLayout* importCancelLayout;
-	int count;
-	bool masterPages;
+	QLabel* fromDocLabel {nullptr};
+	QLabel* importPageLabel {nullptr};
+	QLabel* fromLabel {nullptr};
+	QLineEdit* pageNumberData {nullptr};
+	QLineEdit* fromDocData {nullptr};
+	QPushButton* importButton {nullptr};
+	QPushButton* cancelButton {nullptr};
+	QPushButton* changeButton {nullptr};
+	QCheckBox* createPageData {nullptr};
+	QListWidget* masterPageNameData {nullptr};
+	QComboBox* importWhereData {nullptr};
+	QSpinBox* importWherePageData {nullptr};
+	QVBoxLayout* dialogLayout {nullptr};
+	QGridLayout* fromInfoLayout {nullptr};
+	QHBoxLayout* importCancelLayout {nullptr};
+	int count {0};
+	bool masterPages {false};
 
 private slots:
 	void changeFile();




More information about the scribus-commit mailing list