From b88a5fbce8bbd07e9abda01cf651337cebbdb18f Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Wed, 23 Sep 2020 15:24:16 +0300 Subject: [PATCH] Code refactoring - change code style to the new clang-format rules --- src/cli/commandargument.cpp | 34 +- src/cli/commandargument.h | 11 +- src/cli/commandlineparser.cpp | 180 +++++----- src/cli/commandlineparser.h | 70 ++-- src/cli/commandoption.cpp | 80 +++-- src/cli/commandoption.h | 34 +- src/config/buttonlistview.cpp | 40 ++- src/config/buttonlistview.h | 9 +- src/config/clickablelabel.cpp | 13 +- src/config/clickablelabel.h | 9 +- src/config/extendedslider.cpp | 34 +- src/config/extendedslider.h | 5 +- src/config/filenameeditor.cpp | 62 ++-- src/config/filenameeditor.h | 25 +- src/config/filepathconfiguration.cpp | 52 ++- src/config/filepathconfiguration.h | 15 +- src/config/setshortcutwidget.cpp | 25 +- src/config/setshortcutwidget.h | 11 +- src/config/shortcutswidget.cpp | 51 +-- src/config/shortcutswidget.h | 13 +- src/config/strftimechooserwidget.cpp | 64 ++-- src/config/strftimechooserwidget.h | 7 +- src/config/uicoloreditor.cpp | 79 +++-- src/config/uicoloreditor.h | 26 +- src/config/visualseditor.cpp | 46 ++- src/config/visualseditor.h | 13 +- src/core/capturerequest.cpp | 51 +-- src/core/capturerequest.h | 27 +- src/core/controller.cpp | 228 ++++++------ src/core/controller.h | 24 +- src/core/flameshotdbusadapter.cpp | 65 ++-- src/core/flameshotdbusadapter.h | 20 +- src/core/globalshortcutfilter.cpp | 19 +- src/core/globalshortcutfilter.h | 13 +- src/main.cpp | 290 +++++++++------- .../Qt-Color-Widgets/src/color_utils.cpp | 82 +++-- .../Qt-Color-Widgets/src/color_wheel.cpp | 306 ++++++++--------- .../singleapplication/singleapplication.cpp | 324 +++++++++--------- .../singleapplication/singleapplication.h | 27 +- .../singleapplication/singleapplication_p.h | 37 +- src/tools/abstractactiontool.cpp | 42 ++- src/tools/abstractactiontool.h | 22 +- src/tools/abstractpathtool.cpp | 46 ++- src/tools/abstractpathtool.h | 17 +- src/tools/abstracttwopointtool.cpp | 66 ++-- src/tools/abstracttwopointtool.h | 19 +- src/tools/arrow/arrowtool.cpp | 64 ++-- src/tools/arrow/arrowtool.h | 21 +- src/tools/blur/blurtool.cpp | 55 +-- src/tools/blur/blurtool.h | 21 +- src/tools/capturecontext.cpp | 3 +- src/tools/capturecontext.h | 11 +- src/tools/capturetool.h | 59 ++-- src/tools/circle/circletool.cpp | 34 +- src/tools/circle/circletool.h | 21 +- src/tools/copy/copytool.cpp | 27 +- src/tools/copy/copytool.h | 11 +- src/tools/exit/exittool.cpp | 27 +- src/tools/exit/exittool.h | 11 +- src/tools/launcher/applaunchertool.cpp | 30 +- src/tools/launcher/applaunchertool.h | 11 +- src/tools/launcher/applauncherwidget.cpp | 163 +++++---- src/tools/launcher/applauncherwidget.h | 29 +- src/tools/launcher/launcheritemdelegate.cpp | 44 +-- src/tools/launcher/launcheritemdelegate.h | 14 +- src/tools/launcher/openwithprogram.cpp | 14 +- src/tools/launcher/openwithprogram.h | 2 +- src/tools/launcher/terminallauncher.cpp | 45 +-- src/tools/launcher/terminallauncher.h | 11 +- src/tools/line/linetool.cpp | 34 +- src/tools/line/linetool.h | 21 +- src/tools/marker/markertool.cpp | 37 +- src/tools/marker/markertool.h | 21 +- src/tools/move/movetool.cpp | 27 +- src/tools/move/movetool.h | 11 +- src/tools/pencil/penciltool.cpp | 36 +- src/tools/pencil/penciltool.h | 21 +- src/tools/pin/pintool.cpp | 35 +- src/tools/pin/pintool.h | 11 +- src/tools/pin/pinwidget.cpp | 47 ++- src/tools/pin/pinwidget.h | 27 +- src/tools/rectangle/rectangletool.cpp | 34 +- src/tools/rectangle/rectangletool.h | 21 +- src/tools/redo/redotool.cpp | 27 +- src/tools/redo/redotool.h | 12 +- src/tools/save/savetool.cpp | 31 +- src/tools/save/savetool.h | 11 +- src/tools/selection/selectiontool.cpp | 37 +- src/tools/selection/selectiontool.h | 21 +- src/tools/sizeindicator/sizeindicatortool.cpp | 31 +- src/tools/sizeindicator/sizeindicatortool.h | 11 +- src/tools/storage/imguploader.cpp | 4 +- src/tools/storage/imguploadertool.cpp | 11 +- src/tools/storage/imguploadertool.h | 1 - src/tools/storage/storagemanager.cpp | 5 +- src/tools/storage/storagemanager.h | 2 +- src/tools/text/textconfig.cpp | 75 ++-- src/tools/text/textconfig.h | 17 +- src/tools/text/texttool.cpp | 152 +++++--- src/tools/text/texttool.h | 36 +- src/tools/text/textwidget.cpp | 41 ++- src/tools/text/textwidget.h | 14 +- src/tools/toolfactory.h | 17 +- src/tools/undo/undotool.cpp | 27 +- src/tools/undo/undotool.h | 12 +- src/utils/colorutils.cpp | 10 +- src/utils/colorutils.h | 4 +- src/utils/configenterprise.cpp | 15 +- src/utils/configenterprise.h | 5 +- src/utils/configshortcuts.cpp | 185 +++++----- src/utils/configshortcuts.h | 12 +- src/utils/dbusutils.cpp | 35 +- src/utils/dbusutils.h | 10 +- src/utils/desktopfileparse.cpp | 85 ++--- src/utils/desktopfileparse.h | 44 +-- src/utils/desktopinfo.cpp | 24 +- src/utils/desktopinfo.h | 6 +- src/utils/filenamehandler.cpp | 59 ++-- src/utils/filenamehandler.h | 22 +- src/utils/globalvalues.cpp | 5 +- src/utils/pathinfo.cpp | 27 +- src/utils/screengrabber.cpp | 109 +++--- src/utils/screengrabber.h | 9 +- src/utils/screenshotsaver.cpp | 47 +-- src/utils/screenshotsaver.h | 10 +- src/utils/systemnotification.cpp | 58 ++-- src/utils/systemnotification.h | 16 +- src/utils/waylandutils.cpp | 9 +- src/utils/waylandutils.h | 2 - src/widgets/capture/buttonhandler.cpp | 197 ++++++----- src/widgets/capture/buttonhandler.h | 35 +- src/widgets/capture/capturebutton.cpp | 149 ++++---- src/widgets/capture/capturebutton.h | 22 +- src/widgets/capture/capturewidget.h | 71 ++-- src/widgets/capture/colorpicker.cpp | 43 ++- src/widgets/capture/colorpicker.h | 9 +- src/widgets/capture/hovereventfilter.cpp | 35 +- src/widgets/capture/hovereventfilter.h | 18 +- src/widgets/capture/modificationcommand.cpp | 11 +- src/widgets/capture/modificationcommand.h | 9 +- src/widgets/capture/notifierbox.cpp | 32 +- src/widgets/capture/notifierbox.h | 15 +- src/widgets/capture/selectionwidget.cpp | 56 +-- src/widgets/capture/selectionwidget.h | 19 +- src/widgets/capturelauncher.cpp | 98 +++--- src/widgets/capturelauncher.h | 15 +- src/widgets/historywidget.cpp | 2 +- src/widgets/imagelabel.cpp | 34 +- src/widgets/imagelabel.h | 29 +- src/widgets/infowindow.cpp | 37 +- src/widgets/infowindow.h | 9 +- src/widgets/loadspinner.cpp | 47 ++- src/widgets/loadspinner.h | 15 +- src/widgets/notificationwidget.cpp | 25 +- src/widgets/notificationwidget.h | 19 +- src/widgets/panel/sidepanelwidget.cpp | 119 ++++--- src/widgets/panel/sidepanelwidget.h | 41 +-- src/widgets/panel/utilitypanel.cpp | 51 ++- src/widgets/panel/utilitypanel.h | 23 +- translations/Internationalization_ca.ts | 314 ++++++++--------- translations/Internationalization_de_DE.ts | 314 ++++++++--------- translations/Internationalization_es.ts | 314 ++++++++--------- translations/Internationalization_fr.ts | 314 ++++++++--------- translations/Internationalization_ja.ts | 314 ++++++++--------- translations/Internationalization_ka.ts | 314 ++++++++--------- translations/Internationalization_nl.ts | 314 ++++++++--------- translations/Internationalization_pl.ts | 314 ++++++++--------- translations/Internationalization_pt_br.ts | 314 ++++++++--------- translations/Internationalization_ru.ts | 314 ++++++++--------- translations/Internationalization_sk.ts | 314 ++++++++--------- translations/Internationalization_sr.ts | 314 ++++++++--------- translations/Internationalization_tr.ts | 314 ++++++++--------- translations/Internationalization_uk.ts | 314 ++++++++--------- translations/Internationalization_zh_CN.ts | 314 ++++++++--------- translations/Internationalization_zh_TW.ts | 314 ++++++++--------- 175 files changed, 6200 insertions(+), 5356 deletions(-) mode change 100755 => 100644 src/tools/pin/pintool.h diff --git a/src/cli/commandargument.cpp b/src/cli/commandargument.cpp index b516ee90..f1eeeda9 100644 --- a/src/cli/commandargument.cpp +++ b/src/cli/commandargument.cpp @@ -17,38 +17,40 @@ #include "commandargument.h" -CommandArgument::CommandArgument() { +CommandArgument::CommandArgument() {} -} +CommandArgument::CommandArgument(const QString& name, + const QString& description) + : m_name(name) + , m_description(description) +{} -CommandArgument::CommandArgument(const QString &name, - const QString &description) : - m_name(name), m_description(description) +void CommandArgument::setName(const QString& name) { - -} - -void CommandArgument::setName(const QString &name) { m_name = name; } -QString CommandArgument::name() const { +QString CommandArgument::name() const +{ return m_name; } -void CommandArgument::setDescription(const QString &description) { +void CommandArgument::setDescription(const QString& description) +{ m_description = description; } -QString CommandArgument::description() const { +QString CommandArgument::description() const +{ return m_description; } -bool CommandArgument::isRoot() const { +bool CommandArgument::isRoot() const +{ return m_name.isEmpty() && m_description.isEmpty(); } -bool CommandArgument::operator ==(const CommandArgument &arg) const { - return m_description == arg.m_description - && m_name == arg.m_name; +bool CommandArgument::operator==(const CommandArgument& arg) const +{ + return m_description == arg.m_description && m_name == arg.m_name; } diff --git a/src/cli/commandargument.h b/src/cli/commandargument.h index b8394218..64211833 100644 --- a/src/cli/commandargument.h +++ b/src/cli/commandargument.h @@ -19,20 +19,21 @@ #include -class CommandArgument { +class CommandArgument +{ public: CommandArgument(); - explicit CommandArgument(const QString &name, const QString &description); + explicit CommandArgument(const QString& name, const QString& description); - void setName(const QString &name); + void setName(const QString& name); QString name() const; - void setDescription(const QString &description); + void setDescription(const QString& description); QString description() const; bool isRoot() const; - bool operator ==(const CommandArgument &arg) const; + bool operator==(const CommandArgument& arg) const; private: QString m_name; diff --git a/src/cli/commandlineparser.cpp b/src/cli/commandlineparser.cpp index 9a0daaf2..71437b26 100644 --- a/src/cli/commandlineparser.cpp +++ b/src/cli/commandlineparser.cpp @@ -19,34 +19,34 @@ #include #include -CommandLineParser::CommandLineParser() : - m_description(qApp->applicationName()) -{ - -} +CommandLineParser::CommandLineParser() + : m_description(qApp->applicationName()) +{} namespace { QTextStream out(stdout); QTextStream err(stderr); -auto versionOption = CommandOption({"v", "version"}, - QStringLiteral("Displays version information")); -auto helpOption = CommandOption({"h", "help"}, - QStringLiteral("Displays this help")); +auto versionOption = + CommandOption({ "v", "version" }, + QStringLiteral("Displays version information")); +auto helpOption = + CommandOption({ "h", "help" }, QStringLiteral("Displays this help")); -QString optionsToString(const QList &options, - const QList &arguments) { +QString optionsToString(const QList& options, + const QList& arguments) +{ int size = 0; // track the largest size QStringList dashedOptionList; // save the dashed options and its size in order to print the description // of every option at the same horizontal character position. - for (auto const &option: options) { + for (auto const& option : options) { QStringList dashedOptions = option.dashedNames(); QString joinedDashedOptions = dashedOptions.join(QStringLiteral(", ")); if (!option.valueName().isEmpty()) { - joinedDashedOptions += QStringLiteral(" <%1>") - .arg(option.valueName()); + joinedDashedOptions += + QStringLiteral(" <%1>").arg(option.valueName()); } if (joinedDashedOptions.length() > size) { size = joinedDashedOptions.length(); @@ -54,20 +54,21 @@ QString optionsToString(const QList &options, dashedOptionList << joinedDashedOptions; } // check the length of the arguments - for (auto const &arg: arguments) { - if(arg.name().length() > size) + for (auto const& arg : arguments) { + if (arg.name().length() > size) size = arg.name().length(); } // generate the text QString result; - if(!dashedOptionList.isEmpty()) { + if (!dashedOptionList.isEmpty()) { result += QLatin1String("Options:\n"); - QString linePadding = QStringLiteral(" ").repeated(size + 4).prepend("\n"); + QString linePadding = + QStringLiteral(" ").repeated(size + 4).prepend("\n"); for (int i = 0; i < options.length(); ++i) { result += QStringLiteral(" %1 %2\n") - .arg(dashedOptionList.at(i).leftJustified(size, ' ')) - .arg(options.at(i).description() - .replace(QLatin1String("\n"), linePadding)); + .arg(dashedOptionList.at(i).leftJustified(size, ' ')) + .arg(options.at(i).description().replace( + QLatin1String("\n"), linePadding)); } if (!arguments.isEmpty()) { result += QLatin1String("\n"); @@ -78,22 +79,22 @@ QString optionsToString(const QList &options, } for (int i = 0; i < arguments.length(); ++i) { result += QStringLiteral(" %1 %2\n") - .arg(arguments.at(i).name().leftJustified(size, ' ')) - .arg(arguments.at(i).description()); + .arg(arguments.at(i).name().leftJustified(size, ' ')) + .arg(arguments.at(i).description()); } return result; } } // unnamed namespace -bool CommandLineParser::processArgs(const QStringList &args, - QStringList::const_iterator &actualIt, - Node * &actualNode) +bool CommandLineParser::processArgs(const QStringList& args, + QStringList::const_iterator& actualIt, + Node*& actualNode) { QString argument = *actualIt; bool ok = true; bool isValidArg = false; - for (Node &n: actualNode->subNodes) { + for (Node& n : actualNode->subNodes) { if (n.argument.name() == argument) { actualNode = &n; isValidArg = true; @@ -114,9 +115,9 @@ bool CommandLineParser::processArgs(const QStringList &args, return ok; } -bool CommandLineParser::processOptions(const QStringList &args, - QStringList::const_iterator &actualIt, - Node *const actualNode) +bool CommandLineParser::processOptions(const QStringList& args, + QStringList::const_iterator& actualIt, + Node* const actualNode) { QString arg = *actualIt; bool ok = true; @@ -124,20 +125,17 @@ bool CommandLineParser::processOptions(const QStringList &args, int equalsPos = arg.indexOf(QLatin1String("=")); QString valueStr; if (equalsPos != -1) { - valueStr = arg.mid(equalsPos +1); // right - arg = arg.mid(0, equalsPos); // left + valueStr = arg.mid(equalsPos + 1); // right + arg = arg.mid(0, equalsPos); // left } // check format -x --xx... bool isDoubleDashed = arg.startsWith(QLatin1String("--")); - ok = isDoubleDashed ? arg.length() > 3 : - arg.length() == 2; + ok = isDoubleDashed ? arg.length() > 3 : arg.length() == 2; if (!ok) { out << QStringLiteral("the option %1 has a wrong format.").arg(arg); return ok; } - arg = isDoubleDashed ? - arg.remove(0, 2) : - arg.remove(0, 1); + arg = isDoubleDashed ? arg.remove(0, 2) : arg.remove(0, 1); // get option auto endIt = actualNode->options.cend(); auto optionIt = endIt; @@ -153,8 +151,9 @@ bool CommandLineParser::processOptions(const QStringList &args, argName = qApp->applicationName(); } out << QStringLiteral("the option '%1' is not a valid option " - "for the argument '%2'.").arg(arg) - .arg(argName); + "for the argument '%2'.") + .arg(arg) + .arg(argName); ok = false; return ok; } @@ -163,15 +162,17 @@ bool CommandLineParser::processOptions(const QStringList &args, bool requiresValue = !(option.valueName().isEmpty()); if (!requiresValue && equalsPos != -1) { out << QStringLiteral("the option '%1' contains a '=' and it doesn't " - "require a value.").arg(arg); + "require a value.") + .arg(arg); ok = false; return ok; } else if (requiresValue && valueStr.isEmpty()) { // find in the next - if (actualIt+1 != args.cend()) { + if (actualIt + 1 != args.cend()) { ++actualIt; } else { - out << QStringLiteral("Expected value after the option '%1'.").arg(arg); + out << QStringLiteral("Expected value after the option '%1'.") + .arg(arg); ok = false; return ok; } @@ -193,17 +194,17 @@ bool CommandLineParser::processOptions(const QStringList &args, return ok; } -bool CommandLineParser::parse(const QStringList &args) { +bool CommandLineParser::parse(const QStringList& args) +{ m_foundArgs.clear(); m_foundOptions.clear(); bool ok = true; - Node *actualNode = &m_parseTree; + Node* actualNode = &m_parseTree; auto it = ++args.cbegin(); // check version option QStringList dashedVersion = versionOption.dashedNames(); if (m_withVersion && args.length() > 1 && - dashedVersion.contains(args.at(1))) - { + dashedVersion.contains(args.at(1))) { if (args.length() == 2) { printVersion(); m_foundOptions << versionOption; @@ -212,13 +213,12 @@ bool CommandLineParser::parse(const QStringList &args) { ok = false; } return ok; - } // check help option ok = processIfOptionIsHelp(args, it, actualNode); // process the other args for (; it != args.cend() && ok; ++it) { - const QString &value = *it; + const QString& value = *it; if (value.startsWith(QLatin1String("-"))) { ok = processOptions(args, it, actualNode); @@ -232,21 +232,23 @@ bool CommandLineParser::parse(const QStringList &args) { return ok; } -CommandOption CommandLineParser::addVersionOption() { +CommandOption CommandLineParser::addVersionOption() +{ m_withVersion = true; return versionOption; } -CommandOption CommandLineParser::addHelpOption() { +CommandOption CommandLineParser::addHelpOption() +{ m_withHelp = true; return helpOption; } -bool CommandLineParser::AddArgument(const CommandArgument &arg, - const CommandArgument &parent) +bool CommandLineParser::AddArgument(const CommandArgument& arg, + const CommandArgument& parent) { bool res = true; - Node *n = findParent(parent); + Node* n = findParent(parent); if (n == nullptr) { res = false; } else { @@ -257,11 +259,11 @@ bool CommandLineParser::AddArgument(const CommandArgument &arg, return res; } -bool CommandLineParser::AddOption(const CommandOption &option, - const CommandArgument &parent) +bool CommandLineParser::AddOption(const CommandOption& option, + const CommandArgument& parent) { bool res = true; - Node *n = findParent(parent); + Node* n = findParent(parent); if (n == nullptr) { res = false; } else { @@ -270,11 +272,11 @@ bool CommandLineParser::AddOption(const CommandOption &option, return res; } -bool CommandLineParser::AddOptions(const QList &options, - const CommandArgument &parent) +bool CommandLineParser::AddOptions(const QList& options, + const CommandArgument& parent) { bool res = true; - for (auto const &option: options) { + for (auto const& option : options) { if (!AddOption(option, parent)) { res = false; break; @@ -283,26 +285,30 @@ bool CommandLineParser::AddOptions(const QList &options, return res; } -void CommandLineParser::setGeneralErrorMessage(const QString &msg) { +void CommandLineParser::setGeneralErrorMessage(const QString& msg) +{ m_generalErrorMessage = msg; } -void CommandLineParser::setDescription(const QString &description) { +void CommandLineParser::setDescription(const QString& description) +{ m_description = description; } -bool CommandLineParser::isSet(const CommandArgument &arg) const { +bool CommandLineParser::isSet(const CommandArgument& arg) const +{ return m_foundArgs.contains(arg); } - -bool CommandLineParser::isSet(const CommandOption &option) const { +bool CommandLineParser::isSet(const CommandOption& option) const +{ return m_foundOptions.contains(option); } -QString CommandLineParser::value(const CommandOption &option) const { +QString CommandLineParser::value(const CommandOption& option) const +{ QString value = option.value(); - for (const CommandOption &fOption: m_foundOptions) { + for (const CommandOption& fOption : m_foundOptions) { if (option == fOption) { value = fOption.value(); break; @@ -311,12 +317,14 @@ QString CommandLineParser::value(const CommandOption &option) const { return value; } -void CommandLineParser::printVersion() { +void CommandLineParser::printVersion() +{ out << "Flameshot " << qApp->applicationVersion() << "\nCompiled with Qt " << static_cast(QT_VERSION_STR) << "\n"; } -void CommandLineParser::printHelp(QStringList args, const Node *node) { +void CommandLineParser::printHelp(QStringList args, const Node* node) +{ args.removeLast(); // remove the help, it's always the last QString helpText; // add usage info @@ -326,11 +334,12 @@ void CommandLineParser::printHelp(QStringList args, const Node *node) { } QString argText = node->subNodes.isEmpty() ? "" : "[arguments]"; helpText += QStringLiteral("Usage: %1 [%2-options] %3\n\n") - .arg(args.join(QStringLiteral(" "))) - .arg(argName).arg(argText); + .arg(args.join(QStringLiteral(" "))) + .arg(argName) + .arg(argText); // add command options and subarguments QList subArgs; - for (const Node &n: node->subNodes) + for (const Node& n : node->subNodes) subArgs.append(n.argument); auto modifiedOptions = node->options; if (m_withHelp) @@ -344,16 +353,15 @@ void CommandLineParser::printHelp(QStringList args, const Node *node) { } CommandLineParser::Node* CommandLineParser::findParent( - const CommandArgument &parent) + const CommandArgument& parent) { if (parent == CommandArgument()) { return &m_parseTree; } - //find the parent in the subNodes recursively - Node *res = nullptr; - for (auto i = m_parseTree.subNodes.begin(); - i != m_parseTree.subNodes.end(); ++i) - { + // find the parent in the subNodes recursively + Node* res = nullptr; + for (auto i = m_parseTree.subNodes.begin(); i != m_parseTree.subNodes.end(); + ++i) { res = recursiveParentSearch(parent, *i); if (res != nullptr) { break; @@ -363,13 +371,14 @@ CommandLineParser::Node* CommandLineParser::findParent( } CommandLineParser::Node* CommandLineParser::recursiveParentSearch( - const CommandArgument &parent, Node &node) const + const CommandArgument& parent, + Node& node) const { - Node * res = nullptr; + Node* res = nullptr; if (node.argument == parent) { res = &node; } else { - for (auto i = node.subNodes.begin(); i != node.subNodes.end(); ++i){ + for (auto i = node.subNodes.begin(); i != node.subNodes.end(); ++i) { res = recursiveParentSearch(parent, *i); if (res != nullptr) { break; @@ -380,16 +389,15 @@ CommandLineParser::Node* CommandLineParser::recursiveParentSearch( } bool CommandLineParser::processIfOptionIsHelp( - const QStringList &args, - QStringList::const_iterator &actualIt, - Node * &actualNode) + const QStringList& args, + QStringList::const_iterator& actualIt, + Node*& actualNode) { bool ok = true; auto dashedHelpNames = helpOption.dashedNames(); if (m_withHelp && actualIt != args.cend() && - dashedHelpNames.contains(*actualIt)) - { - if (actualIt+1 == args.cend()) { + dashedHelpNames.contains(*actualIt)) { + if (actualIt + 1 == args.cend()) { m_foundOptions << helpOption; printHelp(args, actualNode); actualIt++; diff --git a/src/cli/commandlineparser.h b/src/cli/commandlineparser.h index dc2306ce..5fc9ad90 100644 --- a/src/cli/commandlineparser.h +++ b/src/cli/commandlineparser.h @@ -21,46 +21,50 @@ #include "src/cli/commandoption.h" #include -class CommandLineParser { +class CommandLineParser +{ public: CommandLineParser(); - bool parse(const QStringList &args); + bool parse(const QStringList& args); CommandArgument rootArgument() const { return CommandArgument(); } CommandOption addVersionOption(); CommandOption addHelpOption(); - bool AddArgument(const CommandArgument &arg, - const CommandArgument &parent = CommandArgument()); + bool AddArgument(const CommandArgument& arg, + const CommandArgument& parent = CommandArgument()); - bool AddOption(const CommandOption &option, - const CommandArgument &parent = CommandArgument()); + bool AddOption(const CommandOption& option, + const CommandArgument& parent = CommandArgument()); - bool AddOptions(const QList &options, - const CommandArgument &parent = CommandArgument()); + bool AddOptions(const QList& options, + const CommandArgument& parent = CommandArgument()); - void setGeneralErrorMessage(const QString &msg); - void setDescription(const QString &description); + void setGeneralErrorMessage(const QString& msg); + void setDescription(const QString& description); - bool isSet(const CommandArgument &arg) const; - bool isSet(const CommandOption &option) const; - QString value(const CommandOption &option) const; + bool isSet(const CommandArgument& arg) const; + bool isSet(const CommandOption& option) const; + QString value(const CommandOption& option) const; private: bool m_withHelp = false; bool m_withVersion = false; QString m_description; - QString m_generalErrorMessage; + QString m_generalErrorMessage; - struct Node { - explicit Node(const CommandArgument &arg) : argument(arg) {} + struct Node + { + explicit Node(const CommandArgument& arg) + : argument(arg) + {} Node() {} - bool operator==(const Node &n) const { - return argument == n.argument && - options == n.options && - subNodes == n.subNodes; + bool operator==(const Node& n) const + { + return argument == n.argument && options == n.options && + subNodes == n.subNodes; } CommandArgument argument; QList options; @@ -73,17 +77,17 @@ private: // helper functions void printVersion(); - void printHelp(QStringList args, const Node *node); - Node* findParent(const CommandArgument &parent); - Node* recursiveParentSearch(const CommandArgument &parent, - Node &node) const; - bool processIfOptionIsHelp(const QStringList &args, - QStringList::const_iterator &actualIt, - Node * &actualNode); - bool processArgs(const QStringList &args, - QStringList::const_iterator &actualIt, - Node * &actualNode); - bool processOptions(const QStringList &args, - QStringList::const_iterator &actualIt, - Node *const actualNode); + void printHelp(QStringList args, const Node* node); + Node* findParent(const CommandArgument& parent); + Node* recursiveParentSearch(const CommandArgument& parent, + Node& node) const; + bool processIfOptionIsHelp(const QStringList& args, + QStringList::const_iterator& actualIt, + Node*& actualNode); + bool processArgs(const QStringList& args, + QStringList::const_iterator& actualIt, + Node*& actualNode); + bool processOptions(const QStringList& args, + QStringList::const_iterator& actualIt, + Node* const actualNode); }; diff --git a/src/cli/commandoption.cpp b/src/cli/commandoption.cpp index a0877fad..6c076612 100644 --- a/src/cli/commandoption.cpp +++ b/src/cli/commandoption.cpp @@ -17,76 +17,90 @@ #include "commandoption.h" -CommandOption::CommandOption(const QString &name, const QString &description, - const QString &valueName, - const QString &defaultValue) : - m_names(name), m_description(description), m_valueName(valueName), - m_value(defaultValue) +CommandOption::CommandOption(const QString& name, + const QString& description, + const QString& valueName, + const QString& defaultValue) + : m_names(name) + , m_description(description) + , m_valueName(valueName) + , m_value(defaultValue) { - m_checker = [](QString const&){ return true; }; + m_checker = [](QString const&) { return true; }; } -CommandOption::CommandOption(const QStringList &names, - const QString &description, - const QString &valueName, - const QString &defaultValue) : - m_names(names), m_description(description), m_valueName(valueName), - m_value(defaultValue) +CommandOption::CommandOption(const QStringList& names, + const QString& description, + const QString& valueName, + const QString& defaultValue) + : m_names(names) + , m_description(description) + , m_valueName(valueName) + , m_value(defaultValue) { m_checker = [](QString const&) -> bool { return true; }; } -void CommandOption::setName(const QString &name) { +void CommandOption::setName(const QString& name) +{ m_names = QStringList() << name; } -void CommandOption::setNames(const QStringList &names) { +void CommandOption::setNames(const QStringList& names) +{ m_names = names; } -QStringList CommandOption::names() const { +QStringList CommandOption::names() const +{ return m_names; } -QStringList CommandOption::dashedNames() const { +QStringList CommandOption::dashedNames() const +{ QStringList dashedNames; - for (const QString &name: m_names) { + for (const QString& name : m_names) { // prepend "-" to single character options, and "--" to the others - QString dashedName = (name.length() == 1) ? - QStringLiteral("-%1").arg(name) : - QStringLiteral("--%1").arg(name); + QString dashedName = (name.length() == 1) + ? QStringLiteral("-%1").arg(name) + : QStringLiteral("--%1").arg(name); dashedNames << dashedName; } return dashedNames; } -void CommandOption::setValueName(const QString &name) { +void CommandOption::setValueName(const QString& name) +{ m_valueName = name; } -QString CommandOption::valueName() const { +QString CommandOption::valueName() const +{ return m_valueName; } -void CommandOption::setValue(const QString &value) { +void CommandOption::setValue(const QString& value) +{ if (m_valueName.isEmpty()) { m_valueName = QLatin1String("value"); } m_value = value; } -QString CommandOption::value() const { +QString CommandOption::value() const +{ return m_value; } -void CommandOption::addChecker(const function checker, - const QString &errMsg) +void CommandOption::addChecker(const function checker, + const QString& errMsg) { m_checker = checker; m_errorMsg = errMsg; } -bool CommandOption::checkValue(const QString &value) const { +bool CommandOption::checkValue(const QString& value) const +{ return m_checker(value); } @@ -95,18 +109,18 @@ QString CommandOption::description() const return m_description; } -void CommandOption::setDescription(const QString &description) +void CommandOption::setDescription(const QString& description) { m_description = description; } -QString CommandOption::errorMsg() const { +QString CommandOption::errorMsg() const +{ return m_errorMsg; } -bool CommandOption::operator ==(const CommandOption &option) const +bool CommandOption::operator==(const CommandOption& option) const { - return m_description == option.m_description - && m_names == option.m_names - && m_valueName == option.m_valueName; + return m_description == option.m_description && m_names == option.m_names && + m_valueName == option.m_valueName; } diff --git a/src/cli/commandoption.h b/src/cli/commandoption.h index d73e5ec5..25fd8b82 100644 --- a/src/cli/commandoption.h +++ b/src/cli/commandoption.h @@ -22,36 +22,40 @@ using std::function; -class CommandOption { +class CommandOption +{ public: - CommandOption(const QString &name, const QString &description, - const QString &valueName = QString(), - const QString &defaultValue = QString()); + CommandOption(const QString& name, + const QString& description, + const QString& valueName = QString(), + const QString& defaultValue = QString()); - CommandOption(const QStringList &names, const QString &description, - const QString &valueName = QString(), - const QString &defaultValue = QString()); + CommandOption(const QStringList& names, + const QString& description, + const QString& valueName = QString(), + const QString& defaultValue = QString()); - void setName(const QString &name); - void setNames(const QStringList &names); + void setName(const QString& name); + void setNames(const QStringList& names); QStringList names() const; QStringList dashedNames() const; - void setValueName(const QString &name); + void setValueName(const QString& name); QString valueName() const; - void setValue(const QString &value); + void setValue(const QString& value); QString value() const; - void addChecker(const function checker, const QString &errMsg); - bool checkValue(const QString &value) const; + void addChecker(const function checker, + const QString& errMsg); + bool checkValue(const QString& value) const; QString description() const; - void setDescription(const QString &description); + void setDescription(const QString& description); QString errorMsg() const; - bool operator==(const CommandOption &option) const; + bool operator==(const CommandOption& option) const; private: QStringList m_names; diff --git a/src/config/buttonlistview.cpp b/src/config/buttonlistview.cpp index 277c176b..45280d6b 100644 --- a/src/config/buttonlistview.cpp +++ b/src/config/buttonlistview.cpp @@ -21,34 +21,38 @@ #include #include -ButtonListView::ButtonListView(QWidget *parent) : QListWidget(parent) { +ButtonListView::ButtonListView(QWidget* parent) + : QListWidget(parent) +{ setMouseTracking(true); setFlow(QListWidget::TopToBottom); initButtonList(); updateComponents(); - connect(this, &QListWidget::itemClicked, this, - &ButtonListView::reverseItemCheck); + connect( + this, &QListWidget::itemClicked, this, &ButtonListView::reverseItemCheck); } -void ButtonListView::initButtonList() { +void ButtonListView::initButtonList() +{ ToolFactory factory; auto listTypes = CaptureButton::getIterableButtonTypes(); - for (const CaptureButton::ButtonType t: listTypes) { - CaptureTool *tool = factory.CreateTool(t); + for (const CaptureButton::ButtonType t : listTypes) { + CaptureTool* tool = factory.CreateTool(t); // add element to the local map m_buttonTypeByName.insert(tool->name(), t); // init the menu option - QListWidgetItem *m_buttonItem = new QListWidgetItem(this); + QListWidgetItem* m_buttonItem = new QListWidgetItem(this); // when the background is lighter than gray, it uses the white icons QColor bgColor = this->palette().color(QWidget::backgroundRole()); m_buttonItem->setIcon(tool->icon(bgColor, false)); m_buttonItem->setFlags(Qt::ItemIsUserCheckable); - QColor foregroundColor = this->palette().color(QWidget::foregroundRole()); + QColor foregroundColor = + this->palette().color(QWidget::foregroundRole()); m_buttonItem->setForeground(foregroundColor); m_buttonItem->setText(tool->name()); @@ -57,15 +61,16 @@ void ButtonListView::initButtonList() { } } -void ButtonListView::updateActiveButtons(QListWidgetItem *item) { +void ButtonListView::updateActiveButtons(QListWidgetItem* item) +{ CaptureButton::ButtonType bType = m_buttonTypeByName[item->text()]; if (item->checkState() == Qt::Checked) { m_listButtons.append(bType); // TODO refactor so we don't need external sorts using bt = CaptureButton::ButtonType; - std::sort(m_listButtons.begin(), m_listButtons.end(), [](bt a, bt b){ + std::sort(m_listButtons.begin(), m_listButtons.end(), [](bt a, bt b) { return CaptureButton::getPriorityByButton(a) < - CaptureButton::getPriorityByButton(b); + CaptureButton::getPriorityByButton(b); }); } else { m_listButtons.remove(m_listButtons.indexOf(bType)); @@ -73,7 +78,8 @@ void ButtonListView::updateActiveButtons(QListWidgetItem *item) { ConfigHandler().setButtons(m_listButtons); } -void ButtonListView::reverseItemCheck(QListWidgetItem *item){ +void ButtonListView::reverseItemCheck(QListWidgetItem* item) +{ if (item->checkState() == Qt::Checked) { item->setCheckState(Qt::Unchecked); } else { @@ -82,18 +88,20 @@ void ButtonListView::reverseItemCheck(QListWidgetItem *item){ updateActiveButtons(item); } -void ButtonListView::selectAll() { +void ButtonListView::selectAll() +{ ConfigHandler().setAllTheButtons(); - for(int i = 0; i < this->count(); ++i) { + for (int i = 0; i < this->count(); ++i) { QListWidgetItem* item = this->item(i); item->setCheckState(Qt::Checked); } } -void ButtonListView::updateComponents() { +void ButtonListView::updateComponents() +{ m_listButtons = ConfigHandler().getButtons(); auto listTypes = CaptureButton::getIterableButtonTypes(); - for(int i = 0; i < this->count(); ++i) { + for (int i = 0; i < this->count(); ++i) { QListWidgetItem* item = this->item(i); auto elem = static_cast(listTypes.at(i)); if (m_listButtons.contains(elem)) { diff --git a/src/config/buttonlistview.h b/src/config/buttonlistview.h index 8449d85f..8cefeb6a 100644 --- a/src/config/buttonlistview.h +++ b/src/config/buttonlistview.h @@ -20,16 +20,17 @@ #include "src/widgets/capture/capturebutton.h" #include -class ButtonListView : public QListWidget { +class ButtonListView : public QListWidget +{ public: - explicit ButtonListView(QWidget *parent= nullptr); + explicit ButtonListView(QWidget* parent = nullptr); public slots: void selectAll(); void updateComponents(); private slots: - void reverseItemCheck(QListWidgetItem *); + void reverseItemCheck(QListWidgetItem*); protected: void initButtonList(); @@ -38,5 +39,5 @@ private: QVector m_listButtons; QMap m_buttonTypeByName; - void updateActiveButtons(QListWidgetItem *); + void updateActiveButtons(QListWidgetItem*); }; diff --git a/src/config/clickablelabel.cpp b/src/config/clickablelabel.cpp index 75bd146c..85f9d6ae 100644 --- a/src/config/clickablelabel.cpp +++ b/src/config/clickablelabel.cpp @@ -17,14 +17,17 @@ #include "clickablelabel.h" -ClickableLabel::ClickableLabel(QWidget *parent) : QLabel(parent) { +ClickableLabel::ClickableLabel(QWidget* parent) + : QLabel(parent) +{} -} - -ClickableLabel::ClickableLabel(QString s, QWidget *parent) : QLabel(parent) { +ClickableLabel::ClickableLabel(QString s, QWidget* parent) + : QLabel(parent) +{ setText(s); } -void ClickableLabel::mousePressEvent(QMouseEvent *) { +void ClickableLabel::mousePressEvent(QMouseEvent*) +{ emit clicked(); } diff --git a/src/config/clickablelabel.h b/src/config/clickablelabel.h index 3431ee5a..d5dcbe53 100644 --- a/src/config/clickablelabel.h +++ b/src/config/clickablelabel.h @@ -19,15 +19,16 @@ #include -class ClickableLabel : public QLabel { +class ClickableLabel : public QLabel +{ Q_OBJECT public: - explicit ClickableLabel(QWidget *parent = nullptr); - ClickableLabel(QString s, QWidget *parent = nullptr); + explicit ClickableLabel(QWidget* parent = nullptr); + ClickableLabel(QString s, QWidget* parent = nullptr); signals: void clicked(); private: - void mousePressEvent (QMouseEvent *); + void mousePressEvent(QMouseEvent*); }; diff --git a/src/config/extendedslider.cpp b/src/config/extendedslider.cpp index b7e7ac05..6d937c5c 100644 --- a/src/config/extendedslider.cpp +++ b/src/config/extendedslider.cpp @@ -17,34 +17,40 @@ #include "extendedslider.h" -ExtendedSlider::ExtendedSlider(QWidget *parent) - : QSlider(parent) +ExtendedSlider::ExtendedSlider(QWidget* parent) + : QSlider(parent) { - connect(this, &ExtendedSlider::valueChanged, - this, &ExtendedSlider::updateTooltip); - connect(this, &ExtendedSlider::sliderMoved, - this, &ExtendedSlider::fireTimer); + connect(this, + &ExtendedSlider::valueChanged, + this, + &ExtendedSlider::updateTooltip); + connect( + this, &ExtendedSlider::sliderMoved, this, &ExtendedSlider::fireTimer); m_timer.setSingleShot(true); - connect(&m_timer, &QTimer::timeout, - this, &ExtendedSlider::modificationsEnded); + connect( + &m_timer, &QTimer::timeout, this, &ExtendedSlider::modificationsEnded); } -int ExtendedSlider::mappedValue(int min, int max) { +int ExtendedSlider::mappedValue(int min, int max) +{ qreal progress = - ((value() - minimum())) / static_cast(maximum() - minimum()); + ((value() - minimum())) / static_cast(maximum() - minimum()); return min + (max - min) * progress; } -void ExtendedSlider::setMapedValue(int min, int val, int max) { +void ExtendedSlider::setMapedValue(int min, int val, int max) +{ qreal progress = ((val - min) + 1) / static_cast(max - min); int value = minimum() + (maximum() - minimum()) * progress; setValue(value); } -void ExtendedSlider::updateTooltip() { - setToolTip(QString::number(value())+"%"); +void ExtendedSlider::updateTooltip() +{ + setToolTip(QString::number(value()) + "%"); } -void ExtendedSlider::fireTimer() { +void ExtendedSlider::fireTimer() +{ m_timer.start(500); } diff --git a/src/config/extendedslider.h b/src/config/extendedslider.h index 9b0f5627..ea4a7608 100644 --- a/src/config/extendedslider.h +++ b/src/config/extendedslider.h @@ -20,10 +20,11 @@ #include #include -class ExtendedSlider : public QSlider { +class ExtendedSlider : public QSlider +{ Q_OBJECT public: - explicit ExtendedSlider(QWidget *parent = nullptr); + explicit ExtendedSlider(QWidget* parent = nullptr); int mappedValue(int min, int max); void setMapedValue(int min, int val, int max); diff --git a/src/config/filenameeditor.cpp b/src/config/filenameeditor.cpp index 46bc7c88..abbcc64d 100644 --- a/src/config/filenameeditor.cpp +++ b/src/config/filenameeditor.cpp @@ -16,21 +16,24 @@ // along with Flameshot. If not, see . #include "filenameeditor.h" -#include "src/utils/filenamehandler.h" -#include "src/utils/confighandler.h" #include "src/config/strftimechooserwidget.h" -#include +#include "src/utils/confighandler.h" +#include "src/utils/filenamehandler.h" #include -#include #include +#include #include +#include -FileNameEditor::FileNameEditor(QWidget *parent) : QWidget(parent) { +FileNameEditor::FileNameEditor(QWidget* parent) + : QWidget(parent) +{ initWidgets(); initLayout(); } -void FileNameEditor::initLayout() { +void FileNameEditor::initLayout() +{ m_layout = new QVBoxLayout(this); auto infoLabel = new QLabel(tr("Edit the name of your captures:"), this); infoLabel->setFixedHeight(20); @@ -41,14 +44,15 @@ void FileNameEditor::initLayout() { m_layout->addWidget(new QLabel(tr("Preview:"))); m_layout->addWidget(m_outputLabel); - QHBoxLayout *horizLayout = new QHBoxLayout(); + QHBoxLayout* horizLayout = new QHBoxLayout(); horizLayout->addWidget(m_saveButton); horizLayout->addWidget(m_resetButton); horizLayout->addWidget(m_clearButton); m_layout->addLayout(horizLayout); } -void FileNameEditor::initWidgets() { +void FileNameEditor::initWidgets() +{ m_nameHandler = new FileNameHandler(this); // editor @@ -61,55 +65,67 @@ void FileNameEditor::initWidgets() { QString foreground = this->palette().foreground().color().name(); m_outputLabel->setStyleSheet(QStringLiteral("color: %1").arg(foreground)); QPalette pal = m_outputLabel->palette(); - QColor color = pal.color(QPalette::Disabled, m_outputLabel->backgroundRole()); + QColor color = + pal.color(QPalette::Disabled, m_outputLabel->backgroundRole()); pal.setColor(QPalette::Active, m_outputLabel->backgroundRole(), color); m_outputLabel->setPalette(pal); - connect(m_nameEditor, &QLineEdit::textChanged, this, + connect(m_nameEditor, + &QLineEdit::textChanged, + this, &FileNameEditor::showParsedPattern); updateComponents(); // helper buttons m_helperButtons = new StrftimeChooserWidget(this); - connect(m_helperButtons, &StrftimeChooserWidget::variableEmitted, - this, &FileNameEditor::addToNameEditor); + connect(m_helperButtons, + &StrftimeChooserWidget::variableEmitted, + this, + &FileNameEditor::addToNameEditor); // save m_saveButton = new QPushButton(tr("Save"), this); - connect(m_saveButton, &QPushButton::clicked, this, &FileNameEditor::savePattern); + connect( + m_saveButton, &QPushButton::clicked, this, &FileNameEditor::savePattern); m_saveButton->setToolTip(tr("Saves the pattern")); // reset m_resetButton = new QPushButton(tr("Reset"), this); - connect(m_resetButton, &QPushButton::clicked, - this, &FileNameEditor::resetName); + connect( + m_resetButton, &QPushButton::clicked, this, &FileNameEditor::resetName); m_resetButton->setToolTip(tr("Restores the saved pattern")); // clear m_clearButton = new QPushButton(tr("Clear"), this); - connect(m_clearButton, &QPushButton::clicked, this, - [this](){ m_nameEditor->setText(QString()); + connect(m_clearButton, &QPushButton::clicked, this, [this]() { + m_nameEditor->setText(QString()); }); - m_clearButton->setToolTip(tr("Deletes the name"));} + m_clearButton->setToolTip(tr("Deletes the name")); +} -void FileNameEditor::savePattern() { +void FileNameEditor::savePattern() +{ QString pattern = m_nameEditor->text(); m_nameHandler->setPattern(pattern); } -void FileNameEditor::showParsedPattern(const QString &p) { +void FileNameEditor::showParsedPattern(const QString& p) +{ QString output = m_nameHandler->parseFilename(p); m_outputLabel->setText(output); } -void FileNameEditor::resetName() { +void FileNameEditor::resetName() +{ m_nameEditor->setText(ConfigHandler().filenamePatternValue()); } -void FileNameEditor::addToNameEditor(QString s) { +void FileNameEditor::addToNameEditor(QString s) +{ m_nameEditor->setText(m_nameEditor->text() + s); m_nameEditor->setFocus(); } -void FileNameEditor::updateComponents() { +void FileNameEditor::updateComponents() +{ m_nameEditor->setText(ConfigHandler().filenamePatternValue()); m_outputLabel->setText(m_nameHandler->parsedPattern()); } diff --git a/src/config/filenameeditor.h b/src/config/filenameeditor.h index d5668c07..bcaf42fe 100644 --- a/src/config/filenameeditor.h +++ b/src/config/filenameeditor.h @@ -17,8 +17,8 @@ #pragma once -#include #include +#include class QVBoxLayout; class QLineEdit; @@ -26,20 +26,21 @@ class FileNameHandler; class QPushButton; class StrftimeChooserWidget; -class FileNameEditor : public QWidget { +class FileNameEditor : public QWidget +{ Q_OBJECT public: - explicit FileNameEditor(QWidget *parent = nullptr); + explicit FileNameEditor(QWidget* parent = nullptr); private: - QVBoxLayout *m_layout; - QLineEdit *m_outputLabel; - QLineEdit *m_nameEditor; - FileNameHandler *m_nameHandler; - StrftimeChooserWidget *m_helperButtons; - QPushButton *m_saveButton; - QPushButton *m_resetButton; - QPushButton *m_clearButton; + QVBoxLayout* m_layout; + QLineEdit* m_outputLabel; + QLineEdit* m_nameEditor; + FileNameHandler* m_nameHandler; + StrftimeChooserWidget* m_helperButtons; + QPushButton* m_saveButton; + QPushButton* m_resetButton; + QPushButton* m_clearButton; void initLayout(); void initWidgets(); @@ -50,6 +51,6 @@ public slots: private slots: void savePattern(); - void showParsedPattern(const QString &); + void showParsedPattern(const QString&); void resetName(); }; diff --git a/src/config/filepathconfiguration.cpp b/src/config/filepathconfiguration.cpp index 278d6f18..4c197eaa 100644 --- a/src/config/filepathconfiguration.cpp +++ b/src/config/filepathconfiguration.cpp @@ -1,56 +1,69 @@ #include "filepathconfiguration.h" -#include "src/utils/filenamehandler.h" #include "src/config/strftimechooserwidget.h" #include "src/utils/confighandler.h" +#include "src/utils/filenamehandler.h" #include -#include #include -#include +#include #include -#include #include +#include #include -#include "src/utils/confighandler.h" +#include - -FilePathConfiguration::FilePathConfiguration(QWidget *parent) : QWidget(parent) { +FilePathConfiguration::FilePathConfiguration(QWidget* parent) + : QWidget(parent) +{ initWidgets(); initLayout(); } -void FilePathConfiguration::initLayout() { +void FilePathConfiguration::initLayout() +{ m_layout = new QVBoxLayout(this); m_layout->addWidget(new QLabel(tr("Screenshot path default:"))); m_layout->addWidget(m_screenshotPathFixed); m_layout->addWidget(m_screenshotPathFixedDefault); m_layout->addStretch(); - QHBoxLayout *horizScreenshotButtonsLayout = new QHBoxLayout(); + QHBoxLayout* horizScreenshotButtonsLayout = new QHBoxLayout(); horizScreenshotButtonsLayout->addStretch(); horizScreenshotButtonsLayout->addWidget(m_screenshotPathFixedClear); horizScreenshotButtonsLayout->addWidget(m_screenshotPathFixedBrowse); m_layout->addLayout(horizScreenshotButtonsLayout); } -void FilePathConfiguration::initWidgets() { +void FilePathConfiguration::initWidgets() +{ ConfigHandler config; // Screenshot path default - m_screenshotPathFixed = new QCheckBox(tr("Use fixed path for screenshots to save"), this); + m_screenshotPathFixed = + new QCheckBox(tr("Use fixed path for screenshots to save"), this); m_screenshotPathFixed->setChecked(!config.savePathFixed().isEmpty()); - connect(m_screenshotPathFixed, SIGNAL(toggled(bool)), this, SLOT(sreenshotPathFixed())); + connect(m_screenshotPathFixed, + SIGNAL(toggled(bool)), + this, + SLOT(sreenshotPathFixed())); m_screenshotPathFixedDefault = new QLineEdit(this); m_screenshotPathFixedDefault->setText(config.savePathFixed()); m_screenshotPathFixedDefault->setDisabled(config.savePathFixed().isEmpty()); m_screenshotPathFixedBrowse = new QPushButton(tr("Browse"), this); m_screenshotPathFixedBrowse->setDisabled(config.savePathFixed().isEmpty()); - connect(m_screenshotPathFixedBrowse, SIGNAL(released()),this, SLOT (screenshotPathFixedSet())); + connect(m_screenshotPathFixedBrowse, + SIGNAL(released()), + this, + SLOT(screenshotPathFixedSet())); m_screenshotPathFixedClear = new QPushButton(tr("Clear"), this); m_screenshotPathFixedClear->setDisabled(config.savePathFixed().isEmpty()); - connect(m_screenshotPathFixedClear, SIGNAL(released()),this, SLOT (screenshotPathFixedClear())); + connect(m_screenshotPathFixedClear, + SIGNAL(released()), + this, + SLOT(screenshotPathFixedClear())); } -void FilePathConfiguration::sreenshotPathFixed() { +void FilePathConfiguration::sreenshotPathFixed() +{ bool status = m_screenshotPathFixedDefault->isEnabled(); m_screenshotPathFixedDefault->setEnabled(!status); m_screenshotPathFixedBrowse->setEnabled(!status); @@ -58,8 +71,10 @@ void FilePathConfiguration::sreenshotPathFixed() { screenshotPathFixedClear(); } -void FilePathConfiguration::screenshotPathFixedSet() { - QFileDialog *dirDialog = new QFileDialog(this, tr("Select default path for Screenshots")); +void FilePathConfiguration::screenshotPathFixedSet() +{ + QFileDialog* dirDialog = + new QFileDialog(this, tr("Select default path for Screenshots")); dirDialog->setFileMode(QFileDialog::DirectoryOnly); dirDialog->setOption(QFileDialog::ShowDirsOnly, true); if (dirDialog->exec()) { @@ -71,7 +86,8 @@ void FilePathConfiguration::screenshotPathFixedSet() { } } -void FilePathConfiguration::screenshotPathFixedClear() { +void FilePathConfiguration::screenshotPathFixedClear() +{ ConfigHandler config; m_screenshotPathFixedDefault->setText(""); config.setSavePathFixed(m_screenshotPathFixedDefault->text()); diff --git a/src/config/filepathconfiguration.h b/src/config/filepathconfiguration.h index 0d4fc7fc..55b87859 100644 --- a/src/config/filepathconfiguration.h +++ b/src/config/filepathconfiguration.h @@ -9,17 +9,18 @@ class QCheckBox; class FileNameHandler; class QPushButton; -class FilePathConfiguration : public QWidget { +class FilePathConfiguration : public QWidget +{ Q_OBJECT public: - explicit FilePathConfiguration(QWidget *parent = nullptr); + explicit FilePathConfiguration(QWidget* parent = nullptr); private: - QVBoxLayout *m_layout; - QCheckBox *m_screenshotPathFixed; - QLineEdit *m_screenshotPathFixedDefault; - QPushButton *m_screenshotPathFixedBrowse; - QPushButton *m_screenshotPathFixedClear; + QVBoxLayout* m_layout; + QCheckBox* m_screenshotPathFixed; + QLineEdit* m_screenshotPathFixedDefault; + QPushButton* m_screenshotPathFixedBrowse; + QPushButton* m_screenshotPathFixedClear; void initLayout(); void initWidgets(); diff --git a/src/config/setshortcutwidget.cpp b/src/config/setshortcutwidget.cpp index 8aef7042..b191d27a 100644 --- a/src/config/setshortcutwidget.cpp +++ b/src/config/setshortcutwidget.cpp @@ -1,11 +1,12 @@ #include "setshortcutwidget.h" -#include -#include -#include #include +#include +#include +#include #include -SetShortcutDialog::SetShortcutDialog(QDialog *parent) : QDialog(parent) +SetShortcutDialog::SetShortcutDialog(QDialog* parent) + : QDialog(parent) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowIcon(QIcon(":img/app/flameshot.svg")); @@ -15,29 +16,32 @@ SetShortcutDialog::SetShortcutDialog(QDialog *parent) : QDialog(parent) m_layout = new QVBoxLayout(this); m_layout->setAlignment(Qt::AlignHCenter); - QLabel *infoTop = new QLabel(tr("Enter new shortcut to change ")); + QLabel* infoTop = new QLabel(tr("Enter new shortcut to change ")); infoTop->setMargin(10); infoTop->setAlignment(Qt::AlignCenter); m_layout->addWidget(infoTop); - QLabel *infoIcon = new QLabel(); + QLabel* infoIcon = new QLabel(); infoIcon->setAlignment(Qt::AlignCenter); infoIcon->setPixmap(QPixmap(":/img/app/keyboard.svg")); m_layout->addWidget(infoIcon); m_layout->addWidget(infoIcon); - QLabel *infoBottom = new QLabel(tr("Press Esc to cancel or Backspace to disable the keyboard shortcut.")); + QLabel* infoBottom = new QLabel( + tr("Press Esc to cancel or Backspace to disable the keyboard shortcut.")); infoBottom->setMargin(10); infoBottom->setAlignment(Qt::AlignCenter); m_layout->addWidget(infoBottom); } -const QKeySequence& SetShortcutDialog::shortcut() { +const QKeySequence& SetShortcutDialog::shortcut() +{ return m_ks; } -void SetShortcutDialog::keyPressEvent(QKeyEvent *ke) { +void SetShortcutDialog::keyPressEvent(QKeyEvent* ke) +{ if (ke->modifiers() & Qt::ShiftModifier) m_modifier += "Shift+"; if (ke->modifiers() & Qt::ControlModifier) @@ -51,7 +55,8 @@ void SetShortcutDialog::keyPressEvent(QKeyEvent *ke) { m_ks = QKeySequence(m_modifier + key); } -void SetShortcutDialog::keyReleaseEvent(QKeyEvent *event) { +void SetShortcutDialog::keyReleaseEvent(QKeyEvent* event) +{ if (m_ks == QKeySequence(Qt::Key_Escape)) { reject(); } diff --git a/src/config/setshortcutwidget.h b/src/config/setshortcutwidget.h index 156204d5..ba86df4c 100644 --- a/src/config/setshortcutwidget.h +++ b/src/config/setshortcutwidget.h @@ -1,28 +1,27 @@ #ifndef SETSHORTCUTWIDGET_H #define SETSHORTCUTWIDGET_H -#include #include #include +#include class QVBoxLayout; - class SetShortcutDialog : public QDialog { Q_OBJECT public: - explicit SetShortcutDialog(QDialog *parent = nullptr); + explicit SetShortcutDialog(QDialog* parent = nullptr); const QKeySequence& shortcut(); public: - void keyPressEvent(QKeyEvent *); - void keyReleaseEvent(QKeyEvent *event); + void keyPressEvent(QKeyEvent*); + void keyReleaseEvent(QKeyEvent* event); signals: private: - QVBoxLayout *m_layout; + QVBoxLayout* m_layout; QString m_modifier; QKeySequence m_ks; }; diff --git a/src/config/shortcutswidget.cpp b/src/config/shortcutswidget.cpp index 919b5b7e..64c6ca14 100644 --- a/src/config/shortcutswidget.cpp +++ b/src/config/shortcutswidget.cpp @@ -1,32 +1,33 @@ #include "shortcutswidget.h" #include "setshortcutwidget.h" -#include -#include -#include #include -#include +#include #include +#include #include +#include +#include #include #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) #include +#include #include #include -#include #endif #include - -ShortcutsWidget::ShortcutsWidget(QWidget *parent) : QWidget(parent) { +ShortcutsWidget::ShortcutsWidget(QWidget* parent) + : QWidget(parent) +{ setAttribute(Qt::WA_DeleteOnClose); setWindowIcon(QIcon(":img/app/flameshot.svg")); setWindowTitle(tr("Hot Keys")); #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) QRect position = frameGeometry(); - QScreen *screen = QGuiApplication::screenAt(QCursor::pos()); + QScreen* screen = QGuiApplication::screenAt(QCursor::pos()); position.moveCenter(screen->availableGeometry().center()); move(position.topLeft()); #endif @@ -39,11 +40,13 @@ ShortcutsWidget::ShortcutsWidget(QWidget *parent) : QWidget(parent) { show(); } -const QVector &ShortcutsWidget::shortcuts() { +const QVector& ShortcutsWidget::shortcuts() +{ return m_shortcuts; } -void ShortcutsWidget::initInfoTable() { +void ShortcutsWidget::initInfoTable() +{ m_table = new QTableWidget(this); m_table->setToolTip(tr("Available shortcuts in the screen capture mode.")); @@ -59,17 +62,20 @@ void ShortcutsWidget::initInfoTable() { QStringList names; names << tr("Description") << tr("Key"); m_table->setHorizontalHeaderLabels(names); - connect(m_table, SIGNAL(cellClicked(int, int)), this, SLOT(slotShortcutCellClicked(int, int))); + connect(m_table, + SIGNAL(cellClicked(int, int)), + this, + SLOT(slotShortcutCellClicked(int, int))); - //add content - for (int i= 0; i < shortcuts().size(); ++i){ + // add content + for (int i = 0; i < shortcuts().size(); ++i) { m_table->setItem(i, 0, new QTableWidgetItem(m_shortcuts.at(i).at(1))); QTableWidgetItem* item = new QTableWidgetItem(m_shortcuts.at(i).at(2)); - item->setTextAlignment( Qt::AlignCenter ); + item->setTextAlignment(Qt::AlignCenter); m_table->setItem(i, 1, item); - if( m_shortcuts.at(i).at(0).isEmpty() ) { + if (m_shortcuts.at(i).at(0).isEmpty()) { QFont font; font.setBold(true); item->setFont(font); @@ -81,7 +87,7 @@ void ShortcutsWidget::initInfoTable() { // Read-only table items for (int x = 0; x < m_table->rowCount(); ++x) { for (int y = 0; y < m_table->columnCount(); ++y) { - QTableWidgetItem *item = m_table->item(x, y); + QTableWidgetItem* item = m_table->item(x, y); item->setFlags(item->flags() ^ Qt::ItemIsEditable); } } @@ -97,14 +103,16 @@ void ShortcutsWidget::initInfoTable() { QSizePolicy::Expanding); } -void ShortcutsWidget::slotShortcutCellClicked(int row, int col) { +void ShortcutsWidget::slotShortcutCellClicked(int row, int col) +{ if (col == 1) { // Ignore non-changable shortcuts - if( Qt::ItemIsEnabled != (Qt::ItemIsEnabled & m_table->item(row, col)->flags()) ) { + if (Qt::ItemIsEnabled != + (Qt::ItemIsEnabled & m_table->item(row, col)->flags())) { return; } - SetShortcutDialog *setShortcutDialog = new SetShortcutDialog(); + SetShortcutDialog* setShortcutDialog = new SetShortcutDialog(); if (0 != setShortcutDialog->exec()) { QString shortcutName = m_shortcuts.at(row).at(0); QKeySequence shortcutValue = setShortcutDialog->shortcut(); @@ -115,8 +123,9 @@ void ShortcutsWidget::slotShortcutCellClicked(int row, int col) { } if (m_config.setShortcut(shortcutName, shortcutValue.toString())) { - QTableWidgetItem* item = new QTableWidgetItem(shortcutValue.toString()); - item->setTextAlignment( Qt::AlignCenter ); + QTableWidgetItem* item = + new QTableWidgetItem(shortcutValue.toString()); + item->setTextAlignment(Qt::AlignCenter); item->setFlags(item->flags() ^ Qt::ItemIsEditable); m_table->setItem(row, col, item); } diff --git a/src/config/shortcutswidget.h b/src/config/shortcutswidget.h index decdcb78..94410beb 100644 --- a/src/config/shortcutswidget.h +++ b/src/config/shortcutswidget.h @@ -2,10 +2,9 @@ #define HOTKEYSCONFIG_H #include "src/utils/confighandler.h" -#include -#include #include - +#include +#include class SetShortcutDialog; class QTableWidget; @@ -15,8 +14,8 @@ class ShortcutsWidget : public QWidget { Q_OBJECT public: - explicit ShortcutsWidget(QWidget *parent = nullptr); - const QVector &shortcuts(); + explicit ShortcutsWidget(QWidget* parent = nullptr); + const QVector& shortcuts(); private: void initInfoTable(); @@ -26,8 +25,8 @@ private slots: private: ConfigHandler m_config; - QTableWidget *m_table; - QVBoxLayout *m_layout; + QTableWidget* m_table; + QVBoxLayout* m_layout; QVector m_shortcuts; }; diff --git a/src/config/strftimechooserwidget.cpp b/src/config/strftimechooserwidget.cpp index 85507419..e415a077 100644 --- a/src/config/strftimechooserwidget.cpp +++ b/src/config/strftimechooserwidget.cpp @@ -16,53 +16,57 @@ // along with Flameshot. If not, see . #include "strftimechooserwidget.h" -#include #include +#include #include -StrftimeChooserWidget::StrftimeChooserWidget(QWidget *parent) : QWidget(parent) { - QGridLayout *layout = new QGridLayout(this); +StrftimeChooserWidget::StrftimeChooserWidget(QWidget* parent) + : QWidget(parent) +{ + QGridLayout* layout = new QGridLayout(this); auto k = m_buttonData.keys(); - int middle = k.length()/2; + int middle = k.length() / 2; // add the buttons in 2 columns (they need to be even) for (int i = 0; i < 2; i++) { for (int j = 0; j < middle; j++) { QString key = k.last(); k.pop_back(); QString variable = m_buttonData.value(key); - QPushButton *button = new QPushButton(this); + QPushButton* button = new QPushButton(this); button->setText(tr(key.toStdString().data())); button->setToolTip(variable); - button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + button->setSizePolicy(QSizePolicy::Expanding, + QSizePolicy::Expanding); button->setMinimumHeight(25); layout->addWidget(button, j, i); - connect(button, &QPushButton::clicked, - this, [variable, this](){emit variableEmitted(variable);}); + connect(button, &QPushButton::clicked, this, [variable, this]() { + emit variableEmitted(variable); + }); } } setLayout(layout); } -QMap StrftimeChooserWidget::m_buttonData { - { QT_TR_NOOP("Century (00-99)"), "%C"}, - { QT_TR_NOOP("Year (00-99)"), "%y"}, - { QT_TR_NOOP("Year (2000)"), "%Y"}, - { QT_TR_NOOP("Month Name (jan)"), "%b"}, - { QT_TR_NOOP("Month Name (january)"), "%B"}, - { QT_TR_NOOP("Month (01-12)"), "%m"}, - { QT_TR_NOOP("Week Day (1-7)"), "%u"}, - { QT_TR_NOOP("Week (01-53)"), "%V"}, - { QT_TR_NOOP("Day Name (mon)"), "%a"}, - { QT_TR_NOOP("Day Name (monday)"), "%A"}, - { QT_TR_NOOP("Day (01-31)"), "%d"}, - { QT_TR_NOOP("Day of Month (1-31)"), "%e"}, - { QT_TR_NOOP("Day (001-366)"), "%j"}, - { QT_TR_NOOP("Time (%H-%M-%S)"), "%T"}, - { QT_TR_NOOP("Time (%H-%M)"), "%R"}, - { QT_TR_NOOP("Hour (00-23)"), "%H"}, - { QT_TR_NOOP("Hour (01-12)"), "%I"}, - { QT_TR_NOOP("Minute (00-59)"), "%M"}, - { QT_TR_NOOP("Second (00-59)"), "%S"}, - { QT_TR_NOOP("Full Date (%m/%d/%y)"), "%D"}, - { QT_TR_NOOP("Full Date (%Y-%m-%d)"), "%F"}, +QMap StrftimeChooserWidget::m_buttonData{ + { QT_TR_NOOP("Century (00-99)"), "%C" }, + { QT_TR_NOOP("Year (00-99)"), "%y" }, + { QT_TR_NOOP("Year (2000)"), "%Y" }, + { QT_TR_NOOP("Month Name (jan)"), "%b" }, + { QT_TR_NOOP("Month Name (january)"), "%B" }, + { QT_TR_NOOP("Month (01-12)"), "%m" }, + { QT_TR_NOOP("Week Day (1-7)"), "%u" }, + { QT_TR_NOOP("Week (01-53)"), "%V" }, + { QT_TR_NOOP("Day Name (mon)"), "%a" }, + { QT_TR_NOOP("Day Name (monday)"), "%A" }, + { QT_TR_NOOP("Day (01-31)"), "%d" }, + { QT_TR_NOOP("Day of Month (1-31)"), "%e" }, + { QT_TR_NOOP("Day (001-366)"), "%j" }, + { QT_TR_NOOP("Time (%H-%M-%S)"), "%T" }, + { QT_TR_NOOP("Time (%H-%M)"), "%R" }, + { QT_TR_NOOP("Hour (00-23)"), "%H" }, + { QT_TR_NOOP("Hour (01-12)"), "%I" }, + { QT_TR_NOOP("Minute (00-59)"), "%M" }, + { QT_TR_NOOP("Second (00-59)"), "%S" }, + { QT_TR_NOOP("Full Date (%m/%d/%y)"), "%D" }, + { QT_TR_NOOP("Full Date (%Y-%m-%d)"), "%F" }, }; diff --git a/src/config/strftimechooserwidget.h b/src/config/strftimechooserwidget.h index 999df4c3..10a7dc80 100644 --- a/src/config/strftimechooserwidget.h +++ b/src/config/strftimechooserwidget.h @@ -19,13 +19,14 @@ #include -class StrftimeChooserWidget : public QWidget { +class StrftimeChooserWidget : public QWidget +{ Q_OBJECT public: - explicit StrftimeChooserWidget(QWidget *parent = nullptr); + explicit StrftimeChooserWidget(QWidget* parent = nullptr); signals: - void variableEmitted(const QString &); + void variableEmitted(const QString&); private: static QMap m_buttonData; diff --git a/src/config/uicoloreditor.cpp b/src/config/uicoloreditor.cpp index 1d580bd2..161b77dc 100644 --- a/src/config/uicoloreditor.cpp +++ b/src/config/uicoloreditor.cpp @@ -15,18 +15,20 @@ // You should have received a copy of the GNU General Public License // along with Flameshot. If not, see . -#include "src/utils/confighandler.h" #include "uicoloreditor.h" #include "clickablelabel.h" +#include "src/utils/confighandler.h" #include "src/utils/globalvalues.h" -#include #include -#include #include +#include #include #include +#include -UIcolorEditor::UIcolorEditor(QWidget *parent) : QGroupBox(parent) { +UIcolorEditor::UIcolorEditor(QWidget* parent) + : QGroupBox(parent) +{ setTitle(tr("UI Color Editor")); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_hLayout = new QHBoxLayout; @@ -46,7 +48,8 @@ UIcolorEditor::UIcolorEditor(QWidget *parent) : QGroupBox(parent) { updateComponents(); } -void UIcolorEditor::updateComponents() { +void UIcolorEditor::updateComponents() +{ ConfigHandler config; m_uiColor = config.uiMainColorValue(); m_contrastColor = config.uiContrastColorValue(); @@ -60,7 +63,8 @@ void UIcolorEditor::updateComponents() { } // updateUIcolor updates the appearance of the buttons -void UIcolorEditor::updateUIcolor() { +void UIcolorEditor::updateUIcolor() +{ ConfigHandler config; if (m_lastButtonPressed == m_buttonMainColor) { config.setUIMainColor(m_uiColor); @@ -70,7 +74,8 @@ void UIcolorEditor::updateUIcolor() { } // updateLocalColor updates the local button -void UIcolorEditor::updateLocalColor(const QColor c) { +void UIcolorEditor::updateLocalColor(const QColor c) +{ if (m_lastButtonPressed == m_buttonMainColor) { m_uiColor = c; } else { @@ -79,16 +84,21 @@ void UIcolorEditor::updateLocalColor(const QColor c) { m_lastButtonPressed->setColor(c); } -void UIcolorEditor::initColorWheel() { +void UIcolorEditor::initColorWheel() +{ m_colorWheel = new color_widgets::ColorWheel(this); - connect(m_colorWheel, &color_widgets::ColorWheel::mouseReleaseOnColor, this, + connect(m_colorWheel, + &color_widgets::ColorWheel::mouseReleaseOnColor, + this, &UIcolorEditor::updateUIcolor); - connect(m_colorWheel, &color_widgets::ColorWheel::colorChanged, this, + connect(m_colorWheel, + &color_widgets::ColorWheel::colorChanged, + this, &UIcolorEditor::updateLocalColor); const int size = GlobalValues::buttonBaseSize() * 3; m_colorWheel->setMinimumSize(size, size); - m_colorWheel->setMaximumSize(size*2, size*2); + m_colorWheel->setMaximumSize(size * 2, size * 2); m_colorWheel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_colorWheel->setToolTip(tr("Change the color moving the selectors and see" " the changes in the preview buttons.")); @@ -96,32 +106,34 @@ void UIcolorEditor::initColorWheel() { m_hLayout->addWidget(m_colorWheel); } -void UIcolorEditor::initButtons() { +void UIcolorEditor::initButtons() +{ const int extraSize = GlobalValues::buttonBaseSize() / 3; int frameSize = GlobalValues::buttonBaseSize() + extraSize; m_vLayout->addWidget(new QLabel(tr("Select a Button to modify it"), this)); - QGroupBox *frame = new QGroupBox(); + QGroupBox* frame = new QGroupBox(); frame->setFixedSize(frameSize, frameSize); m_buttonMainColor = new CaptureButton(m_buttonIconType, frame); - m_buttonMainColor->move(m_buttonMainColor->x() + extraSize/2, m_buttonMainColor->y() + extraSize/2); - QHBoxLayout *h1 = new QHBoxLayout(); + m_buttonMainColor->move(m_buttonMainColor->x() + extraSize / 2, + m_buttonMainColor->y() + extraSize / 2); + QHBoxLayout* h1 = new QHBoxLayout(); h1->addWidget(frame); m_labelMain = new ClickableLabel(tr("Main Color"), this); h1->addWidget(m_labelMain); m_vLayout->addLayout(h1); m_buttonMainColor->setToolTip(tr("Click on this button to set the edition" - " mode of the main color.")); + " mode of the main color.")); - QGroupBox *frame2 = new QGroupBox(); + QGroupBox* frame2 = new QGroupBox(); m_buttonContrast = new CaptureButton(m_buttonIconType, frame2); - m_buttonContrast->move(m_buttonContrast->x() + extraSize/2, - m_buttonContrast->y() + extraSize/2); + m_buttonContrast->move(m_buttonContrast->x() + extraSize / 2, + m_buttonContrast->y() + extraSize / 2); - QHBoxLayout *h2 = new QHBoxLayout(); + QHBoxLayout* h2 = new QHBoxLayout(); h2->addWidget(frame2); frame2->setFixedSize(frameSize, frameSize); m_labelContrast = new ClickableLabel(tr("Contrast Color"), this); @@ -130,22 +142,29 @@ void UIcolorEditor::initButtons() { m_vLayout->addLayout(h2); m_buttonContrast->setToolTip(tr("Click on this button to set the edition" - " mode of the contrast color.")); + " mode of the contrast color.")); - connect(m_buttonMainColor, &CaptureButton::pressedButton, - this, &UIcolorEditor::changeLastButton); - connect(m_buttonContrast, &CaptureButton::pressedButton, - this, &UIcolorEditor::changeLastButton); + connect(m_buttonMainColor, + &CaptureButton::pressedButton, + this, + &UIcolorEditor::changeLastButton); + connect(m_buttonContrast, + &CaptureButton::pressedButton, + this, + &UIcolorEditor::changeLastButton); // clicking the labels changes the button too - connect(m_labelMain, &ClickableLabel::clicked, - this, [this]{ changeLastButton(m_buttonMainColor); }); - connect(m_labelContrast, &ClickableLabel::clicked, - this, [this]{ changeLastButton(m_buttonContrast); }); + connect(m_labelMain, &ClickableLabel::clicked, this, [this] { + changeLastButton(m_buttonMainColor); + }); + connect(m_labelContrast, &ClickableLabel::clicked, this, [this] { + changeLastButton(m_buttonContrast); + }); m_lastButtonPressed = m_buttonMainColor; } // visual update for the selected button -void UIcolorEditor::changeLastButton(CaptureButton *b) { +void UIcolorEditor::changeLastButton(CaptureButton* b) +{ if (m_lastButtonPressed != b) { m_lastButtonPressed = b; diff --git a/src/config/uicoloreditor.h b/src/config/uicoloreditor.h index 3c5c555b..4b1f6f0a 100644 --- a/src/config/uicoloreditor.h +++ b/src/config/uicoloreditor.h @@ -26,10 +26,11 @@ class QHBoxLayout; class CaptureButton; class ClickableLabel; -class UIcolorEditor : public QGroupBox { +class UIcolorEditor : public QGroupBox +{ Q_OBJECT public: - explicit UIcolorEditor(QWidget *parent = nullptr); + explicit UIcolorEditor(QWidget* parent = nullptr); public slots: void updateComponents(); @@ -37,21 +38,22 @@ public slots: private slots: void updateUIcolor(); void updateLocalColor(const QColor); - void changeLastButton(CaptureButton *); + void changeLastButton(CaptureButton*); private: QColor m_uiColor, m_contrastColor; - CaptureButton *m_buttonMainColor; - ClickableLabel *m_labelMain; - CaptureButton *m_buttonContrast; - ClickableLabel *m_labelContrast; - CaptureButton *m_lastButtonPressed; - color_widgets::ColorWheel *m_colorWheel; + CaptureButton* m_buttonMainColor; + ClickableLabel* m_labelMain; + CaptureButton* m_buttonContrast; + ClickableLabel* m_labelContrast; + CaptureButton* m_lastButtonPressed; + color_widgets::ColorWheel* m_colorWheel; - static const CaptureButton::ButtonType m_buttonIconType = CaptureButton::TYPE_CIRCLE; + static const CaptureButton::ButtonType m_buttonIconType = + CaptureButton::TYPE_CIRCLE; - QHBoxLayout *m_hLayout; - QVBoxLayout *m_vLayout; + QHBoxLayout* m_hLayout; + QVBoxLayout* m_vLayout; void initColorWheel(); void initButtons(); diff --git a/src/config/visualseditor.cpp b/src/config/visualseditor.cpp index 8ca77c80..7a587e81 100644 --- a/src/config/visualseditor.cpp +++ b/src/config/visualseditor.cpp @@ -17,44 +17,50 @@ #include "visualseditor.h" #include "src/config/buttonlistview.h" +#include "src/config/extendedslider.h" #include "src/config/uicoloreditor.h" #include "src/utils/confighandler.h" -#include "src/config/extendedslider.h" +#include #include #include -#include -VisualsEditor::VisualsEditor(QWidget *parent) : QWidget(parent) { - m_layout= new QVBoxLayout(); +VisualsEditor::VisualsEditor(QWidget* parent) + : QWidget(parent) +{ + m_layout = new QVBoxLayout(); setLayout(m_layout); initWidgets(); } -void VisualsEditor::updateComponents() { +void VisualsEditor::updateComponents() +{ m_buttonList->updateComponents(); m_colorEditor->updateComponents(); int opacity = ConfigHandler().contrastOpacityValue(); m_opacitySlider->setMapedValue(0, opacity, 255); } -void VisualsEditor::initOpacitySlider() { +void VisualsEditor::initOpacitySlider() +{ m_opacitySlider = new ExtendedSlider(); m_opacitySlider->setFocusPolicy(Qt::NoFocus); m_opacitySlider->setOrientation(Qt::Horizontal); m_opacitySlider->setRange(0, 100); - connect(m_opacitySlider, &ExtendedSlider::modificationsEnded, - this, &VisualsEditor::saveOpacity); - QHBoxLayout *localLayout = new QHBoxLayout(); + connect(m_opacitySlider, + &ExtendedSlider::modificationsEnded, + this, + &VisualsEditor::saveOpacity); + QHBoxLayout* localLayout = new QHBoxLayout(); localLayout->addWidget(new QLabel(QStringLiteral("0%"))); localLayout->addWidget(m_opacitySlider); localLayout->addWidget(new QLabel(QStringLiteral("100%"))); - QLabel *label = new QLabel(); + QLabel* label = new QLabel(); QString labelMsg = tr("Opacity of area outside selection:") + " %1%"; - connect(m_opacitySlider, &ExtendedSlider::valueChanged, - this, [labelMsg, label](int val){ - label->setText(labelMsg.arg(val)); - }); + connect(m_opacitySlider, + &ExtendedSlider::valueChanged, + this, + [labelMsg, label](int val) { label->setText(labelMsg.arg(val)); }); m_layout->addWidget(label); m_layout->addLayout(localLayout); @@ -62,12 +68,14 @@ void VisualsEditor::initOpacitySlider() { m_opacitySlider->setMapedValue(0, opacity, 255); } -void VisualsEditor::saveOpacity() { +void VisualsEditor::saveOpacity() +{ int value = m_opacitySlider->mappedValue(0, 255); ConfigHandler().setContrastOpacity(value); } -void VisualsEditor::initWidgets() { +void VisualsEditor::initWidgets() +{ m_colorEditor = new UIcolorEditor(); m_layout->addWidget(m_colorEditor); @@ -81,7 +89,9 @@ void VisualsEditor::initWidgets() { listLayout->addWidget(m_buttonList); QPushButton* setAllButtons = new QPushButton(tr("Select All")); - connect(setAllButtons, &QPushButton::clicked, - m_buttonList, &ButtonListView::selectAll); + connect(setAllButtons, + &QPushButton::clicked, + m_buttonList, + &ButtonListView::selectAll); listLayout->addWidget(setAllButtons); } diff --git a/src/config/visualseditor.h b/src/config/visualseditor.h index 85da7856..2458e973 100644 --- a/src/config/visualseditor.h +++ b/src/config/visualseditor.h @@ -24,10 +24,11 @@ class QVBoxLayout; class ButtonListView; class UIcolorEditor; -class VisualsEditor : public QWidget { +class VisualsEditor : public QWidget +{ Q_OBJECT public: - explicit VisualsEditor(QWidget *parent = nullptr); + explicit VisualsEditor(QWidget* parent = nullptr); public slots: void updateComponents(); @@ -36,10 +37,10 @@ private slots: void saveOpacity(); private: - QVBoxLayout *m_layout; - ButtonListView *m_buttonList; - UIcolorEditor *m_colorEditor; - ExtendedSlider *m_opacitySlider; + QVBoxLayout* m_layout; + ButtonListView* m_buttonList; + UIcolorEditor* m_colorEditor; + ExtendedSlider* m_opacitySlider; void initWidgets(); void initOpacitySlider(); diff --git a/src/core/capturerequest.cpp b/src/core/capturerequest.cpp index 3c174a6d..b58bfcb5 100644 --- a/src/core/capturerequest.cpp +++ b/src/core/capturerequest.cpp @@ -17,60 +17,72 @@ #include "capturerequest.h" #include "src/utils/screenshotsaver.h" -#include #include +#include CaptureRequest::CaptureRequest(CaptureRequest::CaptureMode mode, - const uint delay, const QString &path, - const QVariant &data, - CaptureRequest::ExportTask tasks) : - m_mode(mode), m_delay(delay), m_path(path), m_tasks(tasks), - m_data(data), m_forcedID(false), m_id(0) + const uint delay, + const QString& path, + const QVariant& data, + CaptureRequest::ExportTask tasks) + : m_mode(mode) + , m_delay(delay) + , m_path(path) + , m_tasks(tasks) + , m_data(data) + , m_forcedID(false) + , m_id(0) +{} + +void CaptureRequest::setStaticID(uint id) { - -} - -void CaptureRequest::setStaticID(uint id) { m_forcedID = true; m_id = id; } -uint CaptureRequest::id() const { +uint CaptureRequest::id() const +{ if (m_forcedID) { return m_id; } uint id = 0; - QVectorv; + QVector v; v << qHash(m_mode) << qHash(m_delay * QDateTime::currentMSecsSinceEpoch()) << qHash(m_path) << qHash(m_tasks) << m_data.toInt(); - for(uint i : v) { + for (uint i : v) { id ^= i + 0x9e3779b9 + (id << 6) + (id >> 2); } return id; } -CaptureRequest::CaptureMode CaptureRequest::captureMode() const { +CaptureRequest::CaptureMode CaptureRequest::captureMode() const +{ return m_mode; } -uint CaptureRequest::delay() const { +uint CaptureRequest::delay() const +{ return m_delay; } -QString CaptureRequest::path() const { +QString CaptureRequest::path() const +{ return m_path; } -QVariant CaptureRequest::data() const { +QVariant CaptureRequest::data() const +{ return m_data; } -void CaptureRequest::addTask(CaptureRequest::ExportTask task) { +void CaptureRequest::addTask(CaptureRequest::ExportTask task) +{ m_tasks |= task; } -void CaptureRequest::exportCapture(const QPixmap &p) { +void CaptureRequest::exportCapture(const QPixmap& p) +{ if ((m_tasks & ExportTask::FILESYSTEM_SAVE_TASK) != ExportTask::NO_TASK) { if (m_path.isEmpty()) { ScreenshotSaver().saveToFilesystemGUI(p); @@ -82,5 +94,4 @@ void CaptureRequest::exportCapture(const QPixmap &p) { if ((m_tasks & ExportTask::CLIPBOARD_SAVE_TASK) != ExportTask::NO_TASK) { ScreenshotSaver().saveToClipboard(p); } - } diff --git a/src/core/capturerequest.h b/src/core/capturerequest.h index f500fa60..649c5a86 100644 --- a/src/core/capturerequest.h +++ b/src/core/capturerequest.h @@ -17,19 +17,22 @@ #pragma once -#include #include +#include #include -class CaptureRequest { +class CaptureRequest +{ public: - enum CaptureMode { + enum CaptureMode + { FULLSCREEN_MODE, GRAPHICAL_MODE, SCREEN_MODE, }; - enum ExportTask { + enum ExportTask + { NO_TASK = 0, CLIPBOARD_SAVE_TASK = 1, FILESYSTEM_SAVE_TASK = 2, @@ -37,8 +40,8 @@ public: CaptureRequest(CaptureMode mode, const uint delay = 0, - const QString &path = QLatin1String(""), - const QVariant &data = QVariant(), + const QString& path = QLatin1String(""), + const QVariant& data = QVariant(), ExportTask tasks = NO_TASK); void setStaticID(uint id); @@ -50,7 +53,7 @@ public: CaptureMode captureMode() const; void addTask(ExportTask task); - void exportCapture(const QPixmap &p); + void exportCapture(const QPixmap& p); private: CaptureMode m_mode; @@ -65,16 +68,18 @@ private: using eTask = CaptureRequest::ExportTask; -inline eTask operator|(const eTask &a, const eTask &b) { +inline eTask operator|(const eTask& a, const eTask& b) +{ return static_cast(static_cast(a) | static_cast(b)); } -inline eTask operator&(const eTask &a, const eTask &b) { +inline eTask operator&(const eTask& a, const eTask& b) +{ return static_cast(static_cast(a) & static_cast(b)); } -inline eTask& operator|=(eTask &a, const eTask &b) { +inline eTask& operator|=(eTask& a, const eTask& b) +{ a = static_cast(static_cast(a) | static_cast(b)); return a; } - diff --git a/src/core/controller.cpp b/src/core/controller.cpp index e6934991..9b6f4e69 100644 --- a/src/core/controller.cpp +++ b/src/core/controller.cpp @@ -16,25 +16,25 @@ // along with Flameshot. If not, see . #include "controller.h" -#include "src/widgets/capture/capturewidget.h" -#include "src/utils/confighandler.h" -#include "src/widgets/infowindow.h" #include "src/config/configwindow.h" -#include "src/widgets/capture/capturebutton.h" -#include "src/widgets/capturelauncher.h" -#include "src/widgets/notificationwidget.h" -#include "src/utils/systemnotification.h" -#include "src/utils/screengrabber.h" -#include "src/utils/history.h" #include "src/utils/configenterprise.h" +#include "src/utils/confighandler.h" +#include "src/utils/history.h" +#include "src/utils/screengrabber.h" +#include "src/utils/systemnotification.h" +#include "src/widgets/capture/capturebutton.h" +#include "src/widgets/capture/capturewidget.h" +#include "src/widgets/capturelauncher.h" #include "src/widgets/historywidget.h" -#include -#include -#include +#include "src/widgets/infowindow.h" +#include "src/widgets/notificationwidget.h" #include -#include -#include +#include #include +#include +#include +#include +#include #ifdef Q_OS_WIN #include "src/core/globalshortcutfilter.h" @@ -43,7 +43,9 @@ // Controller is the core component of Flameshot, creates the trayIcon and // launches the capture widget -Controller::Controller() : m_captureWindow(nullptr) { +Controller::Controller() + : m_captureWindow(nullptr) +{ qApp->setQuitOnLastWindowClosed(false); // set default shortcusts if not set yet @@ -57,10 +59,9 @@ Controller::Controller() : m_captureWindow(nullptr) { #elif defined(Q_OS_WIN) enableTrayIcon(); - GlobalShortcutFilter *nativeFilter = new GlobalShortcutFilter(this); + GlobalShortcutFilter* nativeFilter = new GlobalShortcutFilter(this); qApp->installNativeEventFilter(nativeFilter); - connect(nativeFilter, &GlobalShortcutFilter::printPressed, - this, [this](){ + connect(nativeFilter, &GlobalShortcutFilter::printPressed, this, [this]() { this->requestCapture(CaptureRequest(CaptureRequest::GRAPHICAL_MODE)); }); #endif @@ -69,50 +70,57 @@ Controller::Controller() : m_captureWindow(nullptr) { qApp->setStyleSheet(StyleSheet); } -Controller *Controller::getInstance() { +Controller* Controller::getInstance() +{ static Controller c; return &c; } -void Controller::enableExports() { - connect(this, &Controller::captureTaken, - this, &Controller::handleCaptureTaken); - connect(this, &Controller::captureFailed, - this, &Controller::handleCaptureFailed); +void Controller::enableExports() +{ + connect( + this, &Controller::captureTaken, this, &Controller::handleCaptureTaken); + connect( + this, &Controller::captureFailed, this, &Controller::handleCaptureFailed); } -void Controller::requestCapture(const CaptureRequest &request) { +void Controller::requestCapture(const CaptureRequest& request) +{ uint id = request.id(); m_requestMap.insert(id, request); switch (request.captureMode()) { - case CaptureRequest::FULLSCREEN_MODE: - doLater(request.delay(), this, [this, id](){ - this->startFullscreenCapture(id); - }); - break; - case CaptureRequest::SCREEN_MODE: { - int &&number = request.data().toInt(); - doLater(request.delay(), this, [this, id, number](){ - this->startScreenGrab(id, number); - }); - break; - } case CaptureRequest::GRAPHICAL_MODE: { - QString &&path = request.path(); - doLater(request.delay(), this, [this, id, path](){ - this->startVisualCapture(id, path); - }); - break; - } default: - emit captureFailed(id); - break; + case CaptureRequest::FULLSCREEN_MODE: + doLater(request.delay(), this, [this, id]() { + this->startFullscreenCapture(id); + }); + break; + case CaptureRequest::SCREEN_MODE: { + int&& number = request.data().toInt(); + doLater(request.delay(), this, [this, id, number]() { + this->startScreenGrab(id, number); + }); + break; + } + case CaptureRequest::GRAPHICAL_MODE: { + QString&& path = request.path(); + doLater(request.delay(), this, [this, id, path]() { + this->startVisualCapture(id, path); + }); + break; + } + default: + emit captureFailed(id); + break; } } // creation of a new capture in GUI mode -void Controller::startVisualCapture(const uint id, const QString &forcedSavePath) { +void Controller::startVisualCapture(const uint id, + const QString& forcedSavePath) +{ if (!m_captureWindow) { - QWidget *modalWidget = nullptr; + QWidget* modalWidget = nullptr; do { modalWidget = qApp->activeModalWidget(); if (modalWidget) { @@ -122,24 +130,30 @@ void Controller::startVisualCapture(const uint id, const QString &forcedSavePath } while (modalWidget); m_captureWindow = new CaptureWidget(id, forcedSavePath); - //m_captureWindow = new CaptureWidget(id, forcedSavePath, false); // debug - connect(m_captureWindow, &CaptureWidget::captureFailed, - this, &Controller::captureFailed); - connect(m_captureWindow, &CaptureWidget::captureTaken, - this, &Controller::captureTaken); + // m_captureWindow = new CaptureWidget(id, forcedSavePath, false); // + // debug + connect(m_captureWindow, + &CaptureWidget::captureFailed, + this, + &Controller::captureFailed); + connect(m_captureWindow, + &CaptureWidget::captureTaken, + this, + &Controller::captureTaken); #ifdef Q_OS_WIN m_captureWindow->show(); #else m_captureWindow->showFullScreen(); - //m_captureWindow->show(); // Debug + // m_captureWindow->show(); // Debug #endif } else { emit captureFailed(id); } } -void Controller::startScreenGrab(const uint id, const int screenNumber) { +void Controller::startScreenGrab(const uint id, const int screenNumber) +{ bool ok = true; int n = screenNumber; @@ -156,7 +170,8 @@ void Controller::startScreenGrab(const uint id, const int screenNumber) { } // creation of the configuration window -void Controller::openConfigWindow() { +void Controller::openConfigWindow() +{ if (!m_configWindow) { m_configWindow = new ConfigWindow(); m_configWindow->show(); @@ -164,46 +179,50 @@ void Controller::openConfigWindow() { } // creation of the window of information -void Controller::openInfoWindow() { +void Controller::openInfoWindow() +{ if (!m_infoWindow) { m_infoWindow = new InfoWindow(); } } -void Controller::openLauncherWindow() { - CaptureLauncher *w = new CaptureLauncher(); +void Controller::openLauncherWindow() +{ + CaptureLauncher* w = new CaptureLauncher(); w->show(); } -void Controller::enableTrayIcon() { +void Controller::enableTrayIcon() +{ if (m_trayIcon) { return; } - QMenu *trayIconMenu = new QMenu(); + QMenu* trayIconMenu = new QMenu(); ConfigHandler().setDisabledTrayIcon(false); - QAction *captureAction = new QAction(tr("&Take Screenshot"), this); - connect(captureAction, &QAction::triggered, this, [this](){ + QAction* captureAction = new QAction(tr("&Take Screenshot"), this); + connect(captureAction, &QAction::triggered, this, [this]() { // Wait 400 ms to hide the QMenu - doLater(400, this, [this](){ this->startVisualCapture(); }); + doLater(400, this, [this]() { this->startVisualCapture(); }); }); - QAction *launcherAction = new QAction(tr("&Open Launcher"), this); - connect(launcherAction, &QAction::triggered, this, + QAction* launcherAction = new QAction(tr("&Open Launcher"), this); + connect(launcherAction, + &QAction::triggered, + this, &Controller::openLauncherWindow); - QAction *configAction = new QAction(tr("&Configuration"), this); - connect(configAction, &QAction::triggered, this, - &Controller::openConfigWindow); - QAction *infoAction = new QAction(tr("&Information"), this); - connect(infoAction, &QAction::triggered, this, - &Controller::openInfoWindow); - QAction *quitAction = new QAction(tr("&Quit"), this); - connect(quitAction, &QAction::triggered, qApp, - &QCoreApplication::quit); + QAction* configAction = new QAction(tr("&Configuration"), this); + connect( + configAction, &QAction::triggered, this, &Controller::openConfigWindow); + QAction* infoAction = new QAction(tr("&Information"), this); + connect(infoAction, &QAction::triggered, this, &Controller::openInfoWindow); + QAction* quitAction = new QAction(tr("&Quit"), this); + connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit); // recent screenshots - QAction *recentAction = new QAction(tr("&Latest Uploads"), this); - connect(recentAction, SIGNAL(triggered()), this, SLOT(showRecentScreenshots())); + QAction* recentAction = new QAction(tr("&Latest Uploads"), this); + connect( + recentAction, SIGNAL(triggered()), this, SLOT(showRecentScreenshots())); // generate menu trayIconMenu->addAction(captureAction); @@ -219,10 +238,11 @@ void Controller::enableTrayIcon() { m_trayIcon = new QSystemTrayIcon(); m_trayIcon->setToolTip(QStringLiteral("Flameshot")); m_trayIcon->setContextMenu(trayIconMenu); - QIcon trayicon = QIcon::fromTheme("flameshot-tray", QIcon(":img/app/flameshot.png")); + QIcon trayicon = + QIcon::fromTheme("flameshot-tray", QIcon(":img/app/flameshot.png")); m_trayIcon->setIcon(trayicon); - auto trayIconActivated = [this](QSystemTrayIcon::ActivationReason r){ + auto trayIconActivated = [this](QSystemTrayIcon::ActivationReason r) { if (r == QSystemTrayIcon::Trigger) { startVisualCapture(); } @@ -230,14 +250,18 @@ void Controller::enableTrayIcon() { connect(m_trayIcon, &QSystemTrayIcon::activated, this, trayIconActivated); m_trayIcon->show(); if (ConfigHandler().showStartupLaunchMessage()) { - m_trayIcon->showMessage("Flameshot", - QObject::tr("Hello, I'm here! Click icon in the tray to take a screenshot or click with a right button to see more options."), - QSystemTrayIcon::Information, - 3000); + m_trayIcon->showMessage( + "Flameshot", + QObject::tr( + "Hello, I'm here! Click icon in the tray to take a screenshot or " + "click with a right button to see more options."), + QSystemTrayIcon::Information, + 3000); } } -void Controller::disableTrayIcon() { +void Controller::disableTrayIcon() +{ #if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) if (m_trayIcon) { m_trayIcon->deleteLater(); @@ -246,28 +270,31 @@ void Controller::disableTrayIcon() { #endif } -void Controller::sendTrayNotification( - const QString &text, - const QString &title, - const int timeout) +void Controller::sendTrayNotification(const QString& text, + const QString& title, + const int timeout) { if (m_trayIcon) { - m_trayIcon->showMessage(title, text, QSystemTrayIcon::Information, timeout); + m_trayIcon->showMessage( + title, text, QSystemTrayIcon::Information, timeout); } } -void Controller::updateConfigComponents() { +void Controller::updateConfigComponents() +{ if (m_configWindow) { m_configWindow->updateChildren(); } } -void Controller::showRecentScreenshots() { - HistoryWidget *pHistory = new HistoryWidget(); +void Controller::showRecentScreenshots() +{ + HistoryWidget* pHistory = new HistoryWidget(); pHistory->exec(); } -void Controller::startFullscreenCapture(const uint id) { +void Controller::startFullscreenCapture(const uint id) +{ bool ok = true; QPixmap p(ScreenGrabber().grabEntireDesktop(ok)); if (ok) { @@ -277,7 +304,8 @@ void Controller::startFullscreenCapture(const uint id) { } } -void Controller::handleCaptureTaken(uint id, QPixmap p) { +void Controller::handleCaptureTaken(uint id, QPixmap p) +{ auto it = m_requestMap.find(id); if (it != m_requestMap.end()) { it.value().exportCapture(p); @@ -288,7 +316,8 @@ void Controller::handleCaptureTaken(uint id, QPixmap p) { } } -void Controller::handleCaptureFailed(uint id) { +void Controller::handleCaptureFailed(uint id) +{ m_requestMap.remove(id); if (ConfigHandler().closeAfterScreenshotValue()) { @@ -296,10 +325,13 @@ void Controller::handleCaptureFailed(uint id) { } } -void Controller::doLater(int msec, QObject *receiver, lambda func) { - QTimer *timer = new QTimer(receiver); - QObject::connect(timer, &QTimer::timeout, receiver, - [timer, func](){ func(); timer->deleteLater(); }); +void Controller::doLater(int msec, QObject* receiver, lambda func) +{ + QTimer* timer = new QTimer(receiver); + QObject::connect(timer, &QTimer::timeout, receiver, [timer, func]() { + func(); + timer->deleteLater(); + }); timer->setInterval(msec); timer->start(); } diff --git a/src/core/controller.h b/src/core/controller.h index 8bacb7b9..299133b4 100644 --- a/src/core/controller.h +++ b/src/core/controller.h @@ -18,10 +18,10 @@ #pragma once #include "src/core/capturerequest.h" -#include -#include -#include #include +#include +#include +#include #include #include @@ -32,14 +32,15 @@ class QSystemTrayIcon; using lambda = std::function; -class Controller : public QObject { +class Controller : public QObject +{ Q_OBJECT public: static Controller* getInstance(); Controller(const Controller&) = delete; - void operator =(const Controller&) = delete; + void operator=(const Controller&) = delete; void enableExports(); @@ -48,16 +49,17 @@ signals: void captureFailed(uint id); public slots: - void requestCapture(const CaptureRequest &request); + void requestCapture(const CaptureRequest& request); void openConfigWindow(); void openInfoWindow(); void openLauncherWindow(); void enableTrayIcon(); void disableTrayIcon(); - void sendTrayNotification(const QString &text, - const QString &title = QStringLiteral("Flameshot Info"), - const int timeout = 5000); + void sendTrayNotification( + const QString& text, + const QString& title = QStringLiteral("Flameshot Info"), + const int timeout = 5000); void updateConfigComponents(); @@ -66,7 +68,7 @@ public slots: private slots: void startFullscreenCapture(const uint id = 0); void startVisualCapture(const uint id = 0, - const QString &forcedSavePath = QString()); + const QString& forcedSavePath = QString()); void startScreenGrab(const uint id = 0, const int screenNumber = -1); void handleCaptureTaken(uint id, QPixmap p); @@ -77,7 +79,7 @@ private: // replace QTimer::singleShot introduced in Qt 5.4 // the actual target Qt version is 5.3 - void doLater(int msec, QObject *receiver, lambda func); + void doLater(int msec, QObject* receiver, lambda func); QMap m_requestMap; QPointer m_captureWindow; diff --git a/src/core/flameshotdbusadapter.cpp b/src/core/flameshotdbusadapter.cpp index 44b3fb20..ff494c03 100644 --- a/src/core/flameshotdbusadapter.cpp +++ b/src/core/flameshotdbusadapter.cpp @@ -16,37 +16,42 @@ // along with Flameshot. If not, see . #include "flameshotdbusadapter.h" +#include "src/core/controller.h" #include "src/utils/confighandler.h" #include "src/utils/screengrabber.h" -#include "src/core/controller.h" #include "src/utils/screenshotsaver.h" #include "src/utils/systemnotification.h" #include -FlameshotDBusAdapter::FlameshotDBusAdapter(QObject *parent) - : QDBusAbstractAdaptor(parent) +FlameshotDBusAdapter::FlameshotDBusAdapter(QObject* parent) + : QDBusAbstractAdaptor(parent) { - auto controller = Controller::getInstance(); - connect(controller, &Controller::captureFailed, - this, &FlameshotDBusAdapter::captureFailed); - connect(controller, &Controller::captureTaken, - this, &FlameshotDBusAdapter::handleCaptureTaken); + auto controller = Controller::getInstance(); + connect(controller, + &Controller::captureFailed, + this, + &FlameshotDBusAdapter::captureFailed); + connect(controller, + &Controller::captureTaken, + this, + &FlameshotDBusAdapter::handleCaptureTaken); } -FlameshotDBusAdapter::~FlameshotDBusAdapter() { +FlameshotDBusAdapter::~FlameshotDBusAdapter() {} -} - -void FlameshotDBusAdapter::graphicCapture(QString path, int delay, uint id) { +void FlameshotDBusAdapter::graphicCapture(QString path, int delay, uint id) +{ CaptureRequest req(CaptureRequest::GRAPHICAL_MODE, delay, path); -// if (toClipboard) { -// req.addTask(CaptureRequest::CLIPBOARD_SAVE_TASK); -// } + // if (toClipboard) { + // req.addTask(CaptureRequest::CLIPBOARD_SAVE_TASK); + // } req.setStaticID(id); Controller::getInstance()->requestCapture(req); } -void FlameshotDBusAdapter::fullScreen( - QString path, bool toClipboard, int delay, uint id) +void FlameshotDBusAdapter::fullScreen(QString path, + bool toClipboard, + int delay, + uint id) { CaptureRequest req(CaptureRequest::FULLSCREEN_MODE, delay, path); if (toClipboard) { @@ -59,12 +64,16 @@ void FlameshotDBusAdapter::fullScreen( Controller::getInstance()->requestCapture(req); } -void FlameshotDBusAdapter::openLauncher() { +void FlameshotDBusAdapter::openLauncher() +{ Controller::getInstance()->openLauncherWindow(); } -void FlameshotDBusAdapter::captureScreen(int number, QString path, - bool toClipboard, int delay, uint id) +void FlameshotDBusAdapter::captureScreen(int number, + QString path, + bool toClipboard, + int delay, + uint id) { CaptureRequest req(CaptureRequest::SCREEN_MODE, delay, path, number); if (toClipboard) { @@ -77,12 +86,14 @@ void FlameshotDBusAdapter::captureScreen(int number, QString path, Controller::getInstance()->requestCapture(req); } -void FlameshotDBusAdapter::openConfig() { +void FlameshotDBusAdapter::openConfig() +{ Controller::getInstance()->openConfigWindow(); } -void FlameshotDBusAdapter::trayIconEnabled(bool enabled) { - auto controller = Controller::getInstance(); +void FlameshotDBusAdapter::trayIconEnabled(bool enabled) +{ + auto controller = Controller::getInstance(); if (enabled) { controller->enableTrayIcon(); } else { @@ -90,14 +101,16 @@ void FlameshotDBusAdapter::trayIconEnabled(bool enabled) { } } -void FlameshotDBusAdapter::autostartEnabled(bool enabled) { +void FlameshotDBusAdapter::autostartEnabled(bool enabled) +{ ConfigHandler().setStartupLaunch(enabled); - auto controller = Controller::getInstance(); + auto controller = Controller::getInstance(); // Autostart is not saved in a .ini file, requires manual update controller->updateConfigComponents(); } -void FlameshotDBusAdapter::handleCaptureTaken(uint id, const QPixmap &p) { +void FlameshotDBusAdapter::handleCaptureTaken(uint id, const QPixmap& p) +{ QByteArray byteArray; QBuffer buffer(&byteArray); p.save(&buffer, "PNG"); diff --git a/src/core/flameshotdbusadapter.h b/src/core/flameshotdbusadapter.h index 90063593..873e1428 100644 --- a/src/core/flameshotdbusadapter.h +++ b/src/core/flameshotdbusadapter.h @@ -17,15 +17,16 @@ #pragma once -#include #include "src/core/controller.h" +#include -class FlameshotDBusAdapter : public QDBusAbstractAdaptor { +class FlameshotDBusAdapter : public QDBusAbstractAdaptor +{ Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.dharkael.Flameshot") public: - explicit FlameshotDBusAdapter(QObject *parent = nullptr); + explicit FlameshotDBusAdapter(QObject* parent = nullptr); virtual ~FlameshotDBusAdapter(); signals: @@ -34,13 +35,20 @@ signals: public slots: Q_NOREPLY void graphicCapture(QString path, int delay, uint id); - Q_NOREPLY void fullScreen(QString path, bool toClipboard, int delay, uint id); - Q_NOREPLY void captureScreen(int number, QString path, bool toClipboard, int delay, uint id); + Q_NOREPLY void fullScreen(QString path, + bool toClipboard, + int delay, + uint id); + Q_NOREPLY void captureScreen(int number, + QString path, + bool toClipboard, + int delay, + uint id); Q_NOREPLY void openLauncher(); Q_NOREPLY void openConfig(); Q_NOREPLY void trayIconEnabled(bool enabled); Q_NOREPLY void autostartEnabled(bool enabled); private slots: - void handleCaptureTaken(uint id, const QPixmap &p); + void handleCaptureTaken(uint id, const QPixmap& p); }; diff --git a/src/core/globalshortcutfilter.cpp b/src/core/globalshortcutfilter.cpp index 9d508204..56534973 100644 --- a/src/core/globalshortcutfilter.cpp +++ b/src/core/globalshortcutfilter.cpp @@ -20,8 +20,8 @@ #include "src/widgets/historywidget.h" #include -GlobalShortcutFilter::GlobalShortcutFilter(QObject *parent) : - QObject(parent) +GlobalShortcutFilter::GlobalShortcutFilter(QObject* parent) + : QObject(parent) { // Forced Print Screen if (RegisterHotKey(NULL, 1, 0, VK_SNAPSHOT)) { @@ -33,10 +33,9 @@ GlobalShortcutFilter::GlobalShortcutFilter(QObject *parent) : } } -bool GlobalShortcutFilter::nativeEventFilter( - const QByteArray &eventType, - void *message, - long *result) +bool GlobalShortcutFilter::nativeEventFilter(const QByteArray& eventType, + void* message, + long* result) { Q_UNUSED(eventType); Q_UNUSED(result); @@ -49,15 +48,15 @@ bool GlobalShortcutFilter::nativeEventFilter( const quint32 modifiers = LOWORD(msg->lParam); // Show screenshots history - if(VK_SNAPSHOT == keycode && MOD_SHIFT == modifiers) { - HistoryWidget *pHistory = new HistoryWidget(); + if (VK_SNAPSHOT == keycode && MOD_SHIFT == modifiers) { + HistoryWidget* pHistory = new HistoryWidget(); pHistory->show(); } // Capture screen - if(VK_SNAPSHOT == keycode && 0 == modifiers) { + if (VK_SNAPSHOT == keycode && 0 == modifiers) { Controller::getInstance()->requestCapture( - CaptureRequest(CaptureRequest::GRAPHICAL_MODE)); + CaptureRequest(CaptureRequest::GRAPHICAL_MODE)); } return true; diff --git a/src/core/globalshortcutfilter.h b/src/core/globalshortcutfilter.h index be1cc3c5..3ed8f10d 100644 --- a/src/core/globalshortcutfilter.h +++ b/src/core/globalshortcutfilter.h @@ -17,15 +17,20 @@ #pragma once -#include #include +#include -class GlobalShortcutFilter : public QObject, public QAbstractNativeEventFilter { +class GlobalShortcutFilter + : public QObject + , public QAbstractNativeEventFilter +{ Q_OBJECT public: - explicit GlobalShortcutFilter(QObject *parent = nullptr); + explicit GlobalShortcutFilter(QObject* parent = nullptr); - bool nativeEventFilter(const QByteArray &eventType, void *message, long *result); + bool nativeEventFilter(const QByteArray& eventType, + void* message, + long* result); signals: void printPressed(); diff --git a/src/main.cpp b/src/main.cpp index b8c13f1c..f4010c1b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,32 +15,33 @@ // You should have received a copy of the GNU General Public License // along with Flameshot. If not, see . -#include "src/core/controller.h" #include "singleapplication.h" -#include "src/utils/filenamehandler.h" -#include "src/utils/confighandler.h" #include "src/cli/commandlineparser.h" -#include "src/utils/systemnotification.h" -#include "src/utils/pathinfo.h" #include "src/core/capturerequest.h" +#include "src/core/controller.h" +#include "src/utils/confighandler.h" +#include "src/utils/filenamehandler.h" +#include "src/utils/pathinfo.h" +#include "src/utils/systemnotification.h" #include +#include #include -#include #include #include -#include +#include #if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) #include "src/core/flameshotdbusadapter.h" #include "src/utils/dbusutils.h" -#include #include +#include #endif -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) +{ // required for the button serialization // TODO: change to QVector in v1.0 - qRegisterMetaTypeStreamOperators >("QList"); + qRegisterMetaTypeStreamOperators>("QList"); qApp->setApplicationVersion(static_cast(APP_VERSION)); // no arguments, just launch Flameshot @@ -50,17 +51,21 @@ int main(int argc, char *argv[]) { QTranslator translator, qtTranslator; QStringList trPaths = PathInfo::translationsPaths(); - for (const QString &path: trPaths) { + for (const QString& path : trPaths) { bool match = translator.load(QLocale(), - QStringLiteral("Internationalization"), QStringLiteral("_"), - path); + QStringLiteral("Internationalization"), + QStringLiteral("_"), + path); if (match) { break; } } - qtTranslator.load(QLocale::system(), "qt", "_", - QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + qtTranslator.load( + QLocale::system(), + "qt", + "_", + QLibraryInfo::location(QLibraryInfo::TranslationsPath)); app.installTranslator(&translator); app.installTranslator(&qtTranslator); @@ -74,7 +79,7 @@ int main(int argc, char *argv[]) { QDBusConnection dbus = QDBusConnection::sessionBus(); if (!dbus.isConnected()) { SystemNotification().sendMessage( - QObject::tr("Unable to connect via DBus")); + QObject::tr("Unable to connect via DBus")); } dbus.registerObject(QStringLiteral("/"), c); dbus.registerService(QStringLiteral("org.dharkael.Flameshot")); @@ -96,61 +101,64 @@ int main(int argc, char *argv[]) { CommandLineParser parser; // Add description parser.setDescription( - QStringLiteral("Powerful yet simple to use screenshot software.")); + QStringLiteral("Powerful yet simple to use screenshot software.")); parser.setGeneralErrorMessage(QStringLiteral("See 'flameshot --help'.")); // Arguments - CommandArgument fullArgument(QStringLiteral("full"), QStringLiteral("Capture the entire desktop.")); - CommandArgument launcherArgument(QStringLiteral("launcher"), QStringLiteral("Open the capture launcher.")); - CommandArgument guiArgument(QStringLiteral("gui"), QStringLiteral("Start a manual capture in GUI mode.")); - CommandArgument configArgument(QStringLiteral("config"), QStringLiteral("Configure flameshot.")); - CommandArgument screenArgument(QStringLiteral("screen"), QStringLiteral("Capture a single screen.")); + CommandArgument fullArgument(QStringLiteral("full"), + QStringLiteral("Capture the entire desktop.")); + CommandArgument launcherArgument( + QStringLiteral("launcher"), QStringLiteral("Open the capture launcher.")); + CommandArgument guiArgument( + QStringLiteral("gui"), + QStringLiteral("Start a manual capture in GUI mode.")); + CommandArgument configArgument(QStringLiteral("config"), + QStringLiteral("Configure flameshot.")); + CommandArgument screenArgument(QStringLiteral("screen"), + QStringLiteral("Capture a single screen.")); // Options CommandOption pathOption( - {"p", "path"}, - QStringLiteral("Path where the capture will be saved"), - QStringLiteral("path")); + { "p", "path" }, + QStringLiteral("Path where the capture will be saved"), + QStringLiteral("path")); CommandOption clipboardOption( - {"c", "clipboard"}, - QStringLiteral("Save the capture to the clipboard")); - CommandOption delayOption( - {"d", "delay"}, - QStringLiteral("Delay time in milliseconds"), - QStringLiteral("milliseconds")); - CommandOption filenameOption( - {"f", "filename"}, - QStringLiteral("Set the filename pattern"), - QStringLiteral("pattern")); - CommandOption trayOption( - {"t", "trayicon"}, - QStringLiteral("Enable or disable the trayicon"), - QStringLiteral("bool")); + { "c", "clipboard" }, + QStringLiteral("Save the capture to the clipboard")); + CommandOption delayOption({ "d", "delay" }, + QStringLiteral("Delay time in milliseconds"), + QStringLiteral("milliseconds")); + CommandOption filenameOption({ "f", "filename" }, + QStringLiteral("Set the filename pattern"), + QStringLiteral("pattern")); + CommandOption trayOption({ "t", "trayicon" }, + QStringLiteral("Enable or disable the trayicon"), + QStringLiteral("bool")); CommandOption autostartOption( - {"a", "autostart"}, - QStringLiteral("Enable or disable run at startup"), - QStringLiteral("bool")); + { "a", "autostart" }, + QStringLiteral("Enable or disable run at startup"), + QStringLiteral("bool")); CommandOption showHelpOption( - {"s", "showhelp"}, - QStringLiteral("Show the help message in the capture mode"), - QStringLiteral("bool")); - CommandOption mainColorOption( - {"m", "maincolor"}, - QStringLiteral("Define the main UI color"), - QStringLiteral("color-code")); + { "s", "showhelp" }, + QStringLiteral("Show the help message in the capture mode"), + QStringLiteral("bool")); + CommandOption mainColorOption({ "m", "maincolor" }, + QStringLiteral("Define the main UI color"), + QStringLiteral("color-code")); CommandOption contrastColorOption( - {"k", "contrastcolor"}, - QStringLiteral("Define the contrast UI color"), - QStringLiteral("color-code")); - CommandOption rawImageOption( - {"r", "raw"}, - QStringLiteral("Print raw PNG capture")); + { "k", "contrastcolor" }, + QStringLiteral("Define the contrast UI color"), + QStringLiteral("color-code")); + CommandOption rawImageOption({ "r", "raw" }, + QStringLiteral("Print raw PNG capture")); CommandOption screenNumberOption( - {"n", "number"}, - QStringLiteral("Define the screen to capture,\ndefault: screen containing the cursor"), - QStringLiteral("Screen number"), QStringLiteral("-1")); + { "n", "number" }, + QStringLiteral( + "Define the screen to capture,\ndefault: screen containing the cursor"), + QStringLiteral("Screen number"), + QStringLiteral("-1")); // Add checkers - auto colorChecker = [](const QString &colorCode) -> bool { + auto colorChecker = [](const QString& colorCode) -> bool { QColor parsedColor(colorCode); return parsedColor.isValid() && parsedColor.alphaF() == 1.0; }; @@ -162,25 +170,31 @@ int main(int argc, char *argv[]) { "- Named colors like 'blue' or 'red'\n" "You may need to escape the '#' sign as in '\\#FFF'"; - const QString delayErr = QStringLiteral("Invalid delay, it must be higher than 0"); - const QString numberErr = QStringLiteral("Invalid screen number, it must be non negative"); - auto numericChecker = [](const QString &delayValue) -> bool { + const QString delayErr = + QStringLiteral("Invalid delay, it must be higher than 0"); + const QString numberErr = + QStringLiteral("Invalid screen number, it must be non negative"); + auto numericChecker = [](const QString& delayValue) -> bool { int value = delayValue.toInt(); return value >= 0; }; - const QString pathErr = QStringLiteral("Invalid path, it must be a real path in the system"); - auto pathChecker = [pathErr](const QString &pathValue) -> bool { + const QString pathErr = + QStringLiteral("Invalid path, it must be a real path in the system"); + auto pathChecker = [pathErr](const QString& pathValue) -> bool { bool res = QDir(pathValue).exists(); if (!res) { - SystemNotification().sendMessage(QObject::tr(pathErr.toLatin1().data())); + SystemNotification().sendMessage( + QObject::tr(pathErr.toLatin1().data())); } return res; }; - const QString booleanErr = QStringLiteral("Invalid value, it must be defined as 'true' or 'false'"); - auto booleanChecker = [](const QString &value) -> bool { - return value == QLatin1String("true") || value == QLatin1String("false"); + const QString booleanErr = + QStringLiteral("Invalid value, it must be defined as 'true' or 'false'"); + auto booleanChecker = [](const QString& value) -> bool { + return value == QLatin1String("true") || + value == QLatin1String("false"); }; contrastColorOption.addChecker(colorChecker, colorErr); @@ -201,13 +215,21 @@ int main(int argc, char *argv[]) { auto helpOption = parser.addHelpOption(); auto versionOption = parser.addVersionOption(); parser.AddOptions({ pathOption, delayOption, rawImageOption }, guiArgument); - parser.AddOptions({ screenNumberOption, clipboardOption, pathOption, - delayOption, rawImageOption }, + parser.AddOptions({ screenNumberOption, + clipboardOption, + pathOption, + delayOption, + rawImageOption }, screenArgument); - parser.AddOptions({ pathOption, clipboardOption, delayOption, rawImageOption }, - fullArgument); - parser.AddOptions({ autostartOption, filenameOption, trayOption, - showHelpOption, mainColorOption, contrastColorOption }, + parser.AddOptions( + { pathOption, clipboardOption, delayOption, rawImageOption }, + fullArgument); + parser.AddOptions({ autostartOption, + filenameOption, + trayOption, + showHelpOption, + mainColorOption, + contrastColorOption }, configArgument); // Parse if (!parser.parse(app.arguments())) { @@ -217,18 +239,19 @@ int main(int argc, char *argv[]) { // PROCESS DATA //-------------- if (parser.isSet(helpOption) || parser.isSet(versionOption)) { - } - else if (parser.isSet(launcherArgument)) { // LAUNCHER - QDBusMessage m = QDBusMessage::createMethodCall(QStringLiteral("org.dharkael.Flameshot"), - QStringLiteral("/"), QLatin1String(""), QStringLiteral("openLauncher")); + } else if (parser.isSet(launcherArgument)) { // LAUNCHER + QDBusMessage m = QDBusMessage::createMethodCall( + QStringLiteral("org.dharkael.Flameshot"), + QStringLiteral("/"), + QLatin1String(""), + QStringLiteral("openLauncher")); QDBusConnection sessionBus = QDBusConnection::sessionBus(); if (!sessionBus.isConnected()) { SystemNotification().sendMessage( - QObject::tr("Unable to connect via DBus")); + QObject::tr("Unable to connect via DBus")); } sessionBus.call(m); - } - else if (parser.isSet(guiArgument)) { // GUI + } else if (parser.isSet(guiArgument)) { // GUI QString pathValue = parser.value(pathOption); int delay = parser.value(delayOption).toInt(); bool isRaw = parser.isSet(rawImageOption); @@ -237,8 +260,11 @@ int main(int argc, char *argv[]) { uint id = req.id(); // Send message - QDBusMessage m = QDBusMessage::createMethodCall(QStringLiteral("org.dharkael.Flameshot"), - QStringLiteral("/"), QLatin1String(""), QStringLiteral("graphicCapture")); + QDBusMessage m = QDBusMessage::createMethodCall( + QStringLiteral("org.dharkael.Flameshot"), + QStringLiteral("/"), + QLatin1String(""), + QStringLiteral("graphicCapture")); m << pathValue << delay << id; QDBusConnection sessionBus = QDBusConnection::sessionBus(); dbusUtils.checkDBusConnection(sessionBus); @@ -248,14 +274,13 @@ int main(int argc, char *argv[]) { dbusUtils.connectPrintCapture(sessionBus, id); QTimer t; t.setInterval(delay + 1000 * 60 * 15); // 15 minutes timeout - QObject::connect(&t, &QTimer::timeout, qApp, - &QCoreApplication::quit); + QObject::connect( + &t, &QTimer::timeout, qApp, &QCoreApplication::quit); t.start(); // wait return app.exec(); } - } - else if (parser.isSet(fullArgument)) { // FULL + } else if (parser.isSet(fullArgument)) { // FULL QString pathValue = parser.value(pathOption); int delay = parser.value(delayOption).toInt(); bool toClipboard = parser.isSet(clipboardOption); @@ -266,9 +291,12 @@ int main(int argc, char *argv[]) { out << "Invalid format, set where to save the content with one of " << "the following flags:\n " << pathOption.dashedNames().join(QStringLiteral(", ")) << "\n " - << rawImageOption.dashedNames().join(QStringLiteral(", ")) << "\n " - << clipboardOption.dashedNames().join(QStringLiteral(", ")) << "\n\n"; - parser.parse(QStringList() << argv[0] << QStringLiteral("full") << QStringLiteral("-h")); + << rawImageOption.dashedNames().join(QStringLiteral(", ")) + << "\n " + << clipboardOption.dashedNames().join(QStringLiteral(", ")) + << "\n\n"; + parser.parse(QStringList() << argv[0] << QStringLiteral("full") + << QStringLiteral("-h")); goto finish; } @@ -283,8 +311,11 @@ int main(int argc, char *argv[]) { DBusUtils dbusUtils; // Send message - QDBusMessage m = QDBusMessage::createMethodCall(QStringLiteral("org.dharkael.Flameshot"), - QStringLiteral("/"), QLatin1String(""), QStringLiteral("fullScreen")); + QDBusMessage m = QDBusMessage::createMethodCall( + QStringLiteral("org.dharkael.Flameshot"), + QStringLiteral("/"), + QLatin1String(""), + QStringLiteral("fullScreen")); m << pathValue << toClipboard << delay << id; QDBusConnection sessionBus = QDBusConnection::sessionBus(); dbusUtils.checkDBusConnection(sessionBus); @@ -295,16 +326,16 @@ int main(int argc, char *argv[]) { // timeout just in case QTimer t; t.setInterval(delay + 2000); - QObject::connect(&t, &QTimer::timeout, qApp, - &QCoreApplication::quit); + QObject::connect( + &t, &QTimer::timeout, qApp, &QCoreApplication::quit); t.start(); // wait return app.exec(); } - } - else if (parser.isSet(screenArgument)) { // SCREEN + } else if (parser.isSet(screenArgument)) { // SCREEN QString numberStr = parser.value(screenNumberOption); - int number = numberStr.startsWith(QLatin1String("-")) ? -1 : numberStr.toInt(); + int number = + numberStr.startsWith(QLatin1String("-")) ? -1 : numberStr.toInt(); QString pathValue = parser.value(pathOption); int delay = parser.value(delayOption).toInt(); bool toClipboard = parser.isSet(clipboardOption); @@ -315,14 +346,17 @@ int main(int argc, char *argv[]) { out << "Invalid format, set where to save the content with one of " << "the following flags:\n " << pathOption.dashedNames().join(QStringLiteral(", ")) << "\n " - << rawImageOption.dashedNames().join(QStringLiteral(", ")) << "\n " - << clipboardOption.dashedNames().join(QStringLiteral(", ")) << "\n\n"; - parser.parse(QStringList() << argv[0] << QStringLiteral("screen") << QStringLiteral("-h")); + << rawImageOption.dashedNames().join(QStringLiteral(", ")) + << "\n " + << clipboardOption.dashedNames().join(QStringLiteral(", ")) + << "\n\n"; + parser.parse(QStringList() << argv[0] << QStringLiteral("screen") + << QStringLiteral("-h")); goto finish; } - CaptureRequest req(CaptureRequest::SCREEN_MODE, - delay, pathValue, number); + CaptureRequest req( + CaptureRequest::SCREEN_MODE, delay, pathValue, number); if (toClipboard) { req.addTask(CaptureRequest::CLIPBOARD_SAVE_TASK); } @@ -333,8 +367,11 @@ int main(int argc, char *argv[]) { DBusUtils dbusUtils; // Send message - QDBusMessage m = QDBusMessage::createMethodCall(QStringLiteral("org.dharkael.Flameshot"), - QStringLiteral("/"), QLatin1String(""), QStringLiteral("captureScreen")); + QDBusMessage m = QDBusMessage::createMethodCall( + QStringLiteral("org.dharkael.Flameshot"), + QStringLiteral("/"), + QLatin1String(""), + QStringLiteral("captureScreen")); m << number << pathValue << toClipboard << delay << id; QDBusConnection sessionBus = QDBusConnection::sessionBus(); dbusUtils.checkDBusConnection(sessionBus); @@ -345,26 +382,28 @@ int main(int argc, char *argv[]) { // timeout just in case QTimer t; t.setInterval(delay + 2000); - QObject::connect(&t, &QTimer::timeout, qApp, - &QCoreApplication::quit); + QObject::connect( + &t, &QTimer::timeout, qApp, &QCoreApplication::quit); t.start(); // wait return app.exec(); } - } - else if (parser.isSet(configArgument)) { // CONFIG + } else if (parser.isSet(configArgument)) { // CONFIG bool autostart = parser.isSet(autostartOption); bool filename = parser.isSet(filenameOption); bool tray = parser.isSet(trayOption); bool help = parser.isSet(showHelpOption); bool mainColor = parser.isSet(mainColorOption); bool contrastColor = parser.isSet(contrastColorOption); - bool someFlagSet = (filename || tray || help || - mainColor || contrastColor); + bool someFlagSet = + (filename || tray || help || mainColor || contrastColor); ConfigHandler config; if (autostart) { - QDBusMessage m = QDBusMessage::createMethodCall(QStringLiteral("org.dharkael.Flameshot"), - QStringLiteral("/"), QLatin1String(""), QStringLiteral("autostartEnabled")); + QDBusMessage m = QDBusMessage::createMethodCall( + QStringLiteral("org.dharkael.Flameshot"), + QStringLiteral("/"), + QLatin1String(""), + QStringLiteral("autostartEnabled")); if (parser.value(autostartOption) == QLatin1String("false")) { m << false; } else if (parser.value(autostartOption) == QLatin1String("true")) { @@ -373,7 +412,7 @@ int main(int argc, char *argv[]) { QDBusConnection sessionBus = QDBusConnection::sessionBus(); if (!sessionBus.isConnected()) { SystemNotification().sendMessage( - QObject::tr("Unable to connect via DBus")); + QObject::tr("Unable to connect via DBus")); } sessionBus.call(m); } @@ -382,13 +421,17 @@ int main(int argc, char *argv[]) { config.setFilenamePattern(newFilename); FileNameHandler fh; QTextStream(stdout) - << QStringLiteral("The new pattern is '%1'\n" - "Parsed pattern example: %2\n").arg(newFilename) - .arg(fh.parsedPattern()); + << QStringLiteral("The new pattern is '%1'\n" + "Parsed pattern example: %2\n") + .arg(newFilename) + .arg(fh.parsedPattern()); } if (tray) { - QDBusMessage m = QDBusMessage::createMethodCall(QStringLiteral("org.dharkael.Flameshot"), - QStringLiteral("/"), QLatin1String(""), QStringLiteral("trayIconEnabled")); + QDBusMessage m = QDBusMessage::createMethodCall( + QStringLiteral("org.dharkael.Flameshot"), + QStringLiteral("/"), + QLatin1String(""), + QStringLiteral("trayIconEnabled")); if (parser.value(trayOption) == QLatin1String("false")) { m << false; } else if (parser.value(trayOption) == QLatin1String("true")) { @@ -397,7 +440,7 @@ int main(int argc, char *argv[]) { QDBusConnection sessionBus = QDBusConnection::sessionBus(); if (!sessionBus.isConnected()) { SystemNotification().sendMessage( - QObject::tr("Unable to connect via DBus")); + QObject::tr("Unable to connect via DBus")); } sessionBus.call(m); } @@ -421,12 +464,15 @@ int main(int argc, char *argv[]) { // Open gui when no options if (!someFlagSet) { - QDBusMessage m = QDBusMessage::createMethodCall(QStringLiteral("org.dharkael.Flameshot"), - QStringLiteral("/"), QLatin1String(""), QStringLiteral("openConfig")); + QDBusMessage m = QDBusMessage::createMethodCall( + QStringLiteral("org.dharkael.Flameshot"), + QStringLiteral("/"), + QLatin1String(""), + QStringLiteral("openConfig")); QDBusConnection sessionBus = QDBusConnection::sessionBus(); if (!sessionBus.isConnected()) { SystemNotification().sendMessage( - QObject::tr("Unable to connect via DBus")); + QObject::tr("Unable to connect via DBus")); } sessionBus.call(m); } diff --git a/src/third-party/Qt-Color-Widgets/src/color_utils.cpp b/src/third-party/Qt-Color-Widgets/src/color_utils.cpp index e0bdb793..205d8f7c 100644 --- a/src/third-party/Qt-Color-Widgets/src/color_utils.cpp +++ b/src/third-party/Qt-Color-Widgets/src/color_utils.cpp @@ -24,59 +24,57 @@ namespace color_widgets { namespace detail { -QColor color_from_lch(qreal hue, qreal chroma, qreal luma, qreal alpha ) +QColor color_from_lch(qreal hue, qreal chroma, qreal luma, qreal alpha) { - qreal h1 = hue*6; - qreal x = chroma*(1-qAbs(std::fmod(h1,2)-1)); + qreal h1 = hue * 6; + qreal x = chroma * (1 - qAbs(std::fmod(h1, 2) - 1)); QColor col; - if ( h1 >= 0 && h1 < 1 ) - col = QColor::fromRgbF(chroma,x,0); - else if ( h1 < 2 ) - col = QColor::fromRgbF(x,chroma,0); - else if ( h1 < 3 ) - col = QColor::fromRgbF(0,chroma,x); - else if ( h1 < 4 ) - col = QColor::fromRgbF(0,x,chroma); - else if ( h1 < 5 ) - col = QColor::fromRgbF(x,0,chroma); - else if ( h1 < 6 ) - col = QColor::fromRgbF(chroma,0,x); + if (h1 >= 0 && h1 < 1) + col = QColor::fromRgbF(chroma, x, 0); + else if (h1 < 2) + col = QColor::fromRgbF(x, chroma, 0); + else if (h1 < 3) + col = QColor::fromRgbF(0, chroma, x); + else if (h1 < 4) + col = QColor::fromRgbF(0, x, chroma); + else if (h1 < 5) + col = QColor::fromRgbF(x, 0, chroma); + else if (h1 < 6) + col = QColor::fromRgbF(chroma, 0, x); qreal m = luma - color_lumaF(col); - return QColor::fromRgbF( - qBound(0.0,col.redF()+m,1.0), - qBound(0.0,col.greenF()+m,1.0), - qBound(0.0,col.blueF()+m,1.0), - alpha); + return QColor::fromRgbF(qBound(0.0, col.redF() + m, 1.0), + qBound(0.0, col.greenF() + m, 1.0), + qBound(0.0, col.blueF() + m, 1.0), + alpha); } -QColor color_from_hsl(qreal hue, qreal sat, qreal lig, qreal alpha ) +QColor color_from_hsl(qreal hue, qreal sat, qreal lig, qreal alpha) { - qreal chroma = (1 - qAbs(2*lig-1))*sat; - qreal h1 = hue*6; - qreal x = chroma*(1-qAbs(std::fmod(h1,2)-1)); + qreal chroma = (1 - qAbs(2 * lig - 1)) * sat; + qreal h1 = hue * 6; + qreal x = chroma * (1 - qAbs(std::fmod(h1, 2) - 1)); QColor col; - if ( h1 >= 0 && h1 < 1 ) - col = QColor::fromRgbF(chroma,x,0); - else if ( h1 < 2 ) - col = QColor::fromRgbF(x,chroma,0); - else if ( h1 < 3 ) - col = QColor::fromRgbF(0,chroma,x); - else if ( h1 < 4 ) - col = QColor::fromRgbF(0,x,chroma); - else if ( h1 < 5 ) - col = QColor::fromRgbF(x,0,chroma); - else if ( h1 < 6 ) - col = QColor::fromRgbF(chroma,0,x); + if (h1 >= 0 && h1 < 1) + col = QColor::fromRgbF(chroma, x, 0); + else if (h1 < 2) + col = QColor::fromRgbF(x, chroma, 0); + else if (h1 < 3) + col = QColor::fromRgbF(0, chroma, x); + else if (h1 < 4) + col = QColor::fromRgbF(0, x, chroma); + else if (h1 < 5) + col = QColor::fromRgbF(x, 0, chroma); + else if (h1 < 6) + col = QColor::fromRgbF(chroma, 0, x); - qreal m = lig-chroma/2; + qreal m = lig - chroma / 2; - return QColor::fromRgbF( - qBound(0.0,col.redF()+m,1.0), - qBound(0.0,col.greenF()+m,1.0), - qBound(0.0,col.blueF()+m,1.0), - alpha); + return QColor::fromRgbF(qBound(0.0, col.redF() + m, 1.0), + qBound(0.0, col.greenF() + m, 1.0), + qBound(0.0, col.blueF() + m, 1.0), + alpha); } } // namespace detail diff --git a/src/third-party/Qt-Color-Widgets/src/color_wheel.cpp b/src/third-party/Qt-Color-Widgets/src/color_wheel.cpp index 335b29ce..37a03437 100644 --- a/src/third-party/Qt-Color-Widgets/src/color_wheel.cpp +++ b/src/third-party/Qt-Color-Widgets/src/color_wheel.cpp @@ -21,13 +21,13 @@ */ #include "color_wheel.hpp" -#include +#include "color_utils.hpp" +#include +#include +#include #include #include -#include -#include -#include -#include "color_utils.hpp" +#include namespace color_widgets { @@ -38,14 +38,16 @@ enum MouseStatus DragSquare }; -static const ColorWheel::DisplayFlags hard_default_flags = ColorWheel::SHAPE_TRIANGLE|ColorWheel::ANGLE_ROTATING|ColorWheel::COLOR_HSV; +static const ColorWheel::DisplayFlags hard_default_flags = + ColorWheel::SHAPE_TRIANGLE | ColorWheel::ANGLE_ROTATING | + ColorWheel::COLOR_HSV; static ColorWheel::DisplayFlags default_flags = hard_default_flags; static const double selector_radius = 6; class ColorWheel::Private { private: - ColorWheel * const w; + ColorWheel* const w; public: qreal hue, sat, val; @@ -55,15 +57,20 @@ public: QPixmap hue_ring; QImage inner_selector; DisplayFlags display_flags; - QColor (*color_from)(qreal,qreal,qreal,qreal); + QColor (*color_from)(qreal, qreal, qreal, qreal); QColor (*rainbow_from_hue)(qreal); int max_size = 128; - explicit Private(ColorWheel *widget) - : w(widget), hue(0), sat(0), val(0), - wheel_width(20), mouse_status(Nothing), - display_flags(FLAGS_DEFAULT), - color_from(&QColor::fromHsvF), rainbow_from_hue(&detail::rainbow_hsv) + explicit Private(ColorWheel* widget) + : w(widget) + , hue(0) + , sat(0) + , val(0) + , wheel_width(20) + , mouse_status(Nothing) + , display_flags(FLAGS_DEFAULT) + , color_from(&QColor::fromHsvF) + , rainbow_from_hue(&detail::rainbow_hsv) { QColor bgColor = widget->palette().background().color(); bgBrightness = color_widgets::detail::color_lumaF(bgColor); @@ -72,37 +79,26 @@ public: /// Calculate outer wheel radius from idget center qreal outer_radius() const { - return qMin(w->geometry().width(), w->geometry().height())/2; + return qMin(w->geometry().width(), w->geometry().height()) / 2; } /// Calculate inner wheel radius from idget center - qreal inner_radius() const - { - return outer_radius()-wheel_width; - } + qreal inner_radius() const { return outer_radius() - wheel_width; } /// Calculate the edge length of the inner square - qreal square_size() const - { - return inner_radius()*qSqrt(2); - } + qreal square_size() const { return inner_radius() * qSqrt(2); } /// Calculate the height of the inner triangle - qreal triangle_height() const - { - return inner_radius()*3/2; - } + qreal triangle_height() const { return inner_radius() * 3 / 2; } /// Calculate the side of the inner triangle - qreal triangle_side() const - { - return inner_radius()*qSqrt(3); - } + qreal triangle_side() const { return inner_radius() * qSqrt(3); } /// return line from center to given point - QLineF line_to_point(const QPoint &p) const + QLineF line_to_point(const QPoint& p) const { - return QLineF (w->geometry().width()/2, w->geometry().height()/2, p.x(), p.y()); + return QLineF( + w->geometry().width() / 2, w->geometry().height() / 2, p.x(), p.y()); } void render_square() @@ -111,39 +107,40 @@ public: QSize size(width, width); inner_selector = QImage(size, QImage::Format_RGB32); - for ( int y = 0; y < width; ++y ) - { - for ( int x = 0; x < width; ++x ) - { - inner_selector.setPixel( x, y, - color_from(hue,double(x)/width,double(y)/width,1).rgb()); + for (int y = 0; y < width; ++y) { + for (int x = 0; x < width; ++x) { + inner_selector.setPixel( + x, + y, + color_from(hue, double(x) / width, double(y) / width, 1) + .rgb()); } } } /** * \brief renders the selector as a triangle - * \note It's the same as a square with the edge with value=0 collapsed to a single point + * \note It's the same as a square with the edge with value=0 collapsed to a + * single point */ void render_triangle() { QSizeF size = selector_size(); - if ( size.height() > max_size ) + if (size.height() > max_size) size *= max_size / size.height(); - qreal ycenter = size.height()/2; + qreal ycenter = size.height() / 2; inner_selector = QImage(size.toSize(), QImage::Format_RGB32); - for (int x = 0; x < inner_selector.width(); x++ ) - { + for (int x = 0; x < inner_selector.width(); x++) { qreal pval = x / size.height(); qreal slice_h = size.height() * pval; - for (int y = 0; y < inner_selector.height(); y++ ) - { - qreal ymin = ycenter-slice_h/2; - qreal psat = qBound(0.0,(y-ymin)/slice_h,1.0); + for (int y = 0; y < inner_selector.height(); y++) { + qreal ymin = ycenter - slice_h / 2; + qreal psat = qBound(0.0, (y - ymin) / slice_h, 1.0); - inner_selector.setPixel(x,y,color_from(hue,psat,pval,1).rgb()); + inner_selector.setPixel( + x, y, color_from(hue, psat, pval, 1).rgb()); } } } @@ -151,7 +148,7 @@ public: /// Updates the inner image that displays the saturation-value selector void render_inner_selector() { - if ( display_flags & ColorWheel::SHAPE_TRIANGLE ) + if (display_flags & ColorWheel::SHAPE_TRIANGLE) render_triangle(); else render_square(); @@ -160,9 +157,9 @@ public: /// Offset of the selector image QPointF selector_image_offset() { - if ( display_flags & SHAPE_TRIANGLE ) - return QPointF(-inner_radius(),-triangle_side()/2); - return QPointF(-square_size()/2,-square_size()/2); + if (display_flags & SHAPE_TRIANGLE) + return QPointF(-inner_radius(), -triangle_side() / 2); + return QPointF(-square_size() / 2, -square_size() / 2); } /** @@ -170,25 +167,21 @@ public: */ QSizeF selector_size() { - if ( display_flags & SHAPE_TRIANGLE ) - return QSizeF(triangle_height(), triangle_side()); + if (display_flags & SHAPE_TRIANGLE) + return QSizeF(triangle_height(), triangle_side()); return QSizeF(square_size(), square_size()); } - /// Rotation of the selector image qreal selector_image_angle() { - if ( display_flags & SHAPE_TRIANGLE ) - { - if ( display_flags & ANGLE_ROTATING ) - return -hue*360-60; + if (display_flags & SHAPE_TRIANGLE) { + if (display_flags & ANGLE_ROTATING) + return -hue * 360 - 60; return -150; - } - else - { - if ( display_flags & ANGLE_ROTATING ) - return -hue*360-45; + } else { + if (display_flags & ANGLE_ROTATING) + return -hue * 360 - 45; else return 180; } @@ -197,50 +190,42 @@ public: /// Updates the outer ring that displays the hue selector void render_ring() { - hue_ring = QPixmap(outer_radius()*2,outer_radius()*2); + hue_ring = QPixmap(outer_radius() * 2, outer_radius() * 2); hue_ring.fill(Qt::transparent); QPainter painter(&hue_ring); painter.setRenderHint(QPainter::Antialiasing); painter.setCompositionMode(QPainter::CompositionMode_Source); - const int hue_stops = 24; QConicalGradient gradient_hue(0, 0, 0); - if ( gradient_hue.stops().size() < hue_stops ) - { - for ( double a = 0; a < 1.0; a+=1.0/(hue_stops-1) ) - { - gradient_hue.setColorAt(a,rainbow_from_hue(a)); + if (gradient_hue.stops().size() < hue_stops) { + for (double a = 0; a < 1.0; a += 1.0 / (hue_stops - 1)) { + gradient_hue.setColorAt(a, rainbow_from_hue(a)); } - gradient_hue.setColorAt(1,rainbow_from_hue(0)); + gradient_hue.setColorAt(1, rainbow_from_hue(0)); } - painter.translate(outer_radius(),outer_radius()); + painter.translate(outer_radius(), outer_radius()); painter.setPen(Qt::NoPen); painter.setBrush(QBrush(gradient_hue)); - painter.drawEllipse(QPointF(0,0),outer_radius(),outer_radius()); + painter.drawEllipse(QPointF(0, 0), outer_radius(), outer_radius()); - painter.setBrush(Qt::transparent);//palette().background()); - painter.drawEllipse(QPointF(0,0),inner_radius(),inner_radius()); + painter.setBrush(Qt::transparent); // palette().background()); + painter.drawEllipse(QPointF(0, 0), inner_radius(), inner_radius()); } void set_color(const QColor& c) { - if ( display_flags & ColorWheel::COLOR_HSV ) - { + if (display_flags & ColorWheel::COLOR_HSV) { hue = qMax(0.0, c.hsvHueF()); sat = c.hsvSaturationF(); val = c.valueF(); - } - else if ( display_flags & ColorWheel::COLOR_HSL ) - { + } else if (display_flags & ColorWheel::COLOR_HSL) { hue = qMax(0.0, c.hueF()); sat = detail::color_HSL_saturationF(c); val = detail::color_lightnessF(c); - } - else if ( display_flags & ColorWheel::COLOR_LCH ) - { + } else if (display_flags & ColorWheel::COLOR_LCH) { hue = qMax(0.0, c.hsvHueF()); sat = detail::color_chromaF(c); val = detail::color_lumaF(c); @@ -248,8 +233,9 @@ public: } }; -ColorWheel::ColorWheel(QWidget *parent) : - QWidget(parent), p(new Private(this)) +ColorWheel::ColorWheel(QWidget* parent) + : QWidget(parent) + , p(new Private(this)) { setDisplayFlags(FLAGS_DEFAULT); setAcceptDrops(true); @@ -267,12 +253,12 @@ QColor ColorWheel::color() const QSize ColorWheel::sizeHint() const { - return QSize(p->wheel_width*5, p->wheel_width*5); + return QSize(p->wheel_width * 5, p->wheel_width * 5); } qreal ColorWheel::hue() const { - if ( (p->display_flags & COLOR_LCH) && p->sat > 0.01 ) + if ((p->display_flags & COLOR_LCH) && p->sat > 0.01) return color().hueF(); return p->hue; } @@ -299,119 +285,111 @@ void ColorWheel::setWheelWidth(unsigned int w) update(); } -void ColorWheel::paintEvent(QPaintEvent * ) +void ColorWheel::paintEvent(QPaintEvent*) { QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); - painter.translate(geometry().width()/2,geometry().height()/2); + painter.translate(geometry().width() / 2, geometry().height() / 2); // hue wheel - if(p->hue_ring.isNull()) + if (p->hue_ring.isNull()) p->render_ring(); painter.drawPixmap(-p->outer_radius(), -p->outer_radius(), p->hue_ring); // hue selector QColor penColor = p->bgBrightness < 0.6 ? Qt::white : Qt::black; - painter.setPen(QPen(penColor,3)); + painter.setPen(QPen(penColor, 3)); painter.setBrush(Qt::NoBrush); QLineF ray(0, 0, p->outer_radius(), 0); - ray.setAngle(p->hue*360); + ray.setAngle(p->hue * 360); QPointF h1 = ray.p2(); ray.setLength(p->inner_radius()); QPointF h2 = ray.p2(); - painter.drawLine(h1,h2); + painter.drawLine(h1, h2); // lum-sat square - if(p->inner_selector.isNull()) + if (p->inner_selector.isNull()) p->render_inner_selector(); painter.rotate(p->selector_image_angle()); painter.translate(p->selector_image_offset()); QPointF selector_position; - if ( p->display_flags & SHAPE_SQUARE ) - { + if (p->display_flags & SHAPE_SQUARE) { qreal side = p->square_size(); - selector_position = QPointF(p->sat*side, p->val*side); - } - else if ( p->display_flags & SHAPE_TRIANGLE ) - { + selector_position = QPointF(p->sat * side, p->val * side); + } else if (p->display_flags & SHAPE_TRIANGLE) { qreal side = p->triangle_side(); qreal height = p->triangle_height(); qreal slice_h = side * p->val; - qreal ymin = side/2-slice_h/2; + qreal ymin = side / 2 - slice_h / 2; - selector_position = QPointF(p->val*height, ymin + p->sat*slice_h); + selector_position = QPointF(p->val * height, ymin + p->sat * slice_h); QPolygonF triangle; - triangle.append(QPointF(0,side/2)); - triangle.append(QPointF(height,0)); - triangle.append(QPointF(height,side)); + triangle.append(QPointF(0, side / 2)); + triangle.append(QPointF(height, 0)); + triangle.append(QPointF(height, side)); QPainterPath clip; clip.addPolygon(triangle); painter.setClipPath(clip); } - painter.drawImage(QRectF(QPointF(0, 0), p->selector_size()), p->inner_selector); + painter.drawImage(QRectF(QPointF(0, 0), p->selector_size()), + p->inner_selector); painter.setClipping(false); // lum-sat selector - // we define the color of the selecto based on the background color of the widget - // in order to improve the contrast + // we define the color of the selecto based on the background color of the + // widget in order to improve the contrast qreal colorBrightness = color_widgets::detail::color_lumaF(color()); if (p->bgBrightness < 0.6) // dark theme { bool isWhite = (colorBrightness < 0.7); painter.setPen(QPen(isWhite ? Qt::white : Qt::black, 3)); - } - else // light theme + } else // light theme { bool isWhite = (colorBrightness < 0.4 && p->val < 0.3); painter.setPen(QPen(isWhite ? Qt::white : Qt::black, 3)); } painter.setBrush(Qt::NoBrush); painter.drawEllipse(selector_position, selector_radius, selector_radius); - } -void ColorWheel::mouseMoveEvent(QMouseEvent *ev) +void ColorWheel::mouseMoveEvent(QMouseEvent* ev) { - if (p->mouse_status == DragCircle ) - { - p->hue = p->line_to_point(ev->pos()).angle()/360.0; + if (p->mouse_status == DragCircle) { + p->hue = p->line_to_point(ev->pos()).angle() / 360.0; p->render_inner_selector(); emit colorSelected(color()); emit colorChanged(color()); update(); - } - else if(p->mouse_status == DragSquare) - { + } else if (p->mouse_status == DragSquare) { QLineF glob_mouse_ln = p->line_to_point(ev->pos()); - QLineF center_mouse_ln ( QPointF(0,0), - glob_mouse_ln.p2() - glob_mouse_ln.p1() ); + QLineF center_mouse_ln(QPointF(0, 0), + glob_mouse_ln.p2() - glob_mouse_ln.p1()); - center_mouse_ln.setAngle(center_mouse_ln.angle()+p->selector_image_angle()); - center_mouse_ln.setP2(center_mouse_ln.p2()-p->selector_image_offset()); + center_mouse_ln.setAngle(center_mouse_ln.angle() + + p->selector_image_angle()); + center_mouse_ln.setP2(center_mouse_ln.p2() - + p->selector_image_offset()); - if ( p->display_flags & SHAPE_SQUARE ) - { - p->sat = qBound(0.0, center_mouse_ln.x2()/p->square_size(), 1.0); - p->val = qBound(0.0, center_mouse_ln.y2()/p->square_size(), 1.0); - } - else if ( p->display_flags & SHAPE_TRIANGLE ) - { + if (p->display_flags & SHAPE_SQUARE) { + p->sat = qBound(0.0, center_mouse_ln.x2() / p->square_size(), 1.0); + p->val = qBound(0.0, center_mouse_ln.y2() / p->square_size(), 1.0); + } else if (p->display_flags & SHAPE_TRIANGLE) { QPointF pt = center_mouse_ln.p2(); qreal side = p->triangle_side(); p->val = qBound(0.0, pt.x() / p->triangle_height(), 1.0); qreal slice_h = side * p->val; - qreal ycenter = side/2; - qreal ymin = ycenter-slice_h/2; + qreal ycenter = side / 2; + qreal ymin = ycenter - slice_h / 2; - if ( slice_h > 0 ) - p->sat = qBound(0.0, (pt.y()-ymin)/slice_h, 1.0); + if (slice_h > 0) + p->sat = qBound(0.0, (pt.y() - ymin) / slice_h, 1.0); } emit colorSelected(color()); @@ -420,15 +398,14 @@ void ColorWheel::mouseMoveEvent(QMouseEvent *ev) } } -void ColorWheel::mousePressEvent(QMouseEvent *ev) +void ColorWheel::mousePressEvent(QMouseEvent* ev) { - if ( ev->buttons() & Qt::LeftButton ) - { + if (ev->buttons() & Qt::LeftButton) { setFocus(); QLineF ray = p->line_to_point(ev->pos()); - if ( ray.length() <= p->inner_radius() ) + if (ray.length() <= p->inner_radius()) p->mouse_status = DragSquare; - else if ( ray.length() <= p->outer_radius() ) + else if (ray.length() <= p->outer_radius()) p->mouse_status = DragCircle; // Update the color @@ -436,15 +413,14 @@ void ColorWheel::mousePressEvent(QMouseEvent *ev) } } -void ColorWheel::mouseReleaseEvent(QMouseEvent *ev) +void ColorWheel::mouseReleaseEvent(QMouseEvent* ev) { mouseMoveEvent(ev); p->mouse_status = Nothing; emit mouseReleaseOnColor(color()); - } -void ColorWheel::resizeEvent(QResizeEvent *) +void ColorWheel::resizeEvent(QResizeEvent*) { p->render_ring(); p->render_inner_selector(); @@ -454,7 +430,7 @@ void ColorWheel::setColor(QColor c) { qreal oldh = p->hue; p->set_color(c); - if (!qFuzzyCompare(oldh+1, p->hue+1)) + if (!qFuzzyCompare(oldh + 1, p->hue + 1)) p->render_inner_selector(); update(); emit colorChanged(c); @@ -479,37 +455,30 @@ void ColorWheel::setValue(qreal v) update(); } - void ColorWheel::setDisplayFlags(DisplayFlags flags) { - if ( ! (flags & COLOR_FLAGS) ) + if (!(flags & COLOR_FLAGS)) flags |= default_flags & COLOR_FLAGS; - if ( ! (flags & ANGLE_FLAGS) ) + if (!(flags & ANGLE_FLAGS)) flags |= default_flags & ANGLE_FLAGS; - if ( ! (flags & SHAPE_FLAGS) ) + if (!(flags & SHAPE_FLAGS)) flags |= default_flags & SHAPE_FLAGS; - if ( (flags & COLOR_FLAGS) != (p->display_flags & COLOR_FLAGS) ) - { + if ((flags & COLOR_FLAGS) != (p->display_flags & COLOR_FLAGS)) { QColor old_col = color(); - if ( flags & ColorWheel::COLOR_HSL ) - { + if (flags & ColorWheel::COLOR_HSL) { p->hue = old_col.hueF(); p->sat = detail::color_HSL_saturationF(old_col); p->val = detail::color_lightnessF(old_col); p->color_from = &detail::color_from_hsl; p->rainbow_from_hue = &detail::rainbow_hsv; - } - else if ( flags & ColorWheel::COLOR_LCH ) - { + } else if (flags & ColorWheel::COLOR_LCH) { p->hue = old_col.hueF(); p->sat = detail::color_chromaF(old_col); p->val = detail::color_lumaF(old_col); p->color_from = &detail::color_from_lch; p->rainbow_from_hue = &detail::rainbow_lch; - } - else - { + } else { p->hue = old_col.hsvHueF(); p->sat = old_col.hsvSaturationF(); p->val = old_col.valueF(); @@ -532,11 +501,11 @@ ColorWheel::DisplayFlags ColorWheel::displayFlags(DisplayFlags mask) const void ColorWheel::setDefaultDisplayFlags(DisplayFlags flags) { - if ( !(flags & COLOR_FLAGS) ) + if (!(flags & COLOR_FLAGS)) flags |= hard_default_flags & COLOR_FLAGS; - if ( !(flags & ANGLE_FLAGS) ) + if (!(flags & ANGLE_FLAGS)) flags |= hard_default_flags & ANGLE_FLAGS; - if ( !(flags & SHAPE_FLAGS) ) + if (!(flags & SHAPE_FLAGS)) flags |= hard_default_flags & SHAPE_FLAGS; default_flags = flags; } @@ -548,28 +517,25 @@ ColorWheel::DisplayFlags ColorWheel::defaultDisplayFlags(DisplayFlags mask) void ColorWheel::setDisplayFlag(DisplayFlags flag, DisplayFlags mask) { - setDisplayFlags((p->display_flags&~mask)|flag); + setDisplayFlags((p->display_flags & ~mask) | flag); } void ColorWheel::dragEnterEvent(QDragEnterEvent* event) { - if ( event->mimeData()->hasColor() || - ( event->mimeData()->hasText() && QColor(event->mimeData()->text()).isValid() ) ) + if (event->mimeData()->hasColor() || + (event->mimeData()->hasText() && + QColor(event->mimeData()->text()).isValid())) event->acceptProposedAction(); } void ColorWheel::dropEvent(QDropEvent* event) { - if ( event->mimeData()->hasColor() ) - { + if (event->mimeData()->hasColor()) { setColor(event->mimeData()->colorData().value()); event->accept(); - } - else if ( event->mimeData()->hasText() ) - { + } else if (event->mimeData()->hasText()) { QColor col(event->mimeData()->text()); - if ( col.isValid() ) - { + if (col.isValid()) { setColor(col); event->accept(); } diff --git a/src/third-party/singleapplication/singleapplication.cpp b/src/third-party/singleapplication/singleapplication.cpp index 1f34c7ed..093c52e5 100644 --- a/src/third-party/singleapplication/singleapplication.cpp +++ b/src/third-party/singleapplication/singleapplication.cpp @@ -22,48 +22,49 @@ #include +#include +#include +#include +#include +#include #include #include -#include #include #include #include -#include -#include #include #include -#include -#include #ifdef Q_OS_UNIX - #include - #include +#include +#include #endif #ifdef Q_OS_WIN - #include - #include +#include +#include #endif #include "singleapplication.h" #include "singleapplication_p.h" - -SingleApplicationPrivate::SingleApplicationPrivate( SingleApplication *q_ptr ) : q_ptr( q_ptr ) { +SingleApplicationPrivate::SingleApplicationPrivate(SingleApplication* q_ptr) + : q_ptr(q_ptr) +{ server = nullptr; socket = nullptr; } SingleApplicationPrivate::~SingleApplicationPrivate() { - if( socket != nullptr ) { + if (socket != nullptr) { socket->close(); delete socket; } memory->lock(); InstancesInfo* inst = static_cast(memory->data()); - if( server != nullptr ) { + if (server != nullptr) { server->close(); delete server; inst->primary = false; @@ -74,51 +75,57 @@ SingleApplicationPrivate::~SingleApplicationPrivate() delete memory; } -void SingleApplicationPrivate::genBlockServerName( int timeout ) +void SingleApplicationPrivate::genBlockServerName(int timeout) { - QCryptographicHash appData( QCryptographicHash::Sha256 ); - appData.addData( "SingleApplication", 17 ); - appData.addData( SingleApplication::app_t::applicationName().toUtf8() ); - appData.addData( SingleApplication::app_t::organizationName().toUtf8() ); - appData.addData( SingleApplication::app_t::organizationDomain().toUtf8() ); + QCryptographicHash appData(QCryptographicHash::Sha256); + appData.addData("SingleApplication", 17); + appData.addData(SingleApplication::app_t::applicationName().toUtf8()); + appData.addData(SingleApplication::app_t::organizationName().toUtf8()); + appData.addData(SingleApplication::app_t::organizationDomain().toUtf8()); - if( ! (options & SingleApplication::Mode::ExcludeAppVersion) ) { - appData.addData( SingleApplication::app_t::applicationVersion().toUtf8() ); + if (!(options & SingleApplication::Mode::ExcludeAppVersion)) { + appData.addData( + SingleApplication::app_t::applicationVersion().toUtf8()); } - if( ! (options & SingleApplication::Mode::ExcludeAppPath) ) { + if (!(options & SingleApplication::Mode::ExcludeAppPath)) { #ifdef Q_OS_WIN - appData.addData( SingleApplication::app_t::applicationFilePath().toLower().toUtf8() ); + appData.addData( + SingleApplication::app_t::applicationFilePath().toLower().toUtf8()); #else - appData.addData( SingleApplication::app_t::applicationFilePath().toUtf8() ); + appData.addData( + SingleApplication::app_t::applicationFilePath().toUtf8()); #endif } // User level block requires a user specific data in the hash - if( options & SingleApplication::Mode::User ) { + if (options & SingleApplication::Mode::User) { #ifdef Q_OS_WIN Q_UNUSED(timeout); - wchar_t username [ UNLEN + 1 ]; + wchar_t username[UNLEN + 1]; // Specifies size of the buffer on input DWORD usernameLength = UNLEN + 1; - if( GetUserNameW( username, &usernameLength ) ) { - appData.addData( QString::fromWCharArray(username).toUtf8() ); + if (GetUserNameW(username, &usernameLength)) { + appData.addData(QString::fromWCharArray(username).toUtf8()); } else { - appData.addData( QStandardPaths::standardLocations( QStandardPaths::HomeLocation ).join("").toUtf8() ); + appData.addData( + QStandardPaths::standardLocations(QStandardPaths::HomeLocation) + .join("") + .toUtf8()); } #endif #ifdef Q_OS_UNIX QProcess process; - process.start( QStringLiteral("whoami") ); - if( process.waitForFinished( timeout ) && + process.start(QStringLiteral("whoami")); + if (process.waitForFinished(timeout) && process.exitCode() == QProcess::NormalExit) { - appData.addData( process.readLine() ); + appData.addData(process.readLine()); } else { - appData.addData( - QDir( - QStandardPaths::standardLocations( QStandardPaths::HomeLocation ).first() - ).absolutePath().toUtf8() - ); + appData.addData(QDir(QStandardPaths::standardLocations( + QStandardPaths::HomeLocation) + .first()) + .absolutePath() + .toUtf8()); } #endif } @@ -128,7 +135,7 @@ void SingleApplicationPrivate::genBlockServerName( int timeout ) blockServerName = appData.result().toBase64().replace("/", "_"); } -void SingleApplicationPrivate::startPrimary( bool resetMemory ) +void SingleApplicationPrivate::startPrimary(bool resetMemory) { Q_Q(SingleApplication); @@ -139,30 +146,28 @@ void SingleApplicationPrivate::startPrimary( bool resetMemory ) #endif // Successful creation means that no main process exists // So we start a QLocalServer to listen for connections - QLocalServer::removeServer( blockServerName ); + QLocalServer::removeServer(blockServerName); server = new QLocalServer(); // Restrict access to the socket according to the // SingleApplication::Mode::User flag on User level or no restrictions - if( options & SingleApplication::Mode::User ) { - server->setSocketOptions( QLocalServer::UserAccessOption ); + if (options & SingleApplication::Mode::User) { + server->setSocketOptions(QLocalServer::UserAccessOption); } else { - server->setSocketOptions( QLocalServer::WorldAccessOption ); + server->setSocketOptions(QLocalServer::WorldAccessOption); } - server->listen( blockServerName ); - QObject::connect( - server, - &QLocalServer::newConnection, - this, - &SingleApplicationPrivate::slotConnectionEstablished - ); + server->listen(blockServerName); + QObject::connect(server, + &QLocalServer::newConnection, + this, + &SingleApplicationPrivate::slotConnectionEstablished); // Reset the number of connections memory->lock(); InstancesInfo* inst = static_cast(memory->data()); - if( resetMemory ) { + if (resetMemory) { inst->secondary = 0; } @@ -183,31 +188,32 @@ void SingleApplicationPrivate::startSecondary() #endif } -void SingleApplicationPrivate::connectToPrimary( int msecs, ConnectionType connectionType ) +void SingleApplicationPrivate::connectToPrimary(int msecs, + ConnectionType connectionType) { // Connect to the Local Server of the Primary Instance if not already // connected. - if( socket == nullptr ) { + if (socket == nullptr) { socket = new QLocalSocket(); } // If already connected - we are done; - if( socket->state() == QLocalSocket::ConnectedState ) + if (socket->state() == QLocalSocket::ConnectedState) return; // If not connect - if( socket->state() == QLocalSocket::UnconnectedState || - socket->state() == QLocalSocket::ClosingState ) { - socket->connectToServer( blockServerName ); + if (socket->state() == QLocalSocket::UnconnectedState || + socket->state() == QLocalSocket::ClosingState) { + socket->connectToServer(blockServerName); } // Wait for being connected - if( socket->state() == QLocalSocket::ConnectingState ) { - socket->waitForConnected( msecs ); + if (socket->state() == QLocalSocket::ConnectingState) { + socket->waitForConnected(msecs); } // Initialisation message according to the SingleApplication protocol - if( socket->state() == QLocalSocket::ConnectedState ) { + if (socket->state() == QLocalSocket::ConnectedState) { // Notify the parent that a new instance had been started; QByteArray initMsg; QDataStream writeStream(&initMsg, QIODevice::WriteOnly); @@ -215,12 +221,13 @@ void SingleApplicationPrivate::connectToPrimary( int msecs, ConnectionType conne writeStream << blockServerName.toLatin1(); writeStream << static_cast(connectionType); writeStream << instanceNumber; - quint16 checksum = qChecksum(initMsg.constData(), static_cast(initMsg.length())); + quint16 checksum = qChecksum(initMsg.constData(), + static_cast(initMsg.length())); writeStream << checksum; - socket->write( initMsg ); + socket->write(initMsg); socket->flush(); - socket->waitForBytesWritten( msecs ); + socket->waitForBytesWritten(msecs); } } @@ -237,31 +244,31 @@ qint64 SingleApplicationPrivate::primaryPid() } #ifdef Q_OS_UNIX - void SingleApplicationPrivate::crashHandler() - { - // Handle any further termination signals to ensure the - // QSharedMemory block is deleted even if the process crashes - signal( SIGHUP, SingleApplicationPrivate::terminate ); // 1 - signal( SIGINT, SingleApplicationPrivate::terminate ); // 2 - signal( SIGQUIT, SingleApplicationPrivate::terminate ); // 3 - signal( SIGILL, SingleApplicationPrivate::terminate ); // 4 - signal( SIGABRT, SingleApplicationPrivate::terminate ); // 6 - signal( SIGFPE, SingleApplicationPrivate::terminate ); // 8 - signal( SIGBUS, SingleApplicationPrivate::terminate ); // 10 - signal( SIGSEGV, SingleApplicationPrivate::terminate ); // 11 - signal( SIGSYS, SingleApplicationPrivate::terminate ); // 12 - signal( SIGPIPE, SingleApplicationPrivate::terminate ); // 13 - signal( SIGALRM, SingleApplicationPrivate::terminate ); // 14 - signal( SIGTERM, SingleApplicationPrivate::terminate ); // 15 - signal( SIGXCPU, SingleApplicationPrivate::terminate ); // 24 - signal( SIGXFSZ, SingleApplicationPrivate::terminate ); // 25 - } +void SingleApplicationPrivate::crashHandler() +{ + // Handle any further termination signals to ensure the + // QSharedMemory block is deleted even if the process crashes + signal(SIGHUP, SingleApplicationPrivate::terminate); // 1 + signal(SIGINT, SingleApplicationPrivate::terminate); // 2 + signal(SIGQUIT, SingleApplicationPrivate::terminate); // 3 + signal(SIGILL, SingleApplicationPrivate::terminate); // 4 + signal(SIGABRT, SingleApplicationPrivate::terminate); // 6 + signal(SIGFPE, SingleApplicationPrivate::terminate); // 8 + signal(SIGBUS, SingleApplicationPrivate::terminate); // 10 + signal(SIGSEGV, SingleApplicationPrivate::terminate); // 11 + signal(SIGSYS, SingleApplicationPrivate::terminate); // 12 + signal(SIGPIPE, SingleApplicationPrivate::terminate); // 13 + signal(SIGALRM, SingleApplicationPrivate::terminate); // 14 + signal(SIGTERM, SingleApplicationPrivate::terminate); // 15 + signal(SIGXCPU, SingleApplicationPrivate::terminate); // 24 + signal(SIGXFSZ, SingleApplicationPrivate::terminate); // 25 +} - void SingleApplicationPrivate::terminate( int signum ) - { - delete ((SingleApplication*)QCoreApplication::instance())->d_ptr; - ::exit( 128 + signum ); - } +void SingleApplicationPrivate::terminate(int signum) +{ + delete ((SingleApplication*)QCoreApplication::instance())->d_ptr; + ::exit(128 + signum); +} #endif /** @@ -271,13 +278,15 @@ void SingleApplicationPrivate::slotConnectionEstablished() { Q_Q(SingleApplication); - QLocalSocket *nextConnSocket = server->nextPendingConnection(); + QLocalSocket* nextConnSocket = server->nextPendingConnection(); quint32 instanceId = 0; ConnectionType connectionType = InvalidConnection; - if( nextConnSocket->waitForReadyRead( 100 ) ) { + if (nextConnSocket->waitForReadyRead(100)) { // read all data from message in same order/format as written - QByteArray msgBytes = nextConnSocket->read(nextConnSocket->bytesAvailable() - static_cast(sizeof(quint16))); + QByteArray msgBytes = + nextConnSocket->read(nextConnSocket->bytesAvailable() - + static_cast(sizeof(quint16))); QByteArray checksumBytes = nextConnSocket->read(sizeof(quint16)); QDataStream readStream(msgBytes); readStream.setVersion(QDataStream::Qt_5_2); @@ -297,60 +306,62 @@ void SingleApplicationPrivate::slotConnectionEstablished() checksumStream.setVersion(QDataStream::Qt_5_2); checksumStream >> msgChecksum; - const quint16 actualChecksum = qChecksum(msgBytes.constData(), static_cast(msgBytes.length())); + const quint16 actualChecksum = qChecksum( + msgBytes.constData(), static_cast(msgBytes.length())); - if (readStream.status() != QDataStream::Ok || QLatin1String(latin1Name) != blockServerName || msgChecksum != actualChecksum) { - connectionType = InvalidConnection; + if (readStream.status() != QDataStream::Ok || + QLatin1String(latin1Name) != blockServerName || + msgChecksum != actualChecksum) { + connectionType = InvalidConnection; } } - if( connectionType == InvalidConnection ) { + if (connectionType == InvalidConnection) { nextConnSocket->close(); delete nextConnSocket; return; } - QObject::connect( - nextConnSocket, - &QLocalSocket::aboutToClose, - this, - [nextConnSocket, instanceId, this]() { - emit this->slotClientConnectionClosed( nextConnSocket, instanceId ); - } - ); + QObject::connect(nextConnSocket, + &QLocalSocket::aboutToClose, + this, + [nextConnSocket, instanceId, this]() { + emit this->slotClientConnectionClosed(nextConnSocket, + instanceId); + }); - QObject::connect( - nextConnSocket, - &QLocalSocket::readyRead, - this, - [nextConnSocket, instanceId, this]() { - emit this->slotDataAvailable( nextConnSocket, instanceId ); - } - ); + QObject::connect(nextConnSocket, + &QLocalSocket::readyRead, + this, + [nextConnSocket, instanceId, this]() { + emit this->slotDataAvailable(nextConnSocket, + instanceId); + }); - if( connectionType == NewInstance || ( - connectionType == SecondaryInstance && - options & SingleApplication::Mode::SecondaryNotification - ) - ) { + if (connectionType == NewInstance || + (connectionType == SecondaryInstance && + options & SingleApplication::Mode::SecondaryNotification)) { emit q->instanceStarted(); } - if( nextConnSocket->bytesAvailable() > 0 ) { - emit this->slotDataAvailable( nextConnSocket, instanceId ); + if (nextConnSocket->bytesAvailable() > 0) { + emit this->slotDataAvailable(nextConnSocket, instanceId); } } -void SingleApplicationPrivate::slotDataAvailable( QLocalSocket *dataSocket, quint32 instanceId ) +void SingleApplicationPrivate::slotDataAvailable(QLocalSocket* dataSocket, + quint32 instanceId) { Q_Q(SingleApplication); - emit q->receivedMessage( instanceId, dataSocket->readAll() ); + emit q->receivedMessage(instanceId, dataSocket->readAll()); } -void SingleApplicationPrivate::slotClientConnectionClosed( QLocalSocket *closedSocket, quint32 instanceId ) +void SingleApplicationPrivate::slotClientConnectionClosed( + QLocalSocket* closedSocket, + quint32 instanceId) { - if( closedSocket->bytesAvailable() > 0 ) - emit slotDataAvailable( closedSocket, instanceId ); + if (closedSocket->bytesAvailable() > 0) + emit slotDataAvailable(closedSocket, instanceId); closedSocket->deleteLater(); } @@ -361,8 +372,13 @@ void SingleApplicationPrivate::slotClientConnectionClosed( QLocalSocket *closedS * @param argv * @param {bool} allowSecondaryInstances */ -SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSecondary, Options options, int timeout ) - : app_t( argc, argv ), d_ptr( new SingleApplicationPrivate( this ) ) +SingleApplication::SingleApplication(int& argc, + char* argv[], + bool allowSecondary, + Options options, + int timeout) + : app_t(argc, argv) + , d_ptr(new SingleApplicationPrivate(this)) { Q_D(SingleApplication); @@ -371,41 +387,43 @@ SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSeconda // Generating an application ID used for identifying the shared memory // block and QLocalServer - d->genBlockServerName( timeout ); + d->genBlockServerName(timeout); // Guarantee thread safe behaviour with a shared memory block. Also by // explicitly attaching it and then deleting it we make sure that the // memory is deleted even if the process had crashed on Unix. #ifdef Q_OS_UNIX - d->memory = new QSharedMemory( d->blockServerName ); + d->memory = new QSharedMemory(d->blockServerName); d->memory->attach(); delete d->memory; #endif - d->memory = new QSharedMemory( d->blockServerName ); + d->memory = new QSharedMemory(d->blockServerName); // Create a shared memory block - if( d->memory->create( sizeof( InstancesInfo ) ) ) { - d->startPrimary( true ); + if (d->memory->create(sizeof(InstancesInfo))) { + d->startPrimary(true); return; } else { // Attempt to attach to the memory segment - if( d->memory->attach() ) { + if (d->memory->attach()) { d->memory->lock(); - InstancesInfo* inst = static_cast(d->memory->data()); + InstancesInfo* inst = + static_cast(d->memory->data()); - if( ! inst->primary ) { - d->startPrimary( false ); + if (!inst->primary) { + d->startPrimary(false); d->memory->unlock(); return; } // Check if another instance can be started - if( allowSecondary ) { + if (allowSecondary) { inst->secondary += 1; d->instanceNumber = inst->secondary; d->startSecondary(); - if( d->options & Mode::SecondaryNotification ) { - d->connectToPrimary( timeout, SingleApplicationPrivate::SecondaryInstance ); + if (d->options & Mode::SecondaryNotification) { + d->connectToPrimary( + timeout, SingleApplicationPrivate::SecondaryInstance); } d->memory->unlock(); return; @@ -415,29 +433,28 @@ SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSeconda } } - d->connectToPrimary( timeout, SingleApplicationPrivate::NewInstance ); + d->connectToPrimary(timeout, SingleApplicationPrivate::NewInstance); delete d; // show message box with inforation that Flameshot is already launched QMessageBox msgBox; - msgBox.setText(QObject::tr("Hi, I'm already running!\nYou can find me in the system tray.")); + msgBox.setText(QObject::tr( + "Hi, I'm already running!\nYou can find me in the system tray.")); int cnt = 3; QTimer cntDown; QObject::connect( - &cntDown, - &QTimer::timeout, - [&msgBox,&cnt, &cntDown]()->void{ - if(--cnt < 0){ - cntDown.stop(); - msgBox.close(); - } else { - msgBox.setWindowTitle(QString("Flameshot (%1)").arg(cnt + 1)); - } - }); + &cntDown, &QTimer::timeout, [&msgBox, &cnt, &cntDown]() -> void { + if (--cnt < 0) { + cntDown.stop(); + msgBox.close(); + } else { + msgBox.setWindowTitle(QString("Flameshot (%1)").arg(cnt + 1)); + } + }); cntDown.start(1000); msgBox.exec(); - ::exit( EXIT_SUCCESS ); + ::exit(EXIT_SUCCESS); } /** @@ -473,18 +490,19 @@ qint64 SingleApplication::primaryPid() return d->primaryPid(); } -bool SingleApplication::sendMessage( QByteArray message, int timeout ) +bool SingleApplication::sendMessage(QByteArray message, int timeout) { Q_D(SingleApplication); // Nobody to connect to - if( isPrimary() ) return false; + if (isPrimary()) + return false; // Make sure the socket is connected - d->connectToPrimary( timeout, SingleApplicationPrivate::Reconnect ); + d->connectToPrimary(timeout, SingleApplicationPrivate::Reconnect); - d->socket->write( message ); + d->socket->write(message); bool dataWritten = d->socket->flush(); - d->socket->waitForBytesWritten( timeout ); + d->socket->waitForBytesWritten(timeout); return dataWritten; } diff --git a/src/third-party/singleapplication/singleapplication.h b/src/third-party/singleapplication/singleapplication.h index 33a9898a..18115af4 100644 --- a/src/third-party/singleapplication/singleapplication.h +++ b/src/third-party/singleapplication/singleapplication.h @@ -27,7 +27,7 @@ #include #ifndef QAPPLICATION_CLASS - #define QAPPLICATION_CLASS QCoreApplication +#define QAPPLICATION_CLASS QCoreApplication #endif #include QT_STRINGIFY(QAPPLICATION_CLASS) @@ -56,12 +56,13 @@ public: * block will be user wide. * @enum */ - enum Mode { - User = 1 << 0, - System = 1 << 1, - SecondaryNotification = 1 << 2, - ExcludeAppVersion = 1 << 3, - ExcludeAppPath = 1 << 4 + enum Mode + { + User = 1 << 0, + System = 1 << 1, + SecondaryNotification = 1 << 2, + ExcludeAppVersion = 1 << 3, + ExcludeAppPath = 1 << 4 }; Q_DECLARE_FLAGS(Options, Mode) @@ -85,7 +86,11 @@ public: * Usually 4*timeout would be the worst case (fail) scenario. * @see See the corresponding QAPPLICATION_CLASS constructor for reference */ - explicit SingleApplication( int &argc, char *argv[], bool allowSecondary = false, Options options = Mode::User, int timeout = 100 ); + explicit SingleApplication(int& argc, + char* argv[], + bool allowSecondary = false, + Options options = Mode::User, + int timeout = 100); ~SingleApplication(); /** @@ -119,14 +124,14 @@ public: * @note sendMessage() will return false if invoked from the primary * instance. */ - bool sendMessage( QByteArray message, int timeout = 100 ); + bool sendMessage(QByteArray message, int timeout = 100); Q_SIGNALS: void instanceStarted(); - void receivedMessage( quint32 instanceId, QByteArray message ); + void receivedMessage(quint32 instanceId, QByteArray message); private: - SingleApplicationPrivate *d_ptr; + SingleApplicationPrivate* d_ptr; Q_DECLARE_PRIVATE(SingleApplication) }; diff --git a/src/third-party/singleapplication/singleapplication_p.h b/src/third-party/singleapplication/singleapplication_p.h index a990a53c..491f246d 100644 --- a/src/third-party/singleapplication/singleapplication_p.h +++ b/src/third-party/singleapplication/singleapplication_p.h @@ -32,21 +32,24 @@ #ifndef SINGLEAPPLICATION_P_H #define SINGLEAPPLICATION_P_H +#include "singleapplication.h" #include #include #include -#include "singleapplication.h" -struct InstancesInfo { +struct InstancesInfo +{ bool primary; quint32 secondary; qint64 primaryPid; }; -class SingleApplicationPrivate : public QObject { -Q_OBJECT +class SingleApplicationPrivate : public QObject +{ + Q_OBJECT public: - enum ConnectionType : quint8 { + enum ConnectionType : quint8 + { InvalidConnection = 0, NewInstance = 1, SecondaryInstance = 2, @@ -54,32 +57,32 @@ public: }; Q_DECLARE_PUBLIC(SingleApplication) - SingleApplicationPrivate( SingleApplication *q_ptr ); - ~SingleApplicationPrivate(); + SingleApplicationPrivate(SingleApplication* q_ptr); + ~SingleApplicationPrivate(); - void genBlockServerName( int msecs ); - void startPrimary( bool resetMemory ); + void genBlockServerName(int msecs); + void startPrimary(bool resetMemory); void startSecondary(); - void connectToPrimary(int msecs, ConnectionType connectionType ); + void connectToPrimary(int msecs, ConnectionType connectionType); qint64 primaryPid(); #ifdef Q_OS_UNIX void crashHandler(); - static void terminate( int signum ); + static void terminate(int signum); #endif - QSharedMemory *memory; - SingleApplication *q_ptr; - QLocalSocket *socket; - QLocalServer *server; + QSharedMemory* memory; + SingleApplication* q_ptr; + QLocalSocket* socket; + QLocalServer* server; quint32 instanceNumber; QString blockServerName; SingleApplication::Options options; public Q_SLOTS: void slotConnectionEstablished(); - void slotDataAvailable( QLocalSocket*, quint32 ); - void slotClientConnectionClosed( QLocalSocket*, quint32 ); + void slotDataAvailable(QLocalSocket*, quint32); + void slotClientConnectionClosed(QLocalSocket*, quint32); }; #endif // SINGLEAPPLICATION_P_H diff --git a/src/tools/abstractactiontool.cpp b/src/tools/abstractactiontool.cpp index 09eb8b32..bc5dc391 100644 --- a/src/tools/abstractactiontool.cpp +++ b/src/tools/abstractactiontool.cpp @@ -17,55 +17,67 @@ #include "abstractactiontool.h" -AbstractActionTool::AbstractActionTool(QObject *parent) : CaptureTool(parent) { +AbstractActionTool::AbstractActionTool(QObject* parent) + : CaptureTool(parent) +{} -} - -bool AbstractActionTool::isValid() const { +bool AbstractActionTool::isValid() const +{ return true; } -bool AbstractActionTool::isSelectable() const { +bool AbstractActionTool::isSelectable() const +{ return false; } -bool AbstractActionTool::showMousePreview() const { +bool AbstractActionTool::showMousePreview() const +{ return false; } -void AbstractActionTool::undo(QPixmap &pixmap) { +void AbstractActionTool::undo(QPixmap& pixmap) +{ Q_UNUSED(pixmap); } -void AbstractActionTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) { +void AbstractActionTool::process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo) +{ Q_UNUSED(painter); Q_UNUSED(pixmap); Q_UNUSED(recordUndo); } -void AbstractActionTool::paintMousePreview( - QPainter &painter, const CaptureContext &context) +void AbstractActionTool::paintMousePreview(QPainter& painter, + const CaptureContext& context) { Q_UNUSED(painter); Q_UNUSED(context); } -void AbstractActionTool::drawEnd(const QPoint &p) { +void AbstractActionTool::drawEnd(const QPoint& p) +{ Q_UNUSED(p); } -void AbstractActionTool::drawMove(const QPoint &p) { +void AbstractActionTool::drawMove(const QPoint& p) +{ Q_UNUSED(p); } -void AbstractActionTool::drawStart(const CaptureContext &context) { +void AbstractActionTool::drawStart(const CaptureContext& context) +{ Q_UNUSED(context); } -void AbstractActionTool::colorChanged(const QColor &c) { +void AbstractActionTool::colorChanged(const QColor& c) +{ Q_UNUSED(c); } -void AbstractActionTool::thicknessChanged(const int th) { +void AbstractActionTool::thicknessChanged(const int th) +{ Q_UNUSED(th); } diff --git a/src/tools/abstractactiontool.h b/src/tools/abstractactiontool.h index cf1180c4..1dba903c 100644 --- a/src/tools/abstractactiontool.h +++ b/src/tools/abstractactiontool.h @@ -19,23 +19,27 @@ #include "capturetool.h" -class AbstractActionTool : public CaptureTool { +class AbstractActionTool : public CaptureTool +{ Q_OBJECT public: - explicit AbstractActionTool(QObject *parent = nullptr); + explicit AbstractActionTool(QObject* parent = nullptr); bool isValid() const override; bool isSelectable() const override; bool showMousePreview() const override; - void undo(QPixmap &pixmap) override; - void process(QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) override; - void paintMousePreview(QPainter &painter, const CaptureContext &context) override; + void undo(QPixmap& pixmap) override; + void process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo = false) override; + void paintMousePreview(QPainter& painter, + const CaptureContext& context) override; public slots: - void drawEnd(const QPoint &p) override; - void drawMove(const QPoint &p) override; - void drawStart(const CaptureContext &context) override; - void colorChanged(const QColor &c) override; + void drawEnd(const QPoint& p) override; + void drawMove(const QPoint& p) override; + void drawStart(const CaptureContext& context) override; + void colorChanged(const QColor& c) override; void thicknessChanged(const int th) override; }; diff --git a/src/tools/abstractpathtool.cpp b/src/tools/abstractpathtool.cpp index 7f212c91..67a8b6d2 100644 --- a/src/tools/abstractpathtool.cpp +++ b/src/tools/abstractpathtool.cpp @@ -17,59 +17,69 @@ #include "abstractpathtool.h" -AbstractPathTool::AbstractPathTool(QObject *parent) : - CaptureTool(parent), m_thickness(0), m_padding(0) +AbstractPathTool::AbstractPathTool(QObject* parent) + : CaptureTool(parent) + , m_thickness(0) + , m_padding(0) +{} + +bool AbstractPathTool::isValid() const { - -} - -bool AbstractPathTool::isValid() const { return m_points.length() > 1; } -bool AbstractPathTool::closeOnButtonPressed() const { +bool AbstractPathTool::closeOnButtonPressed() const +{ return false; } -bool AbstractPathTool::isSelectable() const { +bool AbstractPathTool::isSelectable() const +{ return true; } -bool AbstractPathTool::showMousePreview() const { +bool AbstractPathTool::showMousePreview() const +{ return true; } -void AbstractPathTool::undo(QPixmap &pixmap) { +void AbstractPathTool::undo(QPixmap& pixmap) +{ QPainter p(&pixmap); const int val = m_thickness + m_padding; QRect area = m_backupArea + QMargins(val, val, val, val); - p.drawPixmap(area.intersected(pixmap.rect()) - .topLeft(), m_pixmapBackup); + p.drawPixmap(area.intersected(pixmap.rect()).topLeft(), m_pixmapBackup); } -void AbstractPathTool::drawEnd(const QPoint &p) { +void AbstractPathTool::drawEnd(const QPoint& p) +{ Q_UNUSED(p); } -void AbstractPathTool::drawMove(const QPoint &p) { +void AbstractPathTool::drawMove(const QPoint& p) +{ addPoint(p); } -void AbstractPathTool::colorChanged(const QColor &c) { +void AbstractPathTool::colorChanged(const QColor& c) +{ m_color = c; } -void AbstractPathTool::thicknessChanged(const int th) { +void AbstractPathTool::thicknessChanged(const int th) +{ m_thickness = th; } -void AbstractPathTool::updateBackup(const QPixmap &pixmap) { +void AbstractPathTool::updateBackup(const QPixmap& pixmap) +{ const int val = m_thickness + m_padding; QRect area = m_backupArea.normalized() + QMargins(val, val, val, val); m_pixmapBackup = pixmap.copy(area); } -void AbstractPathTool::addPoint(const QPoint &point) { +void AbstractPathTool::addPoint(const QPoint& point) +{ if (m_backupArea.left() > point.x()) { m_backupArea.setLeft(point.x()); } else if (m_backupArea.right() < point.x()) { diff --git a/src/tools/abstractpathtool.h b/src/tools/abstractpathtool.h index e2d0a536..8b4a93f9 100644 --- a/src/tools/abstractpathtool.h +++ b/src/tools/abstractpathtool.h @@ -19,27 +19,28 @@ #include "capturetool.h" -class AbstractPathTool : public CaptureTool { +class AbstractPathTool : public CaptureTool +{ Q_OBJECT public: - explicit AbstractPathTool(QObject *parent = nullptr); + explicit AbstractPathTool(QObject* parent = nullptr); bool isValid() const override; bool closeOnButtonPressed() const override; bool isSelectable() const override; bool showMousePreview() const override; - void undo(QPixmap &pixmap) override; + void undo(QPixmap& pixmap) override; public slots: - void drawEnd(const QPoint &p) override; - void drawMove(const QPoint &p) override; - void colorChanged(const QColor &c) override; + void drawEnd(const QPoint& p) override; + void drawMove(const QPoint& p) override; + void colorChanged(const QColor& c) override; void thicknessChanged(const int th) override; protected: - void updateBackup(const QPixmap &pixmap); - void addPoint(const QPoint &point); + void updateBackup(const QPixmap& pixmap); + void addPoint(const QPoint& point); QPixmap m_pixmapBackup; QRect m_backupArea; diff --git a/src/tools/abstracttwopointtool.cpp b/src/tools/abstracttwopointtool.cpp index 3061c98c..820ada93 100644 --- a/src/tools/abstracttwopointtool.cpp +++ b/src/tools/abstracttwopointtool.cpp @@ -23,7 +23,8 @@ namespace { const double ADJ_UNIT = std::atan(1.0); const int DIRS_NUMBER = 4; -enum UNIT { +enum UNIT +{ HORIZ_DIR = 0, DIAG1_DIR = 1, VERT_DIR = 2, @@ -33,74 +34,90 @@ enum UNIT { const double ADJ_DIAG_UNIT = 2 * ADJ_UNIT; const int DIAG_DIRS_NUMBER = 2; -enum DIAG_UNIT { +enum DIAG_UNIT +{ DIR1 = 0, DIR2 = 1 }; } -AbstractTwoPointTool::AbstractTwoPointTool(QObject *parent) : - CaptureTool(parent), m_thickness(0), m_padding(0) +AbstractTwoPointTool::AbstractTwoPointTool(QObject* parent) + : CaptureTool(parent) + , m_thickness(0) + , m_padding(0) +{} + +bool AbstractTwoPointTool::isValid() const { - -} - -bool AbstractTwoPointTool::isValid() const { return (m_points.first != m_points.second); } -bool AbstractTwoPointTool::closeOnButtonPressed() const { +bool AbstractTwoPointTool::closeOnButtonPressed() const +{ return false; } -bool AbstractTwoPointTool::isSelectable() const { +bool AbstractTwoPointTool::isSelectable() const +{ return true; } -bool AbstractTwoPointTool::showMousePreview() const { +bool AbstractTwoPointTool::showMousePreview() const +{ return true; } -void AbstractTwoPointTool::undo(QPixmap &pixmap) { +void AbstractTwoPointTool::undo(QPixmap& pixmap) +{ QPainter p(&pixmap); p.drawPixmap(backupRect(pixmap.rect()).topLeft(), m_pixmapBackup); } -void AbstractTwoPointTool::drawEnd(const QPoint &p) { +void AbstractTwoPointTool::drawEnd(const QPoint& p) +{ Q_UNUSED(p); } -void AbstractTwoPointTool::drawMove(const QPoint &p) { +void AbstractTwoPointTool::drawMove(const QPoint& p) +{ m_points.second = p; } -void AbstractTwoPointTool::drawMoveWithAdjustment(const QPoint &p) { +void AbstractTwoPointTool::drawMoveWithAdjustment(const QPoint& p) +{ m_points.second = m_points.first + adjustedVector(p - m_points.first); } -void AbstractTwoPointTool::colorChanged(const QColor &c) { +void AbstractTwoPointTool::colorChanged(const QColor& c) +{ m_color = c; } -void AbstractTwoPointTool::thicknessChanged(const int th) { +void AbstractTwoPointTool::thicknessChanged(const int th) +{ m_thickness = th; } -void AbstractTwoPointTool::updateBackup(const QPixmap &pixmap) { +void AbstractTwoPointTool::updateBackup(const QPixmap& pixmap) +{ m_pixmapBackup = pixmap.copy(backupRect(pixmap.rect())); } -QRect AbstractTwoPointTool::backupRect(const QRect &limits) const { +QRect AbstractTwoPointTool::backupRect(const QRect& limits) const +{ QRect r = QRect(m_points.first, m_points.second).normalized(); const int val = m_thickness + m_padding; r += QMargins(val, val, val, val); return r.intersected(limits); } -QPoint AbstractTwoPointTool::adjustedVector(QPoint v) const { +QPoint AbstractTwoPointTool::adjustedVector(QPoint v) const +{ if (m_supportsOrthogonalAdj && m_supportsDiagonalAdj) { - int dir = ( static_cast(round(atan2(-v.y(), v.x()) / ADJ_UNIT)) + DIRS_NUMBER ) % DIRS_NUMBER; + int dir = (static_cast(round(atan2(-v.y(), v.x()) / ADJ_UNIT)) + + DIRS_NUMBER) % + DIRS_NUMBER; if (dir == UNIT::HORIZ_DIR) { v.setY(0); } else if (dir == UNIT::VERT_DIR) { @@ -117,8 +134,11 @@ QPoint AbstractTwoPointTool::adjustedVector(QPoint v) const { v.setY(newY); } } else if (m_supportsDiagonalAdj) { - int dir = ( static_cast(round((atan2(-v.y(), v.x()) - ADJ_DIAG_UNIT / 2) / ADJ_DIAG_UNIT)) - + DIAG_DIRS_NUMBER ) % DIAG_DIRS_NUMBER; + int dir = + (static_cast(round((atan2(-v.y(), v.x()) - ADJ_DIAG_UNIT / 2) / + ADJ_DIAG_UNIT)) + + DIAG_DIRS_NUMBER) % + DIAG_DIRS_NUMBER; if (dir == DIAG_UNIT::DIR1) { int newX = (v.x() - v.y()) / 2; int newY = -newX; diff --git a/src/tools/abstracttwopointtool.h b/src/tools/abstracttwopointtool.h index 9a979ef3..3a83bbec 100644 --- a/src/tools/abstracttwopointtool.h +++ b/src/tools/abstracttwopointtool.h @@ -19,28 +19,29 @@ #include "capturetool.h" -class AbstractTwoPointTool : public CaptureTool { +class AbstractTwoPointTool : public CaptureTool +{ Q_OBJECT public: - explicit AbstractTwoPointTool(QObject *parent = nullptr); + explicit AbstractTwoPointTool(QObject* parent = nullptr); bool isValid() const override; bool closeOnButtonPressed() const override; bool isSelectable() const override; bool showMousePreview() const override; - void undo(QPixmap &pixmap) override; + void undo(QPixmap& pixmap) override; public slots: - void drawEnd(const QPoint &p) override; - void drawMove(const QPoint &p) override; - void drawMoveWithAdjustment(const QPoint &p) override; - void colorChanged(const QColor &c) override; + void drawEnd(const QPoint& p) override; + void drawMove(const QPoint& p) override; + void drawMoveWithAdjustment(const QPoint& p) override; + void colorChanged(const QColor& c) override; void thicknessChanged(const int th) override; protected: - void updateBackup(const QPixmap &pixmap); - QRect backupRect(const QRect &limits) const; + void updateBackup(const QPixmap& pixmap); + QRect backupRect(const QRect& limits) const; QPixmap m_pixmapBackup; QPair m_points; diff --git a/src/tools/arrow/arrowtool.cpp b/src/tools/arrow/arrowtool.cpp index dd854017..c8b8030c 100644 --- a/src/tools/arrow/arrowtool.cpp +++ b/src/tools/arrow/arrowtool.cpp @@ -24,25 +24,26 @@ namespace { const int ArrowWidth = 10; const int ArrowHeight = 18; -QPainterPath getArrowHead(QPoint p1, QPoint p2, const int thickness) { +QPainterPath getArrowHead(QPoint p1, QPoint p2, const int thickness) +{ QLineF base(p1, p2); // Create the vector for the position of the base of the arrowhead - QLineF temp(QPoint(0,0), p2-p1); - int val = ArrowHeight + thickness*4; + QLineF temp(QPoint(0, 0), p2 - p1); + int val = ArrowHeight + thickness * 4; if (base.length() < val) { - val = (base.length() + thickness*2); + val = (base.length() + thickness * 2); } - temp.setLength(base.length() + thickness*2 - val); + temp.setLength(base.length() + thickness * 2 - val); // Move across the line up to the head QPointF bottonTranslation(temp.p2()); // Rotate base of the arrowhead - base.setLength(ArrowWidth + thickness*2); + base.setLength(ArrowWidth + thickness * 2); base.setAngle(base.angle() + 90); // Move to the correct point QPointF temp2 = p1 - base.p2(); // Center it - QPointF centerTranslation((temp2.x()/2), (temp2.y()/2)); + QPointF centerTranslation((temp2.x() / 2), (temp2.y() / 2)); base.translate(bottonTranslation); base.translate(centerTranslation); @@ -56,65 +57,82 @@ QPainterPath getArrowHead(QPoint p1, QPoint p2, const int thickness) { } // gets a shorter line to prevent overlap in the point of the arrow -QLine getShorterLine(QPoint p1, QPoint p2, const int thickness) { +QLine getShorterLine(QPoint p1, QPoint p2, const int thickness) +{ QLineF l(p1, p2); - int val = ArrowHeight + thickness*4; + int val = ArrowHeight + thickness * 4; if (l.length() < val) { - val = (l.length() + thickness*2); + val = (l.length() + thickness * 2); } - l.setLength(l.length() + thickness*2 - val); + l.setLength(l.length() + thickness * 2 - val); return l.toLine(); } } // unnamed namespace -ArrowTool::ArrowTool(QObject *parent) : AbstractTwoPointTool(parent) { +ArrowTool::ArrowTool(QObject* parent) + : AbstractTwoPointTool(parent) +{ m_padding = ArrowWidth / 2; m_supportsOrthogonalAdj = true; m_supportsDiagonalAdj = true; } -QIcon ArrowTool::icon(const QColor &background, bool inEditor) const { +QIcon ArrowTool::icon(const QColor& background, bool inEditor) const +{ Q_UNUSED(inEditor); return QIcon(iconPath(background) + "arrow-bottom-left.svg"); } -QString ArrowTool::name() const { +QString ArrowTool::name() const +{ return tr("Arrow"); } -QString ArrowTool::nameID() { +QString ArrowTool::nameID() +{ return QLatin1String(""); } -QString ArrowTool::description() const { +QString ArrowTool::description() const +{ return tr("Set the Arrow as the paint tool"); } -CaptureTool* ArrowTool::copy(QObject *parent) { +CaptureTool* ArrowTool::copy(QObject* parent) +{ return new ArrowTool(parent); } -void ArrowTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) { +void ArrowTool::process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo) +{ if (recordUndo) { updateBackup(pixmap); } painter.setPen(QPen(m_color, m_thickness)); - painter.drawLine(getShorterLine(m_points.first, m_points.second, m_thickness)); - painter.fillPath(getArrowHead(m_points.first, m_points.second, m_thickness), QBrush(m_color)); + painter.drawLine( + getShorterLine(m_points.first, m_points.second, m_thickness)); + painter.fillPath(getArrowHead(m_points.first, m_points.second, m_thickness), + QBrush(m_color)); } -void ArrowTool::paintMousePreview(QPainter &painter, const CaptureContext &context) { +void ArrowTool::paintMousePreview(QPainter& painter, + const CaptureContext& context) +{ painter.setPen(QPen(context.color, PADDING_VALUE + context.thickness)); painter.drawLine(context.mousePos, context.mousePos); } -void ArrowTool::drawStart(const CaptureContext &context) { +void ArrowTool::drawStart(const CaptureContext& context) +{ m_color = context.color; m_thickness = context.thickness + PADDING_VALUE; m_points.first = context.mousePos; m_points.second = context.mousePos; } -void ArrowTool::pressed(const CaptureContext &context) { +void ArrowTool::pressed(const CaptureContext& context) +{ Q_UNUSED(context); } diff --git a/src/tools/arrow/arrowtool.h b/src/tools/arrow/arrowtool.h index 9d81452a..73828500 100644 --- a/src/tools/arrow/arrowtool.h +++ b/src/tools/arrow/arrowtool.h @@ -20,22 +20,25 @@ #include "src/tools/abstracttwopointtool.h" #include -class ArrowTool : public AbstractTwoPointTool { +class ArrowTool : public AbstractTwoPointTool +{ Q_OBJECT public: - explicit ArrowTool(QObject *parent = nullptr); + explicit ArrowTool(QObject* parent = nullptr); - QIcon icon(const QColor &background, bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; - CaptureTool* copy(QObject *parent = nullptr) override; - void process( - QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) override; - void paintMousePreview(QPainter &painter, const CaptureContext &context) override; + CaptureTool* copy(QObject* parent = nullptr) override; + void process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo = false) override; + void paintMousePreview(QPainter& painter, + const CaptureContext& context) override; public slots: - void drawStart(const CaptureContext &context) override; - void pressed(const CaptureContext &context) override; + void drawStart(const CaptureContext& context) override; + void pressed(const CaptureContext& context) override; }; diff --git a/src/tools/blur/blurtool.cpp b/src/tools/blur/blurtool.cpp index b731715c..3bc0403a 100644 --- a/src/tools/blur/blurtool.cpp +++ b/src/tools/blur/blurtool.cpp @@ -16,51 +16,60 @@ // along with Flameshot. If not, see . #include "blurtool.h" -#include +#include #include #include #include -#include +#include -BlurTool::BlurTool(QObject *parent) : AbstractTwoPointTool(parent) { +BlurTool::BlurTool(QObject* parent) + : AbstractTwoPointTool(parent) +{} -} - -QIcon BlurTool::icon(const QColor &background, bool inEditor) const { +QIcon BlurTool::icon(const QColor& background, bool inEditor) const +{ Q_UNUSED(inEditor); return QIcon(iconPath(background) + "blur.svg"); } -QString BlurTool::name() const { +QString BlurTool::name() const +{ return tr("Blur"); } -QString BlurTool::nameID() { +QString BlurTool::nameID() +{ return QLatin1String(""); } -QString BlurTool::description() const { +QString BlurTool::description() const +{ return tr("Set Blur as the paint tool"); } -CaptureTool* BlurTool::copy(QObject *parent) { +CaptureTool* BlurTool::copy(QObject* parent) +{ return new BlurTool(parent); } -void BlurTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) { +void BlurTool::process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo) +{ if (recordUndo) { updateBackup(pixmap); } - QPoint &p0 = m_points.first; - QPoint &p1 = m_points.second; + QPoint& p0 = m_points.first; + QPoint& p1 = m_points.second; auto pixelRatio = pixmap.devicePixelRatio(); QRect selection = QRect(p0, p1).normalized(); - QRect selectionScaled = QRect(p0 * pixelRatio, p1 * pixelRatio).normalized(); + QRect selectionScaled = + QRect(p0 * pixelRatio, p1 * pixelRatio).normalized(); - QGraphicsBlurEffect *blur = new QGraphicsBlurEffect; + QGraphicsBlurEffect* blur = new QGraphicsBlurEffect; blur->setBlurRadius(10); - QGraphicsPixmapItem *item = new QGraphicsPixmapItem ( - pixmap.copy(selectionScaled)); + QGraphicsPixmapItem* item = + new QGraphicsPixmapItem(pixmap.copy(selectionScaled)); item->setGraphicsEffect(blur); QGraphicsScene scene; @@ -68,22 +77,26 @@ void BlurTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo scene.render(&painter, selection, QRectF()); blur->setBlurRadius(12); - for(int cnt = 100; cnt > 0; cnt--){ + for (int cnt = 100; cnt > 0; cnt--) { scene.render(&painter, selection, QRectF()); } } -void BlurTool::paintMousePreview(QPainter &painter, const CaptureContext &context) { +void BlurTool::paintMousePreview(QPainter& painter, + const CaptureContext& context) +{ Q_UNUSED(context); Q_UNUSED(painter); } -void BlurTool::drawStart(const CaptureContext &context) { +void BlurTool::drawStart(const CaptureContext& context) +{ m_thickness = context.thickness; m_points.first = context.mousePos; m_points.second = context.mousePos; } -void BlurTool::pressed(const CaptureContext &context) { +void BlurTool::pressed(const CaptureContext& context) +{ Q_UNUSED(context); } diff --git a/src/tools/blur/blurtool.h b/src/tools/blur/blurtool.h index aa549a61..36b8dfda 100644 --- a/src/tools/blur/blurtool.h +++ b/src/tools/blur/blurtool.h @@ -19,22 +19,25 @@ #include "src/tools/abstracttwopointtool.h" -class BlurTool : public AbstractTwoPointTool { +class BlurTool : public AbstractTwoPointTool +{ Q_OBJECT public: - explicit BlurTool(QObject *parent = nullptr); + explicit BlurTool(QObject* parent = nullptr); - QIcon icon(const QColor &background, bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; - CaptureTool* copy(QObject *parent = nullptr) override; - void process( - QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) override; - void paintMousePreview(QPainter &painter, const CaptureContext &context) override; + CaptureTool* copy(QObject* parent = nullptr) override; + void process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo = false) override; + void paintMousePreview(QPainter& painter, + const CaptureContext& context) override; public slots: - void drawStart(const CaptureContext &context) override; - void pressed(const CaptureContext &context) override; + void drawStart(const CaptureContext& context) override; + void pressed(const CaptureContext& context) override; }; diff --git a/src/tools/capturecontext.cpp b/src/tools/capturecontext.cpp index 4e3c9773..4b0ebc32 100644 --- a/src/tools/capturecontext.cpp +++ b/src/tools/capturecontext.cpp @@ -17,7 +17,8 @@ #include "capturecontext.h" -QPixmap CaptureContext::selectedScreenshotArea() const { +QPixmap CaptureContext::selectedScreenshotArea() const +{ if (selection.isNull()) { return screenshot; } else { diff --git a/src/tools/capturecontext.h b/src/tools/capturecontext.h index 0175fe16..8912f967 100644 --- a/src/tools/capturecontext.h +++ b/src/tools/capturecontext.h @@ -17,12 +17,13 @@ #pragma once -#include -#include -#include #include +#include +#include +#include -struct CaptureContext { +struct CaptureContext +{ // screenshot with modifications QPixmap screenshot; // unmodified screenshot @@ -44,5 +45,5 @@ struct CaptureContext { // Mode of the capture widget bool fullscreen; - QPixmap selectedScreenshotArea() const ; + QPixmap selectedScreenshotArea() const; }; diff --git a/src/tools/capturetool.h b/src/tools/capturetool.h index d7aab848..77ce9015 100644 --- a/src/tools/capturetool.h +++ b/src/tools/capturetool.h @@ -23,12 +23,14 @@ #include #include -class CaptureTool : public QObject { +class CaptureTool : public QObject +{ Q_OBJECT public: // Request actions on the main widget - enum Request { + enum Request + { // Call close() in the editor. REQ_CLOSE_GUI, // Call hide() in the editor. @@ -64,9 +66,11 @@ public: REQ_ADD_EXTERNAL_WIDGETS, }; - explicit CaptureTool(QObject *parent = nullptr) : QObject(parent){} + explicit CaptureTool(QObject* parent = nullptr) + : QObject(parent) + {} - virtual void setCapture(const QPixmap &pixmap) {}; + virtual void setCapture(const QPixmap& pixmap){}; // Returns false when the tool is in an inconsistent state and shouldn't // be included in the tool undo/redo stack. @@ -82,8 +86,7 @@ public: // The icon of the tool. // inEditor is true when the icon is requested inside the editor // and false otherwise. - virtual QIcon icon(const QColor &background, - bool inEditor) const = 0; + virtual QIcon icon(const QColor& background, bool inEditor) const = 0; // Name displayed for the tool, this could be translated with tr() virtual QString name() const = 0; // Codename for the tool, this hsouldn't change as it is used as ID @@ -95,59 +98,53 @@ public: // if the type is TYPE_WIDGET the widget is loaded in the main widget. // If the type is TYPE_EXTERNAL_WIDGET it is created outside as an // individual widget. - virtual QWidget* widget() { - return nullptr; - } + virtual QWidget* widget() { return nullptr; } // When the tool is selected this method is called and the widget is added // to the configuration panel inside the main widget. - virtual QWidget* configurationWidget() { - return nullptr; - } + virtual QWidget* configurationWidget() { return nullptr; } // Permanent configuration used in the configuration outside of the // capture. - virtual QWidget* permanentConfigurationWidget() { - return nullptr; - } + virtual QWidget* permanentConfigurationWidget() { return nullptr; } // Return a copy of the tool - virtual CaptureTool* copy(QObject *parent = nullptr) = 0; + virtual CaptureTool* copy(QObject* parent = nullptr) = 0; // revert changes - virtual void undo(QPixmap &pixmap) = 0; + virtual void undo(QPixmap& pixmap) = 0; // Called every time the tool has to draw // recordUndo indicates when the tool should save the information // for the undo(), if the value is false calling undo() after // that process should not modify revert the changes. - virtual void process(QPainter &painter, - const QPixmap &pixmap, + virtual void process(QPainter& painter, + const QPixmap& pixmap, bool recordUndo = false) = 0; // When the tool is selected, this is called when the mouse moves - virtual void paintMousePreview(QPainter &painter, const CaptureContext &context) = 0; + virtual void paintMousePreview(QPainter& painter, + const CaptureContext& context) = 0; signals: void requestAction(Request r); protected: - QString iconPath(const QColor &c) const { - return ColorUtils::colorIsDark(c) ? - PathInfo::whiteIconPath() : PathInfo::blackIconPath(); + QString iconPath(const QColor& c) const + { + return ColorUtils::colorIsDark(c) ? PathInfo::whiteIconPath() + : PathInfo::blackIconPath(); } public slots: // On mouse release. - virtual void drawEnd(const QPoint &p) = 0; + virtual void drawEnd(const QPoint& p) = 0; // Mouse pressed and moving, called once a pixel. - virtual void drawMove(const QPoint &p) = 0; + virtual void drawMove(const QPoint& p) = 0; // Called when drawMove is needed with an adjustment; // should be overridden in case an adjustment is applicable. - virtual void drawMoveWithAdjustment(const QPoint &p) { - drawMove(p); - } + virtual void drawMoveWithAdjustment(const QPoint& p) { drawMove(p); } // Called when the tool is activated. - virtual void drawStart(const CaptureContext &context) = 0; + virtual void drawStart(const CaptureContext& context) = 0; // Called right after pressign the button which activates the tool. - virtual void pressed(const CaptureContext &context) = 0; + virtual void pressed(const CaptureContext& context) = 0; // Called when the color is changed in the editor. - virtual void colorChanged(const QColor &c) = 0; + virtual void colorChanged(const QColor& c) = 0; // Called when the thickness of the tool is updated in the editor. virtual void thicknessChanged(const int th) = 0; }; diff --git a/src/tools/circle/circletool.cpp b/src/tools/circle/circletool.cpp index ca6e187c..23a00cc3 100644 --- a/src/tools/circle/circletool.cpp +++ b/src/tools/circle/circletool.cpp @@ -22,31 +22,41 @@ namespace { #define PADDING_VALUE 2 } -CircleTool::CircleTool(QObject *parent) : AbstractTwoPointTool(parent) { +CircleTool::CircleTool(QObject* parent) + : AbstractTwoPointTool(parent) +{ m_supportsDiagonalAdj = true; } -QIcon CircleTool::icon(const QColor &background, bool inEditor) const { +QIcon CircleTool::icon(const QColor& background, bool inEditor) const +{ Q_UNUSED(inEditor); return QIcon(iconPath(background) + "circle-outline.svg"); } -QString CircleTool::name() const { +QString CircleTool::name() const +{ return tr("Circle"); } -QString CircleTool::nameID() { +QString CircleTool::nameID() +{ return QLatin1String(""); } -QString CircleTool::description() const { +QString CircleTool::description() const +{ return tr("Set the Circle as the paint tool"); } -CaptureTool* CircleTool::copy(QObject *parent) { +CaptureTool* CircleTool::copy(QObject* parent) +{ return new CircleTool(parent); } -void CircleTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) { +void CircleTool::process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo) +{ if (recordUndo) { updateBackup(pixmap); } @@ -54,18 +64,22 @@ void CircleTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUn painter.drawEllipse(QRect(m_points.first, m_points.second)); } -void CircleTool::paintMousePreview(QPainter &painter, const CaptureContext &context) { +void CircleTool::paintMousePreview(QPainter& painter, + const CaptureContext& context) +{ painter.setPen(QPen(context.color, PADDING_VALUE + context.thickness)); painter.drawLine(context.mousePos, context.mousePos); } -void CircleTool::drawStart(const CaptureContext &context) { +void CircleTool::drawStart(const CaptureContext& context) +{ m_color = context.color; m_thickness = context.thickness + PADDING_VALUE; m_points.first = context.mousePos; m_points.second = context.mousePos; } -void CircleTool::pressed(const CaptureContext &context) { +void CircleTool::pressed(const CaptureContext& context) +{ Q_UNUSED(context); } diff --git a/src/tools/circle/circletool.h b/src/tools/circle/circletool.h index ea4eb8e0..ab7032a9 100644 --- a/src/tools/circle/circletool.h +++ b/src/tools/circle/circletool.h @@ -19,22 +19,25 @@ #include "src/tools/abstracttwopointtool.h" -class CircleTool : public AbstractTwoPointTool { +class CircleTool : public AbstractTwoPointTool +{ Q_OBJECT public: - explicit CircleTool(QObject *parent = nullptr); + explicit CircleTool(QObject* parent = nullptr); - QIcon icon(const QColor &background, bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; - CaptureTool* copy(QObject *parent = nullptr) override; - void process( - QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) override; - void paintMousePreview(QPainter &painter, const CaptureContext &context) override; + CaptureTool* copy(QObject* parent = nullptr) override; + void process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo = false) override; + void paintMousePreview(QPainter& painter, + const CaptureContext& context) override; public slots: - void drawStart(const CaptureContext &context) override; - void pressed(const CaptureContext &context) override; + void drawStart(const CaptureContext& context) override; + void pressed(const CaptureContext& context) override; }; diff --git a/src/tools/copy/copytool.cpp b/src/tools/copy/copytool.cpp index 89d1b2ef..60148237 100644 --- a/src/tools/copy/copytool.cpp +++ b/src/tools/copy/copytool.cpp @@ -19,35 +19,42 @@ #include "src/utils/screenshotsaver.h" #include -CopyTool::CopyTool(QObject *parent) : AbstractActionTool(parent) { +CopyTool::CopyTool(QObject* parent) + : AbstractActionTool(parent) +{} -} - -bool CopyTool::closeOnButtonPressed() const { +bool CopyTool::closeOnButtonPressed() const +{ return true; } -QIcon CopyTool::icon(const QColor &background, bool inEditor) const { +QIcon CopyTool::icon(const QColor& background, bool inEditor) const +{ Q_UNUSED(inEditor); return QIcon(iconPath(background) + "content-copy.svg"); } -QString CopyTool::name() const { +QString CopyTool::name() const +{ return tr("Copy"); } -QString CopyTool::nameID() { +QString CopyTool::nameID() +{ return QLatin1String(""); } -QString CopyTool::description() const { +QString CopyTool::description() const +{ return tr("Copy the selection into the clipboard"); } -CaptureTool* CopyTool::copy(QObject *parent) { +CaptureTool* CopyTool::copy(QObject* parent) +{ return new CopyTool(parent); } -void CopyTool::pressed(const CaptureContext &context) { +void CopyTool::pressed(const CaptureContext& context) +{ emit requestAction(REQ_CAPTURE_DONE_OK); ScreenshotSaver().saveToClipboard(context.selectedScreenshotArea()); } diff --git a/src/tools/copy/copytool.h b/src/tools/copy/copytool.h index 2d9dc454..9e051ec7 100644 --- a/src/tools/copy/copytool.h +++ b/src/tools/copy/copytool.h @@ -19,20 +19,21 @@ #include "src/tools/abstractactiontool.h" -class CopyTool : public AbstractActionTool { +class CopyTool : public AbstractActionTool +{ Q_OBJECT public: - explicit CopyTool(QObject *parent = nullptr); + explicit CopyTool(QObject* parent = nullptr); bool closeOnButtonPressed() const; - QIcon icon(const QColor &background, bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; - CaptureTool* copy(QObject *parent = nullptr) override; + CaptureTool* copy(QObject* parent = nullptr) override; public slots: - void pressed(const CaptureContext &context) override; + void pressed(const CaptureContext& context) override; }; diff --git a/src/tools/exit/exittool.cpp b/src/tools/exit/exittool.cpp index b36b0ecf..6676f174 100644 --- a/src/tools/exit/exittool.cpp +++ b/src/tools/exit/exittool.cpp @@ -18,35 +18,42 @@ #include "exittool.h" #include -ExitTool::ExitTool(QObject *parent) : AbstractActionTool(parent) { +ExitTool::ExitTool(QObject* parent) + : AbstractActionTool(parent) +{} -} - -bool ExitTool::closeOnButtonPressed() const { +bool ExitTool::closeOnButtonPressed() const +{ return true; } -QIcon ExitTool::icon(const QColor &background, bool inEditor) const { +QIcon ExitTool::icon(const QColor& background, bool inEditor) const +{ Q_UNUSED(inEditor); return QIcon(iconPath(background) + "close.svg"); } -QString ExitTool::name() const { +QString ExitTool::name() const +{ return tr("Exit"); } -QString ExitTool::nameID() { +QString ExitTool::nameID() +{ return QLatin1String(""); } -QString ExitTool::description() const { +QString ExitTool::description() const +{ return tr("Leave the capture screen"); } -CaptureTool* ExitTool::copy(QObject *parent) { +CaptureTool* ExitTool::copy(QObject* parent) +{ return new ExitTool(parent); } -void ExitTool::pressed(const CaptureContext &context) { +void ExitTool::pressed(const CaptureContext& context) +{ Q_UNUSED(context); emit requestAction(REQ_CLOSE_GUI); } diff --git a/src/tools/exit/exittool.h b/src/tools/exit/exittool.h index 92fed347..d6ecc0cf 100644 --- a/src/tools/exit/exittool.h +++ b/src/tools/exit/exittool.h @@ -19,20 +19,21 @@ #include "src/tools/abstractactiontool.h" -class ExitTool : public AbstractActionTool { +class ExitTool : public AbstractActionTool +{ Q_OBJECT public: - explicit ExitTool(QObject *parent = nullptr); + explicit ExitTool(QObject* parent = nullptr); bool closeOnButtonPressed() const; - QIcon icon(const QColor &background, bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; - CaptureTool* copy(QObject *parent = nullptr) override; + CaptureTool* copy(QObject* parent = nullptr) override; public slots: - void pressed(const CaptureContext &context) override; + void pressed(const CaptureContext& context) override; }; diff --git a/src/tools/launcher/applaunchertool.cpp b/src/tools/launcher/applaunchertool.cpp index 4070c4b6..5c12f0d8 100644 --- a/src/tools/launcher/applaunchertool.cpp +++ b/src/tools/launcher/applaunchertool.cpp @@ -18,39 +18,47 @@ #include "applaunchertool.h" #include "applauncherwidget.h" -AppLauncher::AppLauncher(QObject *parent) : AbstractActionTool(parent) { +AppLauncher::AppLauncher(QObject* parent) + : AbstractActionTool(parent) +{} -} - -bool AppLauncher::closeOnButtonPressed() const { +bool AppLauncher::closeOnButtonPressed() const +{ return true; } -QIcon AppLauncher::icon(const QColor &background, bool inEditor) const { +QIcon AppLauncher::icon(const QColor& background, bool inEditor) const +{ Q_UNUSED(inEditor); return QIcon(iconPath(background) + "open_with.svg"); } -QString AppLauncher::name() const { +QString AppLauncher::name() const +{ return tr("App Launcher"); } -QString AppLauncher::nameID() { +QString AppLauncher::nameID() +{ return QLatin1String(""); } -QString AppLauncher::description() const { +QString AppLauncher::description() const +{ return tr("Choose an app to open the capture"); } -QWidget* AppLauncher::widget() { +QWidget* AppLauncher::widget() +{ return new AppLauncherWidget(capture); } -CaptureTool* AppLauncher::copy(QObject *parent) { +CaptureTool* AppLauncher::copy(QObject* parent) +{ return new AppLauncher(parent); } -void AppLauncher::pressed(const CaptureContext &context) { +void AppLauncher::pressed(const CaptureContext& context) +{ capture = context.selectedScreenshotArea(); emit requestAction(REQ_CAPTURE_DONE_OK); emit requestAction(REQ_ADD_EXTERNAL_WIDGETS); diff --git a/src/tools/launcher/applaunchertool.h b/src/tools/launcher/applaunchertool.h index 3adc425a..9e28873b 100644 --- a/src/tools/launcher/applaunchertool.h +++ b/src/tools/launcher/applaunchertool.h @@ -19,24 +19,25 @@ #include "src/tools/abstractactiontool.h" -class AppLauncher : public AbstractActionTool { +class AppLauncher : public AbstractActionTool +{ Q_OBJECT public: - explicit AppLauncher(QObject *parent = nullptr); + explicit AppLauncher(QObject* parent = nullptr); bool closeOnButtonPressed() const; - QIcon icon(const QColor &background, bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; QWidget* widget() override; - CaptureTool* copy(QObject *parent = nullptr) override; + CaptureTool* copy(QObject* parent = nullptr) override; public slots: - void pressed(const CaptureContext &context) override; + void pressed(const CaptureContext& context) override; private: QPixmap capture; diff --git a/src/tools/launcher/applauncherwidget.cpp b/src/tools/launcher/applauncherwidget.cpp index e1048b21..1df96b50 100644 --- a/src/tools/launcher/applauncherwidget.cpp +++ b/src/tools/launcher/applauncherwidget.cpp @@ -16,40 +16,40 @@ // along with Flameshot. If not, see . #include "applauncherwidget.h" -#include "src/utils/filenamehandler.h" #include "src/tools/launcher/launcheritemdelegate.h" -#include "src/utils/globalvalues.h" #include "src/utils/confighandler.h" +#include "src/utils/filenamehandler.h" +#include "src/utils/globalvalues.h" #include "terminallauncher.h" -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include #include +#include +#include +#include #include +#include +#include +#include namespace { -QMap catIconNames({ - { "Multimedia", "applications-multimedia" }, - { "Development","applications-development" }, - { "Graphics", "applications-graphics" }, - { "Network", "preferences-system-network" }, - { "Office", "applications-office" }, - { "Science", "applications-science" }, - { "Settings", "preferences-desktop" }, - { "System", "preferences-system" }, - { "Utility", "applications-utilities" } - }); +QMap catIconNames( + { { "Multimedia", "applications-multimedia" }, + { "Development", "applications-development" }, + { "Graphics", "applications-graphics" }, + { "Network", "preferences-system-network" }, + { "Office", "applications-office" }, + { "Science", "applications-science" }, + { "Settings", "preferences-desktop" }, + { "System", "preferences-system" }, + { "Utility", "applications-utilities" } }); } -AppLauncherWidget::AppLauncherWidget(const QPixmap &p, QWidget *parent): - QWidget(parent), m_pixmap(p) +AppLauncherWidget::AppLauncherWidget(const QPixmap& p, QWidget* parent) + : QWidget(parent) + , m_pixmap(p) { setAttribute(Qt::WA_DeleteOnClose); setWindowIcon(QIcon(":img/app/flameshot.svg")); @@ -71,16 +71,22 @@ AppLauncherWidget::AppLauncherWidget(const QPixmap &p, QWidget *parent): m_terminalCheckbox = new QCheckBox(tr("Launch in terminal"), this); m_keepOpenCheckbox = new QCheckBox(tr("Keep open after selection"), this); m_keepOpenCheckbox->setChecked(ConfigHandler().keepOpenAppLauncherValue()); - connect(m_keepOpenCheckbox, &QCheckBox::clicked, this, &AppLauncherWidget::checkboxClicked); + connect(m_keepOpenCheckbox, + &QCheckBox::clicked, + this, + &AppLauncherWidget::checkboxClicked); // search items m_lineEdit = new QLineEdit; - connect(m_lineEdit, &QLineEdit::textChanged, - this, &AppLauncherWidget::searchChanged); + connect(m_lineEdit, + &QLineEdit::textChanged, + this, + &AppLauncherWidget::searchChanged); m_filterList = new QListWidget; m_filterList->hide(); configureListView(m_filterList); - connect(m_filterList, &QListWidget::clicked, this, &AppLauncherWidget::launch); + connect( + m_filterList, &QListWidget::clicked, this, &AppLauncherWidget::launch); m_layout = new QVBoxLayout(this); m_layout->addWidget(m_filterList); @@ -91,25 +97,28 @@ AppLauncherWidget::AppLauncherWidget(const QPixmap &p, QWidget *parent): m_lineEdit->setFocus(); } -void AppLauncherWidget::launch(const QModelIndex &index) { +void AppLauncherWidget::launch(const QModelIndex& index) +{ if (!QFileInfo(m_tempFile).isReadable()) { - m_tempFile = FileNameHandler().generateAbsolutePath(QDir::tempPath()) + ".png"; + m_tempFile = + FileNameHandler().generateAbsolutePath(QDir::tempPath()) + ".png"; bool ok = m_pixmap.save(m_tempFile); if (!ok) { - QMessageBox::about(this, tr("Error"), tr("Unable to write in") - + QDir::tempPath()); + QMessageBox::about( + this, tr("Error"), tr("Unable to write in") + QDir::tempPath()); return; } } - QString command = index.data(Qt::UserRole).toString().replace( - QRegExp("(\\%.)"), '"' + m_tempFile + '"'); - bool inTerminal = index.data(Qt::UserRole+1).toBool() || - m_terminalCheckbox->isChecked(); + QString command = index.data(Qt::UserRole) + .toString() + .replace(QRegExp("(\\%.)"), '"' + m_tempFile + '"'); + bool inTerminal = + index.data(Qt::UserRole + 1).toBool() || m_terminalCheckbox->isChecked(); if (inTerminal) { bool ok = TerminalLauncher::launchDetached(command); if (!ok) { - QMessageBox::about(this, tr("Error"), - tr("Unable to launch in terminal.")); + QMessageBox::about( + this, tr("Error"), tr("Unable to launch in terminal.")); } } else { QProcess::startDetached(command); @@ -119,13 +128,15 @@ void AppLauncherWidget::launch(const QModelIndex &index) { } } -void AppLauncherWidget::checkboxClicked(const bool enabled) { +void AppLauncherWidget::checkboxClicked(const bool enabled) +{ m_keepOpen = enabled; ConfigHandler().setKeepOpenAppLauncher(enabled); m_keepOpenCheckbox->setChecked(enabled); } -void AppLauncherWidget::searchChanged(const QString &text) { +void AppLauncherWidget::searchChanged(const QString& text) +{ if (text.isEmpty()) { m_filterList->hide(); m_tabWidget->show(); @@ -137,15 +148,14 @@ void AppLauncherWidget::searchChanged(const QString &text) { QVector apps; for (auto const& i : catIconNames.toStdMap()) { - const QString &cat = i.first; + const QString& cat = i.first; if (!m_appsMap.contains(cat)) { continue; } - const QVector &appList = m_appsMap[cat]; - for (const DesktopAppData &app: appList) { + const QVector& appList = m_appsMap[cat]; + for (const DesktopAppData& app : appList) { if (!apps.contains(app) && (app.name.contains(regexp) || - app.description.contains(regexp) )) - { + app.description.contains(regexp))) { apps.append(app); } } @@ -154,54 +164,58 @@ void AppLauncherWidget::searchChanged(const QString &text) { } } -void AppLauncherWidget::initListWidget() { +void AppLauncherWidget::initListWidget() +{ m_tabWidget = new QTabWidget; const int size = GlobalValues::buttonBaseSize(); m_tabWidget->setIconSize(QSize(size, size)); for (auto const& i : catIconNames.toStdMap()) { - const QString &cat = i.first; - const QString &iconName = i.second; + const QString& cat = i.first; + const QString& iconName = i.second; if (!m_appsMap.contains(cat)) { continue; } - QListWidget *itemsWidget = new QListWidget(); + QListWidget* itemsWidget = new QListWidget(); configureListView(itemsWidget); - const QVector &appList = m_appsMap[cat]; + const QVector& appList = m_appsMap[cat]; addAppsToListWidget(itemsWidget, appList); - m_tabWidget->addTab(itemsWidget, QIcon::fromTheme(iconName), QLatin1String("")); + m_tabWidget->addTab( + itemsWidget, QIcon::fromTheme(iconName), QLatin1String("")); m_tabWidget->setTabToolTip(m_tabWidget->count(), cat); if (cat == QLatin1String("Graphics")) { - m_tabWidget->setCurrentIndex(m_tabWidget->count() -1); + m_tabWidget->setCurrentIndex(m_tabWidget->count() - 1); } } } -void AppLauncherWidget::initAppMap() { - QStringList categories({"AudioVideo", - "Audio", - "Video", - "Development", - "Graphics", - "Network", - "Office", - "Science", - "Settings", - "System", - "Utility"}); +void AppLauncherWidget::initAppMap() +{ + QStringList categories({ "AudioVideo", + "Audio", + "Video", + "Development", + "Graphics", + "Network", + "Office", + "Science", + "Settings", + "System", + "Utility" }); m_appsMap = m_parser.getAppsByCategory(categories); // Unify multimedia. QVector multimediaList; QStringList multimediaNames; - multimediaNames << QStringLiteral("AudioVideo") << QStringLiteral("Audio") << QStringLiteral("Video"); - for (const QString &name : multimediaNames) { - if(!m_appsMap.contains(name)) { + multimediaNames << QStringLiteral("AudioVideo") << QStringLiteral("Audio") + << QStringLiteral("Video"); + for (const QString& name : multimediaNames) { + if (!m_appsMap.contains(name)) { continue; } for (auto i : m_appsMap[name]) { @@ -214,7 +228,8 @@ void AppLauncherWidget::initAppMap() { m_appsMap.insert(QStringLiteral("Multimedia"), multimediaList); } -void AppLauncherWidget::configureListView(QListWidget *widget) { +void AppLauncherWidget::configureListView(QListWidget* widget) +{ widget->setItemDelegate(new LauncherItemDelegate()); widget->setViewMode(QListWidget::IconMode); widget->setResizeMode(QListView::Adjust); @@ -222,21 +237,21 @@ void AppLauncherWidget::configureListView(QListWidget *widget) { widget->setFlow(QListView::LeftToRight); widget->setDragEnabled(false); widget->setMinimumWidth(GlobalValues::buttonBaseSize() * 11); - connect(widget, &QListWidget::clicked, - this, &AppLauncherWidget::launch); + connect(widget, &QListWidget::clicked, this, &AppLauncherWidget::launch); } void AppLauncherWidget::addAppsToListWidget( - QListWidget *widget, const QVector &appList) + QListWidget* widget, + const QVector& appList) { - for (const DesktopAppData &app: appList) { - QListWidgetItem *buttonItem = new QListWidgetItem(widget); + for (const DesktopAppData& app : appList) { + QListWidgetItem* buttonItem = new QListWidgetItem(widget); buttonItem->setData(Qt::DecorationRole, app.icon); buttonItem->setData(Qt::DisplayRole, app.name); buttonItem->setData(Qt::UserRole, app.exec); - buttonItem->setData(Qt::UserRole+1, app.showInTerminal); + buttonItem->setData(Qt::UserRole + 1, app.showInTerminal); QColor foregroundColor = - this->palette().color(QWidget::foregroundRole()); + this->palette().color(QWidget::foregroundRole()); buttonItem->setForeground(foregroundColor); buttonItem->setIcon(app.icon); diff --git a/src/tools/launcher/applauncherwidget.h b/src/tools/launcher/applauncherwidget.h index e6bd15dd..a92bd59e 100644 --- a/src/tools/launcher/applauncherwidget.h +++ b/src/tools/launcher/applauncherwidget.h @@ -18,8 +18,8 @@ #pragma once #include "src/utils/desktopfileparse.h" -#include #include +#include class QTabWidget; class QCheckBox; @@ -27,32 +27,33 @@ class QVBoxLayout; class QLineEdit; class QListWidget; -class AppLauncherWidget: public QWidget { +class AppLauncherWidget : public QWidget +{ Q_OBJECT public: - explicit AppLauncherWidget(const QPixmap &p, QWidget *parent = nullptr); + explicit AppLauncherWidget(const QPixmap& p, QWidget* parent = nullptr); private slots: - void launch(const QModelIndex &index); + void launch(const QModelIndex& index); void checkboxClicked(const bool enabled); - void searchChanged(const QString &text); + void searchChanged(const QString& text); private: void initListWidget(); void initAppMap(); - void configureListView(QListWidget *widget); - void addAppsToListWidget(QListWidget *widget, - const QVector &appList); + void configureListView(QListWidget* widget); + void addAppsToListWidget(QListWidget* widget, + const QVector& appList); DesktopFileParser m_parser; QPixmap m_pixmap; QString m_tempFile; bool m_keepOpen; QMap> m_appsMap; - QCheckBox *m_keepOpenCheckbox; - QCheckBox *m_terminalCheckbox; - QVBoxLayout *m_layout; - QLineEdit *m_lineEdit; - QListWidget *m_filterList; - QTabWidget *m_tabWidget; + QCheckBox* m_keepOpenCheckbox; + QCheckBox* m_terminalCheckbox; + QVBoxLayout* m_layout; + QLineEdit* m_lineEdit; + QListWidget* m_filterList; + QTabWidget* m_tabWidget; }; diff --git a/src/tools/launcher/launcheritemdelegate.cpp b/src/tools/launcher/launcheritemdelegate.cpp index 8c3a2e5b..51fcadf9 100644 --- a/src/tools/launcher/launcheritemdelegate.cpp +++ b/src/tools/launcher/launcheritemdelegate.cpp @@ -19,45 +19,45 @@ #include "src/utils/globalvalues.h" #include -LauncherItemDelegate::LauncherItemDelegate(QObject *parent) : - QStyledItemDelegate(parent) -{ -} +LauncherItemDelegate::LauncherItemDelegate(QObject* parent) + : QStyledItemDelegate(parent) +{} -void LauncherItemDelegate::paint( - QPainter *painter, - const QStyleOptionViewItem &option, - const QModelIndex &index) const +void LauncherItemDelegate::paint(QPainter* painter, + const QStyleOptionViewItem& option, + const QModelIndex& index) const { - const QRect &rect = option.rect; + const QRect& rect = option.rect; if (option.state & (QStyle::State_Selected | QStyle::State_MouseOver)) { painter->save(); painter->setPen(Qt::transparent); painter->setBrush(QPalette().highlight()); - painter->drawRect(rect.x(), rect.y(), - rect.width() -1, rect.height() -1); + painter->drawRect( + rect.x(), rect.y(), rect.width() - 1, rect.height() - 1); painter->restore(); } QIcon icon = index.data(Qt::DecorationRole).value(); const int iconSide = GlobalValues::buttonBaseSize() * 1.3; - const int halfIcon = iconSide/2; - const int halfWidth = rect.width()/2; - const int halfHeight = rect.height()/2; + const int halfIcon = iconSide / 2; + const int halfWidth = rect.width() / 2; + const int halfHeight = rect.height() / 2; QSize size(iconSide, iconSide); QPixmap pixIcon = icon.pixmap(size).scaled(size, Qt::KeepAspectRatio); painter->drawPixmap(rect.x() + (halfWidth - halfIcon), - rect.y()+ (halfHeight/2 - halfIcon), - iconSide, iconSide, pixIcon); - const QRect textRect(rect.x(), rect.y() + halfHeight, - rect.width(), halfHeight); - painter->drawText(textRect, Qt::TextWordWrap | Qt::AlignHCenter, + rect.y() + (halfHeight / 2 - halfIcon), + iconSide, + iconSide, + pixIcon); + const QRect textRect( + rect.x(), rect.y() + halfHeight, rect.width(), halfHeight); + painter->drawText(textRect, + Qt::TextWordWrap | Qt::AlignHCenter, index.data(Qt::DisplayRole).toString()); } -QSize LauncherItemDelegate::sizeHint( - const QStyleOptionViewItem &option, - const QModelIndex &index) const +QSize LauncherItemDelegate::sizeHint(const QStyleOptionViewItem& option, + const QModelIndex& index) const { Q_UNUSED(option); Q_UNUSED(index); diff --git a/src/tools/launcher/launcheritemdelegate.h b/src/tools/launcher/launcheritemdelegate.h index 2e662426..538179c5 100644 --- a/src/tools/launcher/launcheritemdelegate.h +++ b/src/tools/launcher/launcheritemdelegate.h @@ -20,14 +20,16 @@ #include "src/utils/desktopfileparse.h" #include -class LauncherItemDelegate : public QStyledItemDelegate { +class LauncherItemDelegate : public QStyledItemDelegate +{ Q_OBJECT public: - explicit LauncherItemDelegate(QObject *parent = nullptr); + explicit LauncherItemDelegate(QObject* parent = nullptr); - void paint(QPainter *painter, - const QStyleOptionViewItem &option, - const QModelIndex &index) const; + void paint(QPainter* painter, + const QStyleOptionViewItem& option, + const QModelIndex& index) const; - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; + QSize sizeHint(const QStyleOptionViewItem& option, + const QModelIndex& index) const; }; diff --git a/src/tools/launcher/openwithprogram.cpp b/src/tools/launcher/openwithprogram.cpp index e5fb6e20..cf5d1921 100644 --- a/src/tools/launcher/openwithprogram.cpp +++ b/src/tools/launcher/openwithprogram.cpp @@ -15,29 +15,31 @@ // You should have received a copy of the GNU General Public License // along with Flameshot. If not, see . - #include "openwithprogram.h" #if defined(Q_OS_WIN) #include "src/utils/filenamehandler.h" #include #include -#include #include +#include #pragma comment(lib, "Shell32.lib") #else #include "src/tools/launcher/applauncherwidget.h" #endif -void showOpenWithMenu(const QPixmap &capture) { +void showOpenWithMenu(const QPixmap& capture) +{ #if defined(Q_OS_WIN) QString tempFile = - FileNameHandler().generateAbsolutePath(QDir::tempPath()) + ".png"; + FileNameHandler().generateAbsolutePath(QDir::tempPath()) + ".png"; bool ok = capture.save(tempFile); if (!ok) { - QMessageBox::about(nullptr, QObject::tr("Error"), - QObject::tr("Unable to write in") + QDir::tempPath()); + QMessageBox::about(nullptr, + QObject::tr("Error"), + QObject::tr("Unable to write in") + + QDir::tempPath()); return; } diff --git a/src/tools/launcher/openwithprogram.h b/src/tools/launcher/openwithprogram.h index eed4f892..40396a67 100644 --- a/src/tools/launcher/openwithprogram.h +++ b/src/tools/launcher/openwithprogram.h @@ -19,4 +19,4 @@ #include -void showOpenWithMenu(const QPixmap &capture); +void showOpenWithMenu(const QPixmap& capture); diff --git a/src/tools/launcher/terminallauncher.cpp b/src/tools/launcher/terminallauncher.cpp index 451f60fa..0028980c 100644 --- a/src/tools/launcher/terminallauncher.cpp +++ b/src/tools/launcher/terminallauncher.cpp @@ -16,34 +16,36 @@ // along with Flameshot. If not, see . #include "terminallauncher.h" -#include #include -#include +#include #include +#include namespace { - static const TerminalApp terminalApps[] = { - { "x-terminal-emulator", "-e" }, - { "xfce4-terminal", "-x" }, - { "konsole", "-e" }, - { "gnome-terminal", "--" }, - { "terminator", "-e" }, - { "terminology", "-e" }, - { "tilix", "-e" }, - { "xterm", "-e" }, - { "aterm", "-e" }, - { "Eterm", "-e" }, - { "rxvt", "-e" }, - { "urxvt", "-e" }, - }; +static const TerminalApp terminalApps[] = { + { "x-terminal-emulator", "-e" }, + { "xfce4-terminal", "-x" }, + { "konsole", "-e" }, + { "gnome-terminal", "--" }, + { "terminator", "-e" }, + { "terminology", "-e" }, + { "tilix", "-e" }, + { "xterm", "-e" }, + { "aterm", "-e" }, + { "Eterm", "-e" }, + { "rxvt", "-e" }, + { "urxvt", "-e" }, +}; } -TerminalLauncher::TerminalLauncher(QObject *parent) : QObject(parent) { -} +TerminalLauncher::TerminalLauncher(QObject* parent) + : QObject(parent) +{} -TerminalApp TerminalLauncher::getPreferedTerminal() { +TerminalApp TerminalLauncher::getPreferedTerminal() +{ TerminalApp res; - for (const TerminalApp &app : terminalApps) { + for (const TerminalApp& app : terminalApps) { QString path = QStandardPaths::findExecutable(app.name); if (!path.isEmpty()) { res = app; @@ -53,7 +55,8 @@ TerminalApp TerminalLauncher::getPreferedTerminal() { return res; } -bool TerminalLauncher::launchDetached(const QString &command) { +bool TerminalLauncher::launchDetached(const QString& command) +{ TerminalApp app = getPreferedTerminal(); QString s = app.name + " " + app.arg + " " + command; return QProcess::startDetached(s); diff --git a/src/tools/launcher/terminallauncher.h b/src/tools/launcher/terminallauncher.h index 9a9af38e..df67ffb5 100644 --- a/src/tools/launcher/terminallauncher.h +++ b/src/tools/launcher/terminallauncher.h @@ -19,17 +19,20 @@ #include -struct TerminalApp { +struct TerminalApp +{ QString name; QString arg; }; -class TerminalLauncher : public QObject { +class TerminalLauncher : public QObject +{ Q_OBJECT public: - explicit TerminalLauncher(QObject *parent = nullptr); + explicit TerminalLauncher(QObject* parent = nullptr); + + static bool launchDetached(const QString& command); - static bool launchDetached(const QString &command); private: static TerminalApp getPreferedTerminal(); }; diff --git a/src/tools/line/linetool.cpp b/src/tools/line/linetool.cpp index 343d3eb1..32c28018 100644 --- a/src/tools/line/linetool.cpp +++ b/src/tools/line/linetool.cpp @@ -24,32 +24,42 @@ namespace { } -LineTool::LineTool(QObject *parent) : AbstractTwoPointTool(parent) { +LineTool::LineTool(QObject* parent) + : AbstractTwoPointTool(parent) +{ m_supportsOrthogonalAdj = true; m_supportsDiagonalAdj = true; } -QIcon LineTool::icon(const QColor &background, bool inEditor) const { +QIcon LineTool::icon(const QColor& background, bool inEditor) const +{ Q_UNUSED(inEditor); return QIcon(iconPath(background) + "line.svg"); } -QString LineTool::name() const { +QString LineTool::name() const +{ return tr("Line"); } -QString LineTool::nameID() { +QString LineTool::nameID() +{ return QLatin1String(""); } -QString LineTool::description() const { +QString LineTool::description() const +{ return tr("Set the Line as the paint tool"); } -CaptureTool* LineTool::copy(QObject *parent) { +CaptureTool* LineTool::copy(QObject* parent) +{ return new LineTool(parent); } -void LineTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) { +void LineTool::process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo) +{ if (recordUndo) { updateBackup(pixmap); } @@ -57,18 +67,22 @@ void LineTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo painter.drawLine(m_points.first, m_points.second); } -void LineTool::paintMousePreview(QPainter &painter, const CaptureContext &context) { +void LineTool::paintMousePreview(QPainter& painter, + const CaptureContext& context) +{ painter.setPen(QPen(context.color, PADDING_VALUE + context.thickness)); painter.drawLine(context.mousePos, context.mousePos); } -void LineTool::drawStart(const CaptureContext &context) { +void LineTool::drawStart(const CaptureContext& context) +{ m_color = context.color; m_thickness = context.thickness + PADDING_VALUE; m_points.first = context.mousePos; m_points.second = context.mousePos; } -void LineTool::pressed(const CaptureContext &context) { +void LineTool::pressed(const CaptureContext& context) +{ Q_UNUSED(context); } diff --git a/src/tools/line/linetool.h b/src/tools/line/linetool.h index bb140656..28c6b76d 100644 --- a/src/tools/line/linetool.h +++ b/src/tools/line/linetool.h @@ -19,22 +19,25 @@ #include "src/tools/abstracttwopointtool.h" -class LineTool : public AbstractTwoPointTool { +class LineTool : public AbstractTwoPointTool +{ Q_OBJECT public: - explicit LineTool(QObject *parent = nullptr); + explicit LineTool(QObject* parent = nullptr); - QIcon icon(const QColor &background, bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; - CaptureTool* copy(QObject *parent = nullptr) override; - void process( - QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) override; - void paintMousePreview(QPainter &painter, const CaptureContext &context) override; + CaptureTool* copy(QObject* parent = nullptr) override; + void process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo = false) override; + void paintMousePreview(QPainter& painter, + const CaptureContext& context) override; public slots: - void drawStart(const CaptureContext &context) override; - void pressed(const CaptureContext &context) override; + void drawStart(const CaptureContext& context) override; + void pressed(const CaptureContext& context) override; }; diff --git a/src/tools/marker/markertool.cpp b/src/tools/marker/markertool.cpp index b5d027bb..264edb9b 100644 --- a/src/tools/marker/markertool.cpp +++ b/src/tools/marker/markertool.cpp @@ -24,32 +24,42 @@ namespace { } -MarkerTool::MarkerTool(QObject *parent) : AbstractTwoPointTool(parent) { +MarkerTool::MarkerTool(QObject* parent) + : AbstractTwoPointTool(parent) +{ m_supportsOrthogonalAdj = true; m_supportsDiagonalAdj = true; } -QIcon MarkerTool::icon(const QColor &background, bool inEditor) const { +QIcon MarkerTool::icon(const QColor& background, bool inEditor) const +{ Q_UNUSED(inEditor); return QIcon(iconPath(background) + "marker.svg"); } -QString MarkerTool::name() const { +QString MarkerTool::name() const +{ return tr("Marker"); } -QString MarkerTool::nameID() { +QString MarkerTool::nameID() +{ return QLatin1String(""); } -QString MarkerTool::description() const { +QString MarkerTool::description() const +{ return tr("Set the Marker as the paint tool"); } -CaptureTool* MarkerTool::copy(QObject *parent) { +CaptureTool* MarkerTool::copy(QObject* parent) +{ return new MarkerTool(parent); } -void MarkerTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) { +void MarkerTool::process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo) +{ if (recordUndo) { updateBackup(pixmap); } @@ -59,24 +69,29 @@ void MarkerTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUn painter.drawLine(m_points.first, m_points.second); } -void MarkerTool::paintMousePreview(QPainter &painter, const CaptureContext &context) { +void MarkerTool::paintMousePreview(QPainter& painter, + const CaptureContext& context) +{ painter.setCompositionMode(QPainter::CompositionMode_Multiply); painter.setOpacity(0.35); painter.setPen(QPen(context.color, PADDING_VALUE + context.thickness)); painter.drawLine(context.mousePos, context.mousePos); } -void MarkerTool::drawStart(const CaptureContext &context) { +void MarkerTool::drawStart(const CaptureContext& context) +{ m_color = context.color; m_thickness = context.thickness + PADDING_VALUE; m_points.first = context.mousePos; m_points.second = context.mousePos; } -void MarkerTool::pressed(const CaptureContext &context) { +void MarkerTool::pressed(const CaptureContext& context) +{ Q_UNUSED(context); } -void MarkerTool::thicknessChanged(const int th) { +void MarkerTool::thicknessChanged(const int th) +{ m_thickness = th + PADDING_VALUE; } diff --git a/src/tools/marker/markertool.h b/src/tools/marker/markertool.h index 4d71e48e..9b3b88e6 100644 --- a/src/tools/marker/markertool.h +++ b/src/tools/marker/markertool.h @@ -19,23 +19,26 @@ #include "src/tools/abstracttwopointtool.h" -class MarkerTool : public AbstractTwoPointTool { +class MarkerTool : public AbstractTwoPointTool +{ Q_OBJECT public: - explicit MarkerTool(QObject *parent = nullptr); + explicit MarkerTool(QObject* parent = nullptr); - QIcon icon(const QColor &background, bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; - CaptureTool* copy(QObject *parent = nullptr) override; - void process( - QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) override; - void paintMousePreview(QPainter &painter, const CaptureContext &context) override; + CaptureTool* copy(QObject* parent = nullptr) override; + void process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo = false) override; + void paintMousePreview(QPainter& painter, + const CaptureContext& context) override; public slots: - void drawStart(const CaptureContext &context) override; - void pressed(const CaptureContext &context) override; + void drawStart(const CaptureContext& context) override; + void pressed(const CaptureContext& context) override; void thicknessChanged(const int th) override; }; diff --git a/src/tools/move/movetool.cpp b/src/tools/move/movetool.cpp index faa1cca3..b5fd1859 100644 --- a/src/tools/move/movetool.cpp +++ b/src/tools/move/movetool.cpp @@ -18,35 +18,42 @@ #include "movetool.h" #include -MoveTool::MoveTool(QObject *parent) : AbstractActionTool(parent) { +MoveTool::MoveTool(QObject* parent) + : AbstractActionTool(parent) +{} -} - -bool MoveTool::closeOnButtonPressed() const { +bool MoveTool::closeOnButtonPressed() const +{ return false; } -QIcon MoveTool::icon(const QColor &background, bool inEditor) const { +QIcon MoveTool::icon(const QColor& background, bool inEditor) const +{ Q_UNUSED(inEditor); return QIcon(iconPath(background) + "cursor-move.svg"); } -QString MoveTool::name() const { +QString MoveTool::name() const +{ return tr("Move"); } -QString MoveTool::nameID() { +QString MoveTool::nameID() +{ return QLatin1String(""); } -QString MoveTool::description() const { +QString MoveTool::description() const +{ return tr("Move the selection area"); } -CaptureTool* MoveTool::copy(QObject *parent) { +CaptureTool* MoveTool::copy(QObject* parent) +{ return new MoveTool(parent); } -void MoveTool::pressed(const CaptureContext &context) { +void MoveTool::pressed(const CaptureContext& context) +{ Q_UNUSED(context); emit requestAction(REQ_MOVE_MODE); } diff --git a/src/tools/move/movetool.h b/src/tools/move/movetool.h index 5126eb77..9e202fbf 100644 --- a/src/tools/move/movetool.h +++ b/src/tools/move/movetool.h @@ -19,20 +19,21 @@ #include "src/tools/abstractactiontool.h" -class MoveTool : public AbstractActionTool { +class MoveTool : public AbstractActionTool +{ Q_OBJECT public: - explicit MoveTool(QObject *parent = nullptr); + explicit MoveTool(QObject* parent = nullptr); bool closeOnButtonPressed() const; - QIcon icon(const QColor &background, bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; - CaptureTool* copy(QObject *parent = nullptr) override; + CaptureTool* copy(QObject* parent = nullptr) override; public slots: - void pressed(const CaptureContext &context) override; + void pressed(const CaptureContext& context) override; }; diff --git a/src/tools/pencil/penciltool.cpp b/src/tools/pencil/penciltool.cpp index 377a80a4..4948c860 100644 --- a/src/tools/pencil/penciltool.cpp +++ b/src/tools/pencil/penciltool.cpp @@ -18,31 +18,39 @@ #include "penciltool.h" #include -PencilTool::PencilTool(QObject *parent) : AbstractPathTool(parent) { +PencilTool::PencilTool(QObject* parent) + : AbstractPathTool(parent) +{} -} - -QIcon PencilTool::icon(const QColor &background, bool inEditor) const { +QIcon PencilTool::icon(const QColor& background, bool inEditor) const +{ Q_UNUSED(inEditor); return QIcon(iconPath(background) + "pencil.svg"); } -QString PencilTool::name() const { +QString PencilTool::name() const +{ return tr("Pencil"); } -QString PencilTool::nameID() { +QString PencilTool::nameID() +{ return QLatin1String(""); } -QString PencilTool::description() const { +QString PencilTool::description() const +{ return tr("Set the Pencil as the paint tool"); } -CaptureTool* PencilTool::copy(QObject *parent) { +CaptureTool* PencilTool::copy(QObject* parent) +{ return new PencilTool(parent); } -void PencilTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) { +void PencilTool::process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo) +{ if (recordUndo) { updateBackup(pixmap); } @@ -50,12 +58,15 @@ void PencilTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUn painter.drawPolyline(m_points.data(), m_points.size()); } -void PencilTool::paintMousePreview(QPainter &painter, const CaptureContext &context) { +void PencilTool::paintMousePreview(QPainter& painter, + const CaptureContext& context) +{ painter.setPen(QPen(context.color, context.thickness + 2)); painter.drawLine(context.mousePos, context.mousePos); } -void PencilTool::drawStart(const CaptureContext &context) { +void PencilTool::drawStart(const CaptureContext& context) +{ m_color = context.color; m_thickness = context.thickness + 2; m_points.append(context.mousePos); @@ -63,6 +74,7 @@ void PencilTool::drawStart(const CaptureContext &context) { m_backupArea.setBottomRight(context.mousePos); } -void PencilTool::pressed(const CaptureContext &context) { +void PencilTool::pressed(const CaptureContext& context) +{ Q_UNUSED(context); } diff --git a/src/tools/pencil/penciltool.h b/src/tools/pencil/penciltool.h index feaf9c07..05135f16 100644 --- a/src/tools/pencil/penciltool.h +++ b/src/tools/pencil/penciltool.h @@ -19,23 +19,26 @@ #include "src/tools/abstractpathtool.h" -class PencilTool : public AbstractPathTool { +class PencilTool : public AbstractPathTool +{ Q_OBJECT public: - explicit PencilTool(QObject *parent = nullptr); + explicit PencilTool(QObject* parent = nullptr); - QIcon icon(const QColor &background, bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; - CaptureTool* copy(QObject *parent = nullptr) override; + CaptureTool* copy(QObject* parent = nullptr) override; - void process( - QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) override; - void paintMousePreview(QPainter &painter, const CaptureContext &context) override; + void process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo = false) override; + void paintMousePreview(QPainter& painter, + const CaptureContext& context) override; public slots: - void drawStart(const CaptureContext &context) override; - void pressed(const CaptureContext &context) override; + void drawStart(const CaptureContext& context) override; + void pressed(const CaptureContext& context) override; }; diff --git a/src/tools/pin/pintool.cpp b/src/tools/pin/pintool.cpp index 20a70194..4f418bfc 100644 --- a/src/tools/pin/pintool.cpp +++ b/src/tools/pin/pintool.cpp @@ -18,47 +18,54 @@ #include "pintool.h" #include "src/tools/pin/pinwidget.h" -PinTool::PinTool(QObject *parent) : AbstractActionTool(parent) { +PinTool::PinTool(QObject* parent) + : AbstractActionTool(parent) +{} -} - -bool PinTool::closeOnButtonPressed() const { +bool PinTool::closeOnButtonPressed() const +{ return true; } -QIcon PinTool::icon(const QColor &background, bool inEditor) const { +QIcon PinTool::icon(const QColor& background, bool inEditor) const +{ Q_UNUSED(inEditor); return QIcon(iconPath(background) + "pin.svg"); } -QString PinTool::name() const { +QString PinTool::name() const +{ return tr("Pin Tool"); } -QString PinTool::nameID() { +QString PinTool::nameID() +{ return QLatin1String(""); } -QString PinTool::description() const { +QString PinTool::description() const +{ return tr("Pin image on the desktop"); } -QWidget* PinTool::widget() { - PinWidget *w = new PinWidget(m_pixmap); - const int &&m = w->margin(); +QWidget* PinTool::widget() +{ + PinWidget* w = new PinWidget(m_pixmap); + const int&& m = w->margin(); QRect adjusted_pos = m_geometry + QMargins(m, m, m, m); w->setGeometry(adjusted_pos); return w; } -CaptureTool* PinTool::copy(QObject *parent) { +CaptureTool* PinTool::copy(QObject* parent) +{ return new PinTool(parent); } -void PinTool::pressed(const CaptureContext &context) { +void PinTool::pressed(const CaptureContext& context) +{ emit requestAction(REQ_CAPTURE_DONE_OK); m_geometry = context.selection; m_geometry.setTopLeft(m_geometry.topLeft() + context.widgetOffset); m_pixmap = context.selectedScreenshotArea(); emit requestAction(REQ_ADD_EXTERNAL_WIDGETS); - } diff --git a/src/tools/pin/pintool.h b/src/tools/pin/pintool.h old mode 100755 new mode 100644 index 7690517f..16986fae --- a/src/tools/pin/pintool.h +++ b/src/tools/pin/pintool.h @@ -19,24 +19,25 @@ #include "src/tools/abstractactiontool.h" -class PinTool : public AbstractActionTool { +class PinTool : public AbstractActionTool +{ Q_OBJECT public: - explicit PinTool(QObject *parent = nullptr); + explicit PinTool(QObject* parent = nullptr); bool closeOnButtonPressed() const; - QIcon icon(const QColor &background, bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; QWidget* widget() override; - CaptureTool* copy(QObject *parent = nullptr) override; + CaptureTool* copy(QObject* parent = nullptr) override; public slots: - void pressed(const CaptureContext &context) override; + void pressed(const CaptureContext& context) override; private: QRect m_geometry; diff --git a/src/tools/pin/pinwidget.cpp b/src/tools/pin/pinwidget.cpp index b4d2df6e..ab4edb41 100644 --- a/src/tools/pin/pinwidget.cpp +++ b/src/tools/pin/pinwidget.cpp @@ -17,18 +17,18 @@ #include "pinwidget.h" #include "src/utils/confighandler.h" +#include #include +#include #include #include -#include -#include -PinWidget::PinWidget(const QPixmap &pixmap, QWidget *parent) : - QWidget(parent), m_pixmap(pixmap) +PinWidget::PinWidget(const QPixmap& pixmap, QWidget* parent) + : QWidget(parent) + , m_pixmap(pixmap) { - setWindowFlags(Qt::WindowStaysOnTopHint - | Qt::FramelessWindowHint); - //set the bottom widget background transparent + setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint); + // set the bottom widget background transparent setAttribute(Qt::WA_TranslucentBackground); ConfigHandler conf; @@ -53,11 +53,13 @@ PinWidget::PinWidget(const QPixmap &pixmap, QWidget *parent) : new QShortcut(Qt::Key_Escape, this, SLOT(close())); } -int PinWidget::margin() const { +int PinWidget::margin() const +{ return 7; } -void PinWidget::wheelEvent(QWheelEvent *e) { +void PinWidget::wheelEvent(QWheelEvent* e) +{ int val = e->delta() > 0 ? 15 : -15; int newWidth = qBound(50, m_label->width() + val, maximumWidth()); int newHeight = qBound(50, m_label->height() + val, maximumHeight()); @@ -69,34 +71,41 @@ void PinWidget::wheelEvent(QWheelEvent *e) { e->accept(); } -void PinWidget::enterEvent(QEvent *) { +void PinWidget::enterEvent(QEvent*) +{ m_shadowEffect->setColor(m_hoverColor); } -void PinWidget::leaveEvent(QEvent *) { +void PinWidget::leaveEvent(QEvent*) +{ m_shadowEffect->setColor(m_baseColor); } -void PinWidget::mouseDoubleClickEvent(QMouseEvent *) { +void PinWidget::mouseDoubleClickEvent(QMouseEvent*) +{ close(); } -void PinWidget::mousePressEvent(QMouseEvent *e) { +void PinWidget::mousePressEvent(QMouseEvent* e) +{ m_dragStart = e->globalPos(); - m_offsetX = e->localPos().x() / width(); + m_offsetX = e->localPos().x() / width(); m_offsetY = e->localPos().y() / height(); } -void PinWidget::mouseMoveEvent(QMouseEvent *e) { +void PinWidget::mouseMoveEvent(QMouseEvent* e) +{ const QPoint delta = e->globalPos() - m_dragStart; int offsetW = width() * m_offsetX; int offsetH = height() * m_offsetY; - move(m_dragStart.x() + delta.x() - offsetW, m_dragStart.y() + delta.y() - offsetH); + move(m_dragStart.x() + delta.x() - offsetW, + m_dragStart.y() + delta.y() - offsetH); } -void PinWidget::setScaledPixmap(const QSize &size) { +void PinWidget::setScaledPixmap(const QSize& size) +{ const qreal scale = qApp->devicePixelRatio(); - QPixmap scaledPixmap = m_pixmap.scaled(size * scale, Qt::KeepAspectRatio, - Qt::SmoothTransformation); + QPixmap scaledPixmap = m_pixmap.scaled( + size * scale, Qt::KeepAspectRatio, Qt::SmoothTransformation); scaledPixmap.setDevicePixelRatio(scale); m_label->setPixmap(scaledPixmap); } diff --git a/src/tools/pin/pinwidget.h b/src/tools/pin/pinwidget.h index 8dab1d38..893c4888 100644 --- a/src/tools/pin/pinwidget.h +++ b/src/tools/pin/pinwidget.h @@ -17,35 +17,36 @@ #pragma once -#include #include +#include class QVBoxLayout; class QLabel; -class PinWidget : public QWidget { +class PinWidget : public QWidget +{ Q_OBJECT public: - explicit PinWidget(const QPixmap &pixmap, QWidget *parent = nullptr); + explicit PinWidget(const QPixmap& pixmap, QWidget* parent = nullptr); int margin() const; protected: - void wheelEvent(QWheelEvent *e); - void mouseDoubleClickEvent(QMouseEvent *); - void mousePressEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); - void enterEvent(QEvent *); - void leaveEvent(QEvent *); + void wheelEvent(QWheelEvent* e); + void mouseDoubleClickEvent(QMouseEvent*); + void mousePressEvent(QMouseEvent*); + void mouseMoveEvent(QMouseEvent*); + void enterEvent(QEvent*); + void leaveEvent(QEvent*); private: - void setScaledPixmap(const QSize &size); + void setScaledPixmap(const QSize& size); QPixmap m_pixmap; - QVBoxLayout *m_layout; - QLabel *m_label; + QVBoxLayout* m_layout; + QLabel* m_label; QPoint m_dragStart; qreal m_offsetX, m_offsetY; - QGraphicsDropShadowEffect *m_shadowEffect; + QGraphicsDropShadowEffect* m_shadowEffect; QColor m_baseColor, m_hoverColor; }; diff --git a/src/tools/rectangle/rectangletool.cpp b/src/tools/rectangle/rectangletool.cpp index 9d972582..8d506aec 100644 --- a/src/tools/rectangle/rectangletool.cpp +++ b/src/tools/rectangle/rectangletool.cpp @@ -22,31 +22,41 @@ namespace { #define PADDING_VALUE 2 } -RectangleTool::RectangleTool(QObject *parent) : AbstractTwoPointTool(parent) { +RectangleTool::RectangleTool(QObject* parent) + : AbstractTwoPointTool(parent) +{ m_supportsDiagonalAdj = true; } -QIcon RectangleTool::icon(const QColor &background, bool inEditor) const { +QIcon RectangleTool::icon(const QColor& background, bool inEditor) const +{ Q_UNUSED(inEditor); return QIcon(iconPath(background) + "square.svg"); } -QString RectangleTool::name() const { +QString RectangleTool::name() const +{ return tr("Rectangle"); } -QString RectangleTool::nameID() { +QString RectangleTool::nameID() +{ return QLatin1String(""); } -QString RectangleTool::description() const { +QString RectangleTool::description() const +{ return tr("Set the Rectangle as the paint tool"); } -CaptureTool* RectangleTool::copy(QObject *parent) { +CaptureTool* RectangleTool::copy(QObject* parent) +{ return new RectangleTool(parent); } -void RectangleTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) { +void RectangleTool::process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo) +{ if (recordUndo) { updateBackup(pixmap); } @@ -55,18 +65,22 @@ void RectangleTool::process(QPainter &painter, const QPixmap &pixmap, bool recor painter.drawRect(QRect(m_points.first, m_points.second)); } -void RectangleTool::paintMousePreview(QPainter &painter, const CaptureContext &context) { +void RectangleTool::paintMousePreview(QPainter& painter, + const CaptureContext& context) +{ painter.setPen(QPen(context.color, PADDING_VALUE + context.thickness)); painter.drawLine(context.mousePos, context.mousePos); } -void RectangleTool::drawStart(const CaptureContext &context) { +void RectangleTool::drawStart(const CaptureContext& context) +{ m_color = context.color; m_thickness = context.thickness + PADDING_VALUE; m_points.first = context.mousePos; m_points.second = context.mousePos; } -void RectangleTool::pressed(const CaptureContext &context) { +void RectangleTool::pressed(const CaptureContext& context) +{ Q_UNUSED(context); } diff --git a/src/tools/rectangle/rectangletool.h b/src/tools/rectangle/rectangletool.h index 99d1b21f..1f81c2f6 100644 --- a/src/tools/rectangle/rectangletool.h +++ b/src/tools/rectangle/rectangletool.h @@ -19,22 +19,25 @@ #include "src/tools/abstracttwopointtool.h" -class RectangleTool : public AbstractTwoPointTool { +class RectangleTool : public AbstractTwoPointTool +{ Q_OBJECT public: - explicit RectangleTool(QObject *parent = nullptr); + explicit RectangleTool(QObject* parent = nullptr); - QIcon icon(const QColor &background, bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; - CaptureTool* copy(QObject *parent = nullptr) override; - void process( - QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) override; - void paintMousePreview(QPainter &painter, const CaptureContext &context) override; + CaptureTool* copy(QObject* parent = nullptr) override; + void process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo = false) override; + void paintMousePreview(QPainter& painter, + const CaptureContext& context) override; public slots: - void drawStart(const CaptureContext &context) override; - void pressed(const CaptureContext &context) override; + void drawStart(const CaptureContext& context) override; + void pressed(const CaptureContext& context) override; }; diff --git a/src/tools/redo/redotool.cpp b/src/tools/redo/redotool.cpp index 0f8d4e02..047d272b 100644 --- a/src/tools/redo/redotool.cpp +++ b/src/tools/redo/redotool.cpp @@ -18,35 +18,42 @@ #include "redotool.h" #include -RedoTool::RedoTool(QObject *parent) : AbstractActionTool(parent) { +RedoTool::RedoTool(QObject* parent) + : AbstractActionTool(parent) +{} -} - -bool RedoTool::closeOnButtonPressed() const { +bool RedoTool::closeOnButtonPressed() const +{ return false; } -QIcon RedoTool::icon(const QColor &background, bool inEditor) const { +QIcon RedoTool::icon(const QColor& background, bool inEditor) const +{ Q_UNUSED(inEditor); return QIcon(iconPath(background) + "redo-variant.svg"); } -QString RedoTool::name() const { +QString RedoTool::name() const +{ return tr("Redo"); } -QString RedoTool::nameID() { +QString RedoTool::nameID() +{ return QLatin1String(""); } -QString RedoTool::description() const { +QString RedoTool::description() const +{ return tr("Redo the next modification"); } -CaptureTool* RedoTool::copy(QObject *parent) { +CaptureTool* RedoTool::copy(QObject* parent) +{ return new RedoTool(parent); } -void RedoTool::pressed(const CaptureContext &context) { +void RedoTool::pressed(const CaptureContext& context) +{ Q_UNUSED(context); emit requestAction(REQ_REDO_MODIFICATION); } diff --git a/src/tools/redo/redotool.h b/src/tools/redo/redotool.h index f538f137..a35fbf6f 100644 --- a/src/tools/redo/redotool.h +++ b/src/tools/redo/redotool.h @@ -19,21 +19,21 @@ #include "src/tools/abstractactiontool.h" -class RedoTool : public AbstractActionTool { +class RedoTool : public AbstractActionTool +{ Q_OBJECT public: - explicit RedoTool(QObject *parent = nullptr); + explicit RedoTool(QObject* parent = nullptr); bool closeOnButtonPressed() const; - QIcon icon(const QColor &background, bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; - CaptureTool* copy(QObject *parent = nullptr) override; + CaptureTool* copy(QObject* parent = nullptr) override; public slots: - void pressed(const CaptureContext &context) override; - + void pressed(const CaptureContext& context) override; }; diff --git a/src/tools/save/savetool.cpp b/src/tools/save/savetool.cpp index 29c337f5..587ba190 100644 --- a/src/tools/save/savetool.cpp +++ b/src/tools/save/savetool.cpp @@ -19,45 +19,52 @@ #include "src/utils/screenshotsaver.h" #include -SaveTool::SaveTool(QObject *parent) : AbstractActionTool(parent) { +SaveTool::SaveTool(QObject* parent) + : AbstractActionTool(parent) +{} -} - -bool SaveTool::closeOnButtonPressed() const { +bool SaveTool::closeOnButtonPressed() const +{ return true; } -QIcon SaveTool::icon(const QColor &background, bool inEditor) const { +QIcon SaveTool::icon(const QColor& background, bool inEditor) const +{ Q_UNUSED(inEditor); return QIcon(iconPath(background) + "content-save.svg"); } -QString SaveTool::name() const { +QString SaveTool::name() const +{ return tr("Save"); } -QString SaveTool::nameID() { +QString SaveTool::nameID() +{ return QLatin1String(""); } -QString SaveTool::description() const { +QString SaveTool::description() const +{ return tr("Save the capture"); } -CaptureTool* SaveTool::copy(QObject *parent) { +CaptureTool* SaveTool::copy(QObject* parent) +{ return new SaveTool(parent); } -void SaveTool::pressed(const CaptureContext &context) { +void SaveTool::pressed(const CaptureContext& context) +{ if (context.savePath.isEmpty()) { emit requestAction(REQ_HIDE_GUI); bool ok = ScreenshotSaver().saveToFilesystemGUI( - context.selectedScreenshotArea()); + context.selectedScreenshotArea()); if (ok) { emit requestAction(REQ_CAPTURE_DONE_OK); } } else { bool ok = ScreenshotSaver().saveToFilesystem( - context.selectedScreenshotArea(), context.savePath); + context.selectedScreenshotArea(), context.savePath); if (ok) { emit requestAction(REQ_CAPTURE_DONE_OK); } diff --git a/src/tools/save/savetool.h b/src/tools/save/savetool.h index d5f75813..4d0ae752 100644 --- a/src/tools/save/savetool.h +++ b/src/tools/save/savetool.h @@ -19,20 +19,21 @@ #include "src/tools/abstractactiontool.h" -class SaveTool : public AbstractActionTool { +class SaveTool : public AbstractActionTool +{ Q_OBJECT public: - explicit SaveTool(QObject *parent = nullptr); + explicit SaveTool(QObject* parent = nullptr); bool closeOnButtonPressed() const; - QIcon icon(const QColor &background, bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; - CaptureTool* copy(QObject *parent = nullptr) override; + CaptureTool* copy(QObject* parent = nullptr) override; public slots: - void pressed(const CaptureContext &context) override; + void pressed(const CaptureContext& context) override; }; diff --git a/src/tools/selection/selectiontool.cpp b/src/tools/selection/selectiontool.cpp index 2717da9a..d72e6361 100644 --- a/src/tools/selection/selectiontool.cpp +++ b/src/tools/selection/selectiontool.cpp @@ -22,35 +22,46 @@ namespace { #define PADDING_VALUE 2 } -SelectionTool::SelectionTool(QObject *parent) : AbstractTwoPointTool(parent) { +SelectionTool::SelectionTool(QObject* parent) + : AbstractTwoPointTool(parent) +{ m_supportsDiagonalAdj = true; } -bool SelectionTool::closeOnButtonPressed() const { +bool SelectionTool::closeOnButtonPressed() const +{ return false; } -QIcon SelectionTool::icon(const QColor &background, bool inEditor) const { +QIcon SelectionTool::icon(const QColor& background, bool inEditor) const +{ Q_UNUSED(inEditor); return QIcon(iconPath(background) + "square-outline.svg"); } -QString SelectionTool::name() const { +QString SelectionTool::name() const +{ return tr("Rectangular Selection"); } -QString SelectionTool::nameID() { +QString SelectionTool::nameID() +{ return QLatin1String(""); } -QString SelectionTool::description() const { +QString SelectionTool::description() const +{ return tr("Set Selection as the paint tool"); } -CaptureTool* SelectionTool::copy(QObject *parent) { +CaptureTool* SelectionTool::copy(QObject* parent) +{ return new SelectionTool(parent); } -void SelectionTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) { +void SelectionTool::process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo) +{ if (recordUndo) { updateBackup(pixmap); } @@ -58,18 +69,22 @@ void SelectionTool::process(QPainter &painter, const QPixmap &pixmap, bool recor painter.drawRect(QRect(m_points.first, m_points.second)); } -void SelectionTool::paintMousePreview(QPainter &painter, const CaptureContext &context) { +void SelectionTool::paintMousePreview(QPainter& painter, + const CaptureContext& context) +{ painter.setPen(QPen(context.color, PADDING_VALUE + context.thickness)); painter.drawLine(context.mousePos, context.mousePos); } -void SelectionTool::drawStart(const CaptureContext &context) { +void SelectionTool::drawStart(const CaptureContext& context) +{ m_color = context.color; m_thickness = context.thickness + PADDING_VALUE; m_points.first = context.mousePos; m_points.second = context.mousePos; } -void SelectionTool::pressed(const CaptureContext &context) { +void SelectionTool::pressed(const CaptureContext& context) +{ Q_UNUSED(context); } diff --git a/src/tools/selection/selectiontool.h b/src/tools/selection/selectiontool.h index af46d407..7f215558 100644 --- a/src/tools/selection/selectiontool.h +++ b/src/tools/selection/selectiontool.h @@ -19,24 +19,27 @@ #include "src/tools/abstracttwopointtool.h" -class SelectionTool : public AbstractTwoPointTool { +class SelectionTool : public AbstractTwoPointTool +{ Q_OBJECT public: - explicit SelectionTool(QObject *parent = nullptr); + explicit SelectionTool(QObject* parent = nullptr); bool closeOnButtonPressed() const; - QIcon icon(const QColor &background, bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; - CaptureTool* copy(QObject *parent = nullptr) override; - void process( - QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) override; - void paintMousePreview(QPainter &painter, const CaptureContext &context) override; + CaptureTool* copy(QObject* parent = nullptr) override; + void process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo = false) override; + void paintMousePreview(QPainter& painter, + const CaptureContext& context) override; public slots: - void drawStart(const CaptureContext &context) override; - void pressed(const CaptureContext &context) override; + void drawStart(const CaptureContext& context) override; + void pressed(const CaptureContext& context) override; }; diff --git a/src/tools/sizeindicator/sizeindicatortool.cpp b/src/tools/sizeindicator/sizeindicatortool.cpp index 3277a30f..fa04aef9 100644 --- a/src/tools/sizeindicator/sizeindicatortool.cpp +++ b/src/tools/sizeindicator/sizeindicatortool.cpp @@ -18,34 +18,41 @@ #include "sizeindicatortool.h" #include -SizeIndicatorTool::SizeIndicatorTool(QObject *parent) : AbstractActionTool(parent) { +SizeIndicatorTool::SizeIndicatorTool(QObject* parent) + : AbstractActionTool(parent) +{} -} - -bool SizeIndicatorTool::closeOnButtonPressed() const { +bool SizeIndicatorTool::closeOnButtonPressed() const +{ return false; } -QIcon SizeIndicatorTool::icon(const QColor &background, bool inEditor) const { - return inEditor ? QIcon() : - QIcon(iconPath(background) + "size_indicator.svg"); +QIcon SizeIndicatorTool::icon(const QColor& background, bool inEditor) const +{ + return inEditor ? QIcon() + : QIcon(iconPath(background) + "size_indicator.svg"); } -QString SizeIndicatorTool::name() const { +QString SizeIndicatorTool::name() const +{ return tr("Selection Size Indicator"); } -QString SizeIndicatorTool::nameID() { +QString SizeIndicatorTool::nameID() +{ return QLatin1String(""); } -QString SizeIndicatorTool::description() const { +QString SizeIndicatorTool::description() const +{ return tr("Show the dimensions of the selection (X Y)"); } -CaptureTool* SizeIndicatorTool::copy(QObject *parent) { +CaptureTool* SizeIndicatorTool::copy(QObject* parent) +{ return new SizeIndicatorTool(parent); } -void SizeIndicatorTool::pressed(const CaptureContext &context) { +void SizeIndicatorTool::pressed(const CaptureContext& context) +{ Q_UNUSED(context); } diff --git a/src/tools/sizeindicator/sizeindicatortool.h b/src/tools/sizeindicator/sizeindicatortool.h index 17dccb17..bebef9e3 100644 --- a/src/tools/sizeindicator/sizeindicatortool.h +++ b/src/tools/sizeindicator/sizeindicatortool.h @@ -19,20 +19,21 @@ #include "src/tools/abstractactiontool.h" -class SizeIndicatorTool : public AbstractActionTool { +class SizeIndicatorTool : public AbstractActionTool +{ Q_OBJECT public: - explicit SizeIndicatorTool(QObject *parent = nullptr); + explicit SizeIndicatorTool(QObject* parent = nullptr); bool closeOnButtonPressed() const; - QIcon icon(const QColor &background, bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; - CaptureTool* copy(QObject *parent = nullptr) override; + CaptureTool* copy(QObject* parent = nullptr) override; public slots: - void pressed(const CaptureContext &context) override; + void pressed(const CaptureContext& context) override; }; diff --git a/src/tools/storage/imguploader.cpp b/src/tools/storage/imguploader.cpp index 1e2b160a..2f0d2d59 100644 --- a/src/tools/storage/imguploader.cpp +++ b/src/tools/storage/imguploader.cpp @@ -203,7 +203,7 @@ const QUrl& ImgUploader::imageUrl() return m_imageURL; } -void ImgUploader::showNotificationMessage(const QString& notificationMessage) { +void ImgUploader::showNotificationMessage(const QString& notificationMessage) +{ m_notification->showMessage(notificationMessage); } - diff --git a/src/tools/storage/imguploadertool.cpp b/src/tools/storage/imguploadertool.cpp index 2f4c62f3..95ae7b15 100644 --- a/src/tools/storage/imguploadertool.cpp +++ b/src/tools/storage/imguploadertool.cpp @@ -1,10 +1,8 @@ #include "imguploadertool.h" ImgUploaderTool::ImgUploaderTool(QObject* parent) - : AbstractActionTool(parent) -{ - -} + : AbstractActionTool(parent) +{} void ImgUploaderTool::setCapture(const QPixmap& pixmap) { @@ -18,7 +16,8 @@ void ImgUploaderTool::pressed(const CaptureContext& context) emit requestAction(REQ_ADD_EXTERNAL_WIDGETS); } -const QPixmap& ImgUploaderTool::capture() { +const QPixmap& ImgUploaderTool::capture() +{ return m_capture; } @@ -28,9 +27,7 @@ QIcon ImgUploaderTool::icon(const QColor& background, bool inEditor) const return QIcon(iconPath(background) + "cloud-upload.svg"); } - bool ImgUploaderTool::closeOnButtonPressed() const { return true; } - diff --git a/src/tools/storage/imguploadertool.h b/src/tools/storage/imguploadertool.h index 760f4884..543e4d74 100644 --- a/src/tools/storage/imguploadertool.h +++ b/src/tools/storage/imguploadertool.h @@ -3,7 +3,6 @@ #include "src/tools/abstractactiontool.h" - class ImgUploaderTool : public AbstractActionTool { Q_OBJECT diff --git a/src/tools/storage/storagemanager.cpp b/src/tools/storage/storagemanager.cpp index d8231650..5100805d 100644 --- a/src/tools/storage/storagemanager.cpp +++ b/src/tools/storage/storagemanager.cpp @@ -4,8 +4,8 @@ #include "imgur/imguruploadertool.h" #include "s3/imgs3uploader.h" #include "s3/imgs3uploadertool.h" -#include "src/tools/storage/s3/imgs3settings.h" #include "src/tools/capturetool.h" +#include "src/tools/storage/s3/imgs3settings.h" #include @@ -22,7 +22,8 @@ CaptureTool* StorageManager::imgUploaderTool(const QString& imgUploaderType, return nullptr; } -const QString& StorageManager::storageUrl(const QString& imgUploaderType) { +const QString& StorageManager::storageUrl(const QString& imgUploaderType) +{ if (imgUploaderType == SCREENSHOT_STORAGE_TYPE_S3) { ImgS3Settings s3Settings; m_qstr = s3Settings.url(); diff --git a/src/tools/storage/storagemanager.h b/src/tools/storage/storagemanager.h index 4d1c4a7d..36179bc9 100644 --- a/src/tools/storage/storagemanager.h +++ b/src/tools/storage/storagemanager.h @@ -17,7 +17,7 @@ public: QObject* parent = nullptr); const QString& storageUrl(const QString& imgUploaderType); -// class members + // class members private: QString m_qstr; }; diff --git a/src/tools/text/textconfig.cpp b/src/tools/text/textconfig.cpp index 229d57ed..c8d50372 100644 --- a/src/tools/text/textconfig.cpp +++ b/src/tools/text/textconfig.cpp @@ -18,57 +18,69 @@ #include "textconfig.h" #include "src/utils/colorutils.h" #include "src/utils/pathinfo.h" -#include #include -#include +#include #include #include +#include -TextConfig::TextConfig(QWidget *parent) : QWidget(parent) { +TextConfig::TextConfig(QWidget* parent) + : QWidget(parent) +{ m_layout = new QVBoxLayout(this); QFontDatabase fontDB; - QComboBox *fontsCB = new QComboBox(); - connect(fontsCB, &QComboBox::currentTextChanged, - this, &TextConfig::fontFamilyChanged); + QComboBox* fontsCB = new QComboBox(); + connect(fontsCB, + &QComboBox::currentTextChanged, + this, + &TextConfig::fontFamilyChanged); fontsCB->addItems(fontDB.families()); // TODO save family in config int index = fontsCB->findText(font().family()); fontsCB->setCurrentIndex(index); QColor bgColor(palette().background().color()); - QString iconPrefix = ColorUtils::colorIsDark(bgColor) ? - PathInfo::whiteIconPath() : - PathInfo::blackIconPath(); + QString iconPrefix = ColorUtils::colorIsDark(bgColor) + ? PathInfo::whiteIconPath() + : PathInfo::blackIconPath(); m_strikeOutButton = new QPushButton( - QIcon(iconPrefix + "format_strikethrough.svg"), QLatin1String("")); + QIcon(iconPrefix + "format_strikethrough.svg"), QLatin1String("")); m_strikeOutButton->setCheckable(true); - connect(m_strikeOutButton, &QPushButton::clicked, - this, &TextConfig::fontStrikeOutChanged); + connect(m_strikeOutButton, + &QPushButton::clicked, + this, + &TextConfig::fontStrikeOutChanged); m_strikeOutButton->setToolTip(tr("StrikeOut")); m_underlineButton = new QPushButton( - QIcon(iconPrefix + "format_underlined.svg"), QLatin1String("")); + QIcon(iconPrefix + "format_underlined.svg"), QLatin1String("")); m_underlineButton->setCheckable(true); - connect(m_underlineButton, &QPushButton::clicked, - this, &TextConfig::fontUnderlineChanged); + connect(m_underlineButton, + &QPushButton::clicked, + this, + &TextConfig::fontUnderlineChanged); m_underlineButton->setToolTip(tr("Underline")); - m_weightButton = new QPushButton( - QIcon(iconPrefix + "format_bold.svg"), QLatin1String("")); + m_weightButton = + new QPushButton(QIcon(iconPrefix + "format_bold.svg"), QLatin1String("")); m_weightButton->setCheckable(true); - connect(m_weightButton, &QPushButton::clicked, - this, &TextConfig::weightButtonPressed); + connect(m_weightButton, + &QPushButton::clicked, + this, + &TextConfig::weightButtonPressed); m_weightButton->setToolTip(tr("Bold")); - m_italicButton = new QPushButton( - QIcon(iconPrefix + "format_italic.svg"), QLatin1String("")); + m_italicButton = new QPushButton(QIcon(iconPrefix + "format_italic.svg"), + QLatin1String("")); m_italicButton->setCheckable(true); - connect(m_italicButton, &QPushButton::clicked, - this, &TextConfig::fontItalicChanged); + connect(m_italicButton, + &QPushButton::clicked, + this, + &TextConfig::fontItalicChanged); m_italicButton->setToolTip(tr("Italic")); - QHBoxLayout *modifiersLayout = new QHBoxLayout(); + QHBoxLayout* modifiersLayout = new QHBoxLayout(); m_layout->addWidget(fontsCB); modifiersLayout->addWidget(m_strikeOutButton); @@ -78,23 +90,28 @@ TextConfig::TextConfig(QWidget *parent) : QWidget(parent) { m_layout->addLayout(modifiersLayout); } -void TextConfig::setUnderline(const bool u) { +void TextConfig::setUnderline(const bool u) +{ m_underlineButton->setChecked(u); } -void TextConfig::setStrikeOut(const bool s) { +void TextConfig::setStrikeOut(const bool s) +{ m_strikeOutButton->setChecked(s); } -void TextConfig::setWeight(const int w) { +void TextConfig::setWeight(const int w) +{ m_weightButton->setChecked(static_cast(w) == QFont::Bold); } -void TextConfig::setItalic(const bool i) { +void TextConfig::setItalic(const bool i) +{ m_italicButton->setChecked(i); } -void TextConfig::weightButtonPressed(const bool w) { +void TextConfig::weightButtonPressed(const bool w) +{ if (w) { emit fontWeightChanged(QFont::Bold); } else { diff --git a/src/tools/text/textconfig.h b/src/tools/text/textconfig.h index 13053265..fd8a97e3 100644 --- a/src/tools/text/textconfig.h +++ b/src/tools/text/textconfig.h @@ -22,10 +22,11 @@ class QVBoxLayout; class QPushButton; -class TextConfig : public QWidget { +class TextConfig : public QWidget +{ Q_OBJECT public: - explicit TextConfig(QWidget *parent = nullptr); + explicit TextConfig(QWidget* parent = nullptr); void setUnderline(const bool u); void setStrikeOut(const bool s); @@ -33,7 +34,7 @@ public: void setItalic(const bool i); signals: - void fontFamilyChanged(const QString &f); + void fontFamilyChanged(const QString& f); void fontUnderlineChanged(const bool underlined); void fontStrikeOutChanged(const bool dashed); void fontWeightChanged(const QFont::Weight w); @@ -45,9 +46,9 @@ private slots: void weightButtonPressed(const bool w); private: - QVBoxLayout *m_layout; - QPushButton *m_strikeOutButton; - QPushButton *m_underlineButton; - QPushButton *m_weightButton; - QPushButton *m_italicButton; + QVBoxLayout* m_layout; + QPushButton* m_strikeOutButton; + QPushButton* m_underlineButton; + QPushButton* m_weightButton; + QPushButton* m_italicButton; }; diff --git a/src/tools/text/texttool.cpp b/src/tools/text/texttool.cpp index 0ee93b5c..1fa59908 100644 --- a/src/tools/text/texttool.cpp +++ b/src/tools/text/texttool.cpp @@ -16,71 +16,89 @@ // along with Flameshot. If not, see . #include "texttool.h" -#include "textwidget.h" #include "textconfig.h" +#include "textwidget.h" #define BASE_POINT_SIZE 8 +TextTool::TextTool(QObject* parent) + : CaptureTool(parent) + , m_size(1) +{} -TextTool::TextTool(QObject *parent) : CaptureTool(parent), m_size(1) { -} - -bool TextTool::isValid() const { +bool TextTool::isValid() const +{ return !m_text.isEmpty(); } -bool TextTool::closeOnButtonPressed() const { +bool TextTool::closeOnButtonPressed() const +{ return false; } -bool TextTool::isSelectable() const { +bool TextTool::isSelectable() const +{ return true; } -bool TextTool::showMousePreview() const { +bool TextTool::showMousePreview() const +{ return false; } -QIcon TextTool::icon(const QColor &background, bool inEditor) const { +QIcon TextTool::icon(const QColor& background, bool inEditor) const +{ Q_UNUSED(inEditor); return QIcon(iconPath(background) + "text.svg"); } -QString TextTool::name() const { +QString TextTool::name() const +{ return tr("Text"); } -QString TextTool::nameID() { +QString TextTool::nameID() +{ return QLatin1String(""); } -QString TextTool::description() const { +QString TextTool::description() const +{ return tr("Add text to your capture"); } -QWidget *TextTool::widget() { - TextWidget *w = new TextWidget(); +QWidget* TextTool::widget() +{ + TextWidget* w = new TextWidget(); w->setTextColor(m_color); m_font.setPointSize(m_size + BASE_POINT_SIZE); w->setFont(m_font); - connect(w, &TextWidget::textUpdated, - this, &TextTool::updateText); + connect(w, &TextWidget::textUpdated, this, &TextTool::updateText); m_widget = w; return w; } -QWidget *TextTool::configurationWidget() { +QWidget* TextTool::configurationWidget() +{ m_confW = new TextConfig(); - connect(m_confW, &TextConfig::fontFamilyChanged, - this, &TextTool::updateFamily); - connect(m_confW, &TextConfig::fontItalicChanged, - this, &TextTool::updateFontItalic); - connect(m_confW, &TextConfig::fontStrikeOutChanged, - this, &TextTool::updateFontStrikeOut); - connect(m_confW, &TextConfig::fontUnderlineChanged, - this, &TextTool::updateFontUnderline); - connect(m_confW, &TextConfig::fontWeightChanged, - this, &TextTool::updateFontWeight); + connect( + m_confW, &TextConfig::fontFamilyChanged, this, &TextTool::updateFamily); + connect(m_confW, + &TextConfig::fontItalicChanged, + this, + &TextTool::updateFontItalic); + connect(m_confW, + &TextConfig::fontStrikeOutChanged, + this, + &TextTool::updateFontStrikeOut); + connect(m_confW, + &TextConfig::fontUnderlineChanged, + this, + &TextTool::updateFontUnderline); + connect(m_confW, + &TextConfig::fontWeightChanged, + this, + &TextTool::updateFontWeight); m_confW->setItalic(m_font.italic()); m_confW->setUnderline(m_font.underline()); m_confW->setStrikeOut(m_font.strikeOut()); @@ -88,28 +106,37 @@ QWidget *TextTool::configurationWidget() { return m_confW; } -CaptureTool *TextTool::copy(QObject *parent) { - TextTool *tt = new TextTool(parent); - connect(m_confW, &TextConfig::fontFamilyChanged, - tt, &TextTool::updateFamily); - connect(m_confW, &TextConfig::fontItalicChanged, - tt, &TextTool::updateFontItalic); - connect(m_confW, &TextConfig::fontStrikeOutChanged, - tt, &TextTool::updateFontStrikeOut); - connect(m_confW, &TextConfig::fontUnderlineChanged, - tt, &TextTool::updateFontUnderline); - connect(m_confW, &TextConfig::fontWeightChanged, - tt, &TextTool::updateFontWeight); +CaptureTool* TextTool::copy(QObject* parent) +{ + TextTool* tt = new TextTool(parent); + connect( + m_confW, &TextConfig::fontFamilyChanged, tt, &TextTool::updateFamily); + connect( + m_confW, &TextConfig::fontItalicChanged, tt, &TextTool::updateFontItalic); + connect(m_confW, + &TextConfig::fontStrikeOutChanged, + tt, + &TextTool::updateFontStrikeOut); + connect(m_confW, + &TextConfig::fontUnderlineChanged, + tt, + &TextTool::updateFontUnderline); + connect( + m_confW, &TextConfig::fontWeightChanged, tt, &TextTool::updateFontWeight); tt->m_font = m_font; return tt; } -void TextTool::undo(QPixmap &pixmap) { +void TextTool::undo(QPixmap& pixmap) +{ QPainter p(&pixmap); p.drawPixmap(m_backupArea.topLeft(), m_pixmapBackup); } -void TextTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) { +void TextTool::process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo) +{ if (m_text.isEmpty()) { return; } @@ -125,37 +152,45 @@ void TextTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo painter.drawText(m_backupArea + QMargins(-5, -5, 5, 5), m_text); } -void TextTool::paintMousePreview(QPainter &painter, const CaptureContext &context) { +void TextTool::paintMousePreview(QPainter& painter, + const CaptureContext& context) +{ Q_UNUSED(painter); Q_UNUSED(context); } -void TextTool::drawEnd(const QPoint &p) { +void TextTool::drawEnd(const QPoint& p) +{ m_backupArea.moveTo(p); } -void TextTool::drawMove(const QPoint &p) { +void TextTool::drawMove(const QPoint& p) +{ m_widget->move(p); } -void TextTool::drawStart(const CaptureContext &context) { +void TextTool::drawStart(const CaptureContext& context) +{ m_color = context.color; m_size = context.thickness; emit requestAction(REQ_ADD_CHILD_WIDGET); } -void TextTool::pressed(const CaptureContext &context) { +void TextTool::pressed(const CaptureContext& context) +{ Q_UNUSED(context); } -void TextTool::colorChanged(const QColor &c) { +void TextTool::colorChanged(const QColor& c) +{ m_color = c; if (m_widget) { m_widget->setTextColor(c); } } -void TextTool::thicknessChanged(const int th) { +void TextTool::thicknessChanged(const int th) +{ m_size = th; m_font.setPointSize(m_size + BASE_POINT_SIZE); if (m_widget) { @@ -163,46 +198,53 @@ void TextTool::thicknessChanged(const int th) { } } -void TextTool::updateText(const QString &s) { +void TextTool::updateText(const QString& s) +{ m_text = s; } -void TextTool::setFont(const QFont &f) { +void TextTool::setFont(const QFont& f) +{ m_font = f; if (m_widget) { m_widget->setFont(f); } } -void TextTool::updateFamily(const QString &s) { +void TextTool::updateFamily(const QString& s) +{ m_font.setFamily(s); if (m_widget) { m_widget->setFont(m_font); } } -void TextTool::updateFontUnderline(const bool underlined) { +void TextTool::updateFontUnderline(const bool underlined) +{ m_font.setUnderline(underlined); if (m_widget) { m_widget->setFont(m_font); } } -void TextTool::updateFontStrikeOut(const bool s) { +void TextTool::updateFontStrikeOut(const bool s) +{ m_font.setStrikeOut(s); if (m_widget) { m_widget->setFont(m_font); } } -void TextTool::updateFontWeight(const QFont::Weight w) { +void TextTool::updateFontWeight(const QFont::Weight w) +{ m_font.setWeight(w); if (m_widget) { m_widget->setFont(m_font); } } -void TextTool::updateFontItalic(const bool italic) { +void TextTool::updateFontItalic(const bool italic) +{ m_font.setItalic(italic); if (m_widget) { m_widget->setFont(m_font); diff --git a/src/tools/text/texttool.h b/src/tools/text/texttool.h index b454daaf..63cf192d 100644 --- a/src/tools/text/texttool.h +++ b/src/tools/text/texttool.h @@ -23,43 +23,45 @@ class TextWidget; class TextConfig; -class TextTool : public CaptureTool { +class TextTool : public CaptureTool +{ Q_OBJECT public: - explicit TextTool(QObject *parent = nullptr); + explicit TextTool(QObject* parent = nullptr); bool isValid() const override; bool closeOnButtonPressed() const override; bool isSelectable() const override; bool showMousePreview() const override; - QIcon icon(const QColor &background, - bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; QWidget* widget() override; QWidget* configurationWidget() override; - CaptureTool* copy(QObject *parent = nullptr) override; + CaptureTool* copy(QObject* parent = nullptr) override; - void undo(QPixmap &pixmap) override; - void process( - QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) override; - void paintMousePreview(QPainter &painter, const CaptureContext &context) override; + void undo(QPixmap& pixmap) override; + void process(QPainter& painter, + const QPixmap& pixmap, + bool recordUndo = false) override; + void paintMousePreview(QPainter& painter, + const CaptureContext& context) override; public slots: - void drawEnd(const QPoint &p) override; - void drawMove(const QPoint &p) override; - void drawStart(const CaptureContext &context) override; - void pressed(const CaptureContext &context) override; - void colorChanged(const QColor &c) override; + void drawEnd(const QPoint& p) override; + void drawMove(const QPoint& p) override; + void drawStart(const CaptureContext& context) override; + void pressed(const CaptureContext& context) override; + void colorChanged(const QColor& c) override; void thicknessChanged(const int th) override; private slots: - void updateText(const QString &s); - void setFont(const QFont &f); - void updateFamily(const QString &s); + void updateText(const QString& s); + void setFont(const QFont& f); + void updateFamily(const QString& s); void updateFontUnderline(const bool underlined); void updateFontStrikeOut(const bool s); void updateFontWeight(const QFont::Weight w); diff --git a/src/tools/text/textwidget.cpp b/src/tools/text/textwidget.cpp index 78586342..d991abfd 100644 --- a/src/tools/text/textwidget.cpp +++ b/src/tools/text/textwidget.cpp @@ -17,21 +17,22 @@ #include "textwidget.h" -TextWidget::TextWidget(QWidget *parent) : QTextEdit(parent) { +TextWidget::TextWidget(QWidget* parent) + : QTextEdit(parent) +{ setStyleSheet(QStringLiteral("TextWidget { background: transparent; }")); - connect(this, &TextWidget::textChanged, - this, &TextWidget::adjustSize); - connect(this, &TextWidget::textChanged, - this, &TextWidget::emitTextUpdated); + connect(this, &TextWidget::textChanged, this, &TextWidget::adjustSize); + connect(this, &TextWidget::textChanged, this, &TextWidget::emitTextUpdated); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setContextMenuPolicy(Qt::NoContextMenu); } -void TextWidget::showEvent(QShowEvent *e) { +void TextWidget::showEvent(QShowEvent* e) +{ QFont font; QFontMetrics fm(font); - setFixedWidth(fm.lineSpacing() *6); + setFixedWidth(fm.lineSpacing() * 6); setFixedHeight(fm.lineSpacing() * 2.5); m_baseSize = size(); m_minSize = m_baseSize; @@ -39,34 +40,41 @@ void TextWidget::showEvent(QShowEvent *e) { adjustSize(); } -void TextWidget::resizeEvent(QResizeEvent *e) { +void TextWidget::resizeEvent(QResizeEvent* e) +{ m_minSize.setHeight(qMin(m_baseSize.height(), height())); m_minSize.setWidth(qMin(m_baseSize.width(), width())); QTextEdit::resizeEvent(e); } -void TextWidget::setFont(const QFont &f) { +void TextWidget::setFont(const QFont& f) +{ QTextEdit::setFont(f); adjustSize(); } -void TextWidget::updateFont(const QFont &f) { +void TextWidget::updateFont(const QFont& f) +{ setFont(f); } -void TextWidget::setFontPointSize(qreal s) { +void TextWidget::setFontPointSize(qreal s) +{ QFont f = font(); f.setPointSize(s); setFont(f); } -void TextWidget::setTextColor(const QColor &c) { - QString s(QStringLiteral("TextWidget { background: transparent; color: %1; }")); +void TextWidget::setTextColor(const QColor& c) +{ + QString s( + QStringLiteral("TextWidget { background: transparent; color: %1; }")); setStyleSheet(s.arg(c.name())); } -void TextWidget::adjustSize() { - QString &&text = this->toPlainText(); +void TextWidget::adjustSize() +{ + QString&& text = this->toPlainText(); QFontMetrics fm(font()); QRect bounds = fm.boundingRect(QRect(), 0, text); @@ -82,6 +90,7 @@ void TextWidget::adjustSize() { this->setFixedSize(pixelsWide, pixelsHigh); } -void TextWidget::emitTextUpdated() { +void TextWidget::emitTextUpdated() +{ emit textUpdated(this->toPlainText()); } diff --git a/src/tools/text/textwidget.h b/src/tools/text/textwidget.h index 6d947656..40f23c58 100644 --- a/src/tools/text/textwidget.h +++ b/src/tools/text/textwidget.h @@ -23,21 +23,21 @@ class TextWidget : public QTextEdit { Q_OBJECT public: - explicit TextWidget(QWidget *parent = nullptr); + explicit TextWidget(QWidget* parent = nullptr); void adjustSize(); - void setFont(const QFont &f); + void setFont(const QFont& f); protected: - void showEvent(QShowEvent *e); - void resizeEvent(QResizeEvent *e); + void showEvent(QShowEvent* e); + void resizeEvent(QResizeEvent* e); signals: - void textUpdated(const QString &s); + void textUpdated(const QString& s); public slots: - void updateFont(const QFont &f); - void setTextColor(const QColor &c); + void updateFont(const QFont& f); + void setTextColor(const QColor& c); void setFontPointSize(qreal s); private slots: diff --git a/src/tools/toolfactory.h b/src/tools/toolfactory.h index 5ceaa224..0dc0c12d 100644 --- a/src/tools/toolfactory.h +++ b/src/tools/toolfactory.h @@ -17,23 +17,22 @@ #pragma once -#include "src/widgets/capture/capturebutton.h" #include "src/tools/capturetool.h" +#include "src/widgets/capture/capturebutton.h" #include class CaptureTool; -class ToolFactory : public QObject { +class ToolFactory : public QObject +{ Q_OBJECT public: + explicit ToolFactory(QObject* parent = nullptr); - explicit ToolFactory(QObject *parent = nullptr); + ToolFactory(const ToolFactory&) = delete; + ToolFactory& operator=(const ToolFactory&) = delete; - ToolFactory(const ToolFactory &) = delete; - ToolFactory & operator=(const ToolFactory &) = delete; - - CaptureTool* CreateTool( - CaptureButton::ButtonType t, - QObject *parent = nullptr); + CaptureTool* CreateTool(CaptureButton::ButtonType t, + QObject* parent = nullptr); }; diff --git a/src/tools/undo/undotool.cpp b/src/tools/undo/undotool.cpp index c17c6f45..c3846a43 100644 --- a/src/tools/undo/undotool.cpp +++ b/src/tools/undo/undotool.cpp @@ -18,35 +18,42 @@ #include "undotool.h" #include -UndoTool::UndoTool(QObject *parent) : AbstractActionTool(parent) { +UndoTool::UndoTool(QObject* parent) + : AbstractActionTool(parent) +{} -} - -bool UndoTool::closeOnButtonPressed() const { +bool UndoTool::closeOnButtonPressed() const +{ return false; } -QIcon UndoTool::icon(const QColor &background, bool inEditor) const { +QIcon UndoTool::icon(const QColor& background, bool inEditor) const +{ Q_UNUSED(inEditor); return QIcon(iconPath(background) + "undo-variant.svg"); } -QString UndoTool::name() const { +QString UndoTool::name() const +{ return tr("Undo"); } -QString UndoTool::nameID() { +QString UndoTool::nameID() +{ return QLatin1String(""); } -QString UndoTool::description() const { +QString UndoTool::description() const +{ return tr("Undo the last modification"); } -CaptureTool* UndoTool::copy(QObject *parent) { +CaptureTool* UndoTool::copy(QObject* parent) +{ return new UndoTool(parent); } -void UndoTool::pressed(const CaptureContext &context) { +void UndoTool::pressed(const CaptureContext& context) +{ Q_UNUSED(context); emit requestAction(REQ_UNDO_MODIFICATION); } diff --git a/src/tools/undo/undotool.h b/src/tools/undo/undotool.h index fae4e6ab..50efbec9 100644 --- a/src/tools/undo/undotool.h +++ b/src/tools/undo/undotool.h @@ -19,21 +19,21 @@ #include "src/tools/abstractactiontool.h" -class UndoTool : public AbstractActionTool { +class UndoTool : public AbstractActionTool +{ Q_OBJECT public: - explicit UndoTool(QObject *parent = nullptr); + explicit UndoTool(QObject* parent = nullptr); bool closeOnButtonPressed() const; - QIcon icon(const QColor &background, bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; - CaptureTool* copy(QObject *parent = nullptr) override; + CaptureTool* copy(QObject* parent = nullptr) override; public slots: - void pressed(const CaptureContext &context) override; - + void pressed(const CaptureContext& context) override; }; diff --git a/src/utils/colorutils.cpp b/src/utils/colorutils.cpp index 3af02ddc..8ba9f8ed 100644 --- a/src/utils/colorutils.cpp +++ b/src/utils/colorutils.cpp @@ -17,11 +17,13 @@ #include "colorutils.h" -inline qreal getColorLuma(const QColor &c) { +inline qreal getColorLuma(const QColor& c) +{ return 0.30 * c.redF() + 0.59 * c.greenF() + 0.11 * c.blueF(); } -bool ColorUtils::colorIsDark(const QColor &c) { +bool ColorUtils::colorIsDark(const QColor& c) +{ bool isWhite = false; if (getColorLuma(c) <= 0.60) { isWhite = true; @@ -29,11 +31,11 @@ bool ColorUtils::colorIsDark(const QColor &c) { return isWhite; } -QColor ColorUtils::contrastColor(const QColor &c) { +QColor ColorUtils::contrastColor(const QColor& c) +{ int change = colorIsDark(c) ? 30 : -45; return QColor(qBound(0, c.red() + change, 255), qBound(0, c.green() + change, 255), qBound(0, c.blue() + change, 255)); } - diff --git a/src/utils/colorutils.h b/src/utils/colorutils.h index bb6d20aa..bfee6c78 100644 --- a/src/utils/colorutils.h +++ b/src/utils/colorutils.h @@ -21,8 +21,8 @@ namespace ColorUtils { // namespace -bool colorIsDark(const QColor &c); +bool colorIsDark(const QColor& c); -QColor contrastColor(const QColor &c); +QColor contrastColor(const QColor& c); } // namespace diff --git a/src/utils/configenterprise.cpp b/src/utils/configenterprise.cpp index 0880e7ec..34bc2ee0 100644 --- a/src/utils/configenterprise.cpp +++ b/src/utils/configenterprise.cpp @@ -1,24 +1,24 @@ #include "configenterprise.h" #include -#include #include -#include #include - +#include ConfigEnterprise::ConfigEnterprise() { // get enterprise settings m_settings = nullptr; QString configIniPath = QDir(QDir::currentPath()).filePath("config.ini"); - if(!(QFileInfo::exists(configIniPath) && QFileInfo(configIniPath).isFile())) { + if (!(QFileInfo::exists(configIniPath) && + QFileInfo(configIniPath).isFile())) { #if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) configIniPath = "/etc/flameshot/config.ini"; #elif defined(Q_OS_WIN) // calculate workdir for flameshot on startup if is not set yet QSettings bootUpSettings( - "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", - QSettings::NativeFormat); + "HKEY_CURRENT_" + "USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", + QSettings::NativeFormat); QFileInfo fi(bootUpSettings.value("Flameshot").toString()); configIniPath = QDir(fi.absolutePath()).filePath("config.ini"); #endif @@ -26,6 +26,7 @@ ConfigEnterprise::ConfigEnterprise() m_settings = new QSettings(configIniPath, QSettings::IniFormat); } -QSettings *ConfigEnterprise::settings() { +QSettings* ConfigEnterprise::settings() +{ return m_settings; } diff --git a/src/utils/configenterprise.h b/src/utils/configenterprise.h index 55a44e82..c4afaf89 100644 --- a/src/utils/configenterprise.h +++ b/src/utils/configenterprise.h @@ -3,16 +3,15 @@ class QSettings; - class ConfigEnterprise { public: ConfigEnterprise(); - QSettings *settings(); + QSettings* settings(); private: - QSettings *m_settings; + QSettings* m_settings; }; #endif // CONFIGENTERPRISE_H diff --git a/src/utils/configshortcuts.cpp b/src/utils/configshortcuts.cpp index 21baf233..6095c231 100644 --- a/src/utils/configshortcuts.cpp +++ b/src/utils/configshortcuts.cpp @@ -2,112 +2,133 @@ #include "src/tools/capturetool.h" #include - -ConfigShortcuts::ConfigShortcuts() -{ - -} +ConfigShortcuts::ConfigShortcuts() {} // QVector getButtons() -const QVector& ConfigShortcuts::captureShortcutsDefault(const QVector &buttons) { +const QVector& ConfigShortcuts::captureShortcutsDefault( + const QVector& buttons) +{ // get shortcuts names from tools - for (const CaptureButton::ButtonType &t: buttons) { - CaptureButton *b = new CaptureButton(t, nullptr); + for (const CaptureButton::ButtonType& t : buttons) { + CaptureButton* b = new CaptureButton(t, nullptr); QString shortcutName = QVariant::fromValue(t).toString(); QKeySequence ks = captureShortcutDefault(t); - m_shortcuts << (QStringList() << shortcutName << b->tool()->description() << ks.toString()); + m_shortcuts << (QStringList() + << shortcutName << b->tool()->description() + << ks.toString()); b->close(); } - m_shortcuts << (QStringList() << "TYPE_TOGGLE_PANEL" << QObject::tr("Toggle side panel") + m_shortcuts << (QStringList() + << "TYPE_TOGGLE_PANEL" << QObject::tr("Toggle side panel") << QKeySequence(Qt::Key_Space).toString()); - m_shortcuts << (QStringList() << "TYPE_RESIZE_LEFT" << QObject::tr("Resize selection left 1px") + m_shortcuts << (QStringList() + << "TYPE_RESIZE_LEFT" + << QObject::tr("Resize selection left 1px") << QKeySequence(Qt::SHIFT + Qt::Key_Left).toString()); - m_shortcuts << (QStringList() << "TYPE_RESIZE_RIGHT" << QObject::tr("Resize selection right 1px") + m_shortcuts << (QStringList() + << "TYPE_RESIZE_RIGHT" + << QObject::tr("Resize selection right 1px") << QKeySequence(Qt::SHIFT + Qt::Key_Right).toString()); - m_shortcuts << (QStringList() << "TYPE_RESIZE_UP" << QObject::tr("Resize selection up 1px") + m_shortcuts << (QStringList() + << "TYPE_RESIZE_UP" + << QObject::tr("Resize selection up 1px") << QKeySequence(Qt::SHIFT + Qt::Key_Up).toString()); - m_shortcuts << (QStringList() << "TYPE_RESIZE_DOWN" << QObject::tr("Resize selection down 1px") + m_shortcuts << (QStringList() + << "TYPE_RESIZE_DOWN" + << QObject::tr("Resize selection down 1px") << QKeySequence(Qt::SHIFT + Qt::Key_Down).toString()); - m_shortcuts << (QStringList() << "TYPE_MOVE_LEFT" << QObject::tr("Move selection left 1px") - << QKeySequence(Qt::Key_Left).toString()); - m_shortcuts << (QStringList() << "TYPE_MOVE_RIGHT" << QObject::tr("Move selection right 1px") - << QKeySequence(Qt::Key_Right).toString()); - m_shortcuts << (QStringList() << "TYPE_MOVE_UP" << QObject::tr("Move selection up 1px") + m_shortcuts << (QStringList() << "TYPE_MOVE_LEFT" + << QObject::tr("Move selection left 1px") + << QKeySequence(Qt::Key_Left).toString()); + m_shortcuts << (QStringList() << "TYPE_MOVE_RIGHT" + << QObject::tr("Move selection right 1px") + << QKeySequence(Qt::Key_Right).toString()); + m_shortcuts << (QStringList() + << "TYPE_MOVE_UP" << QObject::tr("Move selection up 1px") << QKeySequence(Qt::Key_Up).toString()); - m_shortcuts << (QStringList() << "TYPE_MOVE_DOWN" << QObject::tr("Move selection down 1px") - << QKeySequence(Qt::Key_Down).toString()); + m_shortcuts << (QStringList() << "TYPE_MOVE_DOWN" + << QObject::tr("Move selection down 1px") + << QKeySequence(Qt::Key_Down).toString()); - m_shortcuts << (QStringList() << "" << QObject::tr("Quit capture") << QKeySequence(Qt::Key_Escape).toString()); - m_shortcuts << (QStringList() << "" << QObject::tr("Screenshot history") << "Shift+Print Screen"); - m_shortcuts << (QStringList() << "" << QObject::tr("Capture screen") << "Print Screen"); - m_shortcuts << (QStringList() << "" << QObject::tr("Show color picker") << "Right Click"); - m_shortcuts << (QStringList() << "" << QObject::tr("Change the tool's thickness") << "Mouse Wheel"); + m_shortcuts << (QStringList() << "" << QObject::tr("Quit capture") + << QKeySequence(Qt::Key_Escape).toString()); + m_shortcuts << (QStringList() << "" << QObject::tr("Screenshot history") + << "Shift+Print Screen"); + m_shortcuts << (QStringList() + << "" << QObject::tr("Capture screen") << "Print Screen"); + m_shortcuts << (QStringList() + << "" << QObject::tr("Show color picker") << "Right Click"); + m_shortcuts << (QStringList() + << "" << QObject::tr("Change the tool's thickness") + << "Mouse Wheel"); return m_shortcuts; } -const QKeySequence &ConfigShortcuts::captureShortcutDefault(const CaptureButton::ButtonType &buttonType) { +const QKeySequence& ConfigShortcuts::captureShortcutDefault( + const CaptureButton::ButtonType& buttonType) +{ m_ks = QKeySequence(); switch (buttonType) { - case CaptureButton::ButtonType::TYPE_PENCIL: - m_ks = QKeySequence(Qt::Key_P); - break; - case CaptureButton::ButtonType::TYPE_DRAWER: - m_ks = QKeySequence(Qt::Key_D); - break; - case CaptureButton::ButtonType::TYPE_ARROW: - m_ks = QKeySequence(Qt::Key_A); - break; - case CaptureButton::ButtonType::TYPE_SELECTION: - m_ks = QKeySequence(Qt::Key_S); - break; - case CaptureButton::ButtonType::TYPE_RECTANGLE: - m_ks = QKeySequence(Qt::Key_R); - break; - case CaptureButton::ButtonType::TYPE_CIRCLE: - m_ks = QKeySequence(Qt::Key_C); - break; - case CaptureButton::ButtonType::TYPE_MARKER: - m_ks = QKeySequence(Qt::Key_M); - break; -// case CaptureButton::ButtonType::TYPE_SELECTIONINDICATOR: - case CaptureButton::ButtonType::TYPE_MOVESELECTION: - m_ks = QKeySequence(Qt::CTRL + Qt::Key_M); - break; - case CaptureButton::ButtonType::TYPE_UNDO: - m_ks = QKeySequence(Qt::CTRL + Qt::Key_Z); - break; - case CaptureButton::ButtonType::TYPE_COPY: - m_ks = QKeySequence(Qt::CTRL + Qt::Key_C); - break; - case CaptureButton::ButtonType::TYPE_SAVE: - m_ks = QKeySequence(Qt::CTRL + Qt::Key_S); - break; - case CaptureButton::ButtonType::TYPE_EXIT: - m_ks = QKeySequence(Qt::CTRL + Qt::Key_Q); - break; - case CaptureButton::ButtonType::TYPE_IMAGEUPLOADER: - m_ks = QKeySequence(Qt::Key_Return); - break; - case CaptureButton::ButtonType::TYPE_OPEN_APP: - m_ks = QKeySequence(Qt::CTRL + Qt::Key_O); - break; - case CaptureButton::ButtonType::TYPE_BLUR: - m_ks = QKeySequence(Qt::Key_B); - break; - case CaptureButton::ButtonType::TYPE_REDO: - m_ks = QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z); - break; -// case CaptureButton::ButtonType::TYPE_PIN: - case CaptureButton::ButtonType::TYPE_TEXT: - m_ks = QKeySequence(Qt::Key_T); - break; - default: - break; + case CaptureButton::ButtonType::TYPE_PENCIL: + m_ks = QKeySequence(Qt::Key_P); + break; + case CaptureButton::ButtonType::TYPE_DRAWER: + m_ks = QKeySequence(Qt::Key_D); + break; + case CaptureButton::ButtonType::TYPE_ARROW: + m_ks = QKeySequence(Qt::Key_A); + break; + case CaptureButton::ButtonType::TYPE_SELECTION: + m_ks = QKeySequence(Qt::Key_S); + break; + case CaptureButton::ButtonType::TYPE_RECTANGLE: + m_ks = QKeySequence(Qt::Key_R); + break; + case CaptureButton::ButtonType::TYPE_CIRCLE: + m_ks = QKeySequence(Qt::Key_C); + break; + case CaptureButton::ButtonType::TYPE_MARKER: + m_ks = QKeySequence(Qt::Key_M); + break; + // case CaptureButton::ButtonType::TYPE_SELECTIONINDICATOR: + case CaptureButton::ButtonType::TYPE_MOVESELECTION: + m_ks = QKeySequence(Qt::CTRL + Qt::Key_M); + break; + case CaptureButton::ButtonType::TYPE_UNDO: + m_ks = QKeySequence(Qt::CTRL + Qt::Key_Z); + break; + case CaptureButton::ButtonType::TYPE_COPY: + m_ks = QKeySequence(Qt::CTRL + Qt::Key_C); + break; + case CaptureButton::ButtonType::TYPE_SAVE: + m_ks = QKeySequence(Qt::CTRL + Qt::Key_S); + break; + case CaptureButton::ButtonType::TYPE_EXIT: + m_ks = QKeySequence(Qt::CTRL + Qt::Key_Q); + break; + case CaptureButton::ButtonType::TYPE_IMAGEUPLOADER: + m_ks = QKeySequence(Qt::Key_Return); + break; + case CaptureButton::ButtonType::TYPE_OPEN_APP: + m_ks = QKeySequence(Qt::CTRL + Qt::Key_O); + break; + case CaptureButton::ButtonType::TYPE_BLUR: + m_ks = QKeySequence(Qt::Key_B); + break; + case CaptureButton::ButtonType::TYPE_REDO: + m_ks = QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z); + break; + // case CaptureButton::ButtonType::TYPE_PIN: + case CaptureButton::ButtonType::TYPE_TEXT: + m_ks = QKeySequence(Qt::Key_T); + break; + default: + break; } return m_ks; } diff --git a/src/utils/configshortcuts.h b/src/utils/configshortcuts.h index f1e67ec6..adb97c9f 100644 --- a/src/utils/configshortcuts.h +++ b/src/utils/configshortcuts.h @@ -1,19 +1,21 @@ #ifndef CONFIGSHORTCUTS_H #define CONFIGSHORTCUTS_H -#include +#include "src/widgets/capture/capturebutton.h" +#include #include #include -#include -#include "src/widgets/capture/capturebutton.h" +#include class ConfigShortcuts { public: ConfigShortcuts(); - const QVector& captureShortcutsDefault(const QVector &buttons); - const QKeySequence& captureShortcutDefault(const CaptureButton::ButtonType &buttonType); + const QVector& captureShortcutsDefault( + const QVector& buttons); + const QKeySequence& captureShortcutDefault( + const CaptureButton::ButtonType& buttonType); private: QVector m_shortcuts; diff --git a/src/utils/dbusutils.cpp b/src/utils/dbusutils.cpp index 3a254f30..145444e2 100644 --- a/src/utils/dbusutils.cpp +++ b/src/utils/dbusutils.cpp @@ -18,34 +18,42 @@ #include "dbusutils.h" #include "src/utils/systemnotification.h" #include -#include #include +#include -DBusUtils::DBusUtils(QObject *parent) : QObject(parent) { -} +DBusUtils::DBusUtils(QObject* parent) + : QObject(parent) +{} -void DBusUtils::connectPrintCapture(QDBusConnection &session, uint id) { +void DBusUtils::connectPrintCapture(QDBusConnection& session, uint id) +{ m_id = id; // captureTaken session.connect(QStringLiteral("org.dharkael.Flameshot"), - QStringLiteral("/"), QLatin1String(""), QStringLiteral("captureTaken"), - this, - SLOT(captureTaken(uint, QByteArray))); + QStringLiteral("/"), + QLatin1String(""), + QStringLiteral("captureTaken"), + this, + SLOT(captureTaken(uint, QByteArray))); // captureFailed session.connect(QStringLiteral("org.dharkael.Flameshot"), - QStringLiteral("/"), QLatin1String(""), QStringLiteral("captureFailed"), - this, - SLOT(captureFailed(uint))); + QStringLiteral("/"), + QLatin1String(""), + QStringLiteral("captureFailed"), + this, + SLOT(captureFailed(uint))); } -void DBusUtils::checkDBusConnection(const QDBusConnection &connection) { +void DBusUtils::checkDBusConnection(const QDBusConnection& connection) +{ if (!connection.isConnected()) { SystemNotification().sendMessage(tr("Unable to connect via DBus")); qApp->exit(1); } } -void DBusUtils::captureTaken(uint id, QByteArray rawImage) { +void DBusUtils::captureTaken(uint id, QByteArray rawImage) +{ if (m_id == id) { QFile file; file.open(stdout, QIODevice::WriteOnly); @@ -55,7 +63,8 @@ void DBusUtils::captureTaken(uint id, QByteArray rawImage) { } } -void DBusUtils::captureFailed(uint id) { +void DBusUtils::captureFailed(uint id) +{ if (m_id == id) { QTextStream(stdout) << "screenshot aborted\n"; qApp->exit(1); diff --git a/src/utils/dbusutils.h b/src/utils/dbusutils.h index b7e7951c..87a84c07 100644 --- a/src/utils/dbusutils.h +++ b/src/utils/dbusutils.h @@ -21,19 +21,19 @@ #include #include -class DBusUtils : public QObject { +class DBusUtils : public QObject +{ Q_OBJECT public: - explicit DBusUtils(QObject *parent = nullptr); + explicit DBusUtils(QObject* parent = nullptr); - void connectPrintCapture(QDBusConnection &session, uint id); - void checkDBusConnection(const QDBusConnection &connection); + void connectPrintCapture(QDBusConnection& session, uint id); + void checkDBusConnection(const QDBusConnection& connection); public slots: void captureTaken(uint id, QByteArray rawImage); void captureFailed(uint id); private: - uint m_id; }; diff --git a/src/utils/desktopfileparse.cpp b/src/utils/desktopfileparse.cpp index 0079db1b..b6d0f005 100644 --- a/src/utils/desktopfileparse.cpp +++ b/src/utils/desktopfileparse.cpp @@ -16,25 +16,26 @@ // along with Flameshot. If not, see . #include "desktopfileparse.h" -#include #include +#include +#include #include #include -#include -DesktopFileParser::DesktopFileParser() { +DesktopFileParser::DesktopFileParser() +{ QString locale = QLocale().name(); QString localeShort = QLocale().name().left(2); m_localeName = QStringLiteral("Name[%1]").arg(locale); m_localeDescription = QStringLiteral("Comment[%1]").arg(locale); m_localeNameShort = QStringLiteral("Name[%1]").arg(localeShort); - m_localeDescriptionShort = QStringLiteral("Comment[%1]") - .arg(localeShort); - m_defaultIcon = QIcon::fromTheme(QStringLiteral("application-x-executable")); + m_localeDescriptionShort = QStringLiteral("Comment[%1]").arg(localeShort); + m_defaultIcon = + QIcon::fromTheme(QStringLiteral("application-x-executable")); } -DesktopAppData DesktopFileParser::parseDesktopFile( - const QString &fileName, bool &ok) const +DesktopAppData DesktopFileParser::parseDesktopFile(const QString& fileName, + bool& ok) const { DesktopAppData res; ok = true; @@ -55,51 +56,48 @@ DesktopAppData DesktopFileParser::parseDesktopFile( QString line = in.readLine(); if (line.startsWith(QLatin1String("Icon"))) { res.icon = QIcon::fromTheme( - line.mid(line.indexOf(QLatin1String("="))+1).trimmed(), - m_defaultIcon); - } - else if (!nameLocaleSet && line.startsWith(QLatin1String("Name"))) { + line.mid(line.indexOf(QLatin1String("=")) + 1).trimmed(), + m_defaultIcon); + } else if (!nameLocaleSet && line.startsWith(QLatin1String("Name"))) { if (line.startsWith(m_localeName) || - line.startsWith(m_localeNameShort)) - { - res.name = line.mid(line.indexOf(QLatin1String("="))+1).trimmed(); + line.startsWith(m_localeNameShort)) { + res.name = + line.mid(line.indexOf(QLatin1String("=")) + 1).trimmed(); nameLocaleSet = true; } else if (line.startsWith(QLatin1String("Name="))) { - res.name = line.mid(line.indexOf(QLatin1String("="))+1).trimmed(); + res.name = + line.mid(line.indexOf(QLatin1String("=")) + 1).trimmed(); } - } - else if (!descriptionLocaleSet && line.startsWith(QLatin1String("Comment"))) { + } else if (!descriptionLocaleSet && + line.startsWith(QLatin1String("Comment"))) { if (line.startsWith(m_localeDescription) || - line.startsWith(m_localeDescriptionShort)) - { - res.description = line.mid(line.indexOf(QLatin1String("="))+1).trimmed(); + line.startsWith(m_localeDescriptionShort)) { + res.description = + line.mid(line.indexOf(QLatin1String("=")) + 1).trimmed(); descriptionLocaleSet = true; } else if (line.startsWith(QLatin1String("Comment="))) { - res.description = line.mid(line.indexOf(QLatin1String("="))+1).trimmed(); + res.description = + line.mid(line.indexOf(QLatin1String("=")) + 1).trimmed(); } - } - else if (line.startsWith(QLatin1String("Exec"))) { + } else if (line.startsWith(QLatin1String("Exec"))) { if (line.contains(QLatin1String("%"))) { - res.exec = line.mid(line.indexOf(QLatin1String("="))+1) - .trimmed(); + res.exec = + line.mid(line.indexOf(QLatin1String("=")) + 1).trimmed(); } else { ok = false; break; } - } - else if (line.startsWith(QLatin1String("Type"))) { + } else if (line.startsWith(QLatin1String("Type"))) { if (line.contains(QLatin1String("Application"))) { isApplication = true; } - } - else if (line.startsWith(QLatin1String("Categories"))) { - res.categories = line.mid(line.indexOf(QLatin1String("="))+1).split(QStringLiteral(";")); - } - else if (line == QLatin1String("NoDisplay=true")) { + } else if (line.startsWith(QLatin1String("Categories"))) { + res.categories = line.mid(line.indexOf(QLatin1String("=")) + 1) + .split(QStringLiteral(";")); + } else if (line == QLatin1String("NoDisplay=true")) { ok = false; break; - } - else if (line == QLatin1String("Terminal=true")) { + } else if (line == QLatin1String("Terminal=true")) { res.showInTerminal = true; } // ignore the other entries @@ -114,11 +112,12 @@ DesktopAppData DesktopFileParser::parseDesktopFile( return res; } -int DesktopFileParser::processDirectory(const QDir &dir) { +int DesktopFileParser::processDirectory(const QDir& dir) +{ QStringList entries = dir.entryList(QDir::NoDotAndDotDot | QDir::Files); bool ok; int length = m_appList.length(); - for (QString file: entries){ + for (QString file : entries) { DesktopAppData app = parseDesktopFile(dir.absoluteFilePath(file), ok); if (ok) { m_appList.append(app); @@ -127,9 +126,11 @@ int DesktopFileParser::processDirectory(const QDir &dir) { return m_appList.length() - length; } -QVector DesktopFileParser::getAppsByCategory(const QString &category) { +QVector DesktopFileParser::getAppsByCategory( + const QString& category) +{ QVector res; - for (const DesktopAppData &app : m_appList) { + for (const DesktopAppData& app : m_appList) { if (app.categories.contains(category)) { res.append(app); } @@ -138,11 +139,11 @@ QVector DesktopFileParser::getAppsByCategory(const QString &cate } QMap> DesktopFileParser::getAppsByCategory( - const QStringList &categories) + const QStringList& categories) { QMap> res; - for (const DesktopAppData &app : m_appList) { - for (const QString &category: categories) { + for (const DesktopAppData& app : m_appList) { + for (const QString& category : categories) { if (app.categories.contains(category)) { res[category].append(app); } diff --git a/src/utils/desktopfileparse.h b/src/utils/desktopfileparse.h index c00a53cf..0f39c4f4 100644 --- a/src/utils/desktopfileparse.h +++ b/src/utils/desktopfileparse.h @@ -18,29 +18,32 @@ #pragma once #include -#include #include +#include class QDir; class QString; class QTextStream; -struct DesktopAppData { - DesktopAppData() : showInTerminal() {} - - DesktopAppData( - const QString &name, - const QString &description, - const QString &exec, - QIcon icon) : - name(name), - description(description), - exec(exec), - icon(icon), - showInTerminal(false) +struct DesktopAppData +{ + DesktopAppData() + : showInTerminal() {} - bool operator==(const DesktopAppData &other) const { + DesktopAppData(const QString& name, + const QString& description, + const QString& exec, + QIcon icon) + : name(name) + , description(description) + , exec(exec) + , icon(icon) + , showInTerminal(false) + {} + + bool operator==(const DesktopAppData& other) const + { return name == other.name; } @@ -52,14 +55,15 @@ struct DesktopAppData { bool showInTerminal; }; -struct DesktopFileParser { +struct DesktopFileParser +{ DesktopFileParser(); - DesktopAppData parseDesktopFile(const QString &fileName, bool &ok) const; - int processDirectory(const QDir &dir); + DesktopAppData parseDesktopFile(const QString& fileName, bool& ok) const; + int processDirectory(const QDir& dir); - QVector getAppsByCategory(const QString &category); + QVector getAppsByCategory(const QString& category); QMap> getAppsByCategory( - const QStringList &categories); + const QStringList& categories); private: QString m_localeName; diff --git a/src/utils/desktopinfo.cpp b/src/utils/desktopinfo.cpp index 9c4b1e1f..bb932b78 100644 --- a/src/utils/desktopinfo.cpp +++ b/src/utils/desktopinfo.cpp @@ -18,28 +18,34 @@ #include "desktopinfo.h" #include -DesktopInfo::DesktopInfo() { +DesktopInfo::DesktopInfo() +{ auto e = QProcessEnvironment::systemEnvironment(); XDG_CURRENT_DESKTOP = e.value(QStringLiteral("XDG_CURRENT_DESKTOP")); XDG_SESSION_TYPE = e.value(QStringLiteral("XDG_SESSION_TYPE")); WAYLAND_DISPLAY = e.value(QStringLiteral("WAYLAND_DISPLAY")); KDE_FULL_SESSION = e.value(QStringLiteral("KDE_FULL_SESSION")); - GNOME_DESKTOP_SESSION_ID = e.value(QStringLiteral("GNOME_DESKTOP_SESSION_ID")); + GNOME_DESKTOP_SESSION_ID = + e.value(QStringLiteral("GNOME_DESKTOP_SESSION_ID")); DESKTOP_SESSION = e.value(QStringLiteral("DESKTOP_SESSION")); } -bool DesktopInfo::waylandDectected() { +bool DesktopInfo::waylandDectected() +{ return XDG_SESSION_TYPE == QLatin1String("wayland") || - WAYLAND_DISPLAY.contains(QLatin1String("wayland"), Qt::CaseInsensitive); + WAYLAND_DISPLAY.contains(QLatin1String("wayland"), + Qt::CaseInsensitive); } -DesktopInfo::WM DesktopInfo::windowManager() { +DesktopInfo::WM DesktopInfo::windowManager() +{ DesktopInfo::WM res = DesktopInfo::OTHER; - if (XDG_CURRENT_DESKTOP.contains(QLatin1String("GNOME"), Qt::CaseInsensitive) || - !GNOME_DESKTOP_SESSION_ID.isEmpty()) - { + if (XDG_CURRENT_DESKTOP.contains(QLatin1String("GNOME"), + Qt::CaseInsensitive) || + !GNOME_DESKTOP_SESSION_ID.isEmpty()) { res = DesktopInfo::GNOME; - } else if (!KDE_FULL_SESSION.isEmpty() || DESKTOP_SESSION == QLatin1String("kde-plasma")) { + } else if (!KDE_FULL_SESSION.isEmpty() || + DESKTOP_SESSION == QLatin1String("kde-plasma")) { res = DesktopInfo::KDE; } return res; diff --git a/src/utils/desktopinfo.h b/src/utils/desktopinfo.h index 06220f4a..061c6e0a 100644 --- a/src/utils/desktopinfo.h +++ b/src/utils/desktopinfo.h @@ -19,11 +19,13 @@ #include -class DesktopInfo { +class DesktopInfo +{ public: DesktopInfo(); - enum WM { + enum WM + { GNOME, KDE, OTHER diff --git a/src/utils/filenamehandler.cpp b/src/utils/filenamehandler.cpp index 7554939d..35eee619 100644 --- a/src/utils/filenamehandler.cpp +++ b/src/utils/filenamehandler.cpp @@ -17,79 +17,92 @@ #include "filenamehandler.h" #include "src/utils/confighandler.h" +#include +#include #include #include -#include -#include -FileNameHandler::FileNameHandler(QObject *parent) : QObject(parent) { +FileNameHandler::FileNameHandler(QObject* parent) + : QObject(parent) +{ std::locale::global(std::locale("")); } -QString FileNameHandler::parsedPattern() { +QString FileNameHandler::parsedPattern() +{ return parseFilename(ConfigHandler().filenamePatternValue()); } -QString FileNameHandler::parseFilename(const QString &name) { +QString FileNameHandler::parseFilename(const QString& name) +{ QString res = name; // remove trailing characters '%' in the pattern if (name.isEmpty()) { res = QLatin1String("%F_%H-%M"); } - while(res.endsWith('%')) { + while (res.endsWith('%')) { res.chop(1); } std::time_t t = std::time(NULL); - char *tempData = QStringTocharArr(res); - char data[MAX_CHARACTERS] = {0}; - std::strftime(data, sizeof(data), - tempData, std::localtime(&t)); + char* tempData = QStringTocharArr(res); + char data[MAX_CHARACTERS] = { 0 }; + std::strftime(data, sizeof(data), tempData, std::localtime(&t)); res = QString::fromLocal8Bit(data, (int)strlen(data)); free(tempData); // add the parsed pattern in a correct format for the filesystem - res = res.replace(QLatin1String("/"), QStringLiteral("⁄")).replace(QLatin1String(":"), QLatin1String("-")); + res = res.replace(QLatin1String("/"), QStringLiteral("⁄")) + .replace(QLatin1String(":"), QLatin1String("-")); return res; } -QString FileNameHandler::generateAbsolutePath(const QString &path) { +QString FileNameHandler::generateAbsolutePath(const QString& path) +{ QString directory = path; QString filename = parsedPattern(); fixPath(directory, filename); return directory + filename; } // path a images si no existe, add numeration -void FileNameHandler::setPattern(const QString &pattern) { +void FileNameHandler::setPattern(const QString& pattern) +{ ConfigHandler().setFilenamePattern(pattern); } -QString FileNameHandler::absoluteSavePath(QString &directory, QString &filename) { +QString FileNameHandler::absoluteSavePath(QString& directory, QString& filename) +{ ConfigHandler config; directory = config.savePathValue(); - if (directory.isEmpty() || !QDir(directory).exists() || !QFileInfo(directory).isWritable()) { - directory = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); + if (directory.isEmpty() || !QDir(directory).exists() || + !QFileInfo(directory).isWritable()) { + directory = + QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); } filename = parsedPattern(); fixPath(directory, filename); return directory + filename; } -QString FileNameHandler::absoluteSavePath() { +QString FileNameHandler::absoluteSavePath() +{ QString dir, file; return absoluteSavePath(dir, file); } -QString FileNameHandler::charArrToQString(const char *c) { +QString FileNameHandler::charArrToQString(const char* c) +{ return QString::fromLocal8Bit(c, MAX_CHARACTERS); } -char * FileNameHandler::QStringTocharArr(const QString &s) { +char* FileNameHandler::QStringTocharArr(const QString& s) +{ QByteArray ba = s.toLocal8Bit(); - return const_cast(strdup(ba.constData())); + return const_cast(strdup(ba.constData())); } -void FileNameHandler::fixPath(QString &directory, QString &filename) { +void FileNameHandler::fixPath(QString& directory, QString& filename) +{ // add '/' at the end of the directory if (!directory.endsWith(QLatin1String("/"))) { directory += QLatin1String("/"); @@ -101,8 +114,8 @@ void FileNameHandler::fixPath(QString &directory, QString &filename) { filename += QLatin1String("_"); int i = 1; while (true) { - checkFile.setFile( - directory + filename + QString::number(i) + ".png"); + checkFile.setFile(directory + filename + QString::number(i) + + ".png"); if (!checkFile.exists()) { filename += QString::number(i); break; diff --git a/src/utils/filenamehandler.h b/src/utils/filenamehandler.h index 5d379064..c20e752f 100644 --- a/src/utils/filenamehandler.h +++ b/src/utils/filenamehandler.h @@ -19,27 +19,27 @@ #include -class FileNameHandler : public QObject { +class FileNameHandler : public QObject +{ Q_OBJECT public: - explicit FileNameHandler(QObject *parent = nullptr); + explicit FileNameHandler(QObject* parent = nullptr); QString parsedPattern(); - QString parseFilename(const QString &name); - QString generateAbsolutePath(const QString &path); - QString absoluteSavePath(QString &directory, QString &filename); + QString parseFilename(const QString& name); + QString generateAbsolutePath(const QString& path); + QString absoluteSavePath(QString& directory, QString& filename); QString absoluteSavePath(); - static const int MAX_CHARACTERS = 70; public slots: - void setPattern(const QString &pattern); + void setPattern(const QString& pattern); private: - //using charArr = char[MAX_CHARACTERS]; - QString charArrToQString(const char *c); - char * QStringTocharArr(const QString &s); + // using charArr = char[MAX_CHARACTERS]; + QString charArrToQString(const char* c); + char* QStringTocharArr(const QString& s); - void fixPath(QString &directory, QString &filename); + void fixPath(QString& directory, QString& filename); }; diff --git a/src/utils/globalvalues.cpp b/src/utils/globalvalues.cpp index fde27e1e..60349e6d 100644 --- a/src/utils/globalvalues.cpp +++ b/src/utils/globalvalues.cpp @@ -16,9 +16,10 @@ // along with Flameshot. If not, see . #include "globalvalues.h" -#include #include +#include -int GlobalValues::buttonBaseSize() { +int GlobalValues::buttonBaseSize() +{ return QApplication::fontMetrics().lineSpacing() * 2.2; } diff --git a/src/utils/pathinfo.cpp b/src/utils/pathinfo.cpp index 8e51d47d..32802d1e 100644 --- a/src/utils/pathinfo.cpp +++ b/src/utils/pathinfo.cpp @@ -17,29 +17,30 @@ #include "pathinfo.h" #include -#include #include +#include -const QString PathInfo::whiteIconPath() { +const QString PathInfo::whiteIconPath() +{ return QStringLiteral(":/img/material/white/"); } -const QString PathInfo::blackIconPath() { +const QString PathInfo::blackIconPath() +{ return QStringLiteral(":/img/material/black/"); } -QStringList PathInfo::translationsPaths() { - QString binaryPath = QFileInfo(qApp->applicationDirPath()) - .absoluteFilePath(); - QString trPath = QDir::toNativeSeparators(binaryPath + "/translations") ; +QStringList PathInfo::translationsPaths() +{ + QString binaryPath = + QFileInfo(qApp->applicationDirPath()).absoluteFilePath(); + QString trPath = QDir::toNativeSeparators(binaryPath + "/translations"); #if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) return QStringList() - << QStringLiteral(APP_PREFIX) + "/share/flameshot/translations" - << trPath - << QStringLiteral("/usr/share/flameshot/translations") - << QStringLiteral("/usr/local/share/flameshot/translations"); + << QStringLiteral(APP_PREFIX) + "/share/flameshot/translations" + << trPath << QStringLiteral("/usr/share/flameshot/translations") + << QStringLiteral("/usr/local/share/flameshot/translations"); #elif defined(Q_OS_WIN) - return QStringList() - << trPath; + return QStringList() << trPath; #endif } diff --git a/src/utils/screengrabber.cpp b/src/utils/screengrabber.cpp index 8b535bd0..a6a35711 100644 --- a/src/utils/screengrabber.cpp +++ b/src/utils/screengrabber.cpp @@ -18,11 +18,11 @@ #include "screengrabber.h" #include "src/utils/filenamehandler.h" #include "src/utils/systemnotification.h" -#include -#include -#include #include #include +#include +#include +#include #if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) #include @@ -30,47 +30,56 @@ #include #endif -ScreenGrabber::ScreenGrabber(QObject *parent) : QObject(parent) { +ScreenGrabber::ScreenGrabber(QObject* parent) + : QObject(parent) +{} -} - -QPixmap ScreenGrabber::grabEntireDesktop(bool &ok) { +QPixmap ScreenGrabber::grabEntireDesktop(bool& ok) +{ ok = true; #if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) - if(m_info.waylandDectected()) { + if (m_info.waylandDectected()) { QPixmap res; // handle screenshot based on DE switch (m_info.windowManager()) { - case DesktopInfo::GNOME: { - // https://github.com/GNOME/gnome-shell/blob/695bfb96160033be55cfb5ac41c121998f98c328/data/org.gnome.Shell.Screenshot.xml - QString path = FileNameHandler().generateAbsolutePath(QDir::tempPath()) + ".png"; - QDBusInterface gnomeInterface(QStringLiteral("org.gnome.Shell"), - QStringLiteral("/org/gnome/Shell/Screenshot"), - QStringLiteral("org.gnome.Shell.Screenshot")); - QDBusReply reply = gnomeInterface.call(QStringLiteral("Screenshot"), false, false, path); - if (reply.value()) { - res = QPixmap(path); - QFile dbusResult(path); - dbusResult.remove(); - } else { + case DesktopInfo::GNOME: { + // https://github.com/GNOME/gnome-shell/blob/695bfb96160033be55cfb5ac41c121998f98c328/data/org.gnome.Shell.Screenshot.xml + QString path = + FileNameHandler().generateAbsolutePath(QDir::tempPath()) + + ".png"; + QDBusInterface gnomeInterface( + QStringLiteral("org.gnome.Shell"), + QStringLiteral("/org/gnome/Shell/Screenshot"), + QStringLiteral("org.gnome.Shell.Screenshot")); + QDBusReply reply = gnomeInterface.call( + QStringLiteral("Screenshot"), false, false, path); + if (reply.value()) { + res = QPixmap(path); + QFile dbusResult(path); + dbusResult.remove(); + } else { + ok = false; + } + break; + } + case DesktopInfo::KDE: { + // https://github.com/KDE/spectacle/blob/517a7baf46a4ca0a45f32fd3f2b1b7210b180134/src/PlatformBackends/KWinWaylandImageGrabber.cpp#L145 + QDBusInterface kwinInterface( + QStringLiteral("org.kde.KWin"), + QStringLiteral("/Screenshot"), + QStringLiteral("org.kde.kwin.Screenshot")); + QDBusReply reply = + kwinInterface.call(QStringLiteral("screenshotFullscreen")); + res = QPixmap(reply.value()); + if (!res.isNull()) { + QFile dbusResult(reply.value()); + dbusResult.remove(); + } + break; + } + default: ok = false; - } - break; - } case DesktopInfo::KDE: { - // https://github.com/KDE/spectacle/blob/517a7baf46a4ca0a45f32fd3f2b1b7210b180134/src/PlatformBackends/KWinWaylandImageGrabber.cpp#L145 - QDBusInterface kwinInterface(QStringLiteral("org.kde.KWin"), - QStringLiteral("/Screenshot"), - QStringLiteral("org.kde.kwin.Screenshot")); - QDBusReply reply = kwinInterface.call(QStringLiteral("screenshotFullscreen")); - res = QPixmap(reply.value()); - if (!res.isNull()) { - QFile dbusResult(reply.value()); - dbusResult.remove(); - } - break; - } default: - ok = false; - break; + break; } if (!ok) { SystemNotification().sendMessage(tr("Unable to capture screen")); @@ -80,24 +89,24 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool &ok) { #endif QRect geometry; - for (QScreen *const screen : QGuiApplication::screens()) { + for (QScreen* const screen : QGuiApplication::screens()) { geometry = geometry.united(screen->geometry()); } QPixmap p(QApplication::primaryScreen()->grabWindow( - QApplication::desktop()->winId(), - geometry.x(), - geometry.y(), - geometry.width(), - geometry.height()) - ); + QApplication::desktop()->winId(), + geometry.x(), + geometry.y(), + geometry.width(), + geometry.height())); auto screenNumber = QApplication::desktop()->screenNumber(); - QScreen *screen = QApplication::screens()[screenNumber]; + QScreen* screen = QApplication::screens()[screenNumber]; p.setDevicePixelRatio(screen->devicePixelRatio()); return p; } -QPixmap ScreenGrabber::grabScreen(int screenNumber, bool &ok) { +QPixmap ScreenGrabber::grabScreen(int screenNumber, bool& ok) +{ QPixmap p; bool isVirtual = QApplication::desktop()->isVirtualDesktop(); if (isVirtual || m_info.waylandDectected()) { @@ -105,16 +114,16 @@ QPixmap ScreenGrabber::grabScreen(int screenNumber, bool &ok) { if (ok) { QPoint topLeft(0, 0); #ifdef Q_OS_WIN - for (QScreen *const screen : QGuiApplication::screens()) { + for (QScreen* const screen : QGuiApplication::screens()) { QPoint topLeftScreen = screen->geometry().topLeft(); if (topLeft.x() > topLeftScreen.x() || - topLeft.y() > topLeftScreen.y()) { + topLeft.y() > topLeftScreen.y()) { topLeft = topLeftScreen; } } #endif - QRect geometry = QApplication::desktop()-> - screenGeometry(screenNumber); + QRect geometry = + QApplication::desktop()->screenGeometry(screenNumber); geometry.moveTo(geometry.topLeft() - topLeft); p = p.copy(geometry); } diff --git a/src/utils/screengrabber.h b/src/utils/screengrabber.h index eb40ee6d..b31bff1f 100644 --- a/src/utils/screengrabber.h +++ b/src/utils/screengrabber.h @@ -20,12 +20,13 @@ #include "src/utils/desktopinfo.h" #include -class ScreenGrabber : public QObject { +class ScreenGrabber : public QObject +{ Q_OBJECT public: - explicit ScreenGrabber(QObject *parent = nullptr); - QPixmap grabEntireDesktop(bool &ok); - QPixmap grabScreen(int screenNumber, bool &ok); + explicit ScreenGrabber(QObject* parent = nullptr); + QPixmap grabEntireDesktop(bool& ok); + QPixmap grabScreen(int screenNumber, bool& ok); private: DesktopInfo m_info; diff --git a/src/utils/screenshotsaver.cpp b/src/utils/screenshotsaver.cpp index 31bbb9b2..0115e43a 100644 --- a/src/utils/screenshotsaver.cpp +++ b/src/utils/screenshotsaver.cpp @@ -17,26 +17,24 @@ #include "screenshotsaver.h" #include "src/utils/confighandler.h" -#include "src/utils/systemnotification.h" #include "src/utils/filenamehandler.h" -#include "src/utils/confighandler.h" -#include +#include "src/utils/systemnotification.h" #include -#include +#include #include #include +#include -ScreenshotSaver::ScreenshotSaver() { -} +ScreenshotSaver::ScreenshotSaver() {} -void ScreenshotSaver::saveToClipboard(const QPixmap &capture) { - SystemNotification().sendMessage( - QObject::tr("Capture saved to clipboard")); +void ScreenshotSaver::saveToClipboard(const QPixmap& capture) +{ + SystemNotification().sendMessage(QObject::tr("Capture saved to clipboard")); QApplication::clipboard()->setPixmap(capture); } -bool ScreenshotSaver::saveToFilesystem(const QPixmap &capture, - const QString &path) +bool ScreenshotSaver::saveToFilesystem(const QPixmap& capture, + const QString& path) { QString completePath = FileNameHandler().generateAbsolutePath(path); completePath += QLatin1String(".png"); @@ -56,17 +54,19 @@ bool ScreenshotSaver::saveToFilesystem(const QPixmap &capture, return ok; } -bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap &capture) { +bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap& capture) +{ bool ok = false; while (!ok) { ConfigHandler config; QString savePath = FileNameHandler().absoluteSavePath(); - if(config.savePathFixed().size() == 0) { + if (config.savePathFixed().size() == 0) { savePath = QFileDialog::getSaveFileName( - nullptr, - QObject::tr("Save screenshot"), - FileNameHandler().absoluteSavePath(), - QLatin1String("Portable Network Graphic file (PNG) (*.png);;BMP file (*.bmp);;JPEG file (*.jpg)")); + nullptr, + QObject::tr("Save screenshot"), + FileNameHandler().absoluteSavePath(), + QLatin1String("Portable Network Graphic file (PNG) (*.png);;BMP " + "file (*.bmp);;JPEG file (*.jpg)")); } if (savePath.isNull()) { @@ -84,20 +84,21 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap &capture) { if (ok) { ConfigHandler config; - QString pathNoFile = savePath.left(savePath.lastIndexOf(QLatin1String("/"))); + QString pathNoFile = + savePath.left(savePath.lastIndexOf(QLatin1String("/"))); config.setSavePath(pathNoFile); QString msg = QObject::tr("Capture saved as ") + savePath; - if(config.copyPathAfterSaveEnabled()) { + if (config.copyPathAfterSaveEnabled()) { QApplication::clipboard()->setText(savePath); - msg = QObject::tr("Capture saved and copied to the clipboard as ") + savePath; + msg = + QObject::tr("Capture saved and copied to the clipboard as ") + + savePath; } SystemNotification().sendMessage(msg, savePath); } else { QString msg = QObject::tr("Error trying to save as ") + savePath; QMessageBox saveErrBox( - QMessageBox::Warning, - QObject::tr("Save Error"), - msg); + QMessageBox::Warning, QObject::tr("Save Error"), msg); saveErrBox.setWindowIcon(QIcon(":img/app/flameshot.svg")); saveErrBox.exec(); } diff --git a/src/utils/screenshotsaver.h b/src/utils/screenshotsaver.h index 0455cde3..f18fefef 100644 --- a/src/utils/screenshotsaver.h +++ b/src/utils/screenshotsaver.h @@ -20,12 +20,12 @@ class QPixmap; class QString; -class ScreenshotSaver { +class ScreenshotSaver +{ public: ScreenshotSaver(); - void saveToClipboard(const QPixmap &capture); - bool saveToFilesystem(const QPixmap &capture, const QString &path); - bool saveToFilesystemGUI(const QPixmap &capture); - + void saveToClipboard(const QPixmap& capture); + bool saveToFilesystem(const QPixmap& capture, const QString& path); + bool saveToFilesystemGUI(const QPixmap& capture); }; diff --git a/src/utils/systemnotification.cpp b/src/utils/systemnotification.cpp index 41a549d2..3df103af 100644 --- a/src/utils/systemnotification.cpp +++ b/src/utils/systemnotification.cpp @@ -5,37 +5,43 @@ #ifndef Q_OS_WIN #include -#include #include +#include #else #endif #include "src/core/controller.h" #if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) -SystemNotification::SystemNotification(QObject *parent) : QObject(parent) { - m_interface = new QDBusInterface(QStringLiteral("org.freedesktop.Notifications"), - QStringLiteral("/org/freedesktop/Notifications"), - QStringLiteral("org.freedesktop.Notifications"), - QDBusConnection::sessionBus(), - this); +SystemNotification::SystemNotification(QObject* parent) + : QObject(parent) +{ + m_interface = + new QDBusInterface(QStringLiteral("org.freedesktop.Notifications"), + QStringLiteral("/org/freedesktop/Notifications"), + QStringLiteral("org.freedesktop.Notifications"), + QDBusConnection::sessionBus(), + this); } #else -SystemNotification::SystemNotification(QObject *parent) : QObject(parent) { +SystemNotification::SystemNotification(QObject* parent) + : QObject(parent) +{ m_interface = nullptr; } #endif -void SystemNotification::sendMessage(const QString &text, const QString &savePath) { +void SystemNotification::sendMessage(const QString& text, + const QString& savePath) +{ sendMessage(text, tr("Flameshot Info"), savePath); } -void SystemNotification::sendMessage( - const QString &text, - const QString &title, - const QString &savePath, - const int timeout) +void SystemNotification::sendMessage(const QString& text, + const QString& title, + const QString& savePath, + const int timeout) { - if(!ConfigHandler().desktopNotificationValue()) { + if (!ConfigHandler().desktopNotificationValue()) { return; } @@ -45,17 +51,19 @@ void SystemNotification::sendMessage( if (!savePath.isEmpty()) { QUrl fullPath = QUrl::fromLocalFile(savePath); // allows the notification to be dragged and dropped - hintsMap[QStringLiteral("x-kde-urls")] = QStringList({fullPath.toString()}); + hintsMap[QStringLiteral("x-kde-urls")] = + QStringList({ fullPath.toString() }); } - args << (qAppName()) //appname - << static_cast(0) //id - << "flameshot" //icon - << title //summary - << text //body - << QStringList() //actions - << hintsMap //hints - << timeout; //timeout - m_interface->callWithArgumentList(QDBus::AutoDetect, QStringLiteral("Notify"), args); + args << (qAppName()) // appname + << static_cast(0) // id + << "flameshot" // icon + << title // summary + << text // body + << QStringList() // actions + << hintsMap // hints + << timeout; // timeout + m_interface->callWithArgumentList( + QDBus::AutoDetect, QStringLiteral("Notify"), args); #else auto c = Controller::getInstance(); c->sendTrayNotification(text, title, timeout); diff --git a/src/utils/systemnotification.h b/src/utils/systemnotification.h index b018246b..0cfb24fa 100644 --- a/src/utils/systemnotification.h +++ b/src/utils/systemnotification.h @@ -21,19 +21,19 @@ class QDBusInterface; -class SystemNotification : public QObject { +class SystemNotification : public QObject +{ Q_OBJECT public: - explicit SystemNotification(QObject *parent = nullptr); + explicit SystemNotification(QObject* parent = nullptr); - void sendMessage(const QString &text, - const QString &savePath = {}); + void sendMessage(const QString& text, const QString& savePath = {}); - void sendMessage(const QString &text, - const QString &title, - const QString &savePath, + void sendMessage(const QString& text, + const QString& title, + const QString& savePath, const int timeout = 5000); private: - QDBusInterface *m_interface; + QDBusInterface* m_interface; }; diff --git a/src/utils/waylandutils.cpp b/src/utils/waylandutils.cpp index d06f5479..a46e59f2 100644 --- a/src/utils/waylandutils.cpp +++ b/src/utils/waylandutils.cpp @@ -1,10 +1,5 @@ #include "waylandutils.h" -WaylandUtils::WaylandUtils() -{ +WaylandUtils::WaylandUtils() {} -} - -bool WaylandUtils::waylandDetected() { - -} +bool WaylandUtils::waylandDetected() {} diff --git a/src/utils/waylandutils.h b/src/utils/waylandutils.h index 2811759c..32fe512b 100644 --- a/src/utils/waylandutils.h +++ b/src/utils/waylandutils.h @@ -1,7 +1,6 @@ #ifndef WAYLANDUTILS_H #define WAYLANDUTILS_H - class WaylandUtils { public: @@ -10,7 +9,6 @@ public: static bool waylandDetected(); private: - }; #endif // WAYLANDUTILS_H diff --git a/src/widgets/capture/buttonhandler.cpp b/src/widgets/capture/buttonhandler.cpp index 373a096d..f20e5be5 100644 --- a/src/widgets/capture/buttonhandler.cpp +++ b/src/widgets/capture/buttonhandler.cpp @@ -17,43 +17,45 @@ #include "buttonhandler.h" #include "src/utils/globalvalues.h" -#include #include +#include #include // ButtonHandler is a habdler for every active button. It makes easier to // manipulate the buttons as a unit. -ButtonHandler::ButtonHandler(const QVector &v, - QObject *parent) : - QObject(parent) +ButtonHandler::ButtonHandler(const QVector& v, QObject* parent) + : QObject(parent) { setButtons(v); init(); } -ButtonHandler::ButtonHandler(QObject *parent) : - QObject(parent) +ButtonHandler::ButtonHandler(QObject* parent) + : QObject(parent) { init(); } -void ButtonHandler::hide() { - for (CaptureButton *b: m_vectorButtons) +void ButtonHandler::hide() +{ + for (CaptureButton* b : m_vectorButtons) b->hide(); } -void ButtonHandler::show() { +void ButtonHandler::show() +{ if (m_vectorButtons.isEmpty() || m_vectorButtons.first()->isVisible()) { return; } - for (CaptureButton *b: m_vectorButtons) + for (CaptureButton* b : m_vectorButtons) b->animatedShow(); } -bool ButtonHandler::isVisible() const { +bool ButtonHandler::isVisible() const +{ bool ret = true; - for (const CaptureButton *b: m_vectorButtons) { + for (const CaptureButton* b : m_vectorButtons) { if (!b->isVisible()) { ret = false; break; @@ -62,11 +64,13 @@ bool ButtonHandler::isVisible() const { return ret; } -bool ButtonHandler::buttonsAreInside() const { +bool ButtonHandler::buttonsAreInside() const +{ return m_buttonsAreInside; } -size_t ButtonHandler::size() const { +size_t ButtonHandler::size() const +{ return m_vectorButtons.size(); } @@ -74,7 +78,8 @@ size_t ButtonHandler::size() const { // selection area. Ignores the sides blocked by the end of the screen. // When the selection is too small it works on a virtual selection with // the original in the center. -void ButtonHandler::updatePosition(const QRect &selection) { +void ButtonHandler::updatePosition(const QRect& selection) +{ resetRegionTrack(); const int vecLength = m_vectorButtons.size(); if (vecLength == 0) { @@ -96,11 +101,13 @@ void ButtonHandler::updatePosition(const QRect &selection) { break; // the while } // Number of buttons per row column - int buttonsPerRow = (m_selection.width() + m_separator) / (m_buttonExtendedSize); - int buttonsPerCol = (m_selection.height() + m_separator) / (m_buttonExtendedSize); + int buttonsPerRow = + (m_selection.width() + m_separator) / (m_buttonExtendedSize); + int buttonsPerCol = + (m_selection.height() + m_separator) / (m_buttonExtendedSize); // Buttons to be placed in the corners - int extraButtons = (vecLength - elemIndicator) - - (buttonsPerRow + buttonsPerCol) * 2; + int extraButtons = + (vecLength - elemIndicator) - (buttonsPerRow + buttonsPerCol) * 2; int elemsAtCorners = extraButtons > 4 ? 4 : extraButtons; int maxExtra = 2; if (m_oneHorizontalBlocked) { @@ -123,7 +130,8 @@ void ButtonHandler::updatePosition(const QRect &selection) { adjustHorizontalCenter(center); } // ElemIndicator, elemsAtCorners - QVector positions = horizontalPoints(center, addCounter, true); + QVector positions = + horizontalPoints(center, addCounter, true); moveButtonsToPoints(positions, elemIndicator); } // Add buttons at the right side of the seletion @@ -133,7 +141,8 @@ void ButtonHandler::updatePosition(const QRect &selection) { QPoint center = QPoint(m_selection.right() + m_separator, m_selection.center().y()); - QVector positions = verticalPoints(center, addCounter, false); + QVector positions = + verticalPoints(center, addCounter, false); moveButtonsToPoints(positions, elemIndicator); } // Add buttons at the top of the seletion @@ -145,7 +154,8 @@ void ButtonHandler::updatePosition(const QRect &selection) { if (addCounter == 1 + buttonsPerRow) { adjustHorizontalCenter(center); } - QVector positions = horizontalPoints(center, addCounter, false); + QVector positions = + horizontalPoints(center, addCounter, false); moveButtonsToPoints(positions, elemIndicator); } // Add buttons at the left side of the seletion @@ -155,7 +165,8 @@ void ButtonHandler::updatePosition(const QRect &selection) { QPoint center = QPoint(m_selection.left() - m_buttonExtendedSize, m_selection.center().y()); - QVector positions = verticalPoints(center, addCounter, true); + QVector positions = + verticalPoints(center, addCounter, true); moveButtonsToPoints(positions, elemIndicator); } // If there are elements for the next cycle, increase the size of the @@ -170,8 +181,9 @@ void ButtonHandler::updatePosition(const QRect &selection) { // horizontalPoints is an auxiliary method for the button position computation. // starts from a known center and keeps adding elements horizontally // and returns the computed positions. -QVector ButtonHandler::horizontalPoints( - const QPoint ¢er, const int elements, const bool leftToRight) const +QVector ButtonHandler::horizontalPoints(const QPoint& center, + const int elements, + const bool leftToRight) const { QVector res; // Distance from the center to start adding buttons @@ -179,16 +191,18 @@ QVector ButtonHandler::horizontalPoints( if (elements % 2 == 0) { shift = m_buttonExtendedSize * (elements / 2) - (m_separator / 2); } else { - shift = m_buttonExtendedSize * ((elements-1) / 2) + m_buttonBaseSize / 2; + shift = + m_buttonExtendedSize * ((elements - 1) / 2) + m_buttonBaseSize / 2; } - if (!leftToRight) { shift -= m_buttonBaseSize; } - int x = leftToRight ? center.x() - shift : - center.x() + shift; + if (!leftToRight) { + shift -= m_buttonBaseSize; + } + int x = leftToRight ? center.x() - shift : center.x() + shift; QPoint i(x, center.y()); while (elements > res.length()) { res.append(i); - leftToRight ? i.setX(i.x() + m_buttonExtendedSize) : - i.setX(i.x() - m_buttonExtendedSize); + leftToRight ? i.setX(i.x() + m_buttonExtendedSize) + : i.setX(i.x() - m_buttonExtendedSize); } return res; } @@ -196,8 +210,9 @@ QVector ButtonHandler::horizontalPoints( // verticalPoints is an auxiliary method for the button position computation. // starts from a known center and keeps adding elements vertically // and returns the computed positions. -QVector ButtonHandler::verticalPoints( - const QPoint ¢er, const int elements, const bool upToDown) const +QVector ButtonHandler::verticalPoints(const QPoint& center, + const int elements, + const bool upToDown) const { QVector res; // Distance from the center to start adding buttons @@ -205,23 +220,26 @@ QVector ButtonHandler::verticalPoints( if (elements % 2 == 0) { shift = m_buttonExtendedSize * (elements / 2) - (m_separator / 2); } else { - shift = m_buttonExtendedSize * ((elements-1) / 2) + m_buttonBaseSize / 2; + shift = + m_buttonExtendedSize * ((elements - 1) / 2) + m_buttonBaseSize / 2; } - if (!upToDown) { shift -= m_buttonBaseSize; } - int y = upToDown ? center.y() - shift : - center.y() + shift; + if (!upToDown) { + shift -= m_buttonBaseSize; + } + int y = upToDown ? center.y() - shift : center.y() + shift; QPoint i(center.x(), y); while (elements > res.length()) { res.append(i); - upToDown ? i.setY(i.y() + m_buttonExtendedSize) : - i.setY(i.y() - m_buttonExtendedSize); + upToDown ? i.setY(i.y() + m_buttonExtendedSize) + : i.setY(i.y() - m_buttonExtendedSize); } return res; } -QRect ButtonHandler::intersectWithAreas(const QRect &rect) { +QRect ButtonHandler::intersectWithAreas(const QRect& rect) +{ QRect res; - for(const QRect &r : m_screenRegions.rects()) { + for (const QRect& r : m_screenRegions.rects()) { QRect temp = rect.intersected(r); if (temp.height() * temp.width() > res.height() * res.width()) { res = temp; @@ -230,54 +248,56 @@ QRect ButtonHandler::intersectWithAreas(const QRect &rect) { return res; } -void ButtonHandler::init() { +void ButtonHandler::init() +{ m_separator = GlobalValues::buttonBaseSize() / 4; } -void ButtonHandler::resetRegionTrack() { +void ButtonHandler::resetRegionTrack() +{ m_buttonsAreInside = false; } -void ButtonHandler::updateBlockedSides() { +void ButtonHandler::updateBlockedSides() +{ const int EXTENSION = m_separator * 2 + m_buttonBaseSize; // Right - QPoint pointA(m_selection.right() + EXTENSION, - m_selection.bottom()); - QPoint pointB(pointA.x(), - m_selection.top()); - m_blockedRight = !(m_screenRegions.contains(pointA) && - m_screenRegions.contains(pointB)); + QPoint pointA(m_selection.right() + EXTENSION, m_selection.bottom()); + QPoint pointB(pointA.x(), m_selection.top()); + m_blockedRight = + !(m_screenRegions.contains(pointA) && m_screenRegions.contains(pointB)); // Left pointA.setX(m_selection.left() - EXTENSION); pointB.setX(pointA.x()); - m_blockedLeft = !(m_screenRegions.contains(pointA) && - m_screenRegions.contains(pointB)); + m_blockedLeft = + !(m_screenRegions.contains(pointA) && m_screenRegions.contains(pointB)); // Bottom - pointA = QPoint(m_selection.left(), - m_selection.bottom() + EXTENSION); - pointB = QPoint(m_selection.right(), - pointA.y()); - m_blockedBotton = !(m_screenRegions.contains(pointA) && - m_screenRegions.contains(pointB)); + pointA = QPoint(m_selection.left(), m_selection.bottom() + EXTENSION); + pointB = QPoint(m_selection.right(), pointA.y()); + m_blockedBotton = + !(m_screenRegions.contains(pointA) && m_screenRegions.contains(pointB)); // Top pointA.setY(m_selection.top() - EXTENSION); pointB.setY(pointA.y()); - m_blockedTop = !(m_screenRegions.contains(pointA) && - m_screenRegions.contains(pointB)); + m_blockedTop = + !(m_screenRegions.contains(pointA) && m_screenRegions.contains(pointB)); // Auxiliary - m_oneHorizontalBlocked = (!m_blockedRight && m_blockedLeft) || - (m_blockedRight && !m_blockedLeft); + m_oneHorizontalBlocked = + (!m_blockedRight && m_blockedLeft) || (m_blockedRight && !m_blockedLeft); m_horizontalyBlocked = (m_blockedRight && m_blockedLeft); - m_allSidesBlocked = (m_blockedBotton && m_horizontalyBlocked && m_blockedTop); + m_allSidesBlocked = + (m_blockedBotton && m_horizontalyBlocked && m_blockedTop); } -void ButtonHandler::expandSelection() { - int &s = m_buttonExtendedSize; +void ButtonHandler::expandSelection() +{ + int& s = m_buttonExtendedSize; m_selection = m_selection + QMargins(s, s, s, s); m_selection = intersectWithAreas(m_selection); } -void ButtonHandler::positionButtonsInside(int index) { +void ButtonHandler::positionButtonsInside(int index) +{ // Position the buttons in the botton-center of the main but inside of the // selection. QRect mainArea = m_selection; @@ -286,8 +306,8 @@ void ButtonHandler::positionButtonsInside(int index) { if (buttonsPerRow == 0) { return; } - QPoint center = QPoint(mainArea.center().x(), - mainArea.bottom() - m_buttonExtendedSize); + QPoint center = + QPoint(mainArea.center().x(), mainArea.bottom() - m_buttonExtendedSize); while (m_vectorButtons.size() > index) { int addCounter = buttonsPerRow; @@ -300,56 +320,61 @@ void ButtonHandler::positionButtonsInside(int index) { m_buttonsAreInside = true; } -void ButtonHandler::ensureSelectionMinimunSize() { +void ButtonHandler::ensureSelectionMinimunSize() +{ // Detect if a side is smaller than a button in order to prevent collision - // and redimension the base area the the base size of a single button per side + // and redimension the base area the the base size of a single button per + // side if (m_selection.width() < m_buttonBaseSize) { if (!m_blockedLeft) { m_selection.setX(m_selection.x() - - (m_buttonBaseSize-m_selection.width()) / 2); + (m_buttonBaseSize - m_selection.width()) / 2); } m_selection.setWidth(m_buttonBaseSize); } if (m_selection.height() < m_buttonBaseSize) { if (!m_blockedTop) { m_selection.setY(m_selection.y() - - (m_buttonBaseSize-m_selection.height()) / 2); + (m_buttonBaseSize - m_selection.height()) / 2); } m_selection.setHeight(m_buttonBaseSize); } } -void ButtonHandler::moveButtonsToPoints( - const QVector &points, int &index) +void ButtonHandler::moveButtonsToPoints(const QVector& points, + int& index) { - for (const QPoint &p: points) { + for (const QPoint& p : points) { auto button = m_vectorButtons[index]; button->move(p); ++index; } } -void ButtonHandler::adjustHorizontalCenter(QPoint ¢er) { +void ButtonHandler::adjustHorizontalCenter(QPoint& center) +{ if (m_blockedLeft) { - center.setX(center.x() + m_buttonExtendedSize/2); + center.setX(center.x() + m_buttonExtendedSize / 2); } else if (m_blockedRight) { - center.setX(center.x() - m_buttonExtendedSize/2); + center.setX(center.x() - m_buttonExtendedSize / 2); } } // setButtons redefines the buttons of the button handler -void ButtonHandler::setButtons(const QVector v) { +void ButtonHandler::setButtons(const QVector v) +{ if (v.isEmpty()) return; - for (CaptureButton *b: m_vectorButtons) - delete(b); + for (CaptureButton* b : m_vectorButtons) + delete (b); m_vectorButtons = v; m_buttonBaseSize = GlobalValues::buttonBaseSize(); m_buttonExtendedSize = m_buttonBaseSize + m_separator; } -bool ButtonHandler::contains(const QPoint &p) const { +bool ButtonHandler::contains(const QPoint& p) const +{ QPoint first(m_vectorButtons.first()->pos()); QPoint last(m_vectorButtons.last()->pos()); bool firstIsTopLeft = (first.x() <= last.x() && first.y() <= last.y()); @@ -361,13 +386,15 @@ bool ButtonHandler::contains(const QPoint &p) const { return r.contains(p); } -void ButtonHandler::updateScreenRegions(const QVector &rects) { +void ButtonHandler::updateScreenRegions(const QVector& rects) +{ m_screenRegions = QRegion(); - for (const QRect &rect: rects) { + for (const QRect& rect : rects) { m_screenRegions += rect; } } -void ButtonHandler::updateScreenRegions(const QRect &rect) { +void ButtonHandler::updateScreenRegions(const QRect& rect) +{ m_screenRegions = QRegion(rect); } diff --git a/src/widgets/capture/buttonhandler.h b/src/widgets/capture/buttonhandler.h index 9efd8bdb..3edd22e7 100644 --- a/src/widgets/capture/buttonhandler.h +++ b/src/widgets/capture/buttonhandler.h @@ -18,43 +18,46 @@ #pragma once #include "capturebutton.h" -#include #include #include +#include class CaptureButton; class QRect; class QPoint; -class ButtonHandler : public QObject { +class ButtonHandler : public QObject +{ Q_OBJECT public: - ButtonHandler(const QVector&, QObject *parent = nullptr); - explicit ButtonHandler(QObject *parent = nullptr); + ButtonHandler(const QVector&, QObject* parent = nullptr); + explicit ButtonHandler(QObject* parent = nullptr); - void hideSectionUnderMouse(const QPoint &p); + void hideSectionUnderMouse(const QPoint& p); bool isVisible() const; bool buttonsAreInside() const; size_t size() const; void setButtons(const QVector); - bool contains(const QPoint &p) const; - void updateScreenRegions(const QVector &rects); - void updateScreenRegions(const QRect &rect); + bool contains(const QPoint& p) const; + void updateScreenRegions(const QVector& rects); + void updateScreenRegions(const QRect& rect); public slots: - void updatePosition(const QRect &selection); + void updatePosition(const QRect& selection); void hide(); void show(); private: - QVector horizontalPoints(const QPoint ¢er, const int elements, - const bool leftToRight) const; - QVector verticalPoints(const QPoint ¢er, const int elements, - const bool upToDown) const; + QVector horizontalPoints(const QPoint& center, + const int elements, + const bool leftToRight) const; + QVector verticalPoints(const QPoint& center, + const int elements, + const bool upToDown) const; - QRect intersectWithAreas(const QRect &rect); + QRect intersectWithAreas(const QRect& rect); QVector m_vectorButtons; @@ -82,6 +85,6 @@ private: void expandSelection(); void positionButtonsInside(int index); void ensureSelectionMinimunSize(); - void moveButtonsToPoints(const QVector &points, int &index); - void adjustHorizontalCenter(QPoint ¢er); + void moveButtonsToPoints(const QVector& points, int& index); + void adjustHorizontalCenter(QPoint& center); }; diff --git a/src/widgets/capture/capturebutton.cpp b/src/widgets/capture/capturebutton.cpp index 8a809660..426a645d 100644 --- a/src/widgets/capture/capturebutton.cpp +++ b/src/widgets/capture/capturebutton.cpp @@ -16,24 +16,25 @@ // along with Flameshot. If not, see . #include "capturebutton.h" -#include "src/widgets/capture/capturewidget.h" -#include "src/utils/confighandler.h" #include "src/tools/capturetool.h" #include "src/tools/toolfactory.h" -#include "src/utils/globalvalues.h" #include "src/utils/colorutils.h" +#include "src/utils/confighandler.h" +#include "src/utils/globalvalues.h" +#include "src/widgets/capture/capturewidget.h" +#include +#include #include +#include #include #include -#include -#include -#include // Button represents a single button of the capture widget, it can enable // multiple functionality. -CaptureButton::CaptureButton(const ButtonType t, QWidget *parent) : QPushButton(parent), - m_buttonType(t) +CaptureButton::CaptureButton(const ButtonType t, QWidget* parent) + : QPushButton(parent) + , m_buttonType(t) { initButton(); if (t == TYPE_SELECTIONINDICATOR) { @@ -45,23 +46,26 @@ CaptureButton::CaptureButton(const ButtonType t, QWidget *parent) : QPushButton( setCursor(Qt::ArrowCursor); } -void CaptureButton::initButton() { +void CaptureButton::initButton() +{ m_tool = ToolFactory().CreateTool(m_buttonType, this); setFocusPolicy(Qt::NoFocus); resize(GlobalValues::buttonBaseSize(), GlobalValues::buttonBaseSize()); - setMask(QRegion(QRect(-1,-1, GlobalValues::buttonBaseSize()+2, - GlobalValues::buttonBaseSize()+2), + setMask(QRegion(QRect(-1, + -1, + GlobalValues::buttonBaseSize() + 2, + GlobalValues::buttonBaseSize() + 2), QRegion::Ellipse)); setToolTip(m_tool->description()); - m_emergeAnimation = new QPropertyAnimation(this, "size", this); + m_emergeAnimation = new QPropertyAnimation(this, "size", this); m_emergeAnimation->setEasingCurve(QEasingCurve::InOutQuad); m_emergeAnimation->setDuration(80); m_emergeAnimation->setStartValue(QSize(0, 0)); m_emergeAnimation->setEndValue( - QSize(GlobalValues::buttonBaseSize(), GlobalValues::buttonBaseSize())); + QSize(GlobalValues::buttonBaseSize(), GlobalValues::buttonBaseSize())); auto dsEffect = new QGraphicsDropShadowEffect(this); dsEffect->setBlurRadius(5); @@ -69,19 +73,21 @@ void CaptureButton::initButton() { dsEffect->setColor(QColor(Qt::black)); setGraphicsEffect(dsEffect); - } -void CaptureButton::updateIcon() { +void CaptureButton::updateIcon() +{ setIcon(icon()); - setIconSize(size()*0.6); + setIconSize(size() * 0.6); } -QVector CaptureButton::getIterableButtonTypes() { +QVector CaptureButton::getIterableButtonTypes() +{ return iterableButtonTypes; } -QString CaptureButton::globalStyleSheet() { +QString CaptureButton::globalStyleSheet() +{ QColor mainColor = ConfigHandler().uiMainColorValue(); QString baseSheet = "CaptureButton { border-radius: %3;" "background-color: %1; color: %4 }" @@ -94,11 +100,14 @@ QString CaptureButton::globalStyleSheet() { // foreground color QString color = ColorUtils::colorIsDark(mainColor) ? "white" : "black"; - return baseSheet.arg(mainColor.name()).arg(contrast.name()) - .arg(GlobalValues::buttonBaseSize()/2).arg(color); + return baseSheet.arg(mainColor.name()) + .arg(contrast.name()) + .arg(GlobalValues::buttonBaseSize() / 2) + .arg(color); } -QString CaptureButton::styleSheet() const { +QString CaptureButton::styleSheet() const +{ QString baseSheet = "CaptureButton { border-radius: %3;" "background-color: %1; color: %4 }" "CaptureButton:hover { background-color: %2; }" @@ -109,36 +118,43 @@ QString CaptureButton::styleSheet() const { // foreground color QString color = ColorUtils::colorIsDark(m_mainColor) ? "white" : "black"; - return baseSheet.arg(m_mainColor.name()).arg(contrast.name()) - .arg(GlobalValues::buttonBaseSize()/2).arg(color); + return baseSheet.arg(m_mainColor.name()) + .arg(contrast.name()) + .arg(GlobalValues::buttonBaseSize() / 2) + .arg(color); } // get icon returns the icon for the type of button -QIcon CaptureButton::icon() const { +QIcon CaptureButton::icon() const +{ return m_tool->icon(m_mainColor, true); } -void CaptureButton::mousePressEvent(QMouseEvent *e) { +void CaptureButton::mousePressEvent(QMouseEvent* e) +{ if (e->button() == Qt::LeftButton) { emit pressedButton(this); emit pressed(); } } -void CaptureButton::animatedShow() { - if(!isVisible()) { +void CaptureButton::animatedShow() +{ + if (!isVisible()) { show(); m_emergeAnimation->start(); - connect(m_emergeAnimation, &QPropertyAnimation::finished, this, [](){ - }); + connect( + m_emergeAnimation, &QPropertyAnimation::finished, this, []() {}); } } -CaptureTool *CaptureButton::tool() const { +CaptureTool* CaptureButton::tool() const +{ return m_tool; } -void CaptureButton::setColor(const QColor &c) { +void CaptureButton::setColor(const QColor& c) +{ m_mainColor = c; setStyleSheet(styleSheet()); updateIcon(); @@ -146,51 +162,44 @@ void CaptureButton::setColor(const QColor &c) { QColor CaptureButton::m_mainColor = ConfigHandler().uiMainColorValue(); -static std::map buttonTypeOrder { - { CaptureButton::TYPE_PENCIL, 0 }, - { CaptureButton::TYPE_DRAWER, 1 }, - { CaptureButton::TYPE_ARROW, 2 }, - { CaptureButton::TYPE_SELECTION, 3 }, - { CaptureButton::TYPE_RECTANGLE, 4 }, - { CaptureButton::TYPE_CIRCLE, 5 }, - { CaptureButton::TYPE_MARKER, 6 }, - { CaptureButton::TYPE_TEXT, 7 }, - { CaptureButton::TYPE_BLUR, 8 }, +static std::map buttonTypeOrder{ + { CaptureButton::TYPE_PENCIL, 0 }, + { CaptureButton::TYPE_DRAWER, 1 }, + { CaptureButton::TYPE_ARROW, 2 }, + { CaptureButton::TYPE_SELECTION, 3 }, + { CaptureButton::TYPE_RECTANGLE, 4 }, + { CaptureButton::TYPE_CIRCLE, 5 }, + { CaptureButton::TYPE_MARKER, 6 }, + { CaptureButton::TYPE_TEXT, 7 }, + { CaptureButton::TYPE_BLUR, 8 }, { CaptureButton::TYPE_SELECTIONINDICATOR, 9 }, - { CaptureButton::TYPE_MOVESELECTION, 10 }, - { CaptureButton::TYPE_UNDO, 11 }, - { CaptureButton::TYPE_REDO, 12 }, - { CaptureButton::TYPE_COPY, 13 }, - { CaptureButton::TYPE_SAVE, 14 }, - { CaptureButton::TYPE_EXIT, 15 }, - { CaptureButton::TYPE_IMAGEUPLOADER, 16 }, - { CaptureButton::TYPE_OPEN_APP, 17 }, - { CaptureButton::TYPE_PIN, 18 }, + { CaptureButton::TYPE_MOVESELECTION, 10 }, + { CaptureButton::TYPE_UNDO, 11 }, + { CaptureButton::TYPE_REDO, 12 }, + { CaptureButton::TYPE_COPY, 13 }, + { CaptureButton::TYPE_SAVE, 14 }, + { CaptureButton::TYPE_EXIT, 15 }, + { CaptureButton::TYPE_IMAGEUPLOADER, 16 }, + { CaptureButton::TYPE_OPEN_APP, 17 }, + { CaptureButton::TYPE_PIN, 18 }, }; -int CaptureButton::getPriorityByButton(CaptureButton::ButtonType b) { +int CaptureButton::getPriorityByButton(CaptureButton::ButtonType b) +{ auto it = buttonTypeOrder.find(b); - return it == buttonTypeOrder.cend() ? (int)buttonTypeOrder.size() : it->second; + return it == buttonTypeOrder.cend() ? (int)buttonTypeOrder.size() + : it->second; } QVector CaptureButton::iterableButtonTypes = { - CaptureButton::TYPE_PENCIL, - CaptureButton::TYPE_DRAWER, - CaptureButton::TYPE_ARROW, - CaptureButton::TYPE_SELECTION, - CaptureButton::TYPE_RECTANGLE, - CaptureButton::TYPE_CIRCLE, - CaptureButton::TYPE_MARKER, - CaptureButton::TYPE_TEXT, - CaptureButton::TYPE_BLUR, - CaptureButton::TYPE_SELECTIONINDICATOR, - CaptureButton::TYPE_MOVESELECTION, - CaptureButton::TYPE_UNDO, - CaptureButton::TYPE_REDO, - CaptureButton::TYPE_COPY, - CaptureButton::TYPE_SAVE, - CaptureButton::TYPE_EXIT, - CaptureButton::TYPE_IMAGEUPLOADER, - CaptureButton::TYPE_OPEN_APP, + CaptureButton::TYPE_PENCIL, CaptureButton::TYPE_DRAWER, + CaptureButton::TYPE_ARROW, CaptureButton::TYPE_SELECTION, + CaptureButton::TYPE_RECTANGLE, CaptureButton::TYPE_CIRCLE, + CaptureButton::TYPE_MARKER, CaptureButton::TYPE_TEXT, + CaptureButton::TYPE_BLUR, CaptureButton::TYPE_SELECTIONINDICATOR, + CaptureButton::TYPE_MOVESELECTION, CaptureButton::TYPE_UNDO, + CaptureButton::TYPE_REDO, CaptureButton::TYPE_COPY, + CaptureButton::TYPE_SAVE, CaptureButton::TYPE_EXIT, + CaptureButton::TYPE_IMAGEUPLOADER, CaptureButton::TYPE_OPEN_APP, CaptureButton::TYPE_PIN, }; diff --git a/src/widgets/capture/capturebutton.h b/src/widgets/capture/capturebutton.h index 4ca4b880..744ecd19 100644 --- a/src/widgets/capture/capturebutton.h +++ b/src/widgets/capture/capturebutton.h @@ -17,21 +17,23 @@ #pragma once -#include #include +#include #include class QWidget; class QPropertyAnimation; class CaptureTool; -class CaptureButton : public QPushButton { +class CaptureButton : public QPushButton +{ Q_OBJECT public: // Don't forget to add the new types to CaptureButton::iterableButtonTypes // in the .cpp and the order value in the private array buttonTypeOrder - enum ButtonType { + enum ButtonType + { TYPE_PENCIL = 0, TYPE_DRAWER = 1, TYPE_ARROW = 2, @@ -60,7 +62,7 @@ public: #endif CaptureButton() = delete; - explicit CaptureButton(const ButtonType, QWidget *parent = nullptr); + explicit CaptureButton(const ButtonType, QWidget* parent = nullptr); static QString globalStyleSheet(); static QVector getIterableButtonTypes(); @@ -72,23 +74,23 @@ public: QString styleSheet() const; CaptureTool* tool() const; - void setColor(const QColor &c); + void setColor(const QColor& c); void animatedShow(); protected: - virtual void mousePressEvent(QMouseEvent *); + virtual void mousePressEvent(QMouseEvent*); static QVector iterableButtonTypes; - CaptureTool *m_tool; + CaptureTool* m_tool; signals: - void pressedButton(CaptureButton *); + void pressedButton(CaptureButton*); private: - CaptureButton(QWidget *parent = nullptr); + CaptureButton(QWidget* parent = nullptr); ButtonType m_buttonType; - QPropertyAnimation *m_emergeAnimation; + QPropertyAnimation* m_emergeAnimation; static QColor m_mainColor; diff --git a/src/widgets/capture/capturewidget.h b/src/widgets/capture/capturewidget.h index d0d52261..ddeb68cd 100644 --- a/src/widgets/capture/capturewidget.h +++ b/src/widgets/capture/capturewidget.h @@ -15,24 +15,26 @@ // You should have received a copy of the GNU General Public License // along with Flameshot. If not, see . -// Based on Lightscreen areadialog.h, Copyright 2017 Christian Kaiser -// released under the GNU GPL2 +// Based on Lightscreen areadialog.h, Copyright 2017 Christian Kaiser +// released under the GNU GPL2 +// -// Based on KDE's KSnapshot regiongrabber.cpp, revision 796531, Copyright 2007 Luca Gugelmann -// released under the GNU LGPL +// Based on KDE's KSnapshot regiongrabber.cpp, revision 796531, Copyright 2007 +// Luca Gugelmann released under the GNU LGPL +// #pragma once +#include "buttonhandler.h" #include "capturebutton.h" #include "src/tools/capturecontext.h" #include "src/tools/capturetool.h" #include "src/utils/confighandler.h" #include "src/widgets/capture/selectionwidget.h" #include "src/widgets/panel/utilitypanel.h" -#include "buttonhandler.h" -#include -#include #include +#include +#include class QPaintEvent; class QResizeEvent; @@ -45,18 +47,17 @@ class Screenshot; class NotifierBox; class HoverEventFilter; -class CaptureWidget : public QWidget { +class CaptureWidget : public QWidget +{ Q_OBJECT public: - explicit CaptureWidget(const uint id = 0, - const QString &savePath = QString(), + const QString& savePath = QString(), bool fullScreen = true, - QWidget *parent = nullptr); + QWidget* parent = nullptr); ~CaptureWidget(); - void updateButtons(); QPixmap pixmap(); @@ -66,7 +67,7 @@ public slots: signals: void captureTaken(uint id, QPixmap p); void captureFailed(uint id); - void colorChanged(const QColor &c); + void colorChanged(const QColor& c); void thicknessChanged(const int thickness); private slots: @@ -91,22 +92,22 @@ private slots: void upMove(); void downMove(); - void setState(CaptureButton *b); - void processTool(CaptureTool *t); + void setState(CaptureButton* b); + void processTool(CaptureTool* t); void handleButtonSignal(CaptureTool::Request r); - void setDrawColor(const QColor &c); - void setDrawThickness(const int &t); + void setDrawColor(const QColor& c); + void setDrawThickness(const int& t); protected: - void paintEvent(QPaintEvent *); - void mousePressEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); - void keyPressEvent(QKeyEvent *); - void keyReleaseEvent(QKeyEvent *); - void wheelEvent(QWheelEvent *); - void resizeEvent(QResizeEvent *); - void moveEvent(QMoveEvent *); + void paintEvent(QPaintEvent*); + void mousePressEvent(QMouseEvent*); + void mouseMoveEvent(QMouseEvent*); + void mouseReleaseEvent(QMouseEvent*); + void keyPressEvent(QKeyEvent*); + void keyReleaseEvent(QKeyEvent*); + void wheelEvent(QWheelEvent*); + void resizeEvent(QResizeEvent*); + void moveEvent(QMoveEvent*); // Context information CaptureContext m_context; @@ -129,18 +130,18 @@ protected: bool m_adjustmentButtonPressed; private: - void initContext(const QString &savePath, bool fullscreen); + void initContext(const QString& savePath, bool fullscreen); void initPanel(); void initSelection(); void initShortcuts(); void updateSizeIndicator(); void updateCursor(); void pushToolToStack(); - void makeChild(QWidget *w); + void makeChild(QWidget* w); private: QRect extendedSelection() const; - QRect extendedRect(QRect *r) const; + QRect extendedRect(QRect* r) const; private: QUndoStack m_undoStack; @@ -150,13 +151,13 @@ private: QPointer m_activeTool; QPointer m_toolWidget; - ButtonHandler *m_buttonHandler; - UtilityPanel *m_panel; - ColorPicker *m_colorPicker; + ButtonHandler* m_buttonHandler; + UtilityPanel* m_panel; + ColorPicker* m_colorPicker; ConfigHandler m_config; - NotifierBox *m_notifierBox; - HoverEventFilter *m_eventFilter; - SelectionWidget *m_selection; + NotifierBox* m_notifierBox; + HoverEventFilter* m_eventFilter; + SelectionWidget* m_selection; QPoint m_dragStartPoint; SelectionWidget::SideType m_mouseOverHandle; diff --git a/src/widgets/capture/colorpicker.cpp b/src/widgets/capture/colorpicker.cpp index 2c247392..371034cc 100644 --- a/src/widgets/capture/colorpicker.cpp +++ b/src/widgets/capture/colorpicker.cpp @@ -18,10 +18,12 @@ #include "colorpicker.h" #include "src/utils/confighandler.h" #include "src/utils/globalvalues.h" -#include #include +#include -ColorPicker::ColorPicker(QWidget *parent) : QWidget(parent) { +ColorPicker::ColorPicker(QWidget* parent) + : QWidget(parent) +{ ConfigHandler config; m_colorList = config.getUserColors(); m_colorAreaSize = GlobalValues::buttonBaseSize() * 0.6; @@ -39,32 +41,37 @@ ColorPicker::ColorPicker(QWidget *parent) : QWidget(parent) { double degreeAcum = degree; // this line is the radius of the circle which will be rotated to add // the color components. - QLineF baseLine = QLineF(QPoint(radius + extraSize / 2, radius+extraSize / 2), - QPoint(radius * 2, radius)); + QLineF baseLine = + QLineF(QPoint(radius + extraSize / 2, radius + extraSize / 2), + QPoint(radius * 2, radius)); for (int i = 0; i < m_colorList.size(); ++i) { - m_colorAreaList.append(QRect(baseLine.x2(), baseLine.y2(), - m_colorAreaSize, m_colorAreaSize)); + m_colorAreaList.append(QRect( + baseLine.x2(), baseLine.y2(), m_colorAreaSize, m_colorAreaSize)); baseLine.setAngle(degreeAcum); degreeAcum += degree; } } -QColor ColorPicker::drawColor() { +QColor ColorPicker::drawColor() +{ return m_drawColor; } -void ColorPicker::show() { +void ColorPicker::show() +{ grabMouse(); QWidget::show(); } -void ColorPicker::hide() { +void ColorPicker::hide() +{ releaseMouse(); QWidget::hide(); } -void ColorPicker::paintEvent(QPaintEvent *) { +void ColorPicker::paintEvent(QPaintEvent*) +{ QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); @@ -91,15 +98,15 @@ void ColorPicker::paintEvent(QPaintEvent *) { // draw preset color painter.setBrush(QColor(m_colorList.at(i))); painter.drawRoundRect(rects.at(i), 100, 100); - } - else { + } else { // draw rainbow (part) for custom color QRect lastRect = rects.at(i); int nStep = 1; int nSteps = lastRect.height() / nStep; - // 0.02 - start rainbow color, 0.33 - end rainbow color from range: 0.0 - 1.0 + // 0.02 - start rainbow color, 0.33 - end rainbow color from range: + // 0.0 - 1.0 float h = 0.02; - for (int radius = nSteps; radius > 0; radius -= nStep*2) { + for (int radius = nSteps; radius > 0; radius -= nStep * 2) { // calculate color float fHStep = (0.33 - h) / (nSteps / nStep / 2); QColor color = QColor::fromHslF(h, 0.95, 0.5); @@ -120,7 +127,8 @@ void ColorPicker::paintEvent(QPaintEvent *) { } } -void ColorPicker::mouseMoveEvent(QMouseEvent *e) { +void ColorPicker::mouseMoveEvent(QMouseEvent* e) +{ for (int i = 0; i < m_colorList.size(); ++i) { if (m_colorAreaList.at(i).contains(e->pos())) { m_drawColor = m_colorList.at(i); @@ -131,9 +139,10 @@ void ColorPicker::mouseMoveEvent(QMouseEvent *e) { } } -QVector ColorPicker::handleMask() const { +QVector ColorPicker::handleMask() const +{ QVector areas; - for (const QRect &rect: m_colorAreaList) { + for (const QRect& rect : m_colorAreaList) { areas.append(rect); } return areas; diff --git a/src/widgets/capture/colorpicker.h b/src/widgets/capture/colorpicker.h index 47f6d17b..ae16987c 100644 --- a/src/widgets/capture/colorpicker.h +++ b/src/widgets/capture/colorpicker.h @@ -19,10 +19,11 @@ #include -class ColorPicker : public QWidget { +class ColorPicker : public QWidget +{ Q_OBJECT public: - explicit ColorPicker(QWidget *parent = nullptr); + explicit ColorPicker(QWidget* parent = nullptr); QColor drawColor(); @@ -33,8 +34,8 @@ signals: void colorSelected(QColor c); protected: - void paintEvent(QPaintEvent *); - void mouseMoveEvent(QMouseEvent *); + void paintEvent(QPaintEvent*); + void mouseMoveEvent(QMouseEvent*); QVector handleMask() const; diff --git a/src/widgets/capture/hovereventfilter.cpp b/src/widgets/capture/hovereventfilter.cpp index 687711ad..48b995f5 100644 --- a/src/widgets/capture/hovereventfilter.cpp +++ b/src/widgets/capture/hovereventfilter.cpp @@ -15,30 +15,33 @@ // You should have received a copy of the GNU General Public License // along with Flameshot. If not, see . -// Based on Lightscreen areadialog.h, Copyright 2017 Christian Kaiser -// released under the GNU GPL2 +// Based on Lightscreen areadialog.h, Copyright 2017 Christian Kaiser +// released under the GNU GPL2 +// -// Based on KDE's KSnapshot regiongrabber.cpp, revision 796531, Copyright 2007 Luca Gugelmann -// released under the GNU LGPL +// Based on KDE's KSnapshot regiongrabber.cpp, revision 796531, Copyright 2007 +// Luca Gugelmann released under the GNU LGPL +// #include "hovereventfilter.h" #include -HoverEventFilter::HoverEventFilter(QObject *parent) : QObject(parent) { +HoverEventFilter::HoverEventFilter(QObject* parent) + : QObject(parent) +{} -} - -bool HoverEventFilter::eventFilter(QObject *watched, QEvent *event) { +bool HoverEventFilter::eventFilter(QObject* watched, QEvent* event) +{ QEvent::Type t = event->type(); switch (t) { - case QEvent::Enter: - emit hoverIn(watched); - break; - case QEvent::Leave: - emit hoverOut(watched); - break; - default: - break; + case QEvent::Enter: + emit hoverIn(watched); + break; + case QEvent::Leave: + emit hoverOut(watched); + break; + default: + break; } return false; } diff --git a/src/widgets/capture/hovereventfilter.h b/src/widgets/capture/hovereventfilter.h index 7a26f56d..f71bc109 100644 --- a/src/widgets/capture/hovereventfilter.h +++ b/src/widgets/capture/hovereventfilter.h @@ -15,11 +15,13 @@ // You should have received a copy of the GNU General Public License // along with Flameshot. If not, see . -// Based on Lightscreen areadialog.h, Copyright 2017 Christian Kaiser -// released under the GNU GPL2 +// Based on Lightscreen areadialog.h, Copyright 2017 Christian Kaiser +// released under the GNU GPL2 +// -// Based on KDE's KSnapshot regiongrabber.cpp, revision 796531, Copyright 2007 Luca Gugelmann -// released under the GNU LGPL +// Based on KDE's KSnapshot regiongrabber.cpp, revision 796531, Copyright 2007 +// Luca Gugelmann released under the GNU LGPL +// #pragma once @@ -29,12 +31,12 @@ class HoverEventFilter : public QObject { Q_OBJECT public: - explicit HoverEventFilter(QObject *parent = nullptr); + explicit HoverEventFilter(QObject* parent = nullptr); signals: - void hoverIn(QObject *); - void hoverOut(QObject *); + void hoverIn(QObject*); + void hoverOut(QObject*); protected: - bool eventFilter(QObject *watched, QEvent *event); + bool eventFilter(QObject* watched, QEvent* event); }; diff --git a/src/widgets/capture/modificationcommand.cpp b/src/widgets/capture/modificationcommand.cpp index 737b3b77..63adb2b2 100644 --- a/src/widgets/capture/modificationcommand.cpp +++ b/src/widgets/capture/modificationcommand.cpp @@ -18,17 +18,20 @@ #include "modificationcommand.h" #include -ModificationCommand::ModificationCommand(QPixmap *p, CaptureTool *t) : - m_pixmap(p), m_tool(t) +ModificationCommand::ModificationCommand(QPixmap* p, CaptureTool* t) + : m_pixmap(p) + , m_tool(t) { setText(t->name()); } -void ModificationCommand::undo() { +void ModificationCommand::undo() +{ m_tool->undo(*m_pixmap); } -void ModificationCommand::redo() { +void ModificationCommand::redo() +{ QPainter p(m_pixmap); p.setRenderHint(QPainter::Antialiasing); m_tool->process(p, *m_pixmap, true); diff --git a/src/widgets/capture/modificationcommand.h b/src/widgets/capture/modificationcommand.h index 4465fec1..8c71af90 100644 --- a/src/widgets/capture/modificationcommand.h +++ b/src/widgets/capture/modificationcommand.h @@ -17,17 +17,18 @@ #pragma once -#include #include "src/tools/capturetool.h" +#include -class ModificationCommand : public QUndoCommand { +class ModificationCommand : public QUndoCommand +{ public: - ModificationCommand(QPixmap *, CaptureTool *); + ModificationCommand(QPixmap*, CaptureTool*); virtual void undo() override; virtual void redo() override; private: - QPixmap *m_pixmap; + QPixmap* m_pixmap; QScopedPointer m_tool; }; diff --git a/src/widgets/capture/notifierbox.cpp b/src/widgets/capture/notifierbox.cpp index 93774029..906ef7ff 100644 --- a/src/widgets/capture/notifierbox.cpp +++ b/src/widgets/capture/notifierbox.cpp @@ -16,33 +16,37 @@ // along with Flameshot. If not, see . #include "notifierbox.h" -#include "src/utils/confighandler.h" #include "src/utils/colorutils.h" +#include "src/utils/confighandler.h" #include "src/utils/globalvalues.h" -#include -#include #include +#include +#include -NotifierBox::NotifierBox(QWidget *parent) : QWidget(parent) { +NotifierBox::NotifierBox(QWidget* parent) + : QWidget(parent) +{ m_timer = new QTimer(this); m_timer->setSingleShot(true); m_timer->setInterval(1200); connect(m_timer, &QTimer::timeout, this, &NotifierBox::hide); m_bgColor = ConfigHandler().uiMainColorValue(); - m_foregroundColor = (ColorUtils::colorIsDark(m_bgColor) ? - Qt::white : Qt::black); + m_foregroundColor = + (ColorUtils::colorIsDark(m_bgColor) ? Qt::white : Qt::black); m_bgColor.setAlpha(180); - const int size = (GlobalValues::buttonBaseSize() + - GlobalValues::buttonBaseSize()/2) * - qApp->devicePixelRatio(); + const int size = + (GlobalValues::buttonBaseSize() + GlobalValues::buttonBaseSize() / 2) * + qApp->devicePixelRatio(); setFixedSize(QSize(size, size)); } -void NotifierBox::enterEvent(QEvent *) { +void NotifierBox::enterEvent(QEvent*) +{ hide(); } -void NotifierBox::paintEvent(QPaintEvent *) { +void NotifierBox::paintEvent(QPaintEvent*) +{ QPainter painter(this); // draw Elipse painter.setRenderHint(QPainter::Antialiasing); @@ -54,14 +58,16 @@ void NotifierBox::paintEvent(QPaintEvent *) { painter.drawText(rect(), Qt::AlignCenter, m_message); } -void NotifierBox::showMessage(const QString &msg) { +void NotifierBox::showMessage(const QString& msg) +{ m_message = msg; update(); show(); m_timer->start(); } -void NotifierBox::showColor(const QColor &color) { +void NotifierBox::showColor(const QColor& color) +{ Q_UNUSED(color); m_message = QLatin1String(""); } diff --git a/src/widgets/capture/notifierbox.h b/src/widgets/capture/notifierbox.h index e1ecd939..f1e1a948 100644 --- a/src/widgets/capture/notifierbox.h +++ b/src/widgets/capture/notifierbox.h @@ -21,21 +21,22 @@ class QTimer; -class NotifierBox : public QWidget { +class NotifierBox : public QWidget +{ Q_OBJECT public: - explicit NotifierBox(QWidget *parent = nullptr); + explicit NotifierBox(QWidget* parent = nullptr); protected: - virtual void enterEvent(QEvent *); - virtual void paintEvent(QPaintEvent *); + virtual void enterEvent(QEvent*); + virtual void paintEvent(QPaintEvent*); public slots: - void showMessage(const QString &msg); - void showColor(const QColor &color); + void showMessage(const QString& msg); + void showColor(const QColor& color); private: - QTimer *m_timer; + QTimer* m_timer; QString m_message; QColor m_bgColor; QColor m_foregroundColor; diff --git a/src/widgets/capture/selectionwidget.cpp b/src/widgets/capture/selectionwidget.cpp index 1f8eebe0..a977bb1a 100644 --- a/src/widgets/capture/selectionwidget.cpp +++ b/src/widgets/capture/selectionwidget.cpp @@ -20,29 +20,34 @@ #include #include -SelectionWidget::SelectionWidget(const QColor &c, QWidget *parent) : - QWidget(parent), m_color(c) +SelectionWidget::SelectionWidget(const QColor& c, QWidget* parent) + : QWidget(parent) + , m_color(c) { m_animation = new QPropertyAnimation(this, "geometry", this); m_animation->setEasingCurve(QEasingCurve::InOutQuad); m_animation->setDuration(200); - connect(m_animation, &QPropertyAnimation::finished, - this, &SelectionWidget::animationEnded); + connect(m_animation, + &QPropertyAnimation::finished, + this, + &SelectionWidget::animationEnded); setAttribute(Qt::WA_TransparentForMouseEvents); int sideVal = GlobalValues::buttonBaseSize() * 0.6; int handleSide = sideVal / 2; const QRect areaRect(0, 0, sideVal, sideVal); const QRect handleRect(0, 0, handleSide, handleSide); - m_TLHandle = m_TRHandle = m_BLHandle = m_BRHandle = - m_LHandle = m_THandle = m_RHandle = m_BHandle= handleRect; + m_TLHandle = m_TRHandle = m_BLHandle = m_BRHandle = m_LHandle = m_THandle = + m_RHandle = m_BHandle = handleRect; m_TLArea = m_TRArea = m_BLArea = m_BRArea = areaRect; - m_areaOffset = QPoint(-sideVal/2, -sideVal/2); - m_handleOffset = QPoint(-handleSide/2, -handleSide/2); + m_areaOffset = QPoint(-sideVal / 2, -sideVal / 2); + m_handleOffset = QPoint(-handleSide / 2, -handleSide / 2); } -SelectionWidget::SideType SelectionWidget::getMouseSide(const QPoint &point) const { +SelectionWidget::SideType SelectionWidget::getMouseSide( + const QPoint& point) const +{ if (m_TLArea.contains(point)) { return TOPLEFT_SIDE; } else if (m_TRArea.contains(point)) { @@ -58,20 +63,22 @@ SelectionWidget::SideType SelectionWidget::getMouseSide(const QPoint &point) con } else if (m_RArea.contains(point)) { return RIGHT_SIDE; } else if (m_BArea.contains(point)) { - return BOTTON_SIDE; + return BOTTON_SIDE; } else { return NO_SIDE; } } -QVector SelectionWidget::handlerAreas() { +QVector SelectionWidget::handlerAreas() +{ QVector areas; - areas << m_TLHandle << m_TRHandle << m_BLHandle << m_BRHandle - <setStartValue(geometry()); m_animation->setEndValue(r); @@ -79,33 +86,40 @@ void SelectionWidget::setGeometryAnimated(const QRect &r) { } } -void SelectionWidget::saveGeometry() { +void SelectionWidget::saveGeometry() +{ m_geometryBackup = geometry(); } -QRect SelectionWidget::savedGeometry() { +QRect SelectionWidget::savedGeometry() +{ return m_geometryBackup; } -void SelectionWidget::paintEvent(QPaintEvent *) { +void SelectionWidget::paintEvent(QPaintEvent*) +{ QPainter p(this); p.setPen(m_color); p.drawRect(rect() + QMargins(0, 0, -1, -1)); } -void SelectionWidget::resizeEvent(QResizeEvent *) { +void SelectionWidget::resizeEvent(QResizeEvent*) +{ updateAreas(); } -void SelectionWidget::moveEvent(QMoveEvent *) { +void SelectionWidget::moveEvent(QMoveEvent*) +{ updateAreas(); } -void SelectionWidget::updateColor(const QColor &c) { +void SelectionWidget::updateColor(const QColor& c) +{ m_color = c; } -void SelectionWidget::updateAreas() { +void SelectionWidget::updateAreas() +{ QRect r = rect(); m_TLArea.moveTo(m_areaOffset + pos()); m_TRArea.moveTo(r.topRight() + m_areaOffset + pos()); diff --git a/src/widgets/capture/selectionwidget.h b/src/widgets/capture/selectionwidget.h index 78e3c7e8..5c95027e 100644 --- a/src/widgets/capture/selectionwidget.h +++ b/src/widgets/capture/selectionwidget.h @@ -25,7 +25,8 @@ class SelectionWidget : public QWidget { Q_OBJECT public: - enum SideType { + enum SideType + { TOPLEFT_SIDE, BOTTONLEFT_SIDE, TOPRIGHT_SIDE, @@ -37,30 +38,30 @@ public: NO_SIDE, }; - explicit SelectionWidget(const QColor &c, QWidget *parent = nullptr); + explicit SelectionWidget(const QColor& c, QWidget* parent = nullptr); - SideType getMouseSide(const QPoint &point) const; + SideType getMouseSide(const QPoint& point) const; QVector handlerAreas(); - void setGeometryAnimated(const QRect &r); + void setGeometryAnimated(const QRect& r); void saveGeometry(); QRect savedGeometry(); protected: - void paintEvent(QPaintEvent *); - void resizeEvent(QResizeEvent *); - void moveEvent(QMoveEvent *); + void paintEvent(QPaintEvent*); + void resizeEvent(QResizeEvent*); + void moveEvent(QMoveEvent*); signals: void animationEnded(); public slots: - void updateColor(const QColor &c); + void updateColor(const QColor& c); private: void updateAreas(); - QPropertyAnimation *m_animation; + QPropertyAnimation* m_animation; QColor m_color; QPoint m_areaOffset; diff --git a/src/widgets/capturelauncher.cpp b/src/widgets/capturelauncher.cpp index 268984a6..f89332f2 100644 --- a/src/widgets/capturelauncher.cpp +++ b/src/widgets/capturelauncher.cpp @@ -17,43 +17,49 @@ #include "capturelauncher.h" #include "src/core/controller.h" +#include "src/utils/screengrabber.h" #include "src/widgets/imagelabel.h" #include "src/widgets/notificationwidget.h" -#include "src/utils/screengrabber.h" #include -#include -#include -#include -#include -#include #include -#include #include #include +#include +#include +#include +#include +#include +#include // https://github.com/KDE/spectacle/blob/941c1a517be82bed25d1254ebd735c29b0d2951c/src/Gui/KSWidget.cpp // https://github.com/KDE/spectacle/blob/941c1a517be82bed25d1254ebd735c29b0d2951c/src/Gui/KSMainWindow.cpp -CaptureLauncher::CaptureLauncher(QWidget *parent) : - QWidget(parent), m_id(0) +CaptureLauncher::CaptureLauncher(QWidget* parent) + : QWidget(parent) + , m_id(0) { setAttribute(Qt::WA_DeleteOnClose); - connect(Controller::getInstance(), &Controller::captureTaken, - this, &CaptureLauncher::captureTaken); - connect(Controller::getInstance(), &Controller::captureFailed, - this, &CaptureLauncher::captureFailed); + connect(Controller::getInstance(), + &Controller::captureTaken, + this, + &CaptureLauncher::captureTaken); + connect(Controller::getInstance(), + &Controller::captureFailed, + this, + &CaptureLauncher::captureFailed); m_imageLabel = new ImageLabel(this); bool ok; m_imageLabel->setScreenshot(ScreenGrabber().grabEntireDesktop(ok)); if (!ok) { - } m_imageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - connect(m_imageLabel, &ImageLabel::dragInitiated, - this, &CaptureLauncher::startDrag); + connect(m_imageLabel, + &ImageLabel::dragInitiated, + this, + &CaptureLauncher::startDrag); - QGridLayout *layout = new QGridLayout(this); + QGridLayout* layout = new QGridLayout(this); layout->addWidget(m_imageLabel, 0, 0); m_CaptureModeLabel = new QLabel(tr("Capture Mode")); @@ -61,9 +67,12 @@ CaptureLauncher::CaptureLauncher(QWidget *parent) : m_captureType = new QComboBox(); m_captureType->setMinimumWidth(240); // TODO remember number - m_captureType->insertItem(1, tr("Rectangular Region"), CaptureRequest::GRAPHICAL_MODE); - m_captureType->insertItem(2, tr("Full Screen (All Monitors)"), CaptureRequest::FULLSCREEN_MODE); - //m_captureType->insertItem(3, tr("Single Screen"), CaptureRequest::SCREEN_MODE); + m_captureType->insertItem( + 1, tr("Rectangular Region"), CaptureRequest::GRAPHICAL_MODE); + m_captureType->insertItem( + 2, tr("Full Screen (All Monitors)"), CaptureRequest::FULLSCREEN_MODE); + // m_captureType->insertItem(3, tr("Single Screen"), + // CaptureRequest::SCREEN_MODE); m_delaySpinBox = new QSpinBox(); m_delaySpinBox->setSingleStep(1.0); @@ -74,19 +83,21 @@ CaptureLauncher::CaptureLauncher(QWidget *parent) : // with QT 5.7 qOverload(&QSpinBox::valueChanged), connect(m_delaySpinBox, static_cast(&QSpinBox::valueChanged), - this, [this](int val) - { - QString sufix = val == 1 ?tr(" second") : tr(" seconds"); - this->m_delaySpinBox->setSuffix(sufix); - }); + this, + [this](int val) { + QString sufix = val == 1 ? tr(" second") : tr(" seconds"); + this->m_delaySpinBox->setSuffix(sufix); + }); m_launchButton = new QPushButton(tr("Take new screenshot")); m_launchButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - connect(m_launchButton, &QPushButton::pressed, - this, &CaptureLauncher::startCapture); + connect(m_launchButton, + &QPushButton::pressed, + this, + &CaptureLauncher::startCapture); m_launchButton->setFocus(); - QFormLayout *captureModeForm = new QFormLayout; + QFormLayout* captureModeForm = new QFormLayout; captureModeForm->addRow(tr("Area:"), m_captureType); captureModeForm->addRow(tr("Delay:"), m_delaySpinBox); captureModeForm->setContentsMargins(24, 0, 0, 0); @@ -96,37 +107,39 @@ CaptureLauncher::CaptureLauncher(QWidget *parent) : m_mainLayout->addWidget(m_CaptureModeLabel); m_mainLayout->addLayout(captureModeForm); m_mainLayout->addStretch(10); - m_mainLayout->addWidget(m_launchButton, 1 , Qt::AlignCenter); + m_mainLayout->addWidget(m_launchButton, 1, Qt::AlignCenter); m_mainLayout->setContentsMargins(10, 0, 0, 10); - layout->addLayout(m_mainLayout, 0 ,1); + layout->addLayout(m_mainLayout, 0, 1); layout->setColumnMinimumWidth(0, 320); layout->setColumnMinimumWidth(1, 320); - } -// HACK: https://github.com/KDE/spectacle/blob/fa1e780b8bf3df3ac36c410b9ece4ace041f401b/src/Gui/KSMainWindow.cpp#L70 -void CaptureLauncher::startCapture() { +// HACK: +// https://github.com/KDE/spectacle/blob/fa1e780b8bf3df3ac36c410b9ece4ace041f401b/src/Gui/KSMainWindow.cpp#L70 +void CaptureLauncher::startCapture() +{ hide(); auto mode = static_cast( - m_captureType->currentData().toInt()); + m_captureType->currentData().toInt()); CaptureRequest req(mode, 600 + m_delaySpinBox->value() * 1000); m_id = req.id(); Controller::getInstance()->requestCapture(req); } -void CaptureLauncher::startDrag() { - QDrag *dragHandler = new QDrag(this); - QMimeData *mimeData = new QMimeData; +void CaptureLauncher::startDrag() +{ + QDrag* dragHandler = new QDrag(this); + QMimeData* mimeData = new QMimeData; mimeData->setImageData(m_imageLabel->pixmap()); dragHandler->setMimeData(mimeData); - dragHandler->setPixmap(m_imageLabel->pixmap() - ->scaled(256, 256, Qt::KeepAspectRatioByExpanding, - Qt::SmoothTransformation)); + dragHandler->setPixmap(m_imageLabel->pixmap()->scaled( + 256, 256, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation)); dragHandler->exec(); } -void CaptureLauncher::captureTaken(uint id, QPixmap p) { +void CaptureLauncher::captureTaken(uint id, QPixmap p) +{ if (id == m_id) { m_id = 0; m_imageLabel->setScreenshot(p); @@ -134,7 +147,8 @@ void CaptureLauncher::captureTaken(uint id, QPixmap p) { } } -void CaptureLauncher::captureFailed(uint id) { +void CaptureLauncher::captureFailed(uint id) +{ if (id == m_id) { m_id = 0; show(); diff --git a/src/widgets/capturelauncher.h b/src/widgets/capturelauncher.h index 88c7cb0b..b92fdbd7 100644 --- a/src/widgets/capturelauncher.h +++ b/src/widgets/capturelauncher.h @@ -31,7 +31,7 @@ class CaptureLauncher : public QWidget { Q_OBJECT public: - explicit CaptureLauncher(QWidget *parent = nullptr); + explicit CaptureLauncher(QWidget* parent = nullptr); private slots: void startCapture(); @@ -40,12 +40,11 @@ private slots: void captureFailed(uint id); private: - - QSpinBox *m_delaySpinBox; - QComboBox *m_captureType; - QVBoxLayout *m_mainLayout; - QPushButton *m_launchButton; - QLabel *m_CaptureModeLabel; - ImageLabel *m_imageLabel; + QSpinBox* m_delaySpinBox; + QComboBox* m_captureType; + QVBoxLayout* m_mainLayout; + QPushButton* m_launchButton; + QLabel* m_CaptureModeLabel; + ImageLabel* m_imageLabel; uint m_id; }; diff --git a/src/widgets/historywidget.cpp b/src/widgets/historywidget.cpp index 85048111..93afc738 100644 --- a/src/widgets/historywidget.cpp +++ b/src/widgets/historywidget.cpp @@ -1,7 +1,7 @@ #include "historywidget.h" -#include "src/tools/storage/storagemanager.h" #include "src/tools/storage/imguploader.h" #include "src/tools/storage/s3/imgs3uploader.h" +#include "src/tools/storage/storagemanager.h" #include "src/utils/history.h" #include "src/widgets/notificationwidget.h" #include diff --git a/src/widgets/imagelabel.cpp b/src/widgets/imagelabel.cpp index c64cead4..5115bd26 100644 --- a/src/widgets/imagelabel.cpp +++ b/src/widgets/imagelabel.cpp @@ -20,8 +20,9 @@ #include "imagelabel.h" -ImageLabel::ImageLabel(QWidget *parent): - QLabel(parent), m_pixmap(QPixmap()) +ImageLabel::ImageLabel(QWidget* parent) + : QLabel(parent) + , m_pixmap(QPixmap()) { m_DSEffect = new QGraphicsDropShadowEffect(this); @@ -35,44 +36,48 @@ ImageLabel::ImageLabel(QWidget *parent): setMinimumSize(size()); } -void ImageLabel::setScreenshot(const QPixmap &pixmap) { +void ImageLabel::setScreenshot(const QPixmap& pixmap) +{ m_pixmap = pixmap; - const QString tooltip = QStringLiteral("%1x%2 px").arg(m_pixmap.width()) - .arg(m_pixmap.height()); + const QString tooltip = + QStringLiteral("%1x%2 px").arg(m_pixmap.width()).arg(m_pixmap.height()); setToolTip(tooltip); setScaledPixmap(); } -void ImageLabel::setScaledPixmap() { +void ImageLabel::setScaledPixmap() +{ const qreal scale = qApp->devicePixelRatio(); - QPixmap scaledPixmap = m_pixmap.scaled(size() * scale, Qt::KeepAspectRatio, - Qt::SmoothTransformation); + QPixmap scaledPixmap = m_pixmap.scaled( + size() * scale, Qt::KeepAspectRatio, Qt::SmoothTransformation); scaledPixmap.setDevicePixelRatio(scale); setPixmap(scaledPixmap); } // drag handlers -void ImageLabel::mousePressEvent(QMouseEvent *event) { +void ImageLabel::mousePressEvent(QMouseEvent* event) +{ if (event->button() == Qt::LeftButton) { m_dragStartPosition = event->pos(); setCursor(Qt::ClosedHandCursor); } } -void ImageLabel::mouseReleaseEvent(QMouseEvent *event) { +void ImageLabel::mouseReleaseEvent(QMouseEvent* event) +{ if (event->button() == Qt::LeftButton) { setCursor(Qt::OpenHandCursor); } } -void ImageLabel::mouseMoveEvent(QMouseEvent *event) { +void ImageLabel::mouseMoveEvent(QMouseEvent* event) +{ if (!(event->buttons() & Qt::LeftButton)) { return; } if ((event->pos() - m_dragStartPosition).manhattanLength() < - QGuiApplication::styleHints()->startDragDistance()) - { + QGuiApplication::styleHints()->startDragDistance()) { return; } setCursor(Qt::OpenHandCursor); @@ -80,7 +85,8 @@ void ImageLabel::mouseMoveEvent(QMouseEvent *event) { } // resize handler -void ImageLabel::resizeEvent(QResizeEvent *event) { +void ImageLabel::resizeEvent(QResizeEvent* event) +{ Q_UNUSED(event); setScaledPixmap(); } diff --git a/src/widgets/imagelabel.h b/src/widgets/imagelabel.h index 36983b67..160dea62 100644 --- a/src/widgets/imagelabel.h +++ b/src/widgets/imagelabel.h @@ -20,35 +20,36 @@ #pragma once -#include -#include -#include #include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include -class ImageLabel : public QLabel { +class ImageLabel : public QLabel +{ Q_OBJECT public: - explicit ImageLabel(QWidget *parent = nullptr); - void setScreenshot(const QPixmap &pixmap); + explicit ImageLabel(QWidget* parent = nullptr); + void setScreenshot(const QPixmap& pixmap); signals: void dragInitiated(); protected: - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent* event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent* event) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent* event) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE; private: void setScaledPixmap(); - QGraphicsDropShadowEffect *m_DSEffect; + QGraphicsDropShadowEffect* m_DSEffect; QPixmap m_pixmap; QPoint m_dragStartPosition; }; diff --git a/src/widgets/infowindow.cpp b/src/widgets/infowindow.cpp index 14c75db0..bbf1b820 100644 --- a/src/widgets/infowindow.cpp +++ b/src/widgets/infowindow.cpp @@ -16,30 +16,32 @@ // along with Flameshot. If not, see . #include "infowindow.h" -#include -#include -#include #include -#include +#include #include +#include +#include +#include #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) #include +#include #include #include -#include #endif // InfoWindow show basic information about the usage of Flameshot -InfoWindow::InfoWindow(QWidget *parent) : QWidget(parent) { +InfoWindow::InfoWindow(QWidget* parent) + : QWidget(parent) +{ setAttribute(Qt::WA_DeleteOnClose); setWindowIcon(QIcon(":img/app/flameshot.svg")); setWindowTitle(tr("About")); #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) QRect position = frameGeometry(); - QScreen *screen = QGuiApplication::screenAt(QCursor::pos()); + QScreen* screen = QGuiApplication::screenAt(QCursor::pos()); position.moveCenter(screen->availableGeometry().center()); move(position.topLeft()); #endif @@ -50,34 +52,35 @@ InfoWindow::InfoWindow(QWidget *parent) : QWidget(parent) { show(); } - -void InfoWindow::initLabels() { - QLabel *icon = new QLabel(); +void InfoWindow::initLabels() +{ + QLabel* icon = new QLabel(); icon->setPixmap(QPixmap(":img/app/flameshot.svg")); icon->setAlignment(Qt::AlignHCenter); m_layout->addWidget(icon); - QLabel *licenseTitleLabel = new QLabel(tr("License"), this); + QLabel* licenseTitleLabel = new QLabel(tr("License"), this); licenseTitleLabel->setAlignment(Qt::AlignHCenter); m_layout->addWidget(licenseTitleLabel); - QLabel *licenseLabel = new QLabel(QStringLiteral("GPLv3+"), this); + QLabel* licenseLabel = new QLabel(QStringLiteral("GPLv3+"), this); licenseLabel->setAlignment(Qt::AlignHCenter); m_layout->addWidget(licenseLabel); m_layout->addStretch(); - QLabel *versionTitleLabel = new QLabel(tr("Version"), this); + QLabel* versionTitleLabel = new QLabel(tr("Version"), this); versionTitleLabel->setAlignment(Qt::AlignHCenter); m_layout->addWidget(versionTitleLabel); - QString versionMsg = "Flameshot " + QStringLiteral(APP_VERSION) + "\nCompiled with Qt " - + QT_VERSION_STR; - QLabel *versionLabel = new QLabel(versionMsg, this); + QString versionMsg = "Flameshot " + QStringLiteral(APP_VERSION) + + "\nCompiled with Qt " + QT_VERSION_STR; + QLabel* versionLabel = new QLabel(versionMsg, this); versionLabel->setAlignment(Qt::AlignHCenter); m_layout->addWidget(versionLabel); m_layout->addSpacing(30); } -void InfoWindow::keyPressEvent(QKeyEvent *e) { +void InfoWindow::keyPressEvent(QKeyEvent* e) +{ if (e->key() == Qt::Key_Escape) { close(); } diff --git a/src/widgets/infowindow.h b/src/widgets/infowindow.h index 099f9383..29caa775 100644 --- a/src/widgets/infowindow.h +++ b/src/widgets/infowindow.h @@ -21,15 +21,16 @@ class QVBoxLayout; -class InfoWindow : public QWidget { +class InfoWindow : public QWidget +{ Q_OBJECT public: - explicit InfoWindow(QWidget *parent = nullptr); + explicit InfoWindow(QWidget* parent = nullptr); protected: - void keyPressEvent(QKeyEvent *); + void keyPressEvent(QKeyEvent*); private: void initLabels(); - QVBoxLayout *m_layout; + QVBoxLayout* m_layout; }; diff --git a/src/widgets/loadspinner.cpp b/src/widgets/loadspinner.cpp index 66ba8498..bc181792 100644 --- a/src/widgets/loadspinner.cpp +++ b/src/widgets/loadspinner.cpp @@ -16,81 +16,92 @@ // along with Flameshot. If not, see . #include "loadspinner.h" +#include #include #include #include -#include #define OFFSET 5 -LoadSpinner::LoadSpinner(QWidget *parent) : - QWidget(parent), m_startAngle(0), m_span(0), m_growing(true) +LoadSpinner::LoadSpinner(QWidget* parent) + : QWidget(parent) + , m_startAngle(0) + , m_span(0) + , m_growing(true) { setAttribute(Qt::WA_TranslucentBackground); const int size = QApplication::fontMetrics().height() * 8; setFixedSize(size, size); updateFrame(); // init timer - m_timer = new QTimer(this); + m_timer = new QTimer(this); connect(m_timer, &QTimer::timeout, this, &LoadSpinner::rotate); m_timer->setInterval(30); } -void LoadSpinner::setColor(const QColor &c) { +void LoadSpinner::setColor(const QColor& c) +{ m_color = c; } -void LoadSpinner::setWidth(int w) { +void LoadSpinner::setWidth(int w) +{ setFixedSize(w, w); updateFrame(); } -void LoadSpinner::setHeight(int h) { +void LoadSpinner::setHeight(int h) +{ setFixedSize(h, h); updateFrame(); } -void LoadSpinner::start() { +void LoadSpinner::start() +{ m_timer->start(); } -void LoadSpinner::stop() { +void LoadSpinner::stop() +{ m_timer->stop(); } -void LoadSpinner::paintEvent(QPaintEvent *) { +void LoadSpinner::paintEvent(QPaintEvent*) +{ QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, true); auto pen = QPen(m_color); - pen.setWidth(height()/10); + pen.setWidth(height() / 10); painter.setPen(pen); painter.setOpacity(0.2); - painter.drawArc(m_frame, 0, 5760); + painter.drawArc(m_frame, 0, 5760); painter.setOpacity(1.0); painter.drawArc(m_frame, (m_startAngle * 16), (m_span * 16)); - } -void LoadSpinner::rotate() { +void LoadSpinner::rotate() +{ const int advance = 3; const int grow = 8; if (m_growing) { m_startAngle = (m_startAngle + advance) % 360; m_span += grow; - if(m_span > 260) { + if (m_span > 260) { m_growing = false; } } else { m_startAngle = (m_startAngle + grow) % 360; m_span = m_span + advance - grow; - if(m_span < 10) { + if (m_span < 10) { m_growing = true; } } update(); } -void LoadSpinner::updateFrame() { - m_frame = QRect(OFFSET, OFFSET, width() - OFFSET*2, height() - OFFSET*2); +void LoadSpinner::updateFrame() +{ + m_frame = + QRect(OFFSET, OFFSET, width() - OFFSET * 2, height() - OFFSET * 2); } diff --git a/src/widgets/loadspinner.h b/src/widgets/loadspinner.h index a0fea570..9cb5d1e6 100644 --- a/src/widgets/loadspinner.h +++ b/src/widgets/loadspinner.h @@ -19,31 +19,32 @@ #include -class LoadSpinner : public QWidget { +class LoadSpinner : public QWidget +{ Q_OBJECT public: - explicit LoadSpinner(QWidget *parent = nullptr); + explicit LoadSpinner(QWidget* parent = nullptr); - void setColor(const QColor &c); + void setColor(const QColor& c); void setWidth(int w); void setHeight(int h); void start(); void stop(); protected: - void paintEvent(QPaintEvent *); + void paintEvent(QPaintEvent*); private slots: void rotate(); private: QColor m_color; - QTimer *m_timer; + QTimer* m_timer; int m_startAngle = 0; - int m_span =180; + int m_span = 180; bool m_growing; - QRect m_frame; + QRect m_frame; void updateFrame(); }; diff --git a/src/widgets/notificationwidget.cpp b/src/widgets/notificationwidget.cpp index 35b70f54..c0c1fed5 100644 --- a/src/widgets/notificationwidget.cpp +++ b/src/widgets/notificationwidget.cpp @@ -16,15 +16,16 @@ // along with Flameshot. If not, see . #include "notificationwidget.h" -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include -NotificationWidget::NotificationWidget(QWidget *parent) : QWidget(parent) { +NotificationWidget::NotificationWidget(QWidget* parent) + : QWidget(parent) +{ m_timer = new QTimer(this); m_timer->setSingleShot(true); m_timer->setInterval(7000); @@ -40,7 +41,8 @@ NotificationWidget::NotificationWidget(QWidget *parent) : QWidget(parent) { m_hideAnimation = new QPropertyAnimation(m_content, "geometry", this); m_hideAnimation->setDuration(300); - connect(m_hideAnimation, &QPropertyAnimation::finished, m_label, &QLabel::hide); + connect( + m_hideAnimation, &QPropertyAnimation::finished, m_label, &QLabel::hide); auto mainLayout = new QVBoxLayout(); setLayout(mainLayout); @@ -52,20 +54,23 @@ NotificationWidget::NotificationWidget(QWidget *parent) : QWidget(parent) { setFixedHeight(40); } -void NotificationWidget::showMessage(const QString &msg) { +void NotificationWidget::showMessage(const QString& msg) +{ m_label->setText(msg); m_label->show(); animatedShow(); } -void NotificationWidget::animatedShow() { +void NotificationWidget::animatedShow() +{ m_showAnimation->setStartValue(QRect(0, 0, width(), 0)); m_showAnimation->setEndValue(QRect(0, 0, width(), height())); m_showAnimation->start(); m_timer->start(); } -void NotificationWidget::animatedHide() { +void NotificationWidget::animatedHide() +{ m_hideAnimation->setStartValue(QRect(0, 0, width(), height())); m_hideAnimation->setEndValue(QRect(0, 0, width(), 0)); m_hideAnimation->start(); diff --git a/src/widgets/notificationwidget.h b/src/widgets/notificationwidget.h index 4836e1ea..8b62a17f 100644 --- a/src/widgets/notificationwidget.h +++ b/src/widgets/notificationwidget.h @@ -25,20 +25,21 @@ class QPropertyAnimation; class QVBoxLayout; class QFrame; -class NotificationWidget : public QWidget { +class NotificationWidget : public QWidget +{ Q_OBJECT public: - explicit NotificationWidget(QWidget *parent = nullptr); + explicit NotificationWidget(QWidget* parent = nullptr); - void showMessage(const QString &msg); + void showMessage(const QString& msg); private: - QLabel *m_label; - QPropertyAnimation *m_showAnimation; - QPropertyAnimation *m_hideAnimation; - QVBoxLayout *m_layout; - QFrame *m_content; - QTimer *m_timer; + QLabel* m_label; + QPropertyAnimation* m_showAnimation; + QPropertyAnimation* m_hideAnimation; + QVBoxLayout* m_layout; + QFrame* m_content; + QTimer* m_timer; void animatedShow(); void animatedHide(); diff --git a/src/widgets/panel/sidepanelwidget.cpp b/src/widgets/panel/sidepanelwidget.cpp index 1bb5e8f3..6b4b6ae6 100644 --- a/src/widgets/panel/sidepanelwidget.cpp +++ b/src/widgets/panel/sidepanelwidget.cpp @@ -16,50 +16,55 @@ // along with Flameshot. If not, see . #include "sidepanelwidget.h" -#include "src/utils/pathinfo.h" #include "src/utils/colorutils.h" -#include +#include "src/utils/pathinfo.h" #include -#include -#include #include +#include +#include #include +#include -class QColorPickingEventFilter : public QObject { +class QColorPickingEventFilter : public QObject +{ public: + explicit QColorPickingEventFilter(SidePanelWidget* pw, + QObject* parent = nullptr) + : QObject(parent) + , m_pw(pw) + {} - explicit QColorPickingEventFilter( - SidePanelWidget *pw, QObject *parent = nullptr) : - QObject(parent), m_pw(pw) {} - - bool eventFilter(QObject *, QEvent *event) override { + bool eventFilter(QObject*, QEvent* event) override + { event->accept(); switch (event->type()) { - case QEvent::MouseMove: - return m_pw->handleMouseMove(static_cast(event)); - case QEvent::MouseButtonPress: - return m_pw->handleMouseButtonPressed( - static_cast(event)); - case QEvent::KeyPress: - return m_pw->handleKeyPress(static_cast(event)); - default: - break; + case QEvent::MouseMove: + return m_pw->handleMouseMove(static_cast(event)); + case QEvent::MouseButtonPress: + return m_pw->handleMouseButtonPressed( + static_cast(event)); + case QEvent::KeyPress: + return m_pw->handleKeyPress(static_cast(event)); + default: + break; } return false; } private: - SidePanelWidget *m_pw; + SidePanelWidget* m_pw; }; //////////////////////// -SidePanelWidget::SidePanelWidget(QPixmap *p, QWidget *parent) : - QWidget(parent), m_pixmap(p), m_eventFilter(nullptr) +SidePanelWidget::SidePanelWidget(QPixmap* p, QWidget* parent) + : QWidget(parent) + , m_pixmap(p) + , m_eventFilter(nullptr) { m_layout = new QVBoxLayout(this); - QFormLayout *colorForm = new QFormLayout(); + QFormLayout* colorForm = new QFormLayout(); m_thicknessSlider = new QSlider(Qt::Horizontal); m_thicknessSlider->setValue(m_thickness); m_colorLabel = new QLabel(); @@ -68,48 +73,60 @@ SidePanelWidget::SidePanelWidget(QPixmap *p, QWidget *parent) : colorForm->addRow(tr("Active color:"), m_colorLabel); m_layout->addLayout(colorForm); - connect(m_thicknessSlider, &QSlider::sliderReleased, - this, &SidePanelWidget::updateCurrentThickness); - connect(this, &SidePanelWidget::thicknessChanged, - this, &SidePanelWidget::updateThickness); + connect(m_thicknessSlider, + &QSlider::sliderReleased, + this, + &SidePanelWidget::updateCurrentThickness); + connect(this, + &SidePanelWidget::thicknessChanged, + this, + &SidePanelWidget::updateThickness); QColor background = this->palette().background().color(); bool isDark = ColorUtils::colorIsDark(background); - QString modifier = isDark ? PathInfo::whiteIconPath() : - PathInfo::blackIconPath(); + QString modifier = + isDark ? PathInfo::whiteIconPath() : PathInfo::blackIconPath(); QIcon grabIcon(modifier + "colorize.svg"); m_colorGrabButton = new QPushButton(grabIcon, QLatin1String("")); updateGrabButton(false); - connect(m_colorGrabButton, &QPushButton::pressed, - this, &SidePanelWidget::colorGrabberActivated); + connect(m_colorGrabButton, + &QPushButton::pressed, + this, + &SidePanelWidget::colorGrabberActivated); m_layout->addWidget(m_colorGrabButton); m_colorWheel = new color_widgets::ColorWheel(this); m_colorWheel->setColor(m_color); - connect(m_colorWheel, &color_widgets::ColorWheel::mouseReleaseOnColor, this, + connect(m_colorWheel, + &color_widgets::ColorWheel::mouseReleaseOnColor, + this, &SidePanelWidget::colorChanged); - connect(m_colorWheel, &color_widgets::ColorWheel::colorChanged, this, + connect(m_colorWheel, + &color_widgets::ColorWheel::colorChanged, + this, &SidePanelWidget::updateColorNoWheel); m_layout->addWidget(m_colorWheel); } -void SidePanelWidget::updateColor(const QColor &c) { +void SidePanelWidget::updateColor(const QColor& c) +{ m_color = c; m_colorLabel->setStyleSheet( - QStringLiteral("QLabel { background-color : %1; }").arg(c.name())); + QStringLiteral("QLabel { background-color : %1; }").arg(c.name())); m_colorWheel->setColor(m_color); } -void SidePanelWidget::updateThickness(const int &t) +void SidePanelWidget::updateThickness(const int& t) { m_thickness = qBound(0, t, 100); m_thicknessSlider->setValue(m_thickness); } -void SidePanelWidget::updateColorNoWheel(const QColor &c) { +void SidePanelWidget::updateColorNoWheel(const QColor& c) +{ m_color = c; m_colorLabel->setStyleSheet( - QStringLiteral("QLabel { background-color : %1; }").arg(c.name())); + QStringLiteral("QLabel { background-color : %1; }").arg(c.name())); } void SidePanelWidget::updateCurrentThickness() @@ -117,7 +134,8 @@ void SidePanelWidget::updateCurrentThickness() emit thicknessChanged(m_thicknessSlider->value()); } -void SidePanelWidget::colorGrabberActivated() { +void SidePanelWidget::colorGrabberActivated() +{ grabKeyboard(); grabMouse(Qt::CrossCursor); setMouseTracking(true); @@ -129,7 +147,8 @@ void SidePanelWidget::colorGrabberActivated() { updateGrabButton(true); } -void SidePanelWidget::releaseColorGrab() { +void SidePanelWidget::releaseColorGrab() +{ setMouseTracking(false); removeEventFilter(m_eventFilter); releaseMouse(); @@ -138,16 +157,18 @@ void SidePanelWidget::releaseColorGrab() { updateGrabButton(false); } -QColor SidePanelWidget::grabPixmapColor(const QPoint &p) { +QColor SidePanelWidget::grabPixmapColor(const QPoint& p) +{ QColor c; if (m_pixmap) { QPixmap pixel = m_pixmap->copy(QRect(p, p)); - c = pixel.toImage().pixel(0,0); + c = pixel.toImage().pixel(0, 0); } return c; } -bool SidePanelWidget::handleKeyPress(QKeyEvent *e) { +bool SidePanelWidget::handleKeyPress(QKeyEvent* e) +{ if (e->key() == Qt::Key_Escape) { releaseColorGrab(); updateColor(m_colorBackup); @@ -159,10 +180,10 @@ bool SidePanelWidget::handleKeyPress(QKeyEvent *e) { return true; } -bool SidePanelWidget::handleMouseButtonPressed(QMouseEvent *e) { +bool SidePanelWidget::handleMouseButtonPressed(QMouseEvent* e) +{ if (m_colorGrabButton->geometry().contains(e->pos()) || - e->button() == Qt::RightButton) - { + e->button() == Qt::RightButton) { updateColorNoWheel(m_colorBackup); } else if (e->button() == Qt::LeftButton) { updateColor(grabPixmapColor(QCursor::pos())); @@ -172,12 +193,14 @@ bool SidePanelWidget::handleMouseButtonPressed(QMouseEvent *e) { return true; } -bool SidePanelWidget::handleMouseMove(QMouseEvent *e) { +bool SidePanelWidget::handleMouseMove(QMouseEvent* e) +{ updateColorNoWheel(grabPixmapColor(e->globalPos())); return true; } -void SidePanelWidget::updateGrabButton(const bool activated) { +void SidePanelWidget::updateGrabButton(const bool activated) +{ if (activated) { m_colorGrabButton->setText(tr("Press ESC to cancel")); } else { diff --git a/src/widgets/panel/sidepanelwidget.h b/src/widgets/panel/sidepanelwidget.h index 5757fadd..beaaae29 100644 --- a/src/widgets/panel/sidepanelwidget.h +++ b/src/widgets/panel/sidepanelwidget.h @@ -17,8 +17,8 @@ #pragma once -#include #include "color_wheel.hpp" +#include class QVBoxLayout; class QPushButton; @@ -26,24 +26,26 @@ class QLabel; class QColorPickingEventFilter; class QSlider; -class SidePanelWidget : public QWidget { +class SidePanelWidget : public QWidget +{ Q_OBJECT friend class QColorPickingEventFilter; + public: - explicit SidePanelWidget(QPixmap *p, QWidget *parent = nullptr); + explicit SidePanelWidget(QPixmap* p, QWidget* parent = nullptr); signals: - void colorChanged(const QColor &c); - void thicknessChanged(const int &t); + void colorChanged(const QColor& c); + void thicknessChanged(const int& t); void togglePanel(); public slots: - void updateColor(const QColor &c); - void updateThickness(const int &t); + void updateColor(const QColor& c); + void updateThickness(const int& t); private slots: - void updateColorNoWheel(const QColor &c); + void updateColorNoWheel(const QColor& c); void updateCurrentThickness(); private slots: @@ -51,23 +53,22 @@ private slots: void releaseColorGrab(); private: - QColor grabPixmapColor(const QPoint &p); + QColor grabPixmapColor(const QPoint& p); - bool handleKeyPress(QKeyEvent *e); - bool handleMouseButtonPressed(QMouseEvent *e); - bool handleMouseMove(QMouseEvent *e); + bool handleKeyPress(QKeyEvent* e); + bool handleMouseButtonPressed(QMouseEvent* e); + bool handleMouseMove(QMouseEvent* e); void updateGrabButton(const bool activated); - QVBoxLayout *m_layout; - QPushButton *m_colorGrabButton; - color_widgets::ColorWheel *m_colorWheel; - QLabel *m_colorLabel; - QPixmap *m_pixmap; + QVBoxLayout* m_layout; + QPushButton* m_colorGrabButton; + color_widgets::ColorWheel* m_colorWheel; + QLabel* m_colorLabel; + QPixmap* m_pixmap; QColor m_colorBackup; QColor m_color; - QSlider *m_thicknessSlider; + QSlider* m_thicknessSlider; int m_thickness; - QColorPickingEventFilter *m_eventFilter; - + QColorPickingEventFilter* m_eventFilter; }; diff --git a/src/widgets/panel/utilitypanel.cpp b/src/widgets/panel/utilitypanel.cpp index f3104e35..6f626ac3 100644 --- a/src/widgets/panel/utilitypanel.cpp +++ b/src/widgets/panel/utilitypanel.cpp @@ -17,13 +17,15 @@ #include "utilitypanel.h" #include -#include -#include -#include -#include #include +#include +#include +#include +#include -UtilityPanel::UtilityPanel(QWidget *parent) : QWidget(parent) { +UtilityPanel::UtilityPanel(QWidget* parent) + : QWidget(parent) +{ initInternalPanel(); setAttribute(Qt::WA_TransparentForMouseEvents); setCursor(Qt::ArrowCursor); @@ -36,15 +38,19 @@ UtilityPanel::UtilityPanel(QWidget *parent) : QWidget(parent) { m_hideAnimation->setEasingCurve(QEasingCurve::InOutQuad); m_hideAnimation->setDuration(300); - connect(m_hideAnimation, &QPropertyAnimation::finished, - m_internalPanel, &QWidget::hide); + connect(m_hideAnimation, + &QPropertyAnimation::finished, + m_internalPanel, + &QWidget::hide); } -QWidget *UtilityPanel::toolWidget() const { +QWidget* UtilityPanel::toolWidget() const +{ return m_toolWidget; } -void UtilityPanel::addToolWidget(QWidget *w) { +void UtilityPanel::addToolWidget(QWidget* w) +{ if (m_toolWidget) { m_toolWidget->deleteLater(); } @@ -54,17 +60,20 @@ void UtilityPanel::addToolWidget(QWidget *w) { } } -void UtilityPanel::clearToolWidget() { +void UtilityPanel::clearToolWidget() +{ if (m_toolWidget) { m_toolWidget->deleteLater(); } } -void UtilityPanel::pushWidget(QWidget *w) { +void UtilityPanel::pushWidget(QWidget* w) +{ m_layout->addWidget(w); } -void UtilityPanel::show() { +void UtilityPanel::show() +{ setAttribute(Qt::WA_TransparentForMouseEvents, false); m_showAnimation->setStartValue(QRect(-width(), 0, 0, height())); m_showAnimation->setEndValue(QRect(0, 0, width(), height())); @@ -73,7 +82,8 @@ void UtilityPanel::show() { QWidget::show(); } -void UtilityPanel::hide() { +void UtilityPanel::hide() +{ setAttribute(Qt::WA_TransparentForMouseEvents); m_hideAnimation->setStartValue(QRect(0, 0, width(), height())); m_hideAnimation->setEndValue(QRect(-width(), 0, 0, height())); @@ -82,7 +92,8 @@ void UtilityPanel::hide() { QWidget::hide(); } -void UtilityPanel::toggle() { +void UtilityPanel::toggle() +{ if (m_internalPanel->isHidden()) { show(); } else { @@ -90,10 +101,11 @@ void UtilityPanel::toggle() { } } -void UtilityPanel::initInternalPanel() { +void UtilityPanel::initInternalPanel() +{ m_internalPanel = new QScrollArea(this); m_internalPanel->setAttribute(Qt::WA_NoMousePropagation); - QWidget *widget = new QWidget(); + QWidget* widget = new QWidget(); m_internalPanel->setWidget(widget); m_internalPanel->setWidgetResizable(true); @@ -104,8 +116,8 @@ void UtilityPanel::initInternalPanel() { QColor bgColor = palette().background().color(); bgColor.setAlphaF(0.0); - m_internalPanel->setStyleSheet(QStringLiteral("QScrollArea {background-color: %1}") - .arg(bgColor.name())); + m_internalPanel->setStyleSheet( + QStringLiteral("QScrollArea {background-color: %1}").arg(bgColor.name())); m_internalPanel->hide(); m_hide = new QPushButton(); @@ -114,6 +126,7 @@ void UtilityPanel::initInternalPanel() { connect(m_hide, SIGNAL(clicked()), this, SLOT(slotHidePanel())); } -void UtilityPanel::slotHidePanel() { +void UtilityPanel::slotHidePanel() +{ hide(); } diff --git a/src/widgets/panel/utilitypanel.h b/src/widgets/panel/utilitypanel.h index c852073c..245c3a07 100644 --- a/src/widgets/panel/utilitypanel.h +++ b/src/widgets/panel/utilitypanel.h @@ -17,23 +17,24 @@ #pragma once -#include #include +#include class QVBoxLayout; class QPropertyAnimation; class QScrollArea; class QPushButton; -class UtilityPanel : public QWidget { +class UtilityPanel : public QWidget +{ Q_OBJECT public: - explicit UtilityPanel(QWidget *parent = nullptr); + explicit UtilityPanel(QWidget* parent = nullptr); QWidget* toolWidget() const; - void addToolWidget(QWidget *w); + void addToolWidget(QWidget* w); void clearToolWidget(); - void pushWidget(QWidget *w); + void pushWidget(QWidget* w); void hide(); void show(); @@ -49,10 +50,10 @@ private: void initInternalPanel(); QPointer m_toolWidget; - QScrollArea *m_internalPanel; - QVBoxLayout *m_upLayout; - QVBoxLayout *m_layout; - QPropertyAnimation *m_showAnimation; - QPropertyAnimation *m_hideAnimation; - QPushButton *m_hide; + QScrollArea* m_internalPanel; + QVBoxLayout* m_upLayout; + QVBoxLayout* m_layout; + QPropertyAnimation* m_showAnimation; + QPropertyAnimation* m_hideAnimation; + QPushButton* m_hide; }; diff --git a/translations/Internationalization_ca.ts b/translations/Internationalization_ca.ts index adcebf6b..ab8be7be 100644 --- a/translations/Internationalization_ca.ts +++ b/translations/Internationalization_ca.ts @@ -4,12 +4,12 @@ AppLauncher - + App Launcher Llançador d'aplicacions - + Choose an app to open the capture Trieu una aplicació per obrir la captura @@ -32,18 +32,18 @@ Segueix obert després de la selecció - - + + Error Error - + Unable to launch in terminal. No es pot iniciar a la terminal. - + Unable to write in No es pot escriure a @@ -51,12 +51,12 @@ ArrowTool - + Arrow Fletxa - + Set the Arrow as the paint tool Estableix la fletxa com a eina de dibuix @@ -64,12 +64,12 @@ BlurTool - + Blur Desenfocament - + Set Blur as the paint tool Estableix el desenfocament com a eina de dibuix @@ -77,47 +77,47 @@ CaptureLauncher - + <b>Capture Mode</b> - + Rectangular Region - + Full Screen (All Monitors) - + No Delay - + second - + seconds - + Take new screenshot - + Area: - + Delay: @@ -143,12 +143,12 @@ Press Space to open the side panel. CircleTool - + Circle Cercle - + Set the Circle as the paint tool Estableix el cercle com a eina de dibuix @@ -184,32 +184,32 @@ Press Space to open the side panel. Controller - + &Open Launcher - + &Configuration &Configuració - + &Information &Informació - + &Quit &Ix - + &Latest Uploads - + &Take Screenshot @@ -217,12 +217,12 @@ Press Space to open the side panel. CopyTool - + Copy Copia - + Copy the selection into the clipboard @@ -230,7 +230,7 @@ Press Space to open the side panel. DBusUtils - + Unable to connect via DBus Impossible connectar mitjançant DBus @@ -238,12 +238,12 @@ Press Space to open the side panel. ExitTool - + Exit Ix - + Leave the capture screen Ix de la pantalla de captura @@ -251,47 +251,47 @@ Press Space to open the side panel. FileNameEditor - + Edit the name of your captures: Editeu el nom de les vostres captures: - + Edit: Edita: - + Preview: Previsualització: - + Save Guarda - + Saves the pattern Guarda el patró - + Reset Reinicialitza - + Restores the saved pattern Restaura el patró guardat - + Clear Neteja - + Deletes the name Elimina el patró @@ -299,27 +299,27 @@ Press Space to open the side panel. FilePathConfiguration - + Screenshot path default: - + Use fixed path for screenshots to save - + Browse - + Clear Neteja - + Select default path for Screenshots @@ -573,12 +573,12 @@ Press Space to open the side panel. ImgS3UploaderTool - + Image Uploader Puja la imatge - + Upload the selection to S3 bucket @@ -682,12 +682,12 @@ Press Space to open the side panel. ImgurUploaderTool - + Image Uploader Puja la imatge - + Upload the selection to Imgur Puja la selecció a Imgur @@ -695,7 +695,7 @@ Press Space to open the side panel. InfoWindow - + About Quant a @@ -748,12 +748,12 @@ Press Space to open the side panel. Descripció - + <u><b>License</b></u> <u><b>Llicència</b></u> - + <u><b>Version</b></u> <u><b>Versió</b></u> @@ -769,12 +769,12 @@ Press Space to open the side panel. LineTool - + Line Línia - + Set the Line as the paint tool Estableix la línia com a eina de dibuix @@ -782,12 +782,12 @@ Press Space to open the side panel. MarkerTool - + Marker Marcador - + Set the Marker as the paint tool Estableix el marcador com a eina de dibuix @@ -795,12 +795,12 @@ Press Space to open the side panel. MoveTool - + Move Mou - + Move the selection area Mou la selecció @@ -808,12 +808,12 @@ Press Space to open the side panel. PencilTool - + Pencil Llapis - + Set the Pencil as the paint tool Estableix el llapis com a eina de dibuix @@ -821,12 +821,12 @@ Press Space to open the side panel. PinTool - + Pin Tool - + Pin image on the desktop @@ -834,53 +834,53 @@ Press Space to open the side panel. QObject - + Save Error S'ha produït un error en guardar - - + + Capture saved as Anomena i guarda la captura - - + + Error trying to save as S'ha produït un error en anomenar i guardar - + Save screenshot - + Capture saved and copied to the clipboard as - - - - - + + + + + Unable to connect via DBus No es pot connectar mitjançant DBus - + Error Error - + Unable to write in No es pot escriure a - + Capture saved to clipboard @@ -890,73 +890,73 @@ Press Space to open the side panel. L'URL s'ha copiat al porta-retalls. - + Hi, I'm already running! You can find me in the system tray. - + Hello, I'm here! Click icon in the tray to take a screenshot or click with a right button to see more options. - + Resize selection right 1px - + Resize selection left 1px - + Resize selection up 1px - + Resize selection down 1px - + Toggle side panel - + Move selection left 1px - + Move selection right 1px - + Move selection up 1px - + Move selection down 1px - + Quit capture Ix de la captura - + Screenshot history - + Capture screen @@ -965,12 +965,12 @@ You can find me in the system tray. Mou la selecció 1 px - + Show color picker Mostra el selector de color - + Change the tool's thickness Canvia el gruix de l'eina @@ -978,12 +978,12 @@ You can find me in the system tray. RectangleTool - + Rectangle Rectangle - + Set the Rectangle as the paint tool Estableix el rectangle com a eina de dibuix @@ -991,12 +991,12 @@ You can find me in the system tray. RedoTool - + Redo - + Redo the next modification @@ -1004,12 +1004,12 @@ You can find me in the system tray. SaveTool - + Save Guarda - + Save the capture Guarda la captura @@ -1017,7 +1017,7 @@ You can find me in the system tray. ScreenGrabber - + Unable to capture screen Imposible capturar la pantalla @@ -1025,12 +1025,12 @@ You can find me in the system tray. SelectionTool - + Rectangular Selection Selecció rectangular - + Set Selection as the paint tool Estableix la selecció com a eina de dibuix @@ -1038,17 +1038,17 @@ You can find me in the system tray. SetShortcutDialog - + Set Shortcut - + Enter new shortcut to change - + Press Esc to cancel or Backspace to disable the keyboard shortcut. @@ -1056,22 +1056,22 @@ You can find me in the system tray. ShortcutsWidget - + Hot Keys - + Available shortcuts in the screen capture mode. Dreceres disponibles en el mode de captura de pantalla. - + Description Descripció - + Key Tecla @@ -1079,22 +1079,22 @@ You can find me in the system tray. SidePanelWidget - + Active thickness: - + Active color: - + Press ESC to cancel - + Grab Color @@ -1102,12 +1102,12 @@ You can find me in the system tray. SizeIndicatorTool - + Selection Size Indicator Indicador de mida de selecció - + Show the dimensions of the selection (X Y) Mostra les mides de la selecció (X Y) @@ -1115,107 +1115,107 @@ You can find me in the system tray. StrftimeChooserWidget - + Century (00-99) Segle (00-99) - + Year (00-99) Any (00-99) - + Year (2000) Any (2000) - + Month Name (jan) Nom del mes (jul) - + Month Name (january) Nom del mes (juliol) - + Month (01-12) Mes (01-12) - + Week Day (1-7) Dia de la setmana (1-7) - + Week (01-53) Setmana (01-53) - + Day Name (mon) Nom del dia (dg) - + Day Name (monday) Nom del dia (diumenge) - + Day (01-31) Dia (01-31) - + Day of Month (1-31) Dia del mes (1-31) - + Day (001-366) Dia (001-366) - + Hour (00-23) Hora (00-23) - + Hour (01-12) Hora (01-12) - + Minute (00-59) Minut (00-59) - + Second (00-59) Segon (00-59) - + Full Date (%m/%d/%y) Data (%m/%d/%y) - + Full Date (%Y-%m-%d) Data (%Y-%m-%d) - + Time (%H-%M-%S) - + Time (%H-%M) @@ -1223,7 +1223,7 @@ You can find me in the system tray. SystemNotification - + Flameshot Info @@ -1231,22 +1231,22 @@ You can find me in the system tray. TextConfig - + StrikeOut - + Underline - + Bold - + Italic @@ -1254,12 +1254,12 @@ You can find me in the system tray. TextTool - + Text - + Add text to your capture @@ -1267,37 +1267,37 @@ You can find me in the system tray. UIcolorEditor - + UI Color Editor Editor de color de la interfície - + Change the color moving the selectors and see the changes in the preview buttons. Canvieu el color movent els selectors i observeu els canvis en els botons de previsualització. - + Select a Button to modify it Seleccioneu un botó per a modificar-lo - + Main Color Color principal - + Click on this button to set the edition mode of the main color. Feu clic en aquest botó per a aplicar el mode d'edició per al color principal. - + Contrast Color Color de contrast - + Click on this button to set the edition mode of the contrast color. Feu clic en aquest botó per a aplicar el mode d'edició per al color de contrast. @@ -1305,12 +1305,12 @@ You can find me in the system tray. UndoTool - + Undo Desfés - + Undo the last modification Desfés l'última modificació @@ -1318,7 +1318,7 @@ You can find me in the system tray. UtilityPanel - + Hide @@ -1326,17 +1326,17 @@ You can find me in the system tray. VisualsEditor - + Opacity of area outside selection: Opacitat de la zona fora de la selecció: - + Button Selection Selecció de botó - + Select All Selecciona-ho tot diff --git a/translations/Internationalization_de_DE.ts b/translations/Internationalization_de_DE.ts index 34518205..b0b3c583 100644 --- a/translations/Internationalization_de_DE.ts +++ b/translations/Internationalization_de_DE.ts @@ -4,12 +4,12 @@ AppLauncher - + App Launcher Anwendungs Starter - + Choose an app to open the capture Wähle eine Anwendung um die Auswahl zu öffnen @@ -32,18 +32,18 @@ Nach Auswahl geöffnet lassen - - + + Error Fehler - + Unable to write in Kein Schreibzugriff auf - + Unable to launch in terminal. Kann im Terminal nicht geöffnet werden. @@ -51,12 +51,12 @@ ArrowTool - + Arrow Pfeil - + Set the Arrow as the paint tool Wähle den Pfeil als Werkzeug @@ -64,12 +64,12 @@ BlurTool - + Blur Verwischen - + Set Blur as the paint tool Wähle Verwischen als Werkzeug @@ -77,47 +77,47 @@ CaptureLauncher - + <b>Capture Mode</b> - + Rectangular Region - + Full Screen (All Monitors) - + No Delay - + second - + seconds - + Take new screenshot - + Area: - + Delay: @@ -146,12 +146,12 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. CircleTool - + Circle Kreis - + Set the Circle as the paint tool Wähle den Kreis als Werkzeug @@ -187,32 +187,32 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. Controller - + &Take Screenshot &Bildschirmaufnahme anfertigen - + &Open Launcher - + &Configuration &Einstellungen - + &Information &Informationen - + &Quit &Beenden - + &Latest Uploads @@ -220,12 +220,12 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. CopyTool - + Copy Kopieren - + Copy the selection into the clipboard Auswahl in die Zwischenablage kopieren @@ -233,7 +233,7 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. DBusUtils - + Unable to connect via DBus Kann nicht via DBus verbinden @@ -241,12 +241,12 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. ExitTool - + Exit Beenden - + Leave the capture screen Auswahl beenden @@ -254,47 +254,47 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. FileNameEditor - + Edit the name of your captures: Bearbeite den Namen deiner Aufnahmen: - + Edit: Bearbeite: - + Preview: Vorschau: - + Save Speichern - + Saves the pattern Speichere die Vorlage - + Reset Zurücksetzen - + Restores the saved pattern Setzt die gespeicherte Vorlage zurück - + Clear Löschen - + Deletes the name Löscht den Namen @@ -302,27 +302,27 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. FilePathConfiguration - + Screenshot path default: - + Use fixed path for screenshots to save - + Browse - + Clear Löschen - + Select default path for Screenshots @@ -580,12 +580,12 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. ImgS3UploaderTool - + Image Uploader Bild hochladen - + Upload the selection to S3 bucket @@ -693,12 +693,12 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. ImgurUploaderTool - + Image Uploader Bild hochladen - + Upload the selection to Imgur Auswahl zu Imgur hochladen @@ -706,7 +706,7 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. InfoWindow - + About Über @@ -771,12 +771,12 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. Beschreibung - + <u><b>License</b></u> <u><b>Lizenz</b></u> - + <u><b>Version</b></u> <u><b>Version</b></u> @@ -788,12 +788,12 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. LineTool - + Line Linie - + Set the Line as the paint tool Wähle Linie als Werkzeug @@ -801,12 +801,12 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. MarkerTool - + Marker Markierer - + Set the Marker as the paint tool Wähle den Markierer als Werkzeug @@ -814,12 +814,12 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. MoveTool - + Move Bewege - + Move the selection area Bewege den Auswahlbereich @@ -827,12 +827,12 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. PencilTool - + Pencil Stift - + Set the Pencil as the paint tool Wähle den Stift als Werkzeug @@ -840,12 +840,12 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. PinTool - + Pin Tool Pinnwand Werkzeug - + Pin image on the desktop Pinne Bild auf den Dekstop @@ -853,53 +853,53 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. QObject - + Save Error Speicherfehler - - + + Capture saved as Aufnahme gespeichert als - + Capture saved to clipboard Aufnahme in Zwischenablage gespeichert - - + + Error trying to save as Fehler beim Speichern unter - + Save screenshot - + Capture saved and copied to the clipboard as - - - - - + + + + + Unable to connect via DBus Kann nicht via DBus verbinden - + Error Fehler - + Unable to write in Kein Schreibzugriff auf @@ -909,73 +909,73 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. URL kopiert. - + Hi, I'm already running! You can find me in the system tray. - + Hello, I'm here! Click icon in the tray to take a screenshot or click with a right button to see more options. - + Resize selection right 1px - + Resize selection left 1px - + Resize selection up 1px - + Resize selection down 1px - + Toggle side panel - + Move selection left 1px - + Move selection right 1px - + Move selection up 1px - + Move selection down 1px - + Quit capture Auswahl verlassen - + Screenshot history - + Capture screen @@ -984,12 +984,12 @@ You can find me in the system tray. Verschiebe Auswahl um 1px - + Show color picker Zeige Farbauswahl - + Change the tool's thickness Ändere die Dicke des Werkzeugs @@ -997,12 +997,12 @@ You can find me in the system tray. RectangleTool - + Rectangle Rechteck - + Set the Rectangle as the paint tool Wähle ausgefülltes Rechteck als Werkzeug @@ -1010,12 +1010,12 @@ You can find me in the system tray. RedoTool - + Redo Wiederholen - + Redo the next modification Wiederhole die nächste Veränderung @@ -1023,12 +1023,12 @@ You can find me in the system tray. SaveTool - + Save Speichern - + Save the capture Speichere die Aufnahme @@ -1036,7 +1036,7 @@ You can find me in the system tray. ScreenGrabber - + Unable to capture screen Kann Bereich nicht aufnehmen @@ -1044,12 +1044,12 @@ You can find me in the system tray. SelectionTool - + Rectangular Selection Rechteckige Auswahl - + Set Selection as the paint tool Wähle Rechteck als Werkzeug @@ -1057,17 +1057,17 @@ You can find me in the system tray. SetShortcutDialog - + Set Shortcut - + Enter new shortcut to change - + Press Esc to cancel or Backspace to disable the keyboard shortcut. @@ -1075,22 +1075,22 @@ You can find me in the system tray. ShortcutsWidget - + Hot Keys - + Available shortcuts in the screen capture mode. Verfügbare Tastenkürzel im Aufnahmemodus. - + Description Beschreibung - + Key Taste @@ -1098,22 +1098,22 @@ You can find me in the system tray. SidePanelWidget - + Active thickness: Aktuelle Dicke - + Active color: Aktuelle Farbe: - + Press ESC to cancel Drücke ESC für Abbruch - + Grab Color Wähle Farbe @@ -1121,12 +1121,12 @@ You can find me in the system tray. SizeIndicatorTool - + Selection Size Indicator Auswahlgrößen Indentifikator - + Show the dimensions of the selection (X Y) Zeige die Dimensionen der Auswahl (X Y) @@ -1134,107 +1134,107 @@ You can find me in the system tray. StrftimeChooserWidget - + Century (00-99) Jarhhundert (00-99) - + Year (00-99) Jahr (00-99) - + Year (2000) Jahr (2000) - + Month Name (jan) Monatsname (Jan) - + Month Name (january) Monatsname (Januar) - + Month (01-12) Monat (01-12) - + Week Day (1-7) Wochentag (1-7) - + Week (01-53) Woche (01-53) - + Day Name (mon) Tagesname (Mon) - + Day Name (monday) Tagesname (Montag) - + Day (01-31) Tag (01-31) - + Day of Month (1-31) Tag des Monats (1-31) - + Day (001-366) Tag (001-366) - + Time (%H-%M-%S) Zeit (%H-%M-%S) - + Time (%H-%M) Zeit (%H-%M) - + Hour (00-23) Stunde (00-23) - + Hour (01-12) Stunde (01-12) - + Minute (00-59) Minute (00-59) - + Second (00-59) Sekunde (00-59) - + Full Date (%m/%d/%y) Komplettes Datum (%m/%d/%y) - + Full Date (%Y-%m-%d) Komplettes Datum (%Y-%m-%d) @@ -1242,7 +1242,7 @@ You can find me in the system tray. SystemNotification - + Flameshot Info Flameshot Info @@ -1250,22 +1250,22 @@ You can find me in the system tray. TextConfig - + StrikeOut Durchstreichen - + Underline Unterstrichen - + Bold Fettdruck - + Italic Kursiv @@ -1273,12 +1273,12 @@ You can find me in the system tray. TextTool - + Text Text - + Add text to your capture Füge Text zur Auswahl hinzu @@ -1286,37 +1286,37 @@ You can find me in the system tray. UIcolorEditor - + UI Color Editor UI Farb Editor - + Change the color moving the selectors and see the changes in the preview buttons. Ändere die Farbauswahl und betrachte die Vorschau in den Vorschau-Buttons. - + Select a Button to modify it Wähle einen Button um ihn zu verändern - + Main Color Hauptfarbe - + Click on this button to set the edition mode of the main color. Wähle diesen Button um den Bearbeitungsmodus der Hauptfarbe zu wählen. - + Contrast Color Kontrastfarbe - + Click on this button to set the edition mode of the contrast color. Wähle diesen Button um den Bearbeitungsmodus der Kontrastfarbe zu wählen. @@ -1324,12 +1324,12 @@ You can find me in the system tray. UndoTool - + Undo Verwerfen - + Undo the last modification Letzte Änderung verwerfen @@ -1337,7 +1337,7 @@ You can find me in the system tray. UtilityPanel - + Hide @@ -1345,17 +1345,17 @@ You can find me in the system tray. VisualsEditor - + Opacity of area outside selection: Deckkraft des Bereichs außerhalb der Auswahl: - + Button Selection Button Auswahl - + Select All Alle wählen diff --git a/translations/Internationalization_es.ts b/translations/Internationalization_es.ts index 76d981fa..6f20a2d0 100644 --- a/translations/Internationalization_es.ts +++ b/translations/Internationalization_es.ts @@ -4,12 +4,12 @@ AppLauncher - + App Launcher Lanzador de Aplicaciones - + Choose an app to open the capture Elige una aplicación con la que abrir la captura @@ -32,18 +32,18 @@ Mantener abierto tras la selección - - + + Error Error - + Unable to write in Imposible escribir en - + Unable to launch in terminal. Imposible lanzar en terminal. @@ -51,12 +51,12 @@ ArrowTool - + Arrow Flecha - + Set the Arrow as the paint tool Establece la Flecha como herramienta de dibujo @@ -64,12 +64,12 @@ BlurTool - + Blur Desenfoque - + Set Blur as the paint tool Establece el Desenfoque como herramienta de dibujo @@ -77,47 +77,47 @@ CaptureLauncher - + <b>Capture Mode</b> - + Rectangular Region - + Full Screen (All Monitors) - + No Delay - + second - + seconds - + Take new screenshot - + Area: - + Delay: @@ -146,12 +146,12 @@ Presiona Espacio para abrir el panel lateral. CircleTool - + Circle Círculo - + Set the Circle as the paint tool Establece el Círculo como herramienta de dibujo @@ -187,32 +187,32 @@ Presiona Espacio para abrir el panel lateral. Controller - + &Take Screenshot &Tomar captura de pantalla - + &Open Launcher - + &Configuration &Configuración - + &Information &Información - + &Quit &Salir - + &Latest Uploads @@ -220,12 +220,12 @@ Presiona Espacio para abrir el panel lateral. CopyTool - + Copy Copiar - + Copy the selection into the clipboard Copia la selección al portapapeles @@ -233,7 +233,7 @@ Presiona Espacio para abrir el panel lateral. DBusUtils - + Unable to connect via DBus Imposible conectarse mediante DBus @@ -241,12 +241,12 @@ Presiona Espacio para abrir el panel lateral. ExitTool - + Exit Salir - + Leave the capture screen Salir de la pantalla de captura @@ -254,47 +254,47 @@ Presiona Espacio para abrir el panel lateral. FileNameEditor - + Edit the name of your captures: Edita el nombre de tus capturas: - + Edit: Editar: - + Preview: Previsualización: - + Save Guardar - + Saves the pattern Guarda el patrón - + Reset Reiniciar - + Restores the saved pattern Restaura el patrón guardado - + Clear Limpiar - + Deletes the name Borra el patrón @@ -302,27 +302,27 @@ Presiona Espacio para abrir el panel lateral. FilePathConfiguration - + Screenshot path default: - + Use fixed path for screenshots to save - + Browse - + Clear Limpiar - + Select default path for Screenshots @@ -580,12 +580,12 @@ Presiona Espacio para abrir el panel lateral. ImgS3UploaderTool - + Image Uploader Subir Imagen - + Upload the selection to S3 bucket @@ -693,12 +693,12 @@ Presiona Espacio para abrir el panel lateral. ImgurUploaderTool - + Image Uploader Subir Imagen - + Upload the selection to Imgur Sube la selección a Imgur @@ -706,7 +706,7 @@ Presiona Espacio para abrir el panel lateral. InfoWindow - + About Información @@ -767,12 +767,12 @@ Presiona Espacio para abrir el panel lateral. Descripción - + <u><b>License</b></u> <u><b>Licencia</b></u> - + <u><b>Version</b></u> <u><b>Versión</b></u> @@ -784,12 +784,12 @@ Presiona Espacio para abrir el panel lateral. LineTool - + Line Línea - + Set the Line as the paint tool Establece la Línea como herramienta de dibujo @@ -797,12 +797,12 @@ Presiona Espacio para abrir el panel lateral. MarkerTool - + Marker Marcador - + Set the Marker as the paint tool Establece el Marcador como herramienta de dibujo @@ -810,12 +810,12 @@ Presiona Espacio para abrir el panel lateral. MoveTool - + Move Mover Selección - + Move the selection area Mueve la selección @@ -823,12 +823,12 @@ Presiona Espacio para abrir el panel lateral. PencilTool - + Pencil Lápiz - + Set the Pencil as the paint tool Establece el Lápiz como herramienta de dibujo @@ -836,12 +836,12 @@ Presiona Espacio para abrir el panel lateral. PinTool - + Pin Tool Chincheta - + Pin image on the desktop Fija la imagen sobre el escritorio @@ -849,53 +849,53 @@ Presiona Espacio para abrir el panel lateral. QObject - + Save Error Error al Guardar - - + + Capture saved as Captura guardada como - + Capture saved to clipboard Captura guardada en el portapapeles - - + + Error trying to save as Error intentando guardar como - + Save screenshot - + Capture saved and copied to the clipboard as - - - - - + + + + + Unable to connect via DBus Imposible conectar mediante DBus - + Error Error - + Unable to write in Imposible escribir en @@ -905,73 +905,73 @@ Presiona Espacio para abrir el panel lateral. URL copiada al portapapeles. - + Hi, I'm already running! You can find me in the system tray. - + Hello, I'm here! Click icon in the tray to take a screenshot or click with a right button to see more options. - + Resize selection right 1px - + Resize selection left 1px - + Resize selection up 1px - + Resize selection down 1px - + Toggle side panel - + Move selection left 1px - + Move selection right 1px - + Move selection up 1px - + Move selection down 1px - + Quit capture Salir de la captura - + Screenshot history - + Capture screen @@ -980,12 +980,12 @@ You can find me in the system tray. Mover la selección 1px - + Show color picker Mostrar el selector de color - + Change the tool's thickness Cambiar el grosor de la herramienta @@ -993,12 +993,12 @@ You can find me in the system tray. RectangleTool - + Rectangle Rectángulo - + Set the Rectangle as the paint tool Establece el Rectángulo como herramienta de dibujo @@ -1006,12 +1006,12 @@ You can find me in the system tray. RedoTool - + Redo Rehacer - + Redo the next modification Rehacer la siguiente modificación @@ -1019,12 +1019,12 @@ You can find me in the system tray. SaveTool - + Save Guardar - + Save the capture Guardar la captura @@ -1032,7 +1032,7 @@ You can find me in the system tray. ScreenGrabber - + Unable to capture screen Imposible capturar la pantalla @@ -1040,12 +1040,12 @@ You can find me in the system tray. SelectionTool - + Rectangular Selection Selección Rectangular - + Set Selection as the paint tool Establece la Selección como herramienta de dibujo @@ -1053,17 +1053,17 @@ You can find me in the system tray. SetShortcutDialog - + Set Shortcut - + Enter new shortcut to change - + Press Esc to cancel or Backspace to disable the keyboard shortcut. @@ -1071,22 +1071,22 @@ You can find me in the system tray. ShortcutsWidget - + Hot Keys - + Available shortcuts in the screen capture mode. Atajos disponibles en el modo captura de pantalla. - + Description Descripción - + Key Tecla @@ -1094,22 +1094,22 @@ You can find me in the system tray. SidePanelWidget - + Active thickness: Espesor activo: - + Active color: Color activo: - + Press ESC to cancel Presiona ESC para cancelar - + Grab Color Tomar Color @@ -1117,12 +1117,12 @@ You can find me in the system tray. SizeIndicatorTool - + Selection Size Indicator Indicador de Tamaño de Selección - + Show the dimensions of the selection (X Y) Muestra la dimensión de la selección (X Y) @@ -1130,107 +1130,107 @@ You can find me in the system tray. StrftimeChooserWidget - + Century (00-99) Siglo (00-99) - + Year (00-99) Año (00-99) - + Year (2000) Año (2000) - + Month Name (jan) Nombre del Mes (jul) - + Month Name (january) Nombre del Mes (julio) - + Month (01-12) Mes (01-12) - + Week Day (1-7) Día de la Semana (1-7) - + Week (01-53) Semana (01-53) - + Day Name (mon) Nombre del Día (dom) - + Day Name (monday) Nombre del Día (domingo) - + Day (01-31) Día (01-31) - + Day of Month (1-31) Día del Mes (1-31) - + Day (001-366) Día (001-366) - + Time (%H-%M-%S) Tiempo (%H-%M-%S) - + Time (%H-%M) Tiempo (%H-%M) - + Hour (00-23) Hora (00-23) - + Hour (01-12) Hora (01-12) - + Minute (00-59) Minuto (00-59) - + Second (00-59) Segundo (00-59) - + Full Date (%m/%d/%y) Fecha (%m/%d/%y) - + Full Date (%Y-%m-%d) Fecha (%Y-%m-%d) @@ -1238,7 +1238,7 @@ You can find me in the system tray. SystemNotification - + Flameshot Info Información de Flameshot @@ -1246,22 +1246,22 @@ You can find me in the system tray. TextConfig - + StrikeOut Tachado - + Underline Subrayado - + Bold Negrita - + Italic Cursiva @@ -1269,12 +1269,12 @@ You can find me in the system tray. TextTool - + Text Texto - + Add text to your capture Agregar texto a la captura @@ -1282,37 +1282,37 @@ You can find me in the system tray. UIcolorEditor - + UI Color Editor Editor de Color de Interfaz - + Change the color moving the selectors and see the changes in the preview buttons. Cambia el color moviendo los selectores y observa los cambios en los botones de previsualización. - + Select a Button to modify it Selecciona un Botón para modificarlo - + Main Color Color Principal - + Click on this button to set the edition mode of the main color. Clica en este botón para aplicar el modo edición para el color primario. - + Contrast Color Color de Contraste - + Click on this button to set the edition mode of the contrast color. Clica en este botón para aplicar el modo edición para el color de contraste. @@ -1320,12 +1320,12 @@ You can find me in the system tray. UndoTool - + Undo Deshacer - + Undo the last modification Borra la última modificación @@ -1333,7 +1333,7 @@ You can find me in the system tray. UtilityPanel - + Hide @@ -1341,17 +1341,17 @@ You can find me in the system tray. VisualsEditor - + Opacity of area outside selection: Opacidad del area fuera de la selección: - + Button Selection Selección de Botón - + Select All Seleccionar Todos diff --git a/translations/Internationalization_fr.ts b/translations/Internationalization_fr.ts index ede9c812..55462fe1 100644 --- a/translations/Internationalization_fr.ts +++ b/translations/Internationalization_fr.ts @@ -4,12 +4,12 @@ AppLauncher - + App Launcher Lanceur d'applications - + Choose an app to open the capture Sélectionner une application pour ouvrir la capture @@ -32,18 +32,18 @@ Maintenir ouvert après la sélection - - + + Error Erreur - + Unable to write in Imposible d'écrire dessus - + Unable to launch in terminal. Imposible de lancer dans le terminal. @@ -51,12 +51,12 @@ ArrowTool - + Arrow Flèche - + Set the Arrow as the paint tool Sélectionner l'outil Flèche @@ -64,12 +64,12 @@ BlurTool - + Blur Flou - + Set Blur as the paint tool Sélectionner l'outil Flou @@ -77,47 +77,47 @@ CaptureLauncher - + <b>Capture Mode</b> - + Rectangular Region - + Full Screen (All Monitors) - + No Delay - + second - + seconds - + Take new screenshot - + Area: - + Delay: @@ -146,12 +146,12 @@ Appuyer sur Espace pour ouvrir le panneau latéral. CircleTool - + Circle Ellipse - + Set the Circle as the paint tool Sélectionner l'outil Ellipse @@ -187,32 +187,32 @@ Appuyer sur Espace pour ouvrir le panneau latéral. Controller - + &Take Screenshot &Capturer l'écran - + &Open Launcher - + &Configuration &Configuration - + &Information &Informations - + &Quit &Quitter - + &Latest Uploads @@ -220,12 +220,12 @@ Appuyer sur Espace pour ouvrir le panneau latéral. CopyTool - + Copy Copier - + Copy the selection into the clipboard Copier la sélection dans le presse-papier @@ -233,7 +233,7 @@ Appuyer sur Espace pour ouvrir le panneau latéral. DBusUtils - + Unable to connect via DBus Imposible de se connecter via DBus @@ -241,12 +241,12 @@ Appuyer sur Espace pour ouvrir le panneau latéral. ExitTool - + Exit Sortir - + Leave the capture screen Quitter l'écran de capture @@ -254,47 +254,47 @@ Appuyer sur Espace pour ouvrir le panneau latéral. FileNameEditor - + Edit the name of your captures: Editer le nom des captures: - + Edit: Editer: - + Preview: Prévisualisation: - + Save Sauvegarder - + Saves the pattern Sauvegarder le modèle - + Reset Réinitialiser - + Restores the saved pattern Réstaurer le modèle sauvegardé - + Clear Purger - + Deletes the name Supprime le nom @@ -302,27 +302,27 @@ Appuyer sur Espace pour ouvrir le panneau latéral. FilePathConfiguration - + Screenshot path default: - + Use fixed path for screenshots to save - + Browse - + Clear Purger - + Select default path for Screenshots @@ -576,12 +576,12 @@ Appuyer sur Espace pour ouvrir le panneau latéral. ImgS3UploaderTool - + Image Uploader Mise en ligne d'images - + Upload the selection to S3 bucket @@ -685,12 +685,12 @@ Appuyer sur Espace pour ouvrir le panneau latéral. ImgurUploaderTool - + Image Uploader Mise en ligne d'images - + Upload the selection to Imgur Mettre en ligne la sélection vers Imgur @@ -698,7 +698,7 @@ Appuyer sur Espace pour ouvrir le panneau latéral. InfoWindow - + About À propos @@ -755,12 +755,12 @@ Appuyer sur Espace pour ouvrir le panneau latéral. Description - + <u><b>License</b></u> <u><b>Licences</b></u> - + <u><b>Version</b></u> <u><b>Version</b></u> @@ -772,12 +772,12 @@ Appuyer sur Espace pour ouvrir le panneau latéral. LineTool - + Line Ligne - + Set the Line as the paint tool Sélectionner l'outil Ligne @@ -785,12 +785,12 @@ Appuyer sur Espace pour ouvrir le panneau latéral. MarkerTool - + Marker Surligneur - + Set the Marker as the paint tool Sélectionner l'outil Surligneur @@ -798,12 +798,12 @@ Appuyer sur Espace pour ouvrir le panneau latéral. MoveTool - + Move Déplacer - + Move the selection area Déplacer la sélection @@ -811,12 +811,12 @@ Appuyer sur Espace pour ouvrir le panneau latéral. PencilTool - + Pencil Crayon - + Set the Pencil as the paint tool Sélectionner l'outil Crayon @@ -824,12 +824,12 @@ Appuyer sur Espace pour ouvrir le panneau latéral. PinTool - + Pin Tool Outil Épinglage - + Pin image on the desktop Épingler l'image sur le bureau @@ -837,53 +837,53 @@ Appuyer sur Espace pour ouvrir le panneau latéral. QObject - + Save Error Erreur lors de la sauvegarde - - + + Capture saved as Capture d'écran sauvegardée sous - + Capture saved to clipboard Capture d'écran copiée dans le Presse-papier - - + + Error trying to save as Erreur lors de la sauvegarde sous - + Save screenshot - + Capture saved and copied to the clipboard as - - - - - + + + + + Unable to connect via DBus Impossible de se connecter via DBus - + Error Erreur - + Unable to write in Imposible d'écrire par dessus @@ -893,73 +893,73 @@ Appuyer sur Espace pour ouvrir le panneau latéral. URL copiée dans le Presse-papier. - + Hi, I'm already running! You can find me in the system tray. - + Hello, I'm here! Click icon in the tray to take a screenshot or click with a right button to see more options. - + Resize selection right 1px - + Resize selection left 1px - + Resize selection up 1px - + Resize selection down 1px - + Toggle side panel - + Move selection left 1px - + Move selection right 1px - + Move selection up 1px - + Move selection down 1px - + Quit capture Quitter la capture d'écran - + Screenshot history - + Capture screen @@ -968,12 +968,12 @@ You can find me in the system tray. Déplacer la sélection 1px - + Show color picker Afficher la palette de couleurs - + Change the tool's thickness Changer l'épaisseur des outils @@ -981,12 +981,12 @@ You can find me in the system tray. RectangleTool - + Rectangle Rectangle plein - + Set the Rectangle as the paint tool Sélectionner l'outil Rectangle plein @@ -994,12 +994,12 @@ You can find me in the system tray. RedoTool - + Redo Rétablir - + Redo the next modification Refaire la prochaine modification @@ -1007,12 +1007,12 @@ You can find me in the system tray. SaveTool - + Save Sauvegarder - + Save the capture Sauvegarder la capture d'écran @@ -1020,7 +1020,7 @@ You can find me in the system tray. ScreenGrabber - + Unable to capture screen Imposible de capturer l'écran @@ -1028,12 +1028,12 @@ You can find me in the system tray. SelectionTool - + Rectangular Selection Rectangle - + Set Selection as the paint tool Sélectionner l'outil Rectangle @@ -1041,17 +1041,17 @@ You can find me in the system tray. SetShortcutDialog - + Set Shortcut - + Enter new shortcut to change - + Press Esc to cancel or Backspace to disable the keyboard shortcut. @@ -1059,22 +1059,22 @@ You can find me in the system tray. ShortcutsWidget - + Hot Keys - + Available shortcuts in the screen capture mode. Raccourcis disponibles en mode capture d'écran. - + Description Description - + Key Clé @@ -1082,22 +1082,22 @@ You can find me in the system tray. SidePanelWidget - + Active color: Couleur actuelle: - + Press ESC to cancel Appuyer sur Echap pour annuler - + Grab Color Saisir la couleur - + Active thickness: @@ -1105,12 +1105,12 @@ You can find me in the system tray. SizeIndicatorTool - + Selection Size Indicator Indicateur de la taille de la sélection - + Show the dimensions of the selection (X Y) Montre les dimmensions de la sélection (X Y) @@ -1118,107 +1118,107 @@ You can find me in the system tray. StrftimeChooserWidget - + Century (00-99) Siècle (00-99) - + Year (00-99) Année (00-99) - + Year (2000) Année (2000) - + Month Name (jan) Nom des Mois (jan) - + Month Name (january) nom des Mois (janvier) - + Month (01-12) Mois (01-12) - + Week Day (1-7) Jour de la Semaine (1-7) - + Week (01-53) Semaine (01-53) - + Day Name (mon) Nom du Jour (lun) - + Day Name (monday) Nom du Jour (lundi) - + Day (01-31) Jour (01-31) - + Day of Month (1-31) Jour du Mois (1-31) - + Day (001-366) Jour de l'année (001-366) - + Time (%H-%M-%S) Heure (%H-%M-%S) - + Time (%H-%M) Heure (%H-%M) - + Hour (00-23) Heure (00-23) - + Hour (01-12) Heure (01-12) - + Minute (00-59) Minute (00-59) - + Second (00-59) Seconde (00-59) - + Full Date (%m/%d/%y) Date (%m/%d/%y) - + Full Date (%Y-%m-%d) Date Complête (%Y-%m-%d) @@ -1226,7 +1226,7 @@ You can find me in the system tray. SystemNotification - + Flameshot Info Info Flameshot @@ -1234,22 +1234,22 @@ You can find me in the system tray. TextConfig - + StrikeOut Rayer - + Underline Souligner - + Bold Gras - + Italic Italique @@ -1257,12 +1257,12 @@ You can find me in the system tray. TextTool - + Text Texte - + Add text to your capture Ajouter du texte à la capture @@ -1270,37 +1270,37 @@ You can find me in the system tray. UIcolorEditor - + UI Color Editor Editeur de la Couleur de l'interface - + Change the color moving the selectors and see the changes in the preview buttons. Modifiez la couleur en déplaçant les sélecteur et voir les changements dans les boutons de prévisualisation. - + Select a Button to modify it Sélectionner un bouton pour le modifier - + Main Color Couleur Principale - + Click on this button to set the edition mode of the main color. Cliquer sur ce boutton pour définir le mode édition de la couleur principale. - + Contrast Color Couleur de Contraste - + Click on this button to set the edition mode of the contrast color. Cliquer sur ce boutton pour définir le mode édition de la couleur de contraste. @@ -1308,12 +1308,12 @@ You can find me in the system tray. UndoTool - + Undo Annuler - + Undo the last modification Annuler la dernière modification @@ -1321,7 +1321,7 @@ You can find me in the system tray. UtilityPanel - + Hide @@ -1329,17 +1329,17 @@ You can find me in the system tray. VisualsEditor - + Opacity of area outside selection: Opacité de la zone en dehors de la sélection: - + Button Selection Boutton de sélection - + Select All Sélectionner Tout diff --git a/translations/Internationalization_ja.ts b/translations/Internationalization_ja.ts index 96698057..7540f785 100644 --- a/translations/Internationalization_ja.ts +++ b/translations/Internationalization_ja.ts @@ -4,12 +4,12 @@ AppLauncher - + App Launcher アプリケーションランチャー - + Choose an app to open the capture キャプチャーを開くアプリケーションを選択する @@ -32,18 +32,18 @@ 選択後も開いたままにする - - + + Error エラー - + Unable to launch in terminal. 端末内で起動できません。 - + Unable to write in 書き込めません: @@ -51,12 +51,12 @@ ArrowTool - + Arrow 矢印 - + Set the Arrow as the paint tool ペイントツールとして「矢印」をセットする @@ -64,12 +64,12 @@ BlurTool - + Blur ぼかし - + Set Blur as the paint tool ペイントツールとして「ぼかし」をセットする @@ -77,47 +77,47 @@ CaptureLauncher - + <b>Capture Mode</b> - + Rectangular Region - + Full Screen (All Monitors) - + No Delay - + second - + seconds - + Take new screenshot - + Area: - + Delay: @@ -146,12 +146,12 @@ Enter を押すと画面をキャプチャー。 CircleTool - + Circle 円形 - + Set the Circle as the paint tool ペイントツールとして「円形」をセットする @@ -187,32 +187,32 @@ Enter を押すと画面をキャプチャー。 Controller - + &Take Screenshot スクリーンショットを撮る(&T) - + &Open Launcher - + &Configuration 設定(&C) - + &Information 情報(&I) - + &Quit 終了(&Q) - + &Latest Uploads @@ -220,12 +220,12 @@ Enter を押すと画面をキャプチャー。 CopyTool - + Copy コピー - + Copy the selection into the clipboard 選択範囲をクリップボードにコピーする @@ -233,7 +233,7 @@ Enter を押すと画面をキャプチャー。 DBusUtils - + Unable to connect via DBus DBus に接続できません @@ -241,12 +241,12 @@ Enter を押すと画面をキャプチャー。 ExitTool - + Exit 終了 - + Leave the capture screen 画面キャプチャーを終了する @@ -254,47 +254,47 @@ Enter を押すと画面をキャプチャー。 FileNameEditor - + Edit the name of your captures: キャプチャー名の編集: - + Edit: 編集: - + Preview: プレビュー: - + Save 保存 - + Saves the pattern パターンを保存する - + Reset リセット - + Restores the saved pattern 保存されたパターンに戻す - + Clear 消去 - + Deletes the name 名前を削除する @@ -302,27 +302,27 @@ Enter を押すと画面をキャプチャー。 FilePathConfiguration - + Screenshot path default: - + Use fixed path for screenshots to save - + Browse - + Clear 消去 - + Select default path for Screenshots @@ -580,12 +580,12 @@ Enter を押すと画面をキャプチャー。 ImgS3UploaderTool - + Image Uploader 画像アップローダー - + Upload the selection to S3 bucket @@ -693,12 +693,12 @@ Enter を押すと画面をキャプチャー。 ImgurUploaderTool - + Image Uploader 画像アップローダー - + Upload the selection to Imgur Imgur に選択範囲をアップロードする @@ -706,7 +706,7 @@ Enter を押すと画面をキャプチャー。 InfoWindow - + About このアプリケーションについて @@ -759,12 +759,12 @@ Enter を押すと画面をキャプチャー。 説明 - + <u><b>License</b></u> <u><b>ライセンス</b></u> - + <u><b>Version</b></u> <u><b>バージョン</b></u> @@ -780,12 +780,12 @@ Enter を押すと画面をキャプチャー。 LineTool - + Line 直線 - + Set the Line as the paint tool ペイントツールとして「直線」をセットする @@ -793,12 +793,12 @@ Enter を押すと画面をキャプチャー。 MarkerTool - + Marker マーカー - + Set the Marker as the paint tool ペイントツールとして「マーカー」をセットする @@ -806,12 +806,12 @@ Enter を押すと画面をキャプチャー。 MoveTool - + Move 移動 - + Move the selection area 選択範囲を移動する @@ -819,12 +819,12 @@ Enter を押すと画面をキャプチャー。 PencilTool - + Pencil 鉛筆 - + Set the Pencil as the paint tool ペイントツールとして「鉛筆」をセットする @@ -832,12 +832,12 @@ Enter を押すと画面をキャプチャー。 PinTool - + Pin Tool 固定ツール - + Pin image on the desktop 選択範囲をデスクトップ上に配置する @@ -845,53 +845,53 @@ Enter を押すと画面をキャプチャー。 QObject - + Save Error 保存エラー - - + + Capture saved as キャプチャーを保存しました: - + Capture saved to clipboard キャプチャーをクリップボードに保存しました - - + + Error trying to save as 保存時にエラーが発生しました: - + Save screenshot - + Capture saved and copied to the clipboard as - - - - - + + + + + Unable to connect via DBus DBus に接続できません - + Error エラー - + Unable to write in 書き込めません: @@ -901,73 +901,73 @@ Enter を押すと画面をキャプチャー。 URL をクリップボードにコピーしました。 - + Hi, I'm already running! You can find me in the system tray. - + Hello, I'm here! Click icon in the tray to take a screenshot or click with a right button to see more options. - + Resize selection right 1px - + Resize selection left 1px - + Resize selection up 1px - + Resize selection down 1px - + Toggle side panel - + Move selection left 1px - + Move selection right 1px - + Move selection up 1px - + Move selection down 1px - + Quit capture キャプチャーを終了する - + Screenshot history - + Capture screen @@ -976,12 +976,12 @@ You can find me in the system tray. 選択範囲を 1px 動かす - + Show color picker カラーピッカーを表示する - + Change the tool's thickness ツールの値 (太さや濃さ) を変更する @@ -989,12 +989,12 @@ You can find me in the system tray. RectangleTool - + Rectangle 矩形 - + Set the Rectangle as the paint tool ペイントツールとして「矩形」をセットする @@ -1002,12 +1002,12 @@ You can find me in the system tray. RedoTool - + Redo やり直し - + Redo the next modification 次の変更にやり直す @@ -1015,12 +1015,12 @@ You can find me in the system tray. SaveTool - + Save 保存 - + Save the capture キャプチャーを保存する @@ -1028,7 +1028,7 @@ You can find me in the system tray. ScreenGrabber - + Unable to capture screen 画面をキャプチャーできません @@ -1036,12 +1036,12 @@ You can find me in the system tray. SelectionTool - + Rectangular Selection 矩形選択 - + Set Selection as the paint tool ペイントツールとして「矩形選択」をセットする @@ -1049,17 +1049,17 @@ You can find me in the system tray. SetShortcutDialog - + Set Shortcut - + Enter new shortcut to change - + Press Esc to cancel or Backspace to disable the keyboard shortcut. @@ -1067,22 +1067,22 @@ You can find me in the system tray. ShortcutsWidget - + Hot Keys - + Available shortcuts in the screen capture mode. スクリーンキャプチャーモードで利用可能なショートカット。 - + Description 説明 - + Key キー @@ -1090,22 +1090,22 @@ You can find me in the system tray. SidePanelWidget - + Active thickness: - + Active color: アクティブな色: - + Press ESC to cancel ESC でキャンセル - + Grab Color 色の取得 @@ -1113,12 +1113,12 @@ You can find me in the system tray. SizeIndicatorTool - + Selection Size Indicator 選択サイズインジケーター - + Show the dimensions of the selection (X Y) 選択範囲の寸法 (X Y) を表示する @@ -1126,107 +1126,107 @@ You can find me in the system tray. StrftimeChooserWidget - + Century (00-99) 世紀 (00-99) - + Year (00-99) 年 (00-99) - + Year (2000) 年 (2000) - + Month Name (jan) 月 (jan) - + Month Name (january) 月 (january) - + Month (01-12) 月 (01-12) - + Week Day (1-7) 週日 (1-7) - + Week (01-53) 週 (01-53) - + Day Name (mon) 曜日 (月) - + Day Name (monday) 曜日 (月曜日) - + Day (01-31) 日 (01-31) - + Day of Month (1-31) 日 (1-31) - + Day (001-366) 日 (001-366) - + Time (%H-%M-%S) 時刻 (%H-%M-%S) - + Time (%H-%M) 時刻 (%H-%M) - + Hour (00-23) 時 (00-23) - + Hour (01-12) 時 (01-12) - + Minute (00-59) 分 (00-59) - + Second (00-59) 秒 (00-59) - + Full Date (%m/%d/%y) 年月日 (%m/%d/%y) - + Full Date (%Y-%m-%d) 年月日 (%Y-%m-%d) @@ -1234,7 +1234,7 @@ You can find me in the system tray. SystemNotification - + Flameshot Info Flameshot の情報 @@ -1242,22 +1242,22 @@ You can find me in the system tray. TextConfig - + StrikeOut 取り消し線 - + Underline 下線 - + Bold 太字 - + Italic 斜体 @@ -1265,12 +1265,12 @@ You can find me in the system tray. TextTool - + Text テキスト - + Add text to your capture キャプチャーにテキストを追加する @@ -1278,37 +1278,37 @@ You can find me in the system tray. UIcolorEditor - + UI Color Editor UI カラーエディター - + Change the color moving the selectors and see the changes in the preview buttons. セレクターを動かして色を変更し、プレビューボタンの色がどう変化するか確認してください。 - + Select a Button to modify it 変更するボタンを選択してください - + Main Color メインカラー - + Click on this button to set the edition mode of the main color. このボタンをクリックすると、メインカラーの編集モードをセットします。 - + Contrast Color コントラストカラー - + Click on this button to set the edition mode of the contrast color. このボタンをクリックすると、コントラストカラーの編集モードをセットします。 @@ -1316,12 +1316,12 @@ You can find me in the system tray. UndoTool - + Undo 元に戻す - + Undo the last modification 最後の変更を元に戻す @@ -1329,7 +1329,7 @@ You can find me in the system tray. UtilityPanel - + Hide @@ -1337,17 +1337,17 @@ You can find me in the system tray. VisualsEditor - + Opacity of area outside selection: 選択範囲外の不透明度: - + Button Selection ボタンの選択 - + Select All すべて選択 diff --git a/translations/Internationalization_ka.ts b/translations/Internationalization_ka.ts index f3dfd655..561240e5 100644 --- a/translations/Internationalization_ka.ts +++ b/translations/Internationalization_ka.ts @@ -4,12 +4,12 @@ AppLauncher - + App Launcher აპლიკაციის გამშვები - + Choose an app to open the capture აირჩიეთ აპლიკაცია სურათის გასახსნელად @@ -32,18 +32,18 @@ არ დახურო დიალოგი არჩევის შემდეგ - - + + Error შეცდომა - + Unable to write in შემდეგ მისამართზე ჩაწერა ვერ მოხერხდა: - + Unable to launch in terminal. ტერმინალში გაშვება ვერ მოხერხდა. @@ -51,12 +51,12 @@ ArrowTool - + Arrow ისარი - + Set the Arrow as the paint tool ისრის ხელსაწყოს არჩევა სახატავად @@ -64,12 +64,12 @@ BlurTool - + Blur გაბუნდოვნება - + Set Blur as the paint tool გაბუნდოვნების ხელსაწყოს არჩევა სახატავად @@ -77,47 +77,47 @@ CaptureLauncher - + <b>Capture Mode</b> - + Rectangular Region - + Full Screen (All Monitors) - + No Delay - + second - + seconds - + Take new screenshot - + Area: - + Delay: @@ -142,12 +142,12 @@ Press Space to open the side panel. CircleTool - + Circle წრე - + Set the Circle as the paint tool წრის ხელსაწყოს არჩევა სახატავად @@ -183,32 +183,32 @@ Press Space to open the side panel. Controller - + &Take Screenshot - + &Open Launcher - + &Configuration &პარამეტრები - + &Information &ინფორმაცია - + &Quit &გამოსვლა - + &Latest Uploads @@ -216,12 +216,12 @@ Press Space to open the side panel. CopyTool - + Copy კოპირება - + Copy the selection into the clipboard @@ -229,7 +229,7 @@ Press Space to open the side panel. DBusUtils - + Unable to connect via DBus DBus-ით დაკავშირება ვერ მოხერხდა @@ -237,12 +237,12 @@ Press Space to open the side panel. ExitTool - + Exit გამოსვლა - + Leave the capture screen ეკრანის გადაღების დატოვება @@ -250,47 +250,47 @@ Press Space to open the side panel. FileNameEditor - + Edit the name of your captures: შეცვალეთ თქვენი სურათების სახელი: - + Edit: თარგი: - + Preview: გადახედვა: - + Save შენახვა - + Saves the pattern თარგის შენახვა - + Reset განულება - + Restores the saved pattern შენახული შაბლონის განულება - + Clear გაწმენდა - + Deletes the name სახელის წაშლა @@ -298,27 +298,27 @@ Press Space to open the side panel. FilePathConfiguration - + Screenshot path default: - + Use fixed path for screenshots to save - + Browse - + Clear გაწმენდა - + Select default path for Screenshots @@ -572,12 +572,12 @@ Press Space to open the side panel. ImgS3UploaderTool - + Image Uploader სურათის ამტვირთველი - + Upload the selection to S3 bucket @@ -681,12 +681,12 @@ Press Space to open the side panel. ImgurUploaderTool - + Image Uploader სურათის ამტვირთველი - + Upload the selection to Imgur შერჩეულის Imgur-ზე ატვირთვა @@ -694,7 +694,7 @@ Press Space to open the side panel. InfoWindow - + About პროგრამის შესახებ @@ -751,12 +751,12 @@ Press Space to open the side panel. აღწერა - + <u><b>License</b></u> <u><b>ლიცენზია</b></u> - + <u><b>Version</b></u> <u><b>ვერსია</b></u> @@ -768,12 +768,12 @@ Press Space to open the side panel. LineTool - + Line ხაზი - + Set the Line as the paint tool ხაზის ხელსაწყოს არჩევა სახატავად @@ -781,12 +781,12 @@ Press Space to open the side panel. MarkerTool - + Marker მარკერი - + Set the Marker as the paint tool მარკერის ხელსაწყოს არჩევა სახატავად @@ -794,12 +794,12 @@ Press Space to open the side panel. MoveTool - + Move გადაადგილება - + Move the selection area შერჩეული არის გადაადგილება @@ -807,12 +807,12 @@ Press Space to open the side panel. PencilTool - + Pencil ფანქარი - + Set the Pencil as the paint tool ფანქრის ხელსაწყოს არჩევა სახატავად @@ -820,12 +820,12 @@ Press Space to open the side panel. PinTool - + Pin Tool - + Pin image on the desktop @@ -833,53 +833,53 @@ Press Space to open the side panel. QObject - + Save Error შეცდომა შენახვისას - - + + Capture saved as სურათი შენახულია როგორც: - + Capture saved to clipboard - - + + Error trying to save as შეცდომა მცდელობისას შენახულიყო როგორც: - + Save screenshot - + Capture saved and copied to the clipboard as - - - - - + + + + + Unable to connect via DBus DBus-ით დაკავშირება ვერ მოხერხდა - + Error შეცდომა - + Unable to write in შემდეგ მისამართზე ჩაწერა ვერ მოხერხდა: @@ -889,73 +889,73 @@ Press Space to open the side panel. URL დაკოპირდა გაცვლის ბუფერში. - + Hi, I'm already running! You can find me in the system tray. - + Hello, I'm here! Click icon in the tray to take a screenshot or click with a right button to see more options. - + Resize selection right 1px - + Resize selection left 1px - + Resize selection up 1px - + Resize selection down 1px - + Toggle side panel - + Move selection left 1px - + Move selection right 1px - + Move selection up 1px - + Move selection down 1px - + Quit capture გადაღებიდან გამოსვლა - + Screenshot history - + Capture screen @@ -964,12 +964,12 @@ You can find me in the system tray. შერჩეულის გადაადგილება 1px-ით - + Show color picker ფერის შესარჩევის ჩვენება - + Change the tool's thickness ხელსაწყოს სისქის შეცვლა @@ -977,12 +977,12 @@ You can find me in the system tray. RectangleTool - + Rectangle მართკუთხედი - + Set the Rectangle as the paint tool მართკუთხედის ხელსაწყოს არჩევა სახატავად @@ -990,12 +990,12 @@ You can find me in the system tray. RedoTool - + Redo - + Redo the next modification @@ -1003,12 +1003,12 @@ You can find me in the system tray. SaveTool - + Save შენახვა - + Save the capture სურათის შენახვა @@ -1016,7 +1016,7 @@ You can find me in the system tray. ScreenGrabber - + Unable to capture screen ეკრანის გადაღება ვერ მოხერხდა @@ -1024,12 +1024,12 @@ You can find me in the system tray. SelectionTool - + Rectangular Selection მართკუთხა შერჩევა - + Set Selection as the paint tool შერჩევის ხელსაწყოს არჩევა სახატავად @@ -1037,17 +1037,17 @@ You can find me in the system tray. SetShortcutDialog - + Set Shortcut - + Enter new shortcut to change - + Press Esc to cancel or Backspace to disable the keyboard shortcut. @@ -1055,22 +1055,22 @@ You can find me in the system tray. ShortcutsWidget - + Hot Keys - + Available shortcuts in the screen capture mode. გადაღების რეჟიმში ხელმისაწვდომი მალსახმობები. - + Description აღწერა - + Key კლავიში @@ -1078,22 +1078,22 @@ You can find me in the system tray. SidePanelWidget - + Active thickness: - + Active color: - + Press ESC to cancel - + Grab Color @@ -1101,12 +1101,12 @@ You can find me in the system tray. SizeIndicatorTool - + Selection Size Indicator შერჩეულის ზომის მაჩვენებელი - + Show the dimensions of the selection (X Y) აჩვენებს შერჩეული არის განზომილებებს (X Y) @@ -1114,107 +1114,107 @@ You can find me in the system tray. StrftimeChooserWidget - + Century (00-99) საუკუნე (00-99) - + Year (00-99) წელი (00-99) - + Year (2000) წელი (2000) - + Month Name (jan) თვის სახელი (იან) - + Month Name (january) თვის სახელი (იანვარი) - + Month (01-12) თვე (01-12) - + Week Day (1-7) კვირის დღე (1-7) - + Week (01-53) კვირა (01-53) - + Day Name (mon) დღის სახელი (ორშ) - + Day Name (monday) დღის სახელი (ორშაბათი) - + Day (01-31) დღე (01-31) - + Day of Month (1-31) თვის დღე (1-31) - + Day (001-366) დღე (001-366) - + Time (%H-%M-%S) - + Time (%H-%M) - + Hour (00-23) საათი (00-23) - + Hour (01-12) საათი (01-12) - + Minute (00-59) წუთი (00-59) - + Second (00-59) წამი (00-59) - + Full Date (%m/%d/%y) სრული თარიღი (%m/%d/%y) - + Full Date (%Y-%m-%d) სრული თარიღი (%Y-%m-%d) @@ -1222,7 +1222,7 @@ You can find me in the system tray. SystemNotification - + Flameshot Info @@ -1230,22 +1230,22 @@ You can find me in the system tray. TextConfig - + StrikeOut - + Underline - + Bold - + Italic @@ -1253,12 +1253,12 @@ You can find me in the system tray. TextTool - + Text - + Add text to your capture @@ -1266,37 +1266,37 @@ You can find me in the system tray. UIcolorEditor - + UI Color Editor ინტერფეისის ფერის რედაქტორი - + Change the color moving the selectors and see the changes in the preview buttons. შეცვალეთ ფერი ნიშნულის გადაადგილებით და შეხედეთ ცვლილებებს გადასახედ ღილაკებზე. - + Select a Button to modify it აირჩიეთ ღილაკი მის შესაცვლელად - + Main Color ძირითადი ფერი - + Click on this button to set the edition mode of the main color. დააწექით ამ ღილაკს ძირითადი ფერის არჩევის რეჟიმის ჩასართავად. - + Contrast Color კონტრასტული ფერი - + Click on this button to set the edition mode of the contrast color. დააწექით ამ ღილაკს კონტრასტული ფერის არჩევის რეჟიმის ჩასართავად. @@ -1304,12 +1304,12 @@ You can find me in the system tray. UndoTool - + Undo უკუქმნა - + Undo the last modification ბოლო ცვლილების გაუქმება @@ -1317,7 +1317,7 @@ You can find me in the system tray. UtilityPanel - + Hide @@ -1325,17 +1325,17 @@ You can find me in the system tray. VisualsEditor - + Opacity of area outside selection: შერჩეულის გარე არეს გაუმჭვირვალობა - + Button Selection ღილაკის არჩევა - + Select All ყველაფრის შერჩევა diff --git a/translations/Internationalization_nl.ts b/translations/Internationalization_nl.ts index 284e7f70..d66808b7 100644 --- a/translations/Internationalization_nl.ts +++ b/translations/Internationalization_nl.ts @@ -4,12 +4,12 @@ AppLauncher - + App Launcher App-starter - + Choose an app to open the capture Kies een app om de schermafdruk mee te openen @@ -32,18 +32,18 @@ Openhouden na selectie - - + + Error Fout - + Unable to write in Kan niet schrijven naar - + Unable to launch in terminal. Kan niet openen in terminalvenster. @@ -51,12 +51,12 @@ ArrowTool - + Arrow Cursor - + Set the Arrow as the paint tool Cursor instellen als verfgereedschap @@ -64,12 +64,12 @@ BlurTool - + Blur Vervaging - + Set Blur as the paint tool Vervaging instellen als verfgereedschap @@ -77,47 +77,47 @@ CaptureLauncher - + <b>Capture Mode</b> - + Rectangular Region - + Full Screen (All Monitors) - + No Delay - + second - + seconds - + Take new screenshot - + Area: - + Delay: @@ -146,12 +146,12 @@ Druk op spatie om het zijpaneel te openen. CircleTool - + Circle Cirkel - + Set the Circle as the paint tool Cirkel instellen als verfgereedschap @@ -187,32 +187,32 @@ Druk op spatie om het zijpaneel te openen. Controller - + &Take Screenshot Schermafdruk &maken - + &Open Launcher - + &Configuration &Configuratie - + &Information &Informatie - + &Quit &Afsluiten - + &Latest Uploads @@ -220,12 +220,12 @@ Druk op spatie om het zijpaneel te openen. CopyTool - + Copy Kopiëren - + Copy the selection into the clipboard Selectie kopiëren naar klembord @@ -233,7 +233,7 @@ Druk op spatie om het zijpaneel te openen. DBusUtils - + Unable to connect via DBus Kan niet verbinden via DBus @@ -241,12 +241,12 @@ Druk op spatie om het zijpaneel te openen. ExitTool - + Exit Afsluiten - + Leave the capture screen Verlaat het vastlegscherm @@ -254,47 +254,47 @@ Druk op spatie om het zijpaneel te openen. FileNameEditor - + Edit the name of your captures: Bewerk de naam van je schermafdrukken: - + Edit: Bewerken: - + Preview: Voorbeeld: - + Save Opslaan - + Saves the pattern Slaat het patroon op - + Reset Standaardwaarden - + Restores the saved pattern Herstelt het standaardpatroon - + Clear Wissen - + Deletes the name Wist de naam @@ -302,27 +302,27 @@ Druk op spatie om het zijpaneel te openen. FilePathConfiguration - + Screenshot path default: - + Use fixed path for screenshots to save - + Browse - + Clear Wissen - + Select default path for Screenshots @@ -580,12 +580,12 @@ Druk op spatie om het zijpaneel te openen. ImgS3UploaderTool - + Image Uploader Afbeeldingsuploader - + Upload the selection to S3 bucket @@ -693,12 +693,12 @@ Druk op spatie om het zijpaneel te openen. ImgurUploaderTool - + Image Uploader Afbeeldingsuploader - + Upload the selection to Imgur Upload de selectie naar Imgur @@ -706,7 +706,7 @@ Druk op spatie om het zijpaneel te openen. InfoWindow - + About Over @@ -767,12 +767,12 @@ Druk op spatie om het zijpaneel te openen. Omschrijving - + <u><b>License</b></u> <u><b>Лиценца</b></u> - + <u><b>Version</b></u> <u><b>Верзија</b></u> @@ -784,12 +784,12 @@ Druk op spatie om het zijpaneel te openen. LineTool - + Line Lijn - + Set the Line as the paint tool Lijn instellen als verfgereedschap @@ -797,12 +797,12 @@ Druk op spatie om het zijpaneel te openen. MarkerTool - + Marker Markeerstift - + Set the Marker as the paint tool Markeerstift instellen als verfgereedschap @@ -810,12 +810,12 @@ Druk op spatie om het zijpaneel te openen. MoveTool - + Move Verplaatsen - + Move the selection area Selectiegebied verplaatsen @@ -823,12 +823,12 @@ Druk op spatie om het zijpaneel te openen. PencilTool - + Pencil Potlood - + Set the Pencil as the paint tool Potlood instellen als verfgereedschap @@ -836,12 +836,12 @@ Druk op spatie om het zijpaneel te openen. PinTool - + Pin Tool Vastmaken - + Pin image on the desktop Afbeelding vastmaken op bureaublad @@ -849,53 +849,53 @@ Druk op spatie om het zijpaneel te openen. QObject - + Save Error Fout tijdens opslaan - - + + Capture saved as Schermafdruk opgeslagen als - + Capture saved to clipboard Schermafdruk vastgelegd op klembord - - + + Error trying to save as Fout tijdens opslaan als - + Save screenshot - + Capture saved and copied to the clipboard as - - - - - + + + + + Unable to connect via DBus Kan niet verbinden via DBus - + Error Fout - + Unable to write in Kan niet wegschrijven naar @@ -905,73 +905,73 @@ Druk op spatie om het zijpaneel te openen. URL gekopieerd naar klembord. - + Hi, I'm already running! You can find me in the system tray. - + Hello, I'm here! Click icon in the tray to take a screenshot or click with a right button to see more options. - + Resize selection right 1px - + Resize selection left 1px - + Resize selection up 1px - + Resize selection down 1px - + Toggle side panel - + Move selection left 1px - + Move selection right 1px - + Move selection up 1px - + Move selection down 1px - + Quit capture Vastleggen afsluiten - + Screenshot history - + Capture screen @@ -980,12 +980,12 @@ You can find me in the system tray. Selectie 1px verplaatsen - + Show color picker Kleurkiezer tonen - + Change the tool's thickness Wijzig de gereedschapsdikte @@ -993,12 +993,12 @@ You can find me in the system tray. RectangleTool - + Rectangle Rechthoek - + Set the Rectangle as the paint tool Rechthoek instellen als verfgereedschap @@ -1006,12 +1006,12 @@ You can find me in the system tray. RedoTool - + Redo Opnieuw - + Redo the next modification Volgende wijziging opnieuw toepassen @@ -1019,13 +1019,13 @@ You can find me in the system tray. SaveTool - + Save Сачувај Opslaan - + Save the capture Schermafdruk opslaan @@ -1033,7 +1033,7 @@ You can find me in the system tray. ScreenGrabber - + Unable to capture screen Kan scherm niet vastleggen @@ -1041,12 +1041,12 @@ You can find me in the system tray. SelectionTool - + Rectangular Selection Rechthoekige selectie - + Set Selection as the paint tool Selectie instellen als verfgereedschap @@ -1054,17 +1054,17 @@ You can find me in the system tray. SetShortcutDialog - + Set Shortcut - + Enter new shortcut to change - + Press Esc to cancel or Backspace to disable the keyboard shortcut. @@ -1072,22 +1072,22 @@ You can find me in the system tray. ShortcutsWidget - + Hot Keys - + Available shortcuts in the screen capture mode. Beschikbare sneltoetsen in de vastlegmodus. - + Description Omschrijving - + Key Toets @@ -1095,22 +1095,22 @@ You can find me in the system tray. SidePanelWidget - + Active thickness: Actieve dikte: - + Active color: Actieve kleur: - + Press ESC to cancel Druk op Esc om te annuleren - + Grab Color Kleur opnemen @@ -1118,12 +1118,12 @@ You can find me in the system tray. SizeIndicatorTool - + Selection Size Indicator Grootteindicatie van selectie - + Show the dimensions of the selection (X Y) Toon de afmetingen van de selectie (X Y) @@ -1131,107 +1131,107 @@ You can find me in the system tray. StrftimeChooserWidget - + Century (00-99) Eeuw (00-99) - + Year (00-99) Jaar (00-99) - + Year (2000) Jaar (2000) - + Month Name (jan) Naam van de maand (јаn) - + Month Name (january) Naam van de maand (јаnuari) - + Month (01-12) Maand (01-12) - + Week Day (1-7) Weekdag (1-7) - + Week (01-53) Week (01-53) - + Day Name (mon) Naam van de dag (ma) - + Day Name (monday) Naam van de dag (maandag) - + Day (01-31) Dag (01-31) - + Day of Month (1-31) Dag van de maand (1-31) - + Day (001-366) Dag (001-366) - + Time (%H-%M-%S) Tijd (%H-%M-%S) - + Time (%H-%M) Tijd (%H-%M) - + Hour (00-23) Uur (00-23) - + Hour (01-12) Uur (01-12) - + Minute (00-59) Minuten (00-59) - + Second (00-59) Seconden (00-59) - + Full Date (%m/%d/%y) Volledige datum (%m/%d/%y) - + Full Date (%Y-%m-%d) Volledige datum (%Y-%m-%d) @@ -1239,7 +1239,7 @@ You can find me in the system tray. SystemNotification - + Flameshot Info Flameshot-informatie @@ -1247,22 +1247,22 @@ You can find me in the system tray. TextConfig - + StrikeOut Doorhalen - + Underline Onderstrepen - + Bold Vetgedrukt - + Italic Cursief @@ -1270,12 +1270,12 @@ You can find me in the system tray. TextTool - + Text Tekst - + Add text to your capture Voeg tekst toe aan je schermafdruk @@ -1283,37 +1283,37 @@ You can find me in the system tray. UIcolorEditor - + UI Color Editor Kleurenschemabewerker - + Change the color moving the selectors and see the changes in the preview buttons. Wijzig de kleur d.m.v. de selectie-indicators en bekijk de wijzigingen op de voorbeeldknoppen. - + Select a Button to modify it Kies een te bewerken knop - + Main Color Hoofdkleur - + Click on this button to set the edition mode of the main color. Klik op deze knop om de hoofdkleur te bwerken. - + Contrast Color Contrastkleur - + Click on this button to set the edition mode of the contrast color. Klik op deze knop om de contrastkleur te bewerken. @@ -1321,12 +1321,12 @@ You can find me in the system tray. UndoTool - + Undo Ongedaan mken - + Undo the last modification Laatste wijziging ongedaan maken @@ -1334,7 +1334,7 @@ You can find me in the system tray. UtilityPanel - + Hide @@ -1342,17 +1342,17 @@ You can find me in the system tray. VisualsEditor - + Opacity of area outside selection: Doorzichtigheid van gebied buiten selectie: - + Button Selection Knopselectie - + Select All Alles selecteren diff --git a/translations/Internationalization_pl.ts b/translations/Internationalization_pl.ts index d7bd9fd4..ce7d7dde 100644 --- a/translations/Internationalization_pl.ts +++ b/translations/Internationalization_pl.ts @@ -4,12 +4,12 @@ AppLauncher - + App Launcher Uruchamianie aplikacji - + Choose an app to open the capture Wybierz aplikację do otwierania zrzutu @@ -32,18 +32,18 @@ Pozostaw otwarte po zaznaczeniu - - + + Error Błąd - + Unable to write in Nie można zapisać - + Unable to launch in terminal. Nie można uruchomić w terminalu. @@ -51,12 +51,12 @@ ArrowTool - + Arrow Strzałka - + Set the Arrow as the paint tool Rysowanie strzałek @@ -64,12 +64,12 @@ BlurTool - + Blur Rozmycie - + Set Blur as the paint tool Rozmywanie obszarów @@ -77,47 +77,47 @@ CaptureLauncher - + <b>Capture Mode</b> - + Rectangular Region - + Full Screen (All Monitors) - + No Delay - + second - + seconds - + Take new screenshot - + Area: - + Delay: @@ -145,12 +145,12 @@ Spacja, aby pokazać panel boczny. CircleTool - + Circle Okręgi - + Set the Circle as the paint tool Rysowanie okręgów i elips @@ -186,32 +186,32 @@ Spacja, aby pokazać panel boczny. Controller - + &Take Screenshot &Zrzut ekranu - + &Open Launcher - + &Configuration &Konfiguracja - + &Information &Informacje - + &Quit &Wyjdź - + &Latest Uploads @@ -219,12 +219,12 @@ Spacja, aby pokazać panel boczny. CopyTool - + Copy Kopiuj - + Copy the selection into the clipboard @@ -232,7 +232,7 @@ Spacja, aby pokazać panel boczny. DBusUtils - + Unable to connect via DBus Nie można się połączyć za pomocą DBus @@ -240,12 +240,12 @@ Spacja, aby pokazać panel boczny. ExitTool - + Exit Wyjdź - + Leave the capture screen Opuść ekran przechwytywania @@ -253,47 +253,47 @@ Spacja, aby pokazać panel boczny. FileNameEditor - + Edit the name of your captures: Edycja wzorca nazwy plików: - + Edit: Edytuj: - + Preview: Podgląd: - + Save Zapisz - + Saves the pattern Zapisuje wzorzec - + Reset Reset - + Restores the saved pattern Resetuje wzorzec - + Clear Wyczyść - + Deletes the name Czyści wzorzec @@ -301,27 +301,27 @@ Spacja, aby pokazać panel boczny. FilePathConfiguration - + Screenshot path default: - + Use fixed path for screenshots to save - + Browse - + Clear Wyczyść - + Select default path for Screenshots @@ -579,12 +579,12 @@ Spacja, aby pokazać panel boczny. ImgS3UploaderTool - + Image Uploader Uploader obrazów - + Upload the selection to S3 bucket @@ -692,12 +692,12 @@ Spacja, aby pokazać panel boczny. ImgurUploaderTool - + Image Uploader Uploader obrazów - + Upload the selection to Imgur Wyślij zaznaczenie do Imgur @@ -705,7 +705,7 @@ Spacja, aby pokazać panel boczny. InfoWindow - + About O programie @@ -762,12 +762,12 @@ Spacja, aby pokazać panel boczny. Działanie - + <u><b>License</b></u> <u><b>Licencja</b></u> - + <u><b>Version</b></u> <u><b>Wersja</b></u> @@ -779,12 +779,12 @@ Spacja, aby pokazać panel boczny. LineTool - + Line Linia - + Set the Line as the paint tool Ustawia linię jako narzędzie do rysowania @@ -792,12 +792,12 @@ Spacja, aby pokazać panel boczny. MarkerTool - + Marker Marker - + Set the Marker as the paint tool Ustawia Marker jako narzędzie rysowania @@ -805,12 +805,12 @@ Spacja, aby pokazać panel boczny. MoveTool - + Move Przesuwanie - + Move the selection area Przesuwa zaznaczenie @@ -818,12 +818,12 @@ Spacja, aby pokazać panel boczny. PencilTool - + Pencil Ołówek - + Set the Pencil as the paint tool Ustawia ołówek jako narzędzie do rysowania @@ -831,12 +831,12 @@ Spacja, aby pokazać panel boczny. PinTool - + Pin Tool Narzędzie przypinania - + Pin image on the desktop Przypnij obrazek do pulpitu @@ -844,53 +844,53 @@ Spacja, aby pokazać panel boczny. QObject - + Save Error Błąd zapisu - - + + Capture saved as Zaznaczenie zapisano jako - + Capture saved to clipboard Zrzut skopiowano do schowka - - + + Error trying to save as Błąd przy próbie zapisu jako - + Save screenshot - + Capture saved and copied to the clipboard as - - - - - + + + + + Unable to connect via DBus Nie udało się połączyć za pomocą DBus - + Error Błąd - + Unable to write in Nie można zapisać w @@ -900,73 +900,73 @@ Spacja, aby pokazać panel boczny. URL skopiowany do schowka. - + Hi, I'm already running! You can find me in the system tray. - + Hello, I'm here! Click icon in the tray to take a screenshot or click with a right button to see more options. - + Resize selection right 1px - + Resize selection left 1px - + Resize selection up 1px - + Resize selection down 1px - + Toggle side panel - + Move selection left 1px - + Move selection right 1px - + Move selection up 1px - + Move selection down 1px - + Quit capture Zakończ przechwytywanie - + Screenshot history - + Capture screen @@ -975,12 +975,12 @@ You can find me in the system tray. Przesuń zaznaczenie o 1px - + Show color picker Pokaż próbnik kolorów - + Change the tool's thickness Zmień grubość narzędzia @@ -988,12 +988,12 @@ You can find me in the system tray. RectangleTool - + Rectangle Prostokąt - + Set the Rectangle as the paint tool Ustawia prostokąt jako narzędzie do rysowania @@ -1001,12 +1001,12 @@ You can find me in the system tray. RedoTool - + Redo Cofnij - + Redo the next modification @@ -1014,12 +1014,12 @@ You can find me in the system tray. SaveTool - + Save Zapisz - + Save the capture Zapisz zaznaczenie @@ -1027,7 +1027,7 @@ You can find me in the system tray. ScreenGrabber - + Unable to capture screen Nie można przechwycić ekranu @@ -1035,12 +1035,12 @@ You can find me in the system tray. SelectionTool - + Rectangular Selection Zaznaczenie prostokątne - + Set Selection as the paint tool Ustawia zaznaczenie prostokątne jako narzędzie do rysowania @@ -1048,17 +1048,17 @@ You can find me in the system tray. SetShortcutDialog - + Set Shortcut - + Enter new shortcut to change - + Press Esc to cancel or Backspace to disable the keyboard shortcut. @@ -1066,22 +1066,22 @@ You can find me in the system tray. ShortcutsWidget - + Hot Keys - + Available shortcuts in the screen capture mode. Dostępne skróty w trybie przechwytywania obrazu. - + Description Działanie - + Key Klawisz @@ -1089,22 +1089,22 @@ You can find me in the system tray. SidePanelWidget - + Active thickness: - + Active color: Aktywny kolor: - + Press ESC to cancel Wciśnij ESC, aby anulować - + Grab Color Pobierz kolor @@ -1112,12 +1112,12 @@ You can find me in the system tray. SizeIndicatorTool - + Selection Size Indicator Miernik zaznaczenia - + Show the dimensions of the selection (X Y) Pokazuje wymiary zaznaczenia (X Y) @@ -1125,107 +1125,107 @@ You can find me in the system tray. StrftimeChooserWidget - + Century (00-99) Wiek (00-99) - + Year (00-99) Rok (00-99) - + Year (2000) Rok (2000) - + Month Name (jan) Nazwa miesiąca (cze) - + Month Name (january) Nazwa miesiąca (czerwiec) - + Month (01-12) Miesiąc (01-12) - + Week Day (1-7) Dzień tygodnia (1-7) - + Week (01-53) Tydzień (01-53) - + Day Name (mon) Nazwa dniaa (pią) - + Day Name (monday) Nazwa dnia (piątek) - + Day (01-31) Dzień (01-31) - + Day of Month (1-31) Dzień miesiąca (1-31) - + Day (001-366) Dzień (001-366) - + Time (%H-%M-%S) Czas (%H-%M-%S) - + Time (%H-%M) Czas (%H-%M) - + Hour (00-23) Godzina (00-23) - + Hour (01-12) Godzina (01-12) - + Minute (00-59) Minuta (00-59) - + Second (00-59) Sekunda (00-59) - + Full Date (%m/%d/%y) Data (%m/%d/%y) - + Full Date (%Y-%m-%d) Data (%Y-%m-%d) @@ -1233,7 +1233,7 @@ You can find me in the system tray. SystemNotification - + Flameshot Info Flameshot Info @@ -1241,22 +1241,22 @@ You can find me in the system tray. TextConfig - + StrikeOut Przekreślenie - + Underline Podkreślenie - + Bold Pogrubienie - + Italic Kursywa @@ -1264,12 +1264,12 @@ You can find me in the system tray. TextTool - + Text Tekst - + Add text to your capture Dodaje tekst do zrzutu @@ -1277,37 +1277,37 @@ You can find me in the system tray. UIcolorEditor - + UI Color Editor Edytor kolorów interfejsu - + Change the color moving the selectors and see the changes in the preview buttons. Zmień kolor przesuwając selektory i obserwując podgląd przycisków. - + Select a Button to modify it Wybierz przycisk do zmodyfikowania - + Main Color Kolor główny - + Click on this button to set the edition mode of the main color. Kliknij na przycisk aby móc modyfikować kolor główny. - + Contrast Color Kolor kontrastowy - + Click on this button to set the edition mode of the contrast color. Kliknij na przycisk aby móc modyfikować kolor kontrastowy. @@ -1315,12 +1315,12 @@ You can find me in the system tray. UndoTool - + Undo Cofnij - + Undo the last modification Cofnij ostatnią zmianę @@ -1328,7 +1328,7 @@ You can find me in the system tray. UtilityPanel - + Hide @@ -1336,17 +1336,17 @@ You can find me in the system tray. VisualsEditor - + Opacity of area outside selection: Przezroczystość obszaru poza zaznaczeniem: - + Button Selection Wybór przycisków - + Select All Wybierz wszystkie diff --git a/translations/Internationalization_pt_br.ts b/translations/Internationalization_pt_br.ts index 5e7cac62..42683eb5 100644 --- a/translations/Internationalization_pt_br.ts +++ b/translations/Internationalization_pt_br.ts @@ -4,12 +4,12 @@ AppLauncher - + App Launcher App Launcher - + Choose an app to open the capture Escolha uma aplicação para abrir a captura @@ -32,18 +32,18 @@ Manter aberto após seleção - - + + Error Erro - + Unable to write in Não é possível escrever em - + Unable to launch in terminal. Não foi possível abrir no terminal. @@ -51,12 +51,12 @@ ArrowTool - + Arrow Flecha - + Set the Arrow as the paint tool Usa a Flecha como ferramenta de desenho @@ -64,12 +64,12 @@ BlurTool - + Blur Desfoque - + Set Blur as the paint tool Usa o Desfoque como ferramenta de desenho @@ -77,47 +77,47 @@ CaptureLauncher - + <b>Capture Mode</b> - + Rectangular Region - + Full Screen (All Monitors) - + No Delay - + second - + seconds - + Take new screenshot - + Area: - + Delay: @@ -146,12 +146,12 @@ Pressione espaço abrir o painel lateral. CircleTool - + Circle Círculo - + Set the Circle as the paint tool Usa o Círculo como ferramenta de desenho @@ -187,32 +187,32 @@ Pressione espaço abrir o painel lateral. Controller - + &Take Screenshot &Tirar Screenshot - + &Open Launcher - + &Configuration &Configuração - + &Information &Informações - + &Quit &Sair - + &Latest Uploads @@ -220,12 +220,12 @@ Pressione espaço abrir o painel lateral. CopyTool - + Copy Copiar - + Copy the selection into the clipboard Copia a seleção para o clipboard @@ -233,7 +233,7 @@ Pressione espaço abrir o painel lateral. DBusUtils - + Unable to connect via DBus Não foi possível conectar via DBus @@ -241,12 +241,12 @@ Pressione espaço abrir o painel lateral. ExitTool - + Exit Sair - + Leave the capture screen Sair da ferramenta de captura @@ -254,47 +254,47 @@ Pressione espaço abrir o painel lateral. FileNameEditor - + Edit the name of your captures: Edite o nome das suas capturas: - + Edit: Editar: - + Preview: Preview: - + Save Salvar - + Saves the pattern Salva o padrão - + Reset Reiniciar - + Restores the saved pattern Restaura o padrão salvo - + Clear Limpar - + Deletes the name Deleta o nome @@ -302,27 +302,27 @@ Pressione espaço abrir o painel lateral. FilePathConfiguration - + Screenshot path default: - + Use fixed path for screenshots to save - + Browse - + Clear Limpar - + Select default path for Screenshots @@ -580,12 +580,12 @@ Pressione espaço abrir o painel lateral. ImgS3UploaderTool - + Image Uploader Uploader de imagens - + Upload the selection to S3 bucket @@ -693,12 +693,12 @@ Pressione espaço abrir o painel lateral. ImgurUploaderTool - + Image Uploader Uploader de imagens - + Upload the selection to Imgur Upa a seleção no Imgur @@ -706,7 +706,7 @@ Pressione espaço abrir o painel lateral. InfoWindow - + About Sobre @@ -763,12 +763,12 @@ Pressione espaço abrir o painel lateral. Descrição - + <u><b>License</b></u> <u><b>Licença</b></u> - + <u><b>Version</b></u> <u><b>Versão</b></u> @@ -780,12 +780,12 @@ Pressione espaço abrir o painel lateral. LineTool - + Line Linha - + Set the Line as the paint tool Usa a Linha como ferramenta de desenho @@ -793,12 +793,12 @@ Pressione espaço abrir o painel lateral. MarkerTool - + Marker Marcador - + Set the Marker as the paint tool Usa o marcador como ferramenta de desenho @@ -806,12 +806,12 @@ Pressione espaço abrir o painel lateral. MoveTool - + Move Mover - + Move the selection area Move a área de seleção @@ -819,12 +819,12 @@ Pressione espaço abrir o painel lateral. PencilTool - + Pencil Pincel - + Set the Pencil as the paint tool Usa o Lápis como ferramenta de desenho @@ -832,12 +832,12 @@ Pressione espaço abrir o painel lateral. PinTool - + Pin Tool Ferramenta de Pin - + Pin image on the desktop Pinnar imagem no desktop @@ -845,53 +845,53 @@ Pressione espaço abrir o painel lateral. QObject - + Save Error Salvar erro - - + + Capture saved as Captura salva como - + Capture saved to clipboard Captura salva no clipboard - - + + Error trying to save as Erro tentando salvar como - + Save screenshot - + Capture saved and copied to the clipboard as - - - - - + + + + + Unable to connect via DBus Não foi possível conectar via DBus - + Error Erro - + Unable to write in Não foi possível escrever em @@ -901,73 +901,73 @@ Pressione espaço abrir o painel lateral. URL copiada para o clipboard. - + Hi, I'm already running! You can find me in the system tray. - + Hello, I'm here! Click icon in the tray to take a screenshot or click with a right button to see more options. - + Resize selection right 1px - + Resize selection left 1px - + Resize selection up 1px - + Resize selection down 1px - + Toggle side panel - + Move selection left 1px - + Move selection right 1px - + Move selection up 1px - + Move selection down 1px - + Quit capture Sair da captura - + Screenshot history - + Capture screen @@ -976,12 +976,12 @@ You can find me in the system tray. Move a seleção em 1px - + Show color picker Mostra seletor de cores - + Change the tool's thickness Muda a grossura do pincel @@ -989,12 +989,12 @@ You can find me in the system tray. RectangleTool - + Rectangle Retângulo - + Set the Rectangle as the paint tool Seta o Retângulo como ferramenta de desenho @@ -1002,12 +1002,12 @@ You can find me in the system tray. RedoTool - + Redo Refazer - + Redo the next modification Refazer última modificação @@ -1015,12 +1015,12 @@ You can find me in the system tray. SaveTool - + Save Salvar - + Save the capture Salva a captura @@ -1028,7 +1028,7 @@ You can find me in the system tray. ScreenGrabber - + Unable to capture screen Não foi possível capturar a tela @@ -1036,12 +1036,12 @@ You can find me in the system tray. SelectionTool - + Rectangular Selection Seleção Retangular - + Set Selection as the paint tool Estabelece o Selecionador como ferramenta de desenho @@ -1049,17 +1049,17 @@ You can find me in the system tray. SetShortcutDialog - + Set Shortcut - + Enter new shortcut to change - + Press Esc to cancel or Backspace to disable the keyboard shortcut. @@ -1067,22 +1067,22 @@ You can find me in the system tray. ShortcutsWidget - + Hot Keys - + Available shortcuts in the screen capture mode. Atalhos disponívels na tela de captura. - + Description Descrição - + Key Tecla @@ -1090,22 +1090,22 @@ You can find me in the system tray. SidePanelWidget - + Active thickness: - + Active color: Cor ativa: - + Press ESC to cancel Presione Esc para cancelar - + Grab Color Usar Cor @@ -1113,12 +1113,12 @@ You can find me in the system tray. SizeIndicatorTool - + Selection Size Indicator Indicador do Tamanho da Seleção - + Show the dimensions of the selection (X Y) Mostra a dimensão da seleção (X Y) @@ -1126,107 +1126,107 @@ You can find me in the system tray. StrftimeChooserWidget - + Century (00-99) Século (00-99) - + Year (00-99) Ano (00-99) - + Year (2000) Ano (2000) - + Month Name (jan) Nome do mês (jan) - + Month Name (january) Nome do mês (janeiro) - + Month (01-12) Mês (01-12) - + Week Day (1-7) Dia da semana (1-7) - + Week (01-53) Semana (01-53) - + Day Name (mon) Nome do dia (seg) - + Day Name (monday) Nome do dia (segunda) - + Day (01-31) Dia (01-31) - + Day of Month (1-31) Dia do Mês (1-31) - + Day (001-366) Dia (001-366) - + Time (%H-%M-%S) Tempo (%H-%M-%S) - + Time (%H-%M) Tempo (%H-%M) - + Hour (00-23) Hora (00-23) - + Hour (01-12) Hora (01-12) - + Minute (00-59) Minuto (00-59) - + Second (00-59) Segundo (00-59) - + Full Date (%m/%d/%y) Data Completa (%m/%d/%y) - + Full Date (%Y-%m-%d) Data Completa (%Y-%m-%d) @@ -1234,7 +1234,7 @@ You can find me in the system tray. SystemNotification - + Flameshot Info Informações do Flameshot @@ -1242,22 +1242,22 @@ You can find me in the system tray. TextConfig - + StrikeOut Sobrescrito - + Underline Sublinhado - + Bold Negrito - + Italic Itálico @@ -1265,12 +1265,12 @@ You can find me in the system tray. TextTool - + Text Texto - + Add text to your capture Adicionar texto à captura @@ -1278,37 +1278,37 @@ You can find me in the system tray. UIcolorEditor - + UI Color Editor Interface de Edição de Cores - + Change the color moving the selectors and see the changes in the preview buttons. Modifique a cor movendo os seletores e veja as mudanças nos botões de preview. - + Select a Button to modify it Selecione um botão para modificá-lo - + Main Color Cor Principal - + Click on this button to set the edition mode of the main color. Clique neste botão para setar o modo de edição da cor principal. - + Contrast Color Cor de Contraste - + Click on this button to set the edition mode of the contrast color. Clique neste botão para setar o modo de edição da cor de contraste. @@ -1316,12 +1316,12 @@ You can find me in the system tray. UndoTool - + Undo Desfazer - + Undo the last modification Desfaz a última modificação @@ -1329,7 +1329,7 @@ You can find me in the system tray. UtilityPanel - + Hide @@ -1337,17 +1337,17 @@ You can find me in the system tray. VisualsEditor - + Opacity of area outside selection: Opacidade da área de seleção: - + Button Selection Botão de seleção - + Select All Selecionar Todos diff --git a/translations/Internationalization_ru.ts b/translations/Internationalization_ru.ts index fba7380c..f5c374f9 100644 --- a/translations/Internationalization_ru.ts +++ b/translations/Internationalization_ru.ts @@ -4,12 +4,12 @@ AppLauncher - + App Launcher Запуск приложения - + Choose an app to open the capture Выберите приложение, которым открыть снимок @@ -32,18 +32,18 @@ Оставить запущенным после выделения - - + + Error Ошибка - + Unable to write in Не удалось сохранить - + Unable to launch in terminal. Не удалось запустить в терминале. @@ -51,12 +51,12 @@ ArrowTool - + Arrow Стрелка - + Set the Arrow as the paint tool Выбрать Стрелку инструментом для рисования @@ -64,12 +64,12 @@ BlurTool - + Blur Размытие - + Set Blur as the paint tool Выбрать Размытие инструментом для рисования @@ -77,47 +77,47 @@ CaptureLauncher - + <b>Capture Mode</b> <b>Режим захвата</b> - + Rectangular Region Квадратная область - + Full Screen (All Monitors) Весь экран (все мониторы) - + No Delay Без задержки - + second секунда - + seconds секунд - + Take new screenshot Сделать скриншот - + Area: Область: - + Delay: Задержка: @@ -146,12 +146,12 @@ Press Space to open the side panel. CircleTool - + Circle Окружность - + Set the Circle as the paint tool Выбрать Окружность инструментом для рисования @@ -191,32 +191,32 @@ Press Space to open the side panel. Controller - + &Take Screenshot &Сделать снимок - + &Open Launcher &Открыть - + &Configuration &Настройка - + &Information &Информация - + &Quit &Выход - + &Latest Uploads Последние загрузки @@ -232,12 +232,12 @@ Press Space to open the side panel. CopyTool - + Copy Скопировать - + Copy the selection into the clipboard Скопировать выделение в буфер обмена @@ -245,7 +245,7 @@ Press Space to open the side panel. DBusUtils - + Unable to connect via DBus Не удалось подключиться через DBus @@ -253,12 +253,12 @@ Press Space to open the side panel. ExitTool - + Exit Выход - + Leave the capture screen Покинуть захват экрана @@ -266,47 +266,47 @@ Press Space to open the side panel. FileNameEditor - + Edit the name of your captures: Отредактируйте имя ваших снимков: - + Edit: Шаблон: - + Preview: Предпросмотр: - + Save Сохранить - + Saves the pattern Сохранить шаблон - + Reset Сбросить - + Restores the saved pattern Восстанавливает сохраненный шаблон - + Clear Очистить - + Deletes the name Удаляет имя @@ -314,27 +314,27 @@ Press Space to open the side panel. FilePathConfiguration - + Screenshot path default: Путь скриншотов по умолчанию - + Use fixed path for screenshots to save Использовать фиксированный путь для скриншотов - + Browse Обзор - + Clear Очистить - + Select default path for Screenshots Выбрать путь по умлочанию для скриншотов @@ -608,12 +608,12 @@ Press Space to open the side panel. ImgS3UploaderTool - + Image Uploader Отправка изображений - + Upload the selection to S3 bucket Загрузить выделение на S3 @@ -725,12 +725,12 @@ Press Space to open the side panel. ImgurUploaderTool - + Image Uploader Отправка изображений - + Upload the selection to Imgur Загрузить выделение на Imgur @@ -738,7 +738,7 @@ Press Space to open the side panel. InfoWindow - + About Информация @@ -811,12 +811,12 @@ Press Space to open the side panel. Описание - + <u><b>License</b></u> <u><b>Лицензия</b></u> - + <u><b>Version</b></u> <u><b>Версия</b></u> @@ -828,12 +828,12 @@ Press Space to open the side panel. LineTool - + Line Линия - + Set the Line as the paint tool Выбрать Линию инструментом для рисования @@ -841,12 +841,12 @@ Press Space to open the side panel. MarkerTool - + Marker Маркер - + Set the Marker as the paint tool Выбрать Маркер инструментом для рисования @@ -854,12 +854,12 @@ Press Space to open the side panel. MoveTool - + Move Перемещение - + Move the selection area Выбрать Перемещение инструментом для рисования @@ -867,12 +867,12 @@ Press Space to open the side panel. PencilTool - + Pencil Карандаш - + Set the Pencil as the paint tool Выбрать Карандаш инструментом для рисования @@ -880,12 +880,12 @@ Press Space to open the side panel. PinTool - + Pin Tool Булавка - + Pin image on the desktop Прикрепить изображение к рабочему столу @@ -893,53 +893,53 @@ Press Space to open the side panel. QObject - + Save Error Ошибка сохранения - - + + Capture saved as Снимок сохранён как - + Capture saved to clipboard Снимок сохранён в буфер обмена - - + + Error trying to save as Ошибка при попытке сохранить как - + Save screenshot Сохранить скриншот - + Capture saved and copied to the clipboard as Файл сохранен и путь к нему скопирован как - - - - - + + + + + Unable to connect via DBus Не удалось подключиться через DBus - + Error Ошибка - + Unable to write in Не удалось сохранить @@ -953,73 +953,73 @@ Press Space to open the side panel. Файл удален с S3 - + Hi, I'm already running! You can find me in the system tray. Привет, а я уже работаю!\nВы можете найти меня в системном трэе. - + Hello, I'm here! Click icon in the tray to take a screenshot or click with a right button to see more options. Привет я тут! Щелкните значок на панели задач, чтобы сделать снимок экрана, или щелкните правой кнопкой, чтобы увидеть дополнительные параметры. - + Resize selection right 1px Изменить размер выделения вправо на 1 пиксель - + Resize selection left 1px Изменить размер выделения влево на 1 пиксель - + Resize selection up 1px Изменить размер выделения вверх на 1 пиксель - + Resize selection down 1px Изменить размер выделения вниз на 1 пиксель - + Toggle side panel Вызвать боковую панель - + Move selection left 1px Переместить выделение влево на 1 пиксель - + Move selection right 1px Переместить выделение вправо на 1 пиксель - + Move selection up 1px Переместить выделение вверх на 1 пиксель - + Move selection down 1px Переместить выделение вниз на 1 пиксель - + Quit capture Выйти из захвата экрана - + Screenshot history История скриншотов - + Capture screen Захватить экран @@ -1028,12 +1028,12 @@ You can find me in the system tray. Переместить выделение на 1px - + Show color picker Показать выбор цвета - + Change the tool's thickness Изменить толщину инструмента @@ -1041,12 +1041,12 @@ You can find me in the system tray. RectangleTool - + Rectangle Прямоугольник - + Set the Rectangle as the paint tool Выбрать Прямоугольник инструментом для рисования @@ -1054,12 +1054,12 @@ You can find me in the system tray. RedoTool - + Redo Повторить - + Redo the next modification Повторить последнее изменение @@ -1067,12 +1067,12 @@ You can find me in the system tray. SaveTool - + Save Сохранить - + Save the capture Сохранить снимок @@ -1080,7 +1080,7 @@ You can find me in the system tray. ScreenGrabber - + Unable to capture screen Не удалось захватить экран @@ -1088,12 +1088,12 @@ You can find me in the system tray. SelectionTool - + Rectangular Selection Прямоугольное выделение - + Set Selection as the paint tool Выбрать Прямоугольное выделение инструментом для рисования @@ -1101,17 +1101,17 @@ You can find me in the system tray. SetShortcutDialog - + Set Shortcut Выбрать горячую клавишу - + Enter new shortcut to change Выберите новую горячую клавишу - + Press Esc to cancel or Backspace to disable the keyboard shortcut. Нажмите Esc для отмены или Backspace для удаления горячей клавиши @@ -1119,22 +1119,22 @@ You can find me in the system tray. ShortcutsWidget - + Hot Keys Горячие клавиши - + Available shortcuts in the screen capture mode. Доступные горячие клавиши в режиме захвата экрана. - + Description Описание - + Key Клавиша @@ -1142,22 +1142,22 @@ You can find me in the system tray. SidePanelWidget - + Active thickness: Активная толщина: - + Active color: Активный цвет: - + Press ESC to cancel Нажмите Esc для отмены - + Grab Color Захватить цвет с экрана @@ -1165,12 +1165,12 @@ You can find me in the system tray. SizeIndicatorTool - + Selection Size Indicator Индикатор размера выделения - + Show the dimensions of the selection (X Y) Показывает размер выделения (X Y) @@ -1178,107 +1178,107 @@ You can find me in the system tray. StrftimeChooserWidget - + Century (00-99) Век (00-99) - + Year (00-99) Год (00-99) - + Year (2000) Год (2000) - + Month Name (jan) Название месяца (янв) - + Month Name (january) Название месяца (январь) - + Month (01-12) Месяц (01-12) - + Week Day (1-7) День недели (1-7) - + Week (01-53) Неделя (01-53) - + Day Name (mon) День недели (пн) - + Day Name (monday) День недели (понедельник) - + Day (01-31) День (01-31) - + Day of Month (1-31) День месяца (1-31) - + Day (001-366) День (001-366) - + Time (%H-%M-%S) Время (%H-%M-%S) - + Time (%H-%M) Время (%H-%M) - + Hour (00-23) Час (00-23) - + Hour (01-12) Час (01-12) - + Minute (00-59) Минута (00-59) - + Second (00-59) Секунда (00-59) - + Full Date (%m/%d/%y) Полная дата (%m/%d/%y) - + Full Date (%Y-%m-%d) Полная дата (%Y-%m-%d) @@ -1286,7 +1286,7 @@ You can find me in the system tray. SystemNotification - + Flameshot Info Flameshot Инфо @@ -1294,22 +1294,22 @@ You can find me in the system tray. TextConfig - + StrikeOut Зачеркнутый - + Underline Подчеркнутый - + Bold Полужирный - + Italic Курсив @@ -1317,12 +1317,12 @@ You can find me in the system tray. TextTool - + Text Текст - + Add text to your capture Добавить текст на снимок @@ -1330,37 +1330,37 @@ You can find me in the system tray. UIcolorEditor - + UI Color Editor Редактор цвета интерфейса - + Change the color moving the selectors and see the changes in the preview buttons. Измените цвет, перемещая выделение, и посмотрите изменения в кнопках предварительного просмотра. - + Select a Button to modify it Выберите кнопку, чтобы изменить ее - + Main Color Основной цвет - + Click on this button to set the edition mode of the main color. Нажмите на эту кнопку, чтобы перейти в режим редактирования основного цвета. - + Contrast Color Контрастный цвет - + Click on this button to set the edition mode of the contrast color. Нажмите на эту кнопку, чтобы перейти в режим редактирования контрастного цвета. @@ -1368,12 +1368,12 @@ You can find me in the system tray. UndoTool - + Undo Отменить - + Undo the last modification Отменить последнее изменение @@ -1381,7 +1381,7 @@ You can find me in the system tray. UtilityPanel - + Hide Спрятать @@ -1389,17 +1389,17 @@ You can find me in the system tray. VisualsEditor - + Opacity of area outside selection: Затемнение невыделенной области: - + Button Selection Выбор кнопок - + Select All Выбрать все diff --git a/translations/Internationalization_sk.ts b/translations/Internationalization_sk.ts index 3004419f..0b3c057d 100644 --- a/translations/Internationalization_sk.ts +++ b/translations/Internationalization_sk.ts @@ -4,12 +4,12 @@ AppLauncher - + App Launcher Spúšťač aplikácií - + Choose an app to open the capture Vyberte aplikáciu na otvorenie snímky obrazovky @@ -32,18 +32,18 @@ Nechať otvorené po výbere - - + + Error Chyba - + Unable to write in Zlyhal zápis do - + Unable to launch in terminal. Nepodarilo sa spustiť v termináli. @@ -51,12 +51,12 @@ ArrowTool - + Arrow Šípka - + Set the Arrow as the paint tool Nastaviť Šípku ako nástroj pre úpravy @@ -64,12 +64,12 @@ BlurTool - + Blur Rozmazanie - + Set Blur as the paint tool Nastaviť Rozmazanie ako nástroj pre úpravy @@ -77,47 +77,47 @@ CaptureLauncher - + <b>Capture Mode</b> <b>Režim zachytávania</b> - + Rectangular Region Pravouhlá oblasť - + Full Screen (All Monitors) Celá obrazovka (všetky monitory) - + No Delay Bez oneskorenia - + second sekunda - + seconds sekundy - + Take new screenshot Urobiť novú snímku - + Area: Oblasť: - + Delay: Oneskorenie: @@ -146,12 +146,12 @@ Stlačte medzerník pre otvorenie postranného panelu. CircleTool - + Circle Kruh - + Set the Circle as the paint tool @@ -187,32 +187,32 @@ Stlačte medzerník pre otvorenie postranného panelu. Controller - + &Take Screenshot &Vytvoriť snímku - + &Open Launcher - + &Configuration &Konfigurácia - + &Information &Informácie - + &Quit &Ukončiť - + &Latest Uploads @@ -220,12 +220,12 @@ Stlačte medzerník pre otvorenie postranného panelu. CopyTool - + Copy Kopírovať - + Copy the selection into the clipboard Kopírovať výber do schránky @@ -233,7 +233,7 @@ Stlačte medzerník pre otvorenie postranného panelu. DBusUtils - + Unable to connect via DBus Nie je možné pripojiť sa prostredníctvom DBus @@ -241,12 +241,12 @@ Stlačte medzerník pre otvorenie postranného panelu. ExitTool - + Exit Ukončiť - + Leave the capture screen Opustiť obrazovku so zachytávaním obrazovky @@ -254,47 +254,47 @@ Stlačte medzerník pre otvorenie postranného panelu. FileNameEditor - + Edit the name of your captures: Upraviť meno vašich snímok obrazovky: - + Edit: Upraviť: - + Preview: Náhľad: - + Save Uložiť - + Saves the pattern Uloží vzor - + Reset Resetovať - + Restores the saved pattern Vráti zmeny - + Clear Vyčistiť - + Deletes the name Vymaže meno @@ -302,27 +302,27 @@ Stlačte medzerník pre otvorenie postranného panelu. FilePathConfiguration - + Screenshot path default: - + Use fixed path for screenshots to save - + Browse - + Clear Vyčistiť - + Select default path for Screenshots @@ -580,12 +580,12 @@ Stlačte medzerník pre otvorenie postranného panelu. ImgS3UploaderTool - + Image Uploader Uploader obrázkov - + Upload the selection to S3 bucket @@ -693,12 +693,12 @@ Stlačte medzerník pre otvorenie postranného panelu. ImgurUploaderTool - + Image Uploader Uploader obrázkov - + Upload the selection to Imgur Nahrať výber na Imgur @@ -706,7 +706,7 @@ Stlačte medzerník pre otvorenie postranného panelu. InfoWindow - + About O programe @@ -771,12 +771,12 @@ Stlačte medzerník pre otvorenie postranného panelu. Popis - + <u><b>License</b></u> <u><b>Licencia</b></u> - + <u><b>Version</b></u> <u><b>Verzia</b></u> @@ -788,12 +788,12 @@ Stlačte medzerník pre otvorenie postranného panelu. LineTool - + Line Čiara - + Set the Line as the paint tool Nastaviť Čiaru ako nástroj pre úpravy @@ -801,12 +801,12 @@ Stlačte medzerník pre otvorenie postranného panelu. MarkerTool - + Marker Fixka - + Set the Marker as the paint tool Nastaviť Fixku ako nástroj pre úpravy @@ -814,12 +814,12 @@ Stlačte medzerník pre otvorenie postranného panelu. MoveTool - + Move Presun - + Move the selection area Presunúť oblasť výberu @@ -827,12 +827,12 @@ Stlačte medzerník pre otvorenie postranného panelu. PencilTool - + Pencil Ceruzka - + Set the Pencil as the paint tool Nastaviť Ceruzku ako nástroj pre úpravy @@ -840,12 +840,12 @@ Stlačte medzerník pre otvorenie postranného panelu. PinTool - + Pin Tool Špendlík - + Pin image on the desktop Pripnúť obrázok na plochu @@ -853,53 +853,53 @@ Stlačte medzerník pre otvorenie postranného panelu. QObject - - - - - + + + + + Unable to connect via DBus Nie je možné pripojiť sa prostredníctvom DBus - + Error Chyba - + Unable to write in Zlyhal zápis do - + Capture saved to clipboard Snímka uložená do schránky - - + + Capture saved as Snímka uložená ako - - + + Error trying to save as Chyba pri ukladaní do - + Save screenshot - + Capture saved and copied to the clipboard as - + Save Error Chyba pri ukladaní @@ -909,73 +909,73 @@ Stlačte medzerník pre otvorenie postranného panelu. URL skopírovaná do schránky. - + Hi, I'm already running! You can find me in the system tray. - + Hello, I'm here! Click icon in the tray to take a screenshot or click with a right button to see more options. - + Resize selection right 1px - + Resize selection left 1px - + Resize selection up 1px - + Resize selection down 1px - + Toggle side panel - + Move selection left 1px - + Move selection right 1px - + Move selection up 1px - + Move selection down 1px - + Quit capture Ukončiť zachytávanie obrazovky - + Screenshot history - + Capture screen @@ -984,12 +984,12 @@ You can find me in the system tray. Presunúť výber o 1 px - + Show color picker Zobraziť dialóg na výber farby - + Change the tool's thickness Zmena hrúbky nástroja @@ -997,12 +997,12 @@ You can find me in the system tray. RectangleTool - + Rectangle Obdĺžnik - + Set the Rectangle as the paint tool Nastaviť Obdĺžnik ako nástroj pre úpravy @@ -1010,12 +1010,12 @@ You can find me in the system tray. RedoTool - + Redo Znova - + Redo the next modification Zopakovať úpravu @@ -1023,12 +1023,12 @@ You can find me in the system tray. SaveTool - + Save Uložiť - + Save the capture Uložiť snímku obrazovky @@ -1036,7 +1036,7 @@ You can find me in the system tray. ScreenGrabber - + Unable to capture screen Nepodarilo sa zachytiť obrazovku @@ -1044,12 +1044,12 @@ You can find me in the system tray. SelectionTool - + Rectangular Selection Obdĺžnikový výber - + Set Selection as the paint tool Nastaviť Výber ako nástroj pre úpravy @@ -1057,17 +1057,17 @@ You can find me in the system tray. SetShortcutDialog - + Set Shortcut - + Enter new shortcut to change - + Press Esc to cancel or Backspace to disable the keyboard shortcut. @@ -1075,22 +1075,22 @@ You can find me in the system tray. ShortcutsWidget - + Hot Keys - + Available shortcuts in the screen capture mode. Dostupné klávesové skratky v režime zachytávania obrazovky. - + Description Popis - + Key Kláves @@ -1098,22 +1098,22 @@ You can find me in the system tray. SidePanelWidget - + Active thickness: Aktívna hrúbka: - + Active color: Aktívna farba: - + Press ESC to cancel Stlačte ESC pre zrušenie - + Grab Color Snímať farbu @@ -1121,12 +1121,12 @@ You can find me in the system tray. SizeIndicatorTool - + Selection Size Indicator Ukazovateľ veľkosti výberu - + Show the dimensions of the selection (X Y) Zobraziť rozmery výberu (X Y) @@ -1134,107 +1134,107 @@ You can find me in the system tray. StrftimeChooserWidget - + Century (00-99) Storočie (00-99) - + Year (00-99) Rok (00-99) - + Year (2000) Rok (2000) - + Month Name (jan) Meno mesiaca (jan) - + Month Name (january) Meno mesiaca (január) - + Month (01-12) Mesiac (01-12) - + Week Day (1-7) Deň v týždni (1-7) - + Week (01-53) Týždeň (01-53) - + Day Name (mon) Meno dňa (pon) - + Day Name (monday) Meno dňa (pondelok) - + Day (01-31) Deň (01-31) - + Day of Month (1-31) Deň v mesiaci (1-31) - + Day (001-366) Deň (001-366) - + Time (%H-%M-%S) Čas (%H-%M-%S) - + Time (%H-%M) Čas (%H-%M) - + Hour (00-23) Hodina (00-23) - + Hour (01-12) Hodina (01-12) - + Minute (00-59) Minúta (00-59) - + Second (00-59) Sekunda (00-59) - + Full Date (%m/%d/%y) Celý dátum (%m/%d/%y) - + Full Date (%Y-%m-%d) Celý dátum (%Y-%m-%d) @@ -1242,7 +1242,7 @@ You can find me in the system tray. SystemNotification - + Flameshot Info Informácie o programe Flameshot @@ -1250,22 +1250,22 @@ You can find me in the system tray. TextConfig - + StrikeOut Preškrtnuté - + Underline Podčiarknuté - + Bold Tučné - + Italic Kurzíva @@ -1273,12 +1273,12 @@ You can find me in the system tray. TextTool - + Text Text - + Add text to your capture Pridať text do snímky @@ -1286,37 +1286,37 @@ You can find me in the system tray. UIcolorEditor - + UI Color Editor Editor farieb interfejsu - + Change the color moving the selectors and see the changes in the preview buttons. Presunom bežcov nastavte farbu a sledujte tieto zmeny v náhľade. - + Select a Button to modify it Kliknite na tlačidlo pre jeho úpravu - + Main Color Hlavná farba - + Click on this button to set the edition mode of the main color. Pre nastavenie hlavnej farby kliknite na toto tlačidlo. - + Contrast Color Kontrastná farba - + Click on this button to set the edition mode of the contrast color. Pre nastavenie kontrastnej farby kliknite na toto tlačidlo. @@ -1324,12 +1324,12 @@ You can find me in the system tray. UndoTool - + Undo Späť - + Undo the last modification Vrátiť poslednú úpravu @@ -1337,7 +1337,7 @@ You can find me in the system tray. UtilityPanel - + Hide @@ -1345,17 +1345,17 @@ You can find me in the system tray. VisualsEditor - + Opacity of area outside selection: Priehľadnosť oblasti mimo výberu: - + Button Selection Výber tlačidiel - + Select All Vybrať všetky diff --git a/translations/Internationalization_sr.ts b/translations/Internationalization_sr.ts index b243f85f..269cb9d6 100644 --- a/translations/Internationalization_sr.ts +++ b/translations/Internationalization_sr.ts @@ -4,12 +4,12 @@ AppLauncher - + App Launcher Покретач - + Choose an app to open the capture Изаберите програм у ком желите да отворите снимак @@ -32,18 +32,18 @@ Остави отворено након избора - - + + Error Грешка - + Unable to write in Нисам успео да сачувам - + Unable to launch in terminal. Нисам успео да покренем у терминалу. @@ -51,12 +51,12 @@ ArrowTool - + Arrow Стрелица - + Set the Arrow as the paint tool Избор цртања стрелице @@ -64,12 +64,12 @@ BlurTool - + Blur Замућење - + Set Blur as the paint tool Избор цртања замућене области @@ -77,47 +77,47 @@ CaptureLauncher - + <b>Capture Mode</b> - + Rectangular Region - + Full Screen (All Monitors) - + No Delay - + second - + seconds - + Take new screenshot - + Area: - + Delay: @@ -146,12 +146,12 @@ Press Space to open the side panel. CircleTool - + Circle Круг - + Set the Circle as the paint tool Избор цртања круга @@ -187,32 +187,32 @@ Press Space to open the side panel. Controller - + &Take Screenshot &Направи снимак екрана - + &Open Launcher - + &Configuration &Подешавања - + &Information Ин&формације - + &Quit &Излаз - + &Latest Uploads @@ -220,12 +220,12 @@ Press Space to open the side panel. CopyTool - + Copy Запамти - + Copy the selection into the clipboard Копира избор у привремену оставу @@ -233,7 +233,7 @@ Press Space to open the side panel. DBusUtils - + Unable to connect via DBus Нисам успео да се повежем кроз DBus @@ -241,12 +241,12 @@ Press Space to open the side panel. ExitTool - + Exit Излаз - + Leave the capture screen Напусти екран за снимање @@ -254,47 +254,47 @@ Press Space to open the side panel. FileNameEditor - + Edit the name of your captures: Уређивање имена снимака: - + Edit: Уређивање: - + Preview: Преглед: - + Save Сачувај - + Saves the pattern Сачувај шаблон - + Reset Ресетуј - + Restores the saved pattern Поврати сачувани шаблон - + Clear Очисти - + Deletes the name Брише име @@ -302,27 +302,27 @@ Press Space to open the side panel. FilePathConfiguration - + Screenshot path default: - + Use fixed path for screenshots to save - + Browse - + Clear Очисти - + Select default path for Screenshots @@ -580,12 +580,12 @@ Press Space to open the side panel. ImgS3UploaderTool - + Image Uploader Објављивање слике - + Upload the selection to S3 bucket @@ -693,12 +693,12 @@ Press Space to open the side panel. ImgurUploaderTool - + Image Uploader Објављивање слике - + Upload the selection to Imgur Објави избор на Imgur сајту @@ -706,7 +706,7 @@ Press Space to open the side panel. InfoWindow - + About О програму @@ -763,12 +763,12 @@ Press Space to open the side panel. Опис - + <u><b>License</b></u> <u><b>Лиценца</b></u> - + <u><b>Version</b></u> <u><b>Верзија</b></u> @@ -780,12 +780,12 @@ Press Space to open the side panel. LineTool - + Line Линија - + Set the Line as the paint tool Избор цртања линије @@ -793,12 +793,12 @@ Press Space to open the side panel. MarkerTool - + Marker Маркер - + Set the Marker as the paint tool Избор цртања маркером @@ -806,12 +806,12 @@ Press Space to open the side panel. MoveTool - + Move Премештање - + Move the selection area Премешта изабрану област @@ -819,12 +819,12 @@ Press Space to open the side panel. PencilTool - + Pencil Оловка - + Set the Pencil as the paint tool Избор цртања оловком @@ -832,12 +832,12 @@ Press Space to open the side panel. PinTool - + Pin Tool Закачка - + Pin image on the desktop Закачи слику за радну површину @@ -845,53 +845,53 @@ Press Space to open the side panel. QObject - + Save Error Грешка приликом упусивања - - + + Capture saved as Сачувај снимак као - + Capture saved to clipboard Снимак је сачуван у привремену меморију - - + + Error trying to save as Грешка приликом уписивања као - + Save screenshot - + Capture saved and copied to the clipboard as - - - - - + + + + + Unable to connect via DBus Нисам успео да се повежем кроз DBus - + Error Грешка - + Unable to write in Нисам успео са сачувам @@ -901,73 +901,73 @@ Press Space to open the side panel. Интернет адреса је сачувана у привременој меморији. - + Hi, I'm already running! You can find me in the system tray. - + Hello, I'm here! Click icon in the tray to take a screenshot or click with a right button to see more options. - + Resize selection right 1px - + Resize selection left 1px - + Resize selection up 1px - + Resize selection down 1px - + Toggle side panel - + Move selection left 1px - + Move selection right 1px - + Move selection up 1px - + Move selection down 1px - + Quit capture Излаз из снимача екрана - + Screenshot history - + Capture screen @@ -976,12 +976,12 @@ You can find me in the system tray. Помери избор за 1px - + Show color picker Прикажи избор боје - + Change the tool's thickness Измени дебљину линије алата @@ -989,12 +989,12 @@ You can find me in the system tray. RectangleTool - + Rectangle Правоугаоник - + Set the Rectangle as the paint tool Избор цртања обојеног правоугаоника @@ -1002,12 +1002,12 @@ You can find me in the system tray. RedoTool - + Redo Понови - + Redo the next modification Понови поништену измену @@ -1015,13 +1015,13 @@ You can find me in the system tray. SaveTool - + Save Сачувај Сохранить - + Save the capture Сачувај снимак @@ -1029,7 +1029,7 @@ You can find me in the system tray. ScreenGrabber - + Unable to capture screen Нисам успео да снимим екран @@ -1037,12 +1037,12 @@ You can find me in the system tray. SelectionTool - + Rectangular Selection Правоугаони оквир - + Set Selection as the paint tool Избор цртања правоугаоног оквира @@ -1050,17 +1050,17 @@ You can find me in the system tray. SetShortcutDialog - + Set Shortcut - + Enter new shortcut to change - + Press Esc to cancel or Backspace to disable the keyboard shortcut. @@ -1068,22 +1068,22 @@ You can find me in the system tray. ShortcutsWidget - + Hot Keys - + Available shortcuts in the screen capture mode. Доступне пречице у моду снимка екрана. - + Description Опис - + Key Тастер @@ -1091,22 +1091,22 @@ You can find me in the system tray. SidePanelWidget - + Active thickness: - + Active color: Активна боја: - + Press ESC to cancel Притисните ESC за прекид - + Grab Color Преузмите боју @@ -1114,12 +1114,12 @@ You can find me in the system tray. SizeIndicatorTool - + Selection Size Indicator Приказ величине избора - + Show the dimensions of the selection (X Y) Приказује величину избора (X Y) @@ -1127,107 +1127,107 @@ You can find me in the system tray. StrftimeChooserWidget - + Century (00-99) Век (00-99) - + Year (00-99) Година (00-99) - + Year (2000) Година (2000) - + Month Name (jan) Име месеца (јан) - + Month Name (january) Име месеца (јануар) - + Month (01-12) Месец (01-12) - + Week Day (1-7) Дани у недељи (1-7) - + Week (01-53) Недеља (01-53) - + Day Name (mon) Дан у недељи (пон) - + Day Name (monday) Дан у недељи (понедељак) - + Day (01-31) Дан (01-31) - + Day of Month (1-31) Дан месеца (1-31) - + Day (001-366) Дан (001-366) - + Time (%H-%M-%S) Време (%H-%M-%S) - + Time (%H-%M) Време (%H-%M) - + Hour (00-23) Сат (00-23) - + Hour (01-12) Сат (01-12) - + Minute (00-59) Минута (00-59) - + Second (00-59) Секунда (00-59) - + Full Date (%m/%d/%y) Комплетан датум (%m/%d/%y) - + Full Date (%Y-%m-%d) Комплетан датум (%Y-%m-%d) @@ -1235,7 +1235,7 @@ You can find me in the system tray. SystemNotification - + Flameshot Info Информације о Flameshot-у @@ -1243,22 +1243,22 @@ You can find me in the system tray. TextConfig - + StrikeOut Прецртано - + Underline Подвучено - + Bold Задебљано - + Italic Накошено @@ -1266,12 +1266,12 @@ You can find me in the system tray. TextTool - + Text Текст - + Add text to your capture Додаје текст на снимак @@ -1279,37 +1279,37 @@ You can find me in the system tray. UIcolorEditor - + UI Color Editor Уређивање боје сучеља - + Change the color moving the selectors and see the changes in the preview buttons. Измените боју померањем изборника и видите резултат у прегледу дугмића. - + Select a Button to modify it Изаберите дугме да би га изменили - + Main Color Основна боја - + Click on this button to set the edition mode of the main color. Кликните на дугме да би прешли у режим уређивања основне боје. - + Contrast Color Боја контраста - + Click on this button to set the edition mode of the contrast color. Кликните на дугме да би прешли у режим уређивања боје контраста. @@ -1317,12 +1317,12 @@ You can find me in the system tray. UndoTool - + Undo Поништи - + Undo the last modification Поништи последњу измену @@ -1330,7 +1330,7 @@ You can find me in the system tray. UtilityPanel - + Hide @@ -1338,17 +1338,17 @@ You can find me in the system tray. VisualsEditor - + Opacity of area outside selection: Провидност подручја ван избора: - + Button Selection Избор дугмића - + Select All Изабери све diff --git a/translations/Internationalization_tr.ts b/translations/Internationalization_tr.ts index 07dbd013..aea50b5f 100644 --- a/translations/Internationalization_tr.ts +++ b/translations/Internationalization_tr.ts @@ -4,12 +4,12 @@ AppLauncher - + App Launcher Uygulama Başlatıcı - + Choose an app to open the capture Yakalamayı açmak için bir uygulama seçin @@ -32,18 +32,18 @@ Seçimden sonra açık tutun - - + + Error Hata - + Unable to write in Yazma mümkün değil - + Unable to launch in terminal. Terminalde başlatılamadı. @@ -51,12 +51,12 @@ ArrowTool - + Arrow Ok - + Set the Arrow as the paint tool Oku çizim aracı olarak ayarlar @@ -64,12 +64,12 @@ BlurTool - + Blur Bulanıklık - + Set Blur as the paint tool Bulnıklığı boyama aracı olarak ayarlar @@ -77,47 +77,47 @@ CaptureLauncher - + <b>Capture Mode</b> - + Rectangular Region - + Full Screen (All Monitors) - + No Delay - + second - + seconds - + Take new screenshot - + Area: - + Delay: @@ -146,12 +146,12 @@ Yan paneli açmak için Boşluk tuşuna basın. CircleTool - + Circle Çember - + Set the Circle as the paint tool Çemberi boyama aracı olarak ayarlar @@ -187,32 +187,32 @@ Yan paneli açmak için Boşluk tuşuna basın. Controller - + &Take Screenshot &Ekran Resmi Al - + &Open Launcher - + &Configuration &Ayarlar - + &Information &Bilgi - + &Quit &Çıkış - + &Latest Uploads @@ -220,12 +220,12 @@ Yan paneli açmak için Boşluk tuşuna basın. CopyTool - + Copy Kopyala - + Copy the selection into the clipboard Seçimi panoya kopyalar @@ -233,7 +233,7 @@ Yan paneli açmak için Boşluk tuşuna basın. DBusUtils - + Unable to connect via DBus DBus ile bağlanılamadı @@ -241,12 +241,12 @@ Yan paneli açmak için Boşluk tuşuna basın. ExitTool - + Exit Çıkış - + Leave the capture screen Yakalama ekranından ayrıl @@ -254,47 +254,47 @@ Yan paneli açmak için Boşluk tuşuna basın. FileNameEditor - + Edit the name of your captures: Çekimlerinizin adını düzenleyin: - + Edit: Düzenle: - + Preview: Önizleme: - + Save Kaydet - + Saves the pattern Desenini kaydeder - + Reset Sıfırla - + Restores the saved pattern Kaydedilen deseni geri yükler - + Clear Temizle - + Deletes the name İsmi siler @@ -302,27 +302,27 @@ Yan paneli açmak için Boşluk tuşuna basın. FilePathConfiguration - + Screenshot path default: - + Use fixed path for screenshots to save - + Browse - + Clear Temizle - + Select default path for Screenshots @@ -580,12 +580,12 @@ Yan paneli açmak için Boşluk tuşuna basın. ImgS3UploaderTool - + Image Uploader Resim Yükleme Aracı - + Upload the selection to S3 bucket @@ -693,12 +693,12 @@ Yan paneli açmak için Boşluk tuşuna basın. ImgurUploaderTool - + Image Uploader Resim Yükleme Aracı - + Upload the selection to Imgur Seçimi Imgur'a yükler @@ -706,7 +706,7 @@ Yan paneli açmak için Boşluk tuşuna basın. InfoWindow - + About Hakkında @@ -763,12 +763,12 @@ Yan paneli açmak için Boşluk tuşuna basın. Tanım - + <u><b>License</b></u> <u><b>Lisans</b></u> - + <u><b>Version</b></u> <u><b>Sürüm</b></u> @@ -780,12 +780,12 @@ Yan paneli açmak için Boşluk tuşuna basın. LineTool - + Line Çizgi - + Set the Line as the paint tool Çizgiyi boyama aracı olarak ayarlar @@ -793,12 +793,12 @@ Yan paneli açmak için Boşluk tuşuna basın. MarkerTool - + Marker İşaretleyici - + Set the Marker as the paint tool İşaretleyiciyi boyama aracı olarak ayarlar @@ -806,12 +806,12 @@ Yan paneli açmak için Boşluk tuşuna basın. MoveTool - + Move Oynat - + Move the selection area Seçim alanını hareket ettir @@ -819,12 +819,12 @@ Yan paneli açmak için Boşluk tuşuna basın. PencilTool - + Pencil Kurşun Kalem - + Set the Pencil as the paint tool Kurşun Kalemi çizim aracı olarak ayarlar @@ -832,12 +832,12 @@ Yan paneli açmak için Boşluk tuşuna basın. PinTool - + Pin Tool Pin Aracı - + Pin image on the desktop Masaüstündeki PIN resmi @@ -845,53 +845,53 @@ Yan paneli açmak için Boşluk tuşuna basın. QObject - + Save Error Kaydetme Hatası - - + + Capture saved as Yakalama farklı kaydedildi - + Capture saved to clipboard Yakalama panoya kaydedildi - - + + Error trying to save as Farklı kaydetmeye çalışılırken hata oluştu - + Save screenshot - + Capture saved and copied to the clipboard as - - - - - + + + + + Unable to connect via DBus DBus ile bağlanılamadı - + Error Hata - + Unable to write in Yazma mümkün değil @@ -901,73 +901,73 @@ Yan paneli açmak için Boşluk tuşuna basın. URL panoya kopyalandı. - + Hi, I'm already running! You can find me in the system tray. - + Hello, I'm here! Click icon in the tray to take a screenshot or click with a right button to see more options. - + Resize selection right 1px - + Resize selection left 1px - + Resize selection up 1px - + Resize selection down 1px - + Toggle side panel - + Move selection left 1px - + Move selection right 1px - + Move selection up 1px - + Move selection down 1px - + Quit capture Çıkış - + Screenshot history - + Capture screen @@ -976,12 +976,12 @@ You can find me in the system tray. 1px seçimini hareket ettir - + Show color picker Renk seçici göster - + Change the tool's thickness Araç kalınlığını değiştirin @@ -989,12 +989,12 @@ You can find me in the system tray. RectangleTool - + Rectangle Dikdörtgen - + Set the Rectangle as the paint tool Dikdörtgeni boyama aracı olarak ayarlar @@ -1002,12 +1002,12 @@ You can find me in the system tray. RedoTool - + Redo Yeniden - + Redo the next modification @@ -1015,12 +1015,12 @@ You can find me in the system tray. SaveTool - + Save Kaydet - + Save the capture Yakalamayı kaydet @@ -1028,7 +1028,7 @@ You can find me in the system tray. ScreenGrabber - + Unable to capture screen Ekran resmi alınamadı @@ -1036,12 +1036,12 @@ You can find me in the system tray. SelectionTool - + Rectangular Selection Dikdörtgen Seçim - + Set Selection as the paint tool Seçimi boyama aracı olarak ayarlar @@ -1049,17 +1049,17 @@ You can find me in the system tray. SetShortcutDialog - + Set Shortcut - + Enter new shortcut to change - + Press Esc to cancel or Backspace to disable the keyboard shortcut. @@ -1067,22 +1067,22 @@ You can find me in the system tray. ShortcutsWidget - + Hot Keys - + Available shortcuts in the screen capture mode. Ekran yakalama modunda kullanılabilir kısayollar. - + Description Tanım - + Key Anahtar @@ -1090,22 +1090,22 @@ You can find me in the system tray. SidePanelWidget - + Active thickness: - + Active color: Aktif Renk: - + Press ESC to cancel Çıkmak için ESC'ye tıklayın - + Grab Color @@ -1113,12 +1113,12 @@ You can find me in the system tray. SizeIndicatorTool - + Selection Size Indicator Seçim Boyutu Göstergesi - + Show the dimensions of the selection (X Y) Seçimin boyutlarını gösterir (X Y) @@ -1126,107 +1126,107 @@ You can find me in the system tray. StrftimeChooserWidget - + Century (00-99) Ülke (00-99) - + Year (00-99) Yıl (00-99) - + Year (2000) Yıl (2000) - + Month Name (jan) Ay Adı (Oca) - + Month Name (january) Ay Adı (Ocak) - + Month (01-12) Ay (01-12) - + Week Day (1-7) Haftanın Günü (1-7) - + Week (01-53) Hafta (01-53) - + Day Name (mon) Gün Adı (pzt) - + Day Name (monday) Gün Adı (pazartesi) - + Day (01-31) Gün (01-31) - + Day of Month (1-31) Ayın Günü (1-31) - + Day (001-366) Gün (001-366) - + Time (%H-%M-%S) - + Time (%H-%M) - + Hour (00-23) Saat (00-23) - + Hour (01-12) Saat (01-12) - + Minute (00-59) Dakika (00-59) - + Second (00-59) Saniye (00-59) - + Full Date (%m/%d/%y) Tam Tarih (%d/%m/%y) - + Full Date (%Y-%m-%d) Tam Tarih (%d-%m-%Y) @@ -1234,7 +1234,7 @@ You can find me in the system tray. SystemNotification - + Flameshot Info Flameshot Hakkında @@ -1242,22 +1242,22 @@ You can find me in the system tray. TextConfig - + StrikeOut - + Underline Altçizgi - + Bold Kalın - + Italic Eğik @@ -1265,12 +1265,12 @@ You can find me in the system tray. TextTool - + Text Metin - + Add text to your capture Bilgisayardan yazı ekle @@ -1278,37 +1278,37 @@ You can find me in the system tray. UIcolorEditor - + UI Color Editor UI Renk Editörü - + Change the color moving the selectors and see the changes in the preview buttons. Seçicileri hareket ettiren rengi değiştirin ve önizleme düğmelerindeki değişiklikleri görün. - + Select a Button to modify it Değiştirmek için bir buton seçin - + Main Color Ana Renk - + Click on this button to set the edition mode of the main color. Ana rengin baskı modunu ayarlamak için bu butonu tıklayın. - + Contrast Color Kontrast Renk - + Click on this button to set the edition mode of the contrast color. Kontrast renginin baskı modunu ayarlamak için bu butonu tıklayın. @@ -1316,12 +1316,12 @@ You can find me in the system tray. UndoTool - + Undo Geri - + Undo the last modification Son değişikliği geri al @@ -1329,7 +1329,7 @@ You can find me in the system tray. UtilityPanel - + Hide @@ -1337,17 +1337,17 @@ You can find me in the system tray. VisualsEditor - + Opacity of area outside selection: Seçimin dışındaki alanın opaklığı: - + Button Selection Buton Seçimi - + Select All Tümünü Seç diff --git a/translations/Internationalization_uk.ts b/translations/Internationalization_uk.ts index 761adb7a..f9e007d3 100644 --- a/translations/Internationalization_uk.ts +++ b/translations/Internationalization_uk.ts @@ -4,12 +4,12 @@ AppLauncher - + App Launcher Запуск програми - + Choose an app to open the capture Виберіть програму, щоб відкрити знімок @@ -32,18 +32,18 @@ Не закривати після вибору - - + + Error Помилка - + Unable to write in Не вдалось записати - + Unable to launch in terminal. Не вдалось запустити у терміналі. @@ -51,12 +51,12 @@ ArrowTool - + Arrow Стрілка - + Set the Arrow as the paint tool Вибрати стрілку інструментом малювання @@ -64,12 +64,12 @@ BlurTool - + Blur Розмиття - + Set Blur as the paint tool Вибрати розмиття інструментом малювання @@ -77,47 +77,47 @@ CaptureLauncher - + <b>Capture Mode</b> <b>Режим захвату</b> - + Rectangular Region Квадратна область - + Full Screen (All Monitors) Увесь екран (усі монітори) - + No Delay Без затримки - + second секунда - + seconds секунд - + Take new screenshot Зробити новий скріншот - + Area: Область: - + Delay: Затримка: @@ -146,12 +146,12 @@ Press Space to open the side panel. CircleTool - + Circle Коло - + Set the Circle as the paint tool Вибрати коло інструментом малювання @@ -191,32 +191,32 @@ Press Space to open the side panel. Controller - + &Take Screenshot &Зробити знімок - + &Open Launcher &Відчинити - + &Configuration &Налаштування - + &Information &Інформація - + &Quit Ви&йти - + &Latest Uploads Останні завантаження @@ -232,12 +232,12 @@ Press Space to open the side panel. CopyTool - + Copy Копіювати - + Copy the selection into the clipboard Копіювати вибране до буферу обміну @@ -245,7 +245,7 @@ Press Space to open the side panel. DBusUtils - + Unable to connect via DBus Не вдалось підключитись через DBus @@ -253,12 +253,12 @@ Press Space to open the side panel. ExitTool - + Exit Вийти - + Leave the capture screen Вийти із захоплення екрану @@ -266,47 +266,47 @@ Press Space to open the side panel. FileNameEditor - + Edit the name of your captures: Відредагуйте ім'я ваших знімків: - + Edit: Шаблон: - + Preview: Перегляд: - + Save Зберегти - + Saves the pattern Зберегти шаблон - + Reset Скинути - + Restores the saved pattern Відновлює збережений шаблон - + Clear Очистити - + Deletes the name Видаляє ім'я @@ -314,27 +314,27 @@ Press Space to open the side panel. FilePathConfiguration - + Screenshot path default: Шлях за замовчуванням - + Use fixed path for screenshots to save Використовувати шлях за замовчуванням - + Browse Обрати - + Clear Очистити - + Select default path for Screenshots Обрати шлях за замовчуванням @@ -608,12 +608,12 @@ Press Space to open the side panel. ImgS3UploaderTool - + Image Uploader Вивантаження зображень - + Upload the selection to S3 bucket Вивантажити виділення на S3 @@ -725,12 +725,12 @@ Press Space to open the side panel. ImgurUploaderTool - + Image Uploader Вивантаження зображень - + Upload the selection to Imgur Вивантажити вибране до Imgur @@ -738,7 +738,7 @@ Press Space to open the side panel. InfoWindow - + About Про... @@ -811,12 +811,12 @@ Press Space to open the side panel. Опис - + <u><b>License</b></u> <u><b>Ліцензія</b></u> - + <u><b>Version</b></u> <u><b>Версія</b></u> @@ -828,12 +828,12 @@ Press Space to open the side panel. LineTool - + Line Лінія - + Set the Line as the paint tool Вибрати лінію інструментом малювання @@ -841,12 +841,12 @@ Press Space to open the side panel. MarkerTool - + Marker Маркер - + Set the Marker as the paint tool Вибрати маркер інструментом малювання @@ -854,12 +854,12 @@ Press Space to open the side panel. MoveTool - + Move Переміщення - + Move the selection area Перемістити вибір @@ -867,12 +867,12 @@ Press Space to open the side panel. PencilTool - + Pencil Олівець - + Set the Pencil as the paint tool Вибрати олівець інструментом малювання @@ -880,12 +880,12 @@ Press Space to open the side panel. PinTool - + Pin Tool Прикріплення - + Pin image on the desktop Прикріпити зображення до робочого столу @@ -893,53 +893,53 @@ Press Space to open the side panel. QObject - + Save Error Помилка збереження - - + + Capture saved as Знімок збережено як - + Capture saved to clipboard Знімок збережено до буферу обміну - - + + Error trying to save as Помилка під час збереження як - + Save screenshot Зберегти скріншот - + Capture saved and copied to the clipboard as Файл збережено та шлях до нього скопійовано як - - - - - + + + + + Unable to connect via DBus Не вдалось підключитись через DBus - + Error Помилка - + Unable to write in Не вдалось зберегти @@ -953,73 +953,73 @@ Press Space to open the side panel. Файл видален з S3 - + Hi, I'm already running! You can find me in the system tray. Привіт, а я вже працюю!\nВи можете знайти мене у системному трэї. - + Hello, I'm here! Click icon in the tray to take a screenshot or click with a right button to see more options. Привіт, я тут! Клацніть піктограму в лотку, щоб зробити знімок екрана, або натисніть правою кнопкою, щоб переглянути додаткові параметри. - + Resize selection right 1px Змінити розмір виділення праворуч 1 піксель - + Resize selection left 1px Змінити розмір виділення ліворуч 1 пікс - + Resize selection up 1px Змінити розмір виділення вгору 1 пікс - + Resize selection down 1px Змінити розмір виділення вниз 1 пікс - + Toggle side panel Визвати бічну панель - + Move selection left 1px Перемістити виділення вліво на 1 пікс - + Move selection right 1px Перемістити виділення вправо на 1 пікс - + Move selection up 1px Перемістіть виділення вгору на 1 пікс - + Move selection down 1px Перемістіть виділення вниз на 1 пікс - + Quit capture Вийти із захоплення екрану - + Screenshot history Історія скріншотів - + Capture screen Захватити екран @@ -1028,12 +1028,12 @@ You can find me in the system tray. Перемістити виділення на 1px - + Show color picker Показати вибір кольору - + Change the tool's thickness Змінити товщину інструменту @@ -1041,12 +1041,12 @@ You can find me in the system tray. RectangleTool - + Rectangle Прямокутник - + Set the Rectangle as the paint tool Вибрати прямокутник інструментом малювання @@ -1054,12 +1054,12 @@ You can find me in the system tray. RedoTool - + Redo Повторити - + Redo the next modification Повторити наступну зміну @@ -1067,12 +1067,12 @@ You can find me in the system tray. SaveTool - + Save Зберегти - + Save the capture Зберегти знімок @@ -1080,7 +1080,7 @@ You can find me in the system tray. ScreenGrabber - + Unable to capture screen Не вдалось захопити екран @@ -1088,12 +1088,12 @@ You can find me in the system tray. SelectionTool - + Rectangular Selection Прямокутне виділення - + Set Selection as the paint tool Вибрати прямокутне виділення інструментом малювання @@ -1101,17 +1101,17 @@ You can find me in the system tray. SetShortcutDialog - + Set Shortcut Вибрати гарячу клавішу - + Enter new shortcut to change Оберіть нову гарячу клавішу - + Press Esc to cancel or Backspace to disable the keyboard shortcut. Натисніть Esc для відміни або Backspace для видалення гарячої клавіші @@ -1119,22 +1119,22 @@ You can find me in the system tray. ShortcutsWidget - + Hot Keys Гарячі клавіші - + Available shortcuts in the screen capture mode. Доступні комбінації клавіш у режимі захоплення екрану. - + Description Опис - + Key Клавіша @@ -1142,22 +1142,22 @@ You can find me in the system tray. SidePanelWidget - + Active thickness: Активна товщина: - + Active color: Активний колір: - + Press ESC to cancel Натисніть Esc для скасування - + Grab Color Визначити колір з екрану @@ -1165,12 +1165,12 @@ You can find me in the system tray. SizeIndicatorTool - + Selection Size Indicator Індикатор розміру виділення - + Show the dimensions of the selection (X Y) Показує розмір виділення (X Y) @@ -1178,107 +1178,107 @@ You can find me in the system tray. StrftimeChooserWidget - + Century (00-99) Століття (00-99) - + Year (00-99) Рік (00-99) - + Year (2000) Рік (2000) - + Month Name (jan) Назва місяця (січ) - + Month Name (january) Назва місяця (січень) - + Month (01-12) Місяць (01-12) - + Week Day (1-7) День тижня (1-7) - + Week (01-53) Тиждень (01-53) - + Day Name (mon) Назва дня тижня (пн) - + Day Name (monday) Назва дня тижня (понеділок) - + Day (01-31) День (01-31) - + Day of Month (1-31) День місяця (1-31) - + Day (001-366) День (001-366) - + Time (%H-%M-%S) Час (%H-%M-%S) - + Time (%H-%M) Час (%H-%M) - + Hour (00-23) Година (00-23) - + Hour (01-12) Година (01-12) - + Minute (00-59) Хвилина (00-59) - + Second (00-59) Секунда (00-59) - + Full Date (%m/%d/%y) Повна дата (%m/%d/%y) - + Full Date (%Y-%m-%d) Повна дата (%Y-%m-%d) @@ -1286,7 +1286,7 @@ You can find me in the system tray. SystemNotification - + Flameshot Info Довідка Flameshot @@ -1294,22 +1294,22 @@ You can find me in the system tray. TextConfig - + StrikeOut Перекреслення - + Underline Підкреслення - + Bold Жирний - + Italic Курсив @@ -1317,12 +1317,12 @@ You can find me in the system tray. TextTool - + Text Текст - + Add text to your capture Додати текст на знімок @@ -1330,37 +1330,37 @@ You can find me in the system tray. UIcolorEditor - + UI Color Editor Редактор кольору інтерфейсу - + Change the color moving the selectors and see the changes in the preview buttons. Змініть колір пересуваючи виділення та перегляньте зміни у кнопках перегляду. - + Select a Button to modify it Виберіть кнопку, щоб змінити її - + Main Color Основний колір - + Click on this button to set the edition mode of the main color. Натисніть на цю кнопку, щоб включити режим редагування основного кольору. - + Contrast Color Контрасний колір - + Click on this button to set the edition mode of the contrast color. Натисніть на цю кнопку, щоб включити режим редагування контрасного кольору. @@ -1368,12 +1368,12 @@ You can find me in the system tray. UndoTool - + Undo Скасувати - + Undo the last modification Скасувати останню зміну @@ -1381,7 +1381,7 @@ You can find me in the system tray. UtilityPanel - + Hide Сховати @@ -1389,17 +1389,17 @@ You can find me in the system tray. VisualsEditor - + Opacity of area outside selection: Нерозорість області за межами вибору: - + Button Selection Вибір кнопок - + Select All Вибрати все diff --git a/translations/Internationalization_zh_CN.ts b/translations/Internationalization_zh_CN.ts index 1916eaa7..8522e035 100644 --- a/translations/Internationalization_zh_CN.ts +++ b/translations/Internationalization_zh_CN.ts @@ -4,12 +4,12 @@ AppLauncher - + App Launcher 应用启动器 - + Choose an app to open the capture 选择一个应用打开此截图 @@ -32,18 +32,18 @@ 选择后保持此窗口打开 - - + + Error 错误 - + Unable to launch in terminal. 无法在终端中启动。 - + Unable to write in 无法写入 @@ -51,12 +51,12 @@ ArrowTool - + Arrow 箭头 - + Set the Arrow as the paint tool 选择箭头作为绘画工具 @@ -64,12 +64,12 @@ BlurTool - + Blur 模糊 - + Set Blur as the paint tool 选择模糊作为绘画工具 @@ -77,47 +77,47 @@ CaptureLauncher - + <b>Capture Mode</b> <b>捕获模式</b> - + Rectangular Region 方形区域 - + Full Screen (All Monitors) 全屏(所有显示器) - + No Delay 无延迟 - + second - + seconds - + Take new screenshot 获取新屏幕截图 - + Area: 区域: - + Delay: 延迟: @@ -147,12 +147,12 @@ Press Space to open the side panel. CircleTool - + Circle 圆环 - + Set the Circle as the paint tool 选择圆环作为绘画工具 @@ -188,32 +188,32 @@ Press Space to open the side panel. Controller - + &Take Screenshot 进行截图(&T) - + &Open Launcher 打开启动器(&O) - + &Configuration 配置(&C) - + &Information 信息(&I) - + &Quit 退出(&Q) - + &Latest Uploads @@ -221,12 +221,12 @@ Press Space to open the side panel. CopyTool - + Copy 复制 - + Copy the selection into the clipboard 复制选择到剪贴板 @@ -234,7 +234,7 @@ Press Space to open the side panel. DBusUtils - + Unable to connect via DBus 无法通过 DBus 进行连接 @@ -242,12 +242,12 @@ Press Space to open the side panel. ExitTool - + Exit 退出 - + Leave the capture screen 离开屏幕捕获 @@ -255,47 +255,47 @@ Press Space to open the side panel. FileNameEditor - + Edit the name of your captures: 编辑您的截图名称: - + Edit: 编辑器: - + Preview: 预览: - + Save 保存 - + Saves the pattern 保存样式 - + Reset 恢复 - + Restores the saved pattern 恢复保存的样式 - + Clear 清空 - + Deletes the name 删除这个名字 @@ -303,27 +303,27 @@ Press Space to open the side panel. FilePathConfiguration - + Screenshot path default: - + Use fixed path for screenshots to save - + Browse - + Clear 清空 - + Select default path for Screenshots @@ -581,12 +581,12 @@ Press Space to open the side panel. ImgS3UploaderTool - + Image Uploader 上传图片 - + Upload the selection to S3 bucket @@ -694,12 +694,12 @@ Press Space to open the side panel. ImgurUploaderTool - + Image Uploader 上传图片 - + Upload the selection to Imgur 上传选择到 Imgur @@ -707,7 +707,7 @@ Press Space to open the side panel. InfoWindow - + About 关于 @@ -768,12 +768,12 @@ Press Space to open the side panel. 描述 - + <u><b>License</b></u> <u><b>许可证</b></u> - + <u><b>Version</b></u> <u><b>版本</b></u> @@ -789,12 +789,12 @@ Press Space to open the side panel. LineTool - + Line 直线 - + Set the Line as the paint tool 将直线线设置为绘画工具 @@ -802,12 +802,12 @@ Press Space to open the side panel. MarkerTool - + Marker 标记 - + Set the Marker as the paint tool 将标记设置为绘画工具 @@ -815,12 +815,12 @@ Press Space to open the side panel. MoveTool - + Move 移动 - + Move the selection area 移动选择区域 @@ -828,12 +828,12 @@ Press Space to open the side panel. PencilTool - + Pencil 铅笔 - + Set the Pencil as the paint tool 将铅笔设置为绘画工具 @@ -841,12 +841,12 @@ Press Space to open the side panel. PinTool - + Pin Tool 贴图工具 - + Pin image on the desktop 在桌面上固定图像 @@ -854,53 +854,53 @@ Press Space to open the side panel. QObject - + Save Error 保存错误 - - + + Capture saved as 捕获已保存为 - + Capture saved to clipboard 捕获已保存至剪贴板 - - + + Error trying to save as 尝试另存为时出错 - + Save screenshot - + Capture saved and copied to the clipboard as - - - - - + + + + + Unable to connect via DBus 无法通过DBus进行连接 - + Error 错误 - + Unable to write in 无法写入 @@ -910,73 +910,73 @@ Press Space to open the side panel. 复制链接到剪贴板。 - + Hi, I'm already running! You can find me in the system tray. - + Hello, I'm here! Click icon in the tray to take a screenshot or click with a right button to see more options. - + Resize selection right 1px - + Resize selection left 1px - + Resize selection up 1px - + Resize selection down 1px - + Toggle side panel - + Move selection left 1px - + Move selection right 1px - + Move selection up 1px - + Move selection down 1px - + Quit capture 退出捕获 - + Screenshot history - + Capture screen @@ -985,12 +985,12 @@ You can find me in the system tray. 移动选择 1 px - + Show color picker 显示颜色选择器 - + Change the tool's thickness 改变工具的厚度 @@ -998,12 +998,12 @@ You can find me in the system tray. RectangleTool - + Rectangle 实心矩形 - + Set the Rectangle as the paint tool 将实心矩形设置为绘画工具 @@ -1011,12 +1011,12 @@ You can find me in the system tray. RedoTool - + Redo 重做 - + Redo the next modification 重做上次修改 @@ -1024,12 +1024,12 @@ You can find me in the system tray. SaveTool - + Save 保存 - + Save the capture 保存捕获 @@ -1037,7 +1037,7 @@ You can find me in the system tray. ScreenGrabber - + Unable to capture screen 无法捕获屏幕 @@ -1045,12 +1045,12 @@ You can find me in the system tray. SelectionTool - + Rectangular Selection 矩形选择 - + Set Selection as the paint tool 将矩形选择设置为绘画工具 @@ -1058,17 +1058,17 @@ You can find me in the system tray. SetShortcutDialog - + Set Shortcut - + Enter new shortcut to change - + Press Esc to cancel or Backspace to disable the keyboard shortcut. @@ -1076,22 +1076,22 @@ You can find me in the system tray. ShortcutsWidget - + Hot Keys - + Available shortcuts in the screen capture mode. 屏幕捕捉模式中的可用快捷键。 - + Description 描述 - + Key @@ -1099,22 +1099,22 @@ You can find me in the system tray. SidePanelWidget - + Active thickness: 当前宽度: - + Active color: 活动颜色: - + Press ESC to cancel 按下 ESC 键以取消 - + Grab Color 获取颜色 @@ -1122,12 +1122,12 @@ You can find me in the system tray. SizeIndicatorTool - + Selection Size Indicator 选择尺寸指示 - + Show the dimensions of the selection (X Y) 显示选择的尺寸 (X Y) @@ -1135,107 +1135,107 @@ You can find me in the system tray. StrftimeChooserWidget - + Century (00-99) 世纪(00-99) - + Year (00-99) 年(00-99) - + Year (2000) 年(2000) - + Month Name (jan) 月(1月 - 12月) - + Month Name (january) 月(一月 - 十二月) - + Month (01-12) 月 (01-12) - + Week Day (1-7) 周内的日(1-7) - + Week (01-53) 周(01-53) - + Day Name (mon) 星期(一 - 七) - + Day Name (monday) 星期(星期一 - 星期日) - + Day (01-31) 天(01-31) - + Day of Month (1-31) 一月中的某天(1-31) - + Day (001-366) 天(001-366) - + Time (%H-%M-%S) 时间(%H-%M-%S) - + Time (%H-%M) 时间(%H-%M) - + Hour (00-23) 小时(00-23) - + Hour (01-12) 小时(01-12) - + Minute (00-59) 分钟(00-59) - + Second (00-59) 秒(00-59) - + Full Date (%m/%d/%y) 完整日期(%m/%d/%y) - + Full Date (%Y-%m-%d) 完整日期(%Y-%m-%d) @@ -1243,7 +1243,7 @@ You can find me in the system tray. SystemNotification - + Flameshot Info Flameshot 消息 @@ -1251,22 +1251,22 @@ You can find me in the system tray. TextConfig - + StrikeOut 删除线 - + Underline 下划线 - + Bold 粗体 - + Italic 斜体 @@ -1274,12 +1274,12 @@ You can find me in the system tray. TextTool - + Text 文本 - + Add text to your capture 在您的捕获中添加文本 @@ -1287,37 +1287,37 @@ You can find me in the system tray. UIcolorEditor - + UI Color Editor 用户界面颜色编辑器 - + Change the color moving the selectors and see the changes in the preview buttons. 移动颜色选择并在预览按钮查看。 - + Select a Button to modify it 选择一个按钮以进行修改 - + Main Color 主色 - + Click on this button to set the edition mode of the main color. 点击按钮设置主色。 - + Contrast Color 对比色 - + Click on this button to set the edition mode of the contrast color. 点击按钮设置对比色。 @@ -1325,12 +1325,12 @@ You can find me in the system tray. UndoTool - + Undo 撤消 - + Undo the last modification 撤消上次修改 @@ -1338,7 +1338,7 @@ You can find me in the system tray. UtilityPanel - + Hide @@ -1346,17 +1346,17 @@ You can find me in the system tray. VisualsEditor - + Opacity of area outside selection: 选中区域之外的不透明度: - + Button Selection 按钮选择 - + Select All 全选 diff --git a/translations/Internationalization_zh_TW.ts b/translations/Internationalization_zh_TW.ts index 96cd338a..a08c1b71 100644 --- a/translations/Internationalization_zh_TW.ts +++ b/translations/Internationalization_zh_TW.ts @@ -4,12 +4,12 @@ AppLauncher - + App Launcher 應用程式啟動器 - + Choose an app to open the capture 選擇一個程式打開此截圖 @@ -32,18 +32,18 @@ 選擇後維持此視窗開啟 - - + + Error 錯誤 - + Unable to launch in terminal. 無法在終端機中啟動 - + Unable to write in 無法寫入 @@ -51,12 +51,12 @@ ArrowTool - + Arrow 箭頭 - + Set the Arrow as the paint tool 選擇箭頭作為繪製工具 @@ -64,12 +64,12 @@ BlurTool - + Blur 模糊 - + Set Blur as the paint tool 選擇模糊作為繪製工具 @@ -77,47 +77,47 @@ CaptureLauncher - + <b>Capture Mode</b> - + Rectangular Region - + Full Screen (All Monitors) - + No Delay - + second - + seconds - + Take new screenshot - + Area: - + Delay: @@ -142,12 +142,12 @@ Press Space to open the side panel. CircleTool - + Circle 圈型 - + Set the Circle as the paint tool 選擇圈型作為繪畫工具 @@ -183,32 +183,32 @@ Press Space to open the side panel. Controller - + &Take Screenshot - + &Open Launcher - + &Configuration &設定 - + &Information &資訊 - + &Quit &結束 - + &Latest Uploads @@ -216,12 +216,12 @@ Press Space to open the side panel. CopyTool - + Copy 複製 - + Copy the selection into the clipboard @@ -229,7 +229,7 @@ Press Space to open the side panel. DBusUtils - + Unable to connect via DBus 無法透過 DBus 進行連接 @@ -237,12 +237,12 @@ Press Space to open the side panel. ExitTool - + Exit 離開 - + Leave the capture screen 離開螢幕擷取 @@ -250,47 +250,47 @@ Press Space to open the side panel. FileNameEditor - + Edit the name of your captures: 編輯您的截圖名稱: - + Edit: 編輯器: - + Preview: 預覽: - + Save 存檔 - + Saves the pattern 儲存樣式 - + Reset 重設 - + Restores the saved pattern 恢復儲存的樣式 - + Clear 清空 - + Deletes the name 刪除這個名稱 @@ -298,27 +298,27 @@ Press Space to open the side panel. FilePathConfiguration - + Screenshot path default: - + Use fixed path for screenshots to save - + Browse - + Clear 清空 - + Select default path for Screenshots @@ -572,12 +572,12 @@ Press Space to open the side panel. ImgS3UploaderTool - + Image Uploader 上傳圖片 - + Upload the selection to S3 bucket @@ -681,12 +681,12 @@ Press Space to open the side panel. ImgurUploaderTool - + Image Uploader 上傳圖片 - + Upload the selection to Imgur 上傳到 Imgur @@ -694,7 +694,7 @@ Press Space to open the side panel. InfoWindow - + About 關於 @@ -747,12 +747,12 @@ Press Space to open the side panel. 描述 - + <u><b>License</b></u> <u><b>授權條款</b></u> - + <u><b>Version</b></u> <u><b>版本</b></u> @@ -768,12 +768,12 @@ Press Space to open the side panel. LineTool - + Line 直線 - + Set the Line as the paint tool 將直線線設定為繪畫工具 @@ -781,12 +781,12 @@ Press Space to open the side panel. MarkerTool - + Marker 標記 - + Set the Marker as the paint tool 將標記設定為繪畫工具 @@ -794,12 +794,12 @@ Press Space to open the side panel. MoveTool - + Move 移動 - + Move the selection area 移動選擇區域 @@ -807,12 +807,12 @@ Press Space to open the side panel. PencilTool - + Pencil 鉛筆 - + Set the Pencil as the paint tool 將鉛筆設定為繪畫工具 @@ -820,12 +820,12 @@ Press Space to open the side panel. PinTool - + Pin Tool - + Pin image on the desktop @@ -833,53 +833,53 @@ Press Space to open the side panel. QObject - + Save Error 存檔錯誤 - - + + Capture saved as 截圖已另存為 - + Capture saved to clipboard - - + + Error trying to save as 嘗試另存新檔時發生錯誤 - + Save screenshot - + Capture saved and copied to the clipboard as - - - - - + + + + + Unable to connect via DBus 無法透過 DBus 進行連接 - + Error 錯誤 - + Unable to write in 無法寫入 @@ -889,73 +889,73 @@ Press Space to open the side panel. 連結已複製到剪貼簿 - + Hi, I'm already running! You can find me in the system tray. - + Hello, I'm here! Click icon in the tray to take a screenshot or click with a right button to see more options. - + Resize selection right 1px - + Resize selection left 1px - + Resize selection up 1px - + Resize selection down 1px - + Toggle side panel - + Move selection left 1px - + Move selection right 1px - + Move selection up 1px - + Move selection down 1px - + Quit capture 結束擷取 - + Screenshot history - + Capture screen @@ -964,12 +964,12 @@ You can find me in the system tray. 移動 1px - + Show color picker 顯示顏色選擇器 - + Change the tool's thickness 改變工具的寬度 @@ -977,12 +977,12 @@ You can find me in the system tray. RectangleTool - + Rectangle 實心矩形 - + Set the Rectangle as the paint tool 將實心矩形設定為繪畫工具 @@ -990,12 +990,12 @@ You can find me in the system tray. RedoTool - + Redo - + Redo the next modification @@ -1003,12 +1003,12 @@ You can find me in the system tray. SaveTool - + Save 儲存 - + Save the capture 儲存擷取 @@ -1016,7 +1016,7 @@ You can find me in the system tray. ScreenGrabber - + Unable to capture screen 無法擷取螢幕 @@ -1024,12 +1024,12 @@ You can find me in the system tray. SelectionTool - + Rectangular Selection 矩形選擇 - + Set Selection as the paint tool 將矩形選擇設定為繪畫工具 @@ -1037,17 +1037,17 @@ You can find me in the system tray. SetShortcutDialog - + Set Shortcut - + Enter new shortcut to change - + Press Esc to cancel or Backspace to disable the keyboard shortcut. @@ -1055,22 +1055,22 @@ You can find me in the system tray. ShortcutsWidget - + Hot Keys - + Available shortcuts in the screen capture mode. 螢幕擷取模式中的可用快速鍵 - + Description 描述 - + Key @@ -1078,22 +1078,22 @@ You can find me in the system tray. SidePanelWidget - + Active thickness: - + Active color: - + Press ESC to cancel - + Grab Color @@ -1101,12 +1101,12 @@ You can find me in the system tray. SizeIndicatorTool - + Selection Size Indicator 選擇尺寸指示 - + Show the dimensions of the selection (X Y) 顯示選擇的尺寸 (X Y) @@ -1114,107 +1114,107 @@ You can find me in the system tray. StrftimeChooserWidget - + Century (00-99) 世紀 (00-99) - + Year (00-99) 年 (00-99) - + Year (2000) 年 (2000) - + Month Name (jan) 月 (jul) - + Month Name (january) 月 (juliol) - + Month (01-12) 月 (01-12) - + Week Day (1-7) 平常日 (1-7) - + Week (01-53) 周 (01-53) - + Day Name (mon) 星期 (dg) - + Day Name (monday) 星期 (diumenge) - + Day (01-31) 天 (01-31) - + Day of Month (1-31) 一月中的某天 (1-31) - + Day (001-366) 天 (001-366) - + Time (%H-%M-%S) - + Time (%H-%M) - + Hour (00-23) 小時 (00-23) - + Hour (01-12) 小時 (01-12) - + Minute (00-59) 分鐘 (00-59) - + Second (00-59) 秒 (00-59) - + Full Date (%m/%d/%y) 日期 (%m/%d/%y) - + Full Date (%Y-%m-%d) 日期 (%Y-%m-%d) @@ -1222,7 +1222,7 @@ You can find me in the system tray. SystemNotification - + Flameshot Info @@ -1230,22 +1230,22 @@ You can find me in the system tray. TextConfig - + StrikeOut - + Underline - + Bold - + Italic @@ -1253,12 +1253,12 @@ You can find me in the system tray. TextTool - + Text - + Add text to your capture @@ -1266,37 +1266,37 @@ You can find me in the system tray. UIcolorEditor - + UI Color Editor UI 顏色編輯器 - + Change the color moving the selectors and see the changes in the preview buttons. 移動顏色選擇並在預覽按鈕檢視 - + Select a Button to modify it 選擇一個按鈕來修改它 - + Main Color 主色 - + Click on this button to set the edition mode of the main color. 點選按鈕設定主色 - + Contrast Color 對比色 - + Click on this button to set the edition mode of the contrast color. 點選按鈕設定對比色 @@ -1304,12 +1304,12 @@ You can find me in the system tray. UndoTool - + Undo 復原 - + Undo the last modification 復原上次修改 @@ -1317,7 +1317,7 @@ You can find me in the system tray. UtilityPanel - + Hide @@ -1325,17 +1325,17 @@ You can find me in the system tray. VisualsEditor - + Opacity of area outside selection: 選擇區域以外的不透明度 - + Button Selection 按鈕選擇 - + Select All 全選