r25010 by craig - Backport QDialogButtonBox usage in new doc and prefs dialog

scribus-commit scribus-commit at lists.scribus.net
Thu Mar 10 22:25:48 UTC 2022


Author: craig
Date: Thu Mar 10 22:25:48 2022
New Revision: 25010

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=25010
Log:
Backport QDialogButtonBox usage in new doc and prefs dialog

Modified:
    branches/Version15x/Scribus/scribus/ui/newdocdialog.cpp
    branches/Version15x/Scribus/scribus/ui/newdocdialog.h
    branches/Version15x/Scribus/scribus/ui/preferencesdialog.cpp
    branches/Version15x/Scribus/scribus/ui/preferencesdialog.h
    branches/Version15x/Scribus/scribus/ui/preferencesdialogbase.ui

Modified: branches/Version15x/Scribus/scribus/ui/newdocdialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25010&path=/branches/Version15x/Scribus/scribus/ui/newdocdialog.cpp
==============================================================================
--- branches/Version15x/Scribus/scribus/ui/newdocdialog.cpp	(original)
+++ branches/Version15x/Scribus/scribus/ui/newdocdialog.cpp	Thu Mar 10 22:25:48 2022
@@ -143,12 +143,14 @@
 	}
 	QSpacerItem* spacer = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum );
 	Layout1->addItem( spacer );
-	OKButton = new QPushButton( CommonStrings::tr_OK, this );
-	OKButton->setDefault( true );
-	Layout1->addWidget( OKButton );
-	CancelB = new QPushButton( CommonStrings::tr_Cancel, this );
-	CancelB->setAutoDefault( false );
-	Layout1->addWidget( CancelB );
+	buttonBox = new QDialogButtonBox();
+	Layout1->addWidget(buttonBox);
+	okButton = new QPushButton( CommonStrings::tr_OK, this );
+	okButton->setDefault( true );
+	buttonBox->addButton(okButton, QDialogButtonBox::AcceptRole);
+	cancelButton = new QPushButton( CommonStrings::tr_Cancel, this );
+	cancelButton->setAutoDefault( false );
+	buttonBox->addButton(cancelButton, QDialogButtonBox::RejectRole);
 	TabbedNewDocLayout->addLayout( Layout1 );
 	//tooltips
 	pageSizeComboBox->setToolTip( tr( "Document page size, either a standard size or a custom size" ) );
@@ -162,8 +164,8 @@
 	Distance->setToolTip( tr( "Distance between automatically created columns" ) );
 
 	// signals and slots connections
-	connect( OKButton, SIGNAL( clicked() ), this, SLOT( ExitOK() ) );
-	connect( CancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
+	connect(buttonBox, SIGNAL(accepted()), this, SLOT(ExitOK()));
+	connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
 	connect(pageSizeComboBox, SIGNAL(activated(const QString &)), this, SLOT(setPageSize(const QString &)));
 	connect(pageOrientationComboBox, SIGNAL(activated(int)), this, SLOT(setOrientation(int)));
 	connect(unitOfMeasureComboBox, SIGNAL(activated(int)), this, SLOT(setUnit(int)));
@@ -690,7 +692,7 @@
 		setWindowTitle(tr("Open Recent Document"));
 	else
 		setWindowTitle(tr("New Document"));
-	OKButton->setEnabled(tab!=2);
+	okButton->setEnabled(tab!=2);
 }
 
 void NewDocDialog::locationDropped(const QString& fileUrl)
@@ -742,5 +744,5 @@
 
 void NewDocDialog::openFileDialogFileClicked(const QString& path)
 {
-	OKButton->setEnabled(!path.isEmpty());
-}
+	okButton->setEnabled(!path.isEmpty());
+}

Modified: branches/Version15x/Scribus/scribus/ui/newdocdialog.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25010&path=/branches/Version15x/Scribus/scribus/ui/newdocdialog.h
==============================================================================
--- branches/Version15x/Scribus/scribus/ui/newdocdialog.h	(original)
+++ branches/Version15x/Scribus/scribus/ui/newdocdialog.h	Thu Mar 10 22:25:48 2022
@@ -8,6 +8,7 @@
 #define NEWDOCDIALOG_H
 
 #include <QDialog>
+#include <QDialogButtonBox>
 #include <QDropEvent>
 #include <QDragEnterEvent>
 #include <QDragLeaveEvent>
@@ -108,8 +109,9 @@
 	nftwidget *nftGui {nullptr};
 	QFrame* recentDocFrame {nullptr};
 	QListWidget* recentDocListBox {nullptr};
