summaryrefslogtreecommitdiffstats
path: root/languages/cpp/app_templates/kde4app/kapp4.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch)
treeacaf47eb0fa12142d3896416a69e74cbf5a72242 /languages/cpp/app_templates/kde4app/kapp4.cpp
downloadtdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz
tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'languages/cpp/app_templates/kde4app/kapp4.cpp')
-rw-r--r--languages/cpp/app_templates/kde4app/kapp4.cpp90
1 files changed, 90 insertions, 0 deletions
diff --git a/languages/cpp/app_templates/kde4app/kapp4.cpp b/languages/cpp/app_templates/kde4app/kapp4.cpp
new file mode 100644
index 00000000..c11a58d1
--- /dev/null
+++ b/languages/cpp/app_templates/kde4app/kapp4.cpp
@@ -0,0 +1,90 @@
+%{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"