1
0
mirror of https://invent.kde.org/system/dolphin synced 2024-06-28 14:35:36 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Méven Car
292f9e6f12 Merge branch 'work/meven/confirmation-settings' into 'master'
settings: improve confirmation tab layou layout

See merge request system/dolphin!772
2024-06-24 18:35:53 +00:00
Felix Ernst
d953875b60 DolphinViewContainer: Use KMessageWidget::MessageType instead of own type
This slightly simplifies code and allows showing
KMessageWidget::Positive message boxes.
2024-06-24 17:06:09 +00:00
Méven Car
f9c1a5556e settings: improve confirmation tab layou layout 2024-05-08 17:08:37 +02:00
4 changed files with 33 additions and 47 deletions

View File

@ -184,7 +184,7 @@ DolphinMainWindow::DolphinMainWindow()
m_disabledActionNotifier = new DisabledActionNotifier(this);
connect(m_disabledActionNotifier, &DisabledActionNotifier::disabledActionTriggered, this, [this](const QAction *, QString reason) {
m_activeViewContainer->showMessage(reason, DolphinViewContainer::Warning);
m_activeViewContainer->showMessage(reason, KMessageWidget::Warning);
});
setupDockWidgets();
@ -562,7 +562,7 @@ void DolphinMainWindow::showTarget()
KIO::StatJob *statJob = static_cast<KIO::StatJob *>(job);
if (statJob->error()) {
m_activeViewContainer->showMessage(job->errorString(), DolphinViewContainer::Error);
m_activeViewContainer->showMessage(job->errorString(), KMessageWidget::Error);
} else {
KIO::highlightInFileManager({destinationUrl});
}
@ -801,7 +801,7 @@ void DolphinMainWindow::quit()
void DolphinMainWindow::showErrorMessage(const QString &message)
{
m_activeViewContainer->showMessage(message, DolphinViewContainer::Error);
m_activeViewContainer->showMessage(message, KMessageWidget::Error);
}
void DolphinMainWindow::slotUndoAvailable(bool available)
@ -2898,7 +2898,7 @@ void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job *job)
DolphinMainWindow *mainWin = qobject_cast<DolphinMainWindow *>(parentWidget());
if (mainWin) {
DolphinViewContainer *container = mainWin->activeViewContainer();
container->showMessage(job->errorString(), DolphinViewContainer::Error);
container->showMessage(job->errorString(), KMessageWidget::Error);
} else {
KIO::FileUndoManager::UiInterface::jobError(job);
}

View File

@ -109,7 +109,7 @@ DolphinViewContainer::DolphinViewContainer(const QUrl &url, QWidget *parent)
#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
@ -366,9 +366,7 @@ void DolphinViewContainer::setSelectionModeEnabled(bool enabled, KActionCollecti
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);
});
@ -408,32 +406,18 @@ void DolphinViewContainer::slotSplitTabDisabled()
}
}
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();
@ -828,18 +812,18 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const QUrl &url)
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();
}
@ -914,9 +898,9 @@ 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()
@ -950,7 +934,7 @@ void DolphinViewContainer::slotCurrentDirectoryRemoved()
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)

View File

@ -14,6 +14,7 @@
#include <KFileItem>
#include <KIO/Job>
#include <KMessageWidget>
#include <KUrlNavigator>
#include <QElapsedTimer>
@ -25,7 +26,6 @@ namespace Admin
class Bar;
}
class FilterBar;
class KMessageWidget;
class QAction;
class QGridLayout;
class QUrl;
@ -53,8 +53,6 @@ class DolphinViewContainer : public QWidget
Q_OBJECT
public:
enum MessageType { Information, Warning, Error };
DolphinViewContainer(const QUrl &url, QWidget *parent);
~DolphinViewContainer() override;
@ -151,10 +149,9 @@ public:
bool isSelectionModeEnabled() const;
/**
* Shows the message \msg with the given type non-modal above
* the view-content.
* Shows the message \message with the given type \messageType non-modal above the view-content.
*/
void showMessage(const QString &msg, MessageType type);
void showMessage(const QString &message, KMessageWidget::MessageType messageType);
/**
* Refreshes the view container to get synchronized with the (updated) Dolphin settings.
@ -393,9 +390,9 @@ private Q_SLOTS:
void slotStatusBarZoomLevelChanged(int zoomLevel);
/**
* Slot that calls showMessage(msg, Error).
* Slot that calls showMessage(message, KMessageWidget::Error).
*/
void showErrorMessage(const QString &msg);
void showErrorMessage(const QString &message);
/**
* Is invoked when a KFilePlacesModel has been changed

View File

@ -18,6 +18,7 @@
#include <QComboBox>
#include <QFormLayout>
#include <QLabel>
#include <QVBoxLayout>
namespace
{
@ -72,19 +73,23 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget *parent)
m_confirmScriptExecution = new QComboBox(this);
m_confirmScriptExecution->addItems({i18n("Always ask"), i18n("Open in application"), i18n("Run script")});
topLayout->addRow(confirmLabelKde);
topLayout->addRow(nullptr, m_confirmMoveToTrash);
topLayout->addRow(nullptr, m_confirmEmptyTrash);
auto *layout1 = new QVBoxLayout();
layout1->addWidget(m_confirmMoveToTrash);
layout1->addWidget(m_confirmEmptyTrash);
topLayout->addRow(confirmLabelKde, layout1);
topLayout->addRow(nullptr, m_confirmDelete);
topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed));
topLayout->addRow(confirmLabelDolphin);
topLayout->addRow(nullptr, m_confirmClosingMultipleTabs);
QVBoxLayout *layout2 = new QVBoxLayout();
layout2->addWidget(m_confirmClosingMultipleTabs);
#if HAVE_TERMINAL
topLayout->addRow(nullptr, m_confirmClosingTerminalRunningProgram);
layout2->addWidget(m_confirmClosingTerminalRunningProgram);
#endif
topLayout->addRow(confirmLabelDolphin, layout2);
topLayout->addRow(nullptr, m_confirmOpenManyFolders);
topLayout->addRow(nullptr, m_confirmOpenManyTerminals);
if (KProtocolInfo::isKnownProtocol(QStringLiteral("admin"))) {