Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 287 → Rev 288

/trunk/Scribus/scribus/plugins/fontpreview/ui.h
0,0 → 1,54
#ifndef FONTPREVIEW_H
#define FONTPREVIEW_H
 
#include <qvariant.h>
#include <qdialog.h>
#include "scribus.h"
 
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QListBox;
class QListBoxItem;
class QPushButton;
class QLabel;
 
class FontPreview : public QDialog
{
Q_OBJECT
 
public:
FontPreview( ScribusApp *carrier, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~FontPreview();
 
/** Reference on the parent application object */
ScribusApp *carrier;
/** gui widgets */
QListBox* fontList;
QPushButton* okButton;
QPushButton* cancelButton;
QLabel* fontPreview;
 
public slots:
/** accept dialog */
virtual void okButton_clicked();
/** reject dialog */
virtual void cancelButton_clicked();
/** creates font sample */
virtual void fontList_changed( QListBoxItem * );
 
protected:
/** gui layout */
QGridLayout* FontPreviewLayout;
QVBoxLayout* layout6;
QHBoxLayout* layout5;
QVBoxLayout* layout2;
QVBoxLayout* layout1;
 
protected slots:
/** tr() */
virtual void languageChange();
 
};
 
#endif // FONTPREVIEW_H
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: fontpreview.cpp
===================================================================
--- fontpreview.cpp (nonexistent)
+++ fontpreview.cpp (revision 288)
@@ -0,0 +1,41 @@
+#include "fontpreview.h"
+#include "ui.h"
+
+QString Name()
+{
+ return "Fonts Preview";
+}
+
+
+int Type()
+{
+ return 1;
+}
+
+
+/**
+Create dialog and insert font into Style meny when user accepts.
+*/
+void Run(QWidget *d, ScribusApp *plug)
+{
+ FontPreview *dlg = new FontPreview(plug, d, "dlg", TRUE, 0);
+ SCFontsIterator fontIter(plug->Prefs.AvailFonts);
+
+ fontIter.toFirst();
+ for ( ; fontIter.current(); ++fontIter)
+ {
+ if (fontIter.current()->UseFont)
+ dlg->fontList->insertItem(fontIter.current()->SCName);
+ } // for fontIter
+ dlg->fontList->sort();
+
+ //dlg->selectAction(action);
+ if (dlg->exec()==QDialog::Accepted)
+ {
+ //action accepted
+ plug->SetNewFont(dlg->fontList->currentText());
+ }
+
+ delete dlg;
+}
+
/fontpreview.cpp
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: Makefile.am
===================================================================
--- Makefile.am (nonexistent)
+++ Makefile.am (revision 288)
@@ -0,0 +1,23 @@
+pluginsdir = $(prefix)/lib/scribus/plugins
+AM_CPPFLAGS = -I$(top_builddir)/scribus
+
+plugins_LTLIBRARIES = libfontpreview.la
+
+INCLUDES = $(LIBFREETYPE_CFLAGS) $(all_includes)
+
+libfontpreview_la_LDFLAGS = -version-info 0:0:0
+libfontpreview_la_METASOURCES = AUTO
+libfontpreview_la_SOURCES = ui.cpp fontpreview.cpp
+
+EXTRA_DIST = scribus_head.png ui.cpp fontpreview.cpp ui.h fontpreview.h
+
+KDE_OPTIONS = qtonly
+AM_LDFLAGS = -s $(LIBFREETYPE_LIBS)
+
+install-data-local:
+ $(mkinstalldirs) $(prefix)/share/scribus/icons/
+ $(INSTALL_DATA) $(srcdir)/scribus_head.png $(prefix)/share/scribus/icons/scribus_head.png
+
+uninstall-local:
+ -rm -f $(prefix)/share/scribus/icons/scribus_head.png
+
/Makefile.am
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: fontpreview.h
===================================================================
--- fontpreview.h (nonexistent)
+++ fontpreview.h (revision 288)
@@ -0,0 +1,24 @@
+#ifndef MYPLUGIN_H
+#define MYPLUGIN_H
+
+#include "scribus.h"
+
+/** Calls the Plugin with the main Application window as parent
+ * and the main Application Class as parameter */
+extern "C" void Run(QWidget *d, ScribusApp *plug);
+
+
+/** Returns the Name of the Plugin.
+ * This name appears in the relevant Menue-Entrys */
+extern "C" QString Name();
+
+
+/** Returns the Type of the Plugin.
+ * 1 = the Plugin is a normal Plugin, which appears in the Extras Menue
+ * 2 = the Plugin is a Import Plugin, which appears in the Import Menue
+ * 3 = the Plugin is a Export Plugin, which appears in the Export Menue
+ * 4 = the Plugin is a resident Plugin */
+extern "C" int Type();
+
+
+#endif
/fontpreview.h
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: ui.cpp
===================================================================
--- ui.cpp (nonexistent)
+++ ui.cpp (revision 288)
@@ -0,0 +1,134 @@
+#include "ui.h"
+#include "ui.moc"
+#include <qvariant.h>
+#include <qpushbutton.h>
+#include <qlistbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+extern QPixmap FontSample(QString da, int s, QString ts, QColor back);
+extern QPixmap loadIcon(QString nam);
+
+/*
+ * Constructs a FontPreview as a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'.
+ *
+ * The dialog will by default be modeless, unless you set 'modal' to
+ * TRUE to construct a modal dialog.
+ */
+FontPreview::FontPreview( ScribusApp *carrier, QWidget* parent, const char* name, bool modal, WFlags fl )
+ : QDialog( parent, name, modal, fl )
+{
+ this->carrier = carrier;
+ if ( !name )
+ setName( "FontPreview" );
+ setIcon(loadIcon("AppIcon.png"));
+ FontPreviewLayout = new QGridLayout( this, 1, 1, 11, 6, "FontPreviewLayout");
+
+ layout6 = new QVBoxLayout( 0, 0, 6, "layout6");
+
+ layout5 = new QHBoxLayout( 0, 0, 6, "layout5");
+
+ fontList = new QListBox( this, "fontList" );
+ layout5->addWidget( fontList );
+
+ layout2 = new QVBoxLayout( 0, 0, 6, "layout2");
+
+ layout1 = new QVBoxLayout( 0, 0, 6, "layout1");
+
+ okButton = new QPushButton( this, "okButton" );
+ layout1->addWidget( okButton );
+
+ cancelButton = new QPushButton( this, "cancelButton" );
+ layout1->addWidget( cancelButton );
+ layout2->addLayout( layout1 );
+ QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ layout2->addItem( spacer );
+ layout5->addLayout( layout2 );
+ layout6->addLayout( layout5 );
+
+ fontPreview = new QLabel( this, "fontPreview" );
+ fontPreview->setScaledContents( TRUE );
+ fontPreview->setPixmap(loadIcon("scribus_head.png"));
+ layout6->addWidget( fontPreview );
+
+ FontPreviewLayout->addLayout( layout6, 0, 0 );
+ languageChange();
+ resize( QSize(640, 480).expandedTo(minimumSizeHint()) );
+ clearWState( WState_Polished );
+
+ // signals and slots connections
+ connect( okButton, SIGNAL( clicked() ), this, SLOT( okButton_clicked() ) );
+ connect( cancelButton, SIGNAL( clicked() ), this, SLOT( cancelButton_clicked() ) );
+ //connect( fontList, SIGNAL( clicked(QListBoxItem*,const QPoint&) ), this, SLOT( fontList_clicked(QListBoxItem*,const QPoint&) ) );
+ connect( fontList, SIGNAL( selectionChanged(QListBoxItem*) ), this, SLOT( fontList_changed(QListBoxItem*) ) );
+}
+
+/**
+Destroys the object and frees any allocated resources
+ */
+FontPreview::~FontPreview()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+/*
+ * Sets the strings of the subwidgets using the current
+ * language.
+ */
+void FontPreview::languageChange()
+{
+ setCaption( tr( "Font Preview" ) );
+ okButton->setText( tr( "&OK" ) );
+ okButton->setAccel( QKeySequence( tr( "Alt+O" ) ) );
+ cancelButton->setText( tr( "&Cancel" ) );
+ cancelButton->setAccel( QKeySequence( tr( "Alt+C" ) ) );
+}
+
+
+/**
+User wants to add font into Style menu
+*/
+void FontPreview::okButton_clicked()
+{
+ accept();
+}
+
+
+/**
+Just close the dialog
+*/
+void FontPreview::cancelButton_clicked()
+{
+ reject();
+}
+
+
+/**
+Creates pixmap with font sample
+*/
+void FontPreview::fontList_changed( QListBoxItem *item )
+{
+ int w = fontPreview->width();
+ int h = fontPreview->height();
+ QString da = carrier->Prefs.AvailFonts[item->text()]->Datei;
+ QPixmap pixmap = FontSample(
+ da, 28,
+ tr("Woven silk pyjamas exchanged for blue quartz"),
+ paletteBackgroundColor()
+ );
+ if ((pixmap.width() > w) || (pixmap.height() > h))
+ {
+ pixmap.resize(
+ pixmap.width() > w ? w : pixmap.width(),
+ pixmap.height() > h ? h : pixmap.height()
+ );
+ }
+ fontPreview->clear();
+ fontPreview->setScaledContents(FALSE);
+ fontPreview->setPixmap(pixmap);
+ fontPreview->setMinimumSize(w, h);
+ fontPreview->setMaximumSize(w, h);
+}
/ui.cpp
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: scribus_head.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/scribus_head.png
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property