• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • KDevelop Generic Shell
 

KDevelop Generic Shell

  • src
mainwindowshare.cpp
1/***************************************************************************
2 mainwindowshare.cpp - shared stuff of the main widgets
3 -------------------
4 begin : 19 Dec 2002
5 copyright : (C) 2002 by Falk Brettschneider
6 email : falk@kdevelop.org
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
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 *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include <tqcheckbox.h>
19#include <tqvbox.h>
20#include <tqbuttongroup.h>
21#include <tqradiobutton.h>
22#include <tqdir.h>
23#include <tqregexp.h>
24
25#include <kxmlguiclient.h>
26#include <tdeaction.h>
27#include <tdeaboutdata.h>
28#include <kstdaction.h>
29#include <tdeapplication.h>
30#include <tdelocale.h>
31#include <kstatusbar.h>
32#include <tdeparts/mainwindow.h>
33#include <kdialogbase.h>
34#include <tdeconfig.h>
35#include <kkeydialog.h>
36#include <tdemenubar.h>
37#include <kedittoolbar.h>
38#include <kbugreport.h>
39#include <kurlrequester.h>
40#include <tdepopupmenu.h>
41#include <kiconloader.h>
42
43#include <tdetexteditor/document.h>
44#include <tdetexteditor/view.h>
45#include <tdetexteditor/configinterface.h>
46#include <tdeparts/partmanager.h>
47#include <tdeversion.h>
48#include <kdebug.h>
49#include <knotifydialog.h>
50
51
52#include <config.h>
53
54#include "partcontroller.h"
55#include "projectmanager.h"
56#include "core.h"
57#include "api.h"
58#include "kdevmakefrontend.h"
59#include "toplevel.h"
60#include "plugincontroller.h"
61
62#include "kdevplugininfo.h"
63
64#include "mainwindowshare.h"
65
66#include "shellextension.h"
67
68using namespace MainWindowUtils;
69
70MainWindowShare::MainWindowShare(TQObject* pParent, const char* name)
71 :TQObject(pParent, name)
72 ,m_toggleMainToolbar(0L)
73 ,m_toggleBuildToolbar(0L)
74 ,m_toggleViewToolbar(0L)
75 ,m_toggleBrowserToolbar(0L)
76 ,m_toggleStatusbar(0L)
77 ,m_stopProcesses(0L)
78{
79 m_pMainWnd = (KParts::MainWindow*)pParent;
80}
81
82void MainWindowShare::init()
83{
84 connect(Core::getInstance(), TQ_SIGNAL(contextMenu(TQPopupMenu *, const Context *)),
85 this, TQ_SLOT(contextMenu(TQPopupMenu *, const Context *)));
86
87 connect( m_pMainWnd->actionCollection(), TQ_SIGNAL( actionStatusText( const TQString & ) ),
88 this, TQ_SLOT( slotActionStatusText( const TQString & ) ) );
89}
90
91void MainWindowShare::slotActionStatusText( const TQString &text )
92{
93// kdDebug(9000) << "MainWindowShare::slotActionStatusText() - " << text << endl;
94
95 if ( ! m_pMainWnd ) return;
96
97 KStatusBar * statusBar = m_pMainWnd->statusBar();
98
99 if ( ! statusBar ) return;
100
101 statusBar->message( text );
102}
103
104void MainWindowShare::createActions()
105{
106 ProjectManager::getInstance()->createActions( m_pMainWnd->actionCollection() );
107
108 KStdAction::quit(this->parent(), TQ_SLOT(close()), m_pMainWnd->actionCollection());
109
110 TDEAction* action;
111
112 m_stopProcesses = new TDEToolBarPopupAction( i18n( "&Stop" ), "process-stop",
113 Key_Escape, this, TQ_SLOT(slotStopButtonPressed()),
114 m_pMainWnd->actionCollection(), "stop_processes" );
115 m_stopProcesses->setToolTip(i18n("Stop"));
116 m_stopProcesses->setWhatsThis(i18n("<b>Stop</b><p>Stops all running processes (like building process, grep command, etc.). When placed onto a toolbar provides a popup menu to choose a process to stop."));
117 m_stopProcesses->setEnabled( false );
118 connect(m_stopProcesses->popupMenu(), TQ_SIGNAL(aboutToShow()),
119 this, TQ_SLOT(slotStopMenuAboutToShow()));
120 connect(m_stopProcesses->popupMenu(), TQ_SIGNAL(activated(int)),
121 this, TQ_SLOT(slotStopPopupActivated(int)));
122
123 connect( Core::getInstance(), TQ_SIGNAL(activeProcessChanged(KDevPlugin*, bool)),
124 this, TQ_SLOT(slotActiveProcessChanged(KDevPlugin*, bool)) );
125
126 action = KStdAction::showMenubar(
127 this, TQ_SLOT(slotShowMenuBar()),
128 m_pMainWnd->actionCollection(), "settings_show_menubar" );
129 action->setToolTip(beautifyToolTip(action->text()));
130 action->setWhatsThis(TQString("<b>%1</b><p>%2").arg(beautifyToolTip(action->text())).arg(i18n("Lets you switch the menubar on/off.")));
131
132 action = KStdAction::keyBindings(
133 this, TQ_SLOT(slotKeyBindings()),
134 m_pMainWnd->actionCollection(), "settings_configure_shortcuts" );
135 action->setToolTip(beautifyToolTip(action->text()));
136 action->setWhatsThis(TQString("<b>%1</b><p>%2").arg(beautifyToolTip(action->text())).arg(i18n("Lets you configure shortcut keys.")));
137
138 action = KStdAction::configureToolbars(
139 this, TQ_SLOT(slotConfigureToolbars()),
140 m_pMainWnd->actionCollection(), "settings_configure_toolbars" );
141 action->setToolTip(beautifyToolTip(action->text()));
142 action->setWhatsThis(TQString("<b>%1</b><p>%2").arg(beautifyToolTip(action->text())).arg(i18n("Lets you configure toolbars.")));
143
144 action = KStdAction::configureNotifications(
145 this, TQ_SLOT(slotConfigureNotifications()),
146 m_pMainWnd->actionCollection(), "settings_configure_notifications" );
147 action->setToolTip(beautifyToolTip(action->text()));
148 action->setWhatsThis(TQString("<b>%1</b><p>%2").arg(beautifyToolTip(action->text())).arg(i18n("Lets you configure system notifications.")));
149
150 action = KStdAction::preferences(this, TQ_SLOT(slotSettings()),
151 m_pMainWnd->actionCollection(), "settings_configure" );
152 action->setToolTip( i18n( "Configure TDevelop" ) );
153 action->setWhatsThis(TQString("<b>%1</b><p>%2").arg(i18n( "Configure TDevelop" )).arg(i18n("Lets you customize TDevelop.")));
154
155 m_toggleStatusbar = KStdAction::showToolbar(this, TQ_SLOT(slotToggleStatusbar()),m_pMainWnd->actionCollection(), "settings_statusbar");
156 m_toggleStatusbar->setText(i18n("Show &Statusbar"));
157 m_toggleStatusbar->setToolTip( i18n("Show statusbar") );
158 m_toggleStatusbar->setWhatsThis(i18n("<b>Show statusbar</b><p>Hides or shows the statusbar."));
159
160 action = new TDEAction( i18n("&Next Window"), ALT+Key_Right, this, TQ_SIGNAL(gotoNextWindow()),m_pMainWnd->actionCollection(), "view_next_window");
161 action->setToolTip( i18n("Next window") );
162 action->setWhatsThis(i18n("<b>Next window</b><p>Switches to the next window."));
163
164 action = new TDEAction( i18n("&Previous Window"), ALT+Key_Left, this, TQ_SIGNAL(gotoPreviousWindow()),m_pMainWnd->actionCollection(), "view_previous_window");
165 action->setToolTip( i18n("Previous window") );
166 action->setWhatsThis(i18n("<b>Previous window</b><p>Switches to the previous window."));
167
168 action = new TDEAction( i18n("&Last Accessed Window"), ALT+Key_Up, this, TQ_SIGNAL(gotoLastWindow()), m_pMainWnd->actionCollection(), "view_last_window");
169 action->setToolTip( i18n("Last accessed window") );
170 action->setWhatsThis(i18n("<b>Last accessed window</b><p>Switches to the last viewed window (Hold the Alt key pressed and walk on by repeating the Up key)."));
171
172 action = new TDEAction( i18n("&First Accessed Window"), ALT+Key_Down, this, TQ_SIGNAL(gotoFirstWindow()), m_pMainWnd->actionCollection(), "view_first_window");
173 action->setToolTip( i18n("First accessed window") );
174 action->setWhatsThis(i18n("<b>First accessed window</b><p>Switches to the first accessed window (Hold the Alt key pressed and walk on by repeating the Down key)."));
175
176 action = new TDEAction( i18n("Configure Plugins..."), SmallIconSet("configure"), 0, PluginController::getInstance(), TQ_SLOT(selectPlugins()), m_pMainWnd->actionCollection(), "settings_configure_plugins" );
177
178 m_configureEditorAction = new TDEAction( i18n("Configure &Editor..."), SmallIconSet("configure"), 0, this, TQ_SLOT( slotConfigureEditors() ), m_pMainWnd->actionCollection(), "settings_configure_editors");
179 m_configureEditorAction->setToolTip( i18n("Configure editor settings") );
180 m_configureEditorAction->setWhatsThis(i18n("<b>Configure editor</b><p>Opens editor configuration dialog."));
181 m_configureEditorAction->setEnabled( false );
182
183 KDevPartController * partController = API::getInstance()->partController();
184 connect( partController, TQ_SIGNAL(activePartChanged(KParts::Part*)), this, TQ_SLOT(slotActivePartChanged(KParts::Part* )) );
185}
186
187void MainWindowShare::slotReportBug()
188{
189 KBugReport a(m_pMainWnd, true, TDEGlobal::instance()->aboutData() );
190 a.exec();
191}
192
193void MainWindowShare::slotToggleMainToolbar()
194{
195 if (m_toggleMainToolbar->isChecked())
196 m_pMainWnd->toolBar("mainToolBar")->show();
197 else
198 m_pMainWnd->toolBar("mainToolBar")->hide();
199}
200
201void MainWindowShare::slotToggleBuildToolbar()
202{
203 if (m_toggleBuildToolbar->isChecked())
204 m_pMainWnd->toolBar("buildToolBar")->show();
205 else
206 m_pMainWnd->toolBar("buildToolBar")->hide();
207}
208
209void MainWindowShare::slotToggleViewToolbar()
210{
211 if (m_toggleViewToolbar->isChecked())
212 m_pMainWnd->toolBar("viewToolBar")->show();
213 else
214 m_pMainWnd->toolBar("viewToolBar")->hide();
215}
216
217void MainWindowShare::slotToggleBrowserToolbar()
218{
219 if (m_toggleBrowserToolbar->isChecked())
220 m_pMainWnd->toolBar("browserToolBar")->show();
221 else
222 m_pMainWnd->toolBar("browserToolBar")->hide();
223}
224
225void MainWindowShare::slotToggleStatusbar()
226{
227 KStatusBar* sb = (KStatusBar*) m_pMainWnd->statusBar();
228 if (m_toggleStatusbar->isChecked())
229 sb->show();
230 else
231 sb->hide();
232}
233
234void MainWindowShare::slotStopButtonPressed()
235{
236 Core::getInstance()->doEmitStopButtonPressed();
237}
238
239void MainWindowShare::slotActiveProcessChanged( KDevPlugin* plugin, bool active )
240{
241 if ( !plugin )
242 return;
243
244 if ( active ) {
245 activeProcesses.append( plugin );
246 } else {
247 activeProcesses.removeRef( plugin );
248 }
249 m_stopProcesses->setEnabled( !activeProcesses.isEmpty() );
250}
251
252void MainWindowShare::slotStopPopupActivated( int id )
253{
254 KDevPlugin* plugin = activeProcesses.at( id );
255 if ( plugin && plugin->info()->genericName() == m_stopProcesses->popupMenu()->text( id ) ) {
256 Core::getInstance()->doEmitStopButtonPressed( plugin );
257 return;
258 } else {
259 // oops... list has changed in the meantime
260 TQString str = m_stopProcesses->popupMenu()->text( id );
261 for ( plugin = activeProcesses.first(); plugin; plugin = activeProcesses.next() ) {
262 if ( plugin->info()->genericName() == str ) {
263 Core::getInstance()->doEmitStopButtonPressed( plugin );
264 return;
265 }
266 }
267 }
268}
269
270void MainWindowShare::slotStopMenuAboutToShow()
271{
272 TQPopupMenu* popup = m_stopProcesses->popupMenu();
273 popup->clear();
274
275 int i = 0;
276 for ( KDevPlugin* plugin = activeProcesses.first(); plugin; plugin = activeProcesses.next() ) {
277 popup->insertItem( plugin->info()->genericName(), i++ );
278 }
279}
280
281void MainWindowShare::slotShowMenuBar()
282{
283 if (m_pMainWnd->menuBar()->isVisible()) {
284 m_pMainWnd->menuBar()->hide();
285 } else {
286 m_pMainWnd->menuBar()->show();
287 }
288 m_pMainWnd->saveMainWindowSettings( TDEGlobal::config(), "Mainwindow" );
289}
290
291void MainWindowShare::slotConfigureNotifications()
292{
293 KNotifyDialog::configure(m_pMainWnd, "Notification Configuration Dialog");
294}
295
296void MainWindowShare::slotSettings()
297{
298 KDialogBase dlg(KDialogBase::IconList, i18n("Configure TDevelop"),
299 KDialogBase::Help|KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, m_pMainWnd,
300 "customization dialog");
301 dlg.setHelp("setup");
302
303 ShellExtension::getInstance()->createGlobalSettingsPage(&dlg);
304
305 TDEConfig* config = kapp->config();
306
307 config->setGroup("Global Settings Dialog");
308 int height = config->readNumEntry( "Height", 600 );
309 int width = config->readNumEntry( "Width", 800 );
310
311 dlg.resize( width, height );
312
313 Core::getInstance()->doEmitConfigWidget(&dlg);
314 dlg.exec();
315
316 config->setGroup("Global Settings Dialog");
317 config->writeEntry( "Height", dlg.size().height() );
318 config->writeEntry( "Width", dlg.size().width() );
319
320 if ( dlg.result() != TQDialog::Rejected )
321 ShellExtension::getInstance()->acceptGlobalSettingsPage(&dlg);
322}
323
324void MainWindowShare::slotConfigureEditors()
325{
326 kdDebug(9000) << " *** MainWindowShare::slotConfigureEditors()" << endl;
327
328 KDevPartController * partController = API::getInstance()->partController();
329 KParts::Part * part = partController->activePart();
330
331 KTextEditor::ConfigInterface * conf = dynamic_cast<KTextEditor::ConfigInterface*>( part );
332 if ( ! conf )
333 {
334 kdDebug(9000) << "*** No KTextEditor::ConfigInterface for part!" << endl;
335 return;
336 }
337
338 // show the modal config dialog for this part if it has a ConfigInterface
339 conf->configDialog();
340 conf->writeConfig();
341
342}
343
344void MainWindowShare::slotGUICreated( KParts::Part * part )
345{
346// kdDebug(9000) << "MainWindowShare::slotGUICreated()" << endl;
347
348 if ( ! part ) return;
349
350 // disable configuration entry if created part is not an editor
351 if ( ! dynamic_cast<KTextEditor::ConfigInterface *>( part ) )
352 {
353 m_configureEditorAction->setEnabled( false );
354 return;
355 }
356
357 m_configureEditorAction->setEnabled( true );
358
359 // remove the part's merged menu entry
360 TDEAction * action = part->action("set_confdlg"); // name from katepartui.rc
361 if ( action )
362 {
363 kdDebug(9000) << " *** found \"set_confdlg\" action - unplugging" << endl;
364 action->unplugAll();
365 }
366
367 if ( TDEAction * action = part->action("file_save") )
368 {
369 kdDebug(9000) << " *** found \"file_save\" action - disconnecting" << endl;
370 disconnect( action, TQ_SIGNAL(activated()), 0, 0 );
371 connect( action, TQ_SIGNAL(activated()), PartController::getInstance(), TQ_SLOT(slotSave()) );
372 }
373
374 if ( TDEAction * action = part->action("file_reload") )
375 {
376 kdDebug(9000) << " *** found \"file_reload\" action - disconnecting" << endl;
377 disconnect( action, TQ_SIGNAL(activated()), 0, 0 );
378 connect( action, TQ_SIGNAL(activated()), PartController::getInstance(), TQ_SLOT(slotReload()) );
379 }
380}
381
382// called when OK ar Apply is clicked in the EditToolbar Dialog
383void MainWindowShare::slotNewToolbarConfig()
384{
385 // replug actionlists here...
386
387 m_pMainWnd->applyMainWindowSettings( TDEGlobal::config(), "Mainwindow" );
388
389// PartController::getInstance()->reinstallPopups();
390}
391
392void MainWindowShare::slotKeyBindings()
393{
394 KKeyDialog dlg( false, m_pMainWnd );
395 TQPtrList<KXMLGUIClient> clients = m_pMainWnd->guiFactory()->clients();
396 for( TQPtrListIterator<KXMLGUIClient> it( clients );
397 it.current(); ++it ) {
398 dlg.insert( (*it)->actionCollection() );
399 }
400 if ( dlg.configure() == KKeyDialog::Accepted )
401 {
402 // this is needed for when we have multiple embedded kateparts and change one of them.
403 // it also needs to be done to their views, as they too have actioncollections to update
404 if( const TQPtrList<KParts::Part> * partlist = PartController::getInstance()->parts() )
405 {
406 TQPtrListIterator<KParts::Part> it( *partlist );
407 while ( KParts::Part* part = it.current() )
408 {
409 if ( KTextEditor::Document * doc = dynamic_cast<KTextEditor::Document*>( part ) )
410 {
411 doc->reloadXML();
412
413 TQPtrList<KTextEditor::View> const & list = doc->views();
414 TQPtrListIterator<KTextEditor::View> itt( list );
415 while( KTextEditor::View * view = itt.current() )
416 {
417 view->reloadXML();
418 ++itt;
419 }
420 }
421 ++it;
422 }
423 }
424 Core::setupShourtcutTips();
425 }
426}
427
428void MainWindowShare::slotConfigureToolbars()
429{
430 m_pMainWnd->saveMainWindowSettings( TDEGlobal::config(), "Mainwindow" );
431 KEditToolbar dlg( m_pMainWnd->factory() );
432 connect(&dlg, TQ_SIGNAL(newToolbarConfig()), this, TQ_SLOT(slotNewToolbarConfig()));
433 dlg.exec();
434}
435
436void MainWindowShare::contextMenu(TQPopupMenu* popup, const Context *)
437{
438 if ( m_pMainWnd->menuBar()->isVisible() )
439 return;
440
441 int id = popup->insertItem( i18n("Show &Menubar"), m_pMainWnd->menuBar(), TQ_SLOT(show()) );
442 popup->TQMenuData::setWhatsThis(id, i18n("<b>Show menubar</b><p>Lets you switch the menubar on/off."));
443}
444
445void MainWindowShare::slotActivePartChanged( KParts::Part * part )
446{
447 m_configureEditorAction->setEnabled( part && dynamic_cast<KTextEditor::Document*>(part) );
448}
449
450#include "mainwindowshare.moc"
Core::setupShourtcutTips
static void setupShourtcutTips(KXMLGUIClient *client=0)
Setup shourtcut tips.
Definition core.cpp:32
ShellExtension::getInstance
static ShellExtension * getInstance()
Returns an instance of a shell.
Definition shellextension.h:42
ShellExtension::createGlobalSettingsPage
virtual void createGlobalSettingsPage(KDialogBase *dlg)=0
Reimplement to create global settings page in the dialog dlg.
ShellExtension::acceptGlobalSettingsPage
virtual void acceptGlobalSettingsPage(KDialogBase *dlg)=0
Reimplement to perform actions when the global settings page in the dialog dlg is accepted (user clic...

KDevelop Generic Shell

Skip menu "KDevelop Generic Shell"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

KDevelop Generic Shell

Skip menu "KDevelop Generic Shell"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for KDevelop Generic Shell by doxygen 1.9.8
This website is maintained by Timothy Pearson.