-rw-r--r-- | noncore/apps/tinykate/mainwindow/tinykate.cpp | 27 | ||||
-rw-r--r-- | noncore/apps/tinykate/mainwindow/tinykate.h | 4 |
2 files changed, 23 insertions, 8 deletions
diff --git a/noncore/apps/tinykate/mainwindow/tinykate.cpp b/noncore/apps/tinykate/mainwindow/tinykate.cpp index e808a2e..b1b88e9 100644 --- a/noncore/apps/tinykate/mainwindow/tinykate.cpp +++ b/noncore/apps/tinykate/mainwindow/tinykate.cpp | |||
@@ -28,298 +28,313 @@ | |||
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 | #include <qmessagebox.h> |
34 | 34 | ||
35 | 35 | ||
36 | using namespace Opie::Ui; | 36 | using namespace Opie::Ui; |
37 | TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | 37 | TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : |
38 | QMainWindow( parent, name, f ) | 38 | QMainWindow( parent, name, f ) |
39 | { | 39 | { |
40 | shutDown=false; | 40 | shutDown=false; |
41 | nextUnnamed=0; | 41 | nextUnnamed=0; |
42 | currentView=0; | 42 | currentView=0; |
43 | viewCount=0; | 43 | viewCount=0; |
44 | setCaption(tr("TinyKATE")); | 44 | setCaption(tr("TinyKATE")); |
45 | KGlobal::setAppName("TinyKATE"); | 45 | KGlobal::setAppName("TinyKATE"); |
46 | 46 | ||
47 | QMenuBar *mb = new QMenuBar( this ); | 47 | QMenuBar *mb = new QMenuBar( this ); |
48 | mb->setMargin( 0 ); | 48 | mb->setMargin( 0 ); |
49 | 49 | ||
50 | tabwidget=new OTabWidget(this); | 50 | tabwidget=new OTabWidget(this); |
51 | setCentralWidget(tabwidget); | 51 | setCentralWidget(tabwidget); |
52 | connect(tabwidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(slotCurrentChanged(QWidget*))); | 52 | connect(tabwidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(slotCurrentChanged(QWidget*))); |
53 | 53 | ||
54 | //FILE ACTIONS | 54 | //FILE ACTIONS |
55 | QPopupMenu *popup = new QPopupMenu( this ); | 55 | QPopupMenu *popup = new QPopupMenu( this ); |
56 | 56 | ||
57 | // Action for creating a new document | 57 | // Action for creating a new document |
58 | QAction *a = new QAction( tr( "New" ), Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ), | 58 | QAction *a = new QAction( tr( "New" ), Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ), |
59 | QString::null, 0, this, 0 ); | 59 | QString::null, 0, this, 0 ); |
60 | a->addTo( popup ); | 60 | a->addTo( popup ); |
61 | connect(a, SIGNAL(activated()), this, SLOT(slotNew())); | 61 | connect(a, SIGNAL(activated()), this, SLOT(slotNew())); |
62 | 62 | ||
63 | // Action for opening an exisiting document | 63 | // Action for opening an exisiting document |
64 | a = new QAction( tr( "Open" ), Opie::Core::OResource::loadPixmap( "fileopen", Opie::Core::OResource::SmallIcon ), | 64 | a = new QAction( tr( "Open" ), Opie::Core::OResource::loadPixmap( "fileopen", Opie::Core::OResource::SmallIcon ), |
65 | QString::null, 0, this, 0 ); | 65 | QString::null, 0, this, 0 ); |
66 | a->addTo(popup); | 66 | a->addTo(popup); |
67 | connect(a, SIGNAL(activated()), this, SLOT(slotOpen())); | 67 | connect(a, SIGNAL(activated()), this, SLOT(slotOpen())); |
68 | 68 | ||
69 | 69 | ||
70 | // Action for saving document | 70 | // Action for saving document |
71 | a = new QAction( tr( "Save" ), Opie::Core::OResource::loadPixmap( "save", Opie::Core::OResource::SmallIcon ), | 71 | a = new QAction( tr( "Save" ), Opie::Core::OResource::loadPixmap( "save", Opie::Core::OResource::SmallIcon ), |
72 | QString::null, 0, this, 0 ); | 72 | QString::null, 0, this, 0 ); |
73 | a->addTo(popup); | 73 | a->addTo(popup); |
74 | connect(a, SIGNAL(activated()), this, SLOT(slotSave())); | 74 | connect(a, SIGNAL(activated()), this, SLOT(slotSave())); |
75 | 75 | ||
76 | // Action for saving document to a new name | 76 | // Action for saving document to a new name |
77 | a = new QAction( tr( "Save As" ), Opie::Core::OResource::loadPixmap( "save", Opie::Core::OResource::SmallIcon ), | 77 | a = new QAction( tr( "Save As" ), Opie::Core::OResource::loadPixmap( "save", Opie::Core::OResource::SmallIcon ), |
78 | QString::null, 0, this, 0 ); | 78 | 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" ), Opie::Core::OResource::loadPixmap( "quit_icon", Opie::Core::OResource::SmallIcon ), | 83 | a = new QAction( tr( "Close" ), Opie::Core::OResource::loadPixmap( "quit_icon", Opie::Core::OResource::SmallIcon ), |
84 | QString::null, 0, this, 0 ); | 84 | QString::null, 0, this, 0 ); |
85 | a->addTo(popup); | 85 | a->addTo(popup); |
86 | connect(a, SIGNAL(activated()), this, SLOT(slotClose())); | 86 | connect(a, SIGNAL(activated()), this, SLOT(slotClose())); |
87 | 87 | ||
88 | 88 | ||
89 | mb->insertItem(tr("File"),popup); | 89 | mb->insertItem(tr("File"),popup); |
90 | 90 | ||
91 | //EDIT ACTIONS | 91 | //EDIT ACTIONS |
92 | popup = new QPopupMenu( this ); | ||
92 | bool useBigIcon = qApp->desktop()->size().width() > 330; | 93 | bool useBigIcon = qApp->desktop()->size().width() > 330; |
93 | 94 | ||
94 | // Action for cutting text | 95 | // Action for cutting text |
95 | editCut = new QToolButton( 0 ); | 96 | editCut = new QToolButton( 0 ); |
96 | editCut->setUsesBigPixmap( useBigIcon ); | 97 | editCut->setUsesBigPixmap( useBigIcon ); |
97 | editCut->setAutoRaise( true ); | 98 | editCut->setAutoRaise( true ); |
98 | editCut->setIconSet( Opie::Core::OResource::loadPixmap( "cut", Opie::Core::OResource::SmallIcon ) ); | 99 | editCut->setIconSet( Opie::Core::OResource::loadPixmap( "cut", Opie::Core::OResource::SmallIcon ) ); |
99 | 100 | ||
100 | // Action for Copying text | 101 | // Action for Copying text |
101 | editCopy = new QToolButton( 0 ); | 102 | editCopy = new QToolButton( 0 ); |
102 | editCopy->setUsesBigPixmap( useBigIcon ); | 103 | editCopy->setUsesBigPixmap( useBigIcon ); |
103 | editCopy->setAutoRaise( true ); | 104 | editCopy->setAutoRaise( true ); |
104 | editCopy->setIconSet( Opie::Core::OResource::loadPixmap( "copy", Opie::Core::OResource::SmallIcon ) ); | 105 | editCopy->setIconSet( Opie::Core::OResource::loadPixmap( "copy", Opie::Core::OResource::SmallIcon ) ); |
105 | 106 | ||
106 | // Action for pasting text | 107 | // Action for pasting text |
107 | editPaste = new QToolButton( 0 ); | 108 | editPaste = new QToolButton( 0 ); |
108 | editPaste->setUsesBigPixmap( useBigIcon ); | 109 | editPaste->setUsesBigPixmap( useBigIcon ); |
109 | editPaste->setAutoRaise( true ); | 110 | editPaste->setAutoRaise( true ); |
110 | editPaste->setIconSet( Opie::Core::OResource::loadPixmap( "paste", Opie::Core::OResource::SmallIcon ) ); | 111 | editPaste->setIconSet( Opie::Core::OResource::loadPixmap( "paste", Opie::Core::OResource::SmallIcon ) ); |
111 | 112 | ||
112 | // Action for finding / replacing text | 113 | // Action for finding text |
113 | editFindReplace = new QToolButton( 0 ); | 114 | editFind = new QAction( tr( "Find..." ), Opie::Core::OResource::loadPixmap( "find", Opie::Core::OResource::SmallIcon ), |
114 | editFindReplace->setUsesBigPixmap( useBigIcon ); | 115 | QString::null, 0, this, 0 ); |
115 | editFindReplace->setAutoRaise( true ); | 116 | editFind->addTo(popup); |
116 | editFindReplace->setIconSet( Opie::Core::OResource::loadPixmap( "find", Opie::Core::OResource::SmallIcon ) ); | 117 | |
118 | // Action for replacing text | ||
119 | editReplace = new QAction( tr( "Replace..." ), QString::null, 0, this, 0 ); | ||
120 | editReplace->addTo(popup); | ||
121 | |||
122 | // Action for going to a specific line | ||
123 | editGotoLine = new QAction( tr( "Goto Line..." ), QString::null, 0, this, 0 ); | ||
124 | editGotoLine->addTo(popup); | ||
117 | 125 | ||
118 | // Action for undo | 126 | // Action for undo |
119 | editUndo = new QToolButton( 0 ); | 127 | editUndo = new QToolButton( 0 ); |
120 | editUndo->setUsesBigPixmap( useBigIcon ); | 128 | editUndo->setUsesBigPixmap( useBigIcon ); |
121 | editUndo->setAutoRaise( true ); | 129 | editUndo->setAutoRaise( true ); |
122 | editUndo->setIconSet( Opie::Core::OResource::loadPixmap( "undo", Opie::Core::OResource::SmallIcon ) ); | 130 | editUndo->setIconSet( Opie::Core::OResource::loadPixmap( "undo", Opie::Core::OResource::SmallIcon ) ); |
123 | 131 | ||
124 | // Action for redo | 132 | // Action for redo |
125 | editRedo = new QToolButton( 0 ); | 133 | editRedo = new QToolButton( 0 ); |
126 | editRedo->setUsesBigPixmap( useBigIcon ); | 134 | editRedo->setUsesBigPixmap( useBigIcon ); |
127 | editRedo->setAutoRaise( true ); | 135 | editRedo->setAutoRaise( true ); |
128 | editRedo->setIconSet( Opie::Core::OResource::loadPixmap( "redo", Opie::Core::OResource::SmallIcon ) ); | 136 | editRedo->setIconSet( Opie::Core::OResource::loadPixmap( "redo", Opie::Core::OResource::SmallIcon ) ); |
129 | 137 | ||
138 | mb->insertItem(tr("Edit"),popup); | ||
139 | |||
130 | //VIEW ACITONS | 140 | //VIEW ACITONS |
131 | popup = new QPopupMenu( this ); | 141 | popup = new QPopupMenu( this ); |
132 | 142 | ||
133 | viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 ); | 143 | viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 ); |
134 | viewIncFontSizes->addTo( popup ); | 144 | viewIncFontSizes->addTo( popup ); |
135 | 145 | ||
136 | viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 ); | 146 | viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 ); |
137 | viewDecFontSizes->addTo( popup ); | 147 | viewDecFontSizes->addTo( popup ); |
138 | 148 | ||
139 | mb->insertItem(tr("View"),popup); | 149 | mb->insertItem(tr("View"),popup); |
140 | 150 | ||
141 | popup = new QPopupMenu( this ); | 151 | popup = new QPopupMenu( this ); |
142 | mb->insertItem(tr("Utils"),popup); | 152 | mb->insertItem(tr("Utils"),popup); |
143 | 153 | ||
144 | 154 | ||
145 | mb->insertItem( editCut ); | 155 | mb->insertItem( editCut ); |
146 | mb->insertItem( editCopy ); | 156 | mb->insertItem( editCopy ); |
147 | mb->insertItem( editPaste ); | 157 | mb->insertItem( editPaste ); |
148 | mb->insertItem( editFindReplace ); | ||
149 | mb->insertItem( editUndo ); | 158 | mb->insertItem( editUndo ); |
150 | mb->insertItem( editRedo ); | 159 | mb->insertItem( editRedo ); |
151 | 160 | ||
152 | 161 | ||
153 | //Highlight management | 162 | //Highlight management |
154 | hlmenu=new QPopupMenu(this); | 163 | hlmenu=new QPopupMenu(this); |
155 | HlManager *hlm=HlManager::self(); | 164 | HlManager *hlm=HlManager::self(); |
156 | for (int i=0;i<hlm->highlights();i++) | 165 | for (int i=0;i<hlm->highlights();i++) |
157 | { | 166 | { |
158 | hlmenu->insertItem(hlm->hlName(i),i); | 167 | hlmenu->insertItem(hlm->hlName(i),i); |
159 | } | 168 | } |
160 | popup->insertItem(tr("Highlighting"),hlmenu); | 169 | popup->insertItem(tr("Highlighting"),hlmenu); |
161 | 170 | ||
162 | 171 | ||
163 | utilSettings = new QAction( tr( "Settings" ), | 172 | utilSettings = new QAction( tr( "Settings" ), |
164 | Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ), | 173 | Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ), |
165 | QString::null, 0, this, 0 ); | 174 | QString::null, 0, this, 0 ); |
166 | utilSettings->addTo( popup); | 175 | utilSettings->addTo( popup); |
167 | 176 | ||
168 | if( qApp->argc() > 1) open(qApp->argv()[1]); | 177 | if( qApp->argc() > 1) open(qApp->argv()[1]); |
169 | else slotNew(); | 178 | else slotNew(); |
170 | 179 | ||
171 | } | 180 | } |
172 | 181 | ||
173 | TinyKate::~TinyKate( ) | 182 | TinyKate::~TinyKate( ) |
174 | { | 183 | { |
175 | owarn << "TinyKate destructor\n" << oendl; | 184 | owarn << "TinyKate destructor\n" << oendl; |
176 | 185 | ||
177 | shutDown=true; | 186 | shutDown=true; |
178 | while (currentView!=0) | 187 | while (currentView!=0) |
179 | { | 188 | { |
180 | slotClose(); | 189 | slotClose(); |
181 | } | 190 | } |
182 | 191 | ||
183 | if( KGlobal::config() != 0 ) | 192 | if( KGlobal::config() != 0 ) |
184 | { | 193 | { |
185 | owarn << "deleting KateConfig object..\n" << oendl; | 194 | owarn << "deleting KateConfig object..\n" << oendl; |
186 | delete KGlobal::config(); | 195 | delete KGlobal::config(); |
187 | } | 196 | } |
188 | } | 197 | } |
189 | 198 | ||
190 | void TinyKate::slotOpen( ) | 199 | void TinyKate::slotOpen( ) |
191 | { | 200 | { |
192 | QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 201 | QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
193 | QString::null); | 202 | QString::null); |
194 | if (!filename.isEmpty()) | 203 | if (!filename.isEmpty()) |
195 | { | 204 | { |
196 | open(filename); | 205 | open(filename); |
197 | } | 206 | } |
198 | } | 207 | } |
199 | 208 | ||
200 | void TinyKate::open(const QString & filename) | 209 | void TinyKate::open(const QString & filename) |
201 | { | 210 | { |
202 | KateDocument *kd= new KateDocument(false, false, this,0,this); | 211 | KateDocument *kd= new KateDocument(false, false, this,0,this); |
203 | KTextEditor::View *kv; | 212 | KTextEditor::View *kv; |
204 | QString realFileName; | 213 | QString realFileName; |
205 | //check if filename is a .desktop file | 214 | //check if filename is a .desktop file |
206 | if ( filename.find( ".desktop", 0, true ) != -1 ) { | 215 | if ( filename.find( ".desktop", 0, true ) != -1 ) { |
207 | switch ( QMessageBox::warning( this, tr( "TinyKATE" ), | 216 | switch ( QMessageBox::warning( this, tr( "TinyKATE" ), |
208 | tr("TinyKATE has detected<BR>you selected a <B>.desktop</B> file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?" ), | 217 | tr("TinyKATE has detected<BR>you selected a <B>.desktop</B> file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?" ), |
209 | tr(".desktop File"), | 218 | tr(".desktop File"), |
210 | tr("Linked Document"), 0, 1, 1 ) ) | 219 | tr("Linked Document"), 0, 1, 1 ) ) |
211 | { | 220 | { |
212 | case 0: //desktop | 221 | case 0: //desktop |
213 | realFileName = filename; | 222 | realFileName = filename; |
214 | break; | 223 | break; |
215 | case 1: //linked | 224 | case 1: //linked |
216 | DocLnk docLnk( filename ); | 225 | DocLnk docLnk( filename ); |
217 | realFileName = docLnk.file(); | 226 | realFileName = docLnk.file(); |
218 | break; | 227 | break; |
219 | }; | 228 | }; |
220 | } else { | 229 | } else { |
221 | realFileName = filename; | 230 | realFileName = filename; |
222 | } | 231 | } |
223 | 232 | ||
224 | QFileInfo fileInfo( realFileName ); | 233 | QFileInfo fileInfo( realFileName ); |
225 | QString filenamed = fileInfo.fileName(); | 234 | QString filenamed = fileInfo.fileName(); |
226 | tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed ); | 235 | tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed ); |
227 | odebug << realFileName << oendl; | 236 | odebug << realFileName << oendl; |
228 | 237 | ||
229 | kd->setDocName( filenamed); | 238 | kd->setDocName( filenamed); |
230 | kd->open( realFileName ); | 239 | kd->open( realFileName ); |
231 | viewCount++; | 240 | viewCount++; |
232 | } | 241 | } |
233 | 242 | ||
234 | void TinyKate::setDocument(const QString& fileref) | 243 | void TinyKate::setDocument(const QString& fileref) |
235 | { | 244 | { |
236 | open( fileref ); | 245 | open( fileref ); |
237 | } | 246 | } |
238 | 247 | ||
239 | void TinyKate::slotCurrentChanged( QWidget * view) | 248 | void TinyKate::slotCurrentChanged( QWidget * view) |
240 | { | 249 | { |
241 | if (currentView) | 250 | if (currentView) |
242 | { | 251 | { |
243 | 252 | ||
244 | disconnect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy())); | 253 | disconnect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy())); |
245 | disconnect(editCut,SIGNAL(clicked()),currentView,SLOT(cut())); | 254 | disconnect(editCut,SIGNAL(clicked()),currentView,SLOT(cut())); |
246 | disconnect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste())); | 255 | disconnect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste())); |
247 | disconnect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo())); | 256 | disconnect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo())); |
248 | disconnect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo())); | 257 | disconnect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo())); |
258 | disconnect(editFind,SIGNAL(activated()),currentView,SLOT(find())); | ||
259 | disconnect(editReplace,SIGNAL(activated()),currentView,SLOT(replace())); | ||
260 | disconnect(editGotoLine,SIGNAL(activated()),currentView,SLOT(gotoLine())); | ||
249 | disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); | 261 | disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); |
250 | disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); | 262 | disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); |
251 | disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); | 263 | disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); |
252 | disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); | 264 | disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); |
253 | } | 265 | } |
254 | 266 | ||
255 | currentView=(KTextEditor::View*)view; | 267 | currentView=(KTextEditor::View*)view; |
256 | 268 | ||
257 | connect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy())); | 269 | connect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy())); |
258 | connect(editCut,SIGNAL(clicked()),currentView,SLOT(cut())); | 270 | connect(editCut,SIGNAL(clicked()),currentView,SLOT(cut())); |
259 | connect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste())); | 271 | connect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste())); |
260 | connect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo())); | 272 | connect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo())); |
261 | connect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo())); | 273 | connect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo())); |
274 | connect(editFind,SIGNAL(activated()),currentView,SLOT(find())); | ||
275 | connect(editReplace,SIGNAL(activated()),currentView,SLOT(replace())); | ||
276 | connect(editGotoLine,SIGNAL(activated()),currentView,SLOT(gotoLine())); | ||
262 | connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); | 277 | connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); |
263 | connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); | 278 | connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); |
264 | connect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); | 279 | connect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); |
265 | connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); | 280 | connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); |
266 | 281 | ||
267 | } | 282 | } |
268 | 283 | ||
269 | void TinyKate::slotNew( ) | 284 | void TinyKate::slotNew( ) |
270 | { | 285 | { |
271 | KateDocument *kd= new KateDocument(false, false, this,0,this); | 286 | KateDocument *kd= new KateDocument(false, false, this,0,this); |
272 | KTextEditor::View *kv; | 287 | KTextEditor::View *kv; |
273 | tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"), | 288 | tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"), |
274 | "tinykate/tinykate", | 289 | "tinykate/tinykate", |
275 | tr("Unnamed %1").arg(nextUnnamed++)); | 290 | tr("Unnamed %1").arg(nextUnnamed++)); |
276 | viewCount++; | 291 | viewCount++; |
277 | } | 292 | } |
278 | 293 | ||
279 | void TinyKate::slotClose( ) | 294 | void TinyKate::slotClose( ) |
280 | { | 295 | { |
281 | if (currentView==0) return; | 296 | if (currentView==0) return; |
282 | KTextEditor::View *dv=currentView; | 297 | KTextEditor::View *dv=currentView; |
283 | currentView=0; | 298 | currentView=0; |
284 | tabwidget->removePage(dv); | 299 | tabwidget->removePage(dv); |
285 | delete dv->document(); | 300 | delete dv->document(); |
286 | viewCount--; | 301 | viewCount--; |
287 | if ((!viewCount) && (!shutDown)) slotNew(); | 302 | if ((!viewCount) && (!shutDown)) slotNew(); |
288 | } | 303 | } |
289 | 304 | ||
290 | void TinyKate::slotSave() | 305 | void TinyKate::slotSave() |
291 | { | 306 | { |
292 | // feel free to make this how you want | 307 | // feel free to make this how you want |
293 | if (currentView==0) return; | 308 | if (currentView==0) return; |
294 | 309 | ||
295 | // KateView *kv = (KateView*) currentView; | 310 | // KateView *kv = (KateView*) currentView; |
296 | KateDocument *kd = (KateDocument*) currentView->document(); | 311 | KateDocument *kd = (KateDocument*) currentView->document(); |
297 | // odebug << "saving file "+kd->docName() << oendl; | 312 | // odebug << "saving file "+kd->docName() << oendl; |
298 | if( kd->docName().isEmpty()) | 313 | if( kd->docName().isEmpty()) |
299 | slotSaveAs(); | 314 | slotSaveAs(); |
300 | else | 315 | else |
301 | kd->saveFile(); | 316 | kd->saveFile(); |
302 | // kv->save(); | 317 | // kv->save(); |
303 | // kd->saveFile(); | 318 | // kd->saveFile(); |
304 | } | 319 | } |
305 | 320 | ||
306 | void TinyKate::slotSaveAs() | 321 | void TinyKate::slotSaveAs() |
307 | { | 322 | { |
308 | if (currentView==0) return; | 323 | if (currentView==0) return; |
309 | KateDocument *kd = (KateDocument*) currentView->document(); | 324 | KateDocument *kd = (KateDocument*) currentView->document(); |
310 | 325 | ||
311 | QString filename= OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, | 326 | QString filename= OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, |
312 | QString::null); | 327 | QString::null); |
313 | if (!filename.isEmpty()) | 328 | if (!filename.isEmpty()) |
314 | { | 329 | { |
315 | odebug << "saving file "+filename << oendl; | 330 | odebug << "saving file "+filename << oendl; |
316 | QFileInfo fi(filename); | 331 | QFileInfo fi(filename); |
317 | QString filenamed = fi.fileName(); | 332 | QString filenamed = fi.fileName(); |
318 | kd->setDocFile( filename); | 333 | kd->setDocFile( filename); |
319 | kd->setDocName( filenamed); | 334 | kd->setDocName( filenamed); |
320 | kd->saveFile(); | 335 | kd->saveFile(); |
321 | // KTextEditor::View *dv = currentView; | 336 | // KTextEditor::View *dv = currentView; |
322 | // tabwidget->changeTab( dv, filenamed); | 337 | // tabwidget->changeTab( dv, filenamed); |
323 | // need to change tab label here | 338 | // need to change tab label here |
324 | } | 339 | } |
325 | 340 | ||
diff --git a/noncore/apps/tinykate/mainwindow/tinykate.h b/noncore/apps/tinykate/mainwindow/tinykate.h index 8eb344d..6e95d87 100644 --- a/noncore/apps/tinykate/mainwindow/tinykate.h +++ b/noncore/apps/tinykate/mainwindow/tinykate.h | |||
@@ -1,66 +1,66 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | tinykate.h | 2 | tinykate.h |
3 | Tiny KATE mainwindow | 3 | Tiny KATE mainwindow |
4 | ------------------- | 4 | ------------------- |
5 | begin : November 2002 | 5 | begin : November 2002 |
6 | copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> | 6 | copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; 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 * |
13 | * the Free Software Foundation. * | 13 | * the Free Software Foundation. * |
14 | * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * | 14 | * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #ifndef __TINYKATE_H__ | 18 | #ifndef __TINYKATE_H__ |
19 | #define __TINYKATE_H__ | 19 | #define __TINYKATE_H__ |
20 | 20 | ||
21 | 21 | ||
22 | #include <qmainwindow.h> | 22 | #include <qmainwindow.h> |
23 | #include <opie2/otabwidget.h> | 23 | #include <opie2/otabwidget.h> |
24 | #include <ktexteditor.h> | 24 | #include <ktexteditor.h> |
25 | 25 | ||
26 | class QToolButton; | 26 | class QToolButton; |
27 | class QAction; | 27 | class QAction; |
28 | class QPopupMenu; | 28 | class QPopupMenu; |
29 | 29 | ||
30 | class TinyKate : public QMainWindow | 30 | class TinyKate : public QMainWindow |
31 | { | 31 | { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | public: | 33 | public: |
34 | TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0); | 34 | TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0); |
35 | ~TinyKate( ); | 35 | ~TinyKate( ); |
36 | static QString appName() { return QString::fromLatin1( "tinykate" ); }; | 36 | static QString appName() { return QString::fromLatin1( "tinykate" ); }; |
37 | 37 | ||
38 | 38 | ||
39 | public slots: | 39 | public slots: |
40 | void slotNew(); | 40 | void slotNew(); |
41 | void setDocument(const QString& fileref); | 41 | void setDocument(const QString& fileref); |
42 | 42 | ||
43 | protected slots: | 43 | protected slots: |
44 | void slotOpen(); | 44 | void slotOpen(); |
45 | void slotClose(); | 45 | void slotClose(); |
46 | void slotCurrentChanged(QWidget *); | 46 | void slotCurrentChanged(QWidget *); |
47 | void slotSave(); | 47 | void slotSave(); |
48 | void slotSaveAs(); | 48 | void slotSaveAs(); |
49 | protected: | 49 | protected: |
50 | void open(const QString&); | 50 | void open(const QString&); |
51 | private: | 51 | private: |
52 | QString currentFileName; | 52 | QString currentFileName; |
53 | Opie::Ui::OTabWidget *tabwidget; | 53 | Opie::Ui::OTabWidget *tabwidget; |
54 | KTextEditor::View *currentView; | 54 | KTextEditor::View *currentView; |
55 | bool shutDown; | 55 | bool shutDown; |
56 | 56 | ||
57 | QToolButton *editCopy, *editCut, *editPaste, *editUndo, *editRedo, *editFindReplace; | 57 | QToolButton *editCopy, *editCut, *editPaste, *editUndo, *editRedo; |
58 | QAction *viewIncFontSizes, *viewDecFontSizes, *utilSettings; | 58 | QAction *viewIncFontSizes, *viewDecFontSizes, *utilSettings, *editFind, *editReplace, *editGotoLine; |
59 | 59 | ||
60 | QPopupMenu *hlmenu; | 60 | QPopupMenu *hlmenu; |
61 | uint nextUnnamed; | 61 | uint nextUnnamed; |
62 | uint viewCount; | 62 | uint viewCount; |
63 | }; | 63 | }; |
64 | 64 | ||
65 | 65 | ||
66 | #endif // __TINYKATE_H__ | 66 | #endif // __TINYKATE_H__ |