Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 1595 → Rev 1596

/branches/Version13x/Scribus/scribus/pluginmanager.h
42,6 → 42,7
* \param actMenuAfterName 2nd level menu
* \param actEnabledOnStartup run it at start FIXME
* \param loadPlugin enable or disable plugin for user
* \param loaded is the plug really loaded?
*/
struct PluginData
{
56,6 → 57,7
QString actMenuAfterName;
bool actEnabledOnStartup;
bool loadPlugin;
bool loaded;
};
 
PluginManager();
80,6 → 82,8
void finalizePlug(int pluginID);
/** \brief Returns human readable plugin type */
QString getPluginType(PluginType aType);
/** \brief Saves plugin preferences */
void savePreferences();
 
/*! \brief Input variable to the plug. */
QString dllInput;
/branches/Version13x/Scribus/scribus/libprefs/prefs.cpp
633,41 → 633,48
 
// plugin manager. pv.
pluginManagerWidget = new QWidget(prefsWidgets, "pluginManagerWidget");
pluginManagerLayout = new QVBoxLayout( pluginManagerWidget, 10, 5, "MiscLayout");
pluginManagerLayout->setAlignment( Qt::AlignTop );
groupPluginManager = new QGroupBox(tr("Plugin Manager"), pluginManagerWidget, "groupPluginManager");
groupPluginManager->setColumnLayout(0, Qt::Vertical );
groupPluginManager->layout()->setSpacing(5);
groupPluginManager->layout()->setMargin(10);
groupPluginManagerLayout = new QGridLayout(groupPluginManager->layout());
groupPluginManagerLayout->setAlignment( Qt::AlignTop );
pluginsList = new QListView(groupPluginManager, "pluginsList");
pluginMainLayout = new QVBoxLayout( pluginManagerWidget, 10, 5, "pluginMainLayout");
pluginMainLayout->setAlignment( Qt::AlignTop );
plugGroupBox = new QGroupBox(tr("Plugin Manager"), pluginManagerWidget, "plugGroupBox");
plugGroupBox->setColumnLayout(0, Qt::Vertical);
plugGroupBox->layout()->setSpacing(6);
plugGroupBox->layout()->setMargin(11);
plugGroupBoxLayout = new QGridLayout( plugGroupBox->layout() );
plugGroupBoxLayout->setAlignment(Qt::AlignTop);
plugLayout1 = new QVBoxLayout( 0, 0, 6, "plugLayout1");
pluginsList = new QListView(plugGroupBox, "pluginsList");
pluginsList->setAllColumnsShowFocus(true);
pluginsList->setShowSortIndicator(true);
pluginsList->addColumn(tr("Plugin"));
pluginsList->setColumnWidthMode(0, QListView::Maximum);
pluginsList->addColumn(tr("How to run"));
pluginsList->setColumnWidthMode(1, QListView::Maximum);
pluginsList->addColumn(tr("Type"));
pluginsList->setColumnWidthMode(2, QListView::Maximum);
pluginsList->addColumn(tr("Load it?"));
pluginsList->setAllColumnsShowFocus(true);
pluginsList->setShowSortIndicator(true);
pluginsList->setColumnAlignment(3, Qt::AlignCenter);
// TODO: plugin handling should be better done with some separate class... IN PROGRESS
pluginsList->setColumnWidthMode(3, QListView::Maximum);
pluginsList->addColumn(tr("Plugin ID"));
pluginsList->setColumnWidthMode(4, QListView::Maximum);
pluginsList->addColumn(tr("File"));
pluginsList->setColumnWidthMode(5, QListView::Maximum);
for (QMap<int,PluginManager::PluginData>::Iterator it = ap->pluginManager->pluginMap.begin(); it != ap->pluginManager->pluginMap.end(); ++it)
{
QListViewItem *plugItem = new QListViewItem(pluginsList,
(*it).name.replace('&', "").replace("...", ""),
QString("%1 %2").arg((*it).actMenu).arg((*it).actMenuAfterName),
ap->pluginManager->getPluginType((*it).type));
QListViewItem *plugItem = new QListViewItem(pluginsList);
plugItem->setText(0, (*it).name.replace('&', "").replace("...", "")); // name
plugItem->setText(1, QString("%1 %2").arg((*it).actMenu).arg((*it).actMenuAfterName)); // menu path
plugItem->setText(2, ap->pluginManager->getPluginType((*it).type)); // type
// load at start?
plugItem->setPixmap(3, (*it).loadPlugin ? loadIcon("ok.png") : loadIcon("DateiClos16.png"));
plugItem->setText(3, (*it).loadPlugin ? tr("Yes") : tr("No"));
plugItem->setText(4, QString("%1").arg(it.key())); // id for developers
plugItem->setText(5, (*it).pluginFile); // file for developers
}
groupPluginManagerLayout->addWidget(pluginsList, 0, 0);
/*groupPluginLayout2 = new QHBoxLayout(0, 0, 5, "groupPluginLayout2");
pluginSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
groupPluginLayout2->addItem(pluginSpacer);
pluginRefreshButton = new QPushButton(tr("&Refresh"), groupPluginManager, "pluginRefreshButton");
groupPluginLayout2->addWidget(pluginRefreshButton);
pluginUpdateButton = new QPushButton(tr("&Update"), groupPluginManager, "pluginUpdateButton");
groupPluginLayout2->addWidget(pluginUpdateButton);
groupPluginManagerLayout->addLayout(groupPluginLayout2, 1, 0); */
pluginManagerLayout->addWidget(groupPluginManager);
plugLayout1->addWidget(pluginsList);
pluginWarning = new QLabel(plugGroupBox);
pluginWarning->setText("<qt>" + tr("You need to restart the application to promote the changes.") + "</qt>");
plugLayout1->addWidget(pluginWarning);
plugGroupBoxLayout->addLayout(plugLayout1, 0, 0);
pluginMainLayout->addWidget(plugGroupBox);
addItem(tr("Plugins"), loadIcon("plugins.png"), pluginManagerWidget);
 
