author | ar <ar> | 2004-06-20 21:17:00 (UTC) |
---|---|---|
committer | ar <ar> | 2004-06-20 21:17:00 (UTC) |
commit | 526031c34fff4e789b05fddbd7effe83ef057361 (patch) (unidiff) | |
tree | 23146566d3d27ba9648d5a8e0500d6b41c6ac9f9 | |
parent | f12be4d4ffaf6b5542b270c7d18fbb7141711309 (diff) | |
download | opie-526031c34fff4e789b05fddbd7effe83ef057361.zip opie-526031c34fff4e789b05fddbd7effe83ef057361.tar.gz opie-526031c34fff4e789b05fddbd7effe83ef057361.tar.bz2 |
- BUGFIX: 0001291 - opie tinykate does not open .desktop files
-rw-r--r-- | noncore/apps/tinykate/mainwindow/tinykate.cpp | 49 | ||||
-rw-r--r-- | noncore/apps/tinykate/mainwindow/tinykate.h | 0 |
2 files changed, 38 insertions, 11 deletions
diff --git a/noncore/apps/tinykate/mainwindow/tinykate.cpp b/noncore/apps/tinykate/mainwindow/tinykate.cpp index 9865c35..30c07fc 100644 --- a/noncore/apps/tinykate/mainwindow/tinykate.cpp +++ b/noncore/apps/tinykate/mainwindow/tinykate.cpp | |||
@@ -21,24 +21,25 @@ | |||
21 | #include "kglobal.h" | 21 | #include "kglobal.h" |
22 | 22 | ||
23 | /* OPIE */ | 23 | /* OPIE */ |
24 | #include <opie2/odebug.h> | 24 | #include <opie2/odebug.h> |
25 | #include <opie2/ofiledialog.h> | 25 | #include <opie2/ofiledialog.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | 28 | ||
29 | /* QT */ | 29 | /* QT */ |
30 | #include <qaction.h> | 30 | #include <qaction.h> |
31 | #include <qtoolbutton.h> | 31 | #include <qtoolbutton.h> |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | #include <qmessagebox.h> | ||
33 | 34 | ||
34 | 35 | ||
35 | using namespace Opie::Ui; | 36 | using namespace Opie::Ui; |
36 | TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | 37 | TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : |
37 | QMainWindow( parent, name, f ) | 38 | QMainWindow( parent, name, f ) |
38 | { | 39 | { |
39 | shutDown=false; | 40 | shutDown=false; |
40 | nextUnnamed=0; | 41 | nextUnnamed=0; |
41 | currentView=0; | 42 | currentView=0; |
42 | viewCount=0; | 43 | viewCount=0; |
43 | setCaption(tr("TinyKATE")); | 44 | setCaption(tr("TinyKATE")); |
44 | KGlobal::setAppName("TinyKATE"); | 45 | KGlobal::setAppName("TinyKATE"); |
@@ -151,65 +152,88 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
151 | utilSettings->addTo( popup); | 152 | utilSettings->addTo( popup); |
152 | 153 | ||
153 | if( qApp->argc() > 1) open(qApp->argv()[1]); | 154 | if( qApp->argc() > 1) open(qApp->argv()[1]); |
154 | else slotNew(); | 155 | else slotNew(); |
155 | 156 | ||
156 | } | 157 | } |
157 | 158 | ||
158 | TinyKate::~TinyKate( ) | 159 | TinyKate::~TinyKate( ) |
159 | { | 160 | { |
160 | owarn << "TinyKate destructor\n" << oendl; | 161 | owarn << "TinyKate destructor\n" << oendl; |
161 | 162 | ||
162 | shutDown=true; | 163 | shutDown=true; |
163 | while (currentView!=0) { | 164 | while (currentView!=0) |
165 | { | ||
164 | slotClose(); | 166 | slotClose(); |
165 | } | 167 | } |
166 | 168 | ||
167 | if( KGlobal::config() != 0 ) { | 169 | if( KGlobal::config() != 0 ) |
170 | { | ||
168 | owarn << "deleting KateConfig object..\n" << oendl; | 171 | owarn << "deleting KateConfig object..\n" << oendl; |
169 | delete KGlobal::config(); | 172 | delete KGlobal::config(); |
170 | } | 173 | } |
171 | } | 174 | } |
172 | 175 | ||
173 | void TinyKate::slotOpen( ) | 176 | void TinyKate::slotOpen( ) |
174 | { | 177 | { |
175 | QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 178 | QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
176 | QString::null); | 179 | QString::null); |
177 | if (!filename.isEmpty()) { | 180 | if (!filename.isEmpty()) |
181 | { | ||
178 | open(filename); | 182 | open(filename); |
179 | } | 183 | } |
180 | } | 184 | } |
181 | 185 | ||
182 | void TinyKate::open(const QString & filename) | 186 | void TinyKate::open(const QString & filename) |
183 | { | 187 | { |
184 | KateDocument *kd= new KateDocument(false, false, this,0,this); | 188 | KateDocument *kd= new KateDocument(false, false, this,0,this); |
185 | KTextEditor::View *kv; | 189 | KTextEditor::View *kv; |
186 | QFileInfo fi(filename); | 190 | QString realFileName; |
187 | QString filenamed = fi.fileName(); | 191 | //check if filename is a .desktop file |
192 | if ( filename.find( ".desktop", 0, true ) ) | ||
193 | { | ||
194 | switch ( QMessageBox::warning( this, tr( "TinyKATE" ), | ||
195 | tr("TinyKATE has detected<BR>you selected a <B>.desktop</B> file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?" ), | ||
196 | tr(".desktop File"), | ||
197 | tr("Linked Document"), 0, 1, 1 ) ) | ||
198 | { | ||
199 | case 0: //desktop | ||
200 | realFileName = filename; | ||
201 | break; | ||
202 | case 1: //linked | ||
203 | DocLnk docLnk( filename ); | ||
204 | realFileName = docLnk.file(); | ||
205 | break; | ||
206 | }; | ||
207 | } | ||
208 | |||
209 | QFileInfo fileInfo( realFileName ); | ||
210 | QString filenamed = fileInfo.fileName(); | ||
188 | tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed ); | 211 | tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed ); |
189 | odebug << filename << oendl; | 212 | odebug << realFileName << oendl; |
190 | 213 | ||
191 | kd->setDocName( filenamed); | 214 | kd->setDocName( filenamed); |
192 | kd->open( filename ); | 215 | kd->open( realFileName ); |
193 | viewCount++; | 216 | viewCount++; |
194 | } | 217 | } |
195 | 218 | ||
196 | void TinyKate::setDocument(const QString& fileref) | 219 | void TinyKate::setDocument(const QString& fileref) |
197 | { | 220 | { |
198 | open( fileref ); | 221 | open( fileref ); |
199 | } | 222 | } |
200 | 223 | ||
201 | void TinyKate::slotCurrentChanged( QWidget * view) | 224 | void TinyKate::slotCurrentChanged( QWidget * view) |
202 | { | 225 | { |
203 | if (currentView) { | 226 | if (currentView) |
227 | { | ||
204 | 228 | ||
205 | disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); | 229 | disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); |
206 | disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); | 230 | disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); |
207 | disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); | 231 | disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); |
208 | disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); | 232 | disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); |
209 | disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); | 233 | disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); |
210 | disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); | 234 | disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); |
211 | disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); | 235 | disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); |
212 | disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); | 236 | disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); |
213 | disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); | 237 | disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); |
214 | } | 238 | } |
215 | 239 | ||
@@ -239,46 +263,49 @@ void TinyKate::slotNew( ) | |||
239 | 263 | ||
240 | void TinyKate::slotClose( ) | 264 | void TinyKate::slotClose( ) |
241 | { | 265 | { |
242 | if (currentView==0) return; | 266 | if (currentView==0) return; |
243 | KTextEditor::View *dv=currentView; | 267 | KTextEditor::View *dv=currentView; |
244 | currentView=0; | 268 | currentView=0; |
245 | tabwidget->removePage(dv); | 269 | tabwidget->removePage(dv); |
246 | delete dv->document(); | 270 | delete dv->document(); |
247 | viewCount--; | 271 | viewCount--; |
248 | if ((!viewCount) && (!shutDown)) slotNew(); | 272 | if ((!viewCount) && (!shutDown)) slotNew(); |
249 | } | 273 | } |
250 | 274 | ||
251 | void TinyKate::slotSave() { | 275 | void TinyKate::slotSave() |
276 | { | ||
252 | // feel free to make this how you want | 277 | // feel free to make this how you want |
253 | if (currentView==0) return; | 278 | if (currentView==0) return; |
254 | 279 | ||
255 | // KateView *kv = (KateView*) currentView; | 280 | // KateView *kv = (KateView*) currentView; |
256 | KateDocument *kd = (KateDocument*) currentView->document(); | 281 | KateDocument *kd = (KateDocument*) currentView->document(); |
257 | // odebug << "saving file "+kd->docName() << oendl; | 282 | // odebug << "saving file "+kd->docName() << oendl; |
258 | if( kd->docName().isEmpty()) | 283 | if( kd->docName().isEmpty()) |
259 | slotSaveAs(); | 284 | slotSaveAs(); |
260 | else | 285 | else |
261 | kd->saveFile(); | 286 | kd->saveFile(); |
262 | // kv->save(); | 287 | // kv->save(); |
263 | // kd->saveFile(); | 288 | // kd->saveFile(); |
264 | } | 289 | } |
265 | 290 | ||
266 | void TinyKate::slotSaveAs() { | 291 | void TinyKate::slotSaveAs() |
292 | { | ||
267 | if (currentView==0) return; | 293 | if (currentView==0) return; |
268 | KateDocument *kd = (KateDocument*) currentView->document(); | 294 | KateDocument *kd = (KateDocument*) currentView->document(); |
269 | 295 | ||
270 | QString filename= OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, | 296 | QString filename= OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, |
271 | QString::null); | 297 | QString::null); |
272 | if (!filename.isEmpty()) { | 298 | if (!filename.isEmpty()) |
299 | { | ||
273 | odebug << "saving file "+filename << oendl; | 300 | odebug << "saving file "+filename << oendl; |
274 | QFileInfo fi(filename); | 301 | QFileInfo fi(filename); |
275 | QString filenamed = fi.fileName(); | 302 | QString filenamed = fi.fileName(); |
276 | kd->setDocFile( filename); | 303 | kd->setDocFile( filename); |
277 | kd->setDocName( filenamed); | 304 | kd->setDocName( filenamed); |
278 | kd->saveFile(); | 305 | kd->saveFile(); |
279 | // KTextEditor::View *dv = currentView; | 306 | // KTextEditor::View *dv = currentView; |
280 | // tabwidget->changeTab( dv, filenamed); | 307 | // tabwidget->changeTab( dv, filenamed); |
281 | // need to change tab label here | 308 | // need to change tab label here |
282 | } | 309 | } |
283 | 310 | ||
284 | } | 311 | } |
diff --git a/noncore/apps/tinykate/mainwindow/tinykate.h b/noncore/apps/tinykate/mainwindow/tinykate.h index f435c03..f630f62 100644 --- a/noncore/apps/tinykate/mainwindow/tinykate.h +++ b/noncore/apps/tinykate/mainwindow/tinykate.h | |||