Back to index

scribus-ng  1.3.4.dfsg+svn20071115
fontpreviewplugin.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 "fontpreviewplugin.h"
00008 #include "fontpreviewplugin.moc"
00009 #include "fontpreview.h"
00010 #include "scribuscore.h"
00011 #include "scribusdoc.h"
00012 #include <qcursor.h>
00013 #include <qlistview.h>
00014 
00015 int fontpreview_getPluginAPIVersion()
00016 {
00017        return PLUGIN_API_VERSION;
00018 }
00019 
00020 ScPlugin* fontpreview_getPlugin()
00021 {
00022        FontPreviewPlugin* plug = new FontPreviewPlugin();
00023        Q_CHECK_PTR(plug);
00024        return plug;
00025 }
00026 
00027 void fontpreview_freePlugin(ScPlugin* plugin)
00028 {
00029        FontPreviewPlugin* plug = dynamic_cast<FontPreviewPlugin*>(plugin);
00030        Q_ASSERT(plug);
00031        delete plug;
00032 }
00033 
00034 FontPreviewPlugin::FontPreviewPlugin() : ScActionPlugin()
00035 {
00036        // Set action info in languageChange, so we only have to do
00037        // it in one place.
00038        languageChange();
00039 }
00040 
00041 FontPreviewPlugin::~FontPreviewPlugin() {};
00042 
00043 void FontPreviewPlugin::languageChange()
00044 {
00045        // Note that we leave the unused members unset. They'll be initialised
00046        // with their default ctors during construction.
00047        // Action name
00048        m_actionInfo.name = "FontPreview";
00049        // Action text for menu, including accel
00050        m_actionInfo.text = tr("&Font Preview...");
00051        // Menu
00052        m_actionInfo.menu = "Extras";
00053        m_actionInfo.enabledOnStartup = true;
00054 }
00055 
00056 const QString FontPreviewPlugin::fullTrName() const
00057 {
00058        return QObject::tr("Font Preview");
00059 }
00060 
00061 const ScActionPlugin::AboutData* FontPreviewPlugin::getAboutData() const
00062 {
00063        AboutData* about = new AboutData;
00064        Q_CHECK_PTR(about);
00065        about->authors = QString::fromUtf8("Petr Van\xc4\x9bk <petr@scribus.info>");
00066        about->shortDescription = tr("Font Preview dialog");
00067        about->description = tr("Sorting, searching and browsing available fonts.");
00068        // about->version
00069        // about->releaseDate
00070        // about->copyright
00071        about->license = "GPL";
00072        return about;
00073 }
00074 
00075 void FontPreviewPlugin::deleteAboutData(const AboutData* about) const
00076 {
00077        Q_ASSERT(about);
00078        delete about;
00079 }
00080 
00084 bool FontPreviewPlugin::run(ScribusDoc* doc, QString target)
00085 {
00086        ScribusMainWindow* scmw=(doc==0)?ScCore->primaryMainWindow():doc->scMW();
00087        return run(scmw, doc, target);
00088 }
00089 
00090 bool FontPreviewPlugin::run(QWidget* parent, ScribusDoc* doc, QString target)
00091 {
00092        // I don't know how many fonts user has...
00093        qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
00094        FontPreview *dlg = new FontPreview(target, parent, doc);
00095        qApp->restoreOverrideCursor();
00096        // run it and wait for user's reaction
00097        if (dlg->exec() == QDialog::Accepted)
00098        {
00099               if  (target.isEmpty())
00100                      doc->scMW()->SetNewFont(dlg->getCurrentFont());
00101               else
00102                      m_runResult = dlg->getCurrentFont();
00103        }
00104        delete dlg;
00105        return true;
00106 }