VirtualBox

Changeset 27756 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Mar 26, 2010 5:13:33 PM (15 years ago)
Author:
vboxsync
Message:

FE/Qt: 2643: Offer to download UserManual for OSE version - support for multiple links.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r27743 r27756  
    33803380QString VBoxGlobal::helpFile() const
    33813381{
    3382 #if defined (Q_WS_WIN32) || defined (Q_WS_X11)
     3382#if defined (Q_WS_WIN32)
    33833383    const QString name = "VirtualBox";
    33843384    const QString suffix = "chm";
     
    33863386    const QString name = "UserManual";
    33873387    const QString suffix = "pdf";
     3388#elif defined (Q_WS_X11)
     3389# if defined VBOX_OSE
     3390    const QString name = "UserManual";
     3391    const QString suffix = "pdf";
     3392# else
     3393    const QString name = "VirtualBox";
     3394    const QString suffix = "chm";
     3395# endif
    33883396#endif
    33893397    /* Where are the docs located? */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp

    r27732 r27756  
    25662566    /* For non-OSE version we just open it: */
    25672567    sltShowUserManual(vboxGlobal().helpFile());
    2568 #else /* #endif for #ifndef VBOX_OSE */
     2568#else /* #ifndef VBOX_OSE */
    25692569    /* For OSE version we have to check if it present first: */
    25702570    QString strUserManualFileName1 = vboxGlobal().helpFile();
     
    25812581    else if (!UIDownloaderUserManual::current() && askAboutUserManualDownload(strUserManualFileName1))
    25822582    {
    2583         /* Initialize variables: */
    2584         CVirtualBox vbox = vboxGlobal().virtualBox();
    2585         // TODO: QString source = QString("http://download.virtualbox.org/virtualbox/%1/").arg(vbox.GetVersion().remove("_OSE")) + strName;
    2586         QString source = QString("http://download.virtualbox.org/virtualbox/") + strShortFileName;
    2587 
    25882583        /* Create User Manual downloader: */
    25892584        UIDownloaderUserManual *pDl = UIDownloaderUserManual::create();
    25902585        /* Configure User Manual downloader: */
    2591         pDl->setSource(source);
     2586        CVirtualBox vbox = vboxGlobal().virtualBox();
     2587        pDl->addSource(QString("http://download.virtualbox.org/virtualbox/%1/").arg(vbox.GetVersion().remove("_OSE")) + strShortFileName);
     2588        pDl->addSource(QString("http://download.virtualbox.org/virtualbox/") + strShortFileName);
    25922589        pDl->setTarget(strUserManualFileName2);
    25932590        pDl->setParentWidget(mainWindowShown());
    25942591        /* After the download is finished => show the document: */
    2595         connect(pDl, SIGNAL(downloadFinished(const QString&)), this, SLOT(sltShowUserManual(const QString&)));
     2592        connect(pDl, SIGNAL(sigDownloadFinished(const QString&)), this, SLOT(sltShowUserManual(const QString&)));
    25962593        /* Notify listeners: */
    25972594        emit sigDownloaderUserManualCreated();
     
    25992596        pDl->startDownload();
    26002597    }
    2601 #endif /* #endif for #ifdef VBOX_OSE */
     2598#endif /* #ifdef VBOX_OSE */
    26022599}
    26032600
     
    26112608{
    26122609#if defined (Q_WS_WIN32)
    2613     HtmlHelp (GetDesktopWindow(), strLocation.utf16(), HH_DISPLAY_TOPIC, NULL);
     2610    HtmlHelp(GetDesktopWindow(), strLocation.utf16(), HH_DISPLAY_TOPIC, NULL);
    26142611#elif defined (Q_WS_X11)
     2612# ifndef VBOX_OSE
    26152613    char szViewerPath[RTPATH_MAX];
    26162614    int rc;
     
    26182616    AssertRC(rc);
    26192617    QProcess::startDetached(QString(szViewerPath) + "/kchmviewer", QStringList(strLocation));
     2618# else /* #ifndef VBOX_OSE */
     2619    /* In OSE case we do NOT know which of PDF viewers are installed,
     2620     * so we will just try few of them: */
     2621    QStringList viewers;
     2622    viewers << "evince" << "okular";
     2623    foreach (const QString &viewer, viewers)
     2624        if (QProcess::startDetached(viewer, QStringList(strLocation)))
     2625            break;
     2626# endif /* #ifdef VBOX_OSE */
    26202627#elif defined (Q_WS_MAC)
    2621     vboxGlobal().openURL ("file://" + strLocation);
     2628    vboxGlobal().openURL("file://" + strLocation);
    26222629#endif
    26232630}
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIDownloaderUserManual.cpp

    r27695 r27756  
    5454}
    5555
     56void UIDownloaderUserManual::setSource(const QString &strSource)
     57{
     58    /* Erase the list first: */
     59    m_sourcesList.clear();
     60    /* And add there passed value: */
     61    addSource(strSource);
     62}
     63
     64void UIDownloaderUserManual::addSource(const QString &strSource)
     65{
     66    /* Append passed value: */
     67    m_sourcesList << strSource;
     68}
     69
    5670void UIDownloaderUserManual::setParentWidget(QWidget *pParent)
    5771{
     
    6680UIMiniProcessWidgetUserManual* UIDownloaderUserManual::processWidget(QWidget *pParent /* = 0 */) const
    6781{
    68     UIMiniProcessWidgetUserManual *pWidget = new UIMiniProcessWidgetUserManual(m_source.toString(), pParent);
     82    UIMiniProcessWidgetUserManual *pWidget = new UIMiniProcessWidgetUserManual(pParent);
    6983
    7084    /* Connect the cancel signal: */
    7185    connect(pWidget, SIGNAL(sigCancel()), this, SLOT(cancelDownloading()));
     86    /* Connect the signal to notify about source changed: */
     87    connect(this, SIGNAL(sigSourceChanged(const QString&)), pWidget, SLOT(sltSetSource(const QString&)));
    7288    /* Connect the signal to notify about the download process: */
    7389    connect(this, SIGNAL(sigDownloadProcess(int, int)), pWidget, SLOT(sltProcess(int, int)));
     
    8096void UIDownloaderUserManual::startDownload()
    8197{
    82     acknowledgeStart();
     98    /* If at least one source to try left: */
     99    if (!m_sourcesList.isEmpty())
     100    {
     101        /* Set the first of left sources as current one: */
     102        UIDownloader::setSource(m_sourcesList.takeFirst());
     103        /* Warn process-bar(s) about source was changed: */
     104        emit sigSourceChanged(source());
     105        /* Try to download: */
     106        acknowledgeStart();
     107    }
     108}
     109
     110void UIDownloaderUserManual::acknowledgeFinished(bool fError)
     111{
     112    /* If current source was wrong but other is present
     113     * we will try other source else we should finish: */
     114    if (fError && !m_sourcesList.isEmpty())
     115        startDownload();
     116    else
     117        UIDownloader::acknowledgeFinished(fError);
    83118}
    84119
     
    105140                vboxProblem().warnAboutUserManualDownloaded(m_source.toString(), QDir::toNativeSeparators(m_strTarget));
    106141                /* Warn listener about User Manual was downloaded: */
    107                 emit downloadFinished(m_strTarget);
     142                emit sigDownloadFinished(m_strTarget);
    108143                /* Close the downloader: */
    109144                QTimer::singleShot(0, this, SLOT(suicide()));
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIDownloaderUserManual.h

    r27695 r27756  
    3737public:
    3838
    39     UIMiniProcessWidgetUserManual(const QString &strSource, QWidget *pParent = 0)
     39    UIMiniProcessWidgetUserManual(QWidget *pParent = 0)
    4040        : QIWithRetranslateUI<UIMiniProcessWidget>(pParent)
     41    {
     42        retranslateUi();
     43    }
     44
     45protected slots:
     46
     47    void sltSetSource(const QString &strSource)
    4148    {
    4249        setSource(strSource);
     
    5057        setCancelButtonText(tr("Cancel"));
    5158        setCancelButtonToolTip(tr("Cancel the VirtualBox User Manual download"));
    52         setProgressBarToolTip((tr("Downloading the VirtualBox User Manual "
    53                                   "<nobr><b>%1</b>...</nobr>")
    54                                .arg(source())));
     59        QString strProgressBarTip = source().isEmpty() ? tr("Downloading the VirtualBox User Manual") :
     60            tr("Downloading the VirtualBox User Manual <nobr><b>%1</b>...</nobr>").arg(source());
     61        setProgressBarToolTip(strProgressBarTip);
    5562    }
    5663};
     
    6673    static void destroy();
    6774
     75    void setSource(const QString &strSource);
     76    void addSource(const QString &strSource);
     77
    6878    void setParentWidget(QWidget *pParent);
    6979    QWidget *parentWidget() const;
     
    7484signals:
    7585
    76     void downloadFinished(const QString &strFile);
     86    void sigSourceChanged(const QString &strSource);
     87    void sigDownloadFinished(const QString &strFile);
    7788
    7889private slots:
    7990
     91    void acknowledgeFinished(bool fError);
    8092    void downloadFinished(bool fError);
    8193    void suicide();
     
    94106     * QPointer guarantees that the ptr itself is zero in that case. */
    95107    QPointer<QWidget> m_pParent;
     108
     109    /* List of sources to try to download from: */
     110    QList<QString> m_sourcesList;
    96111};
    97112
Note: See TracChangeset for help on using the changeset viewer.

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