joachim99@8: /* joachim99@8: * Copyright (C) 2003 Joachim Eibl joachim99@8: */ joachim99@8: joachim99@8: #include "kdiff3_shell.h" joachim99@8: #include "kdiff3.h" joachim99@8: joachim99@8: #include joachim99@8: #include joachim99@8: #include joachim99@8: #include joachim99@8: joachim99@8: #include joachim99@8: joachim99@8: #include joachim99@8: #include joachim99@8: joachim99@8: #include joachim99@8: #include joachim99@8: #include joachim99@8: #include joachim99@8: joachim99@8: #include joachim99@8: joachim99@8: KDiff3Shell::KDiff3Shell() joachim99@8: : KParts::MainWindow( 0L, "kdiff3" ) joachim99@8: { joachim99@8: m_bUnderConstruction = true; joachim99@8: // set the shell's ui resource file joachim99@8: setXMLFile("kdiff3_shell.rc"); joachim99@8: joachim99@8: // and a status bar joachim99@8: statusBar()->show(); joachim99@8: joachim99@8: // this routine will find and load our Part. it finds the Part by joachim99@8: // name which is a bad idea usually.. but it's alright in this joachim99@8: // case since our Part is made for this Shell joachim99@8: KLibFactory *factory = KLibLoader::self()->factory("libkdiff3part"); joachim99@8: if (factory) joachim99@8: { joachim99@8: // now that the Part is loaded, we cast it to a Part to get joachim99@8: // our hands on it joachim99@8: m_part = static_cast(factory->create(this, joachim99@8: "kdiff3_part", "KParts::ReadWritePart" )); joachim99@8: joachim99@8: if (m_part) joachim99@8: { joachim99@8: // and integrate the part's GUI with the shell's joachim99@8: createGUI(m_part); joachim99@8: joachim99@8: // tell the KParts::MainWindow that this is indeed the main widget joachim99@8: setCentralWidget(m_part->widget()); joachim99@8: joachim99@8: show(); joachim99@8: joachim99@8: ((KDiff3App*)m_part->widget())->completeInit(); joachim99@8: } joachim99@8: } joachim99@8: else joachim99@8: { joachim99@8: // if we couldn't find our Part, we exit since the Shell by joachim99@8: // itself can't do anything useful joachim99@8: KMessageBox::error(this, i18n("Could not find our part!\n" joachim99@8: "This usually happens due to an installation problem. " joachim99@8: "Please read the README-file in the source package for details.") joachim99@8: ); joachim99@8: kapp->quit(); joachim99@8: // we return here, cause kapp->quit() only means "exit the joachim99@8: // next time we enter the event loop... joachim99@8: return; joachim99@8: } joachim99@8: joachim99@8: // apply the saved mainwindow settings, if any, and ask the mainwindow joachim99@8: // to automatically save settings if changed: window size, toolbar joachim99@8: // position, icon size, etc. joachim99@8: setAutoSaveSettings(); joachim99@8: m_bUnderConstruction = false; joachim99@8: } joachim99@8: joachim99@8: KDiff3Shell::~KDiff3Shell() joachim99@8: { joachim99@8: } joachim99@8: joachim99@8: bool KDiff3Shell::queryClose() joachim99@8: { joachim99@8: if (m_part) joachim99@8: return ((KDiff3App*)m_part->widget())->queryClose(); joachim99@8: else joachim99@8: return true; joachim99@8: } joachim99@8: joachim99@8: bool KDiff3Shell::queryExit() joachim99@8: { joachim99@8: return true; joachim99@8: } joachim99@8: joachim99@8: joachim99@8: joachim99@8: joachim99@8: void KDiff3Shell::optionsShowToolbar() joachim99@8: { joachim99@8: // this is all very cut and paste code for showing/hiding the joachim99@8: // toolbar joachim99@8: if (m_toolbarAction->isChecked()) joachim99@8: toolBar()->show(); joachim99@8: else joachim99@8: toolBar()->hide(); joachim99@8: } joachim99@8: joachim99@8: void KDiff3Shell::optionsShowStatusbar() joachim99@8: { joachim99@8: // this is all very cut and paste code for showing/hiding the joachim99@8: // statusbar joachim99@8: if (m_statusbarAction->isChecked()) joachim99@8: statusBar()->show(); joachim99@8: else joachim99@8: statusBar()->hide(); joachim99@8: } joachim99@8: joachim99@8: void KDiff3Shell::optionsConfigureKeys() joachim99@8: { joachim99@8: KKeyDialog::configure(actionCollection(), "kdiff3_shell.rc"); joachim99@8: } joachim99@8: joachim99@8: void KDiff3Shell::optionsConfigureToolbars() joachim99@8: { joachim99@8: #if defined(KDE_MAKE_VERSION) joachim99@8: # if KDE_VERSION >= KDE_MAKE_VERSION(3,1,0) joachim99@8: saveMainWindowSettings(KGlobal::config(), autoSaveGroup()); joachim99@8: # else joachim99@8: saveMainWindowSettings(KGlobal::config() ); joachim99@8: # endif joachim99@8: #else joachim99@8: saveMainWindowSettings(KGlobal::config() ); joachim99@8: #endif joachim99@8: joachim99@8: // use the standard toolbar editor joachim99@8: KEditToolbar dlg(factory()); joachim99@8: connect(&dlg, SIGNAL(newToolbarConfig()), joachim99@8: this, SLOT(applyNewToolbarConfig())); joachim99@8: dlg.exec(); joachim99@8: } joachim99@8: joachim99@8: void KDiff3Shell::applyNewToolbarConfig() joachim99@8: { joachim99@8: #if defined(KDE_MAKE_VERSION) joachim99@8: # if KDE_VERSION >= KDE_MAKE_VERSION(3,1,0) joachim99@8: applyMainWindowSettings(KGlobal::config(), autoSaveGroup()); joachim99@8: # else joachim99@8: applyMainWindowSettings(KGlobal::config()); joachim99@8: # endif joachim99@8: #else joachim99@8: applyMainWindowSettings(KGlobal::config()); joachim99@8: #endif joachim99@8: } joachim99@8: joachim99@8: #include "kdiff3_shell.moc"