#if !defined(Q_OS_WIN) && !defined(Q_OS_HAIKU)
if (getuid() == 0) {
// We must be logged in as the root user; show a big scary warning
- showMessage(i18n("Running Dolphin as root can be dangerous. Please be careful."), Warning);
+ showMessage(i18n("Running Dolphin as root can be dangerous. Please be careful."), KMessageWidget::Warning);
}
#endif
connect(m_view, &DolphinView::directoryLoadingCompleted, this, &DolphinViewContainer::slotDirectoryLoadingCompleted);
connect(m_view, &DolphinView::directoryLoadingCanceled, this, &DolphinViewContainer::slotDirectoryLoadingCanceled);
connect(m_view, &DolphinView::itemCountChanged, this, &DolphinViewContainer::delayedStatusBarUpdate);
- connect(m_view, &DolphinView::directoryLoadingProgress, this, &DolphinViewContainer::updateDirectoryLoadingProgress);
- connect(m_view, &DolphinView::directorySortingProgress, this, &DolphinViewContainer::updateDirectorySortingProgress);
connect(m_view, &DolphinView::selectionChanged, this, &DolphinViewContainer::delayedStatusBarUpdate);
connect(m_view, &DolphinView::errorMessage, this, &DolphinViewContainer::showErrorMessage);
connect(m_view, &DolphinView::urlIsFileError, this, &DolphinViewContainer::slotUrlIsFileError);
connect(m_view, &DolphinView::operationCompletedMessage, m_statusBar, &DolphinStatusBar::setText);
connect(m_view, &DolphinView::statusBarTextChanged, m_statusBar, &DolphinStatusBar::setDefaultText);
connect(m_view, &DolphinView::statusBarTextChanged, m_statusBar, &DolphinStatusBar::resetToDefaultText);
+ connect(m_view, &DolphinView::directoryLoadingProgress, m_statusBar, [this](int percent) {
+ m_statusBar->showProgress(i18nc("@info:progress", "Loading folder…"), percent);
+ });
+ connect(m_view, &DolphinView::directorySortingProgress, m_statusBar, [this](int percent) {
+ m_statusBar->showProgress(i18nc("@info:progress", "Sorting…"), percent);
+ });
connect(m_statusBar, &DolphinStatusBar::stopPressed, this, &DolphinViewContainer::stopDirectoryLoading);
connect(m_statusBar, &DolphinStatusBar::zoomLevelChanged, this, &DolphinViewContainer::slotStatusBarZoomLevelChanged);
connect(m_view, &DolphinView::selectionChanged, this, [this](const KFileItemList &selection) {
m_selectionModeBottomBar->slotSelectionChanged(selection, m_view->url());
});
- connect(m_selectionModeBottomBar, &SelectionMode::BottomBar::error, this, [this](const QString &errorMessage) {
- showErrorMessage(errorMessage);
- });
+ connect(m_selectionModeBottomBar, &SelectionMode::BottomBar::error, this, &DolphinViewContainer::showErrorMessage);
connect(m_selectionModeBottomBar, &SelectionMode::BottomBar::selectionModeLeavingRequested, this, [this]() {
setSelectionModeEnabled(false);
});
}
}
-void DolphinViewContainer::showMessage(const QString &msg, MessageType type)
+void DolphinViewContainer::showMessage(const QString &message, KMessageWidget::MessageType messageType)
{
- if (msg.isEmpty()) {
+ if (message.isEmpty()) {
return;
}
- m_messageWidget->setText(msg);
+ m_messageWidget->setText(message);
// TODO: wrap at arbitrary character positions once QLabel can do this
// https://bugreports.qt.io/browse/QTBUG-1276
m_messageWidget->setWordWrap(true);
-
- switch (type) {
- case Information:
- m_messageWidget->setMessageType(KMessageWidget::Information);
- break;
- case Warning:
- m_messageWidget->setMessageType(KMessageWidget::Warning);
- break;
- case Error:
- m_messageWidget->setMessageType(KMessageWidget::Error);
- break;
- default:
- Q_ASSERT(false);
- break;
- }
+ m_messageWidget->setMessageType(messageType);
m_messageWidget->setWordWrap(false);
const int unwrappedWidth = m_messageWidget->sizeHint().width();
m_view->requestStatusBarText();
}
-void DolphinViewContainer::updateDirectoryLoadingProgress(int percent)
-{
- if (m_statusBar->progressText().isEmpty()) {
- m_statusBar->setProgressText(i18nc("@info:progress", "Loading folder…"));
- }
- m_statusBar->setProgress(percent);
-}
-
-void DolphinViewContainer::updateDirectorySortingProgress(int percent)
-{
- if (m_statusBar->progressText().isEmpty()) {
- m_statusBar->setProgressText(i18nc("@info:progress", "Sorting…"));
- }
- m_statusBar->setProgress(percent);
-}
-
void DolphinViewContainer::slotDirectoryLoadingStarted()
{
if (isSearchUrl(url())) {
// Search KIO-slaves usually don't provide any progress information. Give
// a hint to the user that a searching is done:
updateStatusBar();
- m_statusBar->setProgressText(i18nc("@info", "Searching…"));
- m_statusBar->setProgress(-1);
+ m_statusBar->showProgress(i18nc("@info", "Searching…"), -1);
} else {
// Trigger an undetermined progress indication. The progress
// information in percent will be triggered by the percent() signal
// of the directory lister later.
- m_statusBar->setProgressText(QString());
- updateDirectoryLoadingProgress(-1);
+ m_statusBar->showProgress(QString(), -1);
}
if (m_urlNavigatorConnected) {
void DolphinViewContainer::slotDirectoryLoadingCompleted()
{
- if (!m_statusBar->progressText().isEmpty()) {
- m_statusBar->setProgressText(QString());
- m_statusBar->setProgress(100);
- }
+ m_statusBar->showProgress(QString(), 100);
if (isSearchUrl(url()) && m_view->itemsCount() == 0) {
// The dir lister has been completed on a Baloo-URI and no items have been found. Instead
void DolphinViewContainer::slotDirectoryLoadingCanceled()
{
- if (!m_statusBar->progressText().isEmpty()) {
- m_statusBar->setProgressText(QString());
- m_statusBar->setProgress(100);
- }
-
+ m_statusBar->showProgress(QString(), 100);
m_statusBar->setText(QString());
}
if (url.scheme().startsWith(QLatin1String("http"))) {
showMessage(i18nc("@info:status", // krazy:exclude=qmethods
"Dolphin does not support web pages, the web browser has been launched"),
- Information);
+ KMessageWidget::Information);
} else {
- showMessage(i18nc("@info:status", "Protocol not supported by Dolphin, default application has been launched"), Information);
+ showMessage(i18nc("@info:status", "Protocol not supported by Dolphin, default application has been launched"), KMessageWidget::Information);
}
QDesktopServices::openUrl(url);
redirect(QUrl(), m_urlNavigator->locationUrl(1));
} else {
if (!url.scheme().isEmpty()) {
- showMessage(i18nc("@info:status", "Invalid protocol '%1'", url.scheme()), Error);
+ showMessage(i18nc("@info:status", "Invalid protocol '%1'", url.scheme()), KMessageWidget::Error);
} else {
- showMessage(i18nc("@info:status", "Invalid protocol"), Error);
+ showMessage(i18nc("@info:status", "Invalid protocol"), KMessageWidget::Error);
}
m_urlNavigator->goBack();
}
void DolphinViewContainer::stopDirectoryLoading()
{
m_view->stopLoading();
- m_statusBar->setProgress(100);
+ m_statusBar->showProgress(QString(), 100);
}
void DolphinViewContainer::slotStatusBarZoomLevelChanged(int zoomLevel)
m_view->setZoomLevel(zoomLevel);
}
-void DolphinViewContainer::showErrorMessage(const QString &msg)
+void DolphinViewContainer::showErrorMessage(const QString &message)
{
- showMessage(msg, Error);
+ showMessage(message, KMessageWidget::Error);
}
void DolphinViewContainer::slotPlacesModelChanged()
setUrl(newUrl);
}
- showMessage(xi18n("Current location changed, <filename>%1</filename> is no longer accessible.", location), Warning);
+ showMessage(xi18n("Current location changed, <filename>%1</filename> is no longer accessible.", location), KMessageWidget::Warning);
}
void DolphinViewContainer::slotOpenUrlFinished(KJob *job)