-rw-r--r-- | noncore/apps/opie-write/mainwindow.cpp | 24 | ||||
-rw-r--r-- | noncore/apps/opie-write/qtextedit.cpp | 4 |
2 files changed, 14 insertions, 14 deletions
diff --git a/noncore/apps/opie-write/mainwindow.cpp b/noncore/apps/opie-write/mainwindow.cpp index 6bb524f..90e1a70 100644 --- a/noncore/apps/opie-write/mainwindow.cpp +++ b/noncore/apps/opie-write/mainwindow.cpp | |||
@@ -102,50 +102,50 @@ private: | |||
102 | 102 | ||
103 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags fl ) | 103 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags fl ) |
104 | : QMainWindow( parent, name, fl ), | 104 | : QMainWindow( parent, name, fl ), |
105 | doc( 0 ) | 105 | doc( 0 ) |
106 | { | 106 | { |
107 | setRightJustification(TRUE); | 107 | setRightJustification(TRUE); |
108 | 108 | ||
109 | editorStack = new QWidgetStack( this ); | 109 | editorStack = new QWidgetStack( this ); |
110 | 110 | ||
111 | fileSelector = new FileSelector( "text/html", | 111 | fileSelector = new FileSelector( "text/html", |
112 | editorStack, "fileselector" ); | 112 | editorStack, "fileselector" ); |
113 | 113 | ||
114 | 114 | ||
115 | fileSelector->setCloseVisible( FALSE ); | 115 | fileSelector->setCloseVisible( FALSE ); |
116 | editorStack->addWidget( fileSelector, 0 ); | 116 | editorStack->addWidget( fileSelector, 0 ); |
117 | 117 | ||
118 | editor = new Qt3::QTextEdit( editorStack ); | 118 | editor = new Qt3::QTextEdit( editorStack ); |
119 | editor->setTextFormat( Qt::RichText ); | 119 | editor->setTextFormat( Qt::RichText ); |
120 | editorStack->addWidget( editor, 1 ); | 120 | editorStack->addWidget( editor, 1 ); |
121 | 121 | ||
122 | setupActions(); | 122 | setupActions(); |
123 | 123 | ||
124 | QObject::connect( fileSelector, SIGNAL(closeMe()), | 124 | QObject::connect( fileSelector, SIGNAL(closeMe()), |
125 | this, SLOT(showEditTools()) ); | 125 | this, SLOT(showEditTools()) ); |
126 | QObject::connect( fileSelector, SIGNAL(fileSelected(const DocLnk &)), | 126 | QObject::connect( fileSelector, SIGNAL(fileSelected(const DocLnk&)), |
127 | this, SLOT(openFile(const DocLnk &)) ); | 127 | this, SLOT(openFile(const DocLnk&)) ); |
128 | QObject::connect( fileSelector, SIGNAL(newSelected(const DocLnk&)), | 128 | QObject::connect( fileSelector, SIGNAL(newSelected(const DocLnk&)), |
129 | this, SLOT(newFile(const DocLnk&)) ); | 129 | this, SLOT(newFile(const DocLnk&)) ); |
130 | 130 | ||
131 | if ( fileSelector->fileCount() < 1 ) | 131 | if ( fileSelector->fileCount() < 1 ) |
132 | fileNew(); | 132 | fileNew(); |
133 | else { | 133 | else { |
134 | fileOpen(); | 134 | fileOpen(); |
135 | } | 135 | } |
136 | doConnections( editor ); | 136 | doConnections( editor ); |
137 | 137 | ||
138 | setCentralWidget( editorStack ); | 138 | setCentralWidget( editorStack ); |
139 | } | 139 | } |
140 | 140 | ||
141 | MainWindow::~MainWindow() | 141 | MainWindow::~MainWindow() |
142 | { | 142 | { |
143 | save(); | 143 | save(); |
144 | } | 144 | } |
145 | 145 | ||
146 | void MainWindow::setupActions() | 146 | void 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 ); |
@@ -192,111 +192,111 @@ void MainWindow::setupActions() | |||
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 ); |
222 | QValueList<int> sizes = db.standardSizes(); | 222 | QValueList<int> sizes = db.standardSizes(); |
223 | QValueList<int>::Iterator it = sizes.begin(); | 223 | QValueList<int>::Iterator it = sizes.begin(); |
224 | for ( ; it != sizes.end(); ++it ) | 224 | for ( ; it != sizes.end(); ++it ) |
225 | comboSize->insertItem( QString::number( *it ) ); | 225 | comboSize->insertItem( QString::number( *it ) ); |
226 | connect( comboSize, SIGNAL( activated( const QString & ) ), | 226 | connect( comboSize, SIGNAL( activated(const QString&) ), |
227 | this, SLOT( textSize( const QString & ) ) ); | 227 | this, SLOT( textSize(const QString&) ) ); |
228 | comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) ); | 228 | comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) ); |
229 | comboSize->setFixedWidth( 38 ); | 229 | comboSize->setFixedWidth( 38 ); |
230 | 230 | ||
231 | tbStyle = new QToolBar( this ); | 231 | tbStyle = new QToolBar( this ); |
232 | tbStyle->setLabel( "Style Actions" ); | 232 | tbStyle->setLabel( "Style Actions" ); |
233 | 233 | ||
234 | actionTextBold = new QAction( tr( "Bold" ), | 234 | actionTextBold = new QAction( tr( "Bold" ), |
235 | Resource::loadPixmap("bold"), | 235 | Resource::loadPixmap("bold"), |
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 | ||
266 | Qt3::QTextEdit *MainWindow::currentEditor() const | 266 | Qt3::QTextEdit *MainWindow::currentEditor() const |
267 | { | 267 | { |
268 | return editor; | 268 | return editor; |
269 | } | 269 | } |
270 | 270 | ||
271 | void MainWindow::doConnections( Qt3::QTextEdit *e ) | 271 | void 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 | ||
281 | void MainWindow::updateFontSizeCombo( const QFont &f ) | 281 | void 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 | ||
291 | void MainWindow::editUndo() | 291 | void MainWindow::editUndo() |
292 | { | 292 | { |
293 | if ( !currentEditor() ) | 293 | if ( !currentEditor() ) |
294 | return; | 294 | return; |
295 | currentEditor()->undo(); | 295 | currentEditor()->undo(); |
296 | } | 296 | } |
297 | 297 | ||
298 | void MainWindow::editRedo() | 298 | void MainWindow::editRedo() |
299 | { | 299 | { |
300 | if ( !currentEditor() ) | 300 | if ( !currentEditor() ) |
301 | return; | 301 | return; |
302 | currentEditor()->redo(); | 302 | currentEditor()->redo(); |
diff --git a/noncore/apps/opie-write/qtextedit.cpp b/noncore/apps/opie-write/qtextedit.cpp index 27dd515..73b7b7b 100644 --- a/noncore/apps/opie-write/qtextedit.cpp +++ b/noncore/apps/opie-write/qtextedit.cpp | |||
@@ -656,50 +656,50 @@ QTextEdit::QTextEdit( const QString& text, const QString& context, | |||
656 | doc( new QTextDocument( 0 ) ), undoRedoInfo( doc ) | 656 | doc( new QTextDocument( 0 ) ), undoRedoInfo( doc ) |
657 | { | 657 | { |
658 | init(); | 658 | init(); |
659 | setText( text, context ); | 659 | setText( text, context ); |
660 | } | 660 | } |
661 | 661 | ||
662 | /*! \reimp */ | 662 | /*! \reimp */ |
663 | 663 | ||
664 | QTextEdit::~QTextEdit() | 664 | QTextEdit::~QTextEdit() |
665 | { | 665 | { |
666 | delete undoRedoInfo.d; | 666 | delete undoRedoInfo.d; |
667 | undoRedoInfo.d = 0; | 667 | undoRedoInfo.d = 0; |
668 | delete cursor; | 668 | delete cursor; |
669 | delete doc; | 669 | delete doc; |
670 | delete d; | 670 | delete d; |
671 | } | 671 | } |
672 | 672 | ||
673 | void QTextEdit::init() | 673 | void QTextEdit::init() |
674 | { | 674 | { |
675 | setFrameStyle( Sunken ); | 675 | setFrameStyle( Sunken ); |
676 | undoEnabled = TRUE; | 676 | undoEnabled = TRUE; |
677 | readonly = TRUE; | 677 | readonly = TRUE; |
678 | setReadOnly( FALSE ); | 678 | setReadOnly( FALSE ); |
679 | d = new QTextEditPrivate; | 679 | d = new QTextEditPrivate; |
680 | connect( doc, SIGNAL( minimumWidthChanged( int ) ), | 680 | connect( doc, SIGNAL( minimumWidthChanged(int) ), |
681 | this, SLOT( documentWidthChanged( int ) ) ); | 681 | this, SLOT( documentWidthChanged(int) ) ); |
682 | 682 | ||
683 | mousePressed = FALSE; | 683 | mousePressed = FALSE; |
684 | inDoubleClick = FALSE; | 684 | inDoubleClick = FALSE; |
685 | modified = FALSE; | 685 | modified = FALSE; |
686 | onLink = QString::null; | 686 | onLink = QString::null; |
687 | overWrite = FALSE; | 687 | overWrite = FALSE; |
688 | wrapMode = WidgetWidth; | 688 | wrapMode = WidgetWidth; |
689 | wrapWidth = -1; | 689 | wrapWidth = -1; |
690 | wPolicy = AtWhiteSpace; | 690 | wPolicy = AtWhiteSpace; |
691 | inDnD = FALSE; | 691 | inDnD = FALSE; |
692 | 692 | ||
693 | doc->setFormatter( new QTextFormatterBreakWords ); | 693 | doc->setFormatter( new QTextFormatterBreakWords ); |
694 | doc->formatCollection()->defaultFormat()->setFont( QScrollView::font() ); | 694 | doc->formatCollection()->defaultFormat()->setFont( QScrollView::font() ); |
695 | doc->formatCollection()->defaultFormat()->setColor( colorGroup().color( QColorGroup::Text ) ); | 695 | doc->formatCollection()->defaultFormat()->setColor( colorGroup().color( QColorGroup::Text ) ); |
696 | currentFormat = doc->formatCollection()->defaultFormat(); | 696 | currentFormat = doc->formatCollection()->defaultFormat(); |
697 | currentAlignment = Qt3::AlignAuto; | 697 | currentAlignment = Qt3::AlignAuto; |
698 | 698 | ||
699 | viewport()->setBackgroundMode( PaletteBase ); | 699 | viewport()->setBackgroundMode( PaletteBase ); |
700 | viewport()->setAcceptDrops( TRUE ); | 700 | viewport()->setAcceptDrops( TRUE ); |
701 | resizeContents( 0, doc->lastParagraph() ? | 701 | resizeContents( 0, doc->lastParagraph() ? |
702 | ( doc->lastParagraph()->paragId() + 1 ) * doc->formatCollection()->defaultFormat()->height() : 0 ); | 702 | ( doc->lastParagraph()->paragId() + 1 ) * doc->formatCollection()->defaultFormat()->height() : 0 ); |
703 | 703 | ||
704 | setKeyCompression( TRUE ); | 704 | setKeyCompression( TRUE ); |
705 | viewport()->setMouseTracking( TRUE ); | 705 | viewport()->setMouseTracking( TRUE ); |