// Display the add tab widget.
qTabWidgetPointer->setCornerWidget(addTabWidgetPointer);
+ // Create the loading favorite icon movie.
+ loadingFavoriteIconMoviePointer = new QMovie();
+
+ // Set the loading favorite icon movie file name.
+ loadingFavoriteIconMoviePointer->setFileName(QStringLiteral(":/icons/loading.gif"));
+
// Add the first tab.
addFirstTab();
int newTabIndex = qTabWidgetPointer->addTab(privacyWebEngineViewPointer, i18nc("New tab label.", "New Tab"));
// Set the default tab icon.
- qTabWidgetPointer->setTabIcon(newTabIndex, defaultTabIcon);
+ qTabWidgetPointer->setTabIcon(newTabIndex, defaultFavoriteIcon);
// Get handles for the WebEngine page and profile.
QWebEnginePage *webEnginePagePointer = privacyWebEngineViewPointer->page();
}
});
- // Update the progress bar when a load is started.
+ // Update the title when it changes.
+ connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::titleChanged, [this, privacyWebEngineViewPointer] (const QString &title)
+ {
+ // Get the index for this tab.
+ int tabIndex = qTabWidgetPointer->indexOf(privacyWebEngineViewPointer);
+
+ // Update the title for this tab.
+ qTabWidgetPointer->setTabText(tabIndex, title);
+
+ // Update the window title if this is the current tab.
+ if (tabIndex == qTabWidgetPointer->currentIndex())
+ emit updateWindowTitle(title);
+ });
+
+ // Connect the loading favorite icon movie to the tab icon.
+ connect(loadingFavoriteIconMoviePointer, &QMovie::frameChanged, [privacyWebEngineViewPointer, this]
+ {
+ // Get the index for this tab.
+ int tabIndex = qTabWidgetPointer->indexOf(privacyWebEngineViewPointer);
+
+ // Display the loading favorite icon if this tab is loading.
+ if (privacyWebEngineViewPointer->isLoading)
+ qTabWidgetPointer->setTabIcon(tabIndex, loadingFavoriteIconMoviePointer->currentPixmap());
+ });
+
+ // Update the icon when it changes.
+ connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::iconChanged, [privacyWebEngineViewPointer, this] (const QIcon &newFavoriteIcon)
+ {
+ // Store the favorite icon in the privacy web engine view.
+ if (newFavoriteIcon.isNull())
+ privacyWebEngineViewPointer->favoriteIcon = defaultFavoriteIcon;
+ else
+ privacyWebEngineViewPointer->favoriteIcon = newFavoriteIcon;
+
+ // Get the index for this tab.
+ int tabIndex = qTabWidgetPointer->indexOf(privacyWebEngineViewPointer);
+
+ // Update the icon for this tab.
+ if (newFavoriteIcon.isNull())
+ qTabWidgetPointer->setTabIcon(tabIndex, defaultFavoriteIcon);
+ else
+ qTabWidgetPointer->setTabIcon(tabIndex, newFavoriteIcon);
+ });
+
+ // Update the progress bar and the favorite icon when a load is started.
connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::loadStarted, [privacyWebEngineViewPointer, this] ()
{
+ // Set the privacy web engine view to be loading.
+ privacyWebEngineViewPointer->isLoading = true;
+
// Store the load progress.
privacyWebEngineViewPointer->loadProgressInt = 0;
// Show the progress bar if this is the current tab.
if (privacyWebEngineViewPointer == currentPrivacyWebEngineViewPointer)
emit showProgressBar(0);
+
+ // Start the loading favorite icon movie.
+ loadingFavoriteIconMoviePointer->start();
});
// Update the progress bar when a load progresses.
// Update the progress bar when a load finishes.
connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::loadFinished, [privacyWebEngineViewPointer, this] ()
{
+ // Set the privacy web engine view to be not loading.
+ privacyWebEngineViewPointer->isLoading = false;
+
// Store the load progress.
privacyWebEngineViewPointer->loadProgressInt = -1;
// Hide the progress bar if this is the current tab.
if (privacyWebEngineViewPointer == currentPrivacyWebEngineViewPointer)
emit hideProgressBar();
+
+ // Get the index for this tab.
+ int tabIndex = qTabWidgetPointer->indexOf(privacyWebEngineViewPointer);
+
+ // Display the current favorite icon
+ qTabWidgetPointer->setTabIcon(tabIndex, privacyWebEngineViewPointer->favoriteIcon);
+
+ // Create a no tabs loading variable.
+ bool noTabsLoading = true;
+
+ // Check to see if any other tabs are loading.
+ for (int i = 0; i < qTabWidgetPointer->count(); i++)
+ {
+ // Get the privacy WebEngine view for the tab.
+ PrivacyWebEngineView *webEngineViewPointer = qobject_cast<PrivacyWebEngineView*>(qTabWidgetPointer->widget(i));
+
+ // Check to see if it is currently loading.
+ if (webEngineViewPointer->isLoading)
+ noTabsLoading = false;
+ }
+
+ // Stop the loading favorite icon movie if there are no loading tabs.
+ if (noTabsLoading)
+ loadingFavoriteIconMoviePointer->stop();
});
// Display HTTP Ping blocked dialogs.
for (QNetworkCookie *cookiePointer : *durableCookiesListPointer)
addCookieToStore(*cookiePointer, webEngineCookieStorePointer);
- // Update the title when it changes.
- connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::titleChanged, [this, privacyWebEngineViewPointer] (const QString &title)
- {
- // Get the index for this tab.
- int tabIndex = qTabWidgetPointer->indexOf(privacyWebEngineViewPointer);
-
- // Update the title for this tab.
- qTabWidgetPointer->setTabText(tabIndex, title);
-
- // Update the window title if this is the current tab.
- if (tabIndex == qTabWidgetPointer->currentIndex())
- emit updateWindowTitle(title);
- });
-
- // Update the icon when it changes.
- connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::iconChanged, [privacyWebEngineViewPointer, this] (const QIcon &icon)
- {
- // Get the index for this tab.
- int tabIndex = qTabWidgetPointer->indexOf(privacyWebEngineViewPointer);
-
- // Update the icon for this tab.
- if (icon.isNull())
- qTabWidgetPointer->setTabIcon(tabIndex, defaultTabIcon);
- else
- qTabWidgetPointer->setTabIcon(tabIndex, icon);
- });
-
// Enable spell checking.
webEngineProfilePointer->setSpellCheckEnabled(true);