VirtualBox

Ignore:
Timestamp:
Aug 24, 2007 6:34:50 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
23911
Message:

FE/Qt: Settings Dialogs: Automatically show the detailed message in the whatsthis pane pointing to the page and field that contain invalid input -- for all fields with validation.

Location:
trunk/src/VBox/Frontends/VirtualBox/ui
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxGlobalSettingsDlg.ui

    r4071 r4364  
    13581358<functions>
    13591359    <function access="private">init()</function>
     1360    <function access="private" returnType="QString">pagePath( QWidget * )</function>
    13601361    <function access="private" returnType="bool">event( QEvent * )</function>
    13611362    <function access="protected">showEvent( QShowEvent * )</function>
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxGlobalSettingsDlg.ui.h

    r4071 r4364  
    340340    /* General page */
    341341
    342 /// @todo (dmik) remove
    343 //    leVDIFolder->setValidator (new QRegExpValidator (QRegExp (".+"), this));
    344 //    leMachineFolder->setValidator (new QRegExpValidator (QRegExp (".+"), this));
    345 
    346     wvalGeneral = new QIWidgetValidator (pageGeneral, this);
     342    wvalGeneral = new QIWidgetValidator (pagePath (pageGeneral), pageGeneral, this);
    347343    connect (wvalGeneral, SIGNAL (validityChanged (const QIWidgetValidator *)),
    348344             this, SLOT (enableOk( const QIWidgetValidator *)));
     
    350346    /* Keyboard page */
    351347
    352     wvalKeyboard = new QIWidgetValidator( pageKeyboard, this );
     348    wvalKeyboard = new QIWidgetValidator (pagePath (pageKeyboard), pageKeyboard, this);
    353349    connect (wvalKeyboard, SIGNAL (validityChanged (const QIWidgetValidator *)),
    354350             this, SLOT (enableOk( const QIWidgetValidator *)));
     
    432428}
    433429
     430/**
     431 *  Returns a path to the given page of this settings dialog. See ::path() for
     432 *  details.
     433 */
     434QString VBoxGlobalSettingsDlg::pagePath (QWidget *aPage)
     435{
     436    QListViewItem *li = listView->
     437        findItem (QString::number (widgetStack->id (aPage)), 1);
     438    return ::path (li);
     439}
     440
    434441bool VBoxGlobalSettingsDlg::event (QEvent *aEvent)
    435442{
     
    526533    Q_UNUSED (wval);
    527534
     535    /* reset the warning text; interested parties will set it during
     536     * validation */
     537    setWarning (QString::null);
     538
     539    QString wvalWarning;
     540
    528541    /* detect the overall validity */
    529542    bool newValid = true;
     
    534547        while ((obj = it.current()) != 0)
    535548        {
    536             newValid &= ((QIWidgetValidator *) obj)->isValid();
    537             ++it;
     549            QIWidgetValidator *wval = (QIWidgetValidator *) obj;
     550            newValid = wval->isValid();
     551            if (!newValid)
     552            {
     553                wvalWarning = wval->warningText();
     554                break;
     555            }
     556            ++ it;
    538557        }
    539558        delete l;
    540559    }
    541560
     561    if (warningString.isNull() && !wvalWarning.isNull())
     562    {
     563        /* try to set the generic error message when invalid but no specific
     564         * message is provided */
     565        setWarning (wvalWarning);
     566    }
     567
    542568    if (valid != newValid)
    543569    {
    544570        valid = newValid;
    545571        buttonOk->setEnabled (valid);
     572        /// @todo in VBoxVMSettingsDlg.ui.h, this is absent at all. Is it
     573        /// really what we want?
     574#if 0
    546575        if (valid)
    547576            warningSpacer->changeSize (0, 0, QSizePolicy::Expanding);
    548577        else
    549578            warningSpacer->changeSize (0, 0);
     579#endif
    550580        warningLabel->setHidden (valid);
    551581        warningPixmap->setHidden (valid);
     
    846876    /* setup validation */
    847877
    848     QIWidgetValidator *wval = new QIWidgetValidator (settings, settings);
     878    QIWidgetValidator *wval =
     879        new QIWidgetValidator (pagePath (pageUSB), settings, settings);
    849880    connect (wval, SIGNAL (validityChanged (const QIWidgetValidator *)),
    850881             this, SLOT (enableOk (const QIWidgetValidator *)));
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui

    r4354 r4364  
    31663166<functions>
    31673167    <function access="private">init()</function>
     3168    <function access="private" returnType="QString">pagePath( QWidget * )</function>
    31683169    <function>setup( const QString &amp;, const QString &amp; )</function>
    31693170    <function>getFromMachine( const CMachine &amp; machine )</function>
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h

    r4324 r4364  
    562562    const uint MaxVRAM = sysProps.GetMaxGuestVRAM();
    563563
    564     leName->setValidator( new QRegExpValidator( QRegExp( ".+" ), this ) );
     564    leName->setValidator (new QRegExpValidator (QRegExp (".+"), this));
    565565
    566566    leRAM->setValidator (new QIntValidator (MinRAM, MaxRAM, this));
    567567    leVRAM->setValidator (new QIntValidator (MinVRAM, MaxVRAM, this));
    568568
    569     wvalGeneral = new QIWidgetValidator( pageGeneral, this );
     569    wvalGeneral = new QIWidgetValidator (pagePath (pageGeneral), pageGeneral, this);
    570570    connect (wvalGeneral, SIGNAL (validityChanged (const QIWidgetValidator *)),
    571571             this, SLOT(enableOk (const QIWidgetValidator *)));
     
    614614                                "and allows to quickly select a different hard disk."));
    615615
    616     wvalHDD = new QIWidgetValidator( pageHDD, this );
     616    wvalHDD = new QIWidgetValidator (pagePath (pageHDD), pageHDD, this);
    617617    connect (wvalHDD, SIGNAL (validityChanged (const QIWidgetValidator *)),
    618618             this, SLOT (enableOk (const QIWidgetValidator *)));
     
    649649                                   "drive and allows to quickly select a different image."));
    650650
    651     wvalDVD = new QIWidgetValidator (pageDVD, this);
     651    wvalDVD = new QIWidgetValidator (pagePath (pageDVD), pageDVD, this);
    652652    connect (wvalDVD, SIGNAL (validityChanged (const QIWidgetValidator *)),
    653653             this, SLOT (enableOk (const QIWidgetValidator *)));
     
    675675                                      "drive and allows to quickly select a different image."));
    676676
    677     wvalFloppy = new QIWidgetValidator (pageFloppy, this);
     677    wvalFloppy = new QIWidgetValidator (pagePath (pageFloppy), pageFloppy, this);
    678678    connect (wvalFloppy, SIGNAL (validityChanged (const QIWidgetValidator *)),
    679679             this, SLOT (enableOk (const QIWidgetValidator *)));
     
    761761                         "using a standard RDP client."));
    762762
    763     ULONG maxPort = 65535;
    764     leVRDPPort->setValidator (new QIntValidator (0, maxPort, this));
    765     leVRDPTimeout->setValidator (new QIntValidator (0, maxPort, this));
    766     wvalVRDP = new QIWidgetValidator (pageVRDP, this);
     763    leVRDPPort->setValidator (new QIntValidator (0, 0xFFFF, this));
     764    leVRDPTimeout->setValidator (new QIntValidator (this));
     765    wvalVRDP = new QIWidgetValidator (pagePath (pageVRDP), pageVRDP, this);
    767766    connect (wvalVRDP, SIGNAL (validityChanged (const QIWidgetValidator *)),
    768767             this, SLOT (enableOk (const QIWidgetValidator *)));
     
    878877    cbVRDPAuthType->insertItem (vboxGlobal().toString (CEnums::VRDPAuthGuest));
    879878    leVRDPTimeout->setAlignment (Qt::AlignRight);
     879}
     880
     881/**
     882 *  Returns a path to the given page of this settings dialog. See ::path() for
     883 *  details.
     884 */
     885QString VBoxVMSettingsDlg::pagePath (QWidget *aPage)
     886{
     887    QListViewItem *li = listView->
     888        findItem (QString::number (widgetStack->id (aPage)), 1);
     889    return ::path (li);
    880890}
    881891
     
    12981308
    12991309
    1300 void VBoxVMSettingsDlg::enableOk( const QIWidgetValidator *wval )
     1310void VBoxVMSettingsDlg::enableOk (const QIWidgetValidator *wval)
    13011311{
    13021312    Q_UNUSED (wval);
     
    13051315     * validation */
    13061316    setWarning (QString::null);
     1317
     1318    QString wvalWarning;
    13071319
    13081320    /* detect the overall validity */
     
    13141326        while ((obj = it.current()) != 0)
    13151327        {
    1316             newValid &= ((QIWidgetValidator *) obj)->isValid();
    1317             ++it;
     1328            QIWidgetValidator *wval = (QIWidgetValidator *) obj;
     1329            newValid = wval->isValid();
     1330            if (!newValid)
     1331            {
     1332                wvalWarning = wval->warningText();
     1333                break;
     1334            }
     1335            ++ it;
    13181336        }
    13191337        delete l;
     1338    }
     1339
     1340    if (warningString.isNull() && !wvalWarning.isNull())
     1341    {
     1342        /* try to set the generic error message when invalid but no specific
     1343         * message is provided */
     1344        setWarning (wvalWarning);
    13201345    }
    13211346
     
    13371362
    13381363    QString warningText;
    1339     QString pageTitle = ::path (listView->currentItem());
     1364    QString pageTitle = pagePath (pg);
    13401365
    13411366    if (pg == pageHDD)
     
    15061531            }
    15071532        }
    1508     }
    1509     else if (pg == pageVRDP)
    1510     {
    1511         if (pageVRDP->isEnabled())
    1512         {
    1513             valid = !(grbVRDP->isChecked() &&
    1514                     (leVRDPPort->text().isEmpty() || leVRDPTimeout->text().isEmpty()));
    1515             if (!valid && leVRDPPort->text().isEmpty())
    1516                 warningText = tr ("VRDP Port is not set ");
    1517             if (!valid && leVRDPTimeout->text().isEmpty())
    1518                 warningText = tr ("VRDP Timeout is not set ");
    1519         }
    1520         else
    1521             valid = true;
    15221533    }
    15231534
     
    21912202    page->loadList (mInterfaceList, mNoInterfaces);
    21922203    page->getFromAdapter (aAdapter);
    2193     tbwNetwork->addTab (page, QString (tr ("Adapter %1", "network"))
    2194                                        .arg (aAdapter.GetSlot()));
     2204    QString pageTitle = QString (tr ("Adapter %1", "network"))
     2205                                 .arg (aAdapter.GetSlot());
     2206    tbwNetwork->addTab (page, pageTitle);
    21952207
    21962208    /* fix the tab order so that main dialog's buttons are always the last */
     
    22002212
    22012213    /* setup validation */
    2202     QIWidgetValidator *wval = new QIWidgetValidator (pageNetwork, this);
     2214    QIWidgetValidator *wval =
     2215        new QIWidgetValidator (QString ("%1: %2")
     2216                               .arg (pagePath (pageNetwork), pageTitle),
     2217                               pageNetwork, this);
    22032218    connect (page->grbEnabled, SIGNAL (toggled (bool)), wval, SLOT (revalidate()));
    22042219    connect (page->cbNetworkAttachment, SIGNAL (activated (const QString &)),
     
    22282243    VBoxVMSerialPortSettings *page = new VBoxVMSerialPortSettings();
    22292244    page->getFromPort (aPort);
    2230     tbwSerialPorts->addTab (page, QString (tr ("Port %1", "serial ports"))
    2231                                                .arg (aPort.GetSlot()));
     2245    QString pageTitle = QString (tr ("Port %1", "serial ports"))
     2246                                 .arg (aPort.GetSlot());
     2247    tbwSerialPorts->addTab (page, pageTitle);
    22322248
    22332249    /* fix the tab order so that main dialog's buttons are always the last */
     
    22372253
    22382254    /* setup validation */
    2239     QIWidgetValidator *wval = new QIWidgetValidator (pageSerial, this);
     2255    QIWidgetValidator *wval =
     2256        new QIWidgetValidator (QString ("%1: %2")
     2257                               .arg (pagePath (pageSerial), pageTitle),
     2258                               pageSerial, this);
    22402259    connect (page->mSerialPortBox, SIGNAL (toggled (bool)),
    22412260             wval, SLOT (revalidate()));
     
    23552374    /* setup validation */
    23562375
    2357     QIWidgetValidator *wval = new QIWidgetValidator (settings, settings);
     2376    QIWidgetValidator *wval =
     2377        new QIWidgetValidator (pagePath (pageUSB), settings, settings);
    23582378    connect (wval, SIGNAL (validityChanged (const QIWidgetValidator *)),
    23592379             this, SLOT (enableOk (const QIWidgetValidator *)));
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette