diff --git a/kmymoney/wizards/newuserwizard/kaccountpage.cpp b/kmymoney/wizards/newuserwizard/kaccountpage.cpp index f5091ef12..8a2e31a04 100644 --- a/kmymoney/wizards/newuserwizard/kaccountpage.cpp +++ b/kmymoney/wizards/newuserwizard/kaccountpage.cpp @@ -1,76 +1,81 @@ /*************************************************************************** kaccountpage.cpp ------------------- begin : Sat Feb 18 2006 copyright : (C) 2006 Thomas Baumgart email : Thomas Baumgart (C) 2017 by Łukasz Wojniłowicz ***************************************************************************/ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #include "kaccountpage.h" #include "kaccountpage_p.h" // ---------------------------------------------------------------------------- // QT Includes #include #include // ---------------------------------------------------------------------------- // KDE Includes #include // ---------------------------------------------------------------------------- // Project Includes #include "ui_kaccountpage.h" #include "kmymoneydateinput.h" #include "knewuserwizard.h" #include "knewuserwizard_p.h" #include "kcategoriespage.h" #include "wizardpage.h" #include "kguiutils.h" namespace NewUserWizard { AccountPage::AccountPage(Wizard* wizard) : QWidget(wizard), WizardPage(*new AccountPagePrivate(wizard), stepCount, this, wizard) // don't inc. the step count here { Q_D(AccountPage); d->ui->setupUi(this); d->m_mandatoryGroup->add(d->ui->m_accountNameEdit); connect(d->m_mandatoryGroup, static_cast(&KMandatoryFieldGroup::stateChanged), object(), &KMyMoneyWizardPagePrivate::completeStateChanged); connect(d->ui->m_haveCheckingAccountButton, &QAbstractButton::toggled, object(), &KMyMoneyWizardPagePrivate::completeStateChanged); - d->ui->m_accountNameEdit->setFocus(); d->ui->m_openingDateEdit->setDate(QDate(QDate::currentDate().year(), 1, 1)); } AccountPage::~AccountPage() { } + void AccountPage::enterPage() + { + Q_D(AccountPage); + d->ui->m_accountNameEdit->setFocus(); + } + KMyMoneyWizardPage* AccountPage::nextPage() const { Q_D(const AccountPage); return d->m_wizard->d_func()->m_categoriesPage; } bool AccountPage::isComplete() const { Q_D(const AccountPage); return !d->ui->m_haveCheckingAccountButton->isChecked() || d->m_mandatoryGroup->isEnabled(); } } diff --git a/kmymoney/wizards/newuserwizard/kaccountpage.h b/kmymoney/wizards/newuserwizard/kaccountpage.h index 8111bb025..2964e91bc 100644 --- a/kmymoney/wizards/newuserwizard/kaccountpage.h +++ b/kmymoney/wizards/newuserwizard/kaccountpage.h @@ -1,61 +1,63 @@ /*************************************************************************** kaccountpage.h ------------------- begin : Sat Feb 18 2006 copyright : (C) 2006 Thomas Baumgart email : Thomas Baumgart ***************************************************************************/ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef KACCOUNTPAGE_H #define KACCOUNTPAGE_H // ---------------------------------------------------------------------------- // QT Includes #include // ---------------------------------------------------------------------------- // Project Includes #include "wizardpage.h" class KMyMoneyWizardPage; namespace NewUserWizard { class Wizard; /** * Wizard page collecting information about the checking account */ class AccountPagePrivate; class AccountPage : public QWidget, public WizardPage { Q_OBJECT Q_DISABLE_COPY(AccountPage) public: explicit AccountPage(Wizard* parent); ~AccountPage() override; KMyMoneyWizardPage* nextPage() const override; bool isComplete() const override; + void enterPage() override; + private: Q_DECLARE_PRIVATE_D(WizardPage::d_ptr, AccountPage) friend class Wizard; friend class CurrencyPage; }; } // namespace #endif diff --git a/kmymoney/wizards/newuserwizard/kgeneralpage.cpp b/kmymoney/wizards/newuserwizard/kgeneralpage.cpp index 6a5d06d00..46c251dc6 100644 --- a/kmymoney/wizards/newuserwizard/kgeneralpage.cpp +++ b/kmymoney/wizards/newuserwizard/kgeneralpage.cpp @@ -1,114 +1,120 @@ /*************************************************************************** kgeneralpage.cpp ------------------- begin : Sat Feb 18 2006 copyright : (C) 2006 Thomas Baumgart email : Thomas Baumgart (C) 2017 by Łukasz Wojniłowicz ***************************************************************************/ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #include "kgeneralpage.h" // ---------------------------------------------------------------------------- // QT Includes #include // ---------------------------------------------------------------------------- // KDE Includes #include #include #include // ---------------------------------------------------------------------------- // Project Includes #include "userinfo.h" #include "ui_userinfo.h" #include "knewuserwizard.h" #include "knewuserwizard_p.h" #include "mymoneycontact.h" #include "kcurrencypage.h" class KMyMoneyWizardPage; namespace NewUserWizard { class GeneralPagePrivate : public WizardPagePrivate { Q_DISABLE_COPY(GeneralPagePrivate) public: GeneralPagePrivate(QObject* parent) : WizardPagePrivate(parent), m_contact(nullptr) { } MyMoneyContact *m_contact; }; GeneralPage::GeneralPage(Wizard* wizard) : UserInfo(wizard), WizardPage(*new GeneralPagePrivate(wizard), stepCount++, this, wizard) { Q_D(GeneralPage); d->m_contact = new MyMoneyContact(this); - ui->m_userNameEdit->setFocus(); ui->m_loadAddressButton->setEnabled(d->m_contact->ownerExists()); connect(ui->m_loadAddressButton, &QAbstractButton::clicked, this, &GeneralPage::slotLoadFromAddressBook); } GeneralPage::~GeneralPage() { } + void GeneralPage::enterPage() + { + Q_D(GeneralPage); + ui->m_userNameEdit->setFocus(); + } + + void GeneralPage::slotLoadFromAddressBook() { Q_D(GeneralPage); ui->m_userNameEdit->setText(d->m_contact->ownerFullName()); ui->m_emailEdit->setText(d->m_contact->ownerEmail()); if (ui->m_emailEdit->text().isEmpty()) { KMessageBox::sorry(this, i18n("Unable to load data, because no contact has been associated with the owner of the standard address book."), i18n("Address book import")); return; } ui->m_loadAddressButton->setEnabled(false); connect(d->m_contact, &MyMoneyContact::contactFetched, this, &GeneralPage::slotContactFetched); d->m_contact->fetchContact(ui->m_emailEdit->text()); } void GeneralPage::slotContactFetched(const ContactData &identity) { ui->m_loadAddressButton->setEnabled(true); if (identity.email.isEmpty()) return; ui->m_telephoneEdit->setText(identity.phoneNumber); QString sep; if (!identity.country.isEmpty() && !identity.region.isEmpty()) sep = " / "; ui->m_countyEdit->setText(QString("%1%2%3").arg(identity.country, sep, identity.region)); ui->m_postcodeEdit->setText(identity.postalCode); ui->m_townEdit->setText(identity.locality); ui->m_streetEdit->setText(identity.street); } KMyMoneyWizardPage* GeneralPage::nextPage() const { Q_D(const GeneralPage); return d->m_wizard->d_func()->m_currencyPage; } } diff --git a/kmymoney/wizards/newuserwizard/kgeneralpage.h b/kmymoney/wizards/newuserwizard/kgeneralpage.h index dd1dfc6e6..5c080997e 100644 --- a/kmymoney/wizards/newuserwizard/kgeneralpage.h +++ b/kmymoney/wizards/newuserwizard/kgeneralpage.h @@ -1,63 +1,65 @@ /*************************************************************************** kgeneralpage.h ------------------- begin : Sat Feb 18 2006 copyright : (C) 2006 Thomas Baumgart email : Thomas Baumgart ***************************************************************************/ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef KGENERALPAGE_H #define KGENERALPAGE_H // ---------------------------------------------------------------------------- // QT Includes // ---------------------------------------------------------------------------- // Project Includes #include "wizardpage.h" #include "userinfo.h" class KMyMoneyWizardPage; struct ContactData; namespace NewUserWizard { class Wizard; /** * Wizard page collecting information about the user * * @author Thomas Baumgart */ class GeneralPagePrivate; class GeneralPage : public UserInfo, public WizardPage { Q_OBJECT Q_DISABLE_COPY(GeneralPage) public: explicit GeneralPage(Wizard* parent); ~GeneralPage() override; KMyMoneyWizardPage* nextPage() const override; + void enterPage() override; + protected Q_SLOTS: void slotLoadFromAddressBook(); void slotContactFetched(const ContactData &identity); private: Q_DECLARE_PRIVATE_D(WizardPage::d_ptr, GeneralPage) friend class Wizard; }; } // namespace #endif