author | jowenn <jowenn> | 2002-11-22 21:18:23 (UTC) |
---|---|---|
committer | jowenn <jowenn> | 2002-11-22 21:18:23 (UTC) |
commit | 0f9ce3f60b6fbd350f79485ee8fc5fe37be692e1 (patch) (side-by-side diff) | |
tree | a55c913156515ca5a5df95f5a838ecf4a80bae87 | |
parent | 575f126fe474ba1d1603de73088c342c2a3eaa8f (diff) | |
download | opie-0f9ce3f60b6fbd350f79485ee8fc5fe37be692e1.zip opie-0f9ce3f60b6fbd350f79485ee8fc5fe37be692e1.tar.gz opie-0f9ce3f60b6fbd350f79485ee8fc5fe37be692e1.tar.bz2 |
Show icons
-rw-r--r-- | noncore/apps/tinykate/tinykate.cpp | 22 | ||||
-rw-r--r-- | noncore/apps/tinykate/tinykate.h | 9 |
2 files changed, 24 insertions, 7 deletions
diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp index 03c6e50..f177e47 100644 --- a/noncore/apps/tinykate/tinykate.cpp +++ b/noncore/apps/tinykate/tinykate.cpp @@ -1,64 +1,67 @@ /*************************************************************************** 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 * * 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 <qpe/resource.h> #include <qpe/global.h> +#include <qpe/qpeapplication.h> #include <opie/ofiledialog.h> #include "tinykate.h" #include "pics/file-new.xpm" #include "pics/file-open.xpm" #include "pics/file-save.xpm" #include "pics/edit-undo.xpm" #include "pics/edit-redo.xpm" #include <katedocument.h> #include <katehighlight.h> TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : QMainWindow( parent, name, f ) { + nextUnnamed=0; currentView=0; + viewCount=0; setCaption(tr("TinyKATE")); setToolBarsMovable(FALSE); QPEToolBar *bar = new QPEToolBar( this ); bar->setHorizontalStretchable( TRUE ); QPEMenuBar *mb = new QPEMenuBar( bar ); 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" ), QPixmap((const char**)file_new_xpm ), 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" ), QPixmap((const char**)file_open_xpm), QString::null, 0, this, 0 ); a->addTo(popup); @@ -116,84 +119,95 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 ); viewDecFontSizes->addTo( popup ); mb->insertItem(tr("View"),popup); popup = new QPopupMenu( this ); mb->insertItem(tr("Utils"),popup); //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(); + } void TinyKate::slotOpen( ) { QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED_ALL); if (!filename.isEmpty()) { + open(filename); + } +} + +void TinyKate::open(const QString & filename) +{ KateDocument *kd= new KateDocument(false, false, this,0,this); KTextEditor::View *kv; - tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"BLAH","BLAH"); + tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate","BLAH"); qDebug(filename); 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(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(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"),"BLAH",tr("Unnamed %1").arg(0)); - + tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"),"tinykate/tinykate",tr("Unnamed %1").arg(nextUnnamed++)); + viewCount++; } void TinyKate::slotClose( ) { if (currentView==0) return; KTextEditor::View *dv=currentView; currentView=0; tabwidget->removePage(dv); delete dv->document(); + viewCount--; + if (!viewCount) slotNew(); } diff --git a/noncore/apps/tinykate/tinykate.h b/noncore/apps/tinykate/tinykate.h index 6dda05d..ef0dcba 100644 --- a/noncore/apps/tinykate/tinykate.h +++ b/noncore/apps/tinykate/tinykate.h @@ -12,51 +12,54 @@ * 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 QAction; class QPopupMenu; class TinyKate : public QMainWindow { Q_OBJECT public: TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0); public slots: - void slotOpen(); + void slotNew(); protected slots: - void slotNew(); + void slotOpen(); void slotClose(); void slotCurrentChanged(QWidget *); +protected: + void open(const QString&); private: OTabWidget *tabwidget; KTextEditor::View *currentView; QAction *editCopy; QAction *editCut; QAction *editPaste; QAction *editUndo; QAction *editRedo; QAction *editFindReplace; QAction *viewIncFontSizes; QAction *viewDecFontSizes; QAction *utilSettings; QPopupMenu *hlmenu; - + uint nextUnnamed; + uint viewCount; }; #endif // __TINYKATE_H__ |