Scribus Developer Documentation - API
logo-pen

Scribus Developer Documentation - API

pluginmanagerprefsgui.cpp

Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #include <QCheckBox>
00008 
00009 #include "pluginmanagerprefsgui.h"
00010 #include "pluginmanager.h"
00011 #include "scplugin.h"
00012 #include "commonstrings.h"
00013 
00014 
00015 PluginManagerPrefsGui::PluginManagerPrefsGui(QWidget * parent)
00016     : PrefsPanel(parent)    
00017 {
00018     setupUi(this);
00019     PluginManager& pluginManager(PluginManager::instance());
00020 
00021     // Get a list of all internal plugin names, including those of disabled
00022     // plugins, then loop over them and add each one to the plugin list.
00023     QStringList pluginNames(pluginManager.pluginNames(true));
00024     pluginTable->setRowCount(pluginNames.count());
00025     ScPlugin* plugin;
00026     ScActionPlugin* ixplug;
00027     QString pName;
00028     for (int i = 0; i < pluginNames.count(); ++i)
00029     {
00030         pName = pluginNames.at(i);
00031         plugin = pluginManager.getPlugin(pName, true);
00032         Q_ASSERT(plugin); // all the returned names should represent loaded plugins
00033 
00034         PluginManagerTableItem *i0 = new PluginManagerTableItem(plugin->fullTrName());
00035         pluginTable->setItem(i, 0, i0);
00036 
00037         PluginManagerTableItem *i1 = new PluginManagerTableItem("");
00038         // Resident plugins don't have predefined actions
00039         if (plugin->inherits("ScActionPlugin"))
00040         {
00041             ixplug = dynamic_cast<ScActionPlugin*>(plugin);
00042             Q_ASSERT(ixplug);
00043             ScActionPlugin::ActionInfo ai(ixplug->actionInfo());
00044             // menu path
00045             i1->setText(QString("%1 %2").arg(ai.menu).arg(ai.menuAfterName));
00046         }
00047         pluginTable->setItem(i, 1, i1);
00048 
00049         PluginManagerTableItem *i2 = new PluginManagerTableItem(plugin->pluginTypeName());
00050         pluginTable->setItem(i, 2, i2);
00051 
00052         // load at start?
00053         bool onStart = pluginManager.enableOnStartup(pName);
00054         QCheckBox *onStartCheck = new QCheckBox(onStart ? CommonStrings::trYes : CommonStrings::trNo, this);
00055         onStartCheck->setChecked(onStart);
00056         pluginTable->setCellWidget(i, 3, onStartCheck);
00057 
00058         PluginManagerTableItem *i4 = new PluginManagerTableItem(pName);
00059         pluginTable->setItem(i, 4, i4); // plugname for developers
00060         PluginManagerTableItem *i5 = new PluginManagerTableItem(pluginManager.getPluginPath(pName));
00061         pluginTable->setItem(i, 5, i5); // file path for developers
00062     }
00063     pluginTable->resizeColumnsToContents();
00064 }
00065 
00066 PluginManagerPrefsGui::~PluginManagerPrefsGui()
00067 {
00068 }
00069 
00070 void PluginManagerPrefsGui::apply()
00071 {
00072     PluginManager& pluginManager(PluginManager::instance());
00073     QString plugName;
00074     bool enable;
00075     for (int i = 0; i < pluginTable->rowCount(); ++i)
00076     {
00077         plugName = pluginTable->item(i, 4)->text();
00078         enable = qobject_cast<QCheckBox*>(pluginTable->cellWidget(i, 3))->isChecked();
00079         pluginManager.enableOnStartup(plugName) = enable;
00080     }
00081 }
00082 
00083 
00084 PluginManagerTableItem::PluginManagerTableItem(const QString & text)
00085     : QTableWidgetItem(text)
00086 {
00087     setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
00088 }
Created with personalized Doxygen. This is documentation for GPL software Scribus - Open Source Desktop Publishing.