author | jowenn <jowenn> | 2002-11-22 21:18:23 (UTC) |
---|---|---|
committer | jowenn <jowenn> | 2002-11-22 21:18:23 (UTC) |
commit | 0f9ce3f60b6fbd350f79485ee8fc5fe37be692e1 (patch) (unidiff) | |
tree | a55c913156515ca5a5df95f5a838ecf4a80bae87 /noncore | |
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 | 24 | ||||
-rw-r--r-- | noncore/apps/tinykate/tinykate.h | 9 |
2 files changed, 25 insertions, 8 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 | |||
@@ -20,8 +20,9 @@ | |||
20 | #include <qpe/qpetoolbar.h> | 20 | #include <qpe/qpetoolbar.h> |
21 | #include <qpe/qpemenubar.h> | 21 | #include <qpe/qpemenubar.h> |
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/qpeapplication.h> | ||
24 | 25 | ||
25 | #include <opie/ofiledialog.h> | 26 | #include <opie/ofiledialog.h> |
26 | 27 | ||
27 | #include "tinykate.h" | 28 | #include "tinykate.h" |
@@ -35,10 +36,12 @@ | |||
35 | #include <katehighlight.h> | 36 | #include <katehighlight.h> |
36 | 37 | ||
37 | TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | 38 | TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : |
38 | QMainWindow( parent, name, f ) | 39 | QMainWindow( parent, name, f ) |
39 | { | 40 | { |
41 | nextUnnamed=0; | ||
40 | currentView=0; | 42 | currentView=0; |
43 | viewCount=0; | ||
41 | setCaption(tr("TinyKATE")); | 44 | setCaption(tr("TinyKATE")); |
42 | 45 | ||
43 | setToolBarsMovable(FALSE); | 46 | setToolBarsMovable(FALSE); |
44 | 47 | ||
@@ -136,21 +139,30 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
136 | 139 | ||
137 | utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 ); | 140 | utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 ); |
138 | utilSettings->addTo( popup); | 141 | utilSettings->addTo( popup); |
139 | 142 | ||
143 | if( qApp->argc() > 1) open(qApp->argv()[1]); | ||
144 | else slotNew(); | ||
145 | |||
140 | } | 146 | } |
141 | 147 | ||
142 | 148 | ||
143 | void TinyKate::slotOpen( ) | 149 | void TinyKate::slotOpen( ) |
144 | { | 150 | { |
145 | QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED_ALL); | 151 | QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED_ALL); |
146 | if (!filename.isEmpty()) { | 152 | if (!filename.isEmpty()) { |
153 | open(filename); | ||
154 | } | ||
155 | } | ||
156 | |||
157 | void TinyKate::open(const QString & filename) | ||
158 | { | ||
147 | KateDocument *kd= new KateDocument(false, false, this,0,this); | 159 | KateDocument *kd= new KateDocument(false, false, this,0,this); |
148 | KTextEditor::View *kv; | 160 | KTextEditor::View *kv; |
149 | tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"BLAH","BLAH"); | 161 | tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate","BLAH"); |
150 | qDebug(filename); | 162 | qDebug(filename); |
151 | kd->open(filename); | 163 | kd->open(filename); |
152 | } | 164 | viewCount++; |
153 | } | 165 | } |
154 | 166 | ||
155 | void TinyKate::slotCurrentChanged( QWidget * view) | 167 | void TinyKate::slotCurrentChanged( QWidget * view) |
156 | { | 168 | { |
@@ -183,10 +195,10 @@ void TinyKate::slotCurrentChanged( QWidget * view) | |||
183 | void TinyKate::slotNew( ) | 195 | void TinyKate::slotNew( ) |
184 | { | 196 | { |
185 | KateDocument *kd= new KateDocument(false, false, this,0,this); | 197 | KateDocument *kd= new KateDocument(false, false, this,0,this); |
186 | KTextEditor::View *kv; | 198 | KTextEditor::View *kv; |
187 | tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"),"BLAH",tr("Unnamed %1").arg(0)); | 199 | tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"),"tinykate/tinykate",tr("Unnamed %1").arg(nextUnnamed++)); |
188 | 200 | viewCount++; | |
189 | } | 201 | } |
190 | 202 | ||
191 | void TinyKate::slotClose( ) | 203 | void TinyKate::slotClose( ) |
192 | { | 204 | { |
@@ -194,6 +206,8 @@ void TinyKate::slotClose( ) | |||
194 | KTextEditor::View *dv=currentView; | 206 | KTextEditor::View *dv=currentView; |
195 | currentView=0; | 207 | currentView=0; |
196 | tabwidget->removePage(dv); | 208 | tabwidget->removePage(dv); |
197 | delete dv->document(); | 209 | delete dv->document(); |
210 | viewCount--; | ||
211 | if (!viewCount) slotNew(); | ||
198 | } | 212 | } |
199 | 213 | ||
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 | |||
@@ -32,15 +32,17 @@ Q_OBJECT | |||
32 | public: | 32 | public: |
33 | TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0); | 33 | TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0); |
34 | 34 | ||
35 | public slots: | 35 | public slots: |
36 | void slotOpen(); | 36 | void slotNew(); |
37 | 37 | ||
38 | protected slots: | 38 | protected slots: |
39 | void slotNew(); | 39 | void slotOpen(); |
40 | void slotClose(); | 40 | void slotClose(); |
41 | void slotCurrentChanged(QWidget *); | 41 | void slotCurrentChanged(QWidget *); |
42 | 42 | ||
43 | protected: | ||
44 | void open(const QString&); | ||
43 | private: | 45 | private: |
44 | OTabWidget *tabwidget; | 46 | OTabWidget *tabwidget; |
45 | KTextEditor::View *currentView; | 47 | KTextEditor::View *currentView; |
46 | 48 | ||
@@ -54,9 +56,10 @@ private: | |||
54 | QAction *viewDecFontSizes; | 56 | QAction *viewDecFontSizes; |
55 | QAction *utilSettings; | 57 | QAction *utilSettings; |
56 | 58 | ||
57 | QPopupMenu *hlmenu; | 59 | QPopupMenu *hlmenu; |
58 | 60 | uint nextUnnamed; | |
61 | uint viewCount; | ||
59 | }; | 62 | }; |
60 | 63 | ||
61 | 64 | ||
62 | #endif // __TINYKATE_H__ | 65 | #endif // __TINYKATE_H__ |