File indexing completed on 2024-05-05 04:34:53

0001 /* SPDX-FileCopyrightText: 2023 Noah Davis <noahadvs@gmail.com>
0002  * SPDX-License-Identifier: LGPL-2.0-or-later
0003  */
0004 
0005 #pragma once
0006 
0007 #include <KLocalizedString>
0008 #include <QCommandLineOption>
0009 #include <QList>
0010 
0011 using namespace Qt::StringLiterals;
0012 
0013 struct CommandLineOptions {
0014     static CommandLineOptions *self();
0015     static QString toArgument(const QCommandLineOption &option) {
0016         return u"--" + option.names().constLast();
0017     }
0018     // i18n() can't be used in static code,
0019     // so we can't just make the variables static and use them directly.
0020     const QCommandLineOption fullscreen = {
0021         {u"f"_s, u"fullscreen"_s},
0022         i18n("Capture the entire desktop (default)")
0023     };
0024     const QCommandLineOption current = {
0025         {u"m"_s, u"current"_s},
0026         i18n("Capture the current monitor")
0027     };
0028     const QCommandLineOption activeWindow = {
0029         {u"a"_s, u"activewindow"_s},
0030         i18n("Capture the active window")
0031     };
0032     const QCommandLineOption windowUnderCursor = {
0033         {u"u"_s, u"windowundercursor"_s},
0034         i18n("Capture the window currently under the cursor, including parents of pop-up menus")
0035     };
0036     const QCommandLineOption transientOnly = {
0037         {u"t"_s, u"transientonly"_s},
0038         i18n("Capture the window currently under the cursor, excluding parents of pop-up menus")
0039     };
0040     const QCommandLineOption region = {
0041         {u"r"_s, u"region"_s},
0042         i18n("Capture a rectangular region of the screen")
0043     };
0044     const QCommandLineOption record = {
0045         {u"R"_s, u"record"_s},
0046         i18n("Record the screen using the given mode. Modes:\n"
0047              "- r, region\n"
0048              "- s, screen\n"
0049              "- w, window"),
0050         u"mode"_s,
0051     };
0052     const QCommandLineOption launchOnly = {
0053         {u"l"_s, u"launchonly"_s},
0054         i18n("Launch Spectacle without taking a screenshot")
0055     };
0056     const QCommandLineOption gui = {
0057         {u"g"_s, u"gui"_s},
0058         i18n("Start in GUI mode (default)")
0059     };
0060     const QCommandLineOption background = {
0061         {u"b"_s, u"background"_s},
0062         i18n("Take a screenshot and exit without showing the GUI")
0063     };
0064     const QCommandLineOption dbus = {
0065         {u"s"_s, u"dbus"_s},
0066         i18n("Start in DBus-Activation mode")
0067     };
0068     const QCommandLineOption noNotify = {
0069         {u"n"_s, u"nonotify"_s},
0070         i18n("In background mode, do not pop up a notification when the screenshot is taken")
0071     };
0072     const QCommandLineOption output = {
0073         {u"o"_s, u"output"_s},
0074         i18n("In background mode, save image to specified file"),
0075         u"fileName"_s
0076     };
0077     const QCommandLineOption delay = {
0078         {u"d"_s, u"delay"_s},
0079         i18n("In background mode, delay before taking the shot (in milliseconds)"),
0080         u"delayMsec"_s
0081     };
0082     const QCommandLineOption copyImage = {
0083         {u"c"_s, u"copy-image"_s},
0084         i18n("In background mode, copy screenshot image to clipboard, unless -o is also used.")
0085     };
0086     const QCommandLineOption copyPath = {
0087         {u"C"_s, u"copy-path"_s},
0088         i18n("In background mode, copy screenshot file path to clipboard")
0089     };
0090     const QCommandLineOption onClick = {
0091         {u"w"_s, u"onclick"_s},
0092         i18n("Wait for a click before taking screenshot. Invalidates delay")
0093     };
0094     const QCommandLineOption newInstance = {
0095         {u"i"_s, u"new-instance"_s},
0096         i18n("Starts a new GUI instance of spectacle without registering to DBus")
0097     };
0098     const QCommandLineOption pointer = {
0099         {u"p"_s, u"pointer"_s},
0100         i18n("In background mode, include pointer in the screenshot")
0101     };
0102     const QCommandLineOption noDecoration = {
0103         {u"e"_s, u"no-decoration"_s},
0104         i18n("In background mode, exclude decorations in the screenshot")
0105     };
0106     const QCommandLineOption noShadow = {{u"S"_s, u"no-shadow"_s}, i18n("In background mode, exclude shadows in the screenshot")};
0107     const QCommandLineOption editExisting = {
0108         {u"E"_s, u"edit-existing"_s},
0109         i18n("Open and edit existing screenshot file"),
0110         u"existingFileName"_s
0111     };
0112 
0113     const QList<QCommandLineOption> allOptions = {
0114         fullscreen, current, activeWindow, windowUnderCursor, transientOnly, region,  record,      launchOnly, gui,          background, dbus,
0115         noNotify,   output,  delay,        copyImage,         copyPath,      onClick, newInstance, pointer,    noDecoration, noShadow,   editExisting,
0116     };
0117 
0118     // Keep order in sync with allOptions
0119     enum Option {
0120         Fullscreen,
0121         Current,
0122         ActiveWindow,
0123         WindowUnderCursor,
0124         TransientOnly,
0125         Region,
0126         Record,
0127         LaunchOnly,
0128         Gui,
0129         Background,
0130         DBus,
0131         NoNotify,
0132         Output,
0133         Delay,
0134         CopyImage,
0135         CopyPath,
0136         OnClick,
0137         NewInstance,
0138         Pointer,
0139         NoDecoration,
0140         NoShadow,
0141         EditExisting,
0142         TotalOptions
0143     };
0144 };