From: Enar Väikene Date: Wed, 28 Sep 2011 06:23:48 +0000 (+0300) Subject: Updated tutorial to reflect latest iSdiWindow interface changes. X-Git-Url: https://vaikene.ee/gitweb/gitweb.cgi?a=commitdiff_plain;h=d45d3f8d2dad5d8150cd8e60b5126dd2ae7b422a;p=evaf Updated tutorial to reflect latest iSdiWindow interface changes. --- diff --git a/www/pswgen10.html b/www/pswgen10.html index 616e321..bef0c7b 100644 --- a/www/pswgen10.html +++ b/www/pswgen10.html @@ -115,13 +115,17 @@ Module::~ModuleQueries and stores interfaces implemented in other modules. The iGenerator interface must be implemented; the iStorage interface is optional and we can work without it.
  • Gets the main window interface iSdiWindow.
  • -
  • Creates the layout for the main window widget and adds our widgets to the layout.
  • +
  • Adds our widgets to the main window layout.
  • Connects signals on widgets to slots in this class.
  • Uses actions QAction to add keyboard shortcuts -- Enter key generates a password and Esc key quits the application.
  • Sets the mReady flag to true when all this is done.
  • +

    The main window has an empty QVBoxLayout layout and we could add our widgets directly to this layout, but for keyboard + shortcuts to work properly, we need a widget that fills the main window. We create a master widget, add it to the main window + layout and then fill the master widget with other widgets.

    +
    bool Module::init(QString const & args)
     {
         Q_UNUSED(args);
    @@ -134,12 +138,15 @@ Module::~Moduleif (!mStorage)
             EVAF_WARNING("No iStorage interface");
     
    -    // Get the main window interface and fill it with widgets
    +    // Get the main window interface and fill it with the widgets
         SdiWindow::iSdiWindow * win = evafQueryInterface<SdiWindow::iSdiWindow>("iSdiWindow");
         EVAF_TEST_X(win, "No iSdiWindow interface");
     
    +    QWidget * masterWidget = new QWidget;
    +    win->addWidget(masterWidget);
    +
         QVBoxLayout * v = new QVBoxLayout;
    -    win->widget()->setLayout(v);
    +    masterWidget->setLayout(v);
     
         QGridLayout * g = new QGridLayout;
         v->addLayout(g);
    @@ -169,7 +176,7 @@ Module::~Module}
         connect(wName, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
         g->addWidget(wName, 1, 1, 1, 2);
    -    win->widget()->setFocusProxy(wName);
    +    masterWidget->setFocusProxy(wName);
     
         l = new QLabel(tr("&Length of the password:", VER_MODULE_NAME_STR));
         l->setAlignment(Qt::AlignRight);
    @@ -207,15 +214,15 @@ Module::~Moduleconnect(wCopy, SIGNAL(clicked()), this, SLOT(copyClicked()));
         h->addWidget(wCopy);
     
    -    QAction * a = new QAction(win->widget());
    +    QAction * a = new QAction(masterWidget);
         a->setShortcut(Qt::Key_Return);
         connect(a, SIGNAL(triggered()), this, SLOT(generateClicked()));
    -    win->widget()->addAction(a);
    +    masterWidget->addAction(a);
     
    -    a = new QAction(win->widget());
    +    a = new QAction(masterWidget);
         a->setShortcut(Qt::Key_Escape);
         connect(a, SIGNAL(triggered()), qApp, SLOT(quit()));
    -    win->widget()->addAction(a);
    +    masterWidget->addAction(a);
     
         mReady = true;
     
    @@ -342,8 +349,11 @@ Module::~Module::iSdiWindow * win = evafQueryInterface<SdiWindow::iSdiWindow>("iSdiWindow");
         EVAF_TEST_X(win, "No iSdiWindow interface");
     
    +    QWidget * masterWidget = new QWidget;
    +    win->addWidget(masterWidget);
    +
         QVBoxLayout * v = new QVBoxLayout;
    -    win->widget()->setLayout(v);
    +    masterWidget->setLayout(v);
     
         QGridLayout * g = new QGridLayout;
         v->addLayout(g);
    @@ -373,7 +383,7 @@ Module::~Module}
         connect(wName, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
         g->addWidget(wName, 1, 1, 1, 2);
    -    win->widget()->setFocusProxy(wName);
    +    masterWidget->setFocusProxy(wName);
     
         l = new QLabel(tr("&Length of the password:", VER_MODULE_NAME_STR));
         l->setAlignment(Qt::AlignRight);
    @@ -411,15 +421,15 @@ Module::~Moduleconnect(wCopy, SIGNAL(clicked()), this, SLOT(copyClicked()));
         h->addWidget(wCopy);
     
    -    QAction * a = new QAction(win->widget());
    +    QAction * a = new QAction(masterWidget);
         a->setShortcut(Qt::Key_Return);
         connect(a, SIGNAL(triggered()), this, SLOT(generateClicked()));
    -    win->widget()->addAction(a);
    +    masterWidget->addAction(a);
     
    -    a = new QAction(win->widget());
    +    a = new QAction(masterWidget);
         a->setShortcut(Qt::Key_Escape);
         connect(a, SIGNAL(triggered()), qApp, SLOT(quit()));
    -    win->widget()->addAction(a);
    +    masterWidget->addAction(a);
     
         mReady = true;