1.1 --- a/texteditor.cpp Tue Jun 13 13:54:53 2006 +0000
1.2 +++ b/texteditor.cpp Wed Jun 14 10:28:01 2006 +0000
1.3 @@ -1,10 +1,6 @@
1.4 #include "texteditor.h"
1.5
1.6 #include <q3canvas.h>
1.7 -#include <qstatusbar.h>
1.8 -#include <qmessagebox.h>
1.9 -#include <qaction.h>
1.10 -#include <qapplication.h>
1.11 #include <qpainter.h>
1.12 #include <qprinter.h>
1.13 #include <qfile.h>
1.14 @@ -13,7 +9,6 @@
1.15 #include <q3popupmenu.h>
1.16 #include <qmenubar.h>
1.17 #include <q3textedit.h>
1.18 -#include <q3accel.h>
1.19 #include <qtextstream.h>
1.20 #include <q3paintdevicemetrics.h>
1.21 #include <qsettings.h>
1.22 @@ -21,12 +16,10 @@
1.23 #include <qmessagebox.h>
1.24 #include <qcolordialog.h>
1.25 #include <qregexp.h>
1.26 -#include <qlineedit.h>
1.27 #include <q3simplerichtext.h>
1.28 //Added by qt3to4:
1.29 #include <Q3ValueList>
1.30 #include <QPixmap>
1.31 -#include <QActionGroup>
1.32 #include <QCloseEvent>
1.33
1.34 #include <iostream>
1.35 @@ -226,137 +219,130 @@
1.36
1.37 void TextEditor::setupFileActions()
1.38 {
1.39 - Q3ToolBar *tb = new Q3ToolBar( this );
1.40 - tb->setLabel( "File Actions" );
1.41 - Q3PopupMenu *menu = new Q3PopupMenu( this );
1.42 - menuBar()->insertItem( tr( "&File" ), menu );
1.43 + QToolBar *tb = addToolBar ( tr("File Actions") );
1.44 + QMenu *fileMenu = menuBar()->addMenu( tr( "&File" ));
1.45
1.46 QAction *a;
1.47 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Import..." ),this);
1.48 a->setStatusTip (tr( "Import" ) );
1.49 a->setShortcut( Qt::CTRL + Qt::Key_O );
1.50 connect( a, SIGNAL( activated() ), this, SLOT( textLoad() ) );
1.51 - a->setEnabled(false);
1.52 - a->addTo( tb );
1.53 - a->addTo( menu );
1.54 + tb->addAction (a);
1.55 + fileMenu->addAction (a);
1.56 actionFileLoad=a;
1.57
1.58 - menu->insertSeparator();
1.59 + fileMenu->addSeparator();
1.60 a = new QAction( QPixmap(iconPath+"filesave.png" ), tr( "&Export..." ),this);
1.61 a->setStatusTip (tr( "Export Note (HTML)" ) );
1.62 a->setShortcut( Qt::CTRL + Qt::Key_S );
1.63 connect( a, SIGNAL( activated() ), this, SLOT( textSave() ) );
1.64 - a->addTo( tb );
1.65 - a->addTo( menu );
1.66 + tb->addAction (a);
1.67 + fileMenu->addAction (a);
1.68 actionFileSave=a;
1.69
1.70 a = new QAction( QPixmap(), tr( "Export &As... (HTML)" ), this);
1.71 a->setStatusTip (tr( "Export Note As (HTML) " ));
1.72 connect( a, SIGNAL( activated() ), this, SLOT( textSaveAs() ) );
1.73 - a->addTo( menu );
1.74 + fileMenu->addAction (a);
1.75 actionFileSaveAs=a;
1.76
1.77 a = new QAction(QPixmap(), tr( "Export &As...(ASCII)" ), this);
1.78 a->setStatusTip ( tr( "Export Note As (ASCII) " ) );
1.79 a->setShortcut(Qt::ALT + Qt::Key_X );
1.80 connect( a, SIGNAL( activated() ), this, SLOT( textExportAsASCII() ) );
1.81 - a->addTo( menu );
1.82 + fileMenu->addAction (a);
1.83 actionFileSaveAs=a;
1.84
1.85 - menu->insertSeparator();
1.86 + fileMenu->addSeparator();
1.87 a = new QAction( QPixmap(iconPath+"fileprint.png" ), tr( "&Print..." ),this);
1.88 a->setStatusTip (tr( "Print Note" ) );
1.89 a->setShortcut( Qt::CTRL + Qt::Key_P );
1.90 connect( a, SIGNAL( activated() ), this, SLOT( textPrint() ) );
1.91 - a->addTo( tb );
1.92 - a->addTo( menu );
1.93 + tb->addAction (a);
1.94 + fileMenu->addAction (a);
1.95 actionFilePrint=a;
1.96 }
1.97
1.98 void TextEditor::setupEditActions()
1.99 {
1.100 - Q3ToolBar *tb = new Q3ToolBar( this );
1.101 - tb->setLabel( "Edit Actions" );
1.102 - Q3PopupMenu *menu = new Q3PopupMenu( this );
1.103 - menuBar()->insertItem( tr( "&Edit" ), menu );
1.104 + QToolBar *tb = addToolBar ( tr( "Edit Actions" ));
1.105 + QMenu *editMenu = menuBar()->addMenu ( tr( "&Edit" ));
1.106
1.107 QAction *a;
1.108 a = new QAction(QPixmap(iconPath+"undo.png"), tr( "&Undo" ), this );
1.109 a->setStatusTip ( tr( "Undo" ) );
1.110 a->setShortcut(Qt::CTRL + Qt::Key_Z );
1.111 connect( a, SIGNAL( activated() ), e, SLOT( undo() ) );
1.112 - a->addTo( menu );
1.113 - a->addTo( tb);
1.114 + editMenu->addAction (a);
1.115 + tb->addAction (a);
1.116 actionEditUndo=a;
1.117
1.118 a = new QAction(QPixmap(iconPath+"redo.png" ), tr( "&Redo" ),this);
1.119 a->setStatusTip ( tr( "Redo" ) );
1.120 a->setShortcut( Qt::CTRL + Qt::Key_Y );
1.121 connect( a, SIGNAL( activated() ), e, SLOT( redo() ) );
1.122 - a->addTo( tb );
1.123 - a->addTo( menu );
1.124 + editMenu->addAction (a);
1.125 + tb->addAction (a);
1.126 actionEditRedo=a;
1.127
1.128 - menu->insertSeparator();
1.129 + editMenu->addSeparator();
1.130 a = new QAction(QPixmap(), tr( "Select and copy &all" ),this);
1.131 a->setStatusTip ( tr( "Select and copy all" ) );
1.132 a->setShortcut( Qt::CTRL + Qt::Key_A );
1.133 connect( a, SIGNAL( activated() ), this, SLOT( editCopyAll() ) );
1.134 - a->addTo( menu );
1.135 + editMenu->addAction (a);
1.136
1.137 - menu->insertSeparator();
1.138 + editMenu->addSeparator();
1.139 a = new QAction(QPixmap(iconPath+"editcopy.png" ), tr( "&Copy" ),this);
1.140 a->setStatusTip ( tr( "Copy" ) );
1.141 a->setShortcut( Qt::CTRL + Qt::Key_C );
1.142 connect( a, SIGNAL( activated() ), e, SLOT( copy() ) );
1.143 - a->addTo( tb );
1.144 - a->addTo( menu );
1.145 + editMenu->addAction (a);
1.146 + tb->addAction (a);
1.147 actionEditCopy=a;
1.148
1.149 a = new QAction(QPixmap(iconPath+"editcut.png" ), tr( "Cu&t" ),this);
1.150 a->setStatusTip ( tr( "Cut" ) );
1.151 a->setShortcut( Qt::CTRL + Qt::Key_X );
1.152 connect( a, SIGNAL( activated() ), e, SLOT( cut() ) );
1.153 - a->addTo( tb );
1.154 - a->addTo( menu );
1.155 + editMenu->addAction (a);
1.156 + tb->addAction (a);
1.157 actionEditCut=a;
1.158
1.159 a = new QAction(QPixmap(iconPath+"editpaste.png" ), tr( "&Paste" ),this);
1.160 a->setStatusTip ( tr( "Paste" ) );
1.161 a->setShortcut( Qt::CTRL + Qt::Key_V );
1.162 connect( a, SIGNAL( activated() ), e, SLOT( paste() ) );
1.163 - a->addTo( tb );
1.164 - a->addTo( menu );
1.165 + editMenu->addAction (a);
1.166 + tb->addAction (a);
1.167 actionEditPaste=a;
1.168
1.169 a = new QAction( QPixmap( iconPath+"edittrash.png"), tr( "&Delete All" ), this);
1.170 a->setStatusTip (tr( "Delete all" ) );
1.171 connect( a, SIGNAL( activated() ), e, SLOT( clear() ) );
1.172 - a->addTo( tb );
1.173 - a->addTo( menu );
1.174 + editMenu->addAction (a);
1.175 + tb->addAction (a);
1.176 actionEditDeleteAll=a;
1.177
1.178 a = new QAction(QPixmap(), tr( "&Convert Paragraphs" ),this);
1.179 a->setStatusTip(tr( "Convert paragraphs to linebreaks" ));
1.180 a->setShortcut( Qt::ALT + Qt::Key_P );
1.181 connect( a, SIGNAL( activated() ), this, SLOT( textConvertPar() ) );
1.182 - a->addTo( menu );
1.183 + editMenu->addAction (a);
1.184 actionEditConvertPar=a;
1.185
1.186 a = new QAction( QPixmap(), tr( "&Join lines" ), this);
1.187 a->setStatusTip(tr( "Join all lines of a paragraph" ) );
1.188 a->setShortcut(Qt::ALT + Qt::Key_J );
1.189 connect( a, SIGNAL( activated() ), this, SLOT( textJoinLines() ) );
1.190 - a->addTo( menu );
1.191 + editMenu->addAction (a);
1.192 actionEditJoinLines=a;
1.193 }
1.194
1.195 void TextEditor::setupFormatActions()
1.196 {
1.197 - Q3ToolBar *tb = new Q3ToolBar( this );
1.198 - tb->setLabel( "Format Actions" );
1.199 - Q3PopupMenu *menu = new Q3PopupMenu( this );
1.200 - menuBar()->insertItem( tr( "F&ormat" ), menu );
1.201 + QToolBar *tb = addToolBar ( tr("Format Actions" ));
1.202 + QMenu *formatMenu = menuBar()->addMenu ( tr( "F&ormat" ));
1.203
1.204 QAction *a;
1.205
1.206 @@ -365,93 +351,112 @@
1.207 a->setToggleAction (true);
1.208 a->setOn (settings.readBoolEntry ("/vym/noteeditor/fonts/useFixedByDefault",false) );
1.209 connect( a, SIGNAL( activated() ), this, SLOT( toggleFonthint() ) );
1.210 - a->addTo( menu );
1.211 - a->addTo( tb );
1.212 + formatMenu->addAction (a);
1.213 + tb->addAction (a);
1.214 actionFormatUseFixedFont=a;
1.215
1.216 - menu->insertSeparator();
1.217 -
1.218 - comboFont = new QComboBox( true, tb );
1.219 +// comboFont = new QComboBox( true, tb );
1.220 + comboFont = new QComboBox;
1.221 + tb->addWidget (comboFont);
1.222 QFontDatabase db;
1.223 comboFont->insertStringList( db.families() );
1.224 connect( comboFont, SIGNAL( activated( const QString & ) ),
1.225 this, SLOT( textFamily( const QString & ) ) );
1.226 - comboFont->lineEdit()->setText( QApplication::font().family() );
1.227 -
1.228 - comboSize = new QComboBox( true, tb );
1.229 + comboFont->addItem( QApplication::font().family() );
1.230 +// comboSize = new QComboBox( true, tb );
1.231 + comboSize = new QComboBox;
1.232 + tb->addWidget (comboSize);
1.233 Q3ValueList<int> sizes = db.standardSizes();
1.234 Q3ValueList<int>::Iterator it = sizes.begin();
1.235 for ( ; it != sizes.end(); ++it )
1.236 comboSize->insertItem( QString::number( *it ) );
1.237 connect( comboSize, SIGNAL( activated( const QString & ) ),
1.238 this, SLOT( textSize( const QString & ) ) );
1.239 - comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) );
1.240 + comboSize->addItem ( QString::number( QApplication::font().pointSize() ) );
1.241
1.242 - menu->insertSeparator();
1.243 + formatMenu->addSeparator();
1.244
1.245 QPixmap pix( 16, 16 );
1.246 pix.fill( e->color());
1.247 - actionTextColor = new QAction( pix, tr( "&Color..." ), this);
1.248 - actionTextColor->addTo( tb );
1.249 - actionTextColor->addTo( menu );
1.250 - connect( actionTextColor, SIGNAL( activated() ), this, SLOT( textColor() ) );
1.251 + a = new QAction( pix, tr( "&Color..." ), this);
1.252 + formatMenu->addAction (a);
1.253 + tb->addAction (a);
1.254 + connect( a, SIGNAL( activated() ), this, SLOT( textColor() ) );
1.255 + actionTextColor=a;
1.256
1.257 - actionTextBold = new QAction( QPixmap (iconPath+"text_bold.png"), tr( "&Bold" ), this);
1.258 - actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B );
1.259 - connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) );
1.260 - actionTextBold->addTo( tb );
1.261 - actionTextBold->addTo( menu );
1.262 - actionTextBold->setToggleAction( true );
1.263 - actionTextItalic = new QAction( QPixmap(iconPath+"text_italic.png"), tr( "&Italic" ), this);
1.264 - actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I);
1.265 - connect( actionTextItalic, SIGNAL( activated() ), this, SLOT( textItalic() ) );
1.266 - actionTextItalic->addTo( tb );
1.267 - actionTextItalic->addTo( menu );
1.268 - actionTextItalic->setToggleAction( true );
1.269 - actionTextUnderline = new QAction( QPixmap (iconPath+"text_under.png"), tr( "&Underline" ), this);
1.270 - actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U );
1.271 - connect( actionTextUnderline, SIGNAL( activated() ), this, SLOT( textUnderline() ) );
1.272 - actionTextUnderline->addTo( tb );
1.273 - actionTextUnderline->addTo( menu );
1.274 - actionTextUnderline->setToggleAction( true );
1.275 - menu->insertSeparator();
1.276 + a = new QAction( QPixmap (iconPath+"text_bold.png"), tr( "&Bold" ), this);
1.277 + a->setShortcut(Qt::CTRL + Qt::Key_B );
1.278 + connect( a, SIGNAL( activated() ), this, SLOT( textBold() ) );
1.279 + tb->addAction (a);
1.280 + formatMenu->addAction (a);
1.281 + a->setToggleAction( true );
1.282 + actionTextBold=a;
1.283 +
1.284 + a = new QAction( QPixmap(iconPath+"text_italic.png"), tr( "&Italic" ), this);
1.285 + a->setShortcut(Qt::CTRL + Qt::Key_I);
1.286 + connect( a, SIGNAL( activated() ), this, SLOT( textItalic() ) );
1.287 + tb->addAction (a);
1.288 + formatMenu->addAction (a);
1.289 + a->setToggleAction( true );
1.290 + actionTextItalic=a;
1.291 +
1.292 + a = new QAction( QPixmap (iconPath+"text_under.png"), tr( "&Underline" ), this);
1.293 + a->setShortcut(Qt::CTRL + Qt::Key_U );
1.294 + connect( a, SIGNAL( activated() ), this, SLOT( textUnderline() ) );
1.295 + tb->addAction (a);
1.296 + formatMenu->addAction (a);
1.297 + a->setToggleAction( true );
1.298 + actionTextUnderline=a;
1.299 + formatMenu->addSeparator();
1.300
1.301 QActionGroup *grp = new QActionGroup( this );
1.302 connect( grp, SIGNAL( selected( QAction* ) ), this, SLOT( textAlign( QAction* ) ) );
1.303
1.304 - actionAlignLeft = new QAction( QPixmap (iconPath+"text_left.png"), tr( "&Left" ),grp );
1.305 - actionAlignLeft->setShortcut( Qt::CTRL+Qt::Key_L );
1.306 - actionAlignLeft->setToggleAction( true );
1.307 - actionAlignCenter = new QAction( QPixmap (iconPath+"text_center.png"), tr( "C&enter" ),grp);
1.308 - actionAlignCenter->setShortcut( Qt::CTRL + Qt::Key_E);
1.309 - actionAlignCenter->setToggleAction( true );
1.310 - actionAlignRight = new QAction( QPixmap (iconPath+"text_right.png" ), tr( "&Right" ), grp);
1.311 - actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R );
1.312 - actionAlignRight->setToggleAction( true );
1.313 - actionAlignJustify = new QAction( QPixmap ( iconPath+"text_block.png"), tr( "&Justify" ), grp );
1.314 - actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J );
1.315 - actionAlignJustify->setToggleAction( true );
1.316 -
1.317 - grp->addTo( tb );
1.318 - grp->addTo( menu );
1.319 + a = new QAction( QPixmap (iconPath+"text_left.png"), tr( "&Left" ),grp );
1.320 + a->setShortcut( Qt::CTRL+Qt::Key_L );
1.321 + a->setToggleAction( true );
1.322 + tb->addAction (a);
1.323 + formatMenu->addAction (a);
1.324 + actionAlignLeft=a;
1.325 + a = new QAction( QPixmap (iconPath+"text_center.png"), tr( "C&enter" ),grp);
1.326 + a->setShortcut( Qt::CTRL + Qt::Key_E);
1.327 + a->setToggleAction( true );
1.328 + tb->addAction (a);
1.329 + formatMenu->addAction (a);
1.330 + actionAlignCenter=a;
1.331 + a = new QAction( QPixmap (iconPath+"text_right.png" ), tr( "&Right" ), grp);
1.332 + a->setShortcut(Qt::CTRL + Qt::Key_R );
1.333 + a->setToggleAction( true );
1.334 + tb->addAction (a);
1.335 + formatMenu->addAction (a);
1.336 + actionAlignRight=a;
1.337 + a = new QAction( QPixmap ( iconPath+"text_block.png"), tr( "&Justify" ), grp );
1.338 + a->setShortcut(Qt::CTRL + Qt::Key_J );
1.339 + a->setToggleAction( true );
1.340 + tb->addAction (a);
1.341 + formatMenu->addAction (a);
1.342 + actionAlignJustify=a;
1.343
1.344 QActionGroup *grp2 = new QActionGroup( this );
1.345 - grp2->setExclusive(false);
1.346 - actionAlignSubScript = new QAction( QPixmap (iconPath+"text_sub.png"), tr( "Subs&cript" ),grp2 );
1.347 - actionAlignSubScript->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_B );
1.348 - actionAlignSubScript->setToggleAction( true );
1.349 - connect(actionAlignSubScript, SIGNAL(activated()), this, SLOT(textVAlign()));
1.350 + grp2->setExclusive(true);
1.351 + a = new QAction( QPixmap (iconPath+"text_sub.png"), tr( "Subs&cript" ),grp2 );
1.352 + a->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_B );
1.353 + a->setToggleAction( true );
1.354 + tb->addAction (a);
1.355 + formatMenu->addAction (a);
1.356 + connect(a, SIGNAL(activated()), this, SLOT(textVAlign()));
1.357 + actionAlignSubScript=a;
1.358
1.359 - actionAlignSuperScript = new QAction( QPixmap (iconPath+"text_super.png"), tr( "Su&perscript" ),grp2 );
1.360 - actionAlignSuperScript->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_P );
1.361 - actionAlignSuperScript->setToggleAction( true );
1.362 - connect(actionAlignSuperScript, SIGNAL(activated()), this, SLOT(textVAlign()));
1.363 + a = new QAction( QPixmap (iconPath+"text_super.png"), tr( "Su&perscript" ),grp2 );
1.364 + a->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_P );
1.365 + a->setToggleAction( true );
1.366 + tb->addAction (a);
1.367 + formatMenu->addAction (a);
1.368 + connect(a, SIGNAL(activated()), this, SLOT(textVAlign()));
1.369 + actionAlignSuperScript=a;
1.370
1.371 - menu->insertSeparator();
1.372 + formatMenu->addSeparator();
1.373
1.374 - grp2->addTo(tb);
1.375 - grp2->addTo(menu);
1.376 -
1.377 connect( e, SIGNAL( currentFontChanged( const QFont & ) ),
1.378 this, SLOT( fontChanged( const QFont & ) ) );
1.379 connect( e, SIGNAL( currentColorChanged( const QColor & ) ),
1.380 @@ -465,27 +470,26 @@
1.381
1.382 void TextEditor::setupSettingsActions()
1.383 {
1.384 - Q3PopupMenu *menu = new Q3PopupMenu( this );
1.385 - menuBar()->insertItem( tr( "&Settings" ), menu );
1.386 + QMenu *settingsMenu = menuBar()->addMenu ( tr( "&Settings" ));
1.387
1.388 QAction *a;
1.389 a = new QAction(tr( "Set &fixed font" ), this);
1.390 a->setStatusTip ( tr( "Set fixed font" ));
1.391 connect( a, SIGNAL( activated() ), this, SLOT( setFixedFont() ) );
1.392 - a->addTo( menu );
1.393 + settingsMenu->addAction (a);
1.394 actionSettingsFixedFont=a;
1.395
1.396 a = new QAction(tr( "Set &variable font" ), this);
1.397 a->setStatusTip ( tr( "Set variable font" ) );
1.398 connect( a, SIGNAL( activated() ), this, SLOT( setVarFont() ) );
1.399 - a->addTo( menu );
1.400 + settingsMenu->addAction (a);
1.401 actionSettingsVarFont=a;
1.402
1.403 a = new QAction(tr( "&fixed font is default" ), this);
1.404 a->setStatusTip (tr( "Used fixed font by default" ) );
1.405 a->setToggleAction (true);
1.406 // set state later in constructor...
1.407 - a->addTo( menu );
1.408 + settingsMenu->addAction (a);
1.409 actionSettingsFonthintDefault=a;
1.410 }
1.411
1.412 @@ -909,8 +913,10 @@
1.413
1.414 void TextEditor::fontChanged( const QFont &f )
1.415 {
1.416 +/*
1.417 comboFont->lineEdit()->setText( f.family() );
1.418 comboSize->lineEdit()->setText( QString::number( f.pointSize() ) );
1.419 +*/
1.420 actionTextBold->setOn( f.bold() );
1.421 actionTextItalic->setOn( f.italic() );
1.422 actionTextUnderline->setOn( f.underline() );