18 #include <tqcheckbox.h> 20 #include <tqbuttongroup.h> 21 #include <tqradiobutton.h> 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> 43 #include <tdetexteditor/document.h> 44 #include <tdetexteditor/view.h> 45 #include <tdetexteditor/configinterface.h> 46 #include <tdeparts/partmanager.h> 47 #include <tdeversion.h> 49 #include <knotifydialog.h> 54 #include "partcontroller.h" 55 #include "projectmanager.h" 58 #include "kdevmakefrontend.h" 60 #include "plugincontroller.h" 62 #include "kdevplugininfo.h" 64 #include "mainwindowshare.h" 66 #include "shellextension.h" 70 MainWindowShare::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)
79 m_pMainWnd = (KParts::MainWindow*)pParent;
82 void MainWindowShare::init()
84 connect(Core::getInstance(), TQT_SIGNAL(contextMenu(TQPopupMenu *,
const Context *)),
85 this, TQT_SLOT(contextMenu(TQPopupMenu *,
const Context *)));
87 connect( m_pMainWnd->actionCollection(), TQT_SIGNAL( actionStatusText(
const TQString & ) ),
88 this, TQT_SLOT( slotActionStatusText(
const TQString & ) ) );
91 void MainWindowShare::slotActionStatusText(
const TQString &text )
95 if ( ! m_pMainWnd )
return;
97 KStatusBar * statusBar = m_pMainWnd->statusBar();
99 if ( ! statusBar )
return;
101 statusBar->message( text );
104 void MainWindowShare::createActions()
106 ProjectManager::getInstance()->createActions( m_pMainWnd->actionCollection() );
108 KStdAction::quit(this->parent(), TQT_SLOT(close()), m_pMainWnd->actionCollection());
112 m_stopProcesses =
new TDEToolBarPopupAction( i18n(
"&Stop" ),
"process-stop",
113 Key_Escape,
this, TQT_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(), TQT_SIGNAL(aboutToShow()),
119 this, TQT_SLOT(slotStopMenuAboutToShow()));
120 connect(m_stopProcesses->popupMenu(), TQT_SIGNAL(activated(
int)),
121 this, TQT_SLOT(slotStopPopupActivated(
int)));
123 connect( Core::getInstance(), TQT_SIGNAL(activeProcessChanged(KDevPlugin*,
bool)),
124 this, TQT_SLOT(slotActiveProcessChanged(KDevPlugin*,
bool)) );
126 action = KStdAction::showMenubar(
127 this, TQT_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.")));
132 action = KStdAction::keyBindings(
133 this, TQT_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.")));
138 action = KStdAction::configureToolbars(
139 this, TQT_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.")));
144 action = KStdAction::configureNotifications(
145 this, TQT_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.")));
150 action = KStdAction::preferences(
this, TQT_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.")));
155 m_toggleStatusbar = KStdAction::showToolbar(
this, TQT_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."));
160 action =
new TDEAction( i18n(
"&Next Window"), ALT+Key_Right,
this, TQT_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."));
164 action =
new TDEAction( i18n(
"&Previous Window"), ALT+Key_Left,
this, TQT_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."));
168 action =
new TDEAction( i18n(
"&Last Accessed Window"), ALT+Key_Up,
this, TQT_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)."));
172 action =
new TDEAction( i18n(
"&First Accessed Window"), ALT+Key_Down,
this, TQT_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)."));
176 action =
new TDEAction( i18n(
"Configure Plugins..."), SmallIconSet(
"configure"), 0, PluginController::getInstance(), TQT_SLOT(selectPlugins()), m_pMainWnd->actionCollection(),
"settings_configure_plugins" );
178 m_configureEditorAction =
new TDEAction( i18n(
"Configure &Editor..."), SmallIconSet(
"configure"), 0,
this, TQT_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 );
183 KDevPartController * partController = API::getInstance()->partController();
184 connect( partController, TQT_SIGNAL(activePartChanged(KParts::Part*)),
this, TQT_SLOT(slotActivePartChanged(KParts::Part* )) );
187 void MainWindowShare::slotReportBug()
189 KBugReport a(m_pMainWnd,
true, TDEGlobal::instance()->aboutData() );
193 void MainWindowShare::slotToggleMainToolbar()
195 if (m_toggleMainToolbar->isChecked())
196 m_pMainWnd->toolBar(
"mainToolBar")->show();
198 m_pMainWnd->toolBar(
"mainToolBar")->hide();
201 void MainWindowShare::slotToggleBuildToolbar()
203 if (m_toggleBuildToolbar->isChecked())
204 m_pMainWnd->toolBar(
"buildToolBar")->show();
206 m_pMainWnd->toolBar(
"buildToolBar")->hide();
209 void MainWindowShare::slotToggleViewToolbar()
211 if (m_toggleViewToolbar->isChecked())
212 m_pMainWnd->toolBar(
"viewToolBar")->show();
214 m_pMainWnd->toolBar(
"viewToolBar")->hide();
217 void MainWindowShare::slotToggleBrowserToolbar()
219 if (m_toggleBrowserToolbar->isChecked())
220 m_pMainWnd->toolBar(
"browserToolBar")->show();
222 m_pMainWnd->toolBar(
"browserToolBar")->hide();
225 void MainWindowShare::slotToggleStatusbar()
227 KStatusBar* sb = (KStatusBar*) m_pMainWnd->statusBar();
228 if (m_toggleStatusbar->isChecked())
234 void MainWindowShare::slotStopButtonPressed()
236 Core::getInstance()->doEmitStopButtonPressed();
239 void MainWindowShare::slotActiveProcessChanged( KDevPlugin* plugin,
bool active )
245 activeProcesses.append( plugin );
247 activeProcesses.removeRef( plugin );
249 m_stopProcesses->setEnabled( !activeProcesses.isEmpty() );
252 void MainWindowShare::slotStopPopupActivated(
int id )
254 KDevPlugin* plugin = activeProcesses.at(
id );
255 if ( plugin && plugin->info()->genericName() == m_stopProcesses->popupMenu()->text(
id ) ) {
256 Core::getInstance()->doEmitStopButtonPressed( plugin );
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 );
270 void MainWindowShare::slotStopMenuAboutToShow()
272 TQPopupMenu* popup = m_stopProcesses->popupMenu();
276 for ( KDevPlugin* plugin = activeProcesses.first(); plugin; plugin = activeProcesses.next() ) {
277 popup->insertItem( plugin->info()->genericName(), i++ );
281 void MainWindowShare::slotShowMenuBar()
283 if (m_pMainWnd->menuBar()->isVisible()) {
284 m_pMainWnd->menuBar()->hide();
286 m_pMainWnd->menuBar()->show();
288 m_pMainWnd->saveMainWindowSettings( TDEGlobal::config(),
"Mainwindow" );
291 void MainWindowShare::slotConfigureNotifications()
293 KNotifyDialog::configure(m_pMainWnd,
"Notification Configuration Dialog");
296 void MainWindowShare::slotSettings()
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");
305 TDEConfig* config = kapp->config();
307 config->setGroup(
"Global Settings Dialog");
308 int height = config->readNumEntry(
"Height", 600 );
309 int width = config->readNumEntry(
"Width", 800 );
311 dlg.resize( width, height );
313 Core::getInstance()->doEmitConfigWidget(&dlg);
316 config->setGroup(
"Global Settings Dialog");
317 config->writeEntry(
"Height", dlg.size().height() );
318 config->writeEntry(
"Width", dlg.size().width() );
320 if ( dlg.result() != TQDialog::Rejected )
324 void MainWindowShare::slotConfigureEditors()
326 kdDebug(9000) <<
" *** MainWindowShare::slotConfigureEditors()" << endl;
328 KDevPartController * partController = API::getInstance()->partController();
329 KParts::Part * part = partController->activePart();
331 KTextEditor::ConfigInterface * conf =
dynamic_cast<KTextEditor::ConfigInterface*
>( part );
334 kdDebug(9000) <<
"*** No KTextEditor::ConfigInterface for part!" << endl;
339 conf->configDialog();
344 void MainWindowShare::slotGUICreated( KParts::Part * part )
348 if ( ! part )
return;
351 if ( ! dynamic_cast<KTextEditor::ConfigInterface *>( part ) )
353 m_configureEditorAction->setEnabled(
false );
357 m_configureEditorAction->setEnabled(
true );
360 TDEAction * action = part->action(
"set_confdlg");
363 kdDebug(9000) <<
" *** found \"set_confdlg\" action - unplugging" << endl;
367 if ( TDEAction * action = part->action(
"file_save") )
369 kdDebug(9000) <<
" *** found \"file_save\" action - disconnecting" << endl;
370 disconnect( action, TQT_SIGNAL(activated()), 0, 0 );
371 connect( action, TQT_SIGNAL(activated()), PartController::getInstance(), TQT_SLOT(slotSave()) );
374 if ( TDEAction * action = part->action(
"file_reload") )
376 kdDebug(9000) <<
" *** found \"file_reload\" action - disconnecting" << endl;
377 disconnect( action, TQT_SIGNAL(activated()), 0, 0 );
378 connect( action, TQT_SIGNAL(activated()), PartController::getInstance(), TQT_SLOT(slotReload()) );
383 void MainWindowShare::slotNewToolbarConfig()
387 m_pMainWnd->applyMainWindowSettings( TDEGlobal::config(),
"Mainwindow" );
392 void MainWindowShare::slotKeyBindings()
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() );
400 if ( dlg.configure() == KKeyDialog::Accepted )
404 if(
const TQPtrList<KParts::Part> * partlist = PartController::getInstance()->parts() )
406 TQPtrListIterator<KParts::Part> it( *partlist );
407 while ( KParts::Part* part = it.current() )
409 if ( KTextEditor::Document * doc = dynamic_cast<KTextEditor::Document*>( part ) )
413 TQPtrList<KTextEditor::View>
const & list = doc->views();
414 TQPtrListIterator<KTextEditor::View> itt( list );
415 while( KTextEditor::View * view = itt.current() )
428 void MainWindowShare::slotConfigureToolbars()
430 m_pMainWnd->saveMainWindowSettings( TDEGlobal::config(),
"Mainwindow" );
431 KEditToolbar dlg( m_pMainWnd->factory() );
432 connect(&dlg, TQT_SIGNAL(newToolbarConfig()),
this, TQT_SLOT(slotNewToolbarConfig()));
436 void MainWindowShare::contextMenu(TQPopupMenu* popup,
const Context *)
438 if ( m_pMainWnd->menuBar()->isVisible() )
441 int id = popup->insertItem( i18n(
"Show &Menubar"), m_pMainWnd->menuBar(), TQT_SLOT(show()) );
442 popup->TQMenuData::setWhatsThis(
id, i18n(
"<b>Show menubar</b><p>Lets you switch the menubar on/off."));
445 void MainWindowShare::slotActivePartChanged( KParts::Part * part )
447 m_configureEditorAction->setEnabled( part && dynamic_cast<KTextEditor::Document*>(part) );
450 #include "mainwindowshare.moc" virtual void acceptGlobalSettingsPage(KDialogBase *dlg)=0
Reimplement to perform actions when the global settings page in the dialog dlg is accepted (user clic...
virtual void createGlobalSettingsPage(KDialogBase *dlg)=0
Reimplement to create global settings page in the dialog dlg.
static void setupShourtcutTips(KXMLGUIClient *client=0)
Setup shourtcut tips.
static ShellExtension * getInstance()
Returns an instance of a shell.