diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch) | |
tree | acaf47eb0fa12142d3896416a69e74cbf5a72242 /languages/cpp/app_templates/kpartapp | |
download | tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'languages/cpp/app_templates/kpartapp')
-rw-r--r-- | languages/cpp/app_templates/kpartapp/.kdev_ignore | 0 | ||||
-rw-r--r-- | languages/cpp/app_templates/kpartapp/Makefile.am | 17 | ||||
-rw-r--r-- | languages/cpp/app_templates/kpartapp/app.cpp | 209 | ||||
-rw-r--r-- | languages/cpp/app_templates/kpartapp/app.desktop | 18 | ||||
-rw-r--r-- | languages/cpp/app_templates/kpartapp/app.h | 76 | ||||
-rw-r--r-- | languages/cpp/app_templates/kpartapp/app.kdevelop | 115 | ||||
-rw-r--r-- | languages/cpp/app_templates/kpartapp/app_part.cpp | 201 | ||||
-rw-r--r-- | languages/cpp/app_templates/kpartapp/app_part.h | 86 | ||||
-rw-r--r-- | languages/cpp/app_templates/kpartapp/app_part.rc | 17 | ||||
-rw-r--r-- | languages/cpp/app_templates/kpartapp/app_shell.rc | 28 | ||||
-rw-r--r-- | languages/cpp/app_templates/kpartapp/kpartapp.kdevtemplate | 237 | ||||
-rw-r--r-- | languages/cpp/app_templates/kpartapp/kpartapp.png | bin | 0 -> 5041 bytes | |||
-rw-r--r-- | languages/cpp/app_templates/kpartapp/main.cpp | 57 | ||||
-rw-r--r-- | languages/cpp/app_templates/kpartapp/src-Makefile.am | 53 | ||||
-rw-r--r-- | languages/cpp/app_templates/kpartapp/subdirs | 3 |
15 files changed, 1117 insertions, 0 deletions
diff --git a/languages/cpp/app_templates/kpartapp/.kdev_ignore b/languages/cpp/app_templates/kpartapp/.kdev_ignore new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/languages/cpp/app_templates/kpartapp/.kdev_ignore diff --git a/languages/cpp/app_templates/kpartapp/Makefile.am b/languages/cpp/app_templates/kpartapp/Makefile.am new file mode 100644 index 00000000..9b69f17d --- /dev/null +++ b/languages/cpp/app_templates/kpartapp/Makefile.am @@ -0,0 +1,17 @@ +dataFiles = src-Makefile.am app.cpp app.h app_part.cpp\ + app_part.h main.cpp app_part.rc app_shell.rc \ + kpartapp.png app.kdevelop subdirs +templateName = kpartapp +### no need to change below: +template_DATA = $(templateName).kdevtemplate +templatedir = ${appwizarddatadir}/templates + +appwizarddatadir = ${kde_datadir}/kdevappwizard +$(templateName).tar.gz: ${dataFiles} + $(TAR) -cf $(templateName).tar -C $(srcdir) ${dataFiles} + $(GZIP_COMMAND) -f9 $(templateName).tar + +archivedir = ${appwizarddatadir} +archive_DATA = $(templateName).tar.gz ${templateName}.png + +CLEANFILES = *.tar.gz diff --git a/languages/cpp/app_templates/kpartapp/app.cpp b/languages/cpp/app_templates/kpartapp/app.cpp new file mode 100644 index 00000000..68c34ab3 --- /dev/null +++ b/languages/cpp/app_templates/kpartapp/app.cpp @@ -0,0 +1,209 @@ + +#include "%{APPNAMELC}.h" + +#include <kkeydialog.h> +#include <kfiledialog.h> +#include <kconfig.h> +#include <kurl.h> + +#include <kedittoolbar.h> + +#include <kaction.h> +#include <kstdaction.h> + +#include <klibloader.h> +#include <kmessagebox.h> +#include <kstatusbar.h> +#include <klocale.h> + +%{APPNAME}::%{APPNAME}() + : KParts::MainWindow( 0L, "%{APPNAME}" ) +{ + // set the shell's ui resource file + setXMLFile("%{APPNAMELC}_shell.rc"); + + // then, setup our actions + setupActions(); + + // and a status bar + statusBar()->show(); + + // this routine will find and load our Part. it finds the Part by + // name which is a bad idea usually.. but it's alright in this + // case since our Part is made for this Shell + KLibFactory *factory = KLibLoader::self()->factory("lib%{APPNAMELC}part"); + if (factory) + { + // now that the Part is loaded, we cast it to a Part to get + // our hands on it + m_part = static_cast<KParts::ReadWritePart *>(factory->create(this, + "%{APPNAMELC}_part", "KParts::ReadWritePart" )); + + if (m_part) + { + // tell the KParts::MainWindow that this is indeed the main widget + setCentralWidget(m_part->widget()); + + // and integrate the part's GUI with the shell's + createGUI(m_part); + } + } + else + { + // if we couldn't find our Part, we exit since the Shell by + // itself can't do anything useful + KMessageBox::error(this, i18n("Could not find our part.")); + kapp->quit(); + // we return here, cause kapp->quit() only means "exit the + // next time we enter the event loop... + return; + } + + // apply the saved mainwindow settings, if any, and ask the mainwindow + // to automatically save settings if changed: window size, toolbar + // position, icon size, etc. + setAutoSaveSettings(); +} + +%{APPNAME}::~%{APPNAME}() +{ +} + +void %{APPNAME}::load(const KURL& url) +{ + m_part->openURL( url ); +} + +void %{APPNAME}::setupActions() +{ + KStdAction::openNew(this, SLOT(fileNew()), actionCollection()); + KStdAction::open(this, SLOT(fileOpen()), actionCollection()); + + KStdAction::quit(kapp, SLOT(quit()), actionCollection()); + + m_toolbarAction = KStdAction::showToolbar(this, SLOT(optionsShowToolbar()), actionCollection()); + m_statusbarAction = KStdAction::showStatusbar(this, SLOT(optionsShowStatusbar()), actionCollection()); + + KStdAction::keyBindings(this, SLOT(optionsConfigureKeys()), actionCollection()); + KStdAction::configureToolbars(this, SLOT(optionsConfigureToolbars()), actionCollection()); +} + +void %{APPNAME}::saveProperties(KConfig* /*config*/) +{ + // the 'config' object points to the session managed + // config file. anything you write here will be available + // later when this app is restored +} + +void %{APPNAME}::readProperties(KConfig* /*config*/) +{ + // the 'config' object points to the session managed + // config file. this function is automatically called whenever + // the app is being restored. read in here whatever you wrote + // in 'saveProperties' +} + +void %{APPNAME}::fileNew() +{ + // this slot is called whenever the File->New menu is selected, + // the New shortcut is pressed (usually CTRL+N) or the New toolbar + // button is clicked + + // About this function, the style guide ( + // http://developer.kde.org/documentation/standards/kde/style/basics/index.html ) + // says that it should open a new window if the document is _not_ + // in its initial state. This is what we do here.. + if ( ! m_part->url().isEmpty() || m_part->isModified() ) + { + (new %{APPNAME})->show(); + }; +} + + +void %{APPNAME}::optionsShowToolbar() +{ + // this is all very cut and paste code for showing/hiding the + // toolbar + if (m_toolbarAction->isChecked()) + toolBar()->show(); + else + toolBar()->hide(); +} + +void %{APPNAME}::optionsShowStatusbar() +{ + // this is all very cut and paste code for showing/hiding the + // statusbar + if (m_statusbarAction->isChecked()) + statusBar()->show(); + else + statusBar()->hide(); +} + +void %{APPNAME}::optionsConfigureKeys() +{ + KKeyDialog::configure(actionCollection()); +} + +void %{APPNAME}::optionsConfigureToolbars() +{ +#if defined(KDE_MAKE_VERSION) +# if KDE_VERSION >= KDE_MAKE_VERSION(3,1,0) + saveMainWindowSettings(KGlobal::config(), autoSaveGroup()); +# else + saveMainWindowSettings(KGlobal::config() ); +# endif +#else + saveMainWindowSettings(KGlobal::config() ); +#endif + + // use the standard toolbar editor + KEditToolbar dlg(factory()); + connect(&dlg, SIGNAL(newToolbarConfig()), + this, SLOT(applyNewToolbarConfig())); + dlg.exec(); +} + +void %{APPNAME}::applyNewToolbarConfig() +{ +#if defined(KDE_MAKE_VERSION) +# if KDE_VERSION >= KDE_MAKE_VERSION(3,1,0) + applyMainWindowSettings(KGlobal::config(), autoSaveGroup()); +# else + applyMainWindowSettings(KGlobal::config()); +# endif +#else + applyMainWindowSettings(KGlobal::config()); +#endif +} + +void %{APPNAME}::fileOpen() +{ + // this slot is called whenever the File->Open menu is selected, + // the Open shortcut is pressed (usually CTRL+O) or the Open toolbar + // button is clicked + KURL url = + KFileDialog::getOpenURL( QString::null, QString::null, this ); + + if (url.isEmpty() == false) + { + // About this function, the style guide ( + // http://developer.kde.org/documentation/standards/kde/style/basics/index.html ) + // says that it should open a new window if the document is _not_ + // in its initial state. This is what we do here.. + if ( m_part->url().isEmpty() && ! m_part->isModified() ) + { + // we open the file in this window... + load( url ); + } + else + { + // we open the file in a new window... + %{APPNAME}* newWin = new %{APPNAME}; + newWin->load( url ); + newWin->show(); + } + } +} + +#include "%{APPNAMELC}.moc" diff --git a/languages/cpp/app_templates/kpartapp/app.desktop b/languages/cpp/app_templates/kpartapp/app.desktop new file mode 100644 index 00000000..01cc9d37 --- /dev/null +++ b/languages/cpp/app_templates/kpartapp/app.desktop @@ -0,0 +1,18 @@ +[Desktop Entry] +Name=%{APPNAME}Part +Name[br]=Perzh%{APPNAME} +Name[ca]=Part per a %{APPNAME} +Name[el]=Τμήμα%{APPNAME} +Name[et]=%{APPNAME} komponent +Name[fa]=جزء %{APPNAME} +Name[gl]=%{APPNAME} Part +Name[ja]=%{APPNAME} パート +Name[ne]=%{APPNAME}भाग +Name[pt_BR]=Parte %{APPNAME} +Name[sv]=%{APPNAME}-del +Name[ta]=%{APPNAME}பாகம் +Name[tr]=%{APPNAME} Bileşeni +MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++; +ServiceTypes=KParts/ReadOnlyPart,KParts/ReadWritePart +X-KDE-Library=lib%{APPNAMELC}part +Type=Service diff --git a/languages/cpp/app_templates/kpartapp/app.h b/languages/cpp/app_templates/kpartapp/app.h new file mode 100644 index 00000000..25cd63bf --- /dev/null +++ b/languages/cpp/app_templates/kpartapp/app.h @@ -0,0 +1,76 @@ + +#ifndef _%{APPNAMEUC}_H_ +#define _%{APPNAMEUC}_H_ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <kapplication.h> +#include <kparts/mainwindow.h> + +class KToggleAction; + +/** + * This is the application "Shell". It has a menubar, toolbar, and + * statusbar but relies on the "Part" to do all the real work. + * + * @short Application Shell + * @author %{AUTHOR} <%{EMAIL}> + * @version %{VERSION} + */ +class %{APPNAME} : public KParts::MainWindow +{ + Q_OBJECT +public: + /** + * Default Constructor + */ + %{APPNAME}(); + + /** + * Default Destructor + */ + virtual ~%{APPNAME}(); + + /** + * Use this method to load whatever file/URL you have + */ + void load(const KURL& url); + +protected: + /** + * This method is called when it is time for the app to save its + * properties for session management purposes. + */ + void saveProperties(KConfig *); + + /** + * This method is called when this app is restored. The KConfig + * object points to the session management config file that was saved + * with @ref saveProperties + */ + void readProperties(KConfig *); + +private slots: + void fileNew(); + void fileOpen(); + void optionsShowToolbar(); + void optionsShowStatusbar(); + void optionsConfigureKeys(); + void optionsConfigureToolbars(); + + void applyNewToolbarConfig(); + +private: + void setupAccel(); + void setupActions(); + +private: + KParts::ReadWritePart *m_part; + + KToggleAction *m_toolbarAction; + KToggleAction *m_statusbarAction; +}; + +#endif // _%{APPNAMEUC}_H_ diff --git a/languages/cpp/app_templates/kpartapp/app.kdevelop b/languages/cpp/app_templates/kpartapp/app.kdevelop new file mode 100644 index 00000000..3adbae9e --- /dev/null +++ b/languages/cpp/app_templates/kpartapp/app.kdevelop @@ -0,0 +1,115 @@ +<?xml version="1.0"?> +<kdevelop> + <general> + <author>%{AUTHOR}</author> + <email>%{EMAIL}</email> + <version>%{VERSION}</version> + <projectmanagement>KDevKDEAutoProject</projectmanagement> + <primarylanguage>C++</primarylanguage> + <keywords> + <keyword>C++</keyword> + <keyword>Code</keyword> + <keyword>Qt</keyword> + <keyword>KDE</keyword> + </keywords> + </general> + <kdevcppsupport> + <qt> + <version>3</version> + <used>true</used> + <includestyle>3</includestyle> + <designerintegration>EmbeddedKDevDesigner</designerintegration> + </qt> + </kdevcppsupport> + + <kdevautoproject> + <general> + <activetarget>src/%{APPNAMELC}</activetarget> + <useconfiguration>debug</useconfiguration> + </general> + <run> + <mainprogram>src/%{APPNAMELC}</mainprogram> + </run> + <configurations> + <optimized> + <builddir>optimized</builddir> + <ccompiler>kdevgccoptions</ccompiler> + <cxxcompiler>kdevgppoptions</cxxcompiler> + <f77compiler>kdevg77options</f77compiler> + <cxxflags>-O2 -g0</cxxflags> + </optimized> + <debug> + <configargs>--enable-debug=full</configargs> + <builddir>debug</builddir> + <ccompiler>kdevgccoptions</ccompiler> + <cxxcompiler>kdevgppoptions</cxxcompiler> + <f77compiler>kdevg77options</f77compiler> + <cxxflags>-O0 -g3</cxxflags> + </debug> + </configurations> +</kdevautoproject> + <kdevfileview> + <groups> + <group pattern="*.cpp;*.cxx;*.h" name="Sources" /> + <group pattern="*.ui" name="User Interface" /> + <group pattern="*.png" name="Icons" /> + <group pattern="*.po;*.ts" name="Translations" /> + <group pattern="*" name="Others" /> + </groups> + </kdevfileview> + <kdevdoctreeview> + <ignoretocs> + <toc>ada</toc> + <toc>ada_bugs_gcc</toc> + <toc>bash</toc> + <toc>bash_bugs</toc> + <toc>clanlib</toc> + <toc>w3c-dom-level2-html</toc> + <toc>fortran_bugs_gcc</toc> + <toc>gnome1</toc> + <toc>gnustep</toc> + <toc>gtk</toc> + <toc>gtk_bugs</toc> + <toc>haskell</toc> + <toc>haskell_bugs_ghc</toc> + <toc>java_bugs_gcc</toc> + <toc>java_bugs_sun</toc> + <toc>pascal_bugs_fp</toc> + <toc>php</toc> + <toc>php_bugs</toc> + <toc>perl</toc> + <toc>perl_bugs</toc> + <toc>python</toc> + <toc>python_bugs</toc> + <toc>ruby</toc> + <toc>ruby_bugs</toc> + <toc>sdl</toc> + <toc>w3c-svg</toc> + <toc>sw</toc> + <toc>w3c-uaag10</toc> + <toc>wxwidgets_bugs</toc> + </ignoretocs> + <ignoreqt_xml> + <toc>qmake User Guide</toc> + </ignoreqt_xml> + </kdevdoctreeview> + <kdevdebugger> + <general> + <dbgshell>libtool</dbgshell> + </general> + </kdevdebugger> + <kdevfilecreate> + <filetypes/> + <useglobaltypes> + <type ext="ui" /> + <type ext="cpp" /> + <type ext="h" /> + </useglobaltypes> + </kdevfilecreate> + <kdevdocumentation> + <projectdoc> + <docsystem>Doxygen Documentation Collection</docsystem> + <docurl>%{APPNAMELC}.tag</docurl> + </projectdoc> + </kdevdocumentation> +</kdevelop> diff --git a/languages/cpp/app_templates/kpartapp/app_part.cpp b/languages/cpp/app_templates/kpartapp/app_part.cpp new file mode 100644 index 00000000..bf63557f --- /dev/null +++ b/languages/cpp/app_templates/kpartapp/app_part.cpp @@ -0,0 +1,201 @@ + +#include "%{APPNAMELC}_part.h" + +#include <kinstance.h> +#include <kaction.h> +#include <kstdaction.h> +#include <kfiledialog.h> +#include <kglobal.h> +#include <klocale.h> + +#include <qfile.h> +#include <qtextstream.h> +#include <qmultilineedit.h> + +%{APPNAME}Part::%{APPNAME}Part( QWidget *parentWidget, const char *widgetName, + QObject *parent, const char *name ) + : KParts::ReadWritePart(parent, name) +{ + // we need an instance + setInstance( %{APPNAME}PartFactory::instance() ); + + // this should be your custom internal widget + m_widget = new QMultiLineEdit( parentWidget, widgetName ); + + // notify the part that this is our internal widget + setWidget(m_widget); + + // create our actions + KStdAction::open(this, SLOT(fileOpen()), actionCollection()); + KStdAction::saveAs(this, SLOT(fileSaveAs()), actionCollection()); + KStdAction::save(this, SLOT(save()), actionCollection()); + + // set our XML-UI resource file + setXMLFile("%{APPNAMELC}_part.rc"); + + // we are read-write by default + setReadWrite(true); + + // we are not modified since we haven't done anything yet + setModified(false); +} + +%{APPNAME}Part::~%{APPNAME}Part() +{ +} + +void %{APPNAME}Part::setReadWrite(bool rw) +{ + // notify your internal widget of the read-write state + m_widget->setReadOnly(!rw); + if (rw) + connect(m_widget, SIGNAL(textChanged()), + this, SLOT(setModified())); + else + { + disconnect(m_widget, SIGNAL(textChanged()), + this, SLOT(setModified())); + } + + ReadWritePart::setReadWrite(rw); +} + +void %{APPNAME}Part::setModified(bool modified) +{ + // get a handle on our Save action and make sure it is valid + KAction *save = actionCollection()->action(KStdAction::stdName(KStdAction::Save)); + if (!save) + return; + + // if so, we either enable or disable it based on the current + // state + if (modified) + save->setEnabled(true); + else + save->setEnabled(false); + + // in any event, we want our parent to do it's thing + ReadWritePart::setModified(modified); +} + +bool %{APPNAME}Part::openFile() +{ + // m_file is always local so we can use QFile on it + QFile file(m_file); + if (file.open(IO_ReadOnly) == false) + return false; + + // our example widget is text-based, so we use QTextStream instead + // of a raw QDataStream + QTextStream stream(&file); + QString str; + while (!stream.eof()) + str += stream.readLine() + "\n"; + + file.close(); + + // now that we have the entire file, display it + m_widget->setText(str); + + // just for fun, set the status bar + emit setStatusBarText( m_url.prettyURL() ); + + return true; +} + +bool %{APPNAME}Part::saveFile() +{ + // if we aren't read-write, return immediately + if (isReadWrite() == false) + return false; + + // m_file is always local, so we use QFile + QFile file(m_file); + if (file.open(IO_WriteOnly) == false) + return false; + + // use QTextStream to dump the text to the file + QTextStream stream(&file); + stream << m_widget->text(); + + file.close(); + + return true; +} + +void %{APPNAME}Part::fileOpen() +{ + // this slot is called whenever the File->Open menu is selected, + // the Open shortcut is pressed (usually CTRL+O) or the Open toolbar + // button is clicked + QString file_name = KFileDialog::getOpenFileName(); + + if (file_name.isEmpty() == false) + openURL(file_name); +} + +void %{APPNAME}Part::fileSaveAs() +{ + // this slot is called whenever the File->Save As menu is selected, + QString file_name = KFileDialog::getSaveFileName(); + if (file_name.isEmpty() == false) + saveAs(file_name); +} + + +// It's usually safe to leave the factory code alone.. with the +// notable exception of the KAboutData data +#include <kaboutdata.h> +#include <klocale.h> + +KInstance* %{APPNAME}PartFactory::s_instance = 0L; +KAboutData* %{APPNAME}PartFactory::s_about = 0L; + +%{APPNAME}PartFactory::%{APPNAME}PartFactory() + : KParts::Factory() +{ +} + +%{APPNAME}PartFactory::~%{APPNAME}PartFactory() +{ + delete s_instance; + delete s_about; + + s_instance = 0L; +} + +KParts::Part* %{APPNAME}PartFactory::createPartObject( QWidget *parentWidget, const char *widgetName, + QObject *parent, const char *name, + const char *classname, const QStringList &args ) +{ + // Create an instance of our Part + %{APPNAME}Part* obj = new %{APPNAME}Part( parentWidget, widgetName, parent, name ); + + // See if we are to be read-write or not + if (QCString(classname) == "KParts::ReadOnlyPart") + obj->setReadWrite(false); + + return obj; +} + +KInstance* %{APPNAME}PartFactory::instance() +{ + if( !s_instance ) + { + s_about = new KAboutData("%{APPNAMELC}part", I18N_NOOP("%{APPNAME}Part"), "%{VERSION}"); + s_about->addAuthor("%{AUTHOR}", 0, "%{EMAIL}"); + s_instance = new KInstance(s_about); + } + return s_instance; +} + +extern "C" +{ + void* init_lib%{APPNAMELC}part() + { + KGlobal::locale()->insertCatalogue("%{APPNAMELC}"); + return new %{APPNAME}PartFactory; + } +}; + +#include "%{APPNAMELC}_part.moc" diff --git a/languages/cpp/app_templates/kpartapp/app_part.h b/languages/cpp/app_templates/kpartapp/app_part.h new file mode 100644 index 00000000..37c30189 --- /dev/null +++ b/languages/cpp/app_templates/kpartapp/app_part.h @@ -0,0 +1,86 @@ + +#ifndef _%{APPNAMEUC}PART_H_ +#define _%{APPNAMEUC}PART_H_ + +#include <kparts/part.h> +#include <kparts/factory.h> + +class QWidget; +class QPainter; +class KURL; +class QMultiLineEdit; + +/** + * This is a "Part". It that does all the real work in a KPart + * application. + * + * @short Main Part + * @author %{AUTHOR} <%{EMAIL}> + * @version %{VERSION} + */ +class %{APPNAME}Part : public KParts::ReadWritePart +{ + Q_OBJECT +public: + /** + * Default constructor + */ + %{APPNAME}Part(QWidget *parentWidget, const char *widgetName, + QObject *parent, const char *name); + + /** + * Destructor + */ + virtual ~%{APPNAME}Part(); + + /** + * This is a virtual function inherited from KParts::ReadWritePart. + * A shell will use this to inform this Part if it should act + * read-only + */ + virtual void setReadWrite(bool rw); + + /** + * Reimplemented to disable and enable Save action + */ + virtual void setModified(bool modified); + +protected: + /** + * This must be implemented by each part + */ + virtual bool openFile(); + + /** + * This must be implemented by each read-write part + */ + virtual bool saveFile(); + +protected slots: + void fileOpen(); + void fileSaveAs(); + +private: + QMultiLineEdit *m_widget; +}; + +class KInstance; +class KAboutData; + +class %{APPNAME}PartFactory : public KParts::Factory +{ + Q_OBJECT +public: + %{APPNAME}PartFactory(); + virtual ~%{APPNAME}PartFactory(); + virtual KParts::Part* createPartObject( QWidget *parentWidget, const char *widgetName, + QObject *parent, const char *name, + const char *classname, const QStringList &args ); + static KInstance* instance(); + +private: + static KInstance* s_instance; + static KAboutData* s_about; +}; + +#endif // _%{APPNAMEUC}PART_H_ diff --git a/languages/cpp/app_templates/kpartapp/app_part.rc b/languages/cpp/app_templates/kpartapp/app_part.rc new file mode 100644 index 00000000..cec8ec5c --- /dev/null +++ b/languages/cpp/app_templates/kpartapp/app_part.rc @@ -0,0 +1,17 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui name="%{APPNAMELC}_part" version="1"> +<MenuBar> + <Menu name="file"> + <Action name="file_open"/> + <Separator/> + <Action name="file_save"/> + <Action name="file_save_as"/> + </Menu> +</MenuBar> +<ToolBar name="mainToolBar"> + <Action name="file_open"/> + <Action name="file_save"/> + <Action name="file_print"/> + <Separator/> +</ToolBar> +</kpartgui> diff --git a/languages/cpp/app_templates/kpartapp/app_shell.rc b/languages/cpp/app_templates/kpartapp/app_shell.rc new file mode 100644 index 00000000..e0600cda --- /dev/null +++ b/languages/cpp/app_templates/kpartapp/app_shell.rc @@ -0,0 +1,28 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui name="%{APPNAMELC}_shell" version="1"> +<MenuBar> + <Menu noMerge="1" name="file"><text>&File</text> + <Action name="file_new"/> + <Merge/> + <Separator/> + <Action name="file_quit"/> + </Menu> + <Menu noMerge="1" name="settings"><text>&Settings</text> + <Action name="options_show_toolbar"/> + <Action name="options_show_statusbar"/> + <Merge name="show_merge"/> + <Separator/> + <Action name="options_configure_keybinding"/> + <Action name="options_configure_toolbars"/> + <Action name="options_configure"/> + <Merge name="configure_merge"/> + <Separator/> + <Merge/> + </Menu> +</MenuBar> +<ToolBar noMerge="1" name="mainToolBar"><text>Main Toolbar</text> + <Action name="file_new"/> + <Merge/> + <Action name="help"/> +</ToolBar> +</kpartgui> diff --git a/languages/cpp/app_templates/kpartapp/kpartapp.kdevtemplate b/languages/cpp/app_templates/kpartapp/kpartapp.kdevtemplate new file mode 100644 index 00000000..03583faa --- /dev/null +++ b/languages/cpp/app_templates/kpartapp/kpartapp.kdevtemplate @@ -0,0 +1,237 @@ +# KDE Config File +[General] +Name=Application framework (KParts) +Name[ca]=Infraestructura d'aplicació (KParts) +Name[da]=Programskelet (KParts) +Name[de]=Anwendungsgerüst (KParts) +Name[el]=Πλαίσιο εφαρμογής (KParts) +Name[es]=Infraestructura de aplicación (KParts) +Name[et]=Rakenduse raamistik (KParts) +Name[eu]=Aplikazioen lan-markoa (KParts) +Name[fa]=(KParts)چارچوب کاربرد +Name[fr]=Infrastructure d'application (KParts) +Name[ga]=Creatlach feidhmchláir (KParts) +Name[gl]=Entorno de traballo de aplicación (KParts) +Name[hu]=Alkalmazás-keretrendszer (objektumokkal) +Name[it]=Infrastruttura applicativa (KParts) +Name[ja]=アプリケーションフレームワーク (KParts) +Name[nds]=Programmrahmenwark (KParts) +Name[ne]=अनुप्रयोग फ्रेमवर्क (केडीई भाग) +Name[nl]=Toepassingframework (KParts) +Name[pl]=Szablon progamu (KParts) +Name[pt]=Plataforma de aplicações (KParts) +Name[pt_BR]=Plataforma de aplicações (KParts) +Name[ru]=Приложение KPart +Name[sk]=Aplikačný framework (KParts) +Name[sr]=Радни оквир програма (KParts) +Name[sr@Latn]=Radni okvir programa (KParts) +Name[sv]=Programramverk (KParts) +Name[tr]=Uygulama Çatısı (KParts) +Name[zh_CN]=应用程序框架(KParts) +Name[zh_TW]=應用程式框架(KParts) +Icon=kpartapp.png +Category=C++/KDE +Comment=Generates a complex KDE application with a KParts shell and a KPart component. +Comment[ca]=Genera una complexa aplicació per al KDE amb un intèrpret de comandaments KParts i un component KPart. +Comment[da]=Genererer et komplekst KDE-program med en KParts-skal og en KPart-komponent. +Comment[de]=Erstellt eine aufwändige KDE-Anwendung mit einer Shell für KParts und einer KPart-Komponente. +Comment[el]=Δημιουργεί μια πολύπλοκη εφαρμογή KDE με ένα κέλυφος KParts και ένα συστατικό KPart. +Comment[es]=Genera una aplicación KDE compleja con un contenedor KParts y un componente KPart. +Comment[et]=Keerulise KDE rakenduse loomine KParts-shelliga ja KPart-komponendiga. +Comment[eu]=KDE aplikazio konplexu bat sortzen du KParts shellbat eta KPart osagai batekin. +Comment[fa]=یک کاربرد پیچیدۀ KDE با یک پوستۀ KParts و یک مؤلفۀ KPart تولید میکند. +Comment[fr]=Génère une application KDE évoluée comprenant un shell KParts et un composant KPart. +Comment[ga]=Cruthaíonn sé seo feidhmchlár casta KDE le blaosc KParts agus comhpháirt KPart. +Comment[gl]=Xera unha aplicación KDE complexa cun terminal KPart e unha compoñente KPart. +Comment[hu]=Létrehoz egy komplex, objektumok használatát támogató KDE-s alkalmazást és egy KPart objektumot. +Comment[it]=Genera un'applicazione complessa di KDE con una shell di KParts e un componente KPart. +Comment[nds]=Stellt en vigeliensch KDE-Programm mit en Konsool för KPart un en KPart-Komponent op. +Comment[ne]=केडीई भाग शेल र केडीई भाग अवयवसँग जटिल केडीई अनुप्रयोग उत्पन्न गर्दछ । +Comment[nl]=Genereert een complexe KDE-toepassing met een KParts-shell en een KPart-component. +Comment[pl]=Generuje złożony program z powłoką KParts i komponentem KPart. +Comment[pt]=Gera uma aplicação complexa do KDE com uma infra-estrutura de KParts, bem como um componente KPart. +Comment[pt_BR]=Gera uma aplicação complexa do KDE com uma infra-estrutura de KParts, bem como um componente KPart. +Comment[ru]=Создание полноценного приложения KDE на базе компонента KPart. +Comment[sk]=Vygeneruje komplexnú KDE aplikáciu s KParts shell a s KPart komponentom. +Comment[sr]=Прави сложени KDE програм са KParts шкољком и KPart компонентом. +Comment[sr@Latn]=Pravi složeni KDE program sa KParts školjkom i KPart komponentom. +Comment[sv]=Skapar ett komplext KDE-program med ett KPart-skal och en KPart-komponent. +Comment[tr]=Bir KParts kabuğu ve KParts bileşeni olan karmaşık bir KDE uygulaması yaratır. +Comment[zh_CN]=生成一个带 KParts 外壳和 KPart 组件的复杂 KDE 应用程序。 +Comment[zh_TW]=產生一個複雜的 KDE 應用程式,內含 KParts shell 與 KPart 元件。 +FileTemplates=h,CStyle,cpp,CStyle +ShowFilesAfterGeneration=%{dest}/src/%{APPNAMELC}_part.cpp +Archive=kpartapp.tar.gz + +[ADMIN] +Type=include +File=%{kdevelop}/template-common/admin.kdevtemplate + +[GNU] +Type=include +File=%{kdevelop}/template-common/gnu.kdevtemplate + +[MKDIR_DOCBOOK1] +Type=mkdir +Dir=%{dest}/doc + +[MKDIR_DOCBOOK2] +Type=mkdir +Dir=%{dest}/doc/en + +[FILE1] +Type=install +Source=%{kdevelop}/template-common/kde-doc-Makefile.am +Dest=%{dest}/doc/Makefile.am + +[FILE2] +Type=install +Source=%{kdevelop}/template-common/kde-doc-en-Makefile.am +Dest=%{dest}/doc/en/Makefile.am + +[FILE3] +Type=install +EscapeXML=true +Source=%{kdevelop}/template-common/kde-index.docbook +Dest=%{dest}/doc/en/index.docbook + +[FILE4] +Type=install +EscapeXML=true +Source=%{src}/app.kdevelop +Dest=%{dest}/%{APPNAMELC}.kdevelop + +[FILE5] +Type=install +Source=%{kdevelop}/template-common/kde-Makefile.cvs +Dest=%{dest}/Makefile.cvs + +[FILE6] +Type=install +Source=%{kdevelop}/template-common/kde-Makefile.am +Dest=%{dest}/Makefile.am + +[FILE7] +Type=install +Source=%{kdevelop}/template-common/kde-configure.in.in +Dest=%{dest}/configure.in.in + +[MkDir3] +Type=mkdir +Dir=%{dest}/src + +[FILE8] +Type=install +Source=%{kdevelop}/template-common/kde-part.desktop +Dest=%{dest}/src/%{APPNAMELC}_part.desktop + +[FILE9] +Type=install +Source=%{kdevelop}/template-common/kde-app.desktop +Dest=%{dest}/src/%{APPNAMELC}.desktop + +[FILE10] +Type=install +Source=%{kdevelop}/template-common/kde-app.lsm +Dest=%{dest}/src/%{APPNAMELC}.lsm + +[FILE11] +Type=install +Source=%{kdevelop}/template-common/hi16-app-app.png +Dest=%{dest}/src/hi16-app-%{APPNAMELC}.png +Process=false + +[FILE12] +Type=install +Source=%{kdevelop}/template-common/hi32-app-app.png +Dest=%{dest}/src/hi32-app-%{APPNAMELC}.png +Process=false + +[MkDir4] +Type=mkdir +Dir=%{dest}/po + +[FILE13] +Type=install +Source=%{kdevelop}/template-common/kde-po-Makefile.am +Dest=%{dest}/po/Makefile.am + +[FILE14] +Type=install +Source=%{src}/subdirs +Dest=%{dest}/subdirs + +[FILE15] +Type=install +Source=%{src}/src-Makefile.am +Dest=%{dest}/src/Makefile.am + +[FILE16] +Type=install +Source=%{src}/app.cpp +Dest=%{dest}/src/%{APPNAMELC}.cpp + +[FILE17] +Type=install +Source=%{src}/app.h +Dest=%{dest}/src/%{APPNAMELC}.h + +[FILE18] +Type=install +Source=%{src}/app_part.cpp +Dest=%{dest}/src/%{APPNAMELC}_part.cpp + +[FILE19] +Type=install +Source=%{src}/app_part.h +Dest=%{dest}/src/%{APPNAMELC}_part.h + +[FILE20] +Type=install +Source=%{src}/main.cpp +Dest=%{dest}/src/main.cpp + +[FILE21] +Type=install +EscapeXML=true +Source=%{src}/app_part.rc +Dest=%{dest}/src/%{APPNAMELC}_part.rc + +[FILE22] +Type=install +EscapeXML=true +Source=%{src}/app_shell.rc +Dest=%{dest}/src/%{APPNAMELC}_shell.rc + +[MSG] +Type=message +Comment=A complex KDE application using KParts was created in %{dest} +Comment[ca]=Una complexa aplicació per al KDE usant KParts ha estat creada en %{dest} +Comment[da]=Et komplekst KDE-program ved brug af KParts blev oprettet i %{dest} +Comment[de]=Eine aufwändige KDE-Anwendung, die KParts verwendet, wurde in %{dest} erstellt. +Comment[el]=Μια πολύπλοκη εφαρμογή KDE που χρησιμοποιεί το KParts δημιουργήθηκε στο %{dest} +Comment[es]=Una aplicación compleja para KDE que usa KParts ha sido creada en %{dest} +Comment[et]=KParts'i kasutav keeruline KDE rakendus loodi asukohta %{dest} +Comment[eu]=KDE aplikazio konplexu bat sortu da hemen: %{dest} +Comment[fa]=یک کاربرد پیچیدۀ KDE با استفاده از KParts در %{dest} ایجاد شد +Comment[fr]=Une application KDE évoluée utilisant KParts a été créée dans %{dest} +Comment[ga]=Cruthaíodh feidhmchlár casta KDE a úsáideann KParts i %{dest} +Comment[gl]=Creouse unha aplicación KDE complexa usando KParts en %{dest} +Comment[hu]=Létrejött egy komplex, objektumok használatát támogató KDE-s alkalmazás itt: %{dest} +Comment[it]=È stata creata un'applicazione KDE complessa usando KParts in %{dest} +Comment[ja]=KParts を使った複雑な KDE アプリケーションを %{dest} に作成しました +Comment[nds]=In %{dest} wöör en vigeliensch KDE-Programm opstellt, dat "KParts" bruukt. +Comment[ne]=केडीई भाग प्रयोग गरेर जटिल केडीई अनुप्रयोग %{dest} मा सिर्जना गरियो +Comment[nl]=Een complexe KDE-toepassing gebruik makend van KParts is aangemaakt in %{dest} +Comment[pl]=Złożony program KDE używający KParts został utworzony w %{dest} +Comment[pt]=Foi criada uma aplicação complexa do KDE, que usa o KParts, em %{dest} +Comment[pt_BR]=Foi criada uma aplicação complexa do KDE, que usa o KParts, em %{dest} +Comment[ru]=Приложение KDE на базе компонента KPart создано в %{dest} +Comment[sk]=Komplexná KDE aplikácia používajúca KParts bola vytvorená v %{dest} +Comment[sr]=Сложени KDE програм на основу KParts направљен је у %{dest} +Comment[sr@Latn]=Složeni KDE program na osnovu KParts napravljen je u %{dest} +Comment[sv]=Ett komplext KDE-program som använder KParts skapades i %{dest} +Comment[tr]=KParts kullanan karmaşık bir KDE uygulaması %{dest} içinde yaratıldı. +Comment[zh_CN]=在 %{dest} 中创建了一个使用 KParts 的复杂 KDE 应用程序 +Comment[zh_TW]=一個使用 KParts 的複雜 KDE 應用程式已建立於 %{dest} + diff --git a/languages/cpp/app_templates/kpartapp/kpartapp.png b/languages/cpp/app_templates/kpartapp/kpartapp.png Binary files differnew file mode 100644 index 00000000..5834ac9f --- /dev/null +++ b/languages/cpp/app_templates/kpartapp/kpartapp.png diff --git a/languages/cpp/app_templates/kpartapp/main.cpp b/languages/cpp/app_templates/kpartapp/main.cpp new file mode 100644 index 00000000..a7c0d2c4 --- /dev/null +++ b/languages/cpp/app_templates/kpartapp/main.cpp @@ -0,0 +1,57 @@ + +#include "%{APPNAMELC}.h" +#include <kapplication.h> +#include <kaboutdata.h> +#include <kcmdlineargs.h> +#include <klocale.h> + +static const char description[] = + I18N_NOOP("A KDE KPart Application"); + +static const char version[] = "%{VERSION}"; + +static KCmdLineOptions options[] = +{ + { "+[URL]", I18N_NOOP( "Document to open" ), 0 }, + KCmdLineLastOption +}; + +int main(int argc, char **argv) +{ + KAboutData about("%{APPNAMELC}", I18N_NOOP("%{APPNAME}"), version, description, + KAboutData::License_%{LICENSE}, "(C) %{YEAR} %{AUTHOR}", 0, 0, "%{EMAIL}"); + about.addAuthor( "%{AUTHOR}", 0, "%{EMAIL}" ); + KCmdLineArgs::init(argc, argv, &about); + KCmdLineArgs::addCmdLineOptions( options ); + KApplication app; + + // see if we are starting with session management + if (app.isRestored()) + { + RESTORE(%{APPNAME}); + } + else + { + // no session.. just start up normally + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + if ( args->count() == 0 ) + { + %{APPNAME} *widget = new %{APPNAME}; + widget->show(); + } + else + { + int i = 0; + for (; i < args->count(); i++ ) + { + %{APPNAME} *widget = new %{APPNAME}; + widget->show(); + widget->load( args->url( i ) ); + } + } + args->clear(); + } + + return app.exec(); +} diff --git a/languages/cpp/app_templates/kpartapp/src-Makefile.am b/languages/cpp/app_templates/kpartapp/src-Makefile.am new file mode 100644 index 00000000..357e2d0b --- /dev/null +++ b/languages/cpp/app_templates/kpartapp/src-Makefile.am @@ -0,0 +1,53 @@ +# set the include path for X, qt and KDE +INCLUDES = $(all_includes) + +# these are the headers for your project +noinst_HEADERS = %{APPNAMELC}.h %{APPNAMELC}_part.h + +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + +messages: rc.cpp + $(EXTRACTRC) `find . -name \*.ui -o -name \*.rc` > rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/%{APPNAMELC}.pot + +KDE_ICON = AUTO + +# this Makefile creates both a KPart application and a KPart +######################################################################### +# APPLICATION SECTION +######################################################################### +# this is the program that gets installed. it's name is used for all +# of the other Makefile.am variables +bin_PROGRAMS = %{APPNAMELC} + +# the application source, library search path, and link libraries +%{APPNAMELC}_SOURCES = main.cpp %{APPNAMELC}.cpp +%{APPNAMELC}_LDFLAGS = $(KDE_RPATH) $(all_libraries) +%{APPNAMELC}_LDADD = $(LIB_KPARTS) + +# this is where the desktop file will go +shelldesktopdir = $(kde_appsdir)/Utilities +shelldesktop_DATA = %{APPNAMELC}.desktop + +# this is where the shell's XML-GUI resource file goes +shellrcdir = $(kde_datadir)/%{APPNAMELC} +shellrc_DATA = %{APPNAMELC}_shell.rc + +######################################################################### +# KPART SECTION +######################################################################### +kde_module_LTLIBRARIES = lib%{APPNAMELC}part.la + +# the Part's source, library search path, and link libraries +lib%{APPNAMELC}part_la_SOURCES = %{APPNAMELC}_part.cpp +lib%{APPNAMELC}part_la_LDFLAGS = -module -avoid-version -no-undefined $(KDE_PLUGIN) $(all_libraries) +lib%{APPNAMELC}part_la_LIBADD = $(LIB_KPARTS) $(LIB_KFILE) + +# this is where the desktop file will go +partdesktopdir = $(kde_servicesdir) +partdesktop_DATA = %{APPNAMELC}_part.desktop + +# this is where the part's XML-GUI resource file goes +partrcdir = $(kde_datadir)/%{APPNAMELC}part +partrc_DATA = %{APPNAMELC}_part.rc diff --git a/languages/cpp/app_templates/kpartapp/subdirs b/languages/cpp/app_templates/kpartapp/subdirs new file mode 100644 index 00000000..0e678106 --- /dev/null +++ b/languages/cpp/app_templates/kpartapp/subdirs @@ -0,0 +1,3 @@ +doc +po +src |