-	QPushButton* OKButton {nullptr};
-	QPushButton* CancelB {nullptr};
+	QDialogButtonBox* buttonBox {nullptr};
+	QPushButton* okButton {nullptr};
+	QPushButton* cancelButton {nullptr};
 
 	bool onStartup() const { return m_onStartup;}
 	int  tabSelected() const { return m_tabSelected;}

Modified: branches/Version15x/Scribus/scribus/ui/preferencesdialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25010&path=/branches/Version15x/Scribus/scribus/ui/preferencesdialog.cpp
==============================================================================
--- branches/Version15x/Scribus/scribus/ui/preferencesdialog.cpp	(original)
+++ branches/Version15x/Scribus/scribus/ui/preferencesdialog.cpp	Thu Mar 10 22:25:48 2022
@@ -32,7 +32,6 @@
 	while (prefsStackWidget->currentWidget()!=nullptr)
 		prefsStackWidget->removeWidget(prefsStackWidget->currentWidget());
 
-	applyButton->hide();
 	exportButton->hide();
 
 	if(doc)
@@ -138,14 +137,10 @@
 
 	connect(prefs_DocumentSetup, SIGNAL(changeToOtherSection(const QString&)), this, SLOT(setNewItemSelected(const QString&)));
 	connect(prefs_DocumentSetup, SIGNAL(prefsChangeUnits(int)), this, SLOT(changeUnits(int)));
-	connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
-	connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
-	connect(applyButton, SIGNAL(clicked()), this, SLOT(applyButtonClicked()));
+	connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+	connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
 	connect(preferencesTypeList, SIGNAL(itemSelectionChanged()), this, SLOT(newItemSelected()));
 }
-
-
-PreferencesDialog::~PreferencesDialog() = default;
 
 void PreferencesDialog::restoreDefaults()
 {
@@ -225,13 +220,6 @@
 	if (prefs_ImageCache) prefs_ImageCache->saveGuiToPrefs(&localPrefs);
 }
 
