summaryrefslogtreecommitdiff
authorpaule <paule>2007-01-13 07:12:11 (UTC)
committer paule <paule>2007-01-13 07:12:11 (UTC)
commitbccf96bb5b516d05df54dbcee8b8402ded815ed4 (patch) (unidiff)
tree9de5251a1a34321c9fcd41bc2b5b408244ff6135
parentc0eb83f37ec3c49d0c6b322840605f2a95ea0b52 (diff)
downloadopie-bccf96bb5b516d05df54dbcee8b8402ded815ed4.zip
opie-bccf96bb5b516d05df54dbcee8b8402ded815ed4.tar.gz
opie-bccf96bb5b516d05df54dbcee8b8402ded815ed4.tar.bz2
Add Edit menu with find, replace & go to line functions. Uses dialogs/code already provided by libkate.
Fixes bug #1231.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/mainwindow/tinykate.cpp27
-rw-r--r--noncore/apps/tinykate/mainwindow/tinykate.h4
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
@@ -80,81 +80,90 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
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);
@@ -237,37 +246,43 @@ void TinyKate::setDocument(const QString& fileref)
237} 246}
238 247
239void TinyKate::slotCurrentChanged( QWidget * view) 248void 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
269void TinyKate::slotNew( ) 284void 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"),
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
@@ -45,22 +45,22 @@ protected slots:
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();
49protected: 49protected:
50 void open(const QString&); 50 void open(const QString&);
51private: 51private:
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__