diff options
Diffstat (limited to 'kapptemplate')
99 files changed, 3909 insertions, 0 deletions
diff --git a/kapptemplate/ChangeLog b/kapptemplate/ChangeLog new file mode 100644 index 00000000..1c1721c3 --- /dev/null +++ b/kapptemplate/ChangeLog @@ -0,0 +1,200 @@ +July-01-2004 - Michael Goettsche + o Update some dates to 2004 + +Jan-09-2003 - Kurt Granroth + o Use variable subst in kpartapp/main.cpp instead of my hard-coded + email address + o Update some dates to 2003 + +Mar-25-2002 - Frerich Raabe (v1.1.1) + o Changes to make kapptemplate work better under *BSD (no more hard- + coded 'make') + +Feb-12-2002 - Kurt Granroth (v1.1) + o Restructuring change to make kapptemplate behave a little better + during installation. Now, the standard 'make' commands should + work. The 'install-me' script is gone. + +Nov-10-2001 - Simon Hausmann + o Added missing kstatusbar.h include in app.cpp + o Use KParts::GenericFactory and KGenericFactory to reduce + boilerplate code + +Jul-30-2001 - Kurt Granroth + o KAppTemplate isn't really a 'sh' shell script.. it's a 'bash' + shell script. Changed #! line to reflect this. + +Jul-06-2001 - Kurt Granroth + o Fixed 'configure toolbar' in part app template + o KIONetAccess is now (and has been for some time) KIO::NetAccess + +Jul-05-2001 - Kurt Granroth (v1.0.6) + o KPartApp's part should be in it's own directory. Did it ever work + as-was? XML merging between shell and part should now work. + o Added new hi-color default icons to kpartapp and kapp + +Jun-30-2001 - David Faure + o Include .moc files in .cpp files in kapp template + +Mar-29-2001 - Nikolas Zimmermann + o Converted kapp template to use new KPrinter printing framework + +Feb-16-2001 - Kurt Granroth (v1.0.5) + o KParts::Factory, it seems, should not be used with plugins + +Feb-15-2001 - Kurt Granroth (v1.0.4) + o Create a "real" factory for the KPart plugins instead of using a + generic one + o Use 'find' instead of 'ls' for listing files. Works better on + FreeBSD. Thanks to Jonathan Belson <jon@witchspace.com> for the + heads up. + o Fixed command line args and module selection code. Thanks to + David Jarvie <djarvie@lineone.net> for the fix. + +Feb-04-2001 - Kurt Granroth (v1.0.3) + o Converted App::load method to use KURL instead of QString in kapp + module + o Added +[URL] command line option in kapp module + +Feb-04-2001 - Simon Hausman (v1.0.2) + o Converted App::load method to use KURL instead of QString in kpart + module + o Used correct constructor for Part in kpart module + o Used correct instance() in kpart module + o Other random correctness fixes in kpart module + o Added +[URL] command line option in kpart module + +Feb-04-2001 - Simon Hausman (v1.0.1) + o Fixed memory leak in plugin module + o Use createObject instead of old create in plugin module + o Added version number to xml file in plugin module + o Fixed integration of configure.in.in in kdesdk + +Feb-04-2001 - Kurt Granroth (v1.0) + o GIGANTIC REWRITE. This was *almost* a complete rewrite from + scratch + o Made entire system much more modular allowing for future + frameworks to be easily added + o Added module to create a full KParts application + o Added module to create a KPart plugin + o Added module to create an autoconf/automake framework for existing + source code + o Added more command-line options to speed up creation of projects + o Dropped knewclass and knewfunction as they were next to useless + +Dec-10-2000 - Kurt Granroth (v0.7.5) + o Finally fixed --noinit for real + o kapptemplate no longer needs to be in your $PATH + +Nov-20-2000 - Kurt Granroth (v0.7.4) + o Added custom menu item and menu as example on how to do it + o Fixed some --noinit bugs + +Oct-27-2000 - Stephan Kulow (v0.7.3) + o Fixed pot file handling. 'make package-messages' should now work. + +Oct-14-2000 - Malte Starostik (v0.7.2) + o Added --help option + o Added option to not run ./configure on newly created project + +Sep-26-2000 - Kurt Granroth (v0.7.1) + o Added hooks for more KAboutData information + o Now building moc files as moc.cpp instead of #including them + +Jul-21-2000 - Kurt Granroth (v0.7) + o Now using an HTML KPart component instead of a widget since that + is The Right Thing to Do(tm) + o Renamed .png files to use sizes in the names + +Jun-09-2000 - Kurt Granroth (v0.6.3) + o Added i18n() around preference titles... mostly so it would + compile with the newly ambiguous KDialogBase::addPage methods + +May-30-2000 - Kurt Granroth (v0.6.2) + o Removed KAccel stuff... KKeyDialog can handle action collections + o Use KURLRequesterDlg instead of homemade job + +Mar-14-2000 - Kurt Granroth (v0.6.1) + o Added toolbar editor + o Changed sample html code to reflect khtml changes + +Feb-26-2000 - Kurt Granroth (v0.6) + o Converted to use the new XML UI framework (big change!) + +Jan-12-2000 - Kurt Granroth (v0.5.2) + o Use KAboutData and KCmdLineArgs + +Dec-28-1999 - Kurt Granroth (v0.5.1) + o The po Makefile now uses the autogenerated rules. I don't know + why I didn't notice that capability before + +Dec-25-1999 - Kurt Granroth (v0.5) + o Use standard actions instead of constructing everything manually + (big change!) + o Allow .po files to be installed in $DESTDIR + o Added .spec file for RPM fans + +Dec-05-1999 - Kurt Granroth (v0.4.5) + o Changed 'QCString' to QString in DCOP iface stuff... + +Nov-29-1999 - Kurt Granroth (v0.4.4) + o Added sample DCOP client for app + o Fixed .desktop file + o Made QPrinter a member var so settings are saved + +Nov-26-1999 - Kurt Granroth (v0.4.3) + o Beefed up the print function with more boilerplate stuff + o KAccel keys should now work + +Nov-20-1999 - Kurt Granroth (v0.4.2) + o Use mkinstalldirs instead of mkdir + +Nov-04-1999 - Kurt Granroth (v0.4.1) + o Removed a few files from common/ that are in admin/ (missing, + install-sh, mkinstalldirs) + o Renamed .png files to "proper" naming convention + o Got rid of admin/ directory from CVS. It is now copied over from + the common admin directory (found in kdesdk/admin). This should + prevent a lot of redundent updates + +Nov-02-1999 - Kurt Granroth (v0.4) + o Updated for KDE 2.x. The produced application now has a LOT more + functionality than before -- it is a scriptable web browser (see + dcopclient.py for more info on that)! + +Jan-24-1999 - Kurt Granroth (v0.3.2) + o Added LIB_X11 and LIB_QT to acinclude.m4 + +Jan-18-1999 - Kurt Granroth (v0.3.1) + o AUGH!! I forgot 'acinclude.m4'!! + o Slightly modified 'install-me' so that kapptemplate will install from + CVS. It was wigging out when it tried to cp the CVS directory... + +Jan-01-1999 - Kurt Granroth (v0.3) + o Added kapptemplate to kdesdk + o HUGE clean-up of code + o Put in some session management stuff + o Changed main() to use 'App *widget = new App;' instead of 'App widget'. + The latter case caused the app to seg fault if the user closed it + any way other than File->Quit + +Dec-31-1998 - Kurt Granroth + o Added 'knewfunction' module that will add a function to an existing + class + +Dec-27-1998 - Kurt Granroth + o Split kapptemplate into modules. Added 'knewclass' module that will + create a new class + +Dec-25-1998 - Kurt Granroth (v0.2.2) + o Fixed bug in App class where AppWidget needed 'this' parent + o Added 'pics' directory + +Dec-18-1998 - Kurt Granroth + o Added patch from Helmut Bohr <Helmut.Bohr@t-online.de> to properly + escape backquotes in po-Makefile.am + o Changed 'cp' to 'cp -p' to hopefully preserve executable permissions + where needed. + +Dec-04-1998 - Kurt Granroth (v0.2.1) + o released 0.2.1 diff --git a/kapptemplate/Makefile.am b/kapptemplate/Makefile.am new file mode 100644 index 00000000..bf58afdc --- /dev/null +++ b/kapptemplate/Makefile.am @@ -0,0 +1,19 @@ +SUBDIRS=admin appframework existing kapp kpartapp kpartplugin + +VERSION := `cat $(srcdir)/VERSION` + +bin_SCRIPTS = kapptemplate + +kapptemplate: kapptemplate.in + echo "#!/usr/bin/env bash" > kapptemplate; \ + echo "INSTALLED_SHARE_DIR=$(kde_datadir)/kapptemplate" >> kapptemplate; \ + echo "KAPPTEMPLATEVERSION=$(VERSION)" >> kapptemplate; \ + cat $(srcdir)/kapptemplate.in >> kapptemplate; \ + chmod 755 kapptemplate + +databindir = $(kde_datadir)/kapptemplate/bin +databin_SCRIPTS = mkinstalldirs + +moduledir = $(kde_datadir)/kapptemplate/include +module_DATA = kapptemplate.common kapptemplate.module \ + kpartplugin.module kpartapp.module existing.module diff --git a/kapptemplate/Makefile.cvs b/kapptemplate/Makefile.cvs new file mode 100644 index 00000000..2d5db15f --- /dev/null +++ b/kapptemplate/Makefile.cvs @@ -0,0 +1,12 @@ +all: + @echo "Copying over the admin directory"; \ + for file in admin/*; do \ + if [ -f $$file -a $$file != 'admin/Makefile.am' -a $$file != 'admin/Makefile.in' ]; then \ + /bin/rm -f $$file; \ + fi \ + done + @for file in ../admin/*; do \ + if [ -f $$file ]; then \ + cp -p $$file admin/; \ + fi \ + done diff --git a/kapptemplate/README b/kapptemplate/README new file mode 100644 index 00000000..9ee09553 --- /dev/null +++ b/kapptemplate/README @@ -0,0 +1,68 @@ +KAppTemplate v1.1 +Kurt Granroth <granroth@kde.org> +---------------------------------------------------------------------- + +What is it? +----------- +KAppTemplate is a shell script that will create the necessary +framework to develop various KDE applications. It takes care of the +autoconf/automake code as well as providing a skeleton and example of +what the code typically looks like. + +Currently, KAppTemplate creates four different types of frameworks: + +1) Full featured KDE application + + This is a "normal" KDE application with nearly every bleeding edge + feature. + +2) KPart application + + This creates a KDE application that uses KParts as both the Shell + and the Part (KParts::MainWindow and KParts::ReadWritePart) + +3) KPart plugin + + This creates a sample KPart plugin that acts on KHTMLPart + +4) Existing application conversion + + This will take existing source and put it in a KDE automake/autoconf + framework + +What is a framework? +-------------------- +When I say "framework", I mean all of the source files as well as the +autoconf/automake stuff. When KAppTemplate is done, all you will need +to do to compile and install your app is: + ./configure + make && make install + +What do I need to use this? +--------------------------- +o KDE 3.x +o autoconf +o automake + +How do I install it? +-------------------- +If you have a standalone kapptemplate.tar.bz2, do: + ./configure + make && make install +If you are installing from kdesdk, then just + make && make install +If you are installing from .deb or .rpm, then install like any other +normal package + +How does <whatever> work? +------------------------- +Before you email me, look through the kapptemplate file. It is a +shell script so it should be pretty easy to understand what is going +on. + +I have a suggest, question, or comment +-------------------------------------- +Well, email me, then! + +Have fun! +Kurt Granroth <granroth@kde.org> diff --git a/kapptemplate/VERSION b/kapptemplate/VERSION new file mode 100644 index 00000000..524cb552 --- /dev/null +++ b/kapptemplate/VERSION @@ -0,0 +1 @@ +1.1.1 diff --git a/kapptemplate/admin/Makefile.am b/kapptemplate/admin/Makefile.am new file mode 100644 index 00000000..fef6965c --- /dev/null +++ b/kapptemplate/admin/Makefile.am @@ -0,0 +1,12 @@ +install-data-local: + $(mkinstalldirs) $(DESTDIR)$(kde_datadir)/kapptemplate/admin + for file in $(srcdir)/*; do \ + if [ -f $$file -a $$file != 'Makefile' -a $$file != 'Makefile.in' -a $$file != 'Makefile.am' ]; then \ + destfile=`basename $$file` \ + $(INSTALL_DATA) $$file \ + $(DESTDIR)$(kde_datadir)/kapptemplate/admin/$$destfile; \ + fi \ + done + +uninstall-local: + -/bin/rm -rf $(DESTDIR)$(kde_datadir)/kapptemplate/admin diff --git a/kapptemplate/appframework/AUTHORS b/kapptemplate/appframework/AUTHORS new file mode 100644 index 00000000..4c2a9fd3 --- /dev/null +++ b/kapptemplate/appframework/AUTHORS @@ -0,0 +1,3 @@ +echo "Creating $LOCATION_ROOT/AUTHORS..."; +cat << EOF > $LOCATION_ROOT/AUTHORS +$AUTHOR <$EMAIL> diff --git a/kapptemplate/appframework/COPYING b/kapptemplate/appframework/COPYING new file mode 100644 index 00000000..7b7dedf5 --- /dev/null +++ b/kapptemplate/appframework/COPYING @@ -0,0 +1,2 @@ +echo "Creating $LOCATION_ROOT/COPYING..."; +cp $SHARE_DIR/appframework/no-exe/COPYING $LOCATION_ROOT/COPYING diff --git a/kapptemplate/appframework/ChangeLog b/kapptemplate/appframework/ChangeLog new file mode 100644 index 00000000..290f8348 --- /dev/null +++ b/kapptemplate/appframework/ChangeLog @@ -0,0 +1,4 @@ +echo "Creating $LOCATION_ROOT/ChangeLog..."; +cat << EOF > $LOCATION_ROOT/ChangeLog +`date` - $AUTHOR <$EMAIL> + o Initial Creation diff --git a/kapptemplate/appframework/INSTALL b/kapptemplate/appframework/INSTALL new file mode 100644 index 00000000..79fa82c8 --- /dev/null +++ b/kapptemplate/appframework/INSTALL @@ -0,0 +1,2 @@ +echo "Creating $LOCATION_ROOT/INSTALL..."; +cp $SHARE_DIR/appframework/no-exe/INSTALL $LOCATION_ROOT/INSTALL diff --git a/kapptemplate/appframework/Makefile.am b/kapptemplate/appframework/Makefile.am new file mode 100644 index 00000000..25ad4464 --- /dev/null +++ b/kapptemplate/appframework/Makefile.am @@ -0,0 +1,6 @@ +SUBDIRS=no-exe + +frameworkdir = $(kde_datadir)/kapptemplate/appframework +framework_DATA = AUTHORS INSTALL COPYING NEWS app.lsm \ + app.spec configure.in.in.in README base-Makefile.am \ + ChangeLog VERSION base-Makefile.cvs po-Makefile.am diff --git a/kapptemplate/appframework/NEWS b/kapptemplate/appframework/NEWS new file mode 100644 index 00000000..30fa36b4 --- /dev/null +++ b/kapptemplate/appframework/NEWS @@ -0,0 +1,3 @@ +echo "Creating $LOCATION_ROOT/NEWS..."; +cat << EOF > $LOCATION_ROOT/NEWS + diff --git a/kapptemplate/appframework/README b/kapptemplate/appframework/README new file mode 100644 index 00000000..abfbcdb5 --- /dev/null +++ b/kapptemplate/appframework/README @@ -0,0 +1,6 @@ +echo "Creating $LOCATION_ROOT/README..."; +cat << EOF > $LOCATION_ROOT/README +$APP_NAME v$APP_VERSION +$AUTHOR <$EMAIL> +---------------------------------------------------------------------- +This is where you should describe why $APP_NAME is so great diff --git a/kapptemplate/appframework/VERSION b/kapptemplate/appframework/VERSION new file mode 100644 index 00000000..2d8347f1 --- /dev/null +++ b/kapptemplate/appframework/VERSION @@ -0,0 +1,3 @@ +echo "Creating $LOCATION_ROOT/VERSION..."; +cat << EOF > $LOCATION_ROOT/VERSION +$APP_NAME v$APP_VERSION diff --git a/kapptemplate/appframework/app.lsm b/kapptemplate/appframework/app.lsm new file mode 100644 index 00000000..bf4d32fb --- /dev/null +++ b/kapptemplate/appframework/app.lsm @@ -0,0 +1,18 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC.lsm..."; +cat << EOF > $LOCATION_ROOT/$APP_NAME_LC.lsm +Begin4 +Title: $APP_NAME -- Some description +Version: $APP_VERSION +Entered-date: YYYY-MM-DD +Description: +Keywords: KDE3 Qt +Author: $AUTHOR <$EMAIL> +Maintained-by: $AUTHOR <$EMAIL> +Home-page: +Alternate-site: +Primary-site: ftp://ftp.kde.org/pub/kde/unstable/apps/utils + xxxxxx $APP_NAME_LC-$APP_VERSION.tar.gz + xxx $APP_NAME_LC-$APP_VERSION.lsm +Platform: Linux. Needs KDE 2.x +Copying-policy: GPL +End diff --git a/kapptemplate/appframework/app.spec b/kapptemplate/appframework/app.spec new file mode 100644 index 00000000..b0f3fd48 --- /dev/null +++ b/kapptemplate/appframework/app.spec @@ -0,0 +1,44 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC.spec..."; +cat << EOF > $LOCATION_ROOT/$APP_NAME_LC.spec +%define distversion %( perl -e '$_=\<\>;/(\\d+)\\.(\\d)\\.?(\\d)?/; print "$1$2".($3||0)' /etc/*-release) +Name: ${APP_NAME_LC} +Summary: ${APP_NAME} -- Some description +Version: ${APP_VERSION} +Release: %{_vendor}_%{distversion} +Copyright: GPL +Group: X11/KDE/Utilities +Source: ftp://ftp.kde.org/pub/kde/unstable/apps/utils/%{name}-%{version}.tar.gz +Packager: ${AUTHOR} <${EMAIL}> +BuildRoot: /tmp/%{name}-%{version} +Prefix: `kde-config --prefix` + +%description +A long description + +%prep +rm -rf \$RPM_BUILD_ROOT +%setup -n %{name}-%{version} +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" ./configure \ + --disable-debug --enable-final --prefix=%{prefix} + +%build +# Setup for parallel builds +numprocs=`egrep -c ^cpu[0-9]+ /proc/stat || :` +if [ "$numprocs" = "0" ]; then + numprocs=1 +fi + +make -j$numprocs + +%install +make install-strip DESTDIR=\$RPM_BUILD_ROOT + +cd $RPM_BUILD_ROOT +find . -type d | sed '1,2d;s,^\.,\%attr(-\,root\,root) \%dir ,' > $RPM_BUILD_DIR/%{name}-master.list +find . -type f -o -type l | sed 's|^\.||' >> \$RPM_BUILD_DIR/%{name}-master.list + +%clean +rm -rf \$RPM_BUILD_DIR/%{name}-%{version} +rm -rf \$RPM_BUILD_DIR/${name}-master.list + +%files -f \$RPM_BUILD_DIR/%{name}-master.list diff --git a/kapptemplate/appframework/base-Makefile.am b/kapptemplate/appframework/base-Makefile.am new file mode 100644 index 00000000..eef7f78c --- /dev/null +++ b/kapptemplate/appframework/base-Makefile.am @@ -0,0 +1,11 @@ +echo "Creating $LOCATION_ROOT/Makefile.am.in..."; +cat << EOF > $LOCATION_ROOT/Makefile.am.in + +AUTOMAKE_OPTIONS = foreign 1.5 +DISTCLEANFILES = inst-apps +MAINTAINERCLEANFILES = subdirs configure.in acinclude.m4 configure.files + +include admin/deps.am + +include admin/Doxyfile.am + diff --git a/kapptemplate/appframework/base-Makefile.cvs b/kapptemplate/appframework/base-Makefile.cvs new file mode 100644 index 00000000..60510887 --- /dev/null +++ b/kapptemplate/appframework/base-Makefile.cvs @@ -0,0 +1,12 @@ +echo "Creating $LOCATION_ROOT/Makefile.cvs..."; +cat << EOF > $LOCATION_ROOT/Makefile.cvs +all: + @echo "This Makefile is only for the CVS repository" + @echo "This will be deleted before making the distribution" + @echo "" + \$(MAKE) -f admin/Makefile.common cvs + +dist: + \$(MAKE) -f admin/Makefile.common dist + +.SILENT: diff --git a/kapptemplate/appframework/configure.in.in.in b/kapptemplate/appframework/configure.in.in.in new file mode 100644 index 00000000..8b120500 --- /dev/null +++ b/kapptemplate/appframework/configure.in.in.in @@ -0,0 +1,3 @@ +echo "Creating $LOCATION_ROOT/configure.in.in..."; +cat << EOF > $LOCATION_ROOT/configure.in.in +#MIN_CONFIG diff --git a/kapptemplate/appframework/no-exe/COPYING b/kapptemplate/appframework/no-exe/COPYING new file mode 100644 index 00000000..96bdc086 --- /dev/null +++ b/kapptemplate/appframework/no-exe/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) 19yy <name of author> + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/kapptemplate/appframework/no-exe/INSTALL b/kapptemplate/appframework/no-exe/INSTALL new file mode 100644 index 00000000..28fadaa7 --- /dev/null +++ b/kapptemplate/appframework/no-exe/INSTALL @@ -0,0 +1,181 @@ +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, a file +`config.cache' that saves the results of its tests to speed up +reconfiguring, and a file `config.log' containing compiler output +(useful mainly for debugging `configure'). + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If at some point `config.cache' +contains results you don't want to keep, you may remove or edit it. + + The file `configure.in' is used to create `configure' by a program +called `autoconf'. You only need `configure.in' if you want to change +it or regenerate `configure' using a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. You can give `configure' +initial values for variables by setting them in the environment. Using +a Bourne-compatible shell, you can do that on the command line like +this: + CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure + +Or on systems that have the `env' program, you can do it like this: + env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not supports the `VPATH' +variable, you have to compile the package for one architecture at a time +in the source code directory. After you have installed the package for +one architecture, use `make distclean' before reconfiguring for another +architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=PATH' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' can not figure out +automatically, but needs to determine by the type of host the package +will run on. Usually `configure' can figure that out, but if it prints +a message saying it can not guess the host type, give it the +`--host=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name with three fields: + CPU-COMPANY-SYSTEM + +See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the host type. + + If you are building compiler tools for cross-compiling, you can also +use the `--target=TYPE' option to select the type of system they will +produce code for and the `--build=TYPE' option to select the type of +system on which you are compiling the package. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Operation Controls +================== + + `configure' recognizes the following options to control how it +operates. + +`--cache-file=FILE' + Use and save the results of the tests in FILE instead of + `./config.cache'. Set FILE to `/dev/null' to disable caching, for + debugging `configure'. + +`--help' + Print a summary of the options to `configure', and exit. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--version' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`configure' also accepts some other, not widely useful, options. + diff --git a/kapptemplate/appframework/no-exe/Makefile.am b/kapptemplate/appframework/no-exe/Makefile.am new file mode 100644 index 00000000..d61ae693 --- /dev/null +++ b/kapptemplate/appframework/no-exe/Makefile.am @@ -0,0 +1,2 @@ +frameworkdir = $(kde_datadir)/kapptemplate/appframework/no-exe +framework_DATA = COPYING INSTALL diff --git a/kapptemplate/appframework/po-Makefile.am b/kapptemplate/appframework/po-Makefile.am new file mode 100644 index 00000000..c06e6ff9 --- /dev/null +++ b/kapptemplate/appframework/po-Makefile.am @@ -0,0 +1,3 @@ +echo "Creating $LOCATION_ROOT/po/Makefile.am..."; +cat << EOF > $LOCATION_ROOT/po/Makefile.am +POFILES = AUTO diff --git a/kapptemplate/existing.module b/kapptemplate/existing.module new file mode 100644 index 00000000..01a4e710 --- /dev/null +++ b/kapptemplate/existing.module @@ -0,0 +1,118 @@ +function GetCurrentSource +{ + # First, get the location of the existing source code + unset SOURCE_LOCATION; + while [ ! "$SOURCE_LOCATION" ]; + do + $ECHO "What directory contains the existing files? [no default]"; + $ECHO ": \c"; + read SOURCE_LOCATION; + + if [ ! -d $SOURCE_LOCATION ]; + then + $ECHO "Directory does not exist. Try again."; + $ECHO; + unset SOURCE_LOCATION; + fi + done + $ECHO; + + # Now, find C++ source and header files + CUR_PWD=$PWD; + cd $SOURCE_LOCATION; + EXISTING_SOURCE=`/bin/ls -x *.C *.cpp *.cc`; + EXISTING_HEADER=`/bin/ls -x *.h`; + cd $CUR_PWD; + + # Sanity check + if [ "$EXISTING_SOURCE" -o "$EXISTING_HEADER" ]; + then + $ECHO "Found these files: $EXISTING_SOURCE $EXISTING_HEADER"; + else + $ECHO "Could not find any source files in that directory"; + exit 1; + fi +} + +########################################################################### +# +# STEP 1: GET USER INFORMATION +# +########################################################################### +# Get the application name +APPTYPE="existing application"; +unset APPDEFAULT; +GetProperName + +# Get the application version +GetVersion + +# Get where the sources currently are +GetCurrentSource + +# Get the root where this framework will be installed +GetLocationRoot + +# Get the author's name +GetAuthorName + +# Get the author's email +GetAuthorEmail + +# Verify that everything is grand +$ECHO; +$ECHO "Here is what I have:"; +$ECHO "The application: $APP_NAME v$APP_VERSION"; +$ECHO "Installed in: $LOCATION_ROOT"; +$ECHO "Source from: $SOURCE_LOCATION"; +$ECHO "Author: $AUTHOR <$EMAIL>"; +$ECHO; +$ECHO "Is this correct (Y/n)? "; +$ECHO ": \c"; +read Y_N; +if [ $Y_N -a $Y_N = 'n' ]; +then + $ECHO "AUGH! Well, try again."; + exit 0; +fi +$ECHO; + +$ECHO "OK, Here we go!!"; + +########################################################################### +# +# STEP 2: CREATE APPLICATION FRAMEWORK +# +########################################################################### +CreateAppFramework + +########################################################################### +# +# STEP 3: HANDLE EXISTING FILES +# +########################################################################### +for FILE in $EXISTING_SOURCE; +do + cp -f $SOURCE_LOCATION/$FILE $LOCATION_ROOT/$APP_NAME_LC/$FILE +done +for FILE in $EXISTING_HEADER; +do + cp -f $SOURCE_LOCATION/$FILE $LOCATION_ROOT/$APP_NAME_LC/$FILE +done + +for EXE_FILE in $EXISTING_FILES; +do + . $SHARE_DIR/existing/$EXE_FILE || exit 1; +done + +########################################################################### +# +# STEP 4: FINAL STEPS +# +########################################################################### + +if [ ! $NOINIT ]; then + cd $LOCATION_ROOT && $MAKE -f Makefile.cvs +fi + +$ECHO "DONE!"; diff --git a/kapptemplate/existing/Makefile.am b/kapptemplate/existing/Makefile.am new file mode 100644 index 00000000..3abf5838 --- /dev/null +++ b/kapptemplate/existing/Makefile.am @@ -0,0 +1,2 @@ +existingdir = $(kde_datadir)/kapptemplate/existing +existing_DATA = app-Makefile.am app-desktop diff --git a/kapptemplate/existing/app-Makefile.am b/kapptemplate/existing/app-Makefile.am new file mode 100644 index 00000000..79236a7f --- /dev/null +++ b/kapptemplate/existing/app-Makefile.am @@ -0,0 +1,34 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/Makefile.am..."; +cat << EOF > $LOCATION_ROOT/$APP_NAME_LC/Makefile.am +# this has all of the subdirectories that make will recurse into. if +# there are none, comment this out +#SUBDIRS = + +# this is the program that gets installed. it's name is used for all +# of the other Makefile.am variables +bin_PROGRAMS = $APP_NAME_LC + +# set the include path for X, qt and KDE +INCLUDES = \$(all_includes) + +# the library search path. +${APP_NAME_LC}_LDFLAGS = \$(KDE_RPATH) \$(all_libraries) + +# the libraries to link against. +${APP_NAME_LC}_LDADD = \$(LIB_KFILE) + +# which sources should be compiled for $APP_NAME_LC +${APP_NAME_LC}_SOURCES = ${EXISTING_SOURCE} + +# these are the headers for your project that won't be installed +noinst_HEADERS = ${EXISTING_HEADER} + +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + +messages: rc.cpp + \$(XGETTEXT) *.cpp -o \$(podir)/${APP_NAME_LC}.pot + +# this is where the desktop file will go +desktopdir = \$(kde_appsdir)/Utilities +desktop_DATA = ${APP_NAME_LC}.desktop diff --git a/kapptemplate/existing/app-desktop b/kapptemplate/existing/app-desktop new file mode 100644 index 00000000..857fb224 --- /dev/null +++ b/kapptemplate/existing/app-desktop @@ -0,0 +1,9 @@ +echo "Creating $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}.desktop..."; +cat << EOF > $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}.desktop +[Desktop Entry] +Encoding=UTF-8 +Name=${APP_NAME} +Exec=${APP_NAME_LC} %i %m -caption "%c" +Type=Application +Terminal=0 +GenericName=A KDE Application diff --git a/kapptemplate/kapp/Makefile.am b/kapptemplate/kapp/Makefile.am new file mode 100644 index 00000000..6d1a196c --- /dev/null +++ b/kapptemplate/kapp/Makefile.am @@ -0,0 +1,9 @@ +SUBDIRS=no-exe + +kappdir = $(kde_datadir)/kapptemplate/kapp +kapp_DATA = app_client.cpp appview.h index.docbook \ + app-Makefile.am appiface.h doc-Makefile.am lo16-app-app.png \ + app-configure.in.in apppref.cpp doc-app-Makefile.am \ + lo32-app-app.png app.cpp apppref.h hi16-app-app.png main.cpp \ + app-desktop appui.rc hi32-app-app.png app.h appview.cpp \ + hi48-app-app.png pics-Makefile.am diff --git a/kapptemplate/kapp/app-Makefile.am b/kapptemplate/kapp/app-Makefile.am new file mode 100644 index 00000000..9ed82a08 --- /dev/null +++ b/kapptemplate/kapp/app-Makefile.am @@ -0,0 +1,47 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/Makefile.am..."; +cat << EOF > $LOCATION_ROOT/$APP_NAME_LC/Makefile.am +## Makefile.am for $APP_NAME_LC + +# this has all of the subdirectories that make will recurse into. if +# there are none, comment this out +SUBDIRS = . pics + +# this is the program that gets installed. it's name is used for all +# of the other Makefile.am variables +bin_PROGRAMS = $APP_NAME_LC ${APP_NAME_LC}_client + +# set the include path for X, qt and KDE +INCLUDES = \$(all_includes) + +# the library search path. +${APP_NAME_LC}_LDFLAGS = \$(KDE_RPATH) \$(all_libraries) + +# the libraries to link against. +${APP_NAME_LC}_LDADD = \$(LIB_KFILE) -lkdeprint + +# which sources should be compiled for $APP_NAME_LC +${APP_NAME_LC}_SOURCES = main.cpp ${APP_NAME_LC}.cpp ${APP_NAME_LC}view.cpp \\ + ${APP_NAME_LC}pref.cpp ${APP_NAME_LC}iface.skel + +# these are the headers for your project +noinst_HEADERS = ${APP_NAME_LC}.h ${APP_NAME_LC}view.h ${APP_NAME_LC}pref.h + +# client stuff +${APP_NAME_LC}_client_LDFLAGS = \$(KDE_RPATH) \$(all_libraries) +${APP_NAME_LC}_client_LDADD = \$(LIB_KDECORE) +${APP_NAME_LC}_client_SOURCES = ${APP_NAME_LC}_client.cpp + +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + +messages: rc.cpp + \$(XGETTEXT) *.cpp -o \$(podir)/${APP_NAME_LC}.pot + +KDE_ICON = $APP_NAME_LC + +# this is where the kdelnk file will go +xdg_apps_data = ${APP_NAME_LC}.desktop + +# this is where the XML-GUI resource file goes +rcdir = \$(kde_datadir)/${APP_NAME_LC} +rc_DATA = ${APP_NAME_LC}ui.rc diff --git a/kapptemplate/kapp/app-configure.in.in b/kapptemplate/kapp/app-configure.in.in new file mode 100644 index 00000000..4d050a09 --- /dev/null +++ b/kapptemplate/kapp/app-configure.in.in @@ -0,0 +1,14 @@ +echo "Creating $LOCATION_ROOT/configure.in.in..."; +cat << EOF > $LOCATION_ROOT/configure.in.in +#MIN_CONFIG + +AM_INIT_AUTOMAKE(${APP_NAME_LC}, ${APP_VERSION}) + +dnl These are common macros that you might or might not want to use + +dnl Checks for header files. +AC_HEADER_DIRENT +AC_HEADER_STDC +AC_HEADER_TIME +AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h stdlib.h paths.h) +AC_CHECK_FUNCS(usleep) diff --git a/kapptemplate/kapp/app-desktop b/kapptemplate/kapp/app-desktop new file mode 100644 index 00000000..118e0211 --- /dev/null +++ b/kapptemplate/kapp/app-desktop @@ -0,0 +1,11 @@ +echo "Creating $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}.desktop..."; +cat << EOF > $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}.desktop +[Desktop Entry] +Encoding=UTF-8 +Name=${APP_NAME} +Exec=${APP_NAME_LC} %i %m -caption "%c" +Icon=${APP_NAME_LC} +Type=Application +DocPath=${APP_NAME_LC}/${APP_NAME_LC}.html +GenericName=A KDE Application +Terminal=0 diff --git a/kapptemplate/kapp/app.cpp b/kapptemplate/kapp/app.cpp new file mode 100644 index 00000000..58ed3415 --- /dev/null +++ b/kapptemplate/kapp/app.cpp @@ -0,0 +1,263 @@ +echo "Creating $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}.cpp..."; +cat << EOF > $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}.cpp +/* + * ${APP_NAME_LC}.cpp + * + * Copyright (C) 2004 $AUTHOR <$EMAIL> + */ +#include "${APP_NAME_LC}.h" + +#include "${APP_NAME_LC}pref.h" + +#include <kprinter.h> +#include <qpainter.h> +#include <qpaintdevicemetrics.h> + +#include <kdeversion.h> +#include <kglobal.h> +#include <klocale.h> +#include <kiconloader.h> +#include <kmenubar.h> +#include <kstatusbar.h> +#include <kaccel.h> +#include <kio/netaccess.h> +#include <kfiledialog.h> +#include <kconfig.h> +#include <kurl.h> +#include <kurldrag.h> +#include <kurlrequesterdlg.h> + +#include <kedittoolbar.h> + +#include <kstdaccel.h> +#include <kaction.h> +#include <kstdaction.h> + +${APP_NAME}::${APP_NAME}() + : KMainWindow( 0, "${APP_NAME}" ), + m_view(new ${APP_NAME}View(this)), + m_printer(0) +{ + // accept dnd + setAcceptDrops(true); + + // tell the KMainWindow that this is indeed the main widget + setCentralWidget(m_view); + + // then, setup our actions + setupActions(); + + // Add typical actions and save size/toolbars/statusbar + setupGUI(); + + // allow the view to change the statusbar and caption + connect(m_view, SIGNAL(signalChangeStatusbar(const QString&)), + this, SLOT(changeStatusbar(const QString&))); + connect(m_view, SIGNAL(signalChangeCaption(const QString&)), + this, SLOT(changeCaption(const QString&))); + +} + +${APP_NAME}::~${APP_NAME}() +{ + delete m_printer; +} + +void ${APP_NAME}::load(const KURL& url) +{ + QString target; + // the below code is what you should normally do. in this + // example case, we want the url to our own. you probably + // want to use this code instead for your app + + #if 0 + // download the contents + if (KIO::NetAccess::download(url, target)) + { + // set our caption + setCaption(url.prettyURL()); + + // load in the file (target is always local) + loadFile(target); + + // and remove the temp file + KIO::NetAccess::removeTempFile(target); + } + #endif + + setCaption(url.prettyURL()); + m_view->openURL(url); +} + +void ${APP_NAME}::setupActions() +{ + KStdAction::openNew(this, SLOT(fileNew()), actionCollection()); + KStdAction::open(this, SLOT(fileOpen()), actionCollection()); + KStdAction::save(this, SLOT(fileSave()), actionCollection()); + KStdAction::saveAs(this, SLOT(fileSaveAs()), actionCollection()); + KStdAction::print(this, SLOT(filePrint()), actionCollection()); + KStdAction::quit(kapp, SLOT(quit()), actionCollection()); + + KStdAction::preferences(this, SLOT(optionsPreferences()), actionCollection()); + + // this doesn't do anything useful. it's just here to illustrate + // how to insert a custom menu and menu item + KAction *custom = new KAction(i18n("Cus&tom Menuitem"), 0, + this, SLOT(optionsPreferences()), + actionCollection(), "custom_action"); +} + +void ${APP_NAME}::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 + + if (!m_view->currentURL().isNull()) { +#if KDE_IS_VERSION(3,1,3) + config->writePathEntry("lastURL", m_view->currentURL()); +#else + config->writeEntry("lastURL", m_view->currentURL()); +#endif + } +} + +void ${APP_NAME}::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' + + QString url = config->readPathEntry("lastURL"); + + if (!url.isEmpty()) + m_view->openURL(KURL::fromPathOrURL(url)); +} + +void ${APP_NAME}::dragEnterEvent(QDragEnterEvent *event) +{ + // accept uri drops only + event->accept(KURLDrag::canDecode(event)); +} + +void ${APP_NAME}::dropEvent(QDropEvent *event) +{ + // this is a very simplistic implementation of a drop event. we + // will only accept a dropped URL. the Qt dnd code can do *much* + // much more, so please read the docs there + KURL::List urls; + + // see if we can decode a URI.. if not, just ignore it + if (KURLDrag::decode(event, urls) && !urls.isEmpty()) + { + // okay, we have a URI.. process it + const KURL &url = urls.first(); + + // load in the file + load(url); + } +} + +void ${APP_NAME}::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 + + // create a new window + (new ${APP_NAME})->show(); +} + +void ${APP_NAME}::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 = KURLRequesterDlg::getURL(QString::null, this, i18n("Open Location") ); + if (!url.isEmpty()) + m_view->openURL(url); +} + +void ${APP_NAME}::fileSave() +{ + // this slot is called whenever the File->Save menu is selected, + // the Save shortcut is pressed (usually CTRL+S) or the Save toolbar + // button is clicked + + // save the current file +} + +void ${APP_NAME}::fileSaveAs() +{ + // this slot is called whenever the File->Save As menu is selected, + KURL file_url = KFileDialog::getSaveURL(); + if (!file_url.isEmpty() && file_url.isValid()) + { + // save your info, here + } +} + +void ${APP_NAME}::filePrint() +{ + // this slot is called whenever the File->Print menu is selected, + // the Print shortcut is pressed (usually CTRL+P) or the Print toolbar + // button is clicked + if (!m_printer) m_printer = new KPrinter; + if (m_printer->setup(this)) + { + // setup the printer. with Qt, you always "print" to a + // QPainter.. whether the output medium is a pixmap, a screen, + // or paper + QPainter p; + p.begin(m_printer); + + // we let our view do the actual printing + QPaintDeviceMetrics metrics(m_printer); + m_view->print(&p, metrics.height(), metrics.width()); + + // and send the result to the printer + p.end(); + } +} + +void ${APP_NAME}::optionsConfigureToolbars() +{ + // use the standard toolbar editor + saveMainWindowSettings( KGlobal::config(), autoSaveGroup() ); + KEditToolbar dlg(actionCollection()); + connect(&dlg, SIGNAL(newToolbarConfig()), this, SLOT(newToolbarConfig())); + dlg.exec(); +} + +void ${APP_NAME}::newToolbarConfig() +{ + // this slot is called when user clicks "Ok" or "Apply" in the toolbar editor. + // recreate our GUI, and re-apply the settings (e.g. "text under icons", etc.) + createGUI(); + applyMainWindowSettings( KGlobal::config(), autoSaveGroup() ); +} + +void ${APP_NAME}::optionsPreferences() +{ + // popup some sort of preference dialog, here + ${APP_NAME}Preferences dlg; + if (dlg.exec()) + { + // redo your settings + } +} + +void ${APP_NAME}::changeStatusbar(const QString& text) +{ + // display the text on the statusbar + statusBar()->message(text); +} + +void ${APP_NAME}::changeCaption(const QString& text) +{ + // display the text on the caption + setCaption(text); +} + +#include "${APP_NAME_LC}.moc" diff --git a/kapptemplate/kapp/app.h b/kapptemplate/kapp/app.h new file mode 100644 index 00000000..7f7b0d39 --- /dev/null +++ b/kapptemplate/kapp/app.h @@ -0,0 +1,90 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/${APP_NAME_LC}.h..."; +cat << EOF > $LOCATION_ROOT/$APP_NAME_LC/${APP_NAME_LC}.h +#ifndef ${APP_NAME_UC}_H +#define ${APP_NAME_UC}_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <kapplication.h> +#include <kmainwindow.h> + +#include "${APP_NAME_LC}view.h" + +class KPrinter; +class KURL; + +/** + * This class serves as the main window for ${APP_NAME}. It handles the + * menus, toolbars, and status bars. + * + * @short Main window class + * @author $AUTHOR <$EMAIL> + * @version $APP_VERSION + */ +class ${APP_NAME} : public KMainWindow +{ + Q_OBJECT +public: + /** + * Default Constructor + */ + ${APP_NAME}(); + + /** + * Default Destructor + */ + virtual ~${APP_NAME}(); + + /** + * Use this method to load whatever file/URL you have + */ + void load(const KURL& url); + +protected: + /** + * Overridden virtuals for Qt drag 'n drop (XDND) + */ + virtual void dragEnterEvent(QDragEnterEvent *event); + virtual void dropEvent(QDropEvent *event); + +protected: + /** + * This function is called when it is time for the app to save its + * properties for session management purposes. + */ + void saveProperties(KConfig *); + + /** + * This function 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 fileSave(); + void fileSaveAs(); + void filePrint(); + void optionsConfigureToolbars(); + void optionsPreferences(); + void newToolbarConfig(); + + void changeStatusbar(const QString& text); + void changeCaption(const QString& text); + +private: + void setupAccel(); + void setupActions(); + +private: + ${APP_NAME}View *m_view; + + KPrinter *m_printer; +}; + +#endif // ${APP_NAME_UC}_H diff --git a/kapptemplate/kapp/app_client.cpp b/kapptemplate/kapp/app_client.cpp new file mode 100644 index 00000000..cd5e065d --- /dev/null +++ b/kapptemplate/kapp/app_client.cpp @@ -0,0 +1,26 @@ +echo "Creating $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}_client.cpp..."; +cat << EOF > $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}_client.cpp +#include <kapplication.h> +#include <dcopclient.h> +#include <qdatastream.h> +#include <qstring.h> + +int main(int argc, char **argv) +{ + KApplication app(argc, argv, "${APP_NAME_LC}_client", false); + + // get our DCOP client and attach so that we may use it + DCOPClient *client = app.dcopClient(); + client->attach(); + + // do a 'send' for now + QByteArray data; + QDataStream ds(data, IO_WriteOnly); + if (argc > 1) + ds << QString(argv[1]); + else + ds << QString("http://www.kde.org"); + client->send("${APP_NAME_LC}", "${APP_NAME}Iface", "openURL(QString)", data); + + return app.exec(); +} diff --git a/kapptemplate/kapp/appiface.h b/kapptemplate/kapp/appiface.h new file mode 100644 index 00000000..2601df94 --- /dev/null +++ b/kapptemplate/kapp/appiface.h @@ -0,0 +1,17 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/${APP_NAME_LC}iface.h..."; +cat << EOF > $LOCATION_ROOT/$APP_NAME_LC/${APP_NAME_LC}iface.h +#ifndef ${APP_NAME_UC}IFACE_H +#define ${APP_NAME_UC}IFACE_H + +#include <dcopobject.h> + +class ${APP_NAME}Iface : virtual public DCOPObject +{ + K_DCOP +public: + +k_dcop: + virtual void openURL(QString url) = 0; +}; + +#endif // ${APP_NAME_UC}IFACE_H diff --git a/kapptemplate/kapp/apppref.cpp b/kapptemplate/kapp/apppref.cpp new file mode 100644 index 00000000..b025924a --- /dev/null +++ b/kapptemplate/kapp/apppref.cpp @@ -0,0 +1,42 @@ +echo "Creating $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}pref.cpp..."; +cat << EOF > $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}pref.cpp +#include "${APP_NAME_LC}pref.h" + +#include <klocale.h> + +#include <qlayout.h> +#include <qlabel.h> + +${APP_NAME}Preferences::${APP_NAME}Preferences() + : KDialogBase(TreeList, "${APP_NAME} Preferences", + Help|Default|Ok|Apply|Cancel, Ok) +{ + // this is the base class for your preferences dialog. it is now + // a Treelist dialog.. but there are a number of other + // possibilities (including Tab, Swallow, and just Plain) + QFrame *frame; + frame = addPage(i18n("First Page"), i18n("Page One Options")); + m_pageOne = new ${APP_NAME}PrefPageOne(frame); + + frame = addPage(i18n("Second Page"), i18n("Page Two Options")); + m_pageTwo = new ${APP_NAME}PrefPageTwo(frame); +} + +${APP_NAME}PrefPageOne::${APP_NAME}PrefPageOne(QWidget *parent) + : QFrame(parent) +{ + QHBoxLayout *layout = new QHBoxLayout(this); + layout->setAutoAdd(true); + + new QLabel("Add something here", this); +} + +${APP_NAME}PrefPageTwo::${APP_NAME}PrefPageTwo(QWidget *parent) + : QFrame(parent) +{ + QHBoxLayout *layout = new QHBoxLayout(this); + layout->setAutoAdd(true); + + new QLabel("Add something here", this); +} +#include "${APP_NAME_LC}pref.moc" diff --git a/kapptemplate/kapp/apppref.h b/kapptemplate/kapp/apppref.h new file mode 100644 index 00000000..97371936 --- /dev/null +++ b/kapptemplate/kapp/apppref.h @@ -0,0 +1,37 @@ +echo "Creating $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}pref.h..."; +cat << EOF > $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}pref.h +#ifndef ${APP_NAME_UC}PREF_H +#define ${APP_NAME_UC}PREF_H + +#include <kdialogbase.h> +#include <qframe.h> + +class ${APP_NAME}PrefPageOne; +class ${APP_NAME}PrefPageTwo; + +class ${APP_NAME}Preferences : public KDialogBase +{ + Q_OBJECT +public: + ${APP_NAME}Preferences(); + +private: + ${APP_NAME}PrefPageOne *m_pageOne; + ${APP_NAME}PrefPageTwo *m_pageTwo; +}; + +class ${APP_NAME}PrefPageOne : public QFrame +{ + Q_OBJECT +public: + ${APP_NAME}PrefPageOne(QWidget *parent = 0); +}; + +class ${APP_NAME}PrefPageTwo : public QFrame +{ + Q_OBJECT +public: + ${APP_NAME}PrefPageTwo(QWidget *parent = 0); +}; + +#endif // ${APP_NAME_UC}PREF_H diff --git a/kapptemplate/kapp/appui.rc b/kapptemplate/kapp/appui.rc new file mode 100644 index 00000000..f8914570 --- /dev/null +++ b/kapptemplate/kapp/appui.rc @@ -0,0 +1,10 @@ +echo "Creating $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}ui.rc..."; +cat << EOF > $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}ui.rc +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui name="${APP_NAME_LC}" version="1"> +<MenuBar> + <Menu name="custom"><text>C&ustom</text> + <Action name="custom_action" /> + </Menu> +</MenuBar> +</kpartgui> diff --git a/kapptemplate/kapp/appview.cpp b/kapptemplate/kapp/appview.cpp new file mode 100644 index 00000000..575e8a5d --- /dev/null +++ b/kapptemplate/kapp/appview.cpp @@ -0,0 +1,106 @@ +echo "Creating $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}view.cpp..."; +cat << EOF > $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}view.cpp +#include "${APP_NAME_LC}view.h" + +#include <qpainter.h> +#include <qlayout.h> + +#include <kurl.h> + +#include <ktrader.h> +#include <klibloader.h> +#include <kmessagebox.h> +#include <krun.h> + +${APP_NAME}View::${APP_NAME}View(QWidget *parent) + : QWidget(parent), + DCOPObject("${APP_NAME}Iface") +{ + // setup our layout manager to automatically add our widgets + QHBoxLayout *top_layout = new QHBoxLayout(this); + top_layout->setAutoAdd(true); + + // we want to look for all components that satisfy our needs. the + // trader will actually search through *all* registered KDE + // applications and components -- not just KParts. So we have to + // specify two things: a service type and a constraint + // + // the service type is like a mime type. we say that we want all + // applications and components that can handle HTML -- 'text/html' + // + // however, by itself, this will return such things as Netscape.. + // not what we wanted. so we constrain it by saying that the + // string 'KParts/ReadOnlyPart' must be found in the ServiceTypes + // field. with this, only components of the type we want will be + // returned. + KTrader::OfferList offers = KTrader::self()->query("text/html", "'KParts/ReadOnlyPart' in ServiceTypes"); + + KLibFactory *factory = 0; + // in theory, we only care about the first one.. but let's try all + // offers just in case the first can't be loaded for some reason + KTrader::OfferList::Iterator it(offers.begin()); + for( ; it != offers.end(); ++it) + { + KService::Ptr ptr = (*it); + + // we now know that our offer can handle HTML and is a part. + // since it is a part, it must also have a library... let's try to + // load that now + factory = KLibLoader::self()->factory( ptr->library() ); + if (factory) + { + m_html = static_cast<KParts::ReadOnlyPart *>(factory->create(this, ptr->name(), "KParts::ReadOnlyPart")); + break; + } + } + + // if our factory is invalid, then we never found our component + // and we might as well just exit now + if (!factory) + { + KMessageBox::error(this, "Could not find a suitable HTML component"); + return; + } + + connect(m_html, SIGNAL(setWindowCaption(const QString&)), + this, SLOT(slotSetTitle(const QString&))); + connect(m_html, SIGNAL(setStatusBarText(const QString&)), + this, SLOT(slotOnURL(const QString&))); + +} + +${APP_NAME}View::~${APP_NAME}View() +{ +} + +void ${APP_NAME}View::print(QPainter *p, int height, int width) +{ + // do the actual printing, here + // p->drawText(etc..) +} + +QString ${APP_NAME}View::currentURL() +{ + return m_html->url().url(); +} + +void ${APP_NAME}View::openURL(QString url) +{ + openURL(KURL(url)); +} + +void ${APP_NAME}View::openURL(const KURL& url) +{ + m_html->openURL(url); +} + +void ${APP_NAME}View::slotOnURL(const QString& url) +{ + emit signalChangeStatusbar(url); +} + +void ${APP_NAME}View::slotSetTitle(const QString& title) +{ + emit signalChangeCaption(title); +} +#include "${APP_NAME_LC}view.moc" diff --git a/kapptemplate/kapp/appview.h b/kapptemplate/kapp/appview.h new file mode 100644 index 00000000..881b979c --- /dev/null +++ b/kapptemplate/kapp/appview.h @@ -0,0 +1,77 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/${APP_NAME_LC}view.h..."; +cat << EOF > $LOCATION_ROOT/$APP_NAME_LC/${APP_NAME_LC}view.h +#ifndef ${APP_NAME_UC}VIEW_H +#define ${APP_NAME_UC}VIEW_H + +#include <qwidget.h> +#include <kparts/part.h> +#include <${APP_NAME_LC}iface.h> + +class QPainter; +class KURL; + +/** + * This is the main view class for ${APP_NAME}. Most of the non-menu, + * non-toolbar, and non-statusbar (e.g., non frame) GUI code should go + * here. + * + * This ${APP_NAME_LC} uses an HTML component as an example. + * + * @short Main view + * @author $AUTHOR <$EMAIL> + * @version $APP_VERSION + */ +class ${APP_NAME}View : public QWidget, public ${APP_NAME}Iface +{ + Q_OBJECT +public: + /** + * Default constructor + */ + ${APP_NAME}View(QWidget *parent); + + /** + * Destructor + */ + virtual ~${APP_NAME}View(); + + /** + * Random 'get' function + */ + QString currentURL(); + + /** + * Random 'set' function accessed by DCOP + */ + virtual void openURL(QString url); + + /** + * Random 'set' function + */ + virtual void openURL(const KURL& url); + + /** + * Print this view to any medium -- paper or not + */ + void print(QPainter *, int height, int width); + +signals: + /** + * Use this signal to change the content of the statusbar + */ + void signalChangeStatusbar(const QString& text); + + /** + * Use this signal to change the content of the caption + */ + void signalChangeCaption(const QString& text); + +private slots: + void slotOnURL(const QString& url); + void slotSetTitle(const QString& title); + +private: + KParts::ReadOnlyPart *m_html; +}; + +#endif // ${APP_NAME_UC}VIEW_H diff --git a/kapptemplate/kapp/doc-Makefile.am b/kapptemplate/kapp/doc-Makefile.am new file mode 100644 index 00000000..02611d03 --- /dev/null +++ b/kapptemplate/kapp/doc-Makefile.am @@ -0,0 +1,8 @@ +echo "Creating $LOCATION_ROOT/doc/Makefile.am..."; +$MKDIR $LOCATION_ROOT/doc +cat << EOF > $LOCATION_ROOT/doc/Makefile.am + +SUBDIRS = \$(AUTODIRS) +KDE_DOCS = $APP_NAME_LC +KDE_LANG = en + diff --git a/kapptemplate/kapp/doc-app-Makefile.am b/kapptemplate/kapp/doc-app-Makefile.am new file mode 100644 index 00000000..0356a93a --- /dev/null +++ b/kapptemplate/kapp/doc-app-Makefile.am @@ -0,0 +1,9 @@ +echo "Creating $LOCATION_ROOT/doc/$APP_NAME_LC/Makefile.am..."; +$MKDIR $LOCATION_ROOT/doc/$APP_NAME_LC +cat << EOF > $LOCATION_ROOT/doc/$APP_NAME_LC/Makefile.am + +# the SUBDIRS is filled automatically by am_edit. If files are +# in this directory they are installed into the english dir +KDE_LANG = en +KDE_DOCS = $APP_NAME_LC +SUBDIRS = \$(AUTODIRS) diff --git a/kapptemplate/kapp/hi16-app-app.png b/kapptemplate/kapp/hi16-app-app.png new file mode 100644 index 00000000..2f82a953 --- /dev/null +++ b/kapptemplate/kapp/hi16-app-app.png @@ -0,0 +1,2 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/hi16-app-$APP_NAME_LC.png..."; +cp $SHARE_DIR/kapp/no-exe/hi16-app-app.png $LOCATION_ROOT/$APP_NAME_LC/hi16-app-$APP_NAME_LC.png diff --git a/kapptemplate/kapp/hi32-app-app.png b/kapptemplate/kapp/hi32-app-app.png new file mode 100644 index 00000000..767c9448 --- /dev/null +++ b/kapptemplate/kapp/hi32-app-app.png @@ -0,0 +1,2 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/hi32-app-$APP_NAME_LC.png..."; +cp $SHARE_DIR/kapp/no-exe/hi32-app-app.png $LOCATION_ROOT/$APP_NAME_LC/hi32-app-$APP_NAME_LC.png diff --git a/kapptemplate/kapp/hi48-app-app.png b/kapptemplate/kapp/hi48-app-app.png new file mode 100644 index 00000000..08970c62 --- /dev/null +++ b/kapptemplate/kapp/hi48-app-app.png @@ -0,0 +1,2 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/hi48-app-$APP_NAME_LC.png..."; +cp $SHARE_DIR/kapp/no-exe/hi48-app-app.png $LOCATION_ROOT/$APP_NAME_LC/hi48-app-$APP_NAME_LC.png diff --git a/kapptemplate/kapp/index.docbook b/kapptemplate/kapp/index.docbook new file mode 100644 index 00000000..5f8071ff --- /dev/null +++ b/kapptemplate/kapp/index.docbook @@ -0,0 +1,106 @@ +echo "Creating $LOCATION_ROOT/doc/$APP_NAME_LC/index.docbook..."; +$MKDIR $LOCATION_ROOT/doc/$APP_NAME_LC +echo "It is better to use template.docbook instead of this - please replace it" +cat << EOF > $LOCATION_ROOT/doc/$APP_NAME_LC/index.docbook +<?xml version="1.0" ?> +<!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.1.2-Based Variant V1.1//EN" "dtd/kdex.dtd" [ + <!ENTITY $APP_NAME_LC "$APP_NAME"> + <!ENTITY % addindex "IGNORE"> + <!ENTITY % English "INCLUDE" > <!-- change language only here --> +]> +<!-- Important note: please use template.docbook instead of this file. + This is only the conversion of app.sgml into DocBook SGML. + template.docbook gives you more information on what you can and + should do. Thanks. --> +<book lang="&language;"> + +<bookinfo> +<title>The &$APP_NAME_LC; Handbook</title> +<authorgroup> +<author> +<firstname></firstname> +<surname>$AUTHOR</surname> +<affiliation><address><email>$EMAIL</email></address></affiliation> +</author> +</authorgroup> +<date>`date "+%Y-%m-%d"`</date> +<releaseinfo>$APP_VERSION</releaseinfo> +<abstract> +<para>SHORT DESCRIPTION GOES HERE</para> +</abstract> +<keywordset> +<keyword>KDE</keyword> +<keyword>$APP_NAME_LC</keyword> +</keywordset> +</bookinfo> + + <chapter id="introduction"> + <title>Introduction</title> + + <sect1 id="features"> + <title>Features</title> + <para></para> + </sect1> + </chapter> + + <chapter id="installation"> + <title>Installation</title> + + <sect1 id="how-to-obtain-$APP_NAME_LC"> + <title>How to obtain &$APP_NAME_LC;</title> + <para></para> + </sect1> + + <sect1 id="requirements"> + <title>Requirements</title> + <para></para> + </sect1> + + <sect1 id="compilation-and-installation"> + <title>Compilation and Installation</title> + + <para>Compiling &$APP_NAME_LC; is very easy. The following should do + it: <screen> +<prompt>%</prompt> <userinput><command>./configure</command></userinput> +<prompt>%</prompt> <userinput><command>make</command></userinput> +<prompt>%</prompt> <userinput><command>make</command> install</userinput></screen> + </para> + + <para>That should do it! Should you run into any problems, + please report them to the <ulink + url="mailto:$EMAIL">author</ulink></para> + </sect1> + </chapter> + + <chapter id="using-$APP_NAME_LC"> + <title>Using &$APP_NAME_LC;</title> + <para></para> + </chapter> + + <chapter id="questionsanswersandtips"> + <title>Questions, Answers, and Tips</title> + + <qandaset id="faq"> + <title>Frequently asked questions</title> + <qandaentry> + <question> + <para>Question 1</para> + </question> + <answer> + <para>The answer</para> + </answer> + </qandaentry> + </qandaset> + + </chapter> + &documentation.index; +</book> +<!-- +Local Variables: +mode: sgml +sgml-omittag: nil +sgml-shorttag: t +sgml-general-insert-case: lower +End: +--> + diff --git a/kapptemplate/kapp/lo16-app-app.png b/kapptemplate/kapp/lo16-app-app.png new file mode 100644 index 00000000..c495e509 --- /dev/null +++ b/kapptemplate/kapp/lo16-app-app.png @@ -0,0 +1,2 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/lo16-app-$APP_NAME_LC.png..."; +cp $SHARE_DIR/kapp/no-exe/lo16-app-app.png $LOCATION_ROOT/$APP_NAME_LC/lo16-app-$APP_NAME_LC.png diff --git a/kapptemplate/kapp/lo32-app-app.png b/kapptemplate/kapp/lo32-app-app.png new file mode 100644 index 00000000..6faac157 --- /dev/null +++ b/kapptemplate/kapp/lo32-app-app.png @@ -0,0 +1,2 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/lo32-app-$APP_NAME_LC.png..."; +cp $SHARE_DIR/kapp/no-exe/lo32-app-app.png $LOCATION_ROOT/$APP_NAME_LC/lo32-app-$APP_NAME_LC.png diff --git a/kapptemplate/kapp/main.cpp b/kapptemplate/kapp/main.cpp new file mode 100644 index 00000000..40118215 --- /dev/null +++ b/kapptemplate/kapp/main.cpp @@ -0,0 +1,58 @@ +echo "Creating $LOCATION_ROOT/${APP_NAME_LC}/main.cpp..."; +cat << EOF > $LOCATION_ROOT/${APP_NAME_LC}/main.cpp +#include "${APP_NAME_LC}.h" +#include <kapplication.h> +#include <dcopclient.h> +#include <kaboutdata.h> +#include <kcmdlineargs.h> +#include <klocale.h> + +static const char description[] = + I18N_NOOP("A KDE Application"); + +static const char version[] = "v${APP_VERSION}"; + +static KCmdLineOptions options[] = +{ + { "+[URL]", I18N_NOOP( "Document to open" ), 0 }, + KCmdLineLastOption +}; + +int main(int argc, char **argv) +{ + KAboutData about("${APP_NAME_LC}", I18N_NOOP("${APP_NAME}"), version, description, KAboutData::License_GPL, "(C) 2004 ${AUTHOR}", 0, 0, "${EMAIL}"); + about.addAuthor( "${AUTHOR}", 0, "${EMAIL}" ); + KCmdLineArgs::init(argc, argv, &about); + KCmdLineArgs::addCmdLineOptions(options); + KApplication app; + + // register ourselves as a dcop client + app.dcopClient()->registerAs(app.name(), false); + + // see if we are starting with session management + if (app.isRestored()) + RESTORE(${APP_NAME}) + else + { + // no session.. just start up normally + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + if (args->count() == 0) + { + ${APP_NAME} *widget = new ${APP_NAME}; + widget->show(); + } + else + { + int i = 0; + for (; i < args->count(); i++) + { + ${APP_NAME} *widget = new ${APP_NAME}; + widget->show(); + widget->load(args->url(i)); + } + } + args->clear(); + } + + return app.exec(); +} diff --git a/kapptemplate/kapp/no-exe/Makefile.am b/kapptemplate/kapp/no-exe/Makefile.am new file mode 100644 index 00000000..a377e92a --- /dev/null +++ b/kapptemplate/kapp/no-exe/Makefile.am @@ -0,0 +1,3 @@ +kappdir = $(kde_datadir)/kapptemplate/kapp/no-exe +kapp_DATA = hi32-app-app.png lo16-app-app.png hi16-app-app.png \ + hi48-app-app.png lo32-app-app.png diff --git a/kapptemplate/kapp/no-exe/hi16-app-app.png b/kapptemplate/kapp/no-exe/hi16-app-app.png Binary files differnew file mode 100644 index 00000000..43eab761 --- /dev/null +++ b/kapptemplate/kapp/no-exe/hi16-app-app.png diff --git a/kapptemplate/kapp/no-exe/hi32-app-app.png b/kapptemplate/kapp/no-exe/hi32-app-app.png Binary files differnew file mode 100644 index 00000000..ce9df987 --- /dev/null +++ b/kapptemplate/kapp/no-exe/hi32-app-app.png diff --git a/kapptemplate/kapp/no-exe/hi48-app-app.png b/kapptemplate/kapp/no-exe/hi48-app-app.png Binary files differnew file mode 100644 index 00000000..6464fb39 --- /dev/null +++ b/kapptemplate/kapp/no-exe/hi48-app-app.png diff --git a/kapptemplate/kapp/no-exe/lo16-app-app.png b/kapptemplate/kapp/no-exe/lo16-app-app.png Binary files differnew file mode 100644 index 00000000..e21db293 --- /dev/null +++ b/kapptemplate/kapp/no-exe/lo16-app-app.png diff --git a/kapptemplate/kapp/no-exe/lo32-app-app.png b/kapptemplate/kapp/no-exe/lo32-app-app.png Binary files differnew file mode 100644 index 00000000..4ecd9ce3 --- /dev/null +++ b/kapptemplate/kapp/no-exe/lo32-app-app.png diff --git a/kapptemplate/kapp/pics-Makefile.am b/kapptemplate/kapp/pics-Makefile.am new file mode 100644 index 00000000..93c2257e --- /dev/null +++ b/kapptemplate/kapp/pics-Makefile.am @@ -0,0 +1,8 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/pics/Makefile.am..."; +$MKDIR $LOCATION_ROOT/$APP_NAME_LC/pics +cat << EOF > $LOCATION_ROOT/$APP_NAME_LC/pics/Makefile.am +# Add all of your pixmaps here +#picsdata_DATA = + +# This is where it will all be installed +#picsdatadir = \$(kde_datadir)/$APP_NAME_LC/pics diff --git a/kapptemplate/kapptemplate.common b/kapptemplate/kapptemplate.common new file mode 100644 index 00000000..8cff2d60 --- /dev/null +++ b/kapptemplate/kapptemplate.common @@ -0,0 +1,496 @@ +#!/usr/bin/env bash +########################################################################### +# +# kapptemplate.common +# +# This file contains a bunch of common function that may be used by +# the various kapptemplate modules. Each function lists which +# environment variables need to be set before the function is called +# and which variables will be set after it's done. This file is +# intended to be included or sourced by any module that uses its +# functions. +# +########################################################################### + +########################################################################### +# +# Function: Usage +# +# Display the help output (--help) +# +########################################################################### +function Usage +{ + $ECHO "Usage: kapptemplate [options]"; + $ECHO "Options:"; + $ECHO " --help Display this information"; + $ECHO " --noinit Don't run '$MAKE -f Makefile.cvs'"; + $ECHO " --default Use default values instead of prompting"; + $ECHO; + $ECHO "Framework Types:"; + $ECHO " --full-app Create full featured KDE application"; + $ECHO " --kpart-app Create full KPart application"; + $ECHO " --kpart-plugin Create KPart plugin framework"; + $ECHO " --existing Convert existing source to KDE framework"; +} + +########################################################################### +# +# Function: ParseCommandLine +# +# Parse the commandline args (--help, --noinit, etc) +# +# OUTPUT: $NOINIT, $ALL_DEFAULTS, $WHICH_ONE +# +########################################################################### +function ParseCommandLine +{ + unset NOINIT; + unset ALL_DEFAULTS; + unset WHICH_ONE; + if [ ! "$CMDLINE" ]; + then + return; + fi + + for CMD in $CMDLINE; + do + case $CMD in + --help) + Usage; + exit 0;; + + --noinit) + NOINIT=1;; + --default) + ALL_DEFAULTS=1;; + --full-app) + WHICH_ONE=1;; + --kpart-app) + WHICH_ONE=2;; + --kpart-plugin) + WHICH_ONE=3;; + --existing) + WHICH_ONE=4;; + *) + $ECHO "Unknown option $1"; + Usage; + exit 1;; + esac + done +} + +########################################################################### +# +# Function: GetProperName +# +# Get the application or class or plugin or whatever's proper name +# +# INPUT : $APPTYPE, $APPDEFAULT +# OUTPUT: $APP_NAME, $APP_NAME_UC, $APP_NAME_LC +# +########################################################################### +function GetProperName +{ + # Make sure we have reasonable defaults + if [ ! "$APPTYPE" ]; + then + APPTYPE="application"; + fi + if [ ! "$APPDEFAULT" ]; + then + APPDEFAULT="KMyApp"; + fi + + # See what we are getting + if [ ! "$ALL_DEFAULTS" ]; + then + unset APP_NAME; + while [ ! $APP_NAME ]; + do + $ECHO "What is the ${APPTYPE}'s proper name [default: ${APPDEFAULT}]"; + $ECHO ": \c"; + read APP_NAME; + + if [ ! $APP_NAME ]; + then + APP_NAME=${APPDEFAULT}; + $ECHO "Going with default name '${APPDEFAULT}'"; + fi + done + $ECHO; + else + APP_NAME=${APPDEFAULT}; + fi + + # Create some variations + APP_NAME_UC=`$ECHO $APP_NAME | tr a-z A-Z`; + APP_NAME_LC=`$ECHO $APP_NAME | tr A-Z a-z`; +} + +########################################################################### +# +# Function: GetVersion +# +# Get the application or class or plugin or whatever's version +# +# INPUT : $APPTYPE +# OUTPUT: $APP_VERSION +# +########################################################################### +function GetVersion +{ + # Make sure we have reasonable defaults + if [ ! "$APPTYPE" ]; + then + APPTYPE="application"; + fi + + # Get the application version + if [ ! "$ALL_DEFAULTS" ]; + then + unset APP_VERSION; + while [ ! $APP_VERSION ]; + do + $ECHO "What is the ${APPTYPE}'s version [default: 0.1]"; + $ECHO ": \c"; + read APP_VERSION; + + if [ ! $APP_VERSION ]; + then + APP_VERSION="0.1"; + $ECHO "Going with default version '$APP_VERSION'"; + fi + done + $ECHO; + else + APP_VERSION="0.1"; + fi +} + +########################################################################### +# +# Function: GetLocationRoot +# +# Get the directory where this all should be installed +# +# INPUT : $DEFAULT_ROOT, $APP_NAME_LC, $APP_VERSION +# OUTPUT: $LOCATION_ROOT +# +########################################################################### +function GetLocationRoot +{ + if [ ! "$ALL_DEFAULTS" ]; + then + unset LOCATION_ROOT; + while [ ! $LOCATION_ROOT ]; + do + $ECHO "Where should I create this [default: $DEFAULT_ROOT/$APP_NAME_LC-$APP_VERSION]"; + $ECHO ": \c"; + read LOCATION_ROOT; + + if [ ! $LOCATION_ROOT ]; + then + LOCATION_ROOT="$DEFAULT_ROOT/$APP_NAME_LC-$APP_VERSION"; + $ECHO "Going with default root '$LOCATION_ROOT'"; + fi + + # We overwrite anything if the directory already exists + if [ -d $LOCATION_ROOT ]; + then + $ECHO "This directory already exists. Will overwrite."; + $ECHO; + fi + done + $ECHO; + else + LOCATION_ROOT="$DEFAULT_ROOT/$APP_NAME_LC-$APP_VERSION"; + fi + +} + +########################################################################### +# +# Function: GetAuthorName +# +# Get the name of the author +# +# INPUT: $DEFAULT_AUTHOR +# +########################################################################### +function GetAuthorName +{ + unset AUTHOR; + while [ ! "$AUTHOR" ]; + do + if [ "$ALL_DEFAULTS" -a "$DEFAULT_AUTHOR" ]; + then + AUTHOR="$DEFAULT_AUTHOR"; + else + if [ "$DEFAULT_AUTHOR" ]; + then + $ECHO "What is your name [default: $DEFAULT_AUTHOR]"; + else + $ECHO "What is your name [no default]"; + fi + $ECHO ": \c"; + read AUTHOR; + + if [ "$DEFAULT_AUTHOR" -a ! "$AUTHOR" ]; + then + AUTHOR="$DEFAULT_AUTHOR"; + $ECHO "Going with default author '$AUTHOR'"; + fi + fi + done + $ECHO; +} + +########################################################################### +# +# Function: GetAuthorEmail +# +# Get the email of the author +# +# INPUT: $DEFAULT_EMAIL +# +########################################################################### +function GetAuthorEmail +{ + unset EMAIL; + while [ ! "$EMAIL" ]; + do + if [ "$ALL_DEFAULTS" -a "$DEFAULT_EMAIL" ]; + then + EMAIL="$DEFAULT_EMAIL"; + else + if [ "$DEFAULT_EMAIL" ]; + then + $ECHO "What is your email address [default: $DEFAULT_EMAIL]"; + else + $ECHO "What is your email address [no default]"; + fi + $ECHO ": \c"; + read EMAIL; + + if [ "$DEFAULT_EMAIL" -a ! "$EMAIL" ]; + then + EMAIL="$DEFAULT_EMAIL"; + $ECHO "Going with default email address '$EMAIL'"; + fi + fi + done + $ECHO; +} + +########################################################################### +# +# Function: GetFileList +# +# Generic utility function to get a list of files in a directory +# +# INPUT : $DIRECTORY +# OUTPUT: $FILES +# +########################################################################### +function GetFileList +{ + unset FILES; + if [ -d "$DIRECTORY" ]; + then +# FILES=`/bin/ls -1 -I "no-exe" -I*~ $DIRECTORY`; + FILES=`cd $DIRECTORY; find . ! -name "*~" -maxdepth 1 -type f -print | sed 's,^\./,,' | sort`; + + if [ ! "$FILES" ]; + then + $ECHO "Cannot find files in $DIRECTORY!"; + exit 1; + fi + else + $ECHO "$DIRECTORY directory does not exist!"; + exit 1; + fi +} + +########################################################################### +# +# Function: BuildModuleLists +# +# Build a list of files that correspond with each module +# +# INPUT : $SHARE_DIR +# +########################################################################### +function BuildModuleLists +{ + # Make sure all the modules exist first + if [ ! -f "$INCLUDE_DIR/kapptemplate.module" ]; + then + $ECHO "The 'kapptemplate.module' file can't be found."; + $ECHO; + exit 1; + fi + + if [ ! -f "$INCLUDE_DIR/kpartplugin.module" ]; + then + $ECHO "The 'kpartplugin.module' file can't be found."; + $ECHO; + exit 1; + fi + + if [ ! -f "$INCLUDE_DIR/existing.module" ]; + then + $ECHO "The 'existing.module' file can't be found."; + $ECHO; + exit 1; + fi + + # Find the 'admin' files + DIRECTORY=$SHARE_DIR/admin; + GetFileList + ADMIN_FILES=$FILES; + + # Find the 'appframework' files + DIRECTORY=$SHARE_DIR/appframework; + GetFileList + APPFRAMEWORK_FILES=$FILES; + + # Find the 'kapp' files + DIRECTORY=$SHARE_DIR/kapp; + GetFileList + KAPP_FILES=$FILES; + + # Find the 'kpartplugin' files + DIRECTORY=$SHARE_DIR/kpartplugin; + GetFileList + KPARTPLUGIN_FILES=$FILES; + + # Find the 'existing' files + DIRECTORY=$SHARE_DIR/existing; + GetFileList + EXISTING_FILES=$FILES; + + # Find the 'kpartapp' files + DIRECTORY=$SHARE_DIR/kpartapp; + GetFileList + KPARTAPP_FILES=$FILES; +} + +########################################################################### +# +# Function: CreateAppFramework +# +# Create the initial directory structure of the application or plugin +# and put in the common admin and configure files +# +# INPUT : $LOCATION_ROOT, $APP_NAME_LC, $SHARE_DIR +# +########################################################################### +function CreateAppFramework +{ + # Create the directory tree + $ECHO; + $ECHO "Creating directory $LOCATION_ROOT..."; + $MKDIR $LOCATION_ROOT || exit 1; + + $ECHO "Creating directory $LOCATION_ROOT/admin..."; + $MKDIR $LOCATION_ROOT/admin || exit 1; + + $ECHO "Creating directory $LOCATION_ROOT/$APP_NAME_LC..."; + $MKDIR $LOCATION_ROOT/$APP_NAME_LC || exit 1; + + $ECHO "Creating directory $LOCATION_ROOT/po..."; + $MKDIR $LOCATION_ROOT/po || exit 1; + + for FILE in $ADMIN_FILES; + do + $ECHO "Copying $LOCATION_ROOT/$FILE..."; + cp -p $SHARE_DIR/admin/$FILE $LOCATION_ROOT/admin/$FILE || exit 1; + done + + for FILE in $APPFRAMEWORK_FILES; + do + . $SHARE_DIR/appframework/$FILE || exit 1; + done +} + +########################################################################### +# +# Function: GetInitialDefaults +# +# This is run the first time a user uses kapptemplate. It gets a few +# default values and installs them into $HOME/.kapptemplate +# +# INPUT: $KAPPTEMPLATEVERSION +# +########################################################################### +function GetInitialDefaults +{ + $ECHO "I see that this is your first time using KAppTemplate. Excellent!"; + $ECHO "To get started, I need you to answer the following questions. Your"; + $ECHO "answers will be used as the default values every time you use this"; + $ECHO "program in the future."; + unset THE_AUTHOR; + while [ ! "$THE_AUTHOR" ]; + do + $ECHO "What is your full name? \c"; + if [ "$DEFAULT_AUTHOR" ]; + then + $ECHO "[default: $DEFAULT_AUTHOR]"; + else + $ECHO "[no default]"; + fi + $ECHO ": \c"; + read THE_AUTHOR; + + if [ "$DEFAULT_AUTHOR" -a ! "$THE_AUTHOR" ]; + then + THE_AUTHOR="$DEFAULT_AUTHOR"; + fi + done + $ECHO; + + unset THE_EMAIL; + while [ ! "$THE_EMAIL" ]; + do + $ECHO "What is your email address? \c"; + if [ "$DEFAULT_EMAIL" ]; + then + $ECHO "[default: $DEFAULT_EMAIL]"; + else + $ECHO "[no default]"; + fi + $ECHO ": \c"; + read THE_EMAIL; + + if [ "$DEFAULT_EMAIL" -a ! "$THE_EMAIL" ]; + then + THE_EMAIL="$DEFAULT_EMAIL"; + fi + done + $ECHO; + + unset THE_ROOT; + $ECHO "Where should I construct apps? \c"; + if [ ! "$DEFAULT_ROOT" ]; + then + DEFAULT_ROOT="$HOME/src"; + fi + $ECHO "[default: $DEFAULT_ROOT]"; + $ECHO ": \c"; + read THE_ROOT; + + if [ ! "$THE_ROOT" ]; + then + THE_ROOT="$DEFAULT_ROOT"; + fi + $ECHO; + + $ECHO "Constructing .kapptemplaterc..."; + cat << ENDORC > $HOME/.kapptemplaterc +DEFAULT_AUTHOR="$THE_AUTHOR"; +DEFAULT_EMAIL="$THE_EMAIL"; +DEFAULT_ROOT="$THE_ROOT"; +VERSION="$KAPPTEMPLATEVERSION"; +ENDORC +} diff --git a/kapptemplate/kapptemplate.in b/kapptemplate/kapptemplate.in new file mode 100644 index 00000000..dde86d04 --- /dev/null +++ b/kapptemplate/kapptemplate.in @@ -0,0 +1,131 @@ +########################################################################### +# +# Function: LoadDefaults +# +# This will load in all the default values stored in the user's +# .kapptemplaterc file +# +# INPUT : $KAPPTEMPLATEVERSION, $INSTALLED_SHARE_DIR +# OUTPUT: $ECHO, $KAPPTEMPLATERC, $DEFAULT_AUTHOR, $DEFAULT_EMAIL, +# $DEFAULT_ROOT, $SHARE_DIR, $BIN_DIR, $MKDIR, $BASENAME +# +########################################################################### +function LoadDefaults +{ + # horrid hack to try and figure out what shell we are using + # basically, if we can find /usr/ucb/echo, then we are almost for sure + # NOT on a Linux system and probably 'echo "\c" works. if we don't + # find it, we'll assume that the shell is really bash. + if [ -f "/usr/ucb/echo" ]; + then + ECHO="echo"; + else + ECHO="echo -e"; + fi + + # If $MAKE hasn't been set yet, try to figure out how we reach GNU make + # ourselves. + if [ ! "$MAKE" ]; + then + if [ -f "/usr/bin/gmake" ] || [ -f "/usr/local/bin/gmake" ]; + then + MAKE="gmake"; + else + MAKE="make"; + fi + fi + + $ECHO "KAppTemplate v${KAPPTEMPLATEVERSION} (C) 2003 Kurt Granroth <granroth@kde.org>"; + $ECHO; + + if [ ! "$KAPPTEMPLATERC" ]; + then + KAPPTEMPLATERC=$HOME/.kapptemplaterc + fi + + if [ -f $KAPPTEMPLATERC ]; + then + . $KAPPTEMPLATERC + else + GetInitialDefaults + fi + + if [ ! "$DEFAULT_AUTHOR" ]; + then + DEFAULT_AUTHOR="Your Name"; + fi + + if [ ! "$DEFAULT_EMAIL" ]; + then + DEFAULT_EMAIL="`whoami`@$HOST"; + fi + + if [ ! "$DEFAULT_ROOT" ]; + then + DEFAULT_ROOT="$HOME/src"; + fi + + SHARE_DIR=$INSTALLED_SHARE_DIR; + INCLUDE_DIR="$SHARE_DIR/include"; + + if [ -f "$SHARE_DIR/bin/mkinstalldirs" ]; + then + MKDIR=$SHARE_DIR/bin/mkinstalldirs + else + MKDIR=mkdir + fi + + # Finally, get the name of the running program + BASENAME=`echo $0 | sed 's@^.*/@@g'`; +} + +# We start by loading the 'common' file containing all useful +# functions +if [ -f $INSTALLED_SHARE_DIR/include/kapptemplate.common ]; +then + . $INSTALLED_SHARE_DIR/include/kapptemplate.common +else + $ECHO "Could not find common file 'kapptemplate.common'"; + $ECHO; + exit 1; +fi + +# Then, we load all the default environment variables and perform +# any necessary initialization +LoadDefaults + +# Parse the command line +CMDLINE=$@; +ParseCommandLine + +# Do a sanity check and build the various module lists +BuildModuleLists + +if [ ! "$WHICH_ONE" ] && [ "$ALL_DEFAULTS" ]; +then + WHICH_ONE=1; +fi +if [ ! "$WHICH_ONE" ]; +then + # Find out how to use kapptemplate this time + $ECHO "Please select the type of framework you wish to generate"; + $ECHO "1. Full featured KDE application [default]"; + $ECHO "2. Full featured KPart application"; + $ECHO "3. KPart plugin"; + $ECHO "4. Convert existing source to automake/autoconf framework"; + $ECHO "Choose [1-4]: \c"; + read WHICH_ONE; + $ECHO; +fi; + +# Start the proper module +case $WHICH_ONE in + 2) + . $INCLUDE_DIR/kpartapp.module;; + 3) + . $INCLUDE_DIR/kpartplugin.module;; + 4) + . $INCLUDE_DIR/existing.module;; + *) + . $INCLUDE_DIR/kapptemplate.module;; +esac diff --git a/kapptemplate/kapptemplate.lsm b/kapptemplate/kapptemplate.lsm new file mode 100644 index 00000000..d557a8f7 --- /dev/null +++ b/kapptemplate/kapptemplate.lsm @@ -0,0 +1,18 @@ +Begin3 +Title: KAppTemplate +Version: 1.0.6 +Entered-date: 05Jul01 +Description: Modular shell script that will automatically create a + framework for either a normal KDE 2.x application, a + KPart application, a KPart plugin, or convert an + existing application. +Keywords: KDE application generator DCOP KParts Plugins XML-GUI +Author: Kurt Granroth <granroth@kde.org> +Maintained-by: Kurt Granroth <granroth@kde.org> +Home-page: http://www.granroth.org/kapptemplate +Primary-site: cvs.kde.org:/home/kde/kdesdk/kapptemplate + xxxxxx kapptemplate-1.0.6.tar.bz2 + xxx kapptemplate-1.0.6.lsm +Platform: Unix +Copying-policy: GPL +End diff --git a/kapptemplate/kapptemplate.module b/kapptemplate/kapptemplate.module new file mode 100644 index 00000000..90e78649 --- /dev/null +++ b/kapptemplate/kapptemplate.module @@ -0,0 +1,68 @@ +########################################################################### +# +# STEP 1: GET USER INFORMATION +# +########################################################################### +# Get the application name +GetProperName + +# Get the application version +GetVersion + +# Get the root where this framework will be installed +GetLocationRoot + +# Get the author's name +GetAuthorName + +# Get the author's email +GetAuthorEmail + +# Verify that everything is grand +$ECHO; +$ECHO "Here is what I have:"; +$ECHO "The app: $APP_NAME v$APP_VERSION"; +$ECHO "Installed in: $LOCATION_ROOT"; +$ECHO "Author: $AUTHOR <$EMAIL>"; +$ECHO; +$ECHO "Is this correct (Y/n)? "; +$ECHO ": \c"; +read Y_N; +if [ $Y_N -a $Y_N = 'n' ]; +then + $ECHO "AUGH! Well, try again."; + exit 0; +fi +$ECHO; + +$ECHO "OK, Here we go!!"; + +########################################################################### +# +# STEP 2: CREATE APPLICATION FRAMEWORK +# +########################################################################### +CreateAppFramework + +########################################################################### +# +# STEP 3: GENERATE APP-SPECIFIC FILES +# +########################################################################### + +for EXE_FILE in $KAPP_FILES; +do + . $SHARE_DIR/kapp/$EXE_FILE || exit 1; +done + +########################################################################### +# +# STEP 4: FINAL STEPS +# +########################################################################### + +if [ ! $NOINIT ]; then + cd $LOCATION_ROOT && $MAKE -f Makefile.cvs +fi + +$ECHO "DONE!"; diff --git a/kapptemplate/kpartapp.module b/kapptemplate/kpartapp.module new file mode 100644 index 00000000..16c0e630 --- /dev/null +++ b/kapptemplate/kpartapp.module @@ -0,0 +1,70 @@ +########################################################################### +# +# STEP 1: GET USER INFORMATION +# +########################################################################### +# Get the application name +APPTYPE="KPart application"; +APPDEFAULT="KPartApp"; +GetProperName + +# Get the application version +GetVersion + +# Get the root where this framework will be installed +GetLocationRoot + +# Get the author's name +GetAuthorName + +# Get the author's email +GetAuthorEmail + +# Verify that everything is grand +$ECHO; +$ECHO "Here is what I have:"; +$ECHO "The app: $APP_NAME v$APP_VERSION"; +$ECHO "Installed in: $LOCATION_ROOT"; +$ECHO "Author: $AUTHOR <$EMAIL>"; +$ECHO; +$ECHO "Is this correct (Y/n)? "; +$ECHO ": \c"; +read Y_N; +if [ $Y_N -a $Y_N = 'n' ]; +then + $ECHO "AUGH! Well, try again."; + exit 0; +fi +$ECHO; + +$ECHO "OK, Here we go!!"; + +########################################################################### +# +# STEP 2: CREATE APPLICATION FRAMEWORK +# +########################################################################### +CreateAppFramework + +########################################################################### +# +# STEP 3: GENERATE APP-SPECIFIC FILES +# +########################################################################### + +for EXE_FILE in $KPARTAPP_FILES; +do + . $SHARE_DIR/kpartapp/$EXE_FILE || exit 1; +done + +########################################################################### +# +# STEP 4: FINAL STEPS +# +########################################################################### + +if [ ! $NOINIT ]; then + cd $LOCATION_ROOT && $MAKE -f Makefile.cvs +fi + +$ECHO "DONE!"; diff --git a/kapptemplate/kpartapp/Makefile.am b/kapptemplate/kpartapp/Makefile.am new file mode 100644 index 00000000..26e92118 --- /dev/null +++ b/kapptemplate/kpartapp/Makefile.am @@ -0,0 +1,10 @@ +SUBDIRS=no-exe + +kpartappdir = $(kde_datadir)/kapptemplate/kpartapp +kpartapp_DATA = app_part.cpp doc-app-Makefile.am \ + lo32-app-app.png \ + app-Makefile.am app_part-desktop hi16-app-app.png main.cpp \ + app-configure.in.in app_part.h hi32-app-app.png \ + app.cpp app_part.rc hi48-app-app.png \ + app-desktop app_shell.rc index.docbook \ + app.h doc-Makefile.am lo16-app-app.png diff --git a/kapptemplate/kpartapp/app-Makefile.am b/kapptemplate/kpartapp/app-Makefile.am new file mode 100644 index 00000000..3aa0495f --- /dev/null +++ b/kapptemplate/kpartapp/app-Makefile.am @@ -0,0 +1,57 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/Makefile.am..."; +cat << EOF > $LOCATION_ROOT/$APP_NAME_LC/Makefile.am +# this has all of the subdirectories that make will recurse into. if +# there are none, comment this out +#SUBDIRS = . + +# set the include path for X, qt and KDE +INCLUDES = \$(all_includes) + +# these are the headers for your project +noinst_HEADERS = ${APP_NAME_LC}.h ${APP_NAME_LC}_part.h + +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + +messages: rc.cpp + \$(XGETTEXT) *.cpp -o \$(podir)/${APP_NAME_LC}.pot + +KDE_ICON = ${APP_NAME_LC} + +# 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 = ${APP_NAME_LC} + +# the application source, library search path, and link libraries +${APP_NAME_LC}_SOURCES = main.cpp ${APP_NAME_LC}.cpp +${APP_NAME_LC}_LDFLAGS = \$(KDE_RPATH) \$(all_libraries) +${APP_NAME_LC}_LDADD = \$(LIB_KPARTS) + +# this is where the desktop file will go +xdg_apps_DATA = ${APP_NAME_LC}.desktop + +# this is where the shell's XML-GUI resource file goes +shellrcdir = \$(kde_datadir)/${APP_NAME_LC} +shellrc_DATA = ${APP_NAME_LC}_shell.rc + +######################################################################### +# KPART SECTION +######################################################################### +kde_module_LTLIBRARIES = lib${APP_NAME_LC}part.la + +# the Part's source, library search path, and link libraries +lib${APP_NAME_LC}part_la_SOURCES = ${APP_NAME_LC}_part.cpp +lib${APP_NAME_LC}part_la_LDFLAGS = -module \$(KDE_PLUGIN) \$(all_libraries) +lib${APP_NAME_LC}part_la_LIBADD = \$(LIB_KPARTS) \$(LIB_KFILE) + +# this is where the desktop file will go +partdesktopdir = \$(kde_servicesdir) +partdesktop_DATA = ${APP_NAME_LC}_part.desktop + +# this is where the part's XML-GUI resource file goes +partrcdir = \$(kde_datadir)/${APP_NAME_LC}part +partrc_DATA = ${APP_NAME_LC}_part.rc diff --git a/kapptemplate/kpartapp/app-configure.in.in b/kapptemplate/kpartapp/app-configure.in.in new file mode 100644 index 00000000..4d050a09 --- /dev/null +++ b/kapptemplate/kpartapp/app-configure.in.in @@ -0,0 +1,14 @@ +echo "Creating $LOCATION_ROOT/configure.in.in..."; +cat << EOF > $LOCATION_ROOT/configure.in.in +#MIN_CONFIG + +AM_INIT_AUTOMAKE(${APP_NAME_LC}, ${APP_VERSION}) + +dnl These are common macros that you might or might not want to use + +dnl Checks for header files. +AC_HEADER_DIRENT +AC_HEADER_STDC +AC_HEADER_TIME +AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h stdlib.h paths.h) +AC_CHECK_FUNCS(usleep) diff --git a/kapptemplate/kpartapp/app-desktop b/kapptemplate/kpartapp/app-desktop new file mode 100644 index 00000000..7b4090f1 --- /dev/null +++ b/kapptemplate/kpartapp/app-desktop @@ -0,0 +1,11 @@ +echo "Creating $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}.desktop..."; +cat << EOF > $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}.desktop +[Desktop Entry] +Encoding=UTF-8 +Name=${APP_NAME} +Exec=${APP_NAME_LC} %i %m -caption "%c" +Icon=${APP_NAME_LC} +Type=Application +DocPath=${APP_NAME_LC}/${APP_NAME_LC}.html +GenericName=A KDE KPart Application +Terminal=0 diff --git a/kapptemplate/kpartapp/app.cpp b/kapptemplate/kpartapp/app.cpp new file mode 100644 index 00000000..8b04053e --- /dev/null +++ b/kapptemplate/kpartapp/app.cpp @@ -0,0 +1,176 @@ +echo "Creating $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}.cpp..."; +cat << EOF > $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}.cpp +/* + * ${APP_NAME_LC}.cpp + * + * Copyright (C) 2004 $AUTHOR <$EMAIL> + */ +#include "${APP_NAME_LC}.h" +#include "${APP_NAME_LC}.moc" + +#include <kkeydialog.h> +#include <kconfig.h> +#include <kurl.h> + +#include <kedittoolbar.h> + +#include <kaction.h> +#include <kstdaction.h> + +#include <klibloader.h> +#include <kmessagebox.h> +#include <kfiledialog.h> +#include <kstatusbar.h> + +${APP_NAME}::${APP_NAME}() + : KParts::MainWindow( 0L, "${APP_NAME}" ) +{ + // set the shell's ui resource file + setXMLFile("${APP_NAME_LC}_shell.rc"); + + // then, setup our actions + setupActions(); + + // 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${APP_NAME_LC}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, + "${APP_NAME_LC}_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, "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(); +} + +${APP_NAME}::~${APP_NAME}() +{ +} + +void ${APP_NAME}::load(const KURL& url) +{ + m_part->openURL( url ); +} + +void ${APP_NAME}::setupActions() +{ + KStdAction::openNew(this, SLOT(fileNew()), actionCollection()); + KStdAction::open(this, SLOT(fileOpen()), actionCollection()); + + KStdAction::quit(kapp, SLOT(quit()), actionCollection()); + + createStandardStatusBarAction(); + setStandardToolBarMenuEnabled(true); + + KStdAction::keyBindings(this, SLOT(optionsConfigureKeys()), actionCollection()); + KStdAction::configureToolbars(this, SLOT(optionsConfigureToolbars()), actionCollection()); +} + +void ${APP_NAME}::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 ${APP_NAME}::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 ${APP_NAME}::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 ${APP_NAME})->show(); + }; +} + +void ${APP_NAME}::optionsConfigureKeys() +{ + KKeyDialog dlg( true, this ); + dlg.insert( actionCollection(), "${APP_NAME_LC}_shell.rc" ); + dlg.insert( m_part->actionCollection(), "${APP_NAME_LC}_part.rc" ); + (void) dlg.configure( true ); +} + +void ${APP_NAME}::optionsConfigureToolbars() +{ + saveMainWindowSettings(KGlobal::config(), autoSaveGroup()); + + // use the standard toolbar editor + KEditToolbar dlg(factory()); + connect(&dlg, SIGNAL(newToolbarConfig()), + this, SLOT(applyNewToolbarConfig())); + dlg.exec(); +} + +void ${APP_NAME}::applyNewToolbarConfig() +{ + applyMainWindowSettings(KGlobal::config(), autoSaveGroup()); +} + +void ${APP_NAME}::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... + ${APP_NAME}* newWin = new ${APP_NAME}; + newWin->load( url ); + newWin->show(); + } + } +} diff --git a/kapptemplate/kpartapp/app.h b/kapptemplate/kpartapp/app.h new file mode 100644 index 00000000..41daea60 --- /dev/null +++ b/kapptemplate/kpartapp/app.h @@ -0,0 +1,70 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/${APP_NAME_LC}.h..."; +cat << EOF > $LOCATION_ROOT/$APP_NAME_LC/${APP_NAME_LC}.h +#ifndef ${APP_NAME_UC}_H +#define ${APP_NAME_UC}_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <kapplication.h> +#include <kparts/mainwindow.h> + +/** + * 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 ${APP_VERSION} + */ +class ${APP_NAME} : public KParts::MainWindow +{ + Q_OBJECT +public: + /** + * Default Constructor + */ + ${APP_NAME}(); + + /** + * Default Destructor + */ + virtual ~${APP_NAME}(); + + /** + * 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 optionsConfigureKeys(); + void optionsConfigureToolbars(); + + void applyNewToolbarConfig(); + +private: + void setupAccel(); + void setupActions(); + +private: + KParts::ReadWritePart *m_part; +}; + +#endif // ${APP_NAME_UC}_H diff --git a/kapptemplate/kpartapp/app_part-desktop b/kapptemplate/kpartapp/app_part-desktop new file mode 100644 index 00000000..6ba3bf54 --- /dev/null +++ b/kapptemplate/kpartapp/app_part-desktop @@ -0,0 +1,9 @@ +echo "Creating $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}_part.desktop..."; +cat << EOF > $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}_part.desktop +[Desktop Entry] +Encoding=UTF-8 +Name=${APP_NAME}Part +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${APP_NAME_LC}part +Type=Service diff --git a/kapptemplate/kpartapp/app_part.cpp b/kapptemplate/kpartapp/app_part.cpp new file mode 100644 index 00000000..c2821950 --- /dev/null +++ b/kapptemplate/kpartapp/app_part.cpp @@ -0,0 +1,148 @@ +echo "Creating $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}_part.cpp..."; +cat << EOF > $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}_part.cpp +#include "${APP_NAME_LC}_part.h" + +#include "${APP_NAME_LC}_part.moc" + +#include <kinstance.h> +#include <kaction.h> +#include <kstdaction.h> +#include <kfiledialog.h> +#include <kparts/genericfactory.h> + +#include <qfile.h> +#include <qtextstream.h> +#include <qmultilineedit.h> + +typedef KParts::GenericFactory<${APP_NAME}Part> ${APP_NAME}PartFactory; +K_EXPORT_COMPONENT_FACTORY( lib${APP_NAME_LC}part, ${APP_NAME}PartFactory ) + +${APP_NAME}Part::${APP_NAME}Part( QWidget *parentWidget, const char *widgetName, + QObject *parent, const char *name, + const QStringList & /*args*/ ) + : KParts::ReadWritePart(parent, name) +{ + // we need an instance + setInstance( ${APP_NAME}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::saveAs(this, SLOT(fileSaveAs()), actionCollection()); + KStdAction::save(this, SLOT(save()), actionCollection()); + + // set our XML-UI resource file + setXMLFile("${APP_NAME_LC}_part.rc"); + + // we are read-write by default + setReadWrite(true); + + // we are not modified since we haven't done anything yet + setModified(false); +} + +${APP_NAME}Part::~${APP_NAME}Part() +{ +} + +void ${APP_NAME}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 ${APP_NAME}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); +} + +KAboutData *${APP_NAME}Part::createAboutData() +{ + // the non-i18n name here must be the same as the directory in + // which the part's rc file is installed ('partrcdir' in the + // Makefile) + KAboutData *aboutData = new KAboutData("${APP_NAME_LC}part", I18N_NOOP("${APP_NAME}Part"), "${APP_VERSION}"); + aboutData->addAuthor("${AUTHOR}", 0, "${EMAIL}"); + return aboutData; +} + +bool ${APP_NAME}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 ${APP_NAME}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 ${APP_NAME}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); +} + diff --git a/kapptemplate/kpartapp/app_part.h b/kapptemplate/kpartapp/app_part.h new file mode 100644 index 00000000..18841510 --- /dev/null +++ b/kapptemplate/kpartapp/app_part.h @@ -0,0 +1,69 @@ +echo "Creating $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}_part.h..."; +cat << EOF > $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}_part.h +#ifndef ${APP_NAME_UC}PART_H +#define ${APP_NAME_UC}PART_H + +#include <kparts/part.h> + +class QWidget; +class QPainter; +class KURL; +class QMultiLineEdit; +class KAboutData; + +/** + * This is a "Part". It that does all the real work in a KPart + * application. + * + * @short Main Part + * @author ${AUTHOR} <${EMAIL}> + * @version ${APP_VERSION} + */ +class ${APP_NAME}Part : public KParts::ReadWritePart +{ + Q_OBJECT +public: + /** + * Default constructor + */ + ${APP_NAME}Part(QWidget *parentWidget, const char *widgetName, + QObject *parent, const char *name, const QStringList &args); + + /** + * Destructor + */ + virtual ~${APP_NAME}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); + + static KAboutData *createAboutData(); + +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 fileSaveAs(); + +private: + QMultiLineEdit *m_widget; +}; + +#endif // ${APP_NAME_UC}PART_H diff --git a/kapptemplate/kpartapp/app_part.rc b/kapptemplate/kpartapp/app_part.rc new file mode 100644 index 00000000..793fe772 --- /dev/null +++ b/kapptemplate/kpartapp/app_part.rc @@ -0,0 +1,17 @@ +echo "Creating $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}_part.rc..."; +cat << EOF > $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}_part.rc +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui name="${APP_NAME_LC}_part" version="1"> +<MenuBar> + <Menu name="file"> + <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/kapptemplate/kpartapp/app_shell.rc b/kapptemplate/kpartapp/app_shell.rc new file mode 100644 index 00000000..22b95aad --- /dev/null +++ b/kapptemplate/kpartapp/app_shell.rc @@ -0,0 +1,32 @@ +echo "Creating $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}_shell.rc..."; +cat << EOF > $LOCATION_ROOT/${APP_NAME_LC}/${APP_NAME_LC}_shell.rc +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui name="${APP_NAME_LC}_shell" version="1"> +<MenuBar> + <Menu noMerge="1" name="file"><text>&File</text> + <Action name="file_new"/> + <Action name="file_open"/> + <Separator/> + <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/kapptemplate/kpartapp/doc-Makefile.am b/kapptemplate/kpartapp/doc-Makefile.am new file mode 100644 index 00000000..02611d03 --- /dev/null +++ b/kapptemplate/kpartapp/doc-Makefile.am @@ -0,0 +1,8 @@ +echo "Creating $LOCATION_ROOT/doc/Makefile.am..."; +$MKDIR $LOCATION_ROOT/doc +cat << EOF > $LOCATION_ROOT/doc/Makefile.am + +SUBDIRS = \$(AUTODIRS) +KDE_DOCS = $APP_NAME_LC +KDE_LANG = en + diff --git a/kapptemplate/kpartapp/doc-app-Makefile.am b/kapptemplate/kpartapp/doc-app-Makefile.am new file mode 100644 index 00000000..0356a93a --- /dev/null +++ b/kapptemplate/kpartapp/doc-app-Makefile.am @@ -0,0 +1,9 @@ +echo "Creating $LOCATION_ROOT/doc/$APP_NAME_LC/Makefile.am..."; +$MKDIR $LOCATION_ROOT/doc/$APP_NAME_LC +cat << EOF > $LOCATION_ROOT/doc/$APP_NAME_LC/Makefile.am + +# the SUBDIRS is filled automatically by am_edit. If files are +# in this directory they are installed into the english dir +KDE_LANG = en +KDE_DOCS = $APP_NAME_LC +SUBDIRS = \$(AUTODIRS) diff --git a/kapptemplate/kpartapp/hi16-app-app.png b/kapptemplate/kpartapp/hi16-app-app.png new file mode 100644 index 00000000..2f82a953 --- /dev/null +++ b/kapptemplate/kpartapp/hi16-app-app.png @@ -0,0 +1,2 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/hi16-app-$APP_NAME_LC.png..."; +cp $SHARE_DIR/kapp/no-exe/hi16-app-app.png $LOCATION_ROOT/$APP_NAME_LC/hi16-app-$APP_NAME_LC.png diff --git a/kapptemplate/kpartapp/hi32-app-app.png b/kapptemplate/kpartapp/hi32-app-app.png new file mode 100644 index 00000000..767c9448 --- /dev/null +++ b/kapptemplate/kpartapp/hi32-app-app.png @@ -0,0 +1,2 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/hi32-app-$APP_NAME_LC.png..."; +cp $SHARE_DIR/kapp/no-exe/hi32-app-app.png $LOCATION_ROOT/$APP_NAME_LC/hi32-app-$APP_NAME_LC.png diff --git a/kapptemplate/kpartapp/hi48-app-app.png b/kapptemplate/kpartapp/hi48-app-app.png new file mode 100644 index 00000000..08970c62 --- /dev/null +++ b/kapptemplate/kpartapp/hi48-app-app.png @@ -0,0 +1,2 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/hi48-app-$APP_NAME_LC.png..."; +cp $SHARE_DIR/kapp/no-exe/hi48-app-app.png $LOCATION_ROOT/$APP_NAME_LC/hi48-app-$APP_NAME_LC.png diff --git a/kapptemplate/kpartapp/index.docbook b/kapptemplate/kpartapp/index.docbook new file mode 100644 index 00000000..86d1ee8d --- /dev/null +++ b/kapptemplate/kpartapp/index.docbook @@ -0,0 +1,106 @@ +echo "Creating $LOCATION_ROOT/doc/$APP_NAME_LC/index.docbook..."; +echo "It is better to use template.docbook instead of this - please replace it" +cat << EOF > $LOCATION_ROOT/doc/$APP_NAME_LC/index.docbook +<?xml version="1.0" ?> +<!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.1-Based Variant V1.0//EN" "dtd/kdex.dtd" [ + <!ENTITY kappname "&$APP_NAME;"> + <!ENTITY % addindex "IGNORE"> + <!ENTITY % English "INCLUDE" > <!-- change language only here --> +]> +<!-- Important note: please use template.docbook instead of this file. + This is only the conversion of app.sgml into DocBook SGML. + template.docbook gives you more information on what you can and + should do. Thanks. --> + +<book lang="&language;"> + +<bookinfo> +<title>The $APP_NAME Handbook</title> +<authorgroup> +<author> +<firstname></firstname> +<surname>$AUTHOR</surname> +<affiliation><address><email>$EMAIL</email></address></affiliation> +</author> +</authorgroup> +<date>`date "+%Y-%m-%d"`</date> +<releaseinfo>$APP_VERSION</releaseinfo> +<abstract> +<para>SHORT DESCRIPTION GOES HERE</para> +</abstract> +<keywordset> +<keyword>KDE</keyword> +<keyword>$APP_NAME</keyword> +</keywordset> +</bookinfo> + + <chapter id="introduction"> + <title>Introduction</title> + + <sect1 id="features"> + <title>Features</title> + <para></para> + </sect1> + </chapter> + + <chapter id="installation"> + <title>Installation</title> + + <sect1 id="how-to-obtain-$APP_NAME"> + <title>How to obtain $APP_NAME</title> + <para></para> + </sect1> + + <sect1 id="requirements"> + <title>Requirements</title> + <para></para> + </sect1> + + <sect1 id="compilation-and-installation"> + <title>Compilation and Installation</title> + + <para>Compiling $APP_NAME is very easy. The following should do + it: <screen> +<prompt>%</prompt> <userinput><command>./configure</command></userinput> +<prompt>%</prompt> <userinput><command>make</command></userinput> +<prompt>%</prompt> <userinput><command>make</command> install</userinput></screen> + </para> + + <para>That should do it! Should you run into any problems, + please report them to the <ulink + url="mailto:$EMAIL">author</ulink></para> + </sect1> + </chapter> + + <chapter id="using-$APP_NAME"> + <title>Using $APP_NAME</title> + <para></para> + </chapter> + + <chapter id="questionsanswersandtips"> + <title>Questions, Answers, and Tips</title> + + <qandaset id="faq"> + <title>Frequently asked questions</title> + <qandaentry> + <question> + <para>Question 1</para> + </question> + <answer> + <para>The answer</para> + </answer> + </qandaentry> + </qandaset> + + </chapter> + &documentation.index; +</book> +<!-- +Local Variables: +mode: sgml +sgml-omittag: nil +sgml-shorttag: t +sgml-general-insert-case: lower +End: +--> + diff --git a/kapptemplate/kpartapp/lo16-app-app.png b/kapptemplate/kpartapp/lo16-app-app.png new file mode 100644 index 00000000..c495e509 --- /dev/null +++ b/kapptemplate/kpartapp/lo16-app-app.png @@ -0,0 +1,2 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/lo16-app-$APP_NAME_LC.png..."; +cp $SHARE_DIR/kapp/no-exe/lo16-app-app.png $LOCATION_ROOT/$APP_NAME_LC/lo16-app-$APP_NAME_LC.png diff --git a/kapptemplate/kpartapp/lo32-app-app.png b/kapptemplate/kpartapp/lo32-app-app.png new file mode 100644 index 00000000..6faac157 --- /dev/null +++ b/kapptemplate/kpartapp/lo32-app-app.png @@ -0,0 +1,2 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/lo32-app-$APP_NAME_LC.png..."; +cp $SHARE_DIR/kapp/no-exe/lo32-app-app.png $LOCATION_ROOT/$APP_NAME_LC/lo32-app-$APP_NAME_LC.png diff --git a/kapptemplate/kpartapp/main.cpp b/kapptemplate/kpartapp/main.cpp new file mode 100644 index 00000000..14bbf216 --- /dev/null +++ b/kapptemplate/kpartapp/main.cpp @@ -0,0 +1,55 @@ +echo "Creating $LOCATION_ROOT/${APP_NAME_LC}/main.cpp..."; +cat << EOF > $LOCATION_ROOT/${APP_NAME_LC}/main.cpp +#include "${APP_NAME_LC}.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[] = "v${APP_VERSION}"; + +static KCmdLineOptions options[] = +{ + { "+[URL]", I18N_NOOP( "Document to open" ), 0 }, + KCmdLineLastOption +}; + +int main(int argc, char **argv) +{ + KAboutData about("${APP_NAME_LC}", I18N_NOOP("${APP_NAME}"), version, description, KAboutData::License_GPL, "(C) 2004 ${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(${APP_NAME}) + else + { + // no session.. just start up normally + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + if ( args->count() == 0 ) + { + ${APP_NAME} *widget = new ${APP_NAME}; + widget->show(); + } + else + { + int i = 0; + for (; i < args->count(); i++ ) + { + ${APP_NAME} *widget = new ${APP_NAME}; + widget->show(); + widget->load( args->url( i ) ); + } + } + args->clear(); + } + + return app.exec(); +} diff --git a/kapptemplate/kpartapp/no-exe/Makefile.am b/kapptemplate/kpartapp/no-exe/Makefile.am new file mode 100644 index 00000000..7e993c96 --- /dev/null +++ b/kapptemplate/kpartapp/no-exe/Makefile.am @@ -0,0 +1,3 @@ +kpartappdir = $(kde_datadir)/kapptemplate/kpartapp/no-exe +kpartapp_DATA = hi32-app-app.png lo16-app-app.png hi16-app-app.png \ + hi48-app-app.png lo32-app-app.png diff --git a/kapptemplate/kpartapp/no-exe/hi16-app-app.png b/kapptemplate/kpartapp/no-exe/hi16-app-app.png Binary files differnew file mode 100644 index 00000000..43eab761 --- /dev/null +++ b/kapptemplate/kpartapp/no-exe/hi16-app-app.png diff --git a/kapptemplate/kpartapp/no-exe/hi32-app-app.png b/kapptemplate/kpartapp/no-exe/hi32-app-app.png Binary files differnew file mode 100644 index 00000000..ce9df987 --- /dev/null +++ b/kapptemplate/kpartapp/no-exe/hi32-app-app.png diff --git a/kapptemplate/kpartapp/no-exe/hi48-app-app.png b/kapptemplate/kpartapp/no-exe/hi48-app-app.png Binary files differnew file mode 100644 index 00000000..6464fb39 --- /dev/null +++ b/kapptemplate/kpartapp/no-exe/hi48-app-app.png diff --git a/kapptemplate/kpartapp/no-exe/lo16-app-app.png b/kapptemplate/kpartapp/no-exe/lo16-app-app.png Binary files differnew file mode 100644 index 00000000..e21db293 --- /dev/null +++ b/kapptemplate/kpartapp/no-exe/lo16-app-app.png diff --git a/kapptemplate/kpartapp/no-exe/lo32-app-app.png b/kapptemplate/kpartapp/no-exe/lo32-app-app.png Binary files differnew file mode 100644 index 00000000..4ecd9ce3 --- /dev/null +++ b/kapptemplate/kpartapp/no-exe/lo32-app-app.png diff --git a/kapptemplate/kpartplugin.module b/kapptemplate/kpartplugin.module new file mode 100644 index 00000000..86d20120 --- /dev/null +++ b/kapptemplate/kpartplugin.module @@ -0,0 +1,69 @@ +########################################################################### +# +# STEP 1: GET USER INFORMATION +# +########################################################################### +# Get the application name +APPTYPE="plugin"; +APPDEFAULT="Test"; +GetProperName + +# Get the application version +GetVersion + +# Get the root where this framework will be installed +GetLocationRoot + +# Get the author's name +GetAuthorName + +# Get the author's email +GetAuthorEmail + +# Verify that everything is grand +$ECHO; +$ECHO "Here is what I have:"; +$ECHO "The plugin: $APP_NAME v$APP_VERSION"; +$ECHO "Installed in: $LOCATION_ROOT"; +$ECHO "Author: $AUTHOR <$EMAIL>"; +$ECHO; +$ECHO "Is this correct (Y/n)? "; +$ECHO ": \c"; +read Y_N; +if [ $Y_N -a $Y_N = 'n' ]; +then + $ECHO "AUGH! Well, try again."; + exit 0; +fi +$ECHO; + +$ECHO "OK, Here we go!!"; + +########################################################################### +# +# STEP 2: CREATE APPLICATION FRAMEWORK +# +########################################################################### +CreateAppFramework + +########################################################################### +# +# STEP 3: GENERATE PLUGIN-SPECIFIC FILES +# +########################################################################### +for EXE_FILE in $KPARTPLUGIN_FILES; +do + . $SHARE_DIR/kpartplugin/$EXE_FILE || exit 1; +done + +########################################################################### +# +# STEP 4: FINAL STEPS +# +########################################################################### + +if [ ! $NOINIT ]; then + cd $LOCATION_ROOT && $MAKE -f Makefile.cvs +fi + +$ECHO "DONE!"; diff --git a/kapptemplate/kpartplugin/Makefile.am b/kapptemplate/kpartplugin/Makefile.am new file mode 100644 index 00000000..abbef9fb --- /dev/null +++ b/kapptemplate/kpartplugin/Makefile.am @@ -0,0 +1,5 @@ +SUBDIRS=no-exe + +kpartplugindir = $(kde_datadir)/kapptemplate/kpartplugin +kpartplugin_DATA = plugin-Makefile.am plugin_app.cpp plugin_app.h \ + plugin_app.rc hi16-action-plugin.png hi22-action-plugin.png diff --git a/kapptemplate/kpartplugin/hi16-action-plugin.png b/kapptemplate/kpartplugin/hi16-action-plugin.png new file mode 100644 index 00000000..f40bc9c5 --- /dev/null +++ b/kapptemplate/kpartplugin/hi16-action-plugin.png @@ -0,0 +1,2 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/hi16-action-$APP_NAME_LC.png..."; +cp $SHARE_DIR/kpartplugin/no-exe/hi16-action-plugin.png $LOCATION_ROOT/$APP_NAME_LC/hi16-action-$APP_NAME_LC.png diff --git a/kapptemplate/kpartplugin/hi22-action-plugin.png b/kapptemplate/kpartplugin/hi22-action-plugin.png new file mode 100644 index 00000000..8e1a7616 --- /dev/null +++ b/kapptemplate/kpartplugin/hi22-action-plugin.png @@ -0,0 +1,2 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/hi22-action-$APP_NAME_LC.png..."; +cp $SHARE_DIR/kpartplugin/no-exe/hi22-action-plugin.png $LOCATION_ROOT/$APP_NAME_LC/hi22-action-$APP_NAME_LC.png diff --git a/kapptemplate/kpartplugin/no-exe/Makefile.am b/kapptemplate/kpartplugin/no-exe/Makefile.am new file mode 100644 index 00000000..95586248 --- /dev/null +++ b/kapptemplate/kpartplugin/no-exe/Makefile.am @@ -0,0 +1,2 @@ +kpartplugindir = $(kde_datadir)/kapptemplate/kpartplugin/no-exe +kpartplugin_DATA = hi16-action-plugin.png hi22-action-plugin.png diff --git a/kapptemplate/kpartplugin/no-exe/hi16-action-plugin.png b/kapptemplate/kpartplugin/no-exe/hi16-action-plugin.png Binary files differnew file mode 100644 index 00000000..e2d7bab8 --- /dev/null +++ b/kapptemplate/kpartplugin/no-exe/hi16-action-plugin.png diff --git a/kapptemplate/kpartplugin/no-exe/hi22-action-plugin.png b/kapptemplate/kpartplugin/no-exe/hi22-action-plugin.png Binary files differnew file mode 100644 index 00000000..4082bf10 --- /dev/null +++ b/kapptemplate/kpartplugin/no-exe/hi22-action-plugin.png diff --git a/kapptemplate/kpartplugin/plugin-Makefile.am b/kapptemplate/kpartplugin/plugin-Makefile.am new file mode 100644 index 00000000..cdb7d510 --- /dev/null +++ b/kapptemplate/kpartplugin/plugin-Makefile.am @@ -0,0 +1,20 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/Makefile.am..."; +cat << EOF > $LOCATION_ROOT/$APP_NAME_LC/Makefile.am +INCLUDES = \$(all_includes) +METASOURCES = AUTO + +KDE_ICON = ${APP_NAME_LC} + +# Install this plugin in the KDE modules directory +kde_module_LTLIBRARIES = lib${APP_NAME_LC}plugin.la + +# This is all standard. Remove the LIB_KHTML reference if you are not +# using the KHTML Part +lib${APP_NAME_LC}plugin_la_SOURCES = plugin_${APP_NAME_LC}.cpp +lib${APP_NAME_LC}plugin_la_LIBADD = \$(LIB_KPARTS) \$(LIB_KHTML) +lib${APP_NAME_LC}plugin_la_LDFLAGS = -module \$(KDE_PLUGIN) \$(all_libraries) + +# Install the .rc file in the Part's directory (in this case, the part +# is KHTMLPart) +pluginsdir = \$(kde_datadir)/khtml/kpartplugins +plugins_DATA = plugin_${APP_NAME_LC}.rc diff --git a/kapptemplate/kpartplugin/plugin_app.cpp b/kapptemplate/kpartplugin/plugin_app.cpp new file mode 100644 index 00000000..71c68bc7 --- /dev/null +++ b/kapptemplate/kpartplugin/plugin_app.cpp @@ -0,0 +1,81 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/plugin_${APP_NAME_LC}.cpp..."; +cat << EOF > $LOCATION_ROOT/$APP_NAME_LC/plugin_${APP_NAME_LC}.cpp +#include "plugin_${APP_NAME_LC}.h" + +#include <khtml_part.h> +#include <kaction.h> +#include <kinstance.h> +#include <kmessagebox.h> +#include <klocale.h> +#include <kgenericfactory.h> + +typedef KGenericFactory<Plugin${APP_NAME}> ${APP_NAME}Factory; +K_EXPORT_COMPONENT_FACTORY( lib${APP_NAME_LC}plugin, + ${APP_NAME}Factory( "${APP_NAME_LC}" ) ); + +Plugin${APP_NAME}::Plugin${APP_NAME}( QObject* parent, const char* name, + const QStringList & /*args*/ ) + : Plugin( parent, name ) +{ + // Instantiate all of your actions here. These will appear in + // Konqueror's menu and toolbars. + (void) new KAction( i18n("&Plugin Action"), "${APP_NAME_LC}", 0, + this, SLOT(slotAction()), + actionCollection(), "plugin_action" ); +} + +Plugin${APP_NAME}::~Plugin${APP_NAME}() +{ +} + +void Plugin${APP_NAME}::slotAction() +{ + // This plugin assumes KHTMLPart. If your plugin can handle more + // than this or a different Part than this, simply delete or + // change the following block. + if ( !parent()->inherits("KHTMLPart") ) + { + QString title( i18n( "Cannot Translate Source" ) ); + QString text( i18n( "You cannot translate anything except web pages " + "with this plugin." ) ); + + KMessageBox::sorry( 0, text, title ); + return; + } + + // Get a handle on our parent so we may get the necessary data for + // processing + KHTMLPart *part = dynamic_cast<KHTMLPart *>(parent()); + + // This plugin only uses the URL. You may use whatever data you + // need. + KURL url( part->url() ); + + // This is a standard check to make sure we are dealing with a + // valid URL + if ( !url.isValid() ) + { + QString title( i18n( "Malformed URL" ) ); + QString text( i18n( "The URL you entered is not valid, please " + "correct it and try again." ) ); + + KMessageBox::sorry( 0, text, title ); + return; + } + +// The following block is very plugin specific. In this example, we +// translate the current page with AltaVista's BabelFish. You will +// definitely want to change this. +// BEGIN + KURL work( "http://babel.altavista.com/translate.dyn" ); + + QString query( "urltext=" ); + query += KURL::encode_string( url.url() ); + work.setQuery( query ); +// END + + // Finally, execute the request + part->openURL( work ); +} + +#include <plugin_${APP_NAME_LC}.moc> diff --git a/kapptemplate/kpartplugin/plugin_app.h b/kapptemplate/kpartplugin/plugin_app.h new file mode 100644 index 00000000..3e651499 --- /dev/null +++ b/kapptemplate/kpartplugin/plugin_app.h @@ -0,0 +1,20 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/plugin_${APP_NAME_LC}.h..."; +cat << EOF > $LOCATION_ROOT/$APP_NAME_LC/plugin_${APP_NAME_LC}.h +#ifndef PLUGIN_${APP_NAME_UC}_H +#define PLUGIN_${APP_NAME_UC}_H + +#include <kparts/plugin.h> + +class Plugin${APP_NAME} : public KParts::Plugin +{ + Q_OBJECT +public: + Plugin${APP_NAME}( QObject* parent = 0, const char* name = 0, + const QStringList &args = QStringList() ); + virtual ~Plugin${APP_NAME}(); + +public slots: + void slotAction(); +}; + +#endif // PLUGIN_${APP_NAME_UC}_H diff --git a/kapptemplate/kpartplugin/plugin_app.rc b/kapptemplate/kpartplugin/plugin_app.rc new file mode 100644 index 00000000..9d42f3b6 --- /dev/null +++ b/kapptemplate/kpartplugin/plugin_app.rc @@ -0,0 +1,13 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/plugin_${APP_NAME_LC}.rc..."; +cat << EOF > $LOCATION_ROOT/$APP_NAME_LC/plugin_${APP_NAME_LC}.rc +<!DOCTYPE kpartgui> +<kpartplugin name="${APP_NAME_LC}" library="lib${APP_NAME_LC}plugin" version="1"> +<MenuBar> + <Menu name="tools"><Text>&Tools</Text> + <Action name="plugin_action"/> + </Menu> +</MenuBar> +<ToolBar name="extraToolBar"> + <Action name="plugin_action"/> +</ToolBar> +</kpartplugin> diff --git a/kapptemplate/mkinstalldirs b/kapptemplate/mkinstalldirs new file mode 100755 index 00000000..6b3b5fc5 --- /dev/null +++ b/kapptemplate/mkinstalldirs @@ -0,0 +1,40 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman <friedman@prep.ai.mit.edu> +# Created: 1993-05-16 +# Public domain + +# $Id$ + +errstatus=0 + +for file +do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d + do + pathcomp="$pathcomp$d" + case "$pathcomp" in + -* ) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + fi + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# mkinstalldirs ends here |