summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/mainwindow/tinykate.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/noncore/apps/tinykate/mainwindow/tinykate.cpp b/noncore/apps/tinykate/mainwindow/tinykate.cpp
index 30c07fc..8d19c71 100644
--- a/noncore/apps/tinykate/mainwindow/tinykate.cpp
+++ b/noncore/apps/tinykate/mainwindow/tinykate.cpp
@@ -101,211 +101,211 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
101 editPaste->setIconSet( Resource::loadPixmap( "paste" ) ); 101 editPaste->setIconSet( Resource::loadPixmap( "paste" ) );
102 102
103 // Action for finding / replacing text 103 // Action for finding / replacing text
104 editFindReplace = new QToolButton( 0 ); 104 editFindReplace = new QToolButton( 0 );
105 editFindReplace->setAutoRaise( true ); 105 editFindReplace->setAutoRaise( true );
106 editFindReplace->setIconSet( Resource::loadPixmap("find") ); 106 editFindReplace->setIconSet( Resource::loadPixmap("find") );
107 107
108 // Action for undo 108 // Action for undo
109 editUndo = new QToolButton( 0 ); 109 editUndo = new QToolButton( 0 );
110 editUndo->setAutoRaise( true ); 110 editUndo->setAutoRaise( true );
111 editUndo->setIconSet( Resource::loadPixmap( "undo" ) ); 111 editUndo->setIconSet( Resource::loadPixmap( "undo" ) );
112 112
113 // Action for redo 113 // Action for redo
114 editRedo = new QToolButton( 0 ); 114 editRedo = new QToolButton( 0 );
115 editRedo->setAutoRaise( true ); 115 editRedo->setAutoRaise( true );
116 editRedo->setIconSet( Resource::loadPixmap( "redo" ) ); 116 editRedo->setIconSet( Resource::loadPixmap( "redo" ) );
117 117
118 //VIEW ACITONS 118 //VIEW ACITONS
119 popup = new QPopupMenu( this ); 119 popup = new QPopupMenu( this );
120 120
121 viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 ); 121 viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 );
122 viewIncFontSizes->addTo( popup ); 122 viewIncFontSizes->addTo( popup );
123 123
124 viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 ); 124 viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 );
125 viewDecFontSizes->addTo( popup ); 125 viewDecFontSizes->addTo( popup );
126 126
127 mb->insertItem(tr("View"),popup); 127 mb->insertItem(tr("View"),popup);
128 128
129 popup = new QPopupMenu( this ); 129 popup = new QPopupMenu( this );
130 mb->insertItem(tr("Utils"),popup); 130 mb->insertItem(tr("Utils"),popup);
131 131
132 132
133 mb->insertItem( editCut ); 133 mb->insertItem( editCut );
134 mb->insertItem( editCopy ); 134 mb->insertItem( editCopy );
135 mb->insertItem( editPaste ); 135 mb->insertItem( editPaste );
136 mb->insertItem( editFindReplace ); 136 mb->insertItem( editFindReplace );
137 mb->insertItem( editUndo ); 137 mb->insertItem( editUndo );
138 mb->insertItem( editRedo ); 138 mb->insertItem( editRedo );
139 139
140 140
141 //Highlight management 141 //Highlight management
142 hlmenu=new QPopupMenu(this); 142 hlmenu=new QPopupMenu(this);
143 HlManager *hlm=HlManager::self(); 143 HlManager *hlm=HlManager::self();
144 for (int i=0;i<hlm->highlights();i++) 144 for (int i=0;i<hlm->highlights();i++)
145 { 145 {
146 hlmenu->insertItem(hlm->hlName(i),i); 146 hlmenu->insertItem(hlm->hlName(i),i);
147 } 147 }
148 popup->insertItem(tr("Highlighting"),hlmenu); 148 popup->insertItem(tr("Highlighting"),hlmenu);
149 149
150 150
151 utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 ); 151 utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 );
152 utilSettings->addTo( popup); 152 utilSettings->addTo( popup);
153 153
154 if( qApp->argc() > 1) open(qApp->argv()[1]); 154 if( qApp->argc() > 1) open(qApp->argv()[1]);
155 else slotNew(); 155 else slotNew();
156 156
157} 157}
158 158
159TinyKate::~TinyKate( ) 159TinyKate::~TinyKate( )
160{ 160{
161 owarn << "TinyKate destructor\n" << oendl; 161 owarn << "TinyKate destructor\n" << oendl;
162 162
163 shutDown=true; 163 shutDown=true;
164 while (currentView!=0) 164 while (currentView!=0)
165 { 165 {
166 slotClose(); 166 slotClose();
167 } 167 }
168 168
169 if( KGlobal::config() != 0 ) 169 if( KGlobal::config() != 0 )
170 { 170 {
171 owarn << "deleting KateConfig object..\n" << oendl; 171 owarn << "deleting KateConfig object..\n" << oendl;
172 delete KGlobal::config(); 172 delete KGlobal::config();
173 } 173 }
174} 174}
175 175
176void TinyKate::slotOpen( ) 176void TinyKate::slotOpen( )
177{ 177{
178 QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, 178 QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
179 QString::null); 179 QString::null);
180 if (!filename.isEmpty()) 180 if (!filename.isEmpty())
181 { 181 {
182 open(filename); 182 open(filename);
183 } 183 }
184} 184}
185 185
186void TinyKate::open(const QString & filename) 186void TinyKate::open(const QString & filename)
187{ 187{
188 KateDocument *kd= new KateDocument(false, false, this,0,this); 188 KateDocument *kd= new KateDocument(false, false, this,0,this);
189 KTextEditor::View *kv; 189 KTextEditor::View *kv;
190 QString realFileName; 190 QString realFileName;
191 //check if filename is a .desktop file 191 //check if filename is a .desktop file
192 if ( filename.find( ".desktop", 0, true ) ) 192 if ( filename.find( ".desktop", 0, true ) )
193 { 193 {
194 switch ( QMessageBox::warning( this, tr( "TinyKATE" ), 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?" ), 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"), 196 tr(".desktop File"),
197 tr("Linked Document"), 0, 1, 1 ) ) 197 tr("Linked Document"), 0, 1, 1 ) )
198 { 198 {
199 case 0: //desktop 199 case 0: //desktop
200 realFileName = filename; 200 realFileName = filename;
201 break; 201 break;
202 case 1: //linked 202 case 1: //linked
203 DocLnk docLnk( filename ); 203 DocLnk docLnk( filename );
204 realFileName = docLnk.file(); 204 realFileName = docLnk.file();
205 break; 205 break;
206 }; 206 };
207 } 207 }
208 208
209 QFileInfo fileInfo( realFileName ); 209 QFileInfo fileInfo( realFileName );
210 QString filenamed = fileInfo.fileName(); 210 QString filenamed = fileInfo.fileName();
211 tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed ); 211 tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed );
212 odebug << realFileName << oendl; 212 odebug << realFileName << oendl;
213 213
214 kd->setDocName( filenamed); 214 kd->setDocName( filenamed);
215 kd->open( realFileName ); 215 kd->open( realFileName );
216 viewCount++; 216 viewCount++;
217} 217}
218 218
219void TinyKate::setDocument(const QString& fileref) 219void TinyKate::setDocument(const QString& fileref)
220{ 220{
221 open( fileref ); 221 open( fileref );
222} 222}
223 223
224void TinyKate::slotCurrentChanged( QWidget * view) 224void TinyKate::slotCurrentChanged( QWidget * view)
225{ 225{
226 if (currentView) 226 if (currentView)
227 { 227 {
228 228
229 disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); 229 disconnect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy()));
230 disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); 230 disconnect(editCut,SIGNAL(clicked()),currentView,SLOT(cut()));
231 disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); 231 disconnect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste()));
232 disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); 232 disconnect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo()));
233 disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); 233 disconnect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo()));
234 disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); 234 disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes()));
235 disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); 235 disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes()));
236 disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); 236 disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int)));
237 disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); 237 disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog()));
238 } 238 }
239 239
240 currentView=(KTextEditor::View*)view; 240 currentView=(KTextEditor::View*)view;
241 241
242 connect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy())); 242 connect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy()));
243 connect(editCut,SIGNAL(clicked()),currentView,SLOT(cut())); 243 connect(editCut,SIGNAL(clicked()),currentView,SLOT(cut()));
244 connect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste())); 244 connect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste()));
245 connect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo())); 245 connect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo()));
246 connect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo())); 246 connect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo()));
247 connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); 247 connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes()));
248 connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); 248 connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes()));
249 connect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); 249 connect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int)));
250 connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); 250 connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog()));
251 251
252} 252}
253 253
254void TinyKate::slotNew( ) 254void TinyKate::slotNew( )
255{ 255{
256 KateDocument *kd= new KateDocument(false, false, this,0,this); 256 KateDocument *kd= new KateDocument(false, false, this,0,this);
257 KTextEditor::View *kv; 257 KTextEditor::View *kv;
258 tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"), 258 tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"),
259 "tinykate/tinykate", 259 "tinykate/tinykate",
260 tr("Unnamed %1").arg(nextUnnamed++)); 260 tr("Unnamed %1").arg(nextUnnamed++));
261 viewCount++; 261 viewCount++;
262} 262}
263 263
264void TinyKate::slotClose( ) 264void TinyKate::slotClose( )
265{ 265{
266 if (currentView==0) return; 266 if (currentView==0) return;
267 KTextEditor::View *dv=currentView; 267 KTextEditor::View *dv=currentView;
268 currentView=0; 268 currentView=0;
269 tabwidget->removePage(dv); 269 tabwidget->removePage(dv);
270 delete dv->document(); 270 delete dv->document();
271 viewCount--; 271 viewCount--;
272 if ((!viewCount) && (!shutDown)) slotNew(); 272 if ((!viewCount) && (!shutDown)) slotNew();
273} 273}
274 274
275void TinyKate::slotSave() 275void TinyKate::slotSave()
276{ 276{
277 // feel free to make this how you want 277 // feel free to make this how you want
278 if (currentView==0) return; 278 if (currentView==0) return;
279 279
280 // KateView *kv = (KateView*) currentView; 280 // KateView *kv = (KateView*) currentView;
281 KateDocument *kd = (KateDocument*) currentView->document(); 281 KateDocument *kd = (KateDocument*) currentView->document();
282 // odebug << "saving file "+kd->docName() << oendl; 282 // odebug << "saving file "+kd->docName() << oendl;
283 if( kd->docName().isEmpty()) 283 if( kd->docName().isEmpty())
284 slotSaveAs(); 284 slotSaveAs();
285 else 285 else
286 kd->saveFile(); 286 kd->saveFile();
287 // kv->save(); 287 // kv->save();
288 // kd->saveFile(); 288 // kd->saveFile();
289} 289}
290 290
291void TinyKate::slotSaveAs() 291void TinyKate::slotSaveAs()
292{ 292{
293 if (currentView==0) return; 293 if (currentView==0) return;
294 KateDocument *kd = (KateDocument*) currentView->document(); 294 KateDocument *kd = (KateDocument*) currentView->document();
295 295
296 QString filename= OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, 296 QString filename= OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL,
297 QString::null); 297 QString::null);
298 if (!filename.isEmpty()) 298 if (!filename.isEmpty())
299 { 299 {
300 odebug << "saving file "+filename << oendl; 300 odebug << "saving file "+filename << oendl;
301 QFileInfo fi(filename); 301 QFileInfo fi(filename);
302 QString filenamed = fi.fileName(); 302 QString filenamed = fi.fileName();
303 kd->setDocFile( filename); 303 kd->setDocFile( filename);
304 kd->setDocName( filenamed); 304 kd->setDocName( filenamed);
305 kd->saveFile(); 305 kd->saveFile();
306 // KTextEditor::View *dv = currentView; 306 // KTextEditor::View *dv = currentView;
307 // tabwidget->changeTab( dv, filenamed); 307 // tabwidget->changeTab( dv, filenamed);
308 // need to change tab label here 308 // need to change tab label here
309 } 309 }
310 310
311} 311}