author | kergoth <kergoth> | 2003-08-09 16:12:19 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-08-09 16:12:19 (UTC) |
commit | 1c58d1407f9584fedcdae390a04e2b37e5853361 (patch) (unidiff) | |
tree | 3c6e741c4d382d1a53c182930052b684d6e35b91 /noncore/apps/tinykate/tinykate.cpp | |
parent | e3f4607edd0c1ca1434adb446df1d4a1d27c6a86 (diff) | |
download | opie-1c58d1407f9584fedcdae390a04e2b37e5853361.zip opie-1c58d1407f9584fedcdae390a04e2b37e5853361.tar.gz opie-1c58d1407f9584fedcdae390a04e2b37e5853361.tar.bz2 |
Merge from BRANCH_1_0
Diffstat (limited to 'noncore/apps/tinykate/tinykate.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/tinykate/tinykate.cpp | 162 |
1 files changed, 62 insertions, 100 deletions
diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp index dda8405..f470645 100644 --- a/noncore/apps/tinykate/tinykate.cpp +++ b/noncore/apps/tinykate/tinykate.cpp | |||
@@ -10,3 +10,3 @@ | |||
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free softwaSre; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
@@ -19,4 +19,4 @@ | |||
19 | #include <qlayout.h> | 19 | #include <qlayout.h> |
20 | #include <qpe/qpetoolbar.h> | 20 | #include <qtoolbutton.h> |
21 | #include <qpe/qpemenubar.h> | 21 | #include <qmenubar.h> |
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
@@ -27,4 +27,2 @@ | |||
27 | 27 | ||
28 | #include "cgotoline.h" | ||
29 | |||
30 | #include "tinykate.h" | 28 | #include "tinykate.h" |
@@ -38,3 +36,4 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
38 | QMainWindow( parent, name, f ) | 36 | QMainWindow( parent, name, f ) |
39 | { | 37 | { |
38 | shutDown=false; | ||
40 | nextUnnamed=0; | 39 | nextUnnamed=0; |
@@ -42,13 +41,7 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
42 | viewCount=0; | 41 | viewCount=0; |
43 | setCaption("TinyKATE : line 1 col 1"); | 42 | setCaption(tr("TinyKATE")); |
44 | KGlobal::setAppName("TinyKATE"); | 43 | KGlobal::setAppName("TinyKATE"); |
45 | 44 | ||
46 | curLine=curCol=1; | 45 | QMenuBar *mb = new QMenuBar( this ); |
47 | 46 | mb->setMargin( 0 ); | |
48 | setToolBarsMovable(FALSE); | ||
49 | |||
50 | QPEToolBar *bar = new QPEToolBar( this ); | ||
51 | bar->setHorizontalStretchable( TRUE ); | ||
52 | QPEMenuBar *mb = new QPEMenuBar( bar ); | ||
53 | mb->setMargin( 0 ); | ||
54 | 47 | ||
@@ -62,3 +55,3 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
62 | // Action for creating a new document | 55 | // Action for creating a new document |
63 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, CTRL+Key_N, this, 0 ); | 56 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
64 | a->addTo( popup ); | 57 | a->addTo( popup ); |
@@ -67,3 +60,3 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
67 | // Action for opening an exisiting document | 60 | // Action for opening an exisiting document |
68 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, CTRL+Key_O, this, 0 ); | 61 | a = new QAction( tr( "Open" ),Resource::loadPixmap( "fileopen" ) , QString::null, 0, this, 0 ); |
69 | a->addTo(popup); | 62 | a->addTo(popup); |
@@ -73,3 +66,3 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
73 | // Action for saving document | 66 | // Action for saving document |
74 | a = new QAction( tr( "Save" ), Resource::loadPixmap( "save" ), QString::null, CTRL+Key_S, this, 0 ); | 67 | a = new QAction( tr( "Save" ), Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 ); |
75 | a->addTo(popup); | 68 | a->addTo(popup); |
@@ -78,3 +71,3 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
78 | // Action for saving document to a new name | 71 | // Action for saving document to a new name |
79 | a = new QAction( tr( "Save As" ), Resource::loadPixmap( "save" ), QString::null, 0, this, 0 ); | 72 | a = new QAction( tr( "Save As" ),Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 ); |
80 | a->addTo(popup); | 73 | a->addTo(popup); |
@@ -83,6 +76,6 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
83 | // Action for closing the currently active document | 76 | // Action for closing the currently active document |
84 | a = new QAction( tr( "Close" ), Resource::loadPixmap( "close" ), QString::null, CTRL+Key_W, this, 0 ); | 77 | a = new QAction( tr( "Close" ), Resource::loadPixmap( "quit_icon" ) , QString::null, 0, this, 0 ); |
85 | a->addTo(popup); | 78 | a->addTo(popup); |
86 | connect(a, SIGNAL(activated()), this, SLOT(slotClose())); | 79 | connect(a, SIGNAL(activated()), this, SLOT(slotClose())); |
87 | 80 | ||
88 | 81 | ||
@@ -93,27 +86,30 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
93 | // Action for cutting text | 86 | // Action for cutting text |
94 | editCut = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, CTRL+Key_X, this, 0 ); | 87 | editCut = new QToolButton( 0 ); |
95 | editCut->addTo( bar ); | 88 | editCut->setAutoRaise( true ); |
89 | editCut->setIconSet( Resource::loadPixmap( "cut" ) ); | ||
96 | 90 | ||
97 | // Action for Copying text | 91 | // Action for Copying text |
98 | editCopy = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, CTRL+Key_C, this, 0 ); | 92 | editCopy = new QToolButton( 0 ); |
99 | editCopy->addTo( bar ); | 93 | editCopy->setAutoRaise( true ); |
94 | editCopy->setIconSet( Resource::loadPixmap( "copy" ) ); | ||
100 | 95 | ||
101 | // Action for pasting text | 96 | // Action for pasting text |
102 | editPaste = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, CTRL+Key_V, this, 0 ); | 97 | editPaste = new QToolButton( 0 ); |
103 | editPaste->addTo( bar ); | 98 | editPaste->setAutoRaise( true ); |
104 | 99 | editPaste->setIconSet( Resource::loadPixmap( "paste" ) ); | |
105 | 100 | ||
106 | // Action for finding / replacing text | 101 | // Action for finding / replacing text |
107 | editFindReplace = new QAction( tr( "Replace" ), Resource::loadPixmap("find"), QString::null, CTRL+Key_R, this, 0 ); | 102 | editFindReplace = new QToolButton( 0 ); |
108 | editFind = new QAction( tr( "Find" ), Resource::loadPixmap("find"), QString::null, CTRL+Key_F, this, 0 ); | 103 | editFindReplace->setAutoRaise( true ); |
109 | editFind->addTo( bar ); | 104 | editFindReplace->setIconSet( Resource::loadPixmap("find") ); |
110 | 105 | ||
111 | // Action for undo | 106 | // Action for undo |
112 | editUndo = new QAction( tr( "Undo" ), Resource::loadPixmap( "undo" ), QString::null, CTRL+Key_Z, this, 0 ); | 107 | editUndo = new QToolButton( 0 ); |
113 | editUndo->addTo( bar ); | 108 | editUndo->setAutoRaise( true ); |
109 | editUndo->setIconSet( Resource::loadPixmap( "undo" ) ); | ||
114 | 110 | ||
115 | // Action for redo | 111 | // Action for redo |
116 | editRedo = new QAction( tr( "Redo" ), Resource::loadPixmap( "redo" ), QString::null, CTRL+SHIFT+Key_Z, this, 0 ); | 112 | editRedo = new QToolButton( 0 ); |
117 | editRedo->addTo( bar ); | 113 | editRedo->setAutoRaise( true ); |
118 | 114 | editRedo->setIconSet( Resource::loadPixmap( "redo" ) ); | |
119 | 115 | ||
@@ -121,7 +117,3 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
121 | popup = new QPopupMenu( this ); | 117 | popup = new QPopupMenu( this ); |
122 | 118 | ||
123 | a = new QAction( tr( "Goto" ), QString::null, CTRL+Key_G, this, 0 ); | ||
124 | a->addTo( popup ); | ||
125 | connect(a, SIGNAL(activated()), this, SLOT(slotGoTo())); | ||
126 | |||
127 | viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 ); | 119 | viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 ); |
@@ -132,8 +124,15 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
132 | 124 | ||
133 | mb->insertItem(tr("View"),popup); | 125 | mb->insertItem(tr("View"),popup); |
134 | 126 | ||
127 | popup = new QPopupMenu( this ); | ||
128 | mb->insertItem(tr("Utils"),popup); | ||
135 | 129 | ||
136 | 130 | ||
137 | popup = new QPopupMenu( this ); | 131 | mb->insertItem( editCut ); |
138 | mb->insertItem(tr("Utils"),popup); | 132 | mb->insertItem( editCopy ); |
133 | mb->insertItem( editPaste ); | ||
134 | mb->insertItem( editFindReplace ); | ||
135 | mb->insertItem( editUndo ); | ||
136 | mb->insertItem( editRedo ); | ||
137 | |||
139 | 138 | ||
@@ -152,6 +151,2 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
152 | 151 | ||
153 | popup->insertSeparator(); | ||
154 | editFind->addTo(popup); | ||
155 | editFindReplace->addTo(popup); | ||
156 | |||
157 | if( qApp->argc() > 1) open(qApp->argv()[1]); | 152 | if( qApp->argc() > 1) open(qApp->argv()[1]); |
@@ -164,5 +159,9 @@ TinyKate::~TinyKate( ) | |||
164 | qWarning("TinyKate destructor\n"); | 159 | qWarning("TinyKate destructor\n"); |
165 | printf("~TinyKate()\n"); | 160 | |
161 | shutDown=true; | ||
162 | while (currentView!=0) { | ||
163 | slotClose(); | ||
164 | } | ||
165 | |||
166 | if( KGlobal::config() != 0 ) { | 166 | if( KGlobal::config() != 0 ) { |
167 | printf("~TinyKate(): delete configs...\n"); | ||
168 | qWarning("deleting KateConfig object..\n"); | 167 | qWarning("deleting KateConfig object..\n"); |
@@ -195,6 +194,5 @@ void TinyKate::open(const QString & filename) | |||
195 | 194 | ||
196 | void TinyKate::setDocument(const QString &doc) | 195 | void TinyKate::setDocument(const QString& fileref) |
197 | { | 196 | { |
198 | printf("tinykate: setDocument(\"%s\")\n",(const char*)doc); | 197 | open( fileref ); |
199 | open(doc); | ||
200 | } | 198 | } |
@@ -210,9 +208,6 @@ void TinyKate::slotCurrentChanged( QWidget * view) | |||
210 | disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); | 208 | disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); |
211 | disconnect(editFindReplace,SIGNAL(activated()),currentView,SLOT(replace())); | 209 | disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); |
212 | disconnect(editFind,SIGNAL(activated()),currentView,SLOT(find())); | 210 | disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); |
213 | disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); | ||
214 | disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); | ||
215 | disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); | 211 | disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); |
216 | disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); | 212 | disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); |
217 | disconnect(currentView,SIGNAL(newCurPos()),this,SLOT(slotCursorMoved())); | ||
218 | } | 213 | } |
@@ -220,10 +215,8 @@ void TinyKate::slotCurrentChanged( QWidget * view) | |||
220 | currentView=(KTextEditor::View*)view; | 215 | currentView=(KTextEditor::View*)view; |
221 | 216 | ||
222 | connect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); | 217 | connect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy())); |
223 | connect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); | 218 | connect(editCut,SIGNAL(clicked()),currentView,SLOT(cut())); |
224 | connect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); | 219 | connect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste())); |
225 | connect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); | 220 | connect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo())); |
226 | connect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); | 221 | connect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo())); |
227 | connect(editFindReplace,SIGNAL(activated()),currentView,SLOT(replace())); | ||
228 | connect(editFind,SIGNAL(activated()),currentView,SLOT(find())); | ||
229 | connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); | 222 | connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); |
@@ -232,3 +225,3 @@ void TinyKate::slotCurrentChanged( QWidget * view) | |||
232 | connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); | 225 | connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); |
233 | connect(currentView,SIGNAL(newCurPos()),this,SLOT(slotCursorMoved())); | 226 | |
234 | } | 227 | } |
@@ -253,3 +246,3 @@ void TinyKate::slotClose( ) | |||
253 | viewCount--; | 246 | viewCount--; |
254 | if (!viewCount) slotNew(); | 247 | if ((!viewCount) && (!shutDown)) slotNew(); |
255 | } | 248 | } |
@@ -290,32 +283 @@ void TinyKate::slotSaveAs() { | |||
290 | } | } | |
291 | |||
292 | void TinyKate::slotGoTo() | ||
293 | { | ||
294 | int l,c; | ||
295 | if (currentView==0) return; | ||
296 | |||
297 | currentView->getCursorPosition(&l,&c); | ||
298 | |||
299 | CGotoLine g(l); | ||
300 | |||
301 | if(g.exec()==QDialog::Accepted) | ||
302 | { | ||
303 | currentView->setCursorPosition( g.line(), c ); | ||
304 | } | ||
305 | } | ||
306 | |||
307 | void TinyKate::slotCursorMoved() | ||
308 | { | ||
309 | char buf[100]; | ||
310 | int newLine,newCol; | ||
311 | currentView->getCursorPosition(&newLine,&newCol); | ||
312 | newLine++; | ||
313 | newCol++; | ||
314 | if((newLine!=curLine)||(newCol!=curCol)) | ||
315 | { | ||
316 | sprintf(buf,"TinyKATE : line %-6d col %d",newLine,newCol); | ||
317 | setCaption(buf); | ||
318 | curLine=newLine; | ||
319 | curCol=newCol; | ||
320 | } | ||
321 | } | ||