diff options
| author | craig <craig@11d20701-8431-0410-a711-e3c959e3b870> | 2012-01-01 11:40:09 +0000 |
|---|---|---|
| committer | craig <craig@11d20701-8431-0410-a711-e3c959e3b870> | 2012-01-01 11:40:09 +0000 |
| commit | 7ed83b6c6666eb8b6b104c211ae7e52907350372 (patch) | |
| tree | 4430b556abac0ad660a0aacf1887d77f85d8be02 /scribus/plugins/fontpreview/fontpreviewplugin.cpp | |
| download | scribus-7ed83b6c6666eb8b6b104c211ae7e52907350372.tar.gz scribus-7ed83b6c6666eb8b6b104c211ae7e52907350372.tar.xz scribus-7ed83b6c6666eb8b6b104c211ae7e52907350372.zip | |
Branch 1.3.5 tree to 1.4.x tree, goodbye 1.3.x
git-svn-id: svn://scribus.net/branches/Version14x/Scribus@17163 11d20701-8431-0410-a711-e3c959e3b870
Diffstat (limited to 'scribus/plugins/fontpreview/fontpreviewplugin.cpp')
| -rw-r--r-- | scribus/plugins/fontpreview/fontpreviewplugin.cpp | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/scribus/plugins/fontpreview/fontpreviewplugin.cpp b/scribus/plugins/fontpreview/fontpreviewplugin.cpp new file mode 100644 index 0000000..4288de7 --- /dev/null +++ b/scribus/plugins/fontpreview/fontpreviewplugin.cpp @@ -0,0 +1,108 @@ +/* +For general Scribus (>=1.3.2) copyright and licensing information please refer +to the COPYING file provided with the program. Following this notice may exist +a copyright and/or license notice that predates the release of Scribus 1.3.2 +for which a new license (GPL+exception) is in place. +*/ +#include "fontpreviewplugin.h" +//#include "fontpreviewplugin.moc" +#include "fontpreview.h" +#include "scribuscore.h" +#include "scribusdoc.h" +#include <QCursor> + +int fontpreview_getPluginAPIVersion() +{ + return PLUGIN_API_VERSION; +} + +ScPlugin* fontpreview_getPlugin() +{ + FontPreviewPlugin* plug = new FontPreviewPlugin(); + Q_CHECK_PTR(plug); + return plug; +} + +void fontpreview_freePlugin(ScPlugin* plugin) +{ + FontPreviewPlugin* plug = dynamic_cast<FontPreviewPlugin*>(plugin); + Q_ASSERT(plug); + delete plug; +} + +FontPreviewPlugin::FontPreviewPlugin() : ScActionPlugin() +{ + // Set action info in languageChange, so we only have to do + // it in one place. + languageChange(); +} + +FontPreviewPlugin::~FontPreviewPlugin() {}; + +void FontPreviewPlugin::languageChange() +{ + // Note that we leave the unused members unset. They'll be initialised + // with their default ctors during construction. + // Action name + m_actionInfo.name = "FontPreview"; + // Action text for menu, including accel + m_actionInfo.text = tr("&Font Preview..."); + // Menu + m_actionInfo.menu = "Extras"; + m_actionInfo.enabledOnStartup = false; + m_actionInfo.needsNumObjects = -1; +} + +const QString FontPreviewPlugin::fullTrName() const +{ + return QObject::tr("Font Preview"); +} + +const ScActionPlugin::AboutData* FontPreviewPlugin::getAboutData() const +{ + AboutData* about = new AboutData; + Q_CHECK_PTR(about); + about->authors = QString::fromUtf8("Petr Van\xc4\x9bk <petr@scribus.info>"); + about->shortDescription = tr("Font Preview dialog"); + about->description = tr("Sorting, searching and browsing available fonts."); + // about->version + // about->releaseDate + // about->copyright + about->license = "GPL"; + return about; +} + +void FontPreviewPlugin::deleteAboutData(const AboutData* about) const +{ + Q_ASSERT(about); + delete about; +} + +/** +Create dialog and insert font into Style menu when user accepts. +*/ +bool FontPreviewPlugin::run(ScribusDoc* doc, QString target) +{ + ScribusMainWindow* scmw=(doc==0)?ScCore->primaryMainWindow():doc->scMW(); + return run(scmw, doc, target); +} + +bool FontPreviewPlugin::run(QWidget* parent, ScribusDoc* doc, QString target) +{ + if (doc==NULL) + return false; + // I don't know how many fonts user has... + qApp->changeOverrideCursor(QCursor(Qt::WaitCursor)); + FontPreview *dlg = new FontPreview(target, parent, doc); + qApp->changeOverrideCursor(Qt::ArrowCursor); + // run it and wait for user's reaction + if (dlg->exec() == QDialog::Accepted) + { + if (target.isEmpty()) + doc->scMW()->SetNewFont(dlg->getCurrentFont()); + else + m_runResult = dlg->getCurrentFont(); + } + delete dlg; + return true; +} |