setDS();
759,6 → 766,8
connect(FileC4, SIGNAL(clicked()), this, SLOT(changeTemplates()));
connect(CaliSlider, SIGNAL(valueChanged(int)), this, SLOT(setDisScale()));
connect(buttonOk, SIGNAL(clicked()), this, SLOT(setActionHistoryLength()));
connect(pluginsList, SIGNAL(clicked(QListViewItem *, const QPoint &, int)),
this, SLOT(changePluginLoad(QListViewItem *, const QPoint &, int)));
if (CMSavail)
connect(tabColorManagement, SIGNAL(cmsOn(bool )), this, SLOT(switchCMS(bool )));
 
1259,3 → 1268,22
{
tabPDF->enableCMS(enable);
}
 
/*! Set selected item(=plugin) un/loadable (petr vanek) */
void Preferences::changePluginLoad(QListViewItem *item, const QPoint &, int column)
{
if (column != 3)
return;
if (item->text(3) == tr("Yes"))
{
item->setPixmap(3, loadIcon("DateiClos16.png"));
item->setText(3, tr("No"));
ap->pluginManager->pluginMap[item->text(4).toInt()].loadPlugin = false;
}
else
{
item->setPixmap(3, loadIcon("ok.png"));
item->setText(3, tr("Yes"));
ap->pluginManager->pluginMap[item->text(4).toInt()].loadPlugin = true;
}
}
/branches/Version13x/Scribus/scribus/libprefs/prefs.h
167,10 → 167,9
QCheckBox* AskForSubs;
// plugin manager
QWidget* pluginManagerWidget;
QGroupBox* groupPluginManager;
QGroupBox* plugGroupBox;
QListView* pluginsList;
//QPushButton* pluginRefreshButton;
//QPushButton* pluginUpdateButton;
QLabel* pluginWarning;
 
double Umrech;
double PFactor;
238,14 → 237,14
QHBoxLayout* groupScratchLayout;
QGridLayout* Layout4s;
// plugin manager
QSpacerItem* pluginSpacer;
QVBoxLayout* pluginManagerLayout;
QGridLayout* groupPluginManagerLayout;
//QHBoxLayout* groupPluginLayout2;
QVBoxLayout* plugLayout1;
QVBoxLayout* pluginMainLayout;
QGridLayout* plugGroupBoxLayout;
 
private slots:
void setSelectedGUILang( const QString &newLang );
void setActionHistoryLength();
void changePluginLoad(QListViewItem *, const QPoint &, int);
 
private:
LanguageManager langMgr;
/branches/Version13x/Scribus/scribus/scribus.cpp
238,7 → 238,7
splashScreen->setStatus( tr("Initializing Plugins"));
qApp->processEvents();
pluginManager->initPlugs();
 
initKeyboardShortcuts();
 
if (splashScreen != NULL)
1340,7 → 1340,7
connect( scrActions["specialSmartHyphen"], SIGNAL(activatedData(QString)) , this, SLOT(specialActionKeyEvent(QString)) );
connect( scrActions["specialNonBreakingSpace"], SIGNAL(activatedData(QString)) , this, SLOT(specialActionKeyEvent(QString)) );
connect( scrActions["specialPageNumber"], SIGNAL(activatedData(QString)) , this, SLOT(specialActionKeyEvent(QString)) );
 
