Commit 1fef70e8 authored by Andreas Pakulat's avatar Andreas Pakulat

Add a KDE4 application template (based on kapptemplate's simple kde4 app)

parent 6efea5b0
SUBDIRS = kapp kpartapp kpartplugin kcmodule kicker kioslave kdevpart kdevpart2 chello cpphello kscreensaver kofficepart chello_gba dcopservice konqnavpanel qmakesimple qmakeapp qt4makeapp khello khello2 kateplugin kateplugin2 qtopiaapp kdedcop wxhello cppsdlhello kconfig35 kdevlang noatunvisual noatunui kmod kfileplugin clanlib opieapp opieapplet opieinput opiemenu opienet opietoday kxt gtk2mmapp cppcurseshello win32hello win32gui cmakesimple cmakesimplec cmakelibcpp cmakelibc kscons_kxt kscons_kmdi qt4hello qmakeempty automakeempty makefileempty qtopia4app
SUBDIRS = kapp kpartapp kpartplugin kcmodule kicker kioslave kdevpart kdevpart2 chello cpphello kscreensaver kofficepart chello_gba dcopservice konqnavpanel qmakesimple qmakeapp qt4makeapp khello khello2 kateplugin kateplugin2 qtopiaapp kdedcop wxhello cppsdlhello kconfig35 kdevlang noatunvisual noatunui kmod kfileplugin clanlib opieapp opieapplet opieinput opiemenu opienet opietoday kxt gtk2mmapp cppcurseshello win32hello win32gui cmakesimple cmakesimplec cmakelibcpp cmakelibc kscons_kxt kscons_kmdi qt4hello qmakeempty automakeempty makefileempty qtopia4app kde4app
profilescdir = $(kde_datadir)/kdevelop/profiles/IDE/CompiledLanguageIDE/CandCppIDE/CIDE
profilesc_DATA = c.appwizard
......
project(%{APPNAME})
find_package(KDE4 REQUIRED)
include (KDE4Defaults)
include_directories( ${KDE4_INCLUDES} ${QT_INCLUDES} )
set(%{APPNAMELC}_SRCS
%{APPNAMELC}.cpp
main.cpp
%{APPNAMELC}view.cpp
)
#kde4_automoc(${%{APPNAMELC}_SRCS})
kde4_add_ui_files(%{APPNAMELC}_SRCS %{APPNAMELC}view_base.ui prefs_base.ui)
kde4_add_kcfg_files(%{APPNAMELC}_SRCS settings.kcfgc )
kde4_add_executable(%{APPNAMELC} ${%{APPNAMELC}_SRCS})
target_link_libraries(%{APPNAMELC} ${KDE4_KDEUI_LIBS} )
install(TARGETS %{APPNAMELC} DESTINATION ${BIN_INSTALL_DIR} )
########### install files ###############
install( FILES %{APPNAMELC}.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
install( FILES %{APPNAMELC}.kcfg DESTINATION ${KCFG_INSTALL_DIR} )
install( FILES %{APPNAMELC}ui.rc DESTINATION ${DATA_INSTALL_DIR}/%{APPNAMELC} )
dataFiles = kapp4.cpp kapp4.h prefs_base.ui kapp4view.cpp kapp4view.h kapp4view_base.ui \
main.cpp kde4appui.rc CMakeLists.txt kapp4.desktop kapp4.kcfg settings.kcfgc \
kde4app.png README kde4app.kdevelop kde4app.kdevelop.filelist
templateName = kde4app
### no need to change below:
template_DATA = $(templateName).kdevtemplate
templatedir = ${appwizarddatadir}/templates
appwizarddatadir = ${kde_datadir}/kdevappwizard
$(templateName).tar.gz: ${dataFiles}
$(TAR) -cf $(templateName).tar -C $(srcdir) ${dataFiles}
$(GZIP_COMMAND) -f9 $(templateName).tar
archivedir = ${appwizarddatadir}
archive_DATA = $(templateName).tar.gz ${templateName}.png
CLEANFILES = *.tar.gz
!!!!!ATTENTION!!!!!
Before starting the build you may need to setup the KDE4 environment variables.
To do this open Project->Project Options and then look at the "Run" and the "Make"
pages. Each of these two has an environment variables widget in which you have
to fill in the right values for the variables already listed.
After setting up the variables you'll also need to run cmake inside the build
directory. This can not be done by kdevelop as a KDE4 environment is needed
when running cmake to find KDE4. Open the integrated konsole and change to the build
subdirectory. Then setup a KDE4 environment and run "cmake ../".
More information how to setup a KDE4 development environment can be found on
http://techbase.kde.org/Getting_Started/Increased_Productivity_in_KDE4_with_Scripts
%{CPP_TEMPLATE}
#include "%{APPNAMELC}.h"
#include "%{APPNAMELC}view.h"
#include "settings.h"
#include <QtGui/QDropEvent>
#include <QtGui/QPainter>
#include <kconfigdialog.h>
#include <kstatusbar.h>
#include <kaction.h>
#include <kactioncollection.h>
#include <kstandardaction.h>
#include <KDE/KLocale>
%{APPNAME}::%{APPNAME}()
: KXmlGuiWindow(),
m_view(new %{APPNAME}View(this)),
m_printer(0)
{
// accept dnd
setAcceptDrops(true);
// tell the KXmlGuiWindow that this is indeed the main widget
setCentralWidget(m_view);
// then, setup our actions
setupActions();
// add a status bar
statusBar()->show();
// a call to KXmlGuiWindow::setupGUI() populates the GUI
// with actions, using KXMLGUI.
// It also applies the saved mainwindow settings, if any, and ask the
// mainwindow to automatically save settings if changed: window size,
// toolbar position, icon size, etc.
setupGUI();
}
%{APPNAME}::~%{APPNAME}()
{
}
void %{APPNAME}::setupActions()
{
KStandardAction::openNew(this, SLOT(fileNew()), actionCollection());
KStandardAction::quit(qApp, SLOT(quit()), actionCollection());
KStandardAction::preferences(this, SLOT(optionsPreferences()), actionCollection());
// custom menu and menu item - the slot is in the class %{APPNAME}View
KAction *custom = new KAction(KIcon("colorize"), i18n("Swi&tch Colors"), this);
actionCollection()->addAction( QLatin1String("switch_action"), custom );
connect(custom, SIGNAL(triggered(bool)), m_view, SLOT(switchColors()));
}
void %{APPNAME}::fileNew()
{
// this slot is called whenever the File->New menu is selected,
// the New shortcut is pressed (usually CTRL+N) or the New toolbar
// button is clicked
// create a new window
(new %{APPNAME})->show();
}
void %{APPNAME}::optionsPreferences()
{
// The preference dialog is derived from prefs_base.ui
//
// compare the names of the widgets in the .ui file
// to the names of the variables in the .kcfg file
//avoid to have 2 dialogs shown
if ( KConfigDialog::showDialog( "settings" ) ) {
return;
}
KConfigDialog *dialog = new KConfigDialog(this, "settings", Settings::self());
QWidget *generalSettingsDlg = new QWidget;
ui_prefs_base.setupUi(generalSettingsDlg);
dialog->addPage(generalSettingsDlg, i18n("General"), "package_setting");
connect(dialog, SIGNAL(settingsChanged(QString)), m_view, SLOT(settingsChanged()));
dialog->setAttribute( Qt::WA_DeleteOnClose );
dialog->show();
}
#include "%{APPNAMELC}.moc"
[Desktop Entry]
Encoding=UTF-8
Name=KApp4
Exec=kapp4 %i -caption "%c"
Icon=kapp4
Type=Application
DocPath=kapp4/kapp4.html
GenericName=A KDE4 Application
Terminal=0
%{H_TEMPLATE}
#ifndef %{APPNAMEUC}_H
#define %{APPNAMEUC}_H
#include <kxmlguiwindow.h>
#include "ui_prefs_base.h"
class %{APPNAME}View;
class KPrinter;
class KToggleAction;
class KUrl;
/**
* This class serves as the main window for %{APPNAME}. It handles the
* menus, toolbars, and status bars.
*
* @short Main window class
* @author Andreas Pakulat <apaku@gmx.de>
* @version 0.1
*/
class %{APPNAME} : public KXmlGuiWindow
{
Q_OBJECT
public:
/**
* Default Constructor
*/
%{APPNAME}();
/**
* Default Destructor
*/
virtual ~%{APPNAME}();
private slots:
void fileNew();
void optionsPreferences();
private:
void setupActions();
private:
Ui::prefs_base ui_prefs_base ;
%{APPNAME}View *m_view;
KPrinter *m_printer;
KToggleAction *m_toolbarAction;
KToggleAction *m_statusbarAction;
};
#endif // _%{APPNAMELC}_H_
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="KApp4rc"/>
<group name="Preferences">
<entry name="col_background" type="Color">
<label>color of the background</label>
<default>black</default>
</entry>
<entry name="col_foreground" type="Color">
<label>color of the foreground</label>
<default>yellow</default>
</entry>
<entry name="val_time" type="Int">
<label>size of a ball</label>
<default>2</default>
</entry>
</group>
</kcfg>
%{CPP_TEMPLATE}
#include "%{APPNAMELC}view.h"
#include "settings.h"
#include <klocale.h>
#include <QtGui/QLabel>
%{APPNAME}View::%{APPNAME}View(QWidget *)
{
ui_%{APPNAMELC}view_base.setupUi(this);
settingsChanged();
setAutoFillBackground(true);
}
%{APPNAME}View::~%{APPNAME}View()
{
}
void %{APPNAME}View::switchColors()
{
// switch the foreground/background colors of the label
QColor color = Settings::col_background();
Settings::setCol_background( Settings::col_foreground() );
Settings::setCol_foreground( color );
settingsChanged();
}
void %{APPNAME}View::settingsChanged()
{
QPalette pal;
pal.setColor( QPalette::Window, Settings::col_background());
pal.setColor( QPalette::WindowText, Settings::col_foreground());
ui_%{APPNAMELC}view_base.kcfg_sillyLabel->setPalette( pal );
// i18n : internationalization
ui_%{APPNAMELC}view_base.kcfg_sillyLabel->setText( i18n("This project is %1 days old",Settings::val_time()) );
emit signalChangeStatusbar( i18n("Settings changed") );
}
#include "%{APPNAMELC}view.moc"
%{H_TEMPLATE}
#ifndef %{APPNAMELC}VIEW_H
#define %{APPNAMELC}VIEW_H
#include <QtGui/QWidget>
#include "ui_%{APPNAMELC}view_base.h"
class QPainter;
class KUrl;
/**
* This is the main view class for %{APPNAME}. Most of the non-menu,
* non-toolbar, and non-statusbar (e.g., non frame) GUI code should go
* here.
*
* @short Main view
* @author %{AUTHOR} <%{EMAIL}>
* @version %{VERSION}
*/
class %{APPNAME}View : public QWidget, public Ui::%{APPNAMELC}view_base
{
Q_OBJECT
public:
/**
* Default constructor
*/
%{APPNAME}View(QWidget *parent);
/**
* Destructor
*/
virtual ~%{APPNAME}View();
private:
Ui::%{APPNAMELC}view_base ui_%{APPNAMELC}view_base;
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 switchColors();
void settingsChanged();
};
#endif // %{APPNAME}VIEW_H
<ui version="4.0" >
<class>%{APPNAMELC}view_base</class>
<widget class="QWidget" name="%{APPNAMELC}view_base" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>315</width>
<height>233</height>
</rect>
</property>
<property name="windowTitle" >
<string>%{APPNAMELC}_base</string>
</property>
<property name="autoFillBackground" >
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>11</number>
</property>
<property name="topMargin" >
<number>11</number>
</property>
<property name="rightMargin" >
<number>11</number>
</property>
<property name="bottomMargin" >
<number>11</number>
</property>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QLabel" name="kcfg_sillyLabel" >
<property name="palette" >
<palette>
<active>
<colorrole role="WindowText" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>255</red>
<green>255</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>255</red>
<green>255</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>119</red>
<green>119</green>
<blue>119</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="font" >
<font>
<family>Sans Serif</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="autoFillBackground" >
<bool>true</bool>
</property>
<property name="text" >
<string>hello, world</string>
</property>
<property name="scaledContents" >
<bool>true</bool>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<resources/>
<connections/>
</ui>
<?xml version = '1.0'?>
<kdevelop>
<general>
<author>%{AUTHOR}</author>
<email>%{EMAIL}</email>
<version>%{VERSION}</version>
<projectmanagement>KDevCustomProject</projectmanagement>
<primarylanguage>C++</primarylanguage>
<keywords>
<keyword>C++</keyword>
<keyword>Code</keyword>
<keyword>Qt</keyword>
<keyword>KDE</keyword>
</keywords>
<projectname>%{APPNAMELC}</projectname>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<description/>
<ignoreparts/>
</general>
<kdevfileview>
<groups>
<group pattern="*.cpp;*.cxx;*.h" name="Sources" />
<group pattern="*.ui" name="User Interface" />
<group pattern="*.png" name="Icons" />
<group pattern="*.po;*.ts" name="Translations" />
<group pattern="*" name="Others" />
</groups>
<tree>
<hidenonprojectfiles>false</hidenonprojectfiles>
<hidepatterns>*.o,*.lo,CVS</hidepatterns>
</tree>
</kdevfileview>
<kdevdoctreeview>
<ignoretocs>
<toc>ada</toc>
<toc>ada_bugs_gcc</toc>
<toc>bash</toc>
<toc>bash_bugs</toc>
<toc>clanlib</toc>
<toc>w3c-dom-level2-html</toc>
<toc>fortran_bugs_gcc</toc>
<toc>gnome1</toc>
<toc>gnustep</toc>