summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-write/mainwindow.cpp10
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
@@ -143,79 +143,79 @@ MainWindow::~MainWindow()
143 save(); 143 save();
144} 144}
145 145
146void MainWindow::setupActions() 146void MainWindow::setupActions()
147{ 147{
148 setToolBarsMovable(false); 148 setToolBarsMovable(false);
149 149
150 tbMenu = new QToolBar( this ); 150 tbMenu = new QToolBar( this );
151 tbMenu->setHorizontalStretchable( TRUE ); 151 tbMenu->setHorizontalStretchable( TRUE );
152 152
153 QMenuBar *menu = new QMenuBar( tbMenu ); 153 QMenuBar *menu = new QMenuBar( tbMenu );
154 154
155 tbEdit = new QToolBar( this ); 155 tbEdit = new QToolBar( this );
156 156
157 QPopupMenu *file = new QPopupMenu( this ); 157 QPopupMenu *file = new QPopupMenu( this );
158 menu->insertItem( tr("File"), file ); 158 menu->insertItem( tr("File"), file );
159 159
160 QPopupMenu *edit = new QPopupMenu( this ); 160 QPopupMenu *edit = new QPopupMenu( this );
161 menu->insertItem( tr("Edit"), edit ); 161 menu->insertItem( tr("Edit"), edit );
162 162
163 // ### perhaps these shortcut keys should have some 163 // ### perhaps these shortcut keys should have some
164 // IPaq keys defined??? 164 // IPaq keys defined???
165 QAction *a; 165 QAction *a;
166 166
167 a = new QAction( tr( "New" ), Resource::loadPixmap("new"), QString::null, 0, this, 0 ); 167 a = new QAction( tr( "New" ), Resource::loadPixmap("new"), QString::null, 0, this, 0 );
168 connect( a, SIGNAL(activated()), this, SLOT(fileNew()) ); 168 connect( a, SIGNAL(activated()), this, SLOT(fileNew()) );
169 a->addTo( file ); 169 a->addTo( file );
170 170
171 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 171 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
172 connect( a, SIGNAL(activated()), this, SLOT(fileOpen()) ); 172 connect( a, SIGNAL(activated()), this, SLOT(fileOpen()) );
173 a->addTo( file ); 173 a->addTo( file );
174 174
175 a = new QAction( tr( "Undo" ), Resource::loadIconSet("opie-write/undo"), 175 a = new QAction( tr( "Undo" ), Resource::loadIconSet("undo"),
176 QString::null, 0, this, "editUndo" ); 176 QString::null, 0, this, "editUndo" );
177 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) ); 177 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
178 connect( editor, SIGNAL(undoAvailable(bool)), a, SLOT(setEnabled(bool)) ); 178 connect( editor, SIGNAL(undoAvailable(bool)), a, SLOT(setEnabled(bool)) );
179 a->addTo( tbEdit ); 179 a->addTo( tbEdit );
180 a->addTo( edit ); 180 a->addTo( edit );
181 a = new QAction( tr( "Redo" ), Resource::loadIconSet("opie-write/redo"), 181 a = new QAction( tr( "Redo" ), Resource::loadIconSet("redo"),
182 QString::null, 0, this, "editRedo" ); 182 QString::null, 0, this, "editRedo" );
183 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) ); 183 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
184 connect( editor, SIGNAL(redoAvailable(bool)), a, SLOT(setEnabled(bool)) ); 184 connect( editor, SIGNAL(redoAvailable(bool)), a, SLOT(setEnabled(bool)) );
185 a->addTo( tbEdit ); 185 a->addTo( tbEdit );
186 a->addTo( edit ); 186 a->addTo( edit );
187 187
188 edit->insertSeparator(); 188 edit->insertSeparator();
189 189
190 a = new QAction( tr( "Copy" ), Resource::loadIconSet("copy"), 190 a = new QAction( tr( "Copy" ), Resource::loadIconSet("copy"),
191 QString::null, 0, this, "editCopy" ); 191 QString::null, 0, this, "editCopy" );
192 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); 192 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
193 connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) ); 193 connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) );
194 a->addTo( tbEdit ); 194 a->addTo( tbEdit );
195 a->addTo( edit ); 195 a->addTo( edit );
196 a = new QAction( tr( "Cut" ), Resource::loadIconSet("cut"), 196 a = new QAction( tr( "Cut" ), Resource::loadIconSet("cut"),
197 QString::null, 0, this, "editCut" ); 197 QString::null, 0, this, "editCut" );
198 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 198 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
199 connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) ); 199 connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) );
200 a->addTo( tbEdit ); 200 a->addTo( tbEdit );
201 a->addTo( edit ); 201 a->addTo( edit );
202 a = new QAction( tr( "Paste" ), Resource::loadPixmap("paste"), 202 a = new QAction( tr( "Paste" ), Resource::loadPixmap("paste"),
203 QString::null, 0, this, "editPaste" ); 203 QString::null, 0, this, "editPaste" );
204 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); 204 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
205 a->addTo( tbEdit ); 205 a->addTo( tbEdit );
206 a->addTo( edit ); 206 a->addTo( edit );
207 207
208 tbFont = new QToolBar( this ); 208 tbFont = new QToolBar( this );
209 tbFont->setLabel( "Font Actions" ); 209 tbFont->setLabel( "Font Actions" );
210 tbFont->setHorizontalStretchable(TRUE); 210 tbFont->setHorizontalStretchable(TRUE);
211 211
212 comboFont = new QComboBox( FALSE, tbFont ); 212 comboFont = new QComboBox( FALSE, tbFont );
213 FontDatabase db; 213 FontDatabase db;
214 QStringList f= db.families(); 214 QStringList f= db.families();
215 comboFont->insertStringList( db.families() ); 215 comboFont->insertStringList( db.families() );
216 connect( comboFont, SIGNAL( activated( const QString & ) ), 216 connect( comboFont, SIGNAL( activated( const QString & ) ),
217 this, SLOT( textFamily( const QString & ) ) ); 217 this, SLOT( textFamily( const QString & ) ) );
218 comboFont->setCurrentItem( comboFont->listBox()->index( comboFont->listBox()->findItem( QApplication::font().family() ) ) ); 218 comboFont->setCurrentItem( comboFont->listBox()->index( comboFont->listBox()->findItem( QApplication::font().family() ) ) );
219 comboFont->setMaximumWidth(90); 219 comboFont->setMaximumWidth(90);
220 220
221 comboSize = new QComboBox( TRUE, tbFont ); 221 comboSize = new QComboBox( TRUE, tbFont );
@@ -236,65 +236,65 @@ void MainWindow::setupActions()
236 QString::null, CTRL + Key_B, 236 QString::null, CTRL + Key_B,
237 this, "textBold" ); 237 this, "textBold" );
238 connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) ); 238 connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) );
239 actionTextBold->addTo( tbStyle ); 239 actionTextBold->addTo( tbStyle );
240 actionTextBold->setToggleAction( TRUE ); 240 actionTextBold->setToggleAction( TRUE );
241 actionTextItalic = new QAction( tr( "Italic" ), 241 actionTextItalic = new QAction( tr( "Italic" ),
242 Resource::loadPixmap("italic"), 242 Resource::loadPixmap("italic"),
243 tr( "&Italic" ), CTRL + Key_I, 243 tr( "&Italic" ), CTRL + Key_I,
244 this, "textItalic" ); 244 this, "textItalic" );
245 connect( actionTextItalic, SIGNAL( activated() ), this, 245 connect( actionTextItalic, SIGNAL( activated() ), this,
246 SLOT( textItalic() ) ); 246 SLOT( textItalic() ) );
247 actionTextItalic->addTo( tbStyle ); 247 actionTextItalic->addTo( tbStyle );
248 actionTextItalic->setToggleAction( TRUE ); 248 actionTextItalic->setToggleAction( TRUE );
249 actionTextUnderline = new QAction( tr( "Underline" ), 249 actionTextUnderline = new QAction( tr( "Underline" ),
250 Resource::loadPixmap("underline"), 250 Resource::loadPixmap("underline"),
251 tr( "&Underline" ), CTRL + Key_U, 251 tr( "&Underline" ), CTRL + Key_U,
252 this, "textUnderline" ); 252 this, "textUnderline" );
253 connect( actionTextUnderline, SIGNAL( activated() ), 253 connect( actionTextUnderline, SIGNAL( activated() ),
254 this, SLOT( textUnderline() ) ); 254 this, SLOT( textUnderline() ) );
255 actionTextUnderline->addTo( tbStyle ); 255 actionTextUnderline->addTo( tbStyle );
256 actionTextUnderline->setToggleAction( TRUE ); 256 actionTextUnderline->setToggleAction( TRUE );
257 257
258 alignMenu = new ButtonMenu( tbStyle ); 258 alignMenu = new ButtonMenu( tbStyle );
259 alignMenu->insertItem( Resource::loadPixmap("left"), tr("Left"), AlignLeft ); 259 alignMenu->insertItem( Resource::loadPixmap("left"), tr("Left"), AlignLeft );
260 alignMenu->insertItem( Resource::loadPixmap("center"), tr("Center"), AlignCenter ); 260 alignMenu->insertItem( Resource::loadPixmap("center"), tr("Center"), AlignCenter );
261 alignMenu->insertItem( Resource::loadPixmap("right"), tr("Right"), AlignRight ); 261 alignMenu->insertItem( Resource::loadPixmap("right"), tr("Right"), AlignRight );
262 alignMenu->insertItem( Resource::loadPixmap("opie-write/justify"), tr("Full"), Qt3::AlignJustify ); 262 alignMenu->insertItem( Resource::loadPixmap("opie-write/justify"), tr("Full"), Qt3::AlignJustify );
263 connect( alignMenu, SIGNAL(activated(int)), this, SLOT(textAlign(int)) ); 263 connect( alignMenu, SIGNAL(activated(int)), this, SLOT(textAlign(int)) );
264} 264}
265 265
266Qt3::QTextEdit *MainWindow::currentEditor() const 266Qt3::QTextEdit *MainWindow::currentEditor() const
267{ 267{
268 return editor; 268 return editor;
269} 269}
270 270
271void MainWindow::doConnections( Qt3::QTextEdit *e ) 271void MainWindow::doConnections( Qt3::QTextEdit *e )
272{ 272{
273 connect( e, SIGNAL( currentFontChanged( const QFont & ) ), 273 connect( e, SIGNAL( currentFontChanged( const QFont & ) ),
274 this, SLOT( fontChanged( const QFont & ) ) ); 274 this, SLOT( fontChanged( const QFont & ) ) );
275 connect( e, SIGNAL( currentColorChanged( const QColor & ) ), 275 connect( e, SIGNAL( currentColorChanged( const QColor & ) ),
276 this, SLOT( colorChanged( const QColor & ) ) ); 276 this, SLOT( colorChanged( const QColor & ) ) );
277 connect( e, SIGNAL( currentAlignmentChanged( int ) ), 277 connect( e, SIGNAL( currentAlignmentChanged( int ) ),
278 this, SLOT( alignmentChanged( int ) ) ); 278 this, SLOT( alignmentChanged( int ) ) );
279} 279}
280 280
281void MainWindow::updateFontSizeCombo( const QFont &f ) 281void MainWindow::updateFontSizeCombo( const QFont &f )
282{ 282{
283 comboSize->clear(); 283 comboSize->clear();
284 FontDatabase fdb; 284 FontDatabase fdb;
285 QValueList<int> sizes = fdb.pointSizes( f.family() ); 285 QValueList<int> sizes = fdb.pointSizes( f.family() );
286 QValueList<int>::Iterator it = sizes.begin(); 286 QValueList<int>::Iterator it = sizes.begin();
287 for ( ; it != sizes.end(); ++it ) 287 for ( ; it != sizes.end(); ++it )
288 comboSize->insertItem( QString::number( *it ) ); 288 comboSize->insertItem( QString::number( *it ) );
289} 289}
290 290
291void MainWindow::editUndo() 291void MainWindow::editUndo()
292{ 292{
293 if ( !currentEditor() ) 293 if ( !currentEditor() )
294 return; 294 return;
295 currentEditor()->undo(); 295 currentEditor()->undo();
296} 296}
297 297
298void MainWindow::editRedo() 298void MainWindow::editRedo()
299{ 299{
300 if ( !currentEditor() ) 300 if ( !currentEditor() )
@@ -478,65 +478,65 @@ void MainWindow::openFile( const DocLnk &dl )
478 qDebug( "couldn't open file" ); 478 qDebug( "couldn't open file" );
479 clear(); 479 clear();
480 editorStack->raiseWidget( editor ); 480 editorStack->raiseWidget( editor );
481 editor->viewport()->setFocus(); 481 editor->viewport()->setFocus();
482 doc = new DocLnk( dl ); 482 doc = new DocLnk( dl );
483 editor->setText( txt ); 483 editor->setText( txt );
484 editor->setModified( FALSE ); 484 editor->setModified( FALSE );
485 updateCaption(); 485 updateCaption();
486} 486}
487 487
488void MainWindow::showEditTools( void ) 488void MainWindow::showEditTools( void )
489{ 489{
490 tbMenu->show(); 490 tbMenu->show();
491 tbEdit->show(); 491 tbEdit->show();
492 tbFont->show(); 492 tbFont->show();
493 tbStyle->show(); 493 tbStyle->show();
494} 494}
495 495
496void MainWindow::hideEditTools( void ) 496void MainWindow::hideEditTools( void )
497{ 497{
498 // let's reset the buttons... 498 // let's reset the buttons...
499 actionTextBold->setOn( FALSE ); 499 actionTextBold->setOn( FALSE );
500 actionTextItalic->setOn( FALSE ); 500 actionTextItalic->setOn( FALSE );
501 actionTextUnderline->setOn( FALSE ); 501 actionTextUnderline->setOn( FALSE );
502 //comboFont->setCurrentText( QApplication::font().family() ); 502 //comboFont->setCurrentText( QApplication::font().family() );
503 comboSize->lineEdit()->setText( QString::number(QApplication::font().pointSize() ) ); 503 comboSize->lineEdit()->setText( QString::number(QApplication::font().pointSize() ) );
504 tbMenu->hide(); 504 tbMenu->hide();
505 tbEdit->hide(); 505 tbEdit->hide();
506 tbFont->hide(); 506 tbFont->hide();
507 tbStyle->hide(); 507 tbStyle->hide();
508} 508}
509 509
510 510
511void MainWindow::save() 511void MainWindow::save()
512{ 512{
513 if ( !doc ) 513 if ( !doc )
514 return; 514 return;
515 if ( !editor->isModified() ) 515 if ( !editor->isModified() )
516 return; 516 return;
517 517
518 QString rt = editor->text(); 518 QString rt = editor->text();
519 519
520 // quick hack to get around formatting... 520 // quick hack to get around formatting...
521 editor->setTextFormat( Qt::PlainText ); 521 editor->setTextFormat( Qt::PlainText );
522 QString pt = editor->text(); 522 QString pt = editor->text();
523 editor->setTextFormat( Qt::RichText ); 523 editor->setTextFormat( Qt::RichText );
524 524
525 if ( doc->name().isEmpty() ) { 525 if ( doc->name().isEmpty() ) {
526 unsigned ispace = pt.find( ' ' ); 526 unsigned ispace = pt.find( ' ' );
527 unsigned ienter = pt.find( '\n' ); 527 unsigned ienter = pt.find( '\n' );
528 int i = (ispace < ienter) ? ispace : ienter; 528 int i = (ispace < ienter) ? ispace : ienter;
529 QString docname; 529 QString docname;
530 if ( i == -1 ) { 530 if ( i == -1 ) {
531 if ( pt.isEmpty() ) 531 if ( pt.isEmpty() )
532 docname = "Empty Text"; 532 docname = "Empty Text";
533 else 533 else
534 docname = pt; 534 docname = pt;
535 } else { 535 } else {
536 docname = pt.left( i ); 536 docname = pt.left( i );
537 } 537 }
538 doc->setName(docname); 538 doc->setName(docname);
539 } 539 }
540 FileManager fm; 540 FileManager fm;
541 fm.saveFile( *doc, rt ); 541 fm.saveFile( *doc, rt );
542} 542}