• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

kapptemplate

  • sources
  • kde-4.14
  • kdesdk
  • kapptemplate
kapptemplate.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright 2008 by Anne-Marie Mahfouf <annma@kde.org> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License *
15  * along with this program; if not, write to the *
16  * Free Software Foundation, Inc., *
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
18  ***************************************************************************/
19 
20 #include <QPixmap>
21 #include <QRegExpValidator>
22 
23 #include <kapplication.h>
24 #include <KLocale>
25 #include <KDebug>
26 #include <ktoolinvocation.h>
27 
28 #include "choicepage.h"
29 #include "generatepage.h"
30 #include "kapptemplate.h"
31 #include "prefs.h"
32 
33 
34 KAppTemplate::KAppTemplate( QWidget *parent )
35  : QWizard()
36 {
37  Q_UNUSED(parent);
38  setWindowTitle(i18n("KDE 4 Template Generator"));
39  setOption(HaveHelpButton, true);
40  connect(this, SIGNAL(helpRequested()), this, SLOT(showHelp()));
41  addPage(new IntroPage);
42  addPage(new ChoicePage);
43  addPage(new PropertiesPage);
44  addPage(new GeneratePage);
45 }
46 
47 KAppTemplate::~KAppTemplate()
48 {
49 }
50 
51 void KAppTemplate::showHelp()
52 {
53  KToolInvocation::invokeHelp( "kapptemplate-index", "kapptemplate" );
54 }
55 
56 
57 IntroPage::IntroPage(QWidget *parent)
58  : QWizardPage(parent)
59 {
60  setTitle(i18n("Introduction"));
61  ui_introduction.setupUi(this);
62 }
63 
64 PropertiesPage::PropertiesPage(QWidget *parent) //in its own file?
65  : QWizardPage(parent)
66 {
67  setTitle(i18n("Set the project properties"));
68  ui_properties.setupUi(this);
69  //float version = Prefs::appVersion().toFloat();
70  ui_properties.kcfg_appVersion->setText(Prefs::appVersion());//TODO appVersion+0.1 if already exists
71  ui_properties.kcfg_url->setMode(KFile::Directory);
72  ui_properties.kcfg_url->setUrl(Prefs::url());
73  ui_properties.kcfg_name->setText(Prefs::name());
74  ui_properties.kcfg_email->setText(Prefs::email());
75 
76  registerField("author", ui_properties.kcfg_name);
77  registerField("email", ui_properties.kcfg_email);
78  registerField("version", ui_properties.kcfg_appVersion);
79  registerField("url", ui_properties.kcfg_url->lineEdit());
80 
81  //get from emaildefaults [PROFILE_Default]
82  connect(ui_properties.kcfg_appVersion, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
83  connect(ui_properties.kcfg_url, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
84  connect(ui_properties.kcfg_name, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
85  connect(ui_properties.kcfg_email, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
86  connect(this, SIGNAL(completeChanged()), this, SLOT(saveConfig()));
87  // TODO make some fields mandatory?
88 }
89 
90 void PropertiesPage::initializePage()
91 {
92  appNameString = field("appName").toString();
93  QString message = i18n("Your project name is : %1", appNameString);
94  ui_properties.appNameLabel->setText(message);
95 }
96 
97 void PropertiesPage::saveConfig()
98 {
99  Prefs::setAppVersion(ui_properties.kcfg_appVersion->text());
100  Prefs::setUrl(ui_properties.kcfg_url->url().path());
101  Prefs::setName(ui_properties.kcfg_name->text());
102  Prefs::setEmail(ui_properties.kcfg_email->text());
103  Prefs::setAppName(appNameString);
104  Prefs::self()->writeConfig();
105 }
106 
107 
108 
109 
110 
111 
112 
113 
PropertiesPage::PropertiesPage
PropertiesPage(QWidget *parent=0)
Definition: kapptemplate.cpp:64
IntroPage::IntroPage
IntroPage(QWidget *parent=0)
Definition: kapptemplate.cpp:57
QWidget
QWizard::helpRequested
void helpRequested()
KAppTemplate::KAppTemplate
KAppTemplate(QWidget *parent)
Default Constructor.
Definition: kapptemplate.cpp:34
QWizard::addPage
int addPage(QWizardPage *page)
QWizardPage::registerField
void registerField(const QString &name, QWidget *widget, const char *property, const char *changedSignal)
IntroPage
Definition: kapptemplate.h:59
PropertiesPage::completeChanged
void completeChanged()
Emitted when the text in any field changes.
prefs.h
Prefs::appVersion
static QString appVersion()
Get Project version.
Definition: prefs.h:51
GeneratePage
Definition: generatepage.h:34
kapptemplate.h
Prefs::name
static QString name()
Get Name of the user.
Definition: prefs.h:89
Prefs::self
static Prefs * self()
Definition: prefs.cpp:17
Prefs::setAppName
static void setAppName(const QString &v)
Set Name of the project.
Definition: prefs.h:22
generatepage.h
Prefs::setAppVersion
static void setAppVersion(const QString &v)
Set Project version.
Definition: prefs.h:41
Prefs::setEmail
static void setEmail(const QString &v)
Set Email of the user.
Definition: prefs.h:98
QWizard::setOption
void setOption(WizardOption option, bool on)
QString
QWizardPage::field
QVariant field(const QString &name) const
Prefs::url
static QString url()
Get Home dir of the user.
Definition: prefs.h:70
KAppTemplate::~KAppTemplate
virtual ~KAppTemplate()
Default Destructor.
Definition: kapptemplate.cpp:47
ChoicePage
Definition: choicepage.h:32
Prefs::setUrl
static void setUrl(const QString &v)
Set Home dir of the user.
Definition: prefs.h:60
QWidget::setWindowTitle
void setWindowTitle(const QString &)
QWizard
PropertiesPage
Definition: kapptemplate.h:69
choicepage.h
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Prefs::email
static QString email()
Get Email of the user.
Definition: prefs.h:108
QVariant::toString
QString toString() const
QWizardPage
QWizardPage::setTitle
void setTitle(const QString &title)
Prefs::setName
static void setName(const QString &v)
Set Name of the user.
Definition: prefs.h:79
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:39:44 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kapptemplate

Skip menu "kapptemplate"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal