author | mickeyl <mickeyl> | 2004-05-23 11:26:00 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-05-23 11:26:00 (UTC) |
commit | 163a07abb5fbf5346585bce5edf5e48d015b442a (patch) (side-by-side diff) | |
tree | 0ae95b1f32ded0e1766b240ccfcfec856dafea09 /noncore/apps/tinykate/mainwindow | |
parent | 6cd90404121a78f3181a35acc056d7feca3d6aeb (diff) | |
download | opie-163a07abb5fbf5346585bce5edf5e48d015b442a.zip opie-163a07abb5fbf5346585bce5edf5e48d015b442a.tar.gz opie-163a07abb5fbf5346585bce5edf5e48d015b442a.tar.bz2 |
CLEANUP: sanitize tinykate's build structure
Diffstat (limited to 'noncore/apps/tinykate/mainwindow') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/tinykate/mainwindow/.cvsignore | 3 | ||||
-rw-r--r-- | noncore/apps/tinykate/mainwindow/cgotobase.ui | 65 | ||||
-rw-r--r-- | noncore/apps/tinykate/mainwindow/cgotoline.cpp | 23 | ||||
-rw-r--r-- | noncore/apps/tinykate/mainwindow/cgotoline.h | 10 | ||||
-rw-r--r-- | noncore/apps/tinykate/mainwindow/main.cpp | 25 | ||||
-rw-r--r-- | noncore/apps/tinykate/mainwindow/mainwindow.pro | 12 | ||||
-rw-r--r-- | noncore/apps/tinykate/mainwindow/tinykate.cpp | 284 | ||||
-rw-r--r-- | noncore/apps/tinykate/mainwindow/tinykate.h | 66 |
8 files changed, 488 insertions, 0 deletions
diff --git a/noncore/apps/tinykate/mainwindow/.cvsignore b/noncore/apps/tinykate/mainwindow/.cvsignore new file mode 100644 index 0000000..e737538 --- a/dev/null +++ b/noncore/apps/tinykate/mainwindow/.cvsignore @@ -0,0 +1,3 @@ +Makefile* +.moc +.obj diff --git a/noncore/apps/tinykate/mainwindow/cgotobase.ui b/noncore/apps/tinykate/mainwindow/cgotobase.ui new file mode 100644 index 0000000..6660cb8 --- a/dev/null +++ b/noncore/apps/tinykate/mainwindow/cgotobase.ui @@ -0,0 +1,65 @@ +<!DOCTYPE UI><UI> +<class>CGotoBase</class> +<widget> + <class>QDialog</class> + <property stdset="1"> + <name>name</name> + <cstring>CGotoBase</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>215</width> + <height>50</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>Goto Line</string> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>Line:</string> + </property> + <property stdset="1"> + <name>alignment</name> + <set>AlignVCenter|AlignRight</set> + </property> + <property> + <name>hAlign</name> + </property> + </widget> + <widget> + <class>QSpinBox</class> + <property stdset="1"> + <name>name</name> + <cstring>mLine</cstring> + </property> + </widget> + </hbox> +</widget> +</UI> diff --git a/noncore/apps/tinykate/mainwindow/cgotoline.cpp b/noncore/apps/tinykate/mainwindow/cgotoline.cpp new file mode 100644 index 0000000..97f2ea5 --- a/dev/null +++ b/noncore/apps/tinykate/mainwindow/cgotoline.cpp @@ -0,0 +1,23 @@ +#include "cgotoline.h" +#include <qspinbox.h> +// copyright 2003 Craig Graham <cgraham@accessdevices.co.uk> + +CGotoLine::CGotoLine(int l) : CGotoBase(0,0,true) +{ + mLine->setValue(l+1); +} + +int CGotoLine::line() +{ + return mLine->value()-1; +} + +void CGotoLine::keyPressEvent(QKeyEvent *e) +{ + if((e->key()==Key_Return)||(e->key()==Key_Enter)) + { + accept(); + }else{ + QDialog::keyPressEvent(e); + } +} diff --git a/noncore/apps/tinykate/mainwindow/cgotoline.h b/noncore/apps/tinykate/mainwindow/cgotoline.h new file mode 100644 index 0000000..29d6f42 --- a/dev/null +++ b/noncore/apps/tinykate/mainwindow/cgotoline.h @@ -0,0 +1,10 @@ +// +// copyright 2003 Craig Graham <cgraham@accessdevices.co.uk> +#include "cgotobase.h" +class CGotoLine : public CGotoBase { +public: + CGotoLine(int line); + int line(); +protected: + virtual void keyPressEvent(QKeyEvent *e); +}; diff --git a/noncore/apps/tinykate/mainwindow/main.cpp b/noncore/apps/tinykate/mainwindow/main.cpp new file mode 100644 index 0000000..c14d10a --- a/dev/null +++ b/noncore/apps/tinykate/mainwindow/main.cpp @@ -0,0 +1,25 @@ +/*************************************************************************** + + main.cpp + ------------------- + 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 <opie2/oapplicationfactory.h> + +#include "tinykate.h" + +using namespace Opie::Core; + +OPIE_EXPORT_APP( OApplicationFactory<TinyKate> ) + diff --git a/noncore/apps/tinykate/mainwindow/mainwindow.pro b/noncore/apps/tinykate/mainwindow/mainwindow.pro new file mode 100644 index 0000000..94d00bd --- a/dev/null +++ b/noncore/apps/tinykate/mainwindow/mainwindow.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +CONFIG = qt warn_on quick-app +DESTDIR = $(OPIEDIR)/bin +HEADERS = tinykate.h +SOURCES = tinykate.cpp main.cpp +INCLUDEPATH = $(OPIEDIR)/include ../libkate \ + ../libkate/ktexteditor ../libkate/document ../libkate/microkde ../libkate/qt3back ../libkate/view ../libkate/interfaces +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lqpe -lkate -lopiecore2 -lopieui2 +TARGET = tinykate + +include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/apps/tinykate/mainwindow/tinykate.cpp b/noncore/apps/tinykate/mainwindow/tinykate.cpp new file mode 100644 index 0000000..9865c35 --- a/dev/null +++ b/noncore/apps/tinykate/mainwindow/tinykate.cpp @@ -0,0 +1,284 @@ +/*************************************************************************** + tinykate.cpp + Tiny KATE mainwindow + ------------------- + begin : November 2002 + copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 "tinykate.h" + +#include "katedocument.h" +#include "kglobal.h" + +/* OPIE */ +#include <opie2/odebug.h> +#include <opie2/ofiledialog.h> +#include <qpe/resource.h> +#include <qpe/qpeapplication.h> + +/* QT */ +#include <qaction.h> +#include <qtoolbutton.h> +#include <qmenubar.h> + + +using namespace Opie::Ui; +TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : + QMainWindow( parent, name, f ) +{ + shutDown=false; + nextUnnamed=0; + currentView=0; + viewCount=0; + setCaption(tr("TinyKATE")); + KGlobal::setAppName("TinyKATE"); + + 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); + connect(a, SIGNAL(activated()), this, SLOT(slotOpen())); + + + // Action for saving document + a = new QAction( tr( "Save" ), Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 ); + a->addTo(popup); + connect(a, SIGNAL(activated()), this, SLOT(slotSave())); + + // 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 QToolButton( 0 ); + editCut->setAutoRaise( true ); + editCut->setIconSet( Resource::loadPixmap( "cut" ) ); + + // Action for Copying text + editCopy = new QToolButton( 0 ); + editCopy->setAutoRaise( true ); + editCopy->setIconSet( Resource::loadPixmap( "copy" ) ); + + // Action for pasting text + editPaste = new QToolButton( 0 ); + editPaste->setAutoRaise( true ); + editPaste->setIconSet( Resource::loadPixmap( "paste" ) ); + + // Action for finding / replacing text + editFindReplace = new QToolButton( 0 ); + editFindReplace->setAutoRaise( true ); + editFindReplace->setIconSet( Resource::loadPixmap("find") ); + + // Action for undo + editUndo = new QToolButton( 0 ); + editUndo->setAutoRaise( true ); + editUndo->setIconSet( Resource::loadPixmap( "undo" ) ); + + // Action for redo + 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); + + 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(); + +} + +TinyKate::~TinyKate( ) +{ + owarn << "TinyKate destructor\n" << oendl; + + shutDown=true; + while (currentView!=0) { + slotClose(); + } + + if( KGlobal::config() != 0 ) { + owarn << "deleting KateConfig object..\n" << oendl; + delete KGlobal::config(); + } +} + +void TinyKate::slotOpen( ) +{ + QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, + QString::null); + if (!filename.isEmpty()) { + open(filename); + } +} + +void TinyKate::open(const QString & filename) +{ + KateDocument *kd= new KateDocument(false, false, this,0,this); + KTextEditor::View *kv; + QFileInfo fi(filename); + QString filenamed = fi.fileName(); + tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed ); + odebug << filename << oendl; + + kd->setDocName( filenamed); + kd->open( filename ); + viewCount++; +} + +void TinyKate::setDocument(const QString& fileref) +{ + open( fileref ); +} + +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(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( ) +{ + if (currentView==0) return; + KTextEditor::View *dv=currentView; + currentView=0; + tabwidget->removePage(dv); + delete dv->document(); + viewCount--; + if ((!viewCount) && (!shutDown)) slotNew(); +} + +void TinyKate::slotSave() { + // feel free to make this how you want + if (currentView==0) return; + + // KateView *kv = (KateView*) currentView; + KateDocument *kd = (KateDocument*) currentView->document(); + // odebug << "saving file "+kd->docName() << oendl; + if( kd->docName().isEmpty()) + slotSaveAs(); + else + kd->saveFile(); + // kv->save(); + // kd->saveFile(); +} + +void TinyKate::slotSaveAs() { + if (currentView==0) return; + KateDocument *kd = (KateDocument*) currentView->document(); + + QString filename= OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, + QString::null); + if (!filename.isEmpty()) { + odebug << "saving file "+filename << oendl; + QFileInfo fi(filename); + QString filenamed = fi.fileName(); + kd->setDocFile( filename); + kd->setDocName( filenamed); + kd->saveFile(); +// KTextEditor::View *dv = currentView; +// tabwidget->changeTab( dv, filenamed); + // need to change tab label here + } + +} diff --git a/noncore/apps/tinykate/mainwindow/tinykate.h b/noncore/apps/tinykate/mainwindow/tinykate.h new file mode 100644 index 0000000..f435c03 --- a/dev/null +++ b/noncore/apps/tinykate/mainwindow/tinykate.h @@ -0,0 +1,66 @@ +/*************************************************************************** + tinykate.h + 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 * + * * + ***************************************************************************/ + +#ifndef __TINYKATE_H__ +#define __TINYKATE_H__ + + +#include <qmainwindow.h> +#include <opie2/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( ); + static QString appName() { return QString::fromLatin1( "kate" ); }; + + +public slots: + void slotNew(); + void setDocument(const QString& fileref); + +protected slots: + void slotOpen(); + void slotClose(); + void slotCurrentChanged(QWidget *); + void slotSave(); + void slotSaveAs(); +protected: + void open(const QString&); +private: + QString currentFileName; + Opie::Ui::OTabWidget *tabwidget; + KTextEditor::View *currentView; + bool shutDown; + + QToolButton *editCopy, *editCut, *editPaste, *editUndo, *editRedo, *editFindReplace; + QAction *viewIncFontSizes, *viewDecFontSizes, *utilSettings; + + QPopupMenu *hlmenu; + uint nextUnnamed; + uint viewCount; +}; + + +#endif // __TINYKATE_H__ |