author | harlekin <harlekin> | 2003-03-22 18:18:46 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-03-22 18:18:46 (UTC) |
commit | 916e4d83eb69676e527d7b0cce5fdc0a400a8255 (patch) (side-by-side diff) | |
tree | 15c3d829a943cd8902ab44a9b027967fb28c091f | |
parent | 5fa24d5c7e5ebf45917b8632bfb2fb99cf545381 (diff) | |
download | opie-916e4d83eb69676e527d7b0cce5fdc0a400a8255.zip opie-916e4d83eb69676e527d7b0cce5fdc0a400a8255.tar.gz opie-916e4d83eb69676e527d7b0cce5fdc0a400a8255.tar.bz2 |
use icons from inline
-rw-r--r-- | noncore/apps/opie-write/mainwindow.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/noncore/apps/opie-write/mainwindow.cpp b/noncore/apps/opie-write/mainwindow.cpp index bcafd16..4a49abf 100644 --- a/noncore/apps/opie-write/mainwindow.cpp +++ b/noncore/apps/opie-write/mainwindow.cpp @@ -127,190 +127,190 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) this, SLOT(openFile(const DocLnk &)) ); QObject::connect( fileSelector, SIGNAL(newSelected(const DocLnk&)), this, SLOT(newFile(const DocLnk&)) ); if ( fileSelector->fileCount() < 1 ) fileNew(); else { fileOpen(); } doConnections( editor ); setCentralWidget( editorStack ); } MainWindow::~MainWindow() { save(); } void MainWindow::setupActions() { setToolBarsMovable(false); tbMenu = new QToolBar( this ); tbMenu->setHorizontalStretchable( TRUE ); QMenuBar *menu = new QMenuBar( tbMenu ); tbEdit = new QToolBar( this ); QPopupMenu *file = new QPopupMenu( this ); menu->insertItem( tr("File"), file ); QPopupMenu *edit = new QPopupMenu( this ); menu->insertItem( tr("Edit"), edit ); // ### perhaps these shortcut keys should have some // IPaq keys defined??? QAction *a; a = new QAction( tr( "New" ), Resource::loadPixmap("new"), QString::null, 0, this, 0 ); connect( a, SIGNAL(activated()), this, SLOT(fileNew()) ); a->addTo( file ); a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); connect( a, SIGNAL(activated()), this, SLOT(fileOpen()) ); a->addTo( file ); - a = new QAction( tr( "Undo" ), Resource::loadIconSet("opie-write/undo"), + a = new QAction( tr( "Undo" ), Resource::loadIconSet("undo"), QString::null, 0, this, "editUndo" ); connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) ); connect( editor, SIGNAL(undoAvailable(bool)), a, SLOT(setEnabled(bool)) ); a->addTo( tbEdit ); a->addTo( edit ); - a = new QAction( tr( "Redo" ), Resource::loadIconSet("opie-write/redo"), + a = new QAction( tr( "Redo" ), Resource::loadIconSet("redo"), QString::null, 0, this, "editRedo" ); connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) ); connect( editor, SIGNAL(redoAvailable(bool)), a, SLOT(setEnabled(bool)) ); a->addTo( tbEdit ); a->addTo( edit ); edit->insertSeparator(); - + a = new QAction( tr( "Copy" ), Resource::loadIconSet("copy"), QString::null, 0, this, "editCopy" ); connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) ); a->addTo( tbEdit ); a->addTo( edit ); a = new QAction( tr( "Cut" ), Resource::loadIconSet("cut"), QString::null, 0, this, "editCut" ); connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) ); a->addTo( tbEdit ); a->addTo( edit ); a = new QAction( tr( "Paste" ), Resource::loadPixmap("paste"), QString::null, 0, this, "editPaste" ); connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); a->addTo( tbEdit ); a->addTo( edit ); tbFont = new QToolBar( this ); tbFont->setLabel( "Font Actions" ); tbFont->setHorizontalStretchable(TRUE); comboFont = new QComboBox( FALSE, tbFont ); FontDatabase db; QStringList f= db.families(); comboFont->insertStringList( db.families() ); connect( comboFont, SIGNAL( activated( 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 ); QValueList<int> sizes = db.standardSizes(); QValueList<int>::Iterator it = sizes.begin(); for ( ; it != sizes.end(); ++it ) comboSize->insertItem( QString::number( *it ) ); connect( comboSize, SIGNAL( activated( const QString & ) ), this, SLOT( textSize( const QString & ) ) ); comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) ); comboSize->setFixedWidth( 38 ); tbStyle = new QToolBar( this ); tbStyle->setLabel( "Style Actions" ); actionTextBold = new QAction( tr( "Bold" ), 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" ); connect( actionTextItalic, SIGNAL( activated() ), this, SLOT( textItalic() ) ); actionTextItalic->addTo( tbStyle ); actionTextItalic->setToggleAction( TRUE ); actionTextUnderline = new QAction( tr( "Underline" ), Resource::loadPixmap("underline"), tr( "&Underline" ), CTRL + Key_U, this, "textUnderline" ); connect( actionTextUnderline, SIGNAL( activated() ), this, SLOT( textUnderline() ) ); actionTextUnderline->addTo( tbStyle ); actionTextUnderline->setToggleAction( TRUE ); alignMenu = new ButtonMenu( tbStyle ); alignMenu->insertItem( Resource::loadPixmap("left"), tr("Left"), AlignLeft ); alignMenu->insertItem( Resource::loadPixmap("center"), tr("Center"), AlignCenter ); alignMenu->insertItem( Resource::loadPixmap("right"), tr("Right"), AlignRight ); alignMenu->insertItem( Resource::loadPixmap("opie-write/justify"), tr("Full"), Qt3::AlignJustify ); connect( alignMenu, SIGNAL(activated(int)), this, SLOT(textAlign(int)) ); } Qt3::QTextEdit *MainWindow::currentEditor() const { - return editor; + return editor; } void MainWindow::doConnections( Qt3::QTextEdit *e ) { connect( e, SIGNAL( currentFontChanged( const QFont & ) ), this, SLOT( fontChanged( const QFont & ) ) ); connect( e, SIGNAL( currentColorChanged( const QColor & ) ), this, SLOT( colorChanged( const QColor & ) ) ); connect( e, SIGNAL( currentAlignmentChanged( int ) ), this, SLOT( alignmentChanged( int ) ) ); } void MainWindow::updateFontSizeCombo( const QFont &f ) { comboSize->clear(); 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 ) ); } void MainWindow::editUndo() { if ( !currentEditor() ) return; currentEditor()->undo(); } void MainWindow::editRedo() { if ( !currentEditor() ) return; currentEditor()->redo(); } void MainWindow::editCut() { if ( !currentEditor() ) return; currentEditor()->cut(); } void MainWindow::editCopy() { if ( !currentEditor() ) return; currentEditor()->copy(); @@ -462,97 +462,97 @@ void MainWindow::insertTable() void MainWindow::newFile( const DocLnk &dl ) { DocLnk nf = dl; nf.setType( "text/html" ); clear(); editorStack->raiseWidget( editor ); editor->viewport()->setFocus(); doc = new DocLnk( nf ); updateCaption(); } void MainWindow::openFile( const DocLnk &dl ) { FileManager fm; QString txt; if ( !fm.loadFile( dl, txt ) ) qDebug( "couldn't open file" ); clear(); editorStack->raiseWidget( editor ); editor->viewport()->setFocus(); doc = new DocLnk( dl ); editor->setText( txt ); editor->setModified( FALSE ); updateCaption(); } void MainWindow::showEditTools( void ) { tbMenu->show(); tbEdit->show(); tbFont->show(); tbStyle->show(); } void MainWindow::hideEditTools( void ) { // let's reset the buttons... actionTextBold->setOn( FALSE ); actionTextItalic->setOn( FALSE ); actionTextUnderline->setOn( FALSE ); //comboFont->setCurrentText( QApplication::font().family() ); comboSize->lineEdit()->setText( QString::number(QApplication::font().pointSize() ) ); tbMenu->hide(); tbEdit->hide(); tbFont->hide(); tbStyle->hide(); } - + void MainWindow::save() { if ( !doc ) return; if ( !editor->isModified() ) return; QString rt = editor->text(); // quick hack to get around formatting... editor->setTextFormat( Qt::PlainText ); QString pt = editor->text(); editor->setTextFormat( Qt::RichText ); 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); } FileManager fm; fm.saveFile( *doc, rt ); } void MainWindow::clear() { delete doc; doc = 0; editor->clear(); } void MainWindow::updateCaption() { if ( !doc ) setCaption( tr("Rich Text Editor") ); else { QString s = doc->name(); if ( s.isEmpty() ) s = tr( "Unnamed" ); |