annotate kdiff3/src/kdiff3_shell.cpp @ 8:86d21651c8db

KDiff3 version 0.9.70
author joachim99
date Mon, 06 Oct 2003 18:50:45 +0000
parents
children efe33e938730
rev   line source
joachim99@8 1 /*
joachim99@8 2 * Copyright (C) 2003 Joachim Eibl <joachim@gmx.de>
joachim99@8 3 */
joachim99@8 4
joachim99@8 5 #include "kdiff3_shell.h"
joachim99@8 6 #include "kdiff3.h"
joachim99@8 7
joachim99@8 8 #include <kkeydialog.h>
joachim99@8 9 #include <kfiledialog.h>
joachim99@8 10 #include <kconfig.h>
joachim99@8 11 #include <kurl.h>
joachim99@8 12
joachim99@8 13 #include <kedittoolbar.h>
joachim99@8 14
joachim99@8 15 #include <kaction.h>
joachim99@8 16 #include <kstdaction.h>
joachim99@8 17
joachim99@8 18 #include <klibloader.h>
joachim99@8 19 #include <kmessagebox.h>
joachim99@8 20 #include <kstatusbar.h>
joachim99@8 21 #include <klocale.h>
joachim99@8 22
joachim99@8 23 #include <iostream>
joachim99@8 24
joachim99@8 25 KDiff3Shell::KDiff3Shell()
joachim99@8 26 : KParts::MainWindow( 0L, "kdiff3" )
joachim99@8 27 {
joachim99@8 28 m_bUnderConstruction = true;
joachim99@8 29 // set the shell's ui resource file
joachim99@8 30 setXMLFile("kdiff3_shell.rc");
joachim99@8 31
joachim99@8 32 // and a status bar
joachim99@8 33 statusBar()->show();
joachim99@8 34
joachim99@8 35 // this routine will find and load our Part. it finds the Part by
joachim99@8 36 // name which is a bad idea usually.. but it's alright in this
joachim99@8 37 // case since our Part is made for this Shell
joachim99@8 38 KLibFactory *factory = KLibLoader::self()->factory("libkdiff3part");
joachim99@8 39 if (factory)
joachim99@8 40 {
joachim99@8 41 // now that the Part is loaded, we cast it to a Part to get
joachim99@8 42 // our hands on it
joachim99@8 43 m_part = static_cast<KParts::ReadWritePart *>(factory->create(this,
joachim99@8 44 "kdiff3_part", "KParts::ReadWritePart" ));
joachim99@8 45
joachim99@8 46 if (m_part)
joachim99@8 47 {
joachim99@8 48 // and integrate the part's GUI with the shell's
joachim99@8 49 createGUI(m_part);
joachim99@8 50
joachim99@8 51 // tell the KParts::MainWindow that this is indeed the main widget
joachim99@8 52 setCentralWidget(m_part->widget());
joachim99@8 53
joachim99@8 54 show();
joachim99@8 55
joachim99@8 56 ((KDiff3App*)m_part->widget())->completeInit();
joachim99@8 57 }
joachim99@8 58 }
joachim99@8 59 else
joachim99@8 60 {
joachim99@8 61 // if we couldn't find our Part, we exit since the Shell by
joachim99@8 62 // itself can't do anything useful
joachim99@8 63 KMessageBox::error(this, i18n("Could not find our part!\n"
joachim99@8 64 "This usually happens due to an installation problem. "
joachim99@8 65 "Please read the README-file in the source package for details.")
joachim99@8 66 );
joachim99@8 67 kapp->quit();
joachim99@8 68 // we return here, cause kapp->quit() only means "exit the
joachim99@8 69 // next time we enter the event loop...
joachim99@8 70 return;
joachim99@8 71 }
joachim99@8 72
joachim99@8 73 // apply the saved mainwindow settings, if any, and ask the mainwindow
joachim99@8 74 // to automatically save settings if changed: window size, toolbar
joachim99@8 75 // position, icon size, etc.
joachim99@8 76 setAutoSaveSettings();
joachim99@8 77 m_bUnderConstruction = false;
joachim99@8 78 }
joachim99@8 79
joachim99@8 80 KDiff3Shell::~KDiff3Shell()
joachim99@8 81 {
joachim99@8 82 }
joachim99@8 83
joachim99@8 84 bool KDiff3Shell::queryClose()
joachim99@8 85 {
joachim99@8 86 if (m_part)
joachim99@8 87 return ((KDiff3App*)m_part->widget())->queryClose();
joachim99@8 88 else
joachim99@8 89 return true;
joachim99@8 90 }
joachim99@8 91
joachim99@8 92 bool KDiff3Shell::queryExit()
joachim99@8 93 {
joachim99@8 94 return true;
joachim99@8 95 }
joachim99@8 96
joachim99@8 97
joachim99@8 98
joachim99@8 99
joachim99@8 100 void KDiff3Shell::optionsShowToolbar()
joachim99@8 101 {
joachim99@8 102 // this is all very cut and paste code for showing/hiding the
joachim99@8 103 // toolbar
joachim99@8 104 if (m_toolbarAction->isChecked())
joachim99@8 105 toolBar()->show();
joachim99@8 106 else
joachim99@8 107 toolBar()->hide();
joachim99@8 108 }
joachim99@8 109
joachim99@8 110 void KDiff3Shell::optionsShowStatusbar()
joachim99@8 111 {
joachim99@8 112 // this is all very cut and paste code for showing/hiding the
joachim99@8 113 // statusbar
joachim99@8 114 if (m_statusbarAction->isChecked())
joachim99@8 115 statusBar()->show();
joachim99@8 116 else
joachim99@8 117 statusBar()->hide();
joachim99@8 118 }
joachim99@8 119
joachim99@8 120 void KDiff3Shell::optionsConfigureKeys()
joachim99@8 121 {
joachim99@8 122 KKeyDialog::configure(actionCollection(), "kdiff3_shell.rc");
joachim99@8 123 }
joachim99@8 124
joachim99@8 125 void KDiff3Shell::optionsConfigureToolbars()
joachim99@8 126 {
joachim99@8 127 #if defined(KDE_MAKE_VERSION)
joachim99@8 128 # if KDE_VERSION >= KDE_MAKE_VERSION(3,1,0)
joachim99@8 129 saveMainWindowSettings(KGlobal::config(), autoSaveGroup());
joachim99@8 130 # else
joachim99@8 131 saveMainWindowSettings(KGlobal::config() );
joachim99@8 132 # endif
joachim99@8 133 #else
joachim99@8 134 saveMainWindowSettings(KGlobal::config() );
joachim99@8 135 #endif
joachim99@8 136
joachim99@8 137 // use the standard toolbar editor
joachim99@8 138 KEditToolbar dlg(factory());
joachim99@8 139 connect(&dlg, SIGNAL(newToolbarConfig()),
joachim99@8 140 this, SLOT(applyNewToolbarConfig()));
joachim99@8 141 dlg.exec();
joachim99@8 142 }
joachim99@8 143
joachim99@8 144 void KDiff3Shell::applyNewToolbarConfig()
joachim99@8 145 {
joachim99@8 146 #if defined(KDE_MAKE_VERSION)
joachim99@8 147 # if KDE_VERSION >= KDE_MAKE_VERSION(3,1,0)
joachim99@8 148 applyMainWindowSettings(KGlobal::config(), autoSaveGroup());
joachim99@8 149 # else
joachim99@8 150 applyMainWindowSettings(KGlobal::config());
joachim99@8 151 # endif
joachim99@8 152 #else
joachim99@8 153 applyMainWindowSettings(KGlobal::config());
joachim99@8 154 #endif
joachim99@8 155 }
joachim99@8 156
joachim99@8 157 #include "kdiff3_shell.moc"