#include "dolphincontextmenu.h"
#include "dolphin_contextmenusettings.h"
-#include "dolphin_generalsettings.h"
#include "dolphinmainwindow.h"
#include "dolphinnewfilemenu.h"
#include "dolphinplacesmodelsingleton.h"
#include "global.h"
#include "trash/dolphintrash.h"
#include "views/dolphinview.h"
-#include "views/viewmodecontroller.h"
#include <KActionCollection>
#include <KFileItemListProperties>
{
QList<QUrl> urls = {};
- for (const KFileItem &item : m_activeViewContainer->view()->selectedItems()) {
+ const auto selectedItems = m_activeViewContainer->view()->selectedItems();
+ for (const KFileItem &item : selectedItems) {
QUrl url = item.targetUrl();
if (item.isFile()) {
url.setPath(QFileInfo(url.path()).absolutePath());
}
}
- for (const QUrl &url : urls) {
+ for (const QUrl &url : std::as_const(urls)) {
openTerminalJob(url);
}
}
// Used by konqueror. Technically it means "we want undo enabled if
// there are things in the undo history and the current part is a dolphin part".
// Even though it's konqueror doing the undo...
- Q_PROPERTY(bool supportsUndo READ supportsUndo)
+ Q_PROPERTY(bool supportsUndo READ supportsUndo CONSTANT)
Q_PROPERTY(QString currentViewMode READ currentViewMode WRITE setCurrentViewMode)
* Opens a new tab in the background showing the URL \a primaryUrl and the
* optional URL \a secondaryUrl.
*/
- void openNewTab(const QUrl &primaryUrl, const QUrl &secondaryUrl = QUrl(), NewTabPosition position = NewTabPosition::FollowSetting);
+ void openNewTab(const QUrl &primaryUrl,
+ const QUrl &secondaryUrl = QUrl(),
+ DolphinTabWidget::NewTabPosition position = DolphinTabWidget::NewTabPosition::FollowSetting);
/**
* Opens each directory in \p dirs in a separate tab unless it is already open.
class DOLPHIN_EXPORT KItemListController : public QObject
{
Q_OBJECT
- Q_PROPERTY(KItemModelBase *model READ model WRITE setModel)
- Q_PROPERTY(KItemListView *view READ view WRITE setView)
- Q_PROPERTY(SelectionBehavior selectionBehavior READ selectionBehavior WRITE setSelectionBehavior)
- Q_PROPERTY(AutoActivationBehavior autoActivationBehavior READ autoActivationBehavior WRITE setAutoActivationBehavior)
- Q_PROPERTY(MouseDoubleClickAction mouseDoubleClickAction READ mouseDoubleClickAction WRITE setMouseDoubleClickAction)
+ Q_PROPERTY(KItemModelBase *model READ model WRITE setModel NOTIFY modelChanged)
+ Q_PROPERTY(KItemListView *view READ view WRITE setView NOTIFY viewChanged)
public:
enum SelectionBehavior { NoSelection, SingleSelection, MultiSelection };
{
Q_OBJECT
- Q_PROPERTY(qreal scrollOffset READ scrollOffset WRITE setScrollOffset)
- Q_PROPERTY(qreal itemOffset READ itemOffset WRITE setItemOffset)
+ Q_PROPERTY(qreal scrollOffset READ scrollOffset WRITE setScrollOffset NOTIFY scrollOffsetChanged)
+ Q_PROPERTY(qreal itemOffset READ itemOffset WRITE setItemOffset NOTIFY itemOffsetChanged)
public:
explicit KItemListView(QGraphicsWidget *parent = nullptr);
{
if (m_sidePadding != width) {
m_sidePadding = width;
- sidePaddingChanged(width);
+ Q_EMIT sidePaddingChanged(width);
update();
}
}
class DOLPHIN_EXPORT KItemListRubberBand : public QObject
{
Q_OBJECT
- Q_PROPERTY(QPointF endPosition MEMBER m_endPos READ endPosition WRITE setEndPosition)
+ Q_PROPERTY(QPointF endPosition MEMBER m_endPos READ endPosition WRITE setEndPosition NOTIFY endPositionChanged)
public:
explicit KItemListRubberBand(QObject *parent = nullptr);
// - Groups with two leading quotes must close both on them (filename:""abc xyz" tuv")
// - Groups enclosed in quotes
// - Words separated by spaces
- const QRegularExpression subTermsRegExp("(\\S*?\"\"[^\"]+\"[^\"]+\"+|\\S*?\"[^\"]+\"+|(?<=\\s|^)\\S+(?=\\s|$))");
+ static const QRegularExpression subTermsRegExp("(\\S*?\"\"[^\"]+\"[^\"]+\"+|\\S*?\"[^\"]+\"+|(?<=\\s|^)\\S+(?=\\s|$))");
auto subTermsMatchIterator = subTermsRegExp.globalMatch(text);
QStringList textParts;
BackgroundColorHelper::BackgroundColorHelper()
{
updateBackgroundColor();
- QObject::connect(qApp, &QGuiApplication::paletteChanged, [=]() {
+ QObject::connect(qApp, &QGuiApplication::paletteChanged, qApp, [=]() {
slotPaletteChanged();
});
}
auto *copyButton = new QPushButton(this);
// We claim to have PasteContents already so triggering the copy action next won't instantly hide the bottom bar.
- connect(copyButton, &QAbstractButton::clicked, [this]() {
+ connect(copyButton, &QAbstractButton::clicked, this, [this]() {
if (GeneralSettings::showPasteBarAfterCopying()) {
m_contents = BottomBar::Contents::PasteContents; // prevents hiding
}
// Connect the copy action as a second step.
m_mainAction = ActionWithWidget(m_actionCollection->action(KStandardAction::name(KStandardAction::Copy)), copyButton);
// Finally connect the lambda that actually changes the contents to the PasteContents.
- connect(copyButton, &QAbstractButton::clicked, [this]() {
+ connect(copyButton, &QAbstractButton::clicked, this, [this]() {
if (GeneralSettings::showPasteBarAfterCopying()) {
resetContents(BottomBar::Contents::PasteContents); // resetContents() needs to be connected last because
// it instantly deletes the button and then the other slots won't be called.
auto *cutButton = new QPushButton(this);
// We claim to have PasteContents already so triggering the cut action next won't instantly hide the bottom bar.
- connect(cutButton, &QAbstractButton::clicked, [this]() {
+ connect(cutButton, &QAbstractButton::clicked, this, [this]() {
if (GeneralSettings::showPasteBarAfterCopying()) {
m_contents = BottomBar::Contents::PasteContents; // prevents hiding
}
// Connect the cut action as a second step.
m_mainAction = ActionWithWidget(m_actionCollection->action(KStandardAction::name(KStandardAction::Cut)), cutButton);
// Finally connect the lambda that actually changes the contents to the PasteContents.
- connect(cutButton, &QAbstractButton::clicked, [this]() {
+ connect(cutButton, &QAbstractButton::clicked, this, [this]() {
if (GeneralSettings::showPasteBarAfterCopying()) {
resetContents(BottomBar::Contents::PasteContents); // resetContents() needs to be connected last because
// it instantly deletes the button and then the other slots won't be called.
#include "contextmenusettingspage.h"
#include "dolphin_contextmenusettings.h"
-#include "dolphin_generalsettings.h"
#include "dolphin_versioncontrolsettings.h"
#include "global.h"
#include "settings/serviceitemdelegate.h"
void applySettings() override;
void restoreDefaults() override;
-Q_SIGNALS:
- void changed();
-
private Q_SLOTS:
void slotDefaultSliderMoved(int value);
: KFileItemListView(parent)
, m_zoomLevel(0)
{
- updateFont();
+ DolphinItemListView::updateFont();
updateGridSize();
}
}
}
+void DolphinView::onDirectoryLoadingCompleted()
+{
+ // the model should now contain all the items created by the job
+ updateSelectionState();
+ m_selectJobCreatedItems = false;
+ m_selectedUrls.clear();
+}
+
void DolphinView::slotJobResult(KJob *job)
{
if (job->error() && job->error() != KIO::ERR_USER_CANCELED) {
updateSelectionState();
if (!m_selectedUrls.isEmpty()) {
// not all urls were found, the model may not be up to date
- // TODO KF6 replace with Qt::singleShotConnection
- QMetaObject::Connection *const connection = new QMetaObject::Connection;
- *connection = connect(
- m_model,
- &KFileItemModel::directoryLoadingCompleted,
- this,
- [this, connection]() {
- // the model should now contain all the items created by the job
- updateSelectionState();
- m_selectJobCreatedItems = false;
- m_selectedUrls.clear();
- QObject::disconnect(*connection);
- delete connection;
- },
- Qt::UniqueConnection);
+ connect(m_model, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::onDirectoryLoadingCompleted, Qt::UniqueConnection);
} else {
m_selectJobCreatedItems = false;
m_selectedUrls.clear();
void slotTwoClicksRenamingTimerTimeout();
+ void onDirectoryLoadingCompleted();
+
private:
void loadDirectory(const QUrl &url, bool reload = false);