//GUI
//scrActions.insert("specialToggleEditMode", new ScrAction(ScrAction::DataInt, QIconSet(), tr("Toggle Edit Mode"), Key_F9, this, "specialToggleEditMode",EditMode));
scrActions.insert("specialToggleAllPalettes", new ScrAction(ScrAction::DataQString, QIconSet(), tr("Toggle Palettes"), Key_F10, this, "specialToggleAllPalettes",0,0.0,"specialToggleAllPalettes"));
1347,7 → 1347,7
scrActions.insert("specialToggleAllGuides", new ScrAction(ScrAction::DataQString, QIconSet(), tr("Toggle Guides"), Key_F11, this, "specialToggleAllGuides",0,0.0,"specialToggleAllGuides"));
 
//scrActions["specialToggleEditMode"]->setToggleAction(true);
 
//connect( scrActions["specialToggleEditMode"], SIGNAL(toggledData(bool, int)) , this, SLOT(setAppModeByToggle(bool, int)) );
connect( scrActions["specialToggleAllPalettes"], SIGNAL(activated()) , this, SLOT(ToggleAllPalettes()) );
connect( scrActions["specialToggleAllGuides"], SIGNAL(activated()) , this, SLOT(ToggleAllGuides()) );
1882,7 → 1882,7
KeyMod = 0;
break;
}
 
if ((kk == Key_Escape) && (HaveDoc))
{
keyrep = false;
2012,7 → 2012,7
setAppMode(EditMode);
return;
}
 
switch (doc->appMode)
{
case NormalMode:
5313,6 → 5313,7
void ScribusApp::slotFileQuit()
{
propertiesPalette->UnsetDoc();
pluginManager->savePreferences();
close();
}
 
/branches/Version13x/Scribus/scribus/pluginmanager.cpp
25,12 → 25,17
{
}
 
void PluginManager::savePreferences()
{
// write configuration
for (QMap<int, PluginData>::Iterator it = pluginMap.begin(); it != pluginMap.end(); ++it)
prefs->set(it.data().pluginFile, it.data().loadPlugin);
}
 
void PluginManager::initPlugs()
{
QString name = "";
int id = 0;
// int type = 0;
// int menuid = 0;
struct PluginData pda;
#if defined(__hpux)
QDir dirList(PLUGINDIR, "*.sl*", QDir::Name, QDir::Files | QDir::Executable | QDir::NoSymLinks);
44,8 → 49,6
{
pda.index = 0;
pda.pluginFile = "";
//pda.name = "";
//pda.type = 0;
pda.menuID = 0;
pda.pluginFile = dirList[dc];
pda.loadPlugin = prefs->getBool(dirList[dc], true);
52,6 → 55,8
 
if (DLLname(dirList[dc], &pda.name, &pda.type, &pda.index, &id, &pda.actName, &pda.actKeySequence, &pda.actMenu, &pda.actMenuAfterName, &pda.actEnabledOnStartup, pda.loadPlugin))
{
if (ScApp->splashScreen != NULL)
ScApp->splashScreen->setStatus(tr(QString("Loading: %1").arg(pda.name), "plugin manager"));
if (pda.loadPlugin)
{
if (pda.type == Persistent || pda.type == Standard || pda.type == Import)
74,10 → 79,11
}
else
qDebug(tr(QString("Old type plugins are not supported anymore")), "plugin manager");
pda.loaded = true;
} // load
else
pda.loaded = false;
pluginMap.insert(id, pda);
if (ScApp->splashScreen != NULL)
ScApp->splashScreen->setStatus(tr(QString("Loading: %1").arg(pda.name), "plugin manager"));
}
}
}
179,6 → 185,7
sdemID plugID;
QString plugName = PLUGINDIR;
plugName += name;
 
mo = dlopen(plugName, RTLD_LAZY | RTLD_GLOBAL);
if (!mo)
{
264,20 → 271,19
dlclose(mo);
else
{
dlerror();
demo2 = (sdem2)dlsym(mo, "initPlug");
if ((error = dlerror()) != NULL)
if (loadPlugin)
{
dlclose(mo);
return false;
dlerror();
demo2 = (sdem2)dlsym(mo, "initPlug");
if ((error = dlerror()) != NULL)
{
dlclose(mo);
return false;
}
(*demo2)(ScApp, ScApp);
}
(*demo2)(ScApp, ScApp);
// FIXME: how is the menu organized? (*demo2)(ScApp->scrActions[pluginMap[idNr]], ScApp);
}
 
if (!loadPlugin || loadPlugin != 1)
finalizePlug((int)plugID);
 
return true;
}
 
284,7 → 290,8
void PluginManager::finalizePlugs()
{
for (QMap<int, PluginData>::Iterator it = pluginMap.begin(); it != pluginMap.end(); ++it)
finalizePlug(it.key());
if (it.data().loaded == true)
finalizePlug(it.key());
}
 
void PluginManager::finalizePlug(int pluginID)