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