summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/tinykate.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp
index c8c3b31..51afd31 100644
--- a/noncore/apps/tinykate/tinykate.cpp
+++ b/noncore/apps/tinykate/tinykate.cpp
@@ -69,185 +69,188 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
69 connect(a, SIGNAL(activated()), this, SLOT(slotOpen())); 69 connect(a, SIGNAL(activated()), this, SLOT(slotOpen()));
70 70
71 71
72 // Action for saving document 72 // Action for saving document
73 a = new QAction( tr( "Save" ), QPixmap((const char**)file_save_xpm), QString::null, 0, this, 0 ); 73 a = new QAction( tr( "Save" ), QPixmap((const char**)file_save_xpm), QString::null, 0, this, 0 );
74 a->addTo(popup); 74 a->addTo(popup);
75 connect(a, SIGNAL(activated()), this, SLOT(slotSave())); 75 connect(a, SIGNAL(activated()), this, SLOT(slotSave()));
76 76
77 // Action for saving document to a new name 77 // Action for saving document to a new name
78 a = new QAction( tr( "Save As" ), QPixmap((const char**)file_save_xpm), QString::null, 0, this, 0 ); 78 a = new QAction( tr( "Save As" ), QPixmap((const char**)file_save_xpm), QString::null, 0, this, 0 );
79 a->addTo(popup); 79 a->addTo(popup);
80 connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs())); 80 connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs()));
81 81
82 // Action for closing the currently active document 82 // Action for closing the currently active document
83 a = new QAction( tr( "Close" ), QPixmap(), QString::null, 0, this, 0 ); 83 a = new QAction( tr( "Close" ), QPixmap(), QString::null, 0, this, 0 );
84 a->addTo(popup); 84 a->addTo(popup);
85 connect(a, SIGNAL(activated()), this, SLOT(slotClose())); 85 connect(a, SIGNAL(activated()), this, SLOT(slotClose()));
86 86
87 87
88 mb->insertItem(tr("File"),popup); 88 mb->insertItem(tr("File"),popup);
89 89
90//EDIT ACTIONS 90//EDIT ACTIONS
91 91
92 // Action for cutting text 92 // Action for cutting text
93 editCut = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); 93 editCut = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
94 editCut->addTo( bar ); 94 editCut->addTo( bar );
95 95
96 // Action for Copying text 96 // Action for Copying text
97 editCopy = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); 97 editCopy = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 );
98 editCopy->addTo( bar ); 98 editCopy->addTo( bar );
99 99
100 // Action for pasting text 100 // Action for pasting text
101 editPaste = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 101 editPaste = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
102 editPaste->addTo( bar ); 102 editPaste->addTo( bar );
103 103
104 104
105 // Action for finding / replacing text 105 // Action for finding / replacing text
106 editFindReplace = new QAction( tr( "Find/Replace" ), Resource::loadPixmap("find"), QString::null, 0, this, 0 ); 106 editFindReplace = new QAction( tr( "Find/Replace" ), Resource::loadPixmap("find"), QString::null, 0, this, 0 );
107 editFindReplace->addTo( bar ); 107 editFindReplace->addTo( bar );
108 108
109 // Action for undo 109 // Action for undo
110 editUndo = new QAction( tr( "Undo" ), QPixmap((const char**)edit_undo_xpm), QString::null, 0, this, 0 ); 110 editUndo = new QAction( tr( "Undo" ), QPixmap((const char**)edit_undo_xpm), QString::null, 0, this, 0 );
111 editUndo->addTo( bar ); 111 editUndo->addTo( bar );
112 112
113 // Action for redo 113 // Action for redo
114 editRedo = new QAction( tr( "Redo" ), QPixmap((const char**)edit_redo_xpm), QString::null, 0, this, 0 ); 114 editRedo = new QAction( tr( "Redo" ), QPixmap((const char**)edit_redo_xpm), QString::null, 0, this, 0 );
115 editRedo->addTo( bar ); 115 editRedo->addTo( bar );
116 116
117//VIEW ACITONS 117//VIEW ACITONS
118 popup = new QPopupMenu( this ); 118 popup = new QPopupMenu( this );
119 119
120 viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 ); 120 viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 );
121 viewIncFontSizes->addTo( popup ); 121 viewIncFontSizes->addTo( popup );
122 122
123 viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 ); 123 viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 );
124 viewDecFontSizes->addTo( popup ); 124 viewDecFontSizes->addTo( popup );
125 125
126 mb->insertItem(tr("View"),popup); 126 mb->insertItem(tr("View"),popup);
127 127
128 128
129 129
130 popup = new QPopupMenu( this ); 130 popup = new QPopupMenu( this );
131 mb->insertItem(tr("Utils"),popup); 131 mb->insertItem(tr("Utils"),popup);
132 132
133//Highlight management 133//Highlight management
134 hlmenu=new QPopupMenu(this); 134 hlmenu=new QPopupMenu(this);
135 HlManager *hlm=HlManager::self(); 135 HlManager *hlm=HlManager::self();
136 for (int i=0;i<hlm->highlights();i++) 136 for (int i=0;i<hlm->highlights();i++)
137 { 137 {
138 hlmenu->insertItem(hlm->hlName(i),i); 138 hlmenu->insertItem(hlm->hlName(i),i);
139 } 139 }
140 popup->insertItem(tr("Highlighting"),hlmenu); 140 popup->insertItem(tr("Highlighting"),hlmenu);
141 141
142 142
143 utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 ); 143 utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 );
144 utilSettings->addTo( popup); 144 utilSettings->addTo( popup);
145 145
146 if( qApp->argc() > 1) open(qApp->argv()[1]); 146 if( qApp->argc() > 1) open(qApp->argv()[1]);
147 else slotNew(); 147 else slotNew();
148 148
149} 149}
150 150
151 151
152void TinyKate::slotOpen( ) 152void TinyKate::slotOpen( )
153{ 153{
154 QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED_ALL); 154 QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED_ALL);
155 if (!filename.isEmpty()) { 155 if (!filename.isEmpty()) {
156 open(filename); 156 open(filename);
157 } 157 }
158} 158}
159 159
160void TinyKate::open(const QString & filename) 160void TinyKate::open(const QString & filename)
161{ 161{
162 KateDocument *kd= new KateDocument(false, false, this,0,this); 162 KateDocument *kd= new KateDocument(false, false, this,0,this);
163 KTextEditor::View *kv; 163 KTextEditor::View *kv;
164 QFileInfo fi(filename); 164 QFileInfo fi(filename);
165 tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate",fi.fileName()); 165 QString filenamed = fi.fileName();
166 tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed );
166 qDebug(filename); 167 qDebug(filename);
168
169 kd->setDocName( filenamed);
167 kd->open(filename); 170 kd->open(filename);
168 viewCount++; 171 viewCount++;
169} 172}
170 173
171void TinyKate::slotCurrentChanged( QWidget * view) 174void TinyKate::slotCurrentChanged( QWidget * view)
172{ 175{
173 if (currentView) { 176 if (currentView) {
174 177
175 disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); 178 disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy()));
176 disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); 179 disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut()));
177 disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); 180 disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste()));
178 disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); 181 disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo()));
179 disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); 182 disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo()));
180 disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); 183 disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes()));
181 disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); 184 disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes()));
182 disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); 185 disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int)));
183 disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); 186 disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog()));
184 } 187 }
185 188
186 currentView=(KTextEditor::View*)view; 189 currentView=(KTextEditor::View*)view;
187 190
188 connect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); 191 connect(editCopy,SIGNAL(activated()),currentView,SLOT(copy()));
189 connect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); 192 connect(editCut,SIGNAL(activated()),currentView,SLOT(cut()));
190 connect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); 193 connect(editPaste,SIGNAL(activated()),currentView,SLOT(paste()));
191 connect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); 194 connect(editUndo,SIGNAL(activated()),currentView,SLOT(undo()));
192 connect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); 195 connect(editRedo,SIGNAL(activated()),currentView,SLOT(redo()));
193 connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); 196 connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes()));
194 connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); 197 connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes()));
195 connect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); 198 connect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int)));
196 connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); 199 connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog()));
197 200
198} 201}
199 202
200void TinyKate::slotNew( ) 203void TinyKate::slotNew( )
201{ 204{
202 KateDocument *kd= new KateDocument(false, false, this,0,this); 205 KateDocument *kd= new KateDocument(false, false, this,0,this);
203 KTextEditor::View *kv; 206 KTextEditor::View *kv;
204 tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"), 207 tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"),
205 "tinykate/tinykate", 208 "tinykate/tinykate",
206 tr("Unnamed %1").arg(nextUnnamed++)); 209 tr("Unnamed %1").arg(nextUnnamed++));
207 viewCount++; 210 viewCount++;
208} 211}
209 212
210void TinyKate::slotClose( ) 213void TinyKate::slotClose( )
211{ 214{
212 if (currentView==0) return; 215 if (currentView==0) return;
213 KTextEditor::View *dv=currentView; 216 KTextEditor::View *dv=currentView;
214 currentView=0; 217 currentView=0;
215 tabwidget->removePage(dv); 218 tabwidget->removePage(dv);
216 delete dv->document(); 219 delete dv->document();
217 viewCount--; 220 viewCount--;
218 if (!viewCount) slotNew(); 221 if (!viewCount) slotNew();
219} 222}
220 223
221void TinyKate::slotSave() { 224void TinyKate::slotSave() {
222 // feel free to make this how you want 225 // feel free to make this how you want
223 if (currentView==0) return; 226 if (currentView==0) return;
224 227
225 // KateView *kv = (KateView*) currentView; 228 // KateView *kv = (KateView*) currentView;
226 KateDocument *kd = (KateDocument*) currentView->document(); 229 KateDocument *kd = (KateDocument*) currentView->document();
227 // qDebug("saving file "+kd->docName()); 230 // qDebug("saving file "+kd->docName());
228 if( kd->docName().isEmpty()) 231 if( kd->docName().isEmpty())
229 slotSaveAs(); 232 slotSaveAs();
230 else 233 else
231 kd->saveFile(); 234 kd->saveFile();
232 // kv->save(); 235 // kv->save();
233 // kd->saveFile(); 236 // kd->saveFile();
234} 237}
235 238
236void TinyKate::slotSaveAs() { 239void TinyKate::slotSaveAs() {
237 if (currentView==0) return; 240 if (currentView==0) return;
238 KateDocument *kd = (KateDocument*) currentView->document(); 241 KateDocument *kd = (KateDocument*) currentView->document();
239 242
240 QString filename=OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL); 243 QString filename=OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL);
241 if (!filename.isEmpty()) { 244 if (!filename.isEmpty()) {
242 qDebug("saving file "+filename); 245 qDebug("saving file "+filename);
243 QFileInfo fi(filename); 246 QFileInfo fi(filename);
244 QString filenamed = fi.fileName(); 247 QString filenamed = fi.fileName();
245 kd->setDocFile( filename); 248 kd->setDocFile( filename);
246 kd->setDocName( filenamed); 249 kd->setDocName( filenamed);
247 kd->saveFile(); 250 kd->saveFile();
248// KTextEditor::View *dv = currentView; 251// KTextEditor::View *dv = currentView;
249// tabwidget->changeTab( dv, filenamed); 252// tabwidget->changeTab( dv, filenamed);
250 // need to change tab label here 253 // need to change tab label here
251 } 254 }
252 255
253} 256}