30 #include <kedittoolbar.h>
31 #include <kfiledialog.h>
32 #include <kshortcutsdialog.h>
33 #include <klibloader.h>
35 #include <kactioncollection.h>
36 #include <kmessagebox.h>
37 #include <krecentfilesaction.h>
38 #include <kstatusbar.h>
39 #include <kstandardaction.h>
42 #include <kxmlguifactory.h>
43 #include <kapplication.h>
47 : KParts::MainWindow(), m_part( 0 )
49 setObjectName( QLatin1String(
"Kig" ) );
51 config =
new KConfig(
"kigrc" );
53 setXMLFile(
"kigui.rc");
60 KPluginLoader libraryLoader(
"kigpart" );
62 libraryLoader.setLoadHints( QLibrary::ExportExternalSymbolsHint );
64 if ( KPluginFactory* factory = libraryLoader.factory() )
68 m_part = factory->create< KParts::ReadWritePart >( this );
72 setCentralWidget(m_part->widget());
78 QTimer::singleShot( 0,
this, SLOT( startupTipOfDay() ) );
85 KMessageBox::error(
this, i18n(
"Could not find the necessary Kig library, check your installation." ) );
94 setAutoSaveSettings();
99 m_recentFilesAction->saveEntries(config->group( QString() ));
103 void Kig::setupActions()
105 KStandardAction::openNew(
this, SLOT(fileNew()), actionCollection());
106 KStandardAction::open(
this, SLOT(fileOpen()), actionCollection());
107 KStandardAction::quit(
this, SLOT(close()), actionCollection());
109 createStandardStatusBarAction();
110 setStandardToolBarMenuEnabled(
true);
113 m_recentFilesAction = KStandardAction::openRecent(
this, SLOT(
openUrl(
const KUrl& ) ), actionCollection() );
114 m_recentFilesAction->loadEntries(config->group( QString() ) );
116 KStandardAction::keyBindings( guiFactory(), SLOT( configureShortcuts() ), actionCollection() );
117 KStandardAction::configureToolbars(
this, SLOT(optionsConfigureToolbars()), actionCollection());
119 KStandardAction::tipOfDay(
this, SLOT( tipOfDay() ), actionCollection() );
127 config.writePathEntry(
"fileName", m_part->url().path());
136 load( KUrl( config.readPathEntry(
"fileName", QString() ) ) );
143 if ( m_part && m_part->openUrl( url ) ) m_recentFilesAction->addUrl( url );
154 if ( ! m_part->url().isEmpty() || m_part->isModified() )
163 if ( m_part->url().isEmpty() && ! m_part->isModified() )
176 void Kig::optionsConfigureToolbars()
178 saveMainWindowSettings(KGlobal::config()->group(
"MainWindow") );
181 KEditToolBar dlg(factory());
182 connect(&dlg, SIGNAL(newToolBarConfig()),
183 this, SLOT(applyNewToolbarConfig()));
187 void Kig::applyNewToolbarConfig()
189 applyMainWindowSettings(KGlobal::config()->group(
"MainWindow") );
194 return m_part->queryClose();
199 e->setAccepted( KUrl::List::canDecode( e->mimeData() ) );
204 KUrl::List urls = KUrl::List::fromMimeData( e->mimeData() );
205 for ( KUrl::List::iterator u = urls.begin(); u != urls.end(); ++u )
216 i18n(
"*.kig *.kigz *.seg *.fgeo *.fig *.FIG|All Supported Files (*.kig *.kigz *.seg *.fgeo *.fig)\n"
217 "*.kig|Kig Documents (*.kig)\n"
218 "*.kigz|Compressed Kig Documents (*.kigz)\n"
219 "*.kgeo|KGeo Documents (*.kgeo)\n"
220 "*.seg|KSeg Documents (*.seg)\n"
221 "*.fgeo|Dr. Geo Documents (*.fgeo)\n"
222 "*.fig *.FIG|Cabri Documents (*.fig *.FIG)" );
225 QString file_name = KFileDialog::getOpenFileName( KUrl(
"kfiledialog:///document" ), formats );
227 if (!file_name.isEmpty())
openUrl(file_name);
230 void Kig::tipOfDay() {
231 KTipDialog::showTip(
this,
"kig/tips",
true);
234 void Kig::startupTipOfDay() {
235 KTipDialog::showTip(
this,
"kig/tips");
void load(const KUrl &file)
Open file in this window.
virtual void dragEnterEvent(QDragEnterEvent *e)
The user started dragging something onto us...
bool queryClose()
this is called by the framework before closing the window, to allow the user to save his changes...
virtual ~Kig()
Default Destructor.
void saveProperties(KConfigGroup &)
This method is called when it is time for the app to save its properties for session management purpo...
virtual void dropEvent(QDropEvent *e)
The user dropped something onto us...
Kig()
Default Constructor.
This is the application "Shell".
virtual void openUrl(const QString &s)
this opens the file specified in s in a new window
void readProperties(const KConfigGroup &)
This method is called when this app is restored.