Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Tous les espaces de nom  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

licensewizard.cpp Example File
dialogs/licensewizard/licensewizard.cpp

 /****************************************************************************
 **
 ** Copyright (C) 2007-2008 Trolltech ASA. All rights reserved.
 **
 ** This file is part of the documentation of the Qt Toolkit.
 **
 ** This file may be used under the terms of the GNU General Public
** License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file.  Alternatively you may (at
** your option) use any later version of the GNU General Public
** License if such license has been publicly approved by Trolltech ASA
** (or its successors, if any) and the KDE Free Qt Foundation. In
** addition, as a special exception, Trolltech gives you certain
** additional rights. These rights are described in the Trolltech GPL
** Exception version 1.2, which can be found at
** http://www.trolltech.com/products/qt/gplexception/ and in the file
** GPL_EXCEPTION.txt in this package.
**
** Please review the following information to ensure GNU General
** Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/. If
** you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at sales@trolltech.com.
**
** In addition, as a special exception, Trolltech, as the sole
** copyright holder for Qt Designer, grants users of the Qt/Eclipse
** Integration plug-in the right for the Qt/Eclipse Integration to
** link to functionality provided by Qt Designer and its related
** libraries.
**
** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE. Trolltech reserves all rights not expressly
** granted herein.
 **
 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 **
 ****************************************************************************/

 #include <QtGui>

 #include "licensewizard.h"

 LicenseWizard::LicenseWizard(QWidget *parent)
     : QWizard(parent)
 {
     setPage(Page_Intro, new IntroPage);
     setPage(Page_Evaluate, new EvaluatePage);
     setPage(Page_Register, new RegisterPage);
     setPage(Page_Details, new DetailsPage);
     setPage(Page_Conclusion, new ConclusionPage);

     setStartId(Page_Intro);

 #ifndef Q_WS_MAC
     setWizardStyle(ModernStyle);
 #endif
     setOption(HaveHelpButton, true);
     setPixmap(QWizard::LogoPixmap, QPixmap(":/images/logo.png"));

     connect(this, SIGNAL(helpRequested()), this, SLOT(showHelp()));

     setWindowTitle(tr("License Wizard"));
 }

 void LicenseWizard::showHelp()
 {
     static QString lastHelpMessage;

     QString message;

     switch (currentId()) {
     case Page_Intro:
         message = tr("The decision you make here will affect which page you "
                      "get to see next.");
         break;
     case Page_Evaluate:
         message = tr("Make sure to provide a valid email address, such as "
                      "toni.buddenbrook@example.de.");
         break;
     case Page_Register:
         message = tr("If you don't provide an upgrade key, you will be "
                      "asked to fill in your details.");
         break;
     case Page_Details:
         message = tr("Make sure to provide a valid email address, such as "
                      "thomas.gradgrind@example.co.uk.");
         break;
     case Page_Conclusion:
         message = tr("You must accept the terms and conditions of the "
                      "license to proceed.");
         break;
     default:
         message = tr("This help is likely not to be of any help.");
     }

     if (lastHelpMessage == message)
         message = tr("Sorry, I already gave what help I could. "
                      "Maybe you should try asking a human?");

     QMessageBox::information(this, tr("License Wizard Help"), message);

     lastHelpMessage = message;
 }

 IntroPage::IntroPage(QWidget *parent)
     : QWizardPage(parent)
 {
     setTitle(tr("Introduction"));
     setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark.png"));

     topLabel = new QLabel(tr("This wizard will help you register your copy of "
                              "<i>Super Product One</i>&trade; or start "
                              "evaluating the product."));
     topLabel->setWordWrap(true);

     registerRadioButton = new QRadioButton(tr("&Register your copy"));
     evaluateRadioButton = new QRadioButton(tr("&Evaluate the product for 30 "
                                               "days"));
     registerRadioButton->setChecked(true);

     QVBoxLayout *layout = new QVBoxLayout;
     layout->addWidget(topLabel);
     layout->addWidget(registerRadioButton);
     layout->addWidget(evaluateRadioButton);
     setLayout(layout);
 }

 int IntroPage::nextId() const
 {
     if (evaluateRadioButton->isChecked()) {
         return LicenseWizard::Page_Evaluate;
     } else {
         return LicenseWizard::Page_Register;
     }
 }

 EvaluatePage::EvaluatePage(QWidget *parent)
     : QWizardPage(parent)
 {
     setTitle(tr("Evaluate <i>Super Product One</i>&trade;"));
     setSubTitle(tr("Please fill both fields. Make sure to provide a valid "
                    "email address (e.g., john.smith@example.com)."));

     nameLabel = new QLabel(tr("N&ame:"));
     nameLineEdit = new QLineEdit;
     nameLabel->setBuddy(nameLineEdit);

     emailLabel = new QLabel(tr("&Email address:"));
     emailLineEdit = new QLineEdit;
     emailLineEdit->setValidator(new QRegExpValidator(QRegExp(".*@.*"), this));
     emailLabel->setBuddy(emailLineEdit);

     registerField("evaluate.name*", nameLineEdit);
     registerField("evaluate.email*", emailLineEdit);

     QGridLayout *layout = new QGridLayout;
     layout->addWidget(nameLabel, 0, 0);
     layout->addWidget(nameLineEdit, 0, 1);
     layout->addWidget(emailLabel, 1, 0);
     layout->addWidget(emailLineEdit, 1, 1);
     setLayout(layout);
 }

 int EvaluatePage::nextId() const
 {
     return LicenseWizard::Page_Conclusion;
 }

 RegisterPage::RegisterPage(QWidget *parent)
     : QWizardPage(parent)
 {
     setTitle(tr("Register Your Copy of <i>Super Product One</i>&trade;"));
     setSubTitle(tr("If you have an upgrade key, please fill in "
                    "the appropriate field."));

     nameLabel = new QLabel(tr("N&ame:"));
     nameLineEdit = new QLineEdit;
     nameLabel->setBuddy(nameLineEdit);

     upgradeKeyLabel = new QLabel(tr("&Upgrade key:"));
     upgradeKeyLineEdit = new QLineEdit;
     upgradeKeyLabel->setBuddy(upgradeKeyLineEdit);

     registerField("register.name*", nameLineEdit);
     registerField("register.upgradeKey", upgradeKeyLineEdit);

     QGridLayout *layout = new QGridLayout;
     layout->addWidget(nameLabel, 0, 0);
     layout->addWidget(nameLineEdit, 0, 1);
     layout->addWidget(upgradeKeyLabel, 1, 0);
     layout->addWidget(upgradeKeyLineEdit, 1, 1);
     setLayout(layout);
 }

 int RegisterPage::nextId() const
 {
     if (upgradeKeyLineEdit->text().isEmpty()) {
         return LicenseWizard::Page_Details;
     } else {
         return LicenseWizard::Page_Conclusion;
     }
 }

 DetailsPage::DetailsPage(QWidget *parent)
     : QWizardPage(parent)
 {
     setTitle(tr("Fill In Your Details"));
     setSubTitle(tr("Please fill all three fields. Make sure to provide a valid "
                    "email address (e.g., tanaka.aya@example.co.jp)."));

     companyLabel = new QLabel(tr("&Company name:"));
     companyLineEdit = new QLineEdit;
     companyLabel->setBuddy(companyLineEdit);

     emailLabel = new QLabel(tr("&Email address:"));
     emailLineEdit = new QLineEdit;
     emailLineEdit->setValidator(new QRegExpValidator(QRegExp(".*@.*"), this));
     emailLabel->setBuddy(emailLineEdit);

     postalLabel = new QLabel(tr("&Postal address:"));
     postalLineEdit = new QLineEdit;
     postalLabel->setBuddy(postalLineEdit);

     registerField("details.company*", companyLineEdit);
     registerField("details.email*", emailLineEdit);
     registerField("details.postal*", postalLineEdit);

     QGridLayout *layout = new QGridLayout;
     layout->addWidget(companyLabel, 0, 0);
     layout->addWidget(companyLineEdit, 0, 1);
     layout->addWidget(emailLabel, 1, 0);
     layout->addWidget(emailLineEdit, 1, 1);
     layout->addWidget(postalLabel, 2, 0);
     layout->addWidget(postalLineEdit, 2, 1);
     setLayout(layout);
 }

 int DetailsPage::nextId() const
 {
     return LicenseWizard::Page_Conclusion;
 }

 ConclusionPage::ConclusionPage(QWidget *parent)
     : QWizardPage(parent)
 {
     setTitle(tr("Complete Your Registration"));
     setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark.png"));

     bottomLabel = new QLabel;
     bottomLabel->setWordWrap(true);

     agreeCheckBox = new QCheckBox(tr("I agree to the terms of the license"));

     registerField("conclusion.agree*", agreeCheckBox);

     QVBoxLayout *layout = new QVBoxLayout;
     layout->addWidget(bottomLabel);
     layout->addWidget(agreeCheckBox);
     setLayout(layout);
 }

 int ConclusionPage::nextId() const
 {
     return -1;
 }

 void ConclusionPage::initializePage()
 {
     QString licenseText;

     if (wizard()->hasVisitedPage(LicenseWizard::Page_Evaluate)) {
         licenseText = tr("<u>Evaluation License Agreement:</u> "
                          "You can use this software for 30 days and make one "
                          "backup, but you are not allowed to distribute it.");
     } else if (wizard()->hasVisitedPage(LicenseWizard::Page_Details)) {
         licenseText = tr("<u>First-Time License Agreement:</u> "
                          "You can use this software subject to the license "
                          "you will receive by email.");
     } else {
         licenseText = tr("<u>Upgrade License Agreement:</u> "
                          "This software is licensed under the terms of your "
                          "current license.");
     }
     bottomLabel->setText(licenseText);
 }

 void ConclusionPage::setVisible(bool visible)
 {
     QWizardPage::setVisible(visible);

     if (visible) {
         wizard()->setButtonText(QWizard::CustomButton1, tr("&Print"));
         wizard()->setOption(QWizard::HaveCustomButton1, true);
         connect(wizard(), SIGNAL(customButtonClicked(int)),
                 this, SLOT(printButtonClicked()));
     } else {
         wizard()->setOption(QWizard::HaveCustomButton1, false);
         disconnect(wizard(), SIGNAL(customButtonClicked(int)),
                    this, SLOT(printButtonClicked()));
     }
 }

 void ConclusionPage::printButtonClicked()
 {
     QPrinter printer;
     QPrintDialog dialog(&printer, this);
     if (dialog.exec())
         QMessageBox::warning(this, tr("Print License"),
                              tr("As an environmentally friendly measure, the "
                                 "license text will not actually be printed."));
 }

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. Microsoft ouvre aux autres compilateurs C++ AMP, la spécification pour la conception d'applications parallèles C++ utilisant le GPU 22
  2. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  3. RIM : « 13 % des développeurs ont gagné plus de 100 000 $ sur l'AppWord », Qt et open-source au menu du BlackBerry DevCon Europe 0
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
Page suivante

Le Qt Labs au hasard

Logo

La folie est de mettre en forme le même texte

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.3
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web