-void PreferencesDialog::applyButtonClicked()
-{
-	Prefs_Pane* pp=qobject_cast<Prefs_Pane *>(prefsStackWidget->currentWidget());
-	if (pp)
-		pp->saveGuiToPrefs(&localPrefs);
-}
-
 void PreferencesDialog::accept()
 {
 	saveGuiToPrefs();

Modified: branches/Version15x/Scribus/scribus/ui/preferencesdialog.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25010&path=/branches/Version15x/Scribus/scribus/ui/preferencesdialog.h
==============================================================================
--- branches/Version15x/Scribus/scribus/ui/preferencesdialog.h	(original)
+++ branches/Version15x/Scribus/scribus/ui/preferencesdialog.h	Thu Mar 10 22:25:48 2022
@@ -9,6 +9,7 @@
 
 
 #include <QListWidgetItem>
+#include <QDialogButtonBox>
 #include <QMap>
 #include <QStackedWidget>
 
@@ -56,7 +57,7 @@
 
 	public:
 		PreferencesDialog(QWidget* parent, ApplicationPrefs& prefsData, ScribusDoc *doc=nullptr);
-		~PreferencesDialog();
+		~PreferencesDialog() = default;
 
 		ApplicationPrefs prefs() const { return localPrefs; }
 		void getResizeDocumentPages(bool &resizePages, bool &resizeMasterPages, bool &resizePageMargins, bool &resizeMasterPageMargins);
@@ -74,7 +75,6 @@
 
 	protected slots:
 		virtual void languageChange();
-		void applyButtonClicked();
 
 	protected:
 		void addWidget(Prefs_Pane* tab);

Modified: branches/Version15x/Scribus/scribus/ui/preferencesdialogbase.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25010&path=/branches/Version15x/Scribus/scribus/ui/preferencesdialogbase.ui
==============================================================================
--- branches/Version15x/Scribus/scribus/ui/preferencesdialogbase.ui	(original)
+++ branches/Version15x/Scribus/scribus/ui/preferencesdialogbase.ui	Thu Mar 10 22:25:48 2022
@@ -11,29 +11,29 @@
    </rect>
   </property>
   <property name="windowTitle">
-   <string>Preferences</string>
-  </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
-   <property name="leftMargin">
-    <number>9</number>
-   </property>
-   <property name="topMargin">
-    <number>9</number>
-   </property>
-   <property name="rightMargin">
-    <number>9</number>
-   </property>
-   <property name="bottomMargin">
-    <number>9</number>
-   </property>
-   <item>
-    <layout class="QHBoxLayout" name="frameHorizontalLayout">
-     <property name="spacing">
-      <number>9</number>
-     </property>
-     <item>
-      <widget class="QListWidget" name="preferencesTypeList">
-       <property name="minimumSize">
+   <string>Preferences</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <property name="leftMargin">
+    <number>9</number>
+   </property>
+   <property name="topMargin">
+    <number>9</number>
+   </property>
+   <property name="rightMargin">
+    <number>9</number>
+   </property>
+   <property name="bottomMargin">
+    <number>9</number>
+   </property>
+   <item>
+    <layout class="QHBoxLayout" name="frameHorizontalLayout">
+     <property name="spacing">
+      <number>9</number>
+     </property>
+     <item>
+      <widget class="QListWidget" name="preferencesTypeList">
+       <property name="minimumSize">
         <size>
          <width>0</width>
          <height>0</height>
@@ -52,7 +52,7 @@
         <bool>false</bool>
        </property>
        <property name="dragDropMode">
-        <enum>QAbstractItemView::NoDragDrop</enum>
+        <enum>QAbstractItemView::DragDrop</enum>
        </property>
        <property name="alternatingRowColors">
         <bool>true</bool>
@@ -63,95 +63,72 @@
        <property name="viewMode">
         <enum>QListView::IconMode</enum>
        </property>
-      </widget>
-     </item>
-     <item>
-      <layout class="QVBoxLayout" name="verticalLayout_5">
-       <property name="spacing">
-        <number>9</number>
-       </property>
-       <item>
-        <widget class="QStackedWidget" name="prefsStackWidget">
-         <widget class="QWidget" name="page_2"/>
-        </widget>
-       </item>
-       <item>
-        <layout class="QHBoxLayout" name="buttonHorizontalLayout">
-         <property name="leftMargin">
-          <number>0</number>
-         </property>
-         <property name="rightMargin">
-          <number>0</number>
-         </property>
-         <item>
-          <widget class="QPushButton" name="exportButton">
-           <property name="text">
-            <string>Export...</string>
-           </property>
-           <property name="autoDefault">
-            <bool>false</bool>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="QPushButton" name="defaultsButton">
-           <property name="text">
-            <string>Defaults</string>
-           </property>
-           <property name="autoDefault">
-            <bool>false</bool>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <spacer name="buttonHorizontalSpacer">
-           <property name="orientation">
-            <enum>Qt::Horizontal</enum>
-           </property>
-           <property name="sizeHint" stdset="0">
-            <size>
-             <width>40</width>
-             <height>20</height>
-            </size>
-           </property>
-          </spacer>
-         </item>
-         <item>
-          <widget class="QPushButton" name="applyButton">
-           <property name="text">
-            <string>&Apply</string>
-           </property>
-           <property name="autoDefault">
-            <bool>false</bool>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="QPushButton" name="okButton">
-           <property name="text">
-            <string>&OK</string>
-           </property>
-           <property name="autoDefault">
-            <bool>false</bool>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="QPushButton" name="cancelButton">
-           <property name="text">
-            <string>&Cancel</string>
-           </property>
-           <property name="default">
-            <bool>true</bool>
-           </property>
-          </widget>
-         </item>
-        </layout>
-       </item>
-      </layout>
-     </item>
-    </layout>
-   </item>
+      </widget>
+     </item>
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_5">
+       <property name="spacing">
+        <number>9</number>
+       </property>
+       <item>
+        <widget class="QStackedWidget" name="prefsStackWidget">
+         <widget class="QWidget" name="page_2"/>
+        </widget>
+       </item>
+       <item>
+        <layout class="QHBoxLayout" name="buttonHorizontalLayout">
+         <property name="leftMargin">
+          <number>0</number>
+         </property>
+         <property name="rightMargin">
+          <number>0</number>
+         </property>
+         <item>
+          <widget class="QPushButton" name="exportButton">
+           <property name="text">
+            <string>Export...</string>
+           </property>
+           <property name="autoDefault">
+            <bool>false</bool>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QPushButton" name="defaultsButton">
+           <property name="text">
+            <string>Defaults</string>
+           </property>
+           <property name="autoDefault">
+            <bool>false</bool>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <spacer name="buttonHorizontalSpacer">
+           <property name="orientation">
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="sizeHint" stdset="0">
+            <size>
+             <width>40</width>
+             <height>20</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+         <item>
+          <widget class="QDialogButtonBox" name="buttonBox">
+           <property name="standardButtons">
+            <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
   </layout>
  </widget>
  <resources/>




More information about the scribus-commit mailing list