summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-write
authorllornkcor <llornkcor>2002-11-10 03:13:39 (UTC)
committer llornkcor <llornkcor>2002-11-10 03:13:39 (UTC)
commitea3334042e9625c0f67c9a7293a482849f60e4e2 (patch) (side-by-side diff)
treed9c36920818ed681a4a80d3e7af14524e66fa942 /noncore/apps/opie-write
parent7601c75b529d9ff205403a32206b9431845cfc91 (diff)
downloadopie-ea3334042e9625c0f67c9a7293a482849f60e4e2.zip
opie-ea3334042e9625c0f67c9a7293a482849f60e4e2.tar.gz
opie-ea3334042e9625c0f67c9a7293a482849f60e4e2.tar.bz2
use opie's FontDatabase so to be able to use freetype
Diffstat (limited to 'noncore/apps/opie-write') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-write/mainwindow.cpp222
1 files changed, 113 insertions, 109 deletions
diff --git a/noncore/apps/opie-write/mainwindow.cpp b/noncore/apps/opie-write/mainwindow.cpp
index ed95e83..bcafd16 100644
--- a/noncore/apps/opie-write/mainwindow.cpp
+++ b/noncore/apps/opie-write/mainwindow.cpp
@@ -24,4 +24,6 @@
#include <qpe/applnk.h>
#include <qpe/resource.h>
+#include <qpe/fontdatabase.h>
+
//#include "qspellchecker.h"
#include "qtextedit.h"
@@ -50,28 +52,28 @@ class ButtonMenu : public QToolButton
public:
ButtonMenu( QWidget *parent, const char *name=0 )
- : QToolButton( parent, name ), current(0)
+ : QToolButton( parent, name ), current(0)
{
- setPopup( new QPopupMenu( this ) );
- setPopupDelay( 1 );
- connect( popup(), SIGNAL(activated(int)), this, SLOT(selected(int)) );
+ setPopup( new QPopupMenu( this ) );
+ setPopupDelay( 1 );
+ connect( popup(), SIGNAL(activated(int)), this, SLOT(selected(int)) );
}
int insertItem(const QIconSet &icon, const QString &text, int id ) {
- if ( !popup()->count() ) {
- setIconSet( icon );
- current = id;
- }
- return popup()->insertItem( icon, text, id );
+ if ( !popup()->count() ) {
+ setIconSet( icon );
+ current = id;
+ }
+ return popup()->insertItem( icon, text, id );
}
void setCurrentItem( int id ) {
- if ( id != current ) {
- current = id;
- setIconSet( *popup()->iconSet( id ) );
- }
+ if ( id != current ) {
+ current = id;
+ setIconSet( *popup()->iconSet( id ) );
+ }
}
virtual QSize sizeHint() const {
- return QToolButton::sizeHint() + QSize( 4, 0 );
+ return QToolButton::sizeHint() + QSize( 4, 0 );
}
@@ -81,14 +83,14 @@ signals:
protected slots:
void selected( int id ) {
- current = id;
- setIconSet( *popup()->iconSet( id ) );
- emit activated( id );
+ current = id;
+ setIconSet( *popup()->iconSet( id ) );
+ emit activated( id );
}
protected:
virtual void drawButtonLabel( QPainter *p ) {
- p->translate( -4, 0 );
- QToolButton::drawButtonLabel( p );
- p->translate( 4, 0 );
+ p->translate( -4, 0 );
+ QToolButton::drawButtonLabel( p );
+ p->translate( 4, 0 );
}
@@ -108,5 +110,5 @@ MainWindow::MainWindow( QWidget *parent, const char *name )
fileSelector = new FileSelector( "text/html",
- editorStack, "fileselector" );
+ editorStack, "fileselector" );
@@ -121,14 +123,14 @@ MainWindow::MainWindow( QWidget *parent, const char *name )
QObject::connect( fileSelector, SIGNAL(closeMe()),
- this, SLOT(showEditTools()) );
+ this, SLOT(showEditTools()) );
QObject::connect( fileSelector, SIGNAL(fileSelected(const DocLnk &)),
- this, SLOT(openFile(const DocLnk &)) );
+ this, SLOT(openFile(const DocLnk &)) );
QObject::connect( fileSelector, SIGNAL(newSelected(const DocLnk&)),
- this, SLOT(newFile(const DocLnk&)) );
+ this, SLOT(newFile(const DocLnk&)) );
if ( fileSelector->fileCount() < 1 )
- fileNew();
+ fileNew();
else {
- fileOpen();
+ fileOpen();
}
doConnections( editor );
@@ -172,5 +174,5 @@ void MainWindow::setupActions()
a = new QAction( tr( "Undo" ), Resource::loadIconSet("opie-write/undo"),
- QString::null, 0, this, "editUndo" );
+ QString::null, 0, this, "editUndo" );
connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
connect( editor, SIGNAL(undoAvailable(bool)), a, SLOT(setEnabled(bool)) );
@@ -178,5 +180,5 @@ void MainWindow::setupActions()
a->addTo( edit );
a = new QAction( tr( "Redo" ), Resource::loadIconSet("opie-write/redo"),
- QString::null, 0, this, "editRedo" );
+ QString::null, 0, this, "editRedo" );
connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
connect( editor, SIGNAL(redoAvailable(bool)), a, SLOT(setEnabled(bool)) );
@@ -187,5 +189,5 @@ void MainWindow::setupActions()
a = new QAction( tr( "Copy" ), Resource::loadIconSet("copy"),
- QString::null, 0, this, "editCopy" );
+ QString::null, 0, this, "editCopy" );
connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) );
@@ -193,5 +195,5 @@ void MainWindow::setupActions()
a->addTo( edit );
a = new QAction( tr( "Cut" ), Resource::loadIconSet("cut"),
- QString::null, 0, this, "editCut" );
+ QString::null, 0, this, "editCut" );
connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) );
@@ -199,5 +201,5 @@ void MainWindow::setupActions()
a->addTo( edit );
a = new QAction( tr( "Paste" ), Resource::loadPixmap("paste"),
- QString::null, 0, this, "editPaste" );
+ QString::null, 0, this, "editPaste" );
connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
a->addTo( tbEdit );
@@ -209,9 +211,11 @@ void MainWindow::setupActions()
comboFont = new QComboBox( FALSE, tbFont );
- QFontDatabase db;
+ FontDatabase db;
+ QStringList f= db.families();
comboFont->insertStringList( db.families() );
connect( comboFont, SIGNAL( activated( const QString & ) ),
- this, SLOT( textFamily( const QString & ) ) );
+ this, SLOT( textFamily( const QString & ) ) );
comboFont->setCurrentItem( comboFont->listBox()->index( comboFont->listBox()->findItem( QApplication::font().family() ) ) );
+ comboFont->setMaximumWidth(90);
comboSize = new QComboBox( TRUE, tbFont );
@@ -219,7 +223,7 @@ void MainWindow::setupActions()
QValueList<int>::Iterator it = sizes.begin();
for ( ; it != sizes.end(); ++it )
- comboSize->insertItem( QString::number( *it ) );
+ comboSize->insertItem( QString::number( *it ) );
connect( comboSize, SIGNAL( activated( const QString & ) ),
- this, SLOT( textSize( const QString & ) ) );
+ this, SLOT( textSize( const QString & ) ) );
comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) );
comboSize->setFixedWidth( 38 );
@@ -229,24 +233,24 @@ void MainWindow::setupActions()
actionTextBold = new QAction( tr( "Bold" ),
- Resource::loadPixmap("bold"),
- QString::null, CTRL + Key_B,
- this, "textBold" );
+ Resource::loadPixmap("bold"),
+ QString::null, CTRL + Key_B,
+ this, "textBold" );
connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) );
actionTextBold->addTo( tbStyle );
actionTextBold->setToggleAction( TRUE );
actionTextItalic = new QAction( tr( "Italic" ),
- Resource::loadPixmap("italic"),
- tr( "&Italic" ), CTRL + Key_I,
- this, "textItalic" );
+ Resource::loadPixmap("italic"),
+ tr( "&Italic" ), CTRL + Key_I,
+ this, "textItalic" );
connect( actionTextItalic, SIGNAL( activated() ), this,
- SLOT( textItalic() ) );
+ SLOT( textItalic() ) );
actionTextItalic->addTo( tbStyle );
actionTextItalic->setToggleAction( TRUE );
actionTextUnderline = new QAction( tr( "Underline" ),
- Resource::loadPixmap("underline"),
- tr( "&Underline" ), CTRL + Key_U,
- this, "textUnderline" );
+ Resource::loadPixmap("underline"),
+ tr( "&Underline" ), CTRL + Key_U,
+ this, "textUnderline" );
connect( actionTextUnderline, SIGNAL( activated() ),
- this, SLOT( textUnderline() ) );
+ this, SLOT( textUnderline() ) );
actionTextUnderline->addTo( tbStyle );
actionTextUnderline->setToggleAction( TRUE );
@@ -262,5 +266,5 @@ void MainWindow::setupActions()
Qt3::QTextEdit *MainWindow::currentEditor() const
{
- return editor;
+ return editor;
}
@@ -268,9 +272,9 @@ void MainWindow::doConnections( Qt3::QTextEdit *e )
{
connect( e, SIGNAL( currentFontChanged( const QFont & ) ),
- this, SLOT( fontChanged( const QFont & ) ) );
+ this, SLOT( fontChanged( const QFont & ) ) );
connect( e, SIGNAL( currentColorChanged( const QColor & ) ),
- this, SLOT( colorChanged( const QColor & ) ) );
+ this, SLOT( colorChanged( const QColor & ) ) );
connect( e, SIGNAL( currentAlignmentChanged( int ) ),
- this, SLOT( alignmentChanged( int ) ) );
+ this, SLOT( alignmentChanged( int ) ) );
}
@@ -278,9 +282,9 @@ void MainWindow::updateFontSizeCombo( const QFont &f )
{
comboSize->clear();
- QFontDatabase fdb;
+ FontDatabase fdb;
QValueList<int> sizes = fdb.pointSizes( f.family() );
QValueList<int>::Iterator it = sizes.begin();
for ( ; it != sizes.end(); ++it )
- comboSize->insertItem( QString::number( *it ) );
+ comboSize->insertItem( QString::number( *it ) );
}
@@ -288,5 +292,5 @@ void MainWindow::editUndo()
{
if ( !currentEditor() )
- return;
+ return;
currentEditor()->undo();
}
@@ -295,5 +299,5 @@ void MainWindow::editRedo()
{
if ( !currentEditor() )
- return;
+ return;
currentEditor()->redo();
}
@@ -302,5 +306,5 @@ void MainWindow::editCut()
{
if ( !currentEditor() )
- return;
+ return;
currentEditor()->cut();
}
@@ -309,5 +313,5 @@ void MainWindow::editCopy()
{
if ( !currentEditor() )
- return;
+ return;
currentEditor()->copy();
}
@@ -316,5 +320,5 @@ void MainWindow::editPaste()
{
if ( !currentEditor() )
- return;
+ return;
currentEditor()->paste();
}
@@ -323,5 +327,5 @@ void MainWindow::textBold()
{
if ( !currentEditor() )
- return;
+ return;
currentEditor()->setBold( actionTextBold->isOn() );
}
@@ -330,5 +334,5 @@ void MainWindow::textUnderline()
{
if ( !currentEditor() )
- return;
+ return;
currentEditor()->setUnderline( actionTextUnderline->isOn() );
}
@@ -337,5 +341,5 @@ void MainWindow::textItalic()
{
if ( !currentEditor() )
- return;
+ return;
currentEditor()->setItalic( actionTextItalic->isOn() );
}
@@ -344,5 +348,5 @@ void MainWindow::textFamily( const QString &f )
{
if ( !currentEditor() )
- return;
+ return;
currentEditor()->setFamily( f );
currentEditor()->viewport()->setFocus();
@@ -352,5 +356,5 @@ void MainWindow::textSize( const QString &p )
{
if ( !currentEditor() )
- return;
+ return;
currentEditor()->setPointSize( p.toInt() );
currentEditor()->viewport()->setFocus();
@@ -360,26 +364,26 @@ void MainWindow::textStyle( int i )
{
if ( !currentEditor() )
- return;
+ return;
if ( i == 0 )
- currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayBlock,
- Qt3::QStyleSheetItem::ListDisc );
+ currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayBlock,
+ Qt3::QStyleSheetItem::ListDisc );
else if ( i == 1 )
- currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
- Qt3::QStyleSheetItem::ListDisc );
+ currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
+ Qt3::QStyleSheetItem::ListDisc );
else if ( i == 2 )
- currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
- Qt3::QStyleSheetItem::ListCircle );
+ currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
+ Qt3::QStyleSheetItem::ListCircle );
else if ( i == 3 )
- currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
- Qt3::QStyleSheetItem::ListSquare );
+ currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
+ Qt3::QStyleSheetItem::ListSquare );
else if ( i == 4 )
- currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
- Qt3::QStyleSheetItem::ListDecimal );
+ currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
+ Qt3::QStyleSheetItem::ListDecimal );
else if ( i == 5 )
- currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
- Qt3::QStyleSheetItem::ListLowerAlpha );
+ currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
+ Qt3::QStyleSheetItem::ListLowerAlpha );
else if ( i == 6 )
- currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
- Qt3::QStyleSheetItem::ListUpperAlpha );
+ currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
+ Qt3::QStyleSheetItem::ListUpperAlpha );
currentEditor()->viewport()->setFocus();
}
@@ -388,5 +392,5 @@ void MainWindow::textAlign( int a )
{
if ( !currentEditor() )
- return;
+ return;
editor->setAlignment( a );
}
@@ -409,11 +413,11 @@ void MainWindow::alignmentChanged( int a )
{
if ( ( a == Qt3::AlignAuto ) || ( a & AlignLeft )) {
- alignMenu->setCurrentItem(AlignLeft);
+ alignMenu->setCurrentItem(AlignLeft);
} else if ( ( a & AlignCenter ) ) {
- alignMenu->setCurrentItem(AlignCenter);
+ alignMenu->setCurrentItem(AlignCenter);
} else if ( ( a & AlignRight ) ) {
- alignMenu->setCurrentItem(AlignRight);
+ alignMenu->setCurrentItem(AlignRight);
} else if ( ( a & Qt3::AlignJustify ) ) {
- alignMenu->setCurrentItem(Qt3::AlignJustify);
+ alignMenu->setCurrentItem(Qt3::AlignJustify);
}
}
@@ -422,5 +426,5 @@ void MainWindow::editorChanged( QWidget * )
{
if ( !currentEditor() )
- return;
+ return;
fontChanged( currentEditor()->font() );
colorChanged( currentEditor()->color() );
@@ -472,5 +476,5 @@ void MainWindow::openFile( const DocLnk &dl )
QString txt;
if ( !fm.loadFile( dl, txt ) )
- qDebug( "couldn't open file" );
+ qDebug( "couldn't open file" );
clear();
editorStack->raiseWidget( editor );
@@ -504,11 +508,11 @@ void MainWindow::hideEditTools( void )
}
-
+
void MainWindow::save()
{
if ( !doc )
- return;
+ return;
if ( !editor->isModified() )
- return;
+ return;
QString rt = editor->text();
@@ -520,17 +524,17 @@ void MainWindow::save()
if ( doc->name().isEmpty() ) {
- unsigned ispace = pt.find( ' ' );
- unsigned ienter = pt.find( '\n' );
- int i = (ispace < ienter) ? ispace : ienter;
- QString docname;
- if ( i == -1 ) {
- if ( pt.isEmpty() )
- docname = "Empty Text";
- else
- docname = pt;
- } else {
- docname = pt.left( i );
- }
- doc->setName(docname);
+ unsigned ispace = pt.find( ' ' );
+ unsigned ienter = pt.find( '\n' );
+ int i = (ispace < ienter) ? ispace : ienter;
+ QString docname;
+ if ( i == -1 ) {
+ if ( pt.isEmpty() )
+ docname = "Empty Text";
+ else
+ docname = pt;
+ } else {
+ docname = pt.left( i );
+ }
+ doc->setName(docname);
}
FileManager fm;
@@ -548,10 +552,10 @@ void MainWindow::updateCaption()
{
if ( !doc )
- setCaption( tr("Rich Text Editor") );
+ setCaption( tr("Rich Text Editor") );
else {
- QString s = doc->name();
- if ( s.isEmpty() )
- s = tr( "Unnamed" );
- setCaption( s + " - " + tr("Rich Text Editor") );
+ QString s = doc->name();
+ if ( s.isEmpty() )
+ s = tr( "Unnamed" );
+ setCaption( s + " - " + tr("Rich Text Editor") );
}
}
@@ -560,9 +564,9 @@ void MainWindow::closeEvent( QCloseEvent *e )
{
if ( editorStack->visibleWidget() == editor ) {
- // call fileOpen instead, don't close it
- fileOpen();
- e->ignore();
+ // call fileOpen instead, don't close it
+ fileOpen();
+ e->ignore();
} else {
- e->accept();
+ e->accept();
}
}