Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Set as Wallpaper' option for KDE #711

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qView.pro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TARGET = qView
VERSION = 6.1

QT += core gui network widgets
QT += core gui network widgets dbus

TEMPLATE = app

Expand Down
32 changes: 13 additions & 19 deletions src/actionmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,14 @@ QMenuBar *ActionManager::buildMenuBar(QWidget *parent)
addCloneOfAction(fileMenu, "open");
addCloneOfAction(fileMenu, "openurl");
fileMenu->addMenu(buildRecentsMenu(true, fileMenu));
addCloneOfAction(fileMenu, "reloadfile");
fileMenu->addSeparator();
#ifdef Q_OS_MACOS
fileMenu->addSeparator();
addCloneOfAction(fileMenu, "closewindow");
addCloneOfAction(fileMenu, "closeallwindows");
#endif
#ifdef COCOA_LOADED
QVCocoaFunctions::setAlternate(fileMenu, fileMenu->actions().length()-1);
QVCocoaFunctions::setAlternates(fileMenu, fileMenu->actions().length()-1, fileMenu->actions().length()-2);
#endif
fileMenu->addSeparator();
fileMenu->addMenu(buildOpenWithMenu(fileMenu));
Expand All @@ -207,10 +206,6 @@ QMenuBar *ActionManager::buildMenuBar(QWidget *parent)
addCloneOfAction(editMenu, "rename");
editMenu->addSeparator();
addCloneOfAction(editMenu, "delete");
addCloneOfAction(editMenu, "deletepermanent");
#ifdef COCOA_LOADED
QVCocoaFunctions::setAlternate(editMenu, editMenu->actions().length()-1);
#endif

menuBar->addMenu(editMenu);
// End of edit menu
Expand Down Expand Up @@ -590,16 +585,12 @@ void ActionManager::actionTriggered(QAction *triggeredAction, MainWindow *releva
relevantWindow->openWith(openWithItem);
} else if (key == "openurl") {
relevantWindow->pickUrl();
} else if (key == "reloadfile") {
relevantWindow->reloadFile();
} else if (key == "opencontainingfolder") {
relevantWindow->openContainingFolder();
} else if (key == "showfileinfo") {
relevantWindow->showFileInfo();
} else if (key == "delete") {
relevantWindow->askDeleteFile(false);
} else if (key == "deletepermanent") {
relevantWindow->askDeleteFile(true);
relevantWindow->askDeleteFile();
} else if (key == "undo") {
relevantWindow->undoDelete();
} else if (key == "copy") {
Expand Down Expand Up @@ -648,6 +639,8 @@ void ActionManager::actionTriggered(QAction *triggeredAction, MainWindow *releva
relevantWindow->increaseSpeed();
} else if (key == "slideshow") {
relevantWindow->toggleSlideshow();
} else if (QVApplication::isRunningKDE() && key == "setwallpaper") {
relevantWindow->setAsWallpaper();
}
}

Expand All @@ -669,10 +662,6 @@ void ActionManager::initializeActionLibrary()
auto *openUrlAction = new QAction(QIcon::fromTheme("document-open-remote", QIcon::fromTheme("folder-remote")), tr("Open &URL..."));
actionLibrary.insert("openurl", openUrlAction);

auto *reloadFileAction = new QAction(QIcon::fromTheme("view-refresh"), tr("Re&load File"));
reloadFileAction->setData({"disable"});
actionLibrary.insert("reloadfile", reloadFileAction);

auto *closeWindowAction = new QAction(QIcon::fromTheme("window-close"), tr("Close Window"));
actionLibrary.insert("closewindow", closeWindowAction);

Expand All @@ -695,17 +684,22 @@ void ActionManager::initializeActionLibrary()
showFileInfoAction->setData({"disable"});
actionLibrary.insert("showfileinfo", showFileInfoAction);

auto *setWallpaperAction = new QAction(QIcon::fromTheme("preferences-desktop-wallpaper"), tr("Set as &Wallpaper"));
setWallpaperAction->setData({"disable"});
actionLibrary.insert("setwallpaper", setWallpaperAction);

// Hide the action if not running KDE
if (!QVApplication::isRunningKDE()) {
setWallpaperAction->setVisible(false);
}

auto *deleteAction = new QAction(QIcon::fromTheme("edit-delete"), tr("&Move to Trash"));
#ifdef Q_OS_WIN
deleteAction->setText(tr("&Delete"));
#endif
deleteAction->setData({"disable"});
actionLibrary.insert("delete", deleteAction);

auto *deletePermanentAction = new QAction(QIcon::fromTheme("edit-delete"), tr("Delete Permanently"));
deletePermanentAction->setData({"disable"});
actionLibrary.insert("deletepermanent", deletePermanentAction);

auto *undoAction = new QAction(QIcon::fromTheme("edit-undo"), tr("&Restore from Trash"));
#ifdef Q_OS_WIN
undoAction->setText(tr("&Undo Delete"));
Expand Down
12 changes: 0 additions & 12 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "mainwindow.h"
#include "qvapplication.h"
#include "qvwin32functions.h"

#include <QCommandLineParser>

Expand All @@ -16,18 +15,7 @@ int main(int argc, char *argv[])
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument(QObject::tr("file"), QObject::tr("The file to open."));
#if defined Q_OS_WIN && WIN32_LOADED
// Workaround for unicode characters getting mangled in certain cases. To support unicode arguments on
// Windows, QCoreApplication normally ignores argv and gets them from the Windows API instead. But this
// only happens if it thinks argv hasn't been modified prior to being passed into QCoreApplication's
// constructor. Certain characters like U+2033 (double prime) get converted differently in argv versus
// the value Qt is comparing with (__argv). This makes Qt incorrectly think the data was changed, and
// it skips fetching unicode arguments from the API.
// https://bugreports.qt.io/browse/QTBUG-125380
parser.process(QVWin32Functions::getCommandLineArgs());
#else
parser.process(app);
#endif

auto *window = QVApplication::newWindow();
if (!parser.positionalArguments().isEmpty())
Expand Down
Loading