dolphin/src/dolphinnewfilemenu.h
Jakob Petsovits b5b6762b15 Bring back the "Create New" menu in the menu bar
This commit is the result of a three-way diff that
combines my own initial patch with related changes from
Felix Ernst's MR !545 and further suggestions by Méven Car.

Fixes DolphinMainWindowTest::testNewFileMenuEnabled().
Tests are now passing again for my build.

"Create New" was broken by commit c64059bd which switched to the
new, non-deprecated KNewFileMenu constructor (kio commit 89bc6bad)
that doesn't add itself to the passed KActionCollection parameter.
After the switch, hamburger menu and context menu was still working
as intended but the menu bar was missing the "Create New" menu.

This commit adds the addAction("new_menu") call to the File menu
setup that would have previously been called by the deprecated
KNewFileMenu constructor. The corresponding test can now find
the QObject for the menu's named action again, verifying its
existence and enabled-ness like it did before.

The DolphinNewFileMenu constructor's unused actionCollection
parameter serves no use anymore except to confuse people.
We replace it with a single QAction* parameter, createDirAction,
which gets passed to setNewFolderShortcutAction().

2 out of 3 constructor call sites have access to this action,
while the remaining call site in dolphinmainwindow.cpp must wait
until after it has been initialized by DolphinViewActionHandler.
In this case, setNewFolderShortcutAction() is still called manually
at a later time.
2023-05-16 11:11:51 -04:00

40 lines
890 B
C++

/*
* SPDX-FileCopyrightText: 2006 Peter Penz <peter.penz@gmx.at>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef DOLPHINNEWFILEMENU_H
#define DOLPHINNEWFILEMENU_H
#include "dolphin_export.h"
#include <KNewFileMenu>
class KJob;
/**
* @brief Represents the 'Create New...' sub menu for the File menu
* and the context menu.
*
* The only difference to KNewFileMenu is the custom error handling.
* All errors are shown in the status bar of Dolphin
* instead as modal error dialog with an OK button.
*/
class DOLPHIN_EXPORT DolphinNewFileMenu : public KNewFileMenu
{
Q_OBJECT
public:
DolphinNewFileMenu(QAction *createDirAction, QObject *parent);
~DolphinNewFileMenu() override;
Q_SIGNALS:
void errorMessage(const QString &error);
protected Q_SLOTS:
/** @see KNewFileMenu::slotResult() */
void slotResult(KJob *job) override;
};
#endif