From a39b92f278f6d1530cb151875b445185951634df Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 10 Mar 2010 20:44:18 +0000 Subject: Added KDE3 version of POTraceGUI git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/potracegui@1101754 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/potracegui.cpp | 158 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 src/potracegui.cpp (limited to 'src/potracegui.cpp') diff --git a/src/potracegui.cpp b/src/potracegui.cpp new file mode 100644 index 0000000..70168b2 --- /dev/null +++ b/src/potracegui.cpp @@ -0,0 +1,158 @@ +/*************************************************************************** + * Copyright (C) 2004 by Antonio Fasolato * + * Antonio.Fasolato@poste.it * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include "potracegui.h" +#include "mainwidget.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +potracegui::potracegui() + : KMainWindow( 0, "potracegui" ), m_centralWidget(new MainWidget(this)) +{ + // set the shell's ui resource file + setXMLFile("potraceguiui.rc"); + KImageIO::registerFormats(); + + setCentralWidget(m_centralWidget); + + setAcceptDrops(true); + + statusBar()->show(); + statusBar()->message(i18n("Welcome to PotraceGui 1.3")); + setAutoSaveSettings(); + setAcceptDrops(true); + + connect(m_centralWidget,SIGNAL(signalChangeStatusbar(QString)),this,SLOT(changeStatusbar(QString))); + + createInterface(); +} + +potracegui::~potracegui() +{ +} + +void potracegui::createInterface() +{ + /*handled by potracegui*/ + KStdAction::openNew(this, SLOT(fileNew()),actionCollection()); + KStdAction::quit(this, SLOT(quit()),actionCollection()); + m_toolbarAction=KStdAction::showToolbar(this, SLOT(showToolbar()),actionCollection()); + m_statusbarAction=KStdAction::showStatusbar(this, SLOT(showStatusbar()),actionCollection()); + KStdAction::keyBindings(this, SLOT(configureKeys()),actionCollection()); + KStdAction::configureToolbars(this, SLOT(configureTB()),actionCollection()); + + /*handled by MainWidget*/ + KStdAction::open(m_centralWidget, SLOT(fileOpen()),actionCollection()); + KStdAction::save(m_centralWidget, SLOT(fileSave()),actionCollection()); + KStdAction::saveAs(m_centralWidget, SLOT(fileSaveAs()),actionCollection()); + KStdAction::close(m_centralWidget, SLOT(fileClose()),actionCollection()); + KStdAction::cut(m_centralWidget, SLOT(cut()),actionCollection()); + KStdAction::copy(m_centralWidget, SLOT(copy()),actionCollection()); + KStdAction::paste(m_centralWidget, SLOT(paste()),actionCollection()); + + /*Create menu and toolbar*/ + createGUI(); +} + + +//MENU ACTIONS +void potracegui::fileNew() +{ + (new potracegui)->show(); +} + +void potracegui::quit() +{ + close(); +} + +void potracegui::showToolbar() +{ + if(m_toolbarAction->isChecked()) + toolBar()->show(); + else + toolBar()->hide(); +} + +void potracegui::showStatusbar() +{ + if(m_statusbarAction->isChecked()) + statusBar()->show(); + else + statusBar()->hide(); +} + +void potracegui::configureKeys() +{ + KKeyDialog::configure(actionCollection(),"potraceguiui.rc"); +} + +void potracegui::configureTB() +{ + KEditToolbar dlg(actionCollection()); + connect(&dlg,SIGNAL(newToolbarConfig()),this,SLOT(NewTBConfig())); + dlg.exec(); +} + +void potracegui::NewTBConfig() +{ + createGUI(); + saveMainWindowSettings(KGlobal::config()); +} + +void potracegui::changeStatusbar(QString message) +{ + statusBar()->message(message); +} + +bool potracegui::queryClose() { + if(m_centralWidget->m_changed) { + int res= KMessageBox::warningYesNoCancel(this, i18n("Save changes?")); + if(res==KMessageBox::Yes) { + m_centralWidget->fileSave(); + return true; + } + else if(res==KMessageBox::Cancel) { + return false; + } + if(res==KMessageBox::No) { + return true; + } + } + return true; +} + +#include "potracegui.moc" -- cgit v1.2.1