diff -r ec3d2962893d -r 5cfbba1dc2f8 texteditor.cpp --- a/texteditor.cpp Tue Jun 13 13:54:53 2006 +0000 +++ b/texteditor.cpp Wed Jun 14 10:28:01 2006 +0000 @@ -1,10 +1,6 @@ #include "texteditor.h" #include -#include -#include -#include -#include #include #include #include @@ -13,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -21,12 +16,10 @@ #include #include #include -#include #include //Added by qt3to4: #include #include -#include #include #include @@ -226,137 +219,130 @@ void TextEditor::setupFileActions() { - Q3ToolBar *tb = new Q3ToolBar( this ); - tb->setLabel( "File Actions" ); - Q3PopupMenu *menu = new Q3PopupMenu( this ); - menuBar()->insertItem( tr( "&File" ), menu ); + QToolBar *tb = addToolBar ( tr("File Actions") ); + QMenu *fileMenu = menuBar()->addMenu( tr( "&File" )); QAction *a; a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Import..." ),this); a->setStatusTip (tr( "Import" ) ); a->setShortcut( Qt::CTRL + Qt::Key_O ); connect( a, SIGNAL( activated() ), this, SLOT( textLoad() ) ); - a->setEnabled(false); - a->addTo( tb ); - a->addTo( menu ); + tb->addAction (a); + fileMenu->addAction (a); actionFileLoad=a; - menu->insertSeparator(); + fileMenu->addSeparator(); a = new QAction( QPixmap(iconPath+"filesave.png" ), tr( "&Export..." ),this); a->setStatusTip (tr( "Export Note (HTML)" ) ); a->setShortcut( Qt::CTRL + Qt::Key_S ); connect( a, SIGNAL( activated() ), this, SLOT( textSave() ) ); - a->addTo( tb ); - a->addTo( menu ); + tb->addAction (a); + fileMenu->addAction (a); actionFileSave=a; a = new QAction( QPixmap(), tr( "Export &As... (HTML)" ), this); a->setStatusTip (tr( "Export Note As (HTML) " )); connect( a, SIGNAL( activated() ), this, SLOT( textSaveAs() ) ); - a->addTo( menu ); + fileMenu->addAction (a); actionFileSaveAs=a; a = new QAction(QPixmap(), tr( "Export &As...(ASCII)" ), this); a->setStatusTip ( tr( "Export Note As (ASCII) " ) ); a->setShortcut(Qt::ALT + Qt::Key_X ); connect( a, SIGNAL( activated() ), this, SLOT( textExportAsASCII() ) ); - a->addTo( menu ); + fileMenu->addAction (a); actionFileSaveAs=a; - menu->insertSeparator(); + fileMenu->addSeparator(); a = new QAction( QPixmap(iconPath+"fileprint.png" ), tr( "&Print..." ),this); a->setStatusTip (tr( "Print Note" ) ); a->setShortcut( Qt::CTRL + Qt::Key_P ); connect( a, SIGNAL( activated() ), this, SLOT( textPrint() ) ); - a->addTo( tb ); - a->addTo( menu ); + tb->addAction (a); + fileMenu->addAction (a); actionFilePrint=a; } void TextEditor::setupEditActions() { - Q3ToolBar *tb = new Q3ToolBar( this ); - tb->setLabel( "Edit Actions" ); - Q3PopupMenu *menu = new Q3PopupMenu( this ); - menuBar()->insertItem( tr( "&Edit" ), menu ); + QToolBar *tb = addToolBar ( tr( "Edit Actions" )); + QMenu *editMenu = menuBar()->addMenu ( tr( "&Edit" )); QAction *a; a = new QAction(QPixmap(iconPath+"undo.png"), tr( "&Undo" ), this ); a->setStatusTip ( tr( "Undo" ) ); a->setShortcut(Qt::CTRL + Qt::Key_Z ); connect( a, SIGNAL( activated() ), e, SLOT( undo() ) ); - a->addTo( menu ); - a->addTo( tb); + editMenu->addAction (a); + tb->addAction (a); actionEditUndo=a; a = new QAction(QPixmap(iconPath+"redo.png" ), tr( "&Redo" ),this); a->setStatusTip ( tr( "Redo" ) ); a->setShortcut( Qt::CTRL + Qt::Key_Y ); connect( a, SIGNAL( activated() ), e, SLOT( redo() ) ); - a->addTo( tb ); - a->addTo( menu ); + editMenu->addAction (a); + tb->addAction (a); actionEditRedo=a; - menu->insertSeparator(); + editMenu->addSeparator(); a = new QAction(QPixmap(), tr( "Select and copy &all" ),this); a->setStatusTip ( tr( "Select and copy all" ) ); a->setShortcut( Qt::CTRL + Qt::Key_A ); connect( a, SIGNAL( activated() ), this, SLOT( editCopyAll() ) ); - a->addTo( menu ); + editMenu->addAction (a); - menu->insertSeparator(); + editMenu->addSeparator(); a = new QAction(QPixmap(iconPath+"editcopy.png" ), tr( "&Copy" ),this); a->setStatusTip ( tr( "Copy" ) ); a->setShortcut( Qt::CTRL + Qt::Key_C ); connect( a, SIGNAL( activated() ), e, SLOT( copy() ) ); - a->addTo( tb ); - a->addTo( menu ); + editMenu->addAction (a); + tb->addAction (a); actionEditCopy=a; a = new QAction(QPixmap(iconPath+"editcut.png" ), tr( "Cu&t" ),this); a->setStatusTip ( tr( "Cut" ) ); a->setShortcut( Qt::CTRL + Qt::Key_X ); connect( a, SIGNAL( activated() ), e, SLOT( cut() ) ); - a->addTo( tb ); - a->addTo( menu ); + editMenu->addAction (a); + tb->addAction (a); actionEditCut=a; a = new QAction(QPixmap(iconPath+"editpaste.png" ), tr( "&Paste" ),this); a->setStatusTip ( tr( "Paste" ) ); a->setShortcut( Qt::CTRL + Qt::Key_V ); connect( a, SIGNAL( activated() ), e, SLOT( paste() ) ); - a->addTo( tb ); - a->addTo( menu ); + editMenu->addAction (a); + tb->addAction (a); actionEditPaste=a; a = new QAction( QPixmap( iconPath+"edittrash.png"), tr( "&Delete All" ), this); a->setStatusTip (tr( "Delete all" ) ); connect( a, SIGNAL( activated() ), e, SLOT( clear() ) ); - a->addTo( tb ); - a->addTo( menu ); + editMenu->addAction (a); + tb->addAction (a); actionEditDeleteAll=a; a = new QAction(QPixmap(), tr( "&Convert Paragraphs" ),this); a->setStatusTip(tr( "Convert paragraphs to linebreaks" )); a->setShortcut( Qt::ALT + Qt::Key_P ); connect( a, SIGNAL( activated() ), this, SLOT( textConvertPar() ) ); - a->addTo( menu ); + editMenu->addAction (a); actionEditConvertPar=a; a = new QAction( QPixmap(), tr( "&Join lines" ), this); a->setStatusTip(tr( "Join all lines of a paragraph" ) ); a->setShortcut(Qt::ALT + Qt::Key_J ); connect( a, SIGNAL( activated() ), this, SLOT( textJoinLines() ) ); - a->addTo( menu ); + editMenu->addAction (a); actionEditJoinLines=a; } void TextEditor::setupFormatActions() { - Q3ToolBar *tb = new Q3ToolBar( this ); - tb->setLabel( "Format Actions" ); - Q3PopupMenu *menu = new Q3PopupMenu( this ); - menuBar()->insertItem( tr( "F&ormat" ), menu ); + QToolBar *tb = addToolBar ( tr("Format Actions" )); + QMenu *formatMenu = menuBar()->addMenu ( tr( "F&ormat" )); QAction *a; @@ -365,93 +351,112 @@ a->setToggleAction (true); a->setOn (settings.readBoolEntry ("/vym/noteeditor/fonts/useFixedByDefault",false) ); connect( a, SIGNAL( activated() ), this, SLOT( toggleFonthint() ) ); - a->addTo( menu ); - a->addTo( tb ); + formatMenu->addAction (a); + tb->addAction (a); actionFormatUseFixedFont=a; - menu->insertSeparator(); - - comboFont = new QComboBox( true, tb ); +// comboFont = new QComboBox( true, tb ); + comboFont = new QComboBox; + tb->addWidget (comboFont); QFontDatabase db; comboFont->insertStringList( db.families() ); connect( comboFont, SIGNAL( activated( const QString & ) ), this, SLOT( textFamily( const QString & ) ) ); - comboFont->lineEdit()->setText( QApplication::font().family() ); - - comboSize = new QComboBox( true, tb ); + comboFont->addItem( QApplication::font().family() ); +// comboSize = new QComboBox( true, tb ); + comboSize = new QComboBox; + tb->addWidget (comboSize); Q3ValueList sizes = db.standardSizes(); Q3ValueList::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->addItem ( QString::number( QApplication::font().pointSize() ) ); - menu->insertSeparator(); + formatMenu->addSeparator(); QPixmap pix( 16, 16 ); pix.fill( e->color()); - actionTextColor = new QAction( pix, tr( "&Color..." ), this); - actionTextColor->addTo( tb ); - actionTextColor->addTo( menu ); - connect( actionTextColor, SIGNAL( activated() ), this, SLOT( textColor() ) ); + a = new QAction( pix, tr( "&Color..." ), this); + formatMenu->addAction (a); + tb->addAction (a); + connect( a, SIGNAL( activated() ), this, SLOT( textColor() ) ); + actionTextColor=a; - actionTextBold = new QAction( QPixmap (iconPath+"text_bold.png"), tr( "&Bold" ), this); - actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B ); - connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) ); - actionTextBold->addTo( tb ); - actionTextBold->addTo( menu ); - actionTextBold->setToggleAction( true ); - actionTextItalic = new QAction( QPixmap(iconPath+"text_italic.png"), tr( "&Italic" ), this); - actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I); - connect( actionTextItalic, SIGNAL( activated() ), this, SLOT( textItalic() ) ); - actionTextItalic->addTo( tb ); - actionTextItalic->addTo( menu ); - actionTextItalic->setToggleAction( true ); - actionTextUnderline = new QAction( QPixmap (iconPath+"text_under.png"), tr( "&Underline" ), this); - actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U ); - connect( actionTextUnderline, SIGNAL( activated() ), this, SLOT( textUnderline() ) ); - actionTextUnderline->addTo( tb ); - actionTextUnderline->addTo( menu ); - actionTextUnderline->setToggleAction( true ); - menu->insertSeparator(); + a = new QAction( QPixmap (iconPath+"text_bold.png"), tr( "&Bold" ), this); + a->setShortcut(Qt::CTRL + Qt::Key_B ); + connect( a, SIGNAL( activated() ), this, SLOT( textBold() ) ); + tb->addAction (a); + formatMenu->addAction (a); + a->setToggleAction( true ); + actionTextBold=a; + + a = new QAction( QPixmap(iconPath+"text_italic.png"), tr( "&Italic" ), this); + a->setShortcut(Qt::CTRL + Qt::Key_I); + connect( a, SIGNAL( activated() ), this, SLOT( textItalic() ) ); + tb->addAction (a); + formatMenu->addAction (a); + a->setToggleAction( true ); + actionTextItalic=a; + + a = new QAction( QPixmap (iconPath+"text_under.png"), tr( "&Underline" ), this); + a->setShortcut(Qt::CTRL + Qt::Key_U ); + connect( a, SIGNAL( activated() ), this, SLOT( textUnderline() ) ); + tb->addAction (a); + formatMenu->addAction (a); + a->setToggleAction( true ); + actionTextUnderline=a; + formatMenu->addSeparator(); QActionGroup *grp = new QActionGroup( this ); connect( grp, SIGNAL( selected( QAction* ) ), this, SLOT( textAlign( QAction* ) ) ); - actionAlignLeft = new QAction( QPixmap (iconPath+"text_left.png"), tr( "&Left" ),grp ); - actionAlignLeft->setShortcut( Qt::CTRL+Qt::Key_L ); - actionAlignLeft->setToggleAction( true ); - actionAlignCenter = new QAction( QPixmap (iconPath+"text_center.png"), tr( "C&enter" ),grp); - actionAlignCenter->setShortcut( Qt::CTRL + Qt::Key_E); - actionAlignCenter->setToggleAction( true ); - actionAlignRight = new QAction( QPixmap (iconPath+"text_right.png" ), tr( "&Right" ), grp); - actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R ); - actionAlignRight->setToggleAction( true ); - actionAlignJustify = new QAction( QPixmap ( iconPath+"text_block.png"), tr( "&Justify" ), grp ); - actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J ); - actionAlignJustify->setToggleAction( true ); - - grp->addTo( tb ); - grp->addTo( menu ); + a = new QAction( QPixmap (iconPath+"text_left.png"), tr( "&Left" ),grp ); + a->setShortcut( Qt::CTRL+Qt::Key_L ); + a->setToggleAction( true ); + tb->addAction (a); + formatMenu->addAction (a); + actionAlignLeft=a; + a = new QAction( QPixmap (iconPath+"text_center.png"), tr( "C&enter" ),grp); + a->setShortcut( Qt::CTRL + Qt::Key_E); + a->setToggleAction( true ); + tb->addAction (a); + formatMenu->addAction (a); + actionAlignCenter=a; + a = new QAction( QPixmap (iconPath+"text_right.png" ), tr( "&Right" ), grp); + a->setShortcut(Qt::CTRL + Qt::Key_R ); + a->setToggleAction( true ); + tb->addAction (a); + formatMenu->addAction (a); + actionAlignRight=a; + a = new QAction( QPixmap ( iconPath+"text_block.png"), tr( "&Justify" ), grp ); + a->setShortcut(Qt::CTRL + Qt::Key_J ); + a->setToggleAction( true ); + tb->addAction (a); + formatMenu->addAction (a); + actionAlignJustify=a; QActionGroup *grp2 = new QActionGroup( this ); - grp2->setExclusive(false); - actionAlignSubScript = new QAction( QPixmap (iconPath+"text_sub.png"), tr( "Subs&cript" ),grp2 ); - actionAlignSubScript->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_B ); - actionAlignSubScript->setToggleAction( true ); - connect(actionAlignSubScript, SIGNAL(activated()), this, SLOT(textVAlign())); + grp2->setExclusive(true); + a = new QAction( QPixmap (iconPath+"text_sub.png"), tr( "Subs&cript" ),grp2 ); + a->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_B ); + a->setToggleAction( true ); + tb->addAction (a); + formatMenu->addAction (a); + connect(a, SIGNAL(activated()), this, SLOT(textVAlign())); + actionAlignSubScript=a; - actionAlignSuperScript = new QAction( QPixmap (iconPath+"text_super.png"), tr( "Su&perscript" ),grp2 ); - actionAlignSuperScript->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_P ); - actionAlignSuperScript->setToggleAction( true ); - connect(actionAlignSuperScript, SIGNAL(activated()), this, SLOT(textVAlign())); + a = new QAction( QPixmap (iconPath+"text_super.png"), tr( "Su&perscript" ),grp2 ); + a->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_P ); + a->setToggleAction( true ); + tb->addAction (a); + formatMenu->addAction (a); + connect(a, SIGNAL(activated()), this, SLOT(textVAlign())); + actionAlignSuperScript=a; - menu->insertSeparator(); + formatMenu->addSeparator(); - grp2->addTo(tb); - grp2->addTo(menu); - connect( e, SIGNAL( currentFontChanged( const QFont & ) ), this, SLOT( fontChanged( const QFont & ) ) ); connect( e, SIGNAL( currentColorChanged( const QColor & ) ), @@ -465,27 +470,26 @@ void TextEditor::setupSettingsActions() { - Q3PopupMenu *menu = new Q3PopupMenu( this ); - menuBar()->insertItem( tr( "&Settings" ), menu ); + QMenu *settingsMenu = menuBar()->addMenu ( tr( "&Settings" )); QAction *a; a = new QAction(tr( "Set &fixed font" ), this); a->setStatusTip ( tr( "Set fixed font" )); connect( a, SIGNAL( activated() ), this, SLOT( setFixedFont() ) ); - a->addTo( menu ); + settingsMenu->addAction (a); actionSettingsFixedFont=a; a = new QAction(tr( "Set &variable font" ), this); a->setStatusTip ( tr( "Set variable font" ) ); connect( a, SIGNAL( activated() ), this, SLOT( setVarFont() ) ); - a->addTo( menu ); + settingsMenu->addAction (a); actionSettingsVarFont=a; a = new QAction(tr( "&fixed font is default" ), this); a->setStatusTip (tr( "Used fixed font by default" ) ); a->setToggleAction (true); // set state later in constructor... - a->addTo( menu ); + settingsMenu->addAction (a); actionSettingsFonthintDefault=a; } @@ -909,8 +913,10 @@ void TextEditor::fontChanged( const QFont &f ) { +/* comboFont->lineEdit()->setText( f.family() ); comboSize->lineEdit()->setText( QString::number( f.pointSize() ) ); +*/ actionTextBold->setOn( f.bold() ); actionTextItalic->setOn( f.italic() ); actionTextUnderline->setOn( f.underline() );