r14640 by cbradney - Add in plugin prefs pane to new prefs dialog
scribus-commit
scribus-commit at lists.scribus.net
Thu Feb 4 21:40:27 CET 2010
Revision: 14640
Author: cbradney
Date: 2010-02-04T20:31:53.819030Z
Commit message: Add in plugin prefs pane to new prefs dialog
Changeset:
M /trunk/Scribus/scribus/ui/prefs_plugins.cpp
M /trunk/Scribus/scribus/plugins/scriptplugin/prefs_scripter.cpp
M /trunk/Scribus/scribus/ui/prefs_plugins.h
M /trunk/Scribus/scribus/ui/prefs_pluginsbase.ui
Diffs:
Index: scribus/ui/prefs_plugins.h
===================================================================
--- scribus/ui/prefs_plugins.h (revision 14639)
+++ scribus/ui/prefs_plugins.h (revision 14640)
@@ -9,15 +9,30 @@
#define PREFS_PLUGINS_H
#include "ui_prefs_pluginsbase.h"
+#include "prefs_pane.h"
#include "scribusapi.h"
-class SCRIBUS_API Prefs_Plugins : public QWidget, Ui::Prefs_Plugins
+class SCRIBUS_API Prefs_Plugins : public Prefs_Pane, Ui::Prefs_Plugins
{
Q_OBJECT
public:
Prefs_Plugins(QWidget* parent=0);
~Prefs_Plugins();
+ virtual void restoreDefaults(struct ApplicationPrefs *prefsData);
+ virtual void saveGuiToPrefs(struct ApplicationPrefs *prefsData) const;
+
+ public slots:
+ void languageChange();
+ //! \brief Apply changes to each plugin's PluginSettings
+ void apply();
};
+//! \brief Non editable QTableWidgetItem
+class PluginPrefsTableItem : public QTableWidgetItem
+{
+ public:
+ PluginPrefsTableItem(const QString & text);
+};
+
#endif // PREFS_PLUGINS_H
Index: scribus/ui/prefs_pluginsbase.ui
===================================================================
--- scribus/ui/prefs_pluginsbase.ui (revision 14639)
+++ scribus/ui/prefs_pluginsbase.ui (revision 14640)
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>777</width>
- <height>730</height>
+ <width>726</width>
+ <height>429</height>
</rect>
</property>
<property name="windowTitle">
@@ -36,67 +36,55 @@
</widget>
</item>
<item>
- <widget class="QScrollArea" name="scrollArea">
- <property name="widgetResizable">
+ <widget class="QTableWidget" name="pluginTable">
+ <property name="alternatingRowColors">
<bool>true</bool>
</property>
- <widget class="QWidget" name="scrollAreaWidgetContents">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>749</width>
- <height>659</height>
- </rect>
+ <property name="selectionBehavior">
+ <enum>QAbstractItemView::SelectRows</enum>
+ </property>
+ <property name="columnCount">
+ <number>6</number>
+ </property>
+ <column>
+ <property name="text">
+ <string>Plugin</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QTableWidget" name="pluginTable">
- <property name="alternatingRowColors">
- <bool>true</bool>
- </property>
- <property name="selectionBehavior">
- <enum>QAbstractItemView::SelectRows</enum>
- </property>
- <property name="columnCount">
- <number>6</number>
- </property>
- <column>
- <property name="text">
- <string>Plugin</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>How to run</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Type</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Load it?</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Plugin ID</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>File</string>
- </property>
- </column>
- </widget>
- </item>
- </layout>
- </widget>
+ </column>
+ <column>
+ <property name="text">
+ <string>How to run</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Type</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Load it?</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Plugin ID</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>File</string>
+ </property>
+ </column>
</widget>
</item>
+ <item>
+ <widget class="QLabel" name="restartLabel">
+ <property name="text">
+ <string>You need to restart the application to apply the changes.</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<resources/>
Index: scribus/ui/prefs_plugins.cpp
===================================================================
--- scribus/ui/prefs_plugins.cpp (revision 14639)
+++ scribus/ui/prefs_plugins.cpp (revision 14640)
@@ -7,14 +7,125 @@
#include "prefs_plugins.h"
+#include <QCheckBox>
+#include <QLabel>
+#include "ui/scmwmenumanager.h"
+#include "pluginmanagerprefsgui.h"
+#include "pluginmanager.h"
+#include "scraction.h"
+#include "scplugin.h"
+#include "scribuscore.h"
+#include "scribus.h"
+#include "commonstrings.h"
+
Prefs_Plugins::Prefs_Plugins(QWidget* parent)
- : QWidget(parent)
+ : Prefs_Pane(parent)
{
setupUi(this);
+ languageChange();
+ PluginManager& pluginManager(PluginManager::instance());
+ //Hide this stuff as we don't want it now we are not letting people turn plugins on or off
+ pluginTable->setColumnHidden(3, true);
+ restartLabel->setHidden(true);
+ // Get a list of all internal plugin names, including those of disabled
+ // plugins, then loop over them and add each one to the plugin list.
+ QStringList pluginNames(pluginManager.pluginNames(true));
+ pluginTable->setRowCount(pluginNames.count());
+ ScPlugin* plugin;
+ ScActionPlugin* ixplug;
+ QString pName;
+ ScribusMainWindow* scMW=ScCore->primaryMainWindow();
+ for (int i = 0; i < pluginNames.count(); ++i)
+ {
+ pName = pluginNames.at(i);
+ plugin = pluginManager.getPlugin(pName, true);
+ Q_ASSERT(plugin); // all the returned names should represent loaded plugins
+
+ PluginPrefsTableItem *i0 = new PluginPrefsTableItem(plugin->fullTrName());
+ pluginTable->setItem(i, 0, i0);
+
+ PluginPrefsTableItem *i1 = new PluginPrefsTableItem("");
+ // Resident plugins don't have predefined actions
+ if (plugin->inherits("ScActionPlugin"))
+ {
+ ixplug = dynamic_cast<ScActionPlugin*>(plugin);
+ Q_ASSERT(ixplug);
+ ScActionPlugin::ActionInfo ai(ixplug->actionInfo());
+ // menu path
+ QString men = "";
+ if (!ai.parentMenu.isEmpty())
+ {
+ if (scMW->scrMenuMgr->menuExists(ai.parentMenu))
+ men = scMW->scrMenuMgr->getLocalPopupMenu(ai.parentMenu)->title().remove(QRegExp("&(?!&)")) + " -> ";
+ }
+ if (scMW->scrMenuMgr->menuExists(ai.menu))
+ men += scMW->scrMenuMgr->getLocalPopupMenu(ai.menu)->title().remove(QRegExp("&(?!&)")) + " -> ";
+ i1->setText(men + QString("%1").arg(scMW->scrActions[ai.name]->text().remove(QRegExp("&(?!&)"))));
+ }
+ pluginTable->setItem(i, 1, i1);
+
+ PluginPrefsTableItem *i2 = new PluginPrefsTableItem(plugin->pluginTypeName());
+ pluginTable->setItem(i, 2, i2);
+ /* Don't need this column at all now we are not allowing users to turn plugins on or off
+ // load at start?
+ if (plugin->inherits("ScPersistentPlugin"))
+ {
+ bool onStart = pluginManager.enableOnStartup(pName);
+ // QCheckBox *onStartCheck = new QCheckBox(onStart ? CommonStrings::trYes : CommonStrings::trNo, this);
+ QCheckBox *onStartCheck = new QCheckBox(this);
+ pluginTable->setCellWidget(i, 3, onStartCheck);
+ onStartCheck->setChecked(onStart);
+ }
+ */
+
+ PluginPrefsTableItem *i4 = new PluginPrefsTableItem(pName);
+ pluginTable->setItem(i, 4, i4); // plugname for developers
+ PluginPrefsTableItem *i5 = new PluginPrefsTableItem(pluginManager.getPluginPath(pName));
+ pluginTable->setItem(i, 5, i5); // file path for developers
+ }
+ pluginTable->resizeColumnsToContents();
}
+
+void Prefs_Plugins::apply()
+{
+ QString plugName;
+ // PluginManager& pluginManager(PluginManager::instance());
+ // bool enable;
+ for (int i = 0; i < pluginTable->rowCount(); ++i)
+ {
+ plugName = pluginTable->item(i, 4)->text();
+ /* Don't need this at all now we are not allowing users to turn plugins on or off
+ QCheckBox* onStartCheck=qobject_cast<QCheckBox*>(pluginTable->cellWidget(i, 3));
+ if (onStartCheck)
+ {
+ enable = onStartCheck->isChecked();
+ pluginManager.enableOnStartup(plugName) = enable;
+ }
+ */
+ }
+}
+
Prefs_Plugins::~Prefs_Plugins()
{
}
+void Prefs_Plugins::languageChange()
+{
+}
+
+void Prefs_Plugins::restoreDefaults(struct ApplicationPrefs *prefsData)
+{
+}
+
+void Prefs_Plugins::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
+{
+}
+
+PluginPrefsTableItem::PluginPrefsTableItem(const QString & text)
+ : QTableWidgetItem(text)
+{
+ setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+}
+
Index: scribus/plugins/scriptplugin/prefs_scripter.cpp
===================================================================
--- scribus/plugins/scriptplugin/prefs_scripter.cpp (revision 14639)
+++ scribus/plugins/scriptplugin/prefs_scripter.cpp (revision 14640)
@@ -10,6 +10,7 @@
#include <QColorDialog>
#include <QFileDialog>
+#include <QPalette>
#include "prefs_scripter.h"
#include "scriptercore.h"
More information about the scribus-commit
mailing list