r14612 by cbradney - Initial prep for plugins prefs panes
scribus-commit
scribus-commit at lists.scribus.net
Mon Feb 1 19:57:20 CET 2010
Revision: 14612
Author: cbradney
Date: 2010-01-31T23:11:51.870760Z
Commit message: Initial prep for plugins prefs panes
Changeset:
M /trunk/Scribus/scribus/scplugin.h
M /trunk/Scribus/scribus/ui/preferencesdialog.cpp
M /trunk/Scribus/scribus/ui/prefs_shortwordsbase.ui
M /trunk/Scribus/scribus/ui/preferencesdialog.h
Diffs:
Index: scribus/scplugin.h
===================================================================
--- scribus/scplugin.h (revision 14611)
+++ scribus/scplugin.h (revision 14612)
@@ -172,6 +172,8 @@
*/
virtual bool newPrefsPanelWidget(QWidget* parent, PrefsPanel*& panel,
QString& caption, QPixmap& icon);
+ virtual bool newPrefsPanelWidget(QWidget* parent, QWidget* panel,
+ QString& caption, QPixmap& icon);
/*! @brief Return descriptive information about the plug-in
*
Index: scribus/ui/preferencesdialog.h
===================================================================
--- scribus/ui/preferencesdialog.h (revision 14611)
+++ scribus/ui/preferencesdialog.h (revision 14612)
@@ -71,11 +71,14 @@
void applyButtonClicked();
- private:
+ protected:
int addItem(QString name, QPixmap icon, QWidget *tab);
void setupListWidget();
void arrangeIcons();
void initPreferenceValues();
+ /*! \brief Scans plugins for those that want to add a prefs widget and
+ hooks them up to the dialog. */
+ void addPlugins();
Prefs_ColorManagement *prefs_ColorManagement;
Prefs_UserInterface *prefs_UserInterface;
Index: scribus/ui/prefs_shortwordsbase.ui
===================================================================
--- scribus/ui/prefs_shortwordsbase.ui (revision 14611)
+++ scribus/ui/prefs_shortwordsbase.ui (revision 14612)
@@ -13,7 +13,7 @@
<property name="windowTitle">
<string>Form</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_3">
+ <layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="titleLabel">
<property name="font">
@@ -36,43 +36,39 @@
</widget>
</item>
<item>
- <widget class="QScrollArea" name="scrollArea">
- <property name="widgetResizable">
- <bool>true</bool>
- </property>
- <widget class="QWidget" name="scrollAreaWidgetContents">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>663</width>
- <height>349</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QTextEdit" name="textEdit"/>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Minimum</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- </widget>
+ <widget class="QTextEdit" name="textEdit"/>
</item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer">
+ <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="saveButton">
+ <property name="text">
+ <string>Save</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="resetButton">
+ <property name="text">
+ <string>Reset</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
<resources/>
Index: scribus/ui/preferencesdialog.cpp
===================================================================
--- scribus/ui/preferencesdialog.cpp (revision 14611)
+++ scribus/ui/preferencesdialog.cpp (revision 14612)
@@ -14,7 +14,9 @@
#include "ui/preferencesdialog.h"
#include "commonstrings.h"
+#include "pluginmanager.h"
#include "prefsmanager.h"
+#include "scplugin.h"
#include "scribus.h"
#include "scribuscore.h"
#include "units.h"
@@ -89,7 +91,7 @@
initPreferenceValues();
setupGui();
-
+ addPlugins();
}
@@ -197,7 +199,7 @@
}
-int PreferencesDialog::addItem(QString name, QPixmap icon, QWidget *tab)
+int PreferencesDialog::addItem(QString name, QPixmap icon, QWidget* tab)
{
//TODO: Can we avoid using this name and duplicating strings by getting it from the tab UIs
QListWidgetItem* newItem = new QListWidgetItem(icon, name, preferencesTypeList);
@@ -244,6 +246,45 @@
setWindowTitle( tr( "Preferences" ) );
}
+void PreferencesDialog::addPlugins()
+{
+ // Scan for plugins that provide a prefs widget, and add it to the
+ // prefs dialog.
+ // For each plugin, enabled or not:
+ ScPlugin* plugin = 0;
+ QWidget* panel = 0;
+ QString panelCaption;
+ QPixmap panelIcon;
+
+ PluginManager& pluginManager = PluginManager::instance();
+ QStringList pluginNames(pluginManager.pluginNames(true));
+
+ foreach (QString pName, pluginManager.pluginNames(true))
+ {
+ // Ask the plugin manager for a plugin (skipping disabled plugins).
+ plugin = pluginManager.getPlugin(pName, false);
+ // If we got a plugin (which we know is enabled):
+ if (plugin)
+ {
+ // Ask the plugin for a prefs widget
+ bool wantPanel = plugin->newPrefsPanelWidget(prefsStackWidget, panel, panelCaption, panelIcon);
+ // If it gave us one...
+ if (wantPanel)
+ {
+ // Ensure that we got sane return values
+ Q_ASSERT(panel);
+ Q_ASSERT(!panelIcon.isNull());
+ Q_ASSERT(!panelCaption.isNull());
+ // plug it in to the dialog,
+ addItem(panelCaption, panelIcon, panel);
+ // and connect a signal to tell it to save its
+ // settings.
+ connect(this, SIGNAL(accepted()), panel, SLOT(apply()));
+ }
+ }
+ }
+}
+
void PreferencesDialog::arrangeIcons()
{/*
int maxWidth = 0;
More information about the scribus-commit
mailing list