author | harlekin <harlekin> | 2003-04-10 20:10:36 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-04-10 20:10:36 (UTC) |
commit | 0740e2ef7132c53ebe29cc3b548647012bc75d05 (patch) (side-by-side diff) | |
tree | eaf9a1fbdf73324743dc1a896e813c6e2675a513 | |
parent | dbbc4f5122cae1c6d64ce3e6793f4f588075a103 (diff) | |
download | opie-0740e2ef7132c53ebe29cc3b548647012bc75d05.zip opie-0740e2ef7132c53ebe29cc3b548647012bc75d05.tar.gz opie-0740e2ef7132c53ebe29cc3b548647012bc75d05.tar.bz2 |
goodbye qpemenubar and qpetoolbar ( both are depreciated ), using qmenubar now, and also the icons are in the menubar now as qtoolbutton which as side effect gives them the nice benefit if beeing centered to the right
-rw-r--r-- | noncore/apps/tinykate/tinykate.cpp | 78 | ||||
-rw-r--r-- | noncore/apps/tinykate/tinykate.h | 12 |
2 files changed, 46 insertions, 44 deletions
diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp index a25f81f..694efc6 100644 --- a/noncore/apps/tinykate/tinykate.cpp +++ b/noncore/apps/tinykate/tinykate.cpp @@ -1,65 +1,61 @@ /*************************************************************************** tinykate.cpp Tiny KATE mainwindow ------------------- begin : November 2002 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> ***************************************************************************/ /*************************************************************************** * * - * This program is free software; you can redistribute it and/or modify * + * This program is free softwaSre; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation. * * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * * * ***************************************************************************/ #include <qwidget.h> #include <qaction.h> #include <qlayout.h> -#include <qpe/qpetoolbar.h> -#include <qpe/qpemenubar.h> +#include <qtoolbutton.h> +#include <qmenubar.h> #include <qpe/resource.h> #include <qpe/global.h> #include <qpe/qpeapplication.h> #include <opie/ofiledialog.h> #include "tinykate.h" #include <katedocument.h> #include <katehighlight.h> #include <kateview.h> #include <kglobal.h> TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : QMainWindow( parent, name, f ) { nextUnnamed=0; currentView=0; viewCount=0; setCaption(tr("TinyKATE")); KGlobal::setAppName("TinyKATE"); - setToolBarsMovable(FALSE); - - QPEToolBar *bar = new QPEToolBar( this ); - bar->setHorizontalStretchable( TRUE ); - QPEMenuBar *mb = new QPEMenuBar( bar ); - mb->setMargin( 0 ); + QMenuBar *mb = new QMenuBar( this ); + mb->setMargin( 0 ); tabwidget=new OTabWidget(this); setCentralWidget(tabwidget); connect(tabwidget,SIGNAL(currentChanged( QWidget *)),this,SLOT(slotCurrentChanged(QWidget *))); //FILE ACTIONS QPopupMenu *popup = new QPopupMenu( this ); // Action for creating a new document QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); a->addTo( popup ); connect(a, SIGNAL(activated()), this, SLOT(slotNew())); // Action for opening an exisiting document a = new QAction( tr( "Open" ),Resource::loadPixmap( "fileopen" ) , QString::null, 0, this, 0 ); a->addTo(popup); @@ -74,71 +70,83 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : // Action for saving document to a new name a = new QAction( tr( "Save As" ),Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 ); a->addTo(popup); connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs())); // Action for closing the currently active document a = new QAction( tr( "Close" ), Resource::loadPixmap( "quit_icon" ) , QString::null, 0, this, 0 ); a->addTo(popup); connect(a, SIGNAL(activated()), this, SLOT(slotClose())); mb->insertItem(tr("File"),popup); //EDIT ACTIONS // Action for cutting text - editCut = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); - editCut->addTo( bar ); + editCut = new QToolButton( 0 ); + editCut->setAutoRaise( true ); + editCut->setIconSet( Resource::loadPixmap( "cut" ) ); // Action for Copying text - editCopy = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); - editCopy->addTo( bar ); + editCopy = new QToolButton( 0 ); + editCopy->setAutoRaise( true ); + editCopy->setIconSet( Resource::loadPixmap( "copy" ) ); // Action for pasting text - editPaste = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); - editPaste->addTo( bar ); - + editPaste = new QToolButton( 0 ); + editPaste->setAutoRaise( true ); + editPaste->setIconSet( Resource::loadPixmap( "paste" ) ); // Action for finding / replacing text - editFindReplace = new QAction( tr( "Find/Replace" ), Resource::loadPixmap("find"), QString::null, 0, this, 0 ); - editFindReplace->addTo( bar ); + editFindReplace = new QToolButton( 0 ); + editFindReplace->setAutoRaise( true ); + editFindReplace->setIconSet( Resource::loadPixmap("find") ); - // Action for undo - editUndo = new QAction( tr( "Undo" ),Resource::loadPixmap( "undo" ) , QString::null, 0, this, 0 ); - editUndo->addTo( bar ); + // Action for undo + editUndo = new QToolButton( 0 ); + editUndo->setAutoRaise( true ); + editUndo->setIconSet( Resource::loadPixmap( "undo" ) ); // Action for redo - editRedo = new QAction( tr( "Redo" ),Resource::loadPixmap( "redo" ) , QString::null, 0, this, 0 ); - editRedo->addTo( bar ); + editRedo = new QToolButton( 0 ); + editRedo->setAutoRaise( true ); + editRedo->setIconSet( Resource::loadPixmap( "redo" ) ); //VIEW ACITONS popup = new QPopupMenu( this ); viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 ); viewIncFontSizes->addTo( popup ); viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 ); viewDecFontSizes->addTo( popup ); - mb->insertItem(tr("View"),popup); + mb->insertItem(tr("View"),popup); + popup = new QPopupMenu( this ); + mb->insertItem(tr("Utils"),popup); - popup = new QPopupMenu( this ); - mb->insertItem(tr("Utils"),popup); + mb->insertItem( editCut ); + mb->insertItem( editCopy ); + mb->insertItem( editPaste ); + mb->insertItem( editFindReplace ); + mb->insertItem( editUndo ); + mb->insertItem( editRedo ); + //Highlight management hlmenu=new QPopupMenu(this); HlManager *hlm=HlManager::self(); for (int i=0;i<hlm->highlights();i++) { hlmenu->insertItem(hlm->hlName(i),i); } popup->insertItem(tr("Highlighting"),hlmenu); utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 ); utilSettings->addTo( popup); if( qApp->argc() > 1) open(qApp->argv()[1]); else slotNew(); @@ -173,47 +181,47 @@ void TinyKate::open(const QString & filename) qDebug(filename); kd->setDocName( filenamed); kd->open( filename ); viewCount++; } void TinyKate::slotCurrentChanged( QWidget * view) { if (currentView) { disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); - disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); - disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); + disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); + disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); } currentView=(KTextEditor::View*)view; - connect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); - connect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); - connect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); - connect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); - connect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); - connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); - connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); + connect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy())); + connect(editCut,SIGNAL(clicked()),currentView,SLOT(cut())); + connect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste())); + connect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo())); + connect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo())); + connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); + connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); connect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); } void TinyKate::slotNew( ) { KateDocument *kd= new KateDocument(false, false, this,0,this); KTextEditor::View *kv; tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"), "tinykate/tinykate", tr("Unnamed %1").arg(nextUnnamed++)); viewCount++; } void TinyKate::slotClose( ) diff --git a/noncore/apps/tinykate/tinykate.h b/noncore/apps/tinykate/tinykate.h index bb32f98..cdd8f43 100644 --- a/noncore/apps/tinykate/tinykate.h +++ b/noncore/apps/tinykate/tinykate.h @@ -10,59 +10,53 @@ * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation. * * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * * * ***************************************************************************/ #ifndef __TINYKATE_H__ #define __TINYKATE_H__ #include <qmainwindow.h> #include <opie/otabwidget.h> #include <ktexteditor.h> +class QToolButton; class QAction; class QPopupMenu; class TinyKate : public QMainWindow { Q_OBJECT public: TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0); ~TinyKate( ); public slots: void slotNew(); protected slots: void slotOpen(); void slotClose(); void slotCurrentChanged(QWidget *); void slotSave(); void slotSaveAs(); protected: void open(const QString&); private: QString currentFileName; OTabWidget *tabwidget; KTextEditor::View *currentView; - QAction *editCopy; - QAction *editCut; - QAction *editPaste; - QAction *editUndo; - QAction *editRedo; - QAction *editFindReplace; - QAction *viewIncFontSizes; - QAction *viewDecFontSizes; - QAction *utilSettings; + QToolButton *editCopy, *editCut, *editPaste, *editUndo, *editRedo, *editFindReplace; + QAction *viewIncFontSizes, *viewDecFontSizes, *utilSettings; QPopupMenu *hlmenu; uint nextUnnamed; uint viewCount; }; #endif // __TINYKATE_H__ |