mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-22 09:51:06 +00:00
Fix some issues detected by Clazy (#384)
* Fix old style connect * Fix unneeded QString memory allocations
This commit is contained in:
@@ -31,9 +31,9 @@ QTextStream out(stdout);
|
|||||||
QTextStream err(stderr);
|
QTextStream err(stderr);
|
||||||
|
|
||||||
auto versionOption = CommandOption({"v", "version"},
|
auto versionOption = CommandOption({"v", "version"},
|
||||||
"Displays version information");
|
QStringLiteral("Displays version information"));
|
||||||
auto helpOption = CommandOption({"h", "help"},
|
auto helpOption = CommandOption({"h", "help"},
|
||||||
"Displays this help");
|
QStringLiteral("Displays this help"));
|
||||||
|
|
||||||
QString optionsToString(const QList<CommandOption> &options,
|
QString optionsToString(const QList<CommandOption> &options,
|
||||||
const QList<CommandArgument> &arguments) {
|
const QList<CommandArgument> &arguments) {
|
||||||
@@ -43,7 +43,7 @@ QString optionsToString(const QList<CommandOption> &options,
|
|||||||
// of every option at the same horizontal character position.
|
// of every option at the same horizontal character position.
|
||||||
for (auto const &option: options) {
|
for (auto const &option: options) {
|
||||||
QStringList dashedOptions = option.dashedNames();
|
QStringList dashedOptions = option.dashedNames();
|
||||||
QString joinedDashedOptions = dashedOptions.join(", ");
|
QString joinedDashedOptions = dashedOptions.join(QStringLiteral(", "));
|
||||||
if (!option.valueName().isEmpty()) {
|
if (!option.valueName().isEmpty()) {
|
||||||
joinedDashedOptions += QStringLiteral(" <%1>")
|
joinedDashedOptions += QStringLiteral(" <%1>")
|
||||||
.arg(option.valueName());
|
.arg(option.valueName());
|
||||||
@@ -61,20 +61,20 @@ QString optionsToString(const QList<CommandOption> &options,
|
|||||||
// generate the text
|
// generate the text
|
||||||
QString result;
|
QString result;
|
||||||
if(!dashedOptionList.isEmpty()) {
|
if(!dashedOptionList.isEmpty()) {
|
||||||
result += "Options:\n";
|
result += QLatin1String("Options:\n");
|
||||||
QString linePadding = QString(" ").repeated(size + 4).prepend("\n");
|
QString linePadding = QStringLiteral(" ").repeated(size + 4).prepend("\n");
|
||||||
for (int i = 0; i < options.length(); ++i) {
|
for (int i = 0; i < options.length(); ++i) {
|
||||||
result += QStringLiteral(" %1 %2\n")
|
result += QStringLiteral(" %1 %2\n")
|
||||||
.arg(dashedOptionList.at(i).leftJustified(size, ' '))
|
.arg(dashedOptionList.at(i).leftJustified(size, ' '))
|
||||||
.arg(options.at(i).description()
|
.arg(options.at(i).description()
|
||||||
.replace("\n", linePadding));
|
.replace(QLatin1String("\n"), linePadding));
|
||||||
}
|
}
|
||||||
if (!arguments.isEmpty()) {
|
if (!arguments.isEmpty()) {
|
||||||
result += "\n";
|
result += QLatin1String("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!arguments.isEmpty()) {
|
if (!arguments.isEmpty()) {
|
||||||
result += "Arguments:\n";
|
result += QLatin1String("Arguments:\n");
|
||||||
}
|
}
|
||||||
for (int i = 0; i < arguments.length(); ++i) {
|
for (int i = 0; i < arguments.length(); ++i) {
|
||||||
result += QStringLiteral(" %1 %2\n")
|
result += QStringLiteral(" %1 %2\n")
|
||||||
@@ -121,14 +121,14 @@ bool CommandLineParser::processOptions(const QStringList &args,
|
|||||||
QString arg = *actualIt;
|
QString arg = *actualIt;
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
// track values
|
// track values
|
||||||
int equalsPos = arg.indexOf("=");
|
int equalsPos = arg.indexOf(QLatin1String("="));
|
||||||
QString valueStr;
|
QString valueStr;
|
||||||
if (equalsPos != -1) {
|
if (equalsPos != -1) {
|
||||||
valueStr = arg.mid(equalsPos +1); // right
|
valueStr = arg.mid(equalsPos +1); // right
|
||||||
arg = arg.mid(0, equalsPos); // left
|
arg = arg.mid(0, equalsPos); // left
|
||||||
}
|
}
|
||||||
// check format -x --xx...
|
// check format -x --xx...
|
||||||
bool isDoubleDashed = arg.startsWith("--");
|
bool isDoubleDashed = arg.startsWith(QLatin1String("--"));
|
||||||
ok = isDoubleDashed ? arg.length() > 3 :
|
ok = isDoubleDashed ? arg.length() > 3 :
|
||||||
arg.length() == 2;
|
arg.length() == 2;
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
@@ -182,8 +182,8 @@ bool CommandLineParser::processOptions(const QStringList &args,
|
|||||||
ok = option.checkValue(valueStr);
|
ok = option.checkValue(valueStr);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
QString err = option.errorMsg();
|
QString err = option.errorMsg();
|
||||||
if (!err.endsWith("."))
|
if (!err.endsWith(QLatin1String(".")))
|
||||||
err += ".";
|
err += QLatin1String(".");
|
||||||
out << err;
|
out << err;
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
@@ -219,7 +219,7 @@ bool CommandLineParser::parse(const QStringList &args) {
|
|||||||
// process the other args
|
// process the other args
|
||||||
for (; it != args.cend() && ok; ++it) {
|
for (; it != args.cend() && ok; ++it) {
|
||||||
const QString &value = *it;
|
const QString &value = *it;
|
||||||
if (value.startsWith("-")) {
|
if (value.startsWith(QLatin1String("-"))) {
|
||||||
ok = processOptions(args, it, actualNode);
|
ok = processOptions(args, it, actualNode);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -326,7 +326,7 @@ void CommandLineParser::printHelp(QStringList args, const Node *node) {
|
|||||||
}
|
}
|
||||||
QString argText = node->subNodes.isEmpty() ? "" : "[arguments]";
|
QString argText = node->subNodes.isEmpty() ? "" : "[arguments]";
|
||||||
helpText += QStringLiteral("Usage: %1 [%2-options] %3\n\n")
|
helpText += QStringLiteral("Usage: %1 [%2-options] %3\n\n")
|
||||||
.arg(args.join(" "))
|
.arg(args.join(QStringLiteral(" ")))
|
||||||
.arg(argName).arg(argText);
|
.arg(argName).arg(argText);
|
||||||
// add command options and subarguments
|
// add command options and subarguments
|
||||||
QList<CommandArgument> subArgs;
|
QList<CommandArgument> subArgs;
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ QString CommandOption::valueName() const {
|
|||||||
|
|
||||||
void CommandOption::setValue(const QString &value) {
|
void CommandOption::setValue(const QString &value) {
|
||||||
if (m_valueName.isEmpty()) {
|
if (m_valueName.isEmpty()) {
|
||||||
m_valueName = "value";
|
m_valueName = QLatin1String("value");
|
||||||
}
|
}
|
||||||
m_value = value;
|
m_value = value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ void GeneneralConf::importConfiguration() {
|
|||||||
|
|
||||||
void GeneneralConf::exportFileConfiguration() {
|
void GeneneralConf::exportFileConfiguration() {
|
||||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
|
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
|
||||||
"flameshot.conf");
|
QStringLiteral("flameshot.conf"));
|
||||||
|
|
||||||
// Cancel button
|
// Cancel button
|
||||||
if (fileName.isNull()) {
|
if (fileName.isNull()) {
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ void UIcolorEditor::initButtons() {
|
|||||||
h2->addWidget(frame2);
|
h2->addWidget(frame2);
|
||||||
frame2->setFixedSize(frameSize, frameSize);
|
frame2->setFixedSize(frameSize, frameSize);
|
||||||
m_labelContrast = new ClickableLabel(tr("Contrast Color"), this);
|
m_labelContrast = new ClickableLabel(tr("Contrast Color"), this);
|
||||||
m_labelContrast->setStyleSheet("color : gray");
|
m_labelContrast->setStyleSheet(QStringLiteral("color : gray"));
|
||||||
h2->addWidget(m_labelContrast);
|
h2->addWidget(m_labelContrast);
|
||||||
m_vLayout->addLayout(h2);
|
m_vLayout->addLayout(h2);
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ void UIcolorEditor::changeLastButton(CaptureButton *b) {
|
|||||||
if (m_lastButtonPressed != b) {
|
if (m_lastButtonPressed != b) {
|
||||||
m_lastButtonPressed = b;
|
m_lastButtonPressed = b;
|
||||||
|
|
||||||
QString offStyle("QLabel { color : gray; }");
|
QString offStyle(QStringLiteral("QLabel { color : gray; }"));
|
||||||
|
|
||||||
if (b == m_buttonMainColor) {
|
if (b == m_buttonMainColor) {
|
||||||
m_colorWheel->setColor(m_uiColor);
|
m_colorWheel->setColor(m_uiColor);
|
||||||
|
|||||||
@@ -45,9 +45,9 @@ void VisualsEditor::initOpacitySlider() {
|
|||||||
connect(m_opacitySlider, &ExtendedSlider::modificationsEnded,
|
connect(m_opacitySlider, &ExtendedSlider::modificationsEnded,
|
||||||
this, &VisualsEditor::saveOpacity);
|
this, &VisualsEditor::saveOpacity);
|
||||||
QHBoxLayout *localLayout = new QHBoxLayout();
|
QHBoxLayout *localLayout = new QHBoxLayout();
|
||||||
localLayout->addWidget(new QLabel("0%"));
|
localLayout->addWidget(new QLabel(QStringLiteral("0%")));
|
||||||
localLayout->addWidget(m_opacitySlider);
|
localLayout->addWidget(m_opacitySlider);
|
||||||
localLayout->addWidget(new QLabel("100%"));
|
localLayout->addWidget(new QLabel(QStringLiteral("100%")));
|
||||||
|
|
||||||
QLabel *label = new QLabel();
|
QLabel *label = new QLabel();
|
||||||
QString labelMsg = tr("Opacity of area outside selection:") + " %1%";
|
QString labelMsg = tr("Opacity of area outside selection:") + " %1%";
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public:
|
|||||||
|
|
||||||
CaptureRequest(CaptureMode mode,
|
CaptureRequest(CaptureMode mode,
|
||||||
const uint delay = 0,
|
const uint delay = 0,
|
||||||
const QString &path = "",
|
const QString &path = QLatin1String(""),
|
||||||
const QVariant &data = QVariant(),
|
const QVariant &data = QVariant(),
|
||||||
ExportTask tasks = NO_TASK);
|
ExportTask tasks = NO_TASK);
|
||||||
|
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ void Controller::enableTrayIcon() {
|
|||||||
trayIconMenu->addAction(quitAction);
|
trayIconMenu->addAction(quitAction);
|
||||||
|
|
||||||
m_trayIcon = new QSystemTrayIcon();
|
m_trayIcon = new QSystemTrayIcon();
|
||||||
m_trayIcon->setToolTip("Flameshot");
|
m_trayIcon->setToolTip(QStringLiteral("Flameshot"));
|
||||||
m_trayIcon->setContextMenu(trayIconMenu);
|
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);
|
m_trayIcon->setIcon(trayicon);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public slots:
|
|||||||
void enableTrayIcon();
|
void enableTrayIcon();
|
||||||
void disableTrayIcon();
|
void disableTrayIcon();
|
||||||
void sendTrayNotification(const QString &text,
|
void sendTrayNotification(const QString &text,
|
||||||
const QString &title = "Flameshot Info",
|
const QString &title = QStringLiteral("Flameshot Info"),
|
||||||
const int timeout = 5000);
|
const int timeout = 5000);
|
||||||
|
|
||||||
void updateConfigComponents();
|
void updateConfigComponents();
|
||||||
|
|||||||
138
src/main.cpp
138
src/main.cpp
@@ -51,7 +51,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
for (const QString &path: trPaths) {
|
for (const QString &path: trPaths) {
|
||||||
bool match = translator.load(QLocale(),
|
bool match = translator.load(QLocale(),
|
||||||
"Internationalization", "_",
|
QStringLiteral("Internationalization"), QStringLiteral("_"),
|
||||||
path);
|
path);
|
||||||
if (match) {
|
if (match) {
|
||||||
break;
|
break;
|
||||||
@@ -60,8 +60,8 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
app.installTranslator(&translator);
|
app.installTranslator(&translator);
|
||||||
app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
|
app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
|
||||||
app.setApplicationName("flameshot");
|
app.setApplicationName(QStringLiteral("flameshot"));
|
||||||
app.setOrganizationName("Dharkael");
|
app.setOrganizationName(QStringLiteral("Dharkael"));
|
||||||
|
|
||||||
auto c = Controller::getInstance();
|
auto c = Controller::getInstance();
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
|
||||||
@@ -71,8 +71,8 @@ int main(int argc, char *argv[]) {
|
|||||||
SystemNotification().sendMessage(
|
SystemNotification().sendMessage(
|
||||||
QObject::tr("Unable to connect via DBus"));
|
QObject::tr("Unable to connect via DBus"));
|
||||||
}
|
}
|
||||||
dbus.registerObject("/", c);
|
dbus.registerObject(QStringLiteral("/"), c);
|
||||||
dbus.registerService("org.dharkael.Flameshot");
|
dbus.registerService(QStringLiteral("org.dharkael.Flameshot"));
|
||||||
#endif
|
#endif
|
||||||
// Exporting captures must be connected after the dbus interface
|
// Exporting captures must be connected after the dbus interface
|
||||||
// or the dbus signal gets blocked until we end the exports.
|
// or the dbus signal gets blocked until we end the exports.
|
||||||
@@ -85,66 +85,66 @@ int main(int argc, char *argv[]) {
|
|||||||
* CLI parsing |
|
* CLI parsing |
|
||||||
* ------------*/
|
* ------------*/
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
app.setApplicationName("flameshot");
|
app.setApplicationName(QStringLiteral("flameshot"));
|
||||||
app.setOrganizationName("Dharkael");
|
app.setOrganizationName(QStringLiteral("Dharkael"));
|
||||||
app.setApplicationVersion(qApp->applicationVersion());
|
app.setApplicationVersion(qApp->applicationVersion());
|
||||||
CommandLineParser parser;
|
CommandLineParser parser;
|
||||||
// Add description
|
// Add description
|
||||||
parser.setDescription(
|
parser.setDescription(
|
||||||
"Powerful yet simple to use screenshot software.");
|
QStringLiteral("Powerful yet simple to use screenshot software."));
|
||||||
parser.setGeneralErrorMessage("See 'flameshot --help'.");
|
parser.setGeneralErrorMessage(QStringLiteral("See 'flameshot --help'."));
|
||||||
// Arguments
|
// Arguments
|
||||||
CommandArgument fullArgument("full", "Capture the entire desktop.");
|
CommandArgument fullArgument(QStringLiteral("full"), QStringLiteral("Capture the entire desktop."));
|
||||||
CommandArgument guiArgument("gui", "Start a manual capture in GUI mode.");
|
CommandArgument guiArgument(QStringLiteral("gui"), QStringLiteral("Start a manual capture in GUI mode."));
|
||||||
CommandArgument configArgument("config", "Configure flameshot.");
|
CommandArgument configArgument(QStringLiteral("config"), QStringLiteral("Configure flameshot."));
|
||||||
CommandArgument screenArgument("screen", "Capture a single screen.");
|
CommandArgument screenArgument(QStringLiteral("screen"), QStringLiteral("Capture a single screen."));
|
||||||
|
|
||||||
// Options
|
// Options
|
||||||
CommandOption pathOption(
|
CommandOption pathOption(
|
||||||
{"p", "path"},
|
{"p", "path"},
|
||||||
"Path where the capture will be saved",
|
QStringLiteral("Path where the capture will be saved"),
|
||||||
"path");
|
QStringLiteral("path"));
|
||||||
CommandOption clipboardOption(
|
CommandOption clipboardOption(
|
||||||
{"c", "clipboard"},
|
{"c", "clipboard"},
|
||||||
"Save the capture to the clipboard");
|
QStringLiteral("Save the capture to the clipboard"));
|
||||||
CommandOption delayOption(
|
CommandOption delayOption(
|
||||||
{"d", "delay"},
|
{"d", "delay"},
|
||||||
"Delay time in milliseconds",
|
QStringLiteral("Delay time in milliseconds"),
|
||||||
"milliseconds");
|
QStringLiteral("milliseconds"));
|
||||||
CommandOption filenameOption(
|
CommandOption filenameOption(
|
||||||
{"f", "filename"},
|
{"f", "filename"},
|
||||||
"Set the filename pattern",
|
QStringLiteral("Set the filename pattern"),
|
||||||
"pattern");
|
QStringLiteral("pattern"));
|
||||||
CommandOption trayOption(
|
CommandOption trayOption(
|
||||||
{"t", "trayicon"},
|
{"t", "trayicon"},
|
||||||
"Enable or disable the trayicon",
|
QStringLiteral("Enable or disable the trayicon"),
|
||||||
"bool");
|
QStringLiteral("bool"));
|
||||||
CommandOption autostartOption(
|
CommandOption autostartOption(
|
||||||
{"a", "autostart"},
|
{"a", "autostart"},
|
||||||
"Enable or disable run at startup",
|
QStringLiteral("Enable or disable run at startup"),
|
||||||
"bool");
|
QStringLiteral("bool"));
|
||||||
CommandOption showHelpOption(
|
CommandOption showHelpOption(
|
||||||
{"s", "showhelp"},
|
{"s", "showhelp"},
|
||||||
"Show the help message in the capture mode",
|
QStringLiteral("Show the help message in the capture mode"),
|
||||||
"bool");
|
QStringLiteral("bool"));
|
||||||
CommandOption mainColorOption(
|
CommandOption mainColorOption(
|
||||||
{"m", "maincolor"},
|
{"m", "maincolor"},
|
||||||
"Define the main UI color",
|
QStringLiteral("Define the main UI color"),
|
||||||
"color-code");
|
QStringLiteral("color-code"));
|
||||||
CommandOption contrastColorOption(
|
CommandOption contrastColorOption(
|
||||||
{"k", "contrastcolor"},
|
{"k", "contrastcolor"},
|
||||||
"Define the contrast UI color",
|
QStringLiteral("Define the contrast UI color"),
|
||||||
"color-code");
|
QStringLiteral("color-code"));
|
||||||
CommandOption rawImageOption(
|
CommandOption rawImageOption(
|
||||||
{"r", "raw"},
|
{"r", "raw"},
|
||||||
"Print raw PNG capture");
|
QStringLiteral("Print raw PNG capture"));
|
||||||
CommandOption screenNumberOption(
|
CommandOption screenNumberOption(
|
||||||
{"n", "number"},
|
{"n", "number"},
|
||||||
"Define the screen to capture,\ndefault: screen containing the cursor",
|
QStringLiteral("Define the screen to capture,\ndefault: screen containing the cursor"),
|
||||||
"Screen number", "-1");
|
QStringLiteral("Screen number"), QStringLiteral("-1"));
|
||||||
|
|
||||||
// Add checkers
|
// Add checkers
|
||||||
auto colorChecker = [&parser](const QString &colorCode) -> bool {
|
auto colorChecker = [](const QString &colorCode) -> bool {
|
||||||
QColor parsedColor(colorCode);
|
QColor parsedColor(colorCode);
|
||||||
return parsedColor.isValid() && parsedColor.alphaF() == 1.0;
|
return parsedColor.isValid() && parsedColor.alphaF() == 1.0;
|
||||||
};
|
};
|
||||||
@@ -156,15 +156,15 @@ int main(int argc, char *argv[]) {
|
|||||||
"- Named colors like 'blue' or 'red'\n"
|
"- Named colors like 'blue' or 'red'\n"
|
||||||
"You may need to escape the '#' sign as in '\\#FFF'";
|
"You may need to escape the '#' sign as in '\\#FFF'";
|
||||||
|
|
||||||
const QString delayErr = "Invalid delay, it must be higher than 0";
|
const QString delayErr = QStringLiteral("Invalid delay, it must be higher than 0");
|
||||||
const QString numberErr = "Invalid screen number, it must be non negative";
|
const QString numberErr = QStringLiteral("Invalid screen number, it must be non negative");
|
||||||
auto numericChecker = [&parser](const QString &delayValue) -> bool {
|
auto numericChecker = [](const QString &delayValue) -> bool {
|
||||||
int value = delayValue.toInt();
|
int value = delayValue.toInt();
|
||||||
return value >= 0;
|
return value >= 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
const QString pathErr = "Invalid path, it must be a real path in the system";
|
const QString pathErr = QStringLiteral("Invalid path, it must be a real path in the system");
|
||||||
auto pathChecker = [&parser, pathErr](const QString &pathValue) -> bool {
|
auto pathChecker = [pathErr](const QString &pathValue) -> bool {
|
||||||
bool res = QDir(pathValue).exists();
|
bool res = QDir(pathValue).exists();
|
||||||
if (!res) {
|
if (!res) {
|
||||||
SystemNotification().sendMessage(QObject::tr(pathErr.toLatin1().data()));
|
SystemNotification().sendMessage(QObject::tr(pathErr.toLatin1().data()));
|
||||||
@@ -172,9 +172,9 @@ int main(int argc, char *argv[]) {
|
|||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
const QString booleanErr = "Invalid value, it must be defined as 'true' or 'false'";
|
const QString booleanErr = QStringLiteral("Invalid value, it must be defined as 'true' or 'false'");
|
||||||
auto booleanChecker = [&parser](const QString &value) -> bool {
|
auto booleanChecker = [](const QString &value) -> bool {
|
||||||
return value == "true" || value == "false";
|
return value == QLatin1String("true") || value == QLatin1String("false");
|
||||||
};
|
};
|
||||||
|
|
||||||
contrastColorOption.addChecker(colorChecker, colorErr);
|
contrastColorOption.addChecker(colorChecker, colorErr);
|
||||||
@@ -220,8 +220,8 @@ int main(int argc, char *argv[]) {
|
|||||||
uint id = req.id();
|
uint id = req.id();
|
||||||
|
|
||||||
// Send message
|
// Send message
|
||||||
QDBusMessage m = QDBusMessage::createMethodCall("org.dharkael.Flameshot",
|
QDBusMessage m = QDBusMessage::createMethodCall(QStringLiteral("org.dharkael.Flameshot"),
|
||||||
"/", "", "graphicCapture");
|
QStringLiteral("/"), QLatin1String(""), QStringLiteral("graphicCapture"));
|
||||||
m << pathValue << delay << id;
|
m << pathValue << delay << id;
|
||||||
QDBusConnection sessionBus = QDBusConnection::sessionBus();
|
QDBusConnection sessionBus = QDBusConnection::sessionBus();
|
||||||
dbusUtils.checkDBusConnection(sessionBus);
|
dbusUtils.checkDBusConnection(sessionBus);
|
||||||
@@ -248,10 +248,10 @@ int main(int argc, char *argv[]) {
|
|||||||
QTextStream out(stdout);
|
QTextStream out(stdout);
|
||||||
out << "Invalid format, set where to save the content with one of "
|
out << "Invalid format, set where to save the content with one of "
|
||||||
<< "the following flags:\n "
|
<< "the following flags:\n "
|
||||||
<< pathOption.dashedNames().join(", ") << "\n "
|
<< pathOption.dashedNames().join(QStringLiteral(", ")) << "\n "
|
||||||
<< rawImageOption.dashedNames().join(", ") << "\n "
|
<< rawImageOption.dashedNames().join(QStringLiteral(", ")) << "\n "
|
||||||
<< clipboardOption.dashedNames().join(", ") << "\n\n";
|
<< clipboardOption.dashedNames().join(QStringLiteral(", ")) << "\n\n";
|
||||||
parser.parse(QStringList() << argv[0] << "full" << "-h");
|
parser.parse(QStringList() << argv[0] << QStringLiteral("full") << QStringLiteral("-h"));
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,8 +266,8 @@ int main(int argc, char *argv[]) {
|
|||||||
DBusUtils dbusUtils;
|
DBusUtils dbusUtils;
|
||||||
|
|
||||||
// Send message
|
// Send message
|
||||||
QDBusMessage m = QDBusMessage::createMethodCall("org.dharkael.Flameshot",
|
QDBusMessage m = QDBusMessage::createMethodCall(QStringLiteral("org.dharkael.Flameshot"),
|
||||||
"/", "", "fullScreen");
|
QStringLiteral("/"), QLatin1String(""), QStringLiteral("fullScreen"));
|
||||||
m << pathValue << toClipboard << delay << id;
|
m << pathValue << toClipboard << delay << id;
|
||||||
QDBusConnection sessionBus = QDBusConnection::sessionBus();
|
QDBusConnection sessionBus = QDBusConnection::sessionBus();
|
||||||
dbusUtils.checkDBusConnection(sessionBus);
|
dbusUtils.checkDBusConnection(sessionBus);
|
||||||
@@ -287,7 +287,7 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
else if (parser.isSet(screenArgument)) { // SCREEN
|
else if (parser.isSet(screenArgument)) { // SCREEN
|
||||||
QString numberStr = parser.value(screenNumberOption);
|
QString numberStr = parser.value(screenNumberOption);
|
||||||
int number = numberStr.startsWith("-") ? -1 : numberStr.toInt();
|
int number = numberStr.startsWith(QLatin1String("-")) ? -1 : numberStr.toInt();
|
||||||
QString pathValue = parser.value(pathOption);
|
QString pathValue = parser.value(pathOption);
|
||||||
int delay = parser.value(delayOption).toInt();
|
int delay = parser.value(delayOption).toInt();
|
||||||
bool toClipboard = parser.isSet(clipboardOption);
|
bool toClipboard = parser.isSet(clipboardOption);
|
||||||
@@ -297,10 +297,10 @@ int main(int argc, char *argv[]) {
|
|||||||
QTextStream out(stdout);
|
QTextStream out(stdout);
|
||||||
out << "Invalid format, set where to save the content with one of "
|
out << "Invalid format, set where to save the content with one of "
|
||||||
<< "the following flags:\n "
|
<< "the following flags:\n "
|
||||||
<< pathOption.dashedNames().join(", ") << "\n "
|
<< pathOption.dashedNames().join(QStringLiteral(", ")) << "\n "
|
||||||
<< rawImageOption.dashedNames().join(", ") << "\n "
|
<< rawImageOption.dashedNames().join(QStringLiteral(", ")) << "\n "
|
||||||
<< clipboardOption.dashedNames().join(", ") << "\n\n";
|
<< clipboardOption.dashedNames().join(QStringLiteral(", ")) << "\n\n";
|
||||||
parser.parse(QStringList() << argv[0] << "screen" << "-h");
|
parser.parse(QStringList() << argv[0] << QStringLiteral("screen") << QStringLiteral("-h"));
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,8 +316,8 @@ int main(int argc, char *argv[]) {
|
|||||||
DBusUtils dbusUtils;
|
DBusUtils dbusUtils;
|
||||||
|
|
||||||
// Send message
|
// Send message
|
||||||
QDBusMessage m = QDBusMessage::createMethodCall("org.dharkael.Flameshot",
|
QDBusMessage m = QDBusMessage::createMethodCall(QStringLiteral("org.dharkael.Flameshot"),
|
||||||
"/", "", "captureScreen");
|
QStringLiteral("/"), QLatin1String(""), QStringLiteral("captureScreen"));
|
||||||
m << number << pathValue << toClipboard << delay << id;
|
m << number << pathValue << toClipboard << delay << id;
|
||||||
QDBusConnection sessionBus = QDBusConnection::sessionBus();
|
QDBusConnection sessionBus = QDBusConnection::sessionBus();
|
||||||
dbusUtils.checkDBusConnection(sessionBus);
|
dbusUtils.checkDBusConnection(sessionBus);
|
||||||
@@ -346,11 +346,11 @@ int main(int argc, char *argv[]) {
|
|||||||
mainColor || contrastColor);
|
mainColor || contrastColor);
|
||||||
ConfigHandler config;
|
ConfigHandler config;
|
||||||
if (autostart) {
|
if (autostart) {
|
||||||
QDBusMessage m = QDBusMessage::createMethodCall("org.dharkael.Flameshot",
|
QDBusMessage m = QDBusMessage::createMethodCall(QStringLiteral("org.dharkael.Flameshot"),
|
||||||
"/", "", "autostartEnabled");
|
QStringLiteral("/"), QLatin1String(""), QStringLiteral("autostartEnabled"));
|
||||||
if (parser.value(autostartOption) == "false") {
|
if (parser.value(autostartOption) == QLatin1String("false")) {
|
||||||
m << false;
|
m << false;
|
||||||
} else if (parser.value(autostartOption) == "true") {
|
} else if (parser.value(autostartOption) == QLatin1String("true")) {
|
||||||
m << true;
|
m << true;
|
||||||
}
|
}
|
||||||
QDBusConnection sessionBus = QDBusConnection::sessionBus();
|
QDBusConnection sessionBus = QDBusConnection::sessionBus();
|
||||||
@@ -370,11 +370,11 @@ int main(int argc, char *argv[]) {
|
|||||||
.arg(fh.parsedPattern());
|
.arg(fh.parsedPattern());
|
||||||
}
|
}
|
||||||
if (tray) {
|
if (tray) {
|
||||||
QDBusMessage m = QDBusMessage::createMethodCall("org.dharkael.Flameshot",
|
QDBusMessage m = QDBusMessage::createMethodCall(QStringLiteral("org.dharkael.Flameshot"),
|
||||||
"/", "", "trayIconEnabled");
|
QStringLiteral("/"), QLatin1String(""), QStringLiteral("trayIconEnabled"));
|
||||||
if (parser.value(trayOption) == "false") {
|
if (parser.value(trayOption) == QLatin1String("false")) {
|
||||||
m << false;
|
m << false;
|
||||||
} else if (parser.value(trayOption) == "true") {
|
} else if (parser.value(trayOption) == QLatin1String("true")) {
|
||||||
m << true;
|
m << true;
|
||||||
}
|
}
|
||||||
QDBusConnection sessionBus = QDBusConnection::sessionBus();
|
QDBusConnection sessionBus = QDBusConnection::sessionBus();
|
||||||
@@ -385,9 +385,9 @@ int main(int argc, char *argv[]) {
|
|||||||
sessionBus.call(m);
|
sessionBus.call(m);
|
||||||
}
|
}
|
||||||
if (help) {
|
if (help) {
|
||||||
if (parser.value(showHelpOption) == "false") {
|
if (parser.value(showHelpOption) == QLatin1String("false")) {
|
||||||
config.setShowHelp(false);
|
config.setShowHelp(false);
|
||||||
} else if (parser.value(showHelpOption) == "true") {
|
} else if (parser.value(showHelpOption) == QLatin1String("true")) {
|
||||||
config.setShowHelp(true);
|
config.setShowHelp(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -404,8 +404,8 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
// Open gui when no options
|
// Open gui when no options
|
||||||
if (!someFlagSet) {
|
if (!someFlagSet) {
|
||||||
QDBusMessage m = QDBusMessage::createMethodCall("org.dharkael.Flameshot",
|
QDBusMessage m = QDBusMessage::createMethodCall(QStringLiteral("org.dharkael.Flameshot"),
|
||||||
"/", "", "openConfig");
|
QStringLiteral("/"), QLatin1String(""), QStringLiteral("openConfig"));
|
||||||
QDBusConnection sessionBus = QDBusConnection::sessionBus();
|
QDBusConnection sessionBus = QDBusConnection::sessionBus();
|
||||||
if (!sessionBus.isConnected()) {
|
if (!sessionBus.isConnected()) {
|
||||||
SystemNotification().sendMessage(
|
SystemNotification().sendMessage(
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ void SingleApplicationPrivate::genBlockServerName( int timeout )
|
|||||||
#endif
|
#endif
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.start( "whoami" );
|
process.start( QStringLiteral("whoami") );
|
||||||
if( process.waitForFinished( timeout ) &&
|
if( process.waitForFinished( timeout ) &&
|
||||||
process.exitCode() == QProcess::NormalExit) {
|
process.exitCode() == QProcess::NormalExit) {
|
||||||
appData.addData( process.readLine() );
|
appData.addData( process.readLine() );
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ QString ArrowTool::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString ArrowTool::nameID() {
|
QString ArrowTool::nameID() {
|
||||||
return "";
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ArrowTool::description() const {
|
QString ArrowTool::description() const {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ QString BlurTool::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString BlurTool::nameID() {
|
QString BlurTool::nameID() {
|
||||||
return "";
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BlurTool::description() const {
|
QString BlurTool::description() const {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ QString CircleTool::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString CircleTool::nameID() {
|
QString CircleTool::nameID() {
|
||||||
return "";
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CircleTool::description() const {
|
QString CircleTool::description() const {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ QString CopyTool::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString CopyTool::nameID() {
|
QString CopyTool::nameID() {
|
||||||
return "";
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CopyTool::description() const {
|
QString CopyTool::description() const {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ QString ExitTool::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString ExitTool::nameID() {
|
QString ExitTool::nameID() {
|
||||||
return "";
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ExitTool::description() const {
|
QString ExitTool::description() const {
|
||||||
|
|||||||
@@ -72,10 +72,10 @@ void ImgurUploader::handleReply(QNetworkReply *reply) {
|
|||||||
if (reply->error() == QNetworkReply::NoError) {
|
if (reply->error() == QNetworkReply::NoError) {
|
||||||
QJsonDocument response = QJsonDocument::fromJson(reply->readAll());
|
QJsonDocument response = QJsonDocument::fromJson(reply->readAll());
|
||||||
QJsonObject json = response.object();
|
QJsonObject json = response.object();
|
||||||
QJsonObject data = json["data"].toObject();
|
QJsonObject data = json[QStringLiteral("data")].toObject();
|
||||||
m_imageURL.setUrl(data["link"].toString());
|
m_imageURL.setUrl(data[QStringLiteral("link")].toString());
|
||||||
m_deleteImageURL.setUrl(QString("https://imgur.com/delete/%1").arg(
|
m_deleteImageURL.setUrl(QStringLiteral("https://imgur.com/delete/%1").arg(
|
||||||
data["deletehash"].toString()));
|
data[QStringLiteral("deletehash")].toString()));
|
||||||
onUploadOk();
|
onUploadOk();
|
||||||
} else {
|
} else {
|
||||||
m_infoLabel->setText(reply->errorString());
|
m_infoLabel->setText(reply->errorString());
|
||||||
@@ -101,16 +101,16 @@ void ImgurUploader::upload() {
|
|||||||
m_pixmap.save(&buffer, "PNG");
|
m_pixmap.save(&buffer, "PNG");
|
||||||
|
|
||||||
QUrlQuery urlQuery;
|
QUrlQuery urlQuery;
|
||||||
urlQuery.addQueryItem("title", "flameshot_screenshot");
|
urlQuery.addQueryItem(QStringLiteral("title"), QStringLiteral("flameshot_screenshot"));
|
||||||
QString description = FileNameHandler().parsedPattern();
|
QString description = FileNameHandler().parsedPattern();
|
||||||
urlQuery.addQueryItem("description", description);
|
urlQuery.addQueryItem(QStringLiteral("description"), description);
|
||||||
|
|
||||||
QUrl url("https://api.imgur.com/3/image");
|
QUrl url(QStringLiteral("https://api.imgur.com/3/image"));
|
||||||
url.setQuery(urlQuery);
|
url.setQuery(urlQuery);
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader,
|
request.setHeader(QNetworkRequest::ContentTypeHeader,
|
||||||
"application/application/x-www-form-urlencoded");
|
"application/application/x-www-form-urlencoded");
|
||||||
request.setRawHeader("Authorization", QString("Client-ID %1").arg(IMGUR_CLIENT_ID).toUtf8());
|
request.setRawHeader("Authorization", QStringLiteral("Client-ID %1").arg(IMGUR_CLIENT_ID).toUtf8());
|
||||||
|
|
||||||
m_NetworkAM->post(request, byteArray);
|
m_NetworkAM->post(request, byteArray);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ QString ImgurUploaderTool::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString ImgurUploaderTool::nameID() {
|
QString ImgurUploaderTool::nameID() {
|
||||||
return "";
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ImgurUploaderTool::description() const {
|
QString ImgurUploaderTool::description() const {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ QString AppLauncher::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString AppLauncher::nameID() {
|
QString AppLauncher::nameID() {
|
||||||
return "";
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AppLauncher::description() const {
|
QString AppLauncher::description() const {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ AppLauncherWidget::AppLauncherWidget(const QPixmap &p, QWidget *parent):
|
|||||||
QDir appsDirLocal(dirLocal);
|
QDir appsDirLocal(dirLocal);
|
||||||
m_parser.processDirectory(appsDirLocal);
|
m_parser.processDirectory(appsDirLocal);
|
||||||
|
|
||||||
QString dir = "/usr/share/applications/";
|
QString dir = QStringLiteral("/usr/share/applications/");
|
||||||
QDir appsDir(dir);
|
QDir appsDir(dir);
|
||||||
m_parser.processDirectory(appsDir);
|
m_parser.processDirectory(appsDir);
|
||||||
|
|
||||||
@@ -173,9 +173,9 @@ void AppLauncherWidget::initListWidget() {
|
|||||||
const QVector<DesktopAppData> &appList = m_appsMap[cat];
|
const QVector<DesktopAppData> &appList = m_appsMap[cat];
|
||||||
addAppsToListWidget(itemsWidget, appList);
|
addAppsToListWidget(itemsWidget, appList);
|
||||||
|
|
||||||
m_tabWidget->addTab(itemsWidget, QIcon::fromTheme(iconName), "");
|
m_tabWidget->addTab(itemsWidget, QIcon::fromTheme(iconName), QLatin1String(""));
|
||||||
m_tabWidget->setTabToolTip(m_tabWidget->count(), cat);
|
m_tabWidget->setTabToolTip(m_tabWidget->count(), cat);
|
||||||
if (cat == "Graphics") {
|
if (cat == QLatin1String("Graphics")) {
|
||||||
m_tabWidget->setCurrentIndex(m_tabWidget->count() -1);
|
m_tabWidget->setCurrentIndex(m_tabWidget->count() -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -199,7 +199,7 @@ void AppLauncherWidget::initAppMap() {
|
|||||||
// Unify multimedia.
|
// Unify multimedia.
|
||||||
QVector<DesktopAppData> multimediaList;
|
QVector<DesktopAppData> multimediaList;
|
||||||
QStringList multimediaNames;
|
QStringList multimediaNames;
|
||||||
multimediaNames << "AudioVideo" << "Audio" << "Video";
|
multimediaNames << QStringLiteral("AudioVideo") << QStringLiteral("Audio") << QStringLiteral("Video");
|
||||||
for (const QString &name : multimediaNames) {
|
for (const QString &name : multimediaNames) {
|
||||||
if(!m_appsMap.contains(name)) {
|
if(!m_appsMap.contains(name)) {
|
||||||
continue;
|
continue;
|
||||||
@@ -211,7 +211,7 @@ void AppLauncherWidget::initAppMap() {
|
|||||||
}
|
}
|
||||||
m_appsMap.remove(name);
|
m_appsMap.remove(name);
|
||||||
}
|
}
|
||||||
m_appsMap.insert("Multimedia", multimediaList);
|
m_appsMap.insert(QStringLiteral("Multimedia"), multimediaList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppLauncherWidget::configureListView(QListWidget *widget) {
|
void AppLauncherWidget::configureListView(QListWidget *widget) {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ QString LineTool::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString LineTool::nameID() {
|
QString LineTool::nameID() {
|
||||||
return "";
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LineTool::description() const {
|
QString LineTool::description() const {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ QString MarkerTool::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString MarkerTool::nameID() {
|
QString MarkerTool::nameID() {
|
||||||
return "";
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MarkerTool::description() const {
|
QString MarkerTool::description() const {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ QString MoveTool::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString MoveTool::nameID() {
|
QString MoveTool::nameID() {
|
||||||
return "";
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MoveTool::description() const {
|
QString MoveTool::description() const {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ QString PencilTool::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString PencilTool::nameID() {
|
QString PencilTool::nameID() {
|
||||||
return "";
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PencilTool::description() const {
|
QString PencilTool::description() const {
|
||||||
|
|||||||
2
src/tools/pin/pintool.cpp
Executable file → Normal file
2
src/tools/pin/pintool.cpp
Executable file → Normal file
@@ -35,7 +35,7 @@ QString PinTool::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString PinTool::nameID() {
|
QString PinTool::nameID() {
|
||||||
return "";
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PinTool::description() const {
|
QString PinTool::description() const {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ QString RectangleTool::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString RectangleTool::nameID() {
|
QString RectangleTool::nameID() {
|
||||||
return "";
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RectangleTool::description() const {
|
QString RectangleTool::description() const {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ QString RedoTool::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString RedoTool::nameID() {
|
QString RedoTool::nameID() {
|
||||||
return "";
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RedoTool::description() const {
|
QString RedoTool::description() const {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ QString SaveTool::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString SaveTool::nameID() {
|
QString SaveTool::nameID() {
|
||||||
return "";
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SaveTool::description() const {
|
QString SaveTool::description() const {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ QString SelectionTool::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString SelectionTool::nameID() {
|
QString SelectionTool::nameID() {
|
||||||
return "";
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SelectionTool::description() const {
|
QString SelectionTool::description() const {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ QString SizeIndicatorTool::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString SizeIndicatorTool::nameID() {
|
QString SizeIndicatorTool::nameID() {
|
||||||
return "";
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SizeIndicatorTool::description() const {
|
QString SizeIndicatorTool::description() const {
|
||||||
|
|||||||
@@ -42,28 +42,28 @@ TextConfig::TextConfig(QWidget *parent) : QWidget(parent) {
|
|||||||
PathInfo::blackIconPath();
|
PathInfo::blackIconPath();
|
||||||
|
|
||||||
m_strikeOutButton = new QPushButton(
|
m_strikeOutButton = new QPushButton(
|
||||||
QIcon(iconPrefix + "format_strikethrough.svg"), "");
|
QIcon(iconPrefix + "format_strikethrough.svg"), QLatin1String(""));
|
||||||
m_strikeOutButton->setCheckable(true);
|
m_strikeOutButton->setCheckable(true);
|
||||||
connect(m_strikeOutButton, &QPushButton::clicked,
|
connect(m_strikeOutButton, &QPushButton::clicked,
|
||||||
this, &TextConfig::fontStrikeOutChanged);
|
this, &TextConfig::fontStrikeOutChanged);
|
||||||
m_strikeOutButton->setToolTip(tr("StrikeOut"));
|
m_strikeOutButton->setToolTip(tr("StrikeOut"));
|
||||||
|
|
||||||
m_underlineButton = new QPushButton(
|
m_underlineButton = new QPushButton(
|
||||||
QIcon(iconPrefix + "format_underlined.svg"), "");
|
QIcon(iconPrefix + "format_underlined.svg"), QLatin1String(""));
|
||||||
m_underlineButton->setCheckable(true);
|
m_underlineButton->setCheckable(true);
|
||||||
connect(m_underlineButton, &QPushButton::clicked,
|
connect(m_underlineButton, &QPushButton::clicked,
|
||||||
this, &TextConfig::fontUnderlineChanged);
|
this, &TextConfig::fontUnderlineChanged);
|
||||||
m_underlineButton->setToolTip(tr("Underline"));
|
m_underlineButton->setToolTip(tr("Underline"));
|
||||||
|
|
||||||
m_weightButton = new QPushButton(
|
m_weightButton = new QPushButton(
|
||||||
QIcon(iconPrefix + "format_bold.svg"), "");
|
QIcon(iconPrefix + "format_bold.svg"), QLatin1String(""));
|
||||||
m_weightButton->setCheckable(true);
|
m_weightButton->setCheckable(true);
|
||||||
connect(m_weightButton, &QPushButton::clicked,
|
connect(m_weightButton, &QPushButton::clicked,
|
||||||
this, &TextConfig::weightButtonPressed);
|
this, &TextConfig::weightButtonPressed);
|
||||||
m_weightButton->setToolTip(tr("Bold"));
|
m_weightButton->setToolTip(tr("Bold"));
|
||||||
|
|
||||||
m_italicButton = new QPushButton(
|
m_italicButton = new QPushButton(
|
||||||
QIcon(iconPrefix + "format_italic.svg"), "");
|
QIcon(iconPrefix + "format_italic.svg"), QLatin1String(""));
|
||||||
m_italicButton->setCheckable(true);
|
m_italicButton->setCheckable(true);
|
||||||
connect(m_italicButton, &QPushButton::clicked,
|
connect(m_italicButton, &QPushButton::clicked,
|
||||||
this, &TextConfig::fontItalicChanged);
|
this, &TextConfig::fontItalicChanged);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ QString TextTool::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString TextTool::nameID() {
|
QString TextTool::nameID() {
|
||||||
return "";
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TextTool::description() const {
|
QString TextTool::description() const {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
#include "textwidget.h"
|
#include "textwidget.h"
|
||||||
|
|
||||||
TextWidget::TextWidget(QWidget *parent) : QTextEdit(parent) {
|
TextWidget::TextWidget(QWidget *parent) : QTextEdit(parent) {
|
||||||
setStyleSheet("TextWidget { background: transparent; }");
|
setStyleSheet(QStringLiteral("TextWidget { background: transparent; }"));
|
||||||
connect(this, &TextWidget::textChanged,
|
connect(this, &TextWidget::textChanged,
|
||||||
this, &TextWidget::adjustSize);
|
this, &TextWidget::adjustSize);
|
||||||
connect(this, &TextWidget::textChanged,
|
connect(this, &TextWidget::textChanged,
|
||||||
@@ -61,7 +61,7 @@ void TextWidget::setFontPointSize(qreal s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TextWidget::setTextColor(const QColor &c) {
|
void TextWidget::setTextColor(const QColor &c) {
|
||||||
QString s("TextWidget { background: transparent; color: %1; }");
|
QString s(QStringLiteral("TextWidget { background: transparent; color: %1; }"));
|
||||||
setStyleSheet(s.arg(c.name()));
|
setStyleSheet(s.arg(c.name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ QString UndoTool::name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString UndoTool::nameID() {
|
QString UndoTool::nameID() {
|
||||||
return "";
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString UndoTool::description() const {
|
QString UndoTool::description() const {
|
||||||
|
|||||||
@@ -27,13 +27,13 @@ ConfigHandler::ConfigHandler(){
|
|||||||
|
|
||||||
QVector<CaptureButton::ButtonType> ConfigHandler::getButtons() {
|
QVector<CaptureButton::ButtonType> ConfigHandler::getButtons() {
|
||||||
QVector<CaptureButton::ButtonType> buttons;
|
QVector<CaptureButton::ButtonType> buttons;
|
||||||
if (m_settings.contains("buttons")) {
|
if (m_settings.contains(QStringLiteral("buttons"))) {
|
||||||
// TODO: remove toList in v1.0
|
// TODO: remove toList in v1.0
|
||||||
QVector<int> buttonsInt =
|
QVector<int> buttonsInt =
|
||||||
m_settings.value("buttons").value<QList<int> >().toVector();
|
m_settings.value(QStringLiteral("buttons")).value<QList<int> >().toVector();
|
||||||
bool modified = normalizeButtons(buttonsInt);
|
bool modified = normalizeButtons(buttonsInt);
|
||||||
if (modified) {
|
if (modified) {
|
||||||
m_settings.setValue("buttons", QVariant::fromValue(buttonsInt.toList()));
|
m_settings.setValue(QStringLiteral("buttons"), QVariant::fromValue(buttonsInt.toList()));
|
||||||
}
|
}
|
||||||
buttons = fromIntToButton(buttonsInt);
|
buttons = fromIntToButton(buttonsInt);
|
||||||
} else {
|
} else {
|
||||||
@@ -69,7 +69,7 @@ void ConfigHandler::setButtons(const QVector<CaptureButton::ButtonType> &buttons
|
|||||||
QVector<int> l = fromButtonToInt(buttons);
|
QVector<int> l = fromButtonToInt(buttons);
|
||||||
normalizeButtons(l);
|
normalizeButtons(l);
|
||||||
// TODO: remove toList in v1.0
|
// TODO: remove toList in v1.0
|
||||||
m_settings.setValue("buttons", QVariant::fromValue(l.toList()));
|
m_settings.setValue(QStringLiteral("buttons"), QVariant::fromValue(l.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<QColor> ConfigHandler::getUserColors() {
|
QVector<QColor> ConfigHandler::getUserColors() {
|
||||||
@@ -86,8 +86,8 @@ QVector<QColor> ConfigHandler::getUserColors() {
|
|||||||
Qt::darkMagenta
|
Qt::darkMagenta
|
||||||
};
|
};
|
||||||
|
|
||||||
if (m_settings.contains("userColors")) {
|
if (m_settings.contains(QStringLiteral("userColors"))) {
|
||||||
for (const QString &hex : m_settings.value("userColors").toStringList()) {
|
for (const QString &hex : m_settings.value(QStringLiteral("userColors")).toStringList()) {
|
||||||
if (QColor::isValidColor(hex)) {
|
if (QColor::isValidColor(hex)) {
|
||||||
colors.append(QColor(hex));
|
colors.append(QColor(hex));
|
||||||
}
|
}
|
||||||
@@ -110,22 +110,22 @@ void ConfigHandler::setUserColors(const QVector<QColor> &l) {
|
|||||||
hexColors.append(color.name());
|
hexColors.append(color.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_settings.setValue("userColors", QVariant::fromValue(hexColors));
|
m_settings.setValue(QStringLiteral("userColors"), QVariant::fromValue(hexColors));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ConfigHandler::savePathValue() {
|
QString ConfigHandler::savePathValue() {
|
||||||
return m_settings.value("savePath").toString();
|
return m_settings.value(QStringLiteral("savePath")).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigHandler::setSavePath(const QString &savePath) {
|
void ConfigHandler::setSavePath(const QString &savePath) {
|
||||||
m_settings.setValue("savePath", savePath);
|
m_settings.setValue(QStringLiteral("savePath"), savePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor ConfigHandler::uiMainColorValue() {
|
QColor ConfigHandler::uiMainColorValue() {
|
||||||
QColor res = QColor(116, 0, 150);
|
QColor res = QColor(116, 0, 150);
|
||||||
|
|
||||||
if (m_settings.contains("uiColor")) {
|
if (m_settings.contains(QStringLiteral("uiColor"))) {
|
||||||
QString hex = m_settings.value("uiColor").toString();
|
QString hex = m_settings.value(QStringLiteral("uiColor")).toString();
|
||||||
|
|
||||||
if (QColor::isValidColor(hex)) {
|
if (QColor::isValidColor(hex)) {
|
||||||
res = QColor(hex);
|
res = QColor(hex);
|
||||||
@@ -135,14 +135,14 @@ QColor ConfigHandler::uiMainColorValue() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConfigHandler::setUIMainColor(const QColor &c) {
|
void ConfigHandler::setUIMainColor(const QColor &c) {
|
||||||
m_settings.setValue("uiColor", c.name());
|
m_settings.setValue(QStringLiteral("uiColor"), c.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor ConfigHandler::uiContrastColorValue() {
|
QColor ConfigHandler::uiContrastColorValue() {
|
||||||
QColor res = QColor(86, 0, 120);
|
QColor res = QColor(86, 0, 120);
|
||||||
|
|
||||||
if (m_settings.contains("contastUiColor")) {
|
if (m_settings.contains(QStringLiteral("contastUiColor"))) {
|
||||||
QString hex = m_settings.value("contastUiColor").toString();
|
QString hex = m_settings.value(QStringLiteral("contastUiColor")).toString();
|
||||||
|
|
||||||
if (QColor::isValidColor(hex)) {
|
if (QColor::isValidColor(hex)) {
|
||||||
res = QColor(hex);
|
res = QColor(hex);
|
||||||
@@ -153,14 +153,14 @@ QColor ConfigHandler::uiContrastColorValue() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConfigHandler::setUIContrastColor(const QColor &c) {
|
void ConfigHandler::setUIContrastColor(const QColor &c) {
|
||||||
m_settings.setValue("contastUiColor", c.name());
|
m_settings.setValue(QStringLiteral("contastUiColor"), c.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor ConfigHandler::drawColorValue() {
|
QColor ConfigHandler::drawColorValue() {
|
||||||
QColor res(Qt::red);
|
QColor res(Qt::red);
|
||||||
|
|
||||||
if (m_settings.contains("drawColor")) {
|
if (m_settings.contains(QStringLiteral("drawColor"))) {
|
||||||
QString hex = m_settings.value("drawColor").toString();
|
QString hex = m_settings.value(QStringLiteral("drawColor")).toString();
|
||||||
|
|
||||||
if (QColor::isValidColor(hex)) {
|
if (QColor::isValidColor(hex)) {
|
||||||
res = QColor(hex);
|
res = QColor(hex);
|
||||||
@@ -171,71 +171,71 @@ QColor ConfigHandler::drawColorValue() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConfigHandler::setDrawColor(const QColor &c) {
|
void ConfigHandler::setDrawColor(const QColor &c) {
|
||||||
m_settings.setValue("drawColor", c.name());
|
m_settings.setValue(QStringLiteral("drawColor"), c.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfigHandler::showHelpValue() {
|
bool ConfigHandler::showHelpValue() {
|
||||||
bool res = true;
|
bool res = true;
|
||||||
if (m_settings.contains("showHelp")) {
|
if (m_settings.contains(QStringLiteral("showHelp"))) {
|
||||||
res = m_settings.value("showHelp").toBool();
|
res = m_settings.value(QStringLiteral("showHelp")).toBool();
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigHandler::setShowHelp(const bool showHelp) {
|
void ConfigHandler::setShowHelp(const bool showHelp) {
|
||||||
m_settings.setValue("showHelp", showHelp);
|
m_settings.setValue(QStringLiteral("showHelp"), showHelp);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfigHandler::desktopNotificationValue() {
|
bool ConfigHandler::desktopNotificationValue() {
|
||||||
bool res = true;
|
bool res = true;
|
||||||
if (m_settings.contains("showDesktopNotification")) {
|
if (m_settings.contains(QStringLiteral("showDesktopNotification"))) {
|
||||||
res = m_settings.value("showDesktopNotification").toBool();
|
res = m_settings.value(QStringLiteral("showDesktopNotification")).toBool();
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigHandler::setDesktopNotification(const bool showDesktopNotification) {
|
void ConfigHandler::setDesktopNotification(const bool showDesktopNotification) {
|
||||||
m_settings.setValue("showDesktopNotification", showDesktopNotification);
|
m_settings.setValue(QStringLiteral("showDesktopNotification"), showDesktopNotification);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ConfigHandler::filenamePatternValue() {
|
QString ConfigHandler::filenamePatternValue() {
|
||||||
return m_settings.value("filenamePattern").toString();
|
return m_settings.value(QStringLiteral("filenamePattern")).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigHandler::setFilenamePattern(const QString &pattern) {
|
void ConfigHandler::setFilenamePattern(const QString &pattern) {
|
||||||
return m_settings.setValue("filenamePattern", pattern);
|
return m_settings.setValue(QStringLiteral("filenamePattern"), pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfigHandler::disabledTrayIconValue() {
|
bool ConfigHandler::disabledTrayIconValue() {
|
||||||
bool res = false;
|
bool res = false;
|
||||||
if (m_settings.contains("disabledTrayIcon")) {
|
if (m_settings.contains(QStringLiteral("disabledTrayIcon"))) {
|
||||||
res = m_settings.value("disabledTrayIcon").toBool();
|
res = m_settings.value(QStringLiteral("disabledTrayIcon")).toBool();
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigHandler::setDisabledTrayIcon(const bool disabledTrayIcon) {
|
void ConfigHandler::setDisabledTrayIcon(const bool disabledTrayIcon) {
|
||||||
m_settings.setValue("disabledTrayIcon", disabledTrayIcon);
|
m_settings.setValue(QStringLiteral("disabledTrayIcon"), disabledTrayIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ConfigHandler::drawThicknessValue() {
|
int ConfigHandler::drawThicknessValue() {
|
||||||
int res = 0;
|
int res = 0;
|
||||||
if (m_settings.contains("drawThickness")) {
|
if (m_settings.contains(QStringLiteral("drawThickness"))) {
|
||||||
res = m_settings.value("drawThickness").toInt();
|
res = m_settings.value(QStringLiteral("drawThickness")).toInt();
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigHandler::setdrawThickness(const int thickness) {
|
void ConfigHandler::setdrawThickness(const int thickness) {
|
||||||
m_settings.setValue("drawThickness", thickness);
|
m_settings.setValue(QStringLiteral("drawThickness"), thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfigHandler::keepOpenAppLauncherValue() {
|
bool ConfigHandler::keepOpenAppLauncherValue() {
|
||||||
return m_settings.value("keepOpenAppLauncher").toBool();
|
return m_settings.value(QStringLiteral("keepOpenAppLauncher")).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigHandler::setKeepOpenAppLauncher(const bool keepOpen) {
|
void ConfigHandler::setKeepOpenAppLauncher(const bool keepOpen) {
|
||||||
m_settings.setValue("keepOpenAppLauncher", keepOpen);
|
m_settings.setValue(QStringLiteral("keepOpenAppLauncher"), keepOpen);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfigHandler::startupLaunchValue() {
|
bool ConfigHandler::startupLaunchValue() {
|
||||||
@@ -283,15 +283,15 @@ void ConfigHandler::setStartupLaunch(const bool start) {
|
|||||||
|
|
||||||
int ConfigHandler::contrastOpacityValue() {
|
int ConfigHandler::contrastOpacityValue() {
|
||||||
int opacity = 190;
|
int opacity = 190;
|
||||||
if (m_settings.contains("contrastOpacity")) {
|
if (m_settings.contains(QStringLiteral("contrastOpacity"))) {
|
||||||
opacity = m_settings.value("contrastOpacity").toInt();
|
opacity = m_settings.value(QStringLiteral("contrastOpacity")).toInt();
|
||||||
opacity = qBound(0, opacity, 255);
|
opacity = qBound(0, opacity, 255);
|
||||||
}
|
}
|
||||||
return opacity;
|
return opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigHandler::setContrastOpacity(const int transparency) {
|
void ConfigHandler::setContrastOpacity(const int transparency) {
|
||||||
m_settings.setValue("contrastOpacity", transparency);
|
m_settings.setValue(QStringLiteral("contrastOpacity"), transparency);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigHandler::setDefaults() {
|
void ConfigHandler::setDefaults() {
|
||||||
@@ -305,7 +305,7 @@ void ConfigHandler::setAllTheButtons() {
|
|||||||
buttons << static_cast<int>(t);
|
buttons << static_cast<int>(t);
|
||||||
}
|
}
|
||||||
// TODO: remove toList in v1.0
|
// TODO: remove toList in v1.0
|
||||||
m_settings.setValue("buttons", QVariant::fromValue(buttons.toList()));
|
m_settings.setValue(QStringLiteral("buttons"), QVariant::fromValue(buttons.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ConfigHandler::configFilePath() const {
|
QString ConfigHandler::configFilePath() const {
|
||||||
|
|||||||
@@ -27,13 +27,13 @@ DBusUtils::DBusUtils(QObject *parent) : QObject(parent) {
|
|||||||
void DBusUtils::connectPrintCapture(QDBusConnection &session, uint id) {
|
void DBusUtils::connectPrintCapture(QDBusConnection &session, uint id) {
|
||||||
m_id = id;
|
m_id = id;
|
||||||
// captureTaken
|
// captureTaken
|
||||||
session.connect("org.dharkael.Flameshot",
|
session.connect(QStringLiteral("org.dharkael.Flameshot"),
|
||||||
"/", "", "captureTaken",
|
QStringLiteral("/"), QLatin1String(""), QStringLiteral("captureTaken"),
|
||||||
this,
|
this,
|
||||||
SLOT(captureTaken(uint, QByteArray)));
|
SLOT(captureTaken(uint, QByteArray)));
|
||||||
// captureFailed
|
// captureFailed
|
||||||
session.connect("org.dharkael.Flameshot",
|
session.connect(QStringLiteral("org.dharkael.Flameshot"),
|
||||||
"/", "", "captureFailed",
|
QStringLiteral("/"), QLatin1String(""), QStringLiteral("captureFailed"),
|
||||||
this,
|
this,
|
||||||
SLOT(captureFailed(uint)));
|
SLOT(captureFailed(uint)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ DesktopFileParser::DesktopFileParser() {
|
|||||||
m_localeNameShort = QStringLiteral("Name[%1]").arg(localeShort);
|
m_localeNameShort = QStringLiteral("Name[%1]").arg(localeShort);
|
||||||
m_localeDescriptionShort = QStringLiteral("Comment[%1]")
|
m_localeDescriptionShort = QStringLiteral("Comment[%1]")
|
||||||
.arg(localeShort);
|
.arg(localeShort);
|
||||||
m_defaultIcon = QIcon::fromTheme("application-x-executable");
|
m_defaultIcon = QIcon::fromTheme(QStringLiteral("application-x-executable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
DesktopAppData DesktopFileParser::parseDesktopFile(
|
DesktopAppData DesktopFileParser::parseDesktopFile(
|
||||||
@@ -48,62 +48,62 @@ DesktopAppData DesktopFileParser::parseDesktopFile(
|
|||||||
bool isApplication = false;
|
bool isApplication = false;
|
||||||
QTextStream in(&file);
|
QTextStream in(&file);
|
||||||
// enter the desktop entry definition
|
// enter the desktop entry definition
|
||||||
while (!in.atEnd() && in.readLine() != "[Desktop Entry]") {
|
while (!in.atEnd() && in.readLine() != QLatin1String("[Desktop Entry]")) {
|
||||||
}
|
}
|
||||||
// start parsing
|
// start parsing
|
||||||
while (!in.atEnd()) {
|
while (!in.atEnd()) {
|
||||||
QString line = in.readLine();
|
QString line = in.readLine();
|
||||||
if (line.startsWith("Icon")) {
|
if (line.startsWith(QLatin1String("Icon"))) {
|
||||||
res.icon = QIcon::fromTheme(
|
res.icon = QIcon::fromTheme(
|
||||||
line.mid(line.indexOf("=")+1).trimmed(),
|
line.mid(line.indexOf(QLatin1String("="))+1).trimmed(),
|
||||||
m_defaultIcon);
|
m_defaultIcon);
|
||||||
}
|
}
|
||||||
else if (!nameLocaleSet && line.startsWith("Name")) {
|
else if (!nameLocaleSet && line.startsWith(QLatin1String("Name"))) {
|
||||||
if (line.startsWith(m_localeName) ||
|
if (line.startsWith(m_localeName) ||
|
||||||
line.startsWith(m_localeNameShort))
|
line.startsWith(m_localeNameShort))
|
||||||
{
|
{
|
||||||
res.name = line.mid(line.indexOf("=")+1).trimmed();
|
res.name = line.mid(line.indexOf(QLatin1String("="))+1).trimmed();
|
||||||
nameLocaleSet = true;
|
nameLocaleSet = true;
|
||||||
} else if (line.startsWith("Name=")) {
|
} else if (line.startsWith(QLatin1String("Name="))) {
|
||||||
res.name = line.mid(line.indexOf("=")+1).trimmed();
|
res.name = line.mid(line.indexOf(QLatin1String("="))+1).trimmed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!descriptionLocaleSet && line.startsWith("Comment")) {
|
else if (!descriptionLocaleSet && line.startsWith(QLatin1String("Comment"))) {
|
||||||
if (line.startsWith(m_localeDescription) ||
|
if (line.startsWith(m_localeDescription) ||
|
||||||
line.startsWith(m_localeDescriptionShort))
|
line.startsWith(m_localeDescriptionShort))
|
||||||
{
|
{
|
||||||
res.description = line.mid(line.indexOf("=")+1).trimmed();
|
res.description = line.mid(line.indexOf(QLatin1String("="))+1).trimmed();
|
||||||
descriptionLocaleSet = true;
|
descriptionLocaleSet = true;
|
||||||
} else if (line.startsWith("Comment=")) {
|
} else if (line.startsWith(QLatin1String("Comment="))) {
|
||||||
res.description = line.mid(line.indexOf("=")+1).trimmed();
|
res.description = line.mid(line.indexOf(QLatin1String("="))+1).trimmed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (line.startsWith("Exec")) {
|
else if (line.startsWith(QLatin1String("Exec"))) {
|
||||||
if (line.contains("%")) {
|
if (line.contains(QLatin1String("%"))) {
|
||||||
res.exec = line.mid(line.indexOf("=")+1)
|
res.exec = line.mid(line.indexOf(QLatin1String("="))+1)
|
||||||
.trimmed();
|
.trimmed();
|
||||||
} else {
|
} else {
|
||||||
ok = false;
|
ok = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (line.startsWith("Type")) {
|
else if (line.startsWith(QLatin1String("Type"))) {
|
||||||
if (line.contains("Application")) {
|
if (line.contains(QLatin1String("Application"))) {
|
||||||
isApplication = true;
|
isApplication = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (line.startsWith("Categories")) {
|
else if (line.startsWith(QLatin1String("Categories"))) {
|
||||||
res.categories = line.mid(line.indexOf("=")+1).split(";");
|
res.categories = line.mid(line.indexOf(QLatin1String("="))+1).split(QStringLiteral(";"));
|
||||||
}
|
}
|
||||||
else if (line == "NoDisplay=true") {
|
else if (line == QLatin1String("NoDisplay=true")) {
|
||||||
ok = false;
|
ok = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (line == "Terminal=true") {
|
else if (line == QLatin1String("Terminal=true")) {
|
||||||
res.showInTerminal = true;
|
res.showInTerminal = true;
|
||||||
}
|
}
|
||||||
// ignore the other entries
|
// ignore the other entries
|
||||||
else if (line.startsWith("[")) {
|
else if (line.startsWith(QLatin1String("["))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,26 +20,26 @@
|
|||||||
|
|
||||||
DesktopInfo::DesktopInfo() {
|
DesktopInfo::DesktopInfo() {
|
||||||
auto e = QProcessEnvironment::systemEnvironment();
|
auto e = QProcessEnvironment::systemEnvironment();
|
||||||
XDG_CURRENT_DESKTOP = e.value("XDG_CURRENT_DESKTOP");
|
XDG_CURRENT_DESKTOP = e.value(QStringLiteral("XDG_CURRENT_DESKTOP"));
|
||||||
XDG_SESSION_TYPE = e.value("XDG_SESSION_TYPE");
|
XDG_SESSION_TYPE = e.value(QStringLiteral("XDG_SESSION_TYPE"));
|
||||||
WAYLAND_DISPLAY = e.value("WAYLAND_DISPLAY");
|
WAYLAND_DISPLAY = e.value(QStringLiteral("WAYLAND_DISPLAY"));
|
||||||
KDE_FULL_SESSION = e.value("KDE_FULL_SESSION");
|
KDE_FULL_SESSION = e.value(QStringLiteral("KDE_FULL_SESSION"));
|
||||||
GNOME_DESKTOP_SESSION_ID = e.value("GNOME_DESKTOP_SESSION_ID");
|
GNOME_DESKTOP_SESSION_ID = e.value(QStringLiteral("GNOME_DESKTOP_SESSION_ID"));
|
||||||
DESKTOP_SESSION = e.value("DESKTOP_SESSION");
|
DESKTOP_SESSION = e.value(QStringLiteral("DESKTOP_SESSION"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DesktopInfo::waylandDectected() {
|
bool DesktopInfo::waylandDectected() {
|
||||||
return XDG_SESSION_TYPE == "wayland" ||
|
return XDG_SESSION_TYPE == QLatin1String("wayland") ||
|
||||||
WAYLAND_DISPLAY.contains("wayland", Qt::CaseInsensitive);
|
WAYLAND_DISPLAY.contains(QLatin1String("wayland"), Qt::CaseInsensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
DesktopInfo::WM DesktopInfo::windowManager() {
|
DesktopInfo::WM DesktopInfo::windowManager() {
|
||||||
DesktopInfo::WM res = DesktopInfo::OTHER;
|
DesktopInfo::WM res = DesktopInfo::OTHER;
|
||||||
if (XDG_CURRENT_DESKTOP.contains("GNOME", Qt::CaseInsensitive) ||
|
if (XDG_CURRENT_DESKTOP.contains(QLatin1String("GNOME"), Qt::CaseInsensitive) ||
|
||||||
!GNOME_DESKTOP_SESSION_ID.isEmpty())
|
!GNOME_DESKTOP_SESSION_ID.isEmpty())
|
||||||
{
|
{
|
||||||
res = DesktopInfo::GNOME;
|
res = DesktopInfo::GNOME;
|
||||||
} else if (!KDE_FULL_SESSION.isEmpty() || DESKTOP_SESSION == "kde-plasma") {
|
} else if (!KDE_FULL_SESSION.isEmpty() || DESKTOP_SESSION == QLatin1String("kde-plasma")) {
|
||||||
res = DesktopInfo::KDE;
|
res = DesktopInfo::KDE;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ QString FileNameHandler::parsedPattern() {
|
|||||||
QString FileNameHandler::parseFilename(const QString &name) {
|
QString FileNameHandler::parseFilename(const QString &name) {
|
||||||
QString res = name;
|
QString res = name;
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
res = "%F_%H-%M";
|
res = QLatin1String("%F_%H-%M");
|
||||||
}
|
}
|
||||||
std::time_t t = std::time(NULL);
|
std::time_t t = std::time(NULL);
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ QString FileNameHandler::parseFilename(const QString &name) {
|
|||||||
free(tempData);
|
free(tempData);
|
||||||
|
|
||||||
// add the parsed pattern in a correct format for the filesystem
|
// add the parsed pattern in a correct format for the filesystem
|
||||||
res = res.replace("/", "⁄").replace(":", "-");
|
res = res.replace(QLatin1String("/"), QStringLiteral("⁄")).replace(QLatin1String(":"), QLatin1String("-"));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,14 +87,14 @@ char * FileNameHandler::QStringTocharArr(const QString &s) {
|
|||||||
|
|
||||||
void FileNameHandler::fixPath(QString &directory, QString &filename) {
|
void FileNameHandler::fixPath(QString &directory, QString &filename) {
|
||||||
// add '/' at the end of the directory
|
// add '/' at the end of the directory
|
||||||
if (!directory.endsWith("/")) {
|
if (!directory.endsWith(QLatin1String("/"))) {
|
||||||
directory += "/";
|
directory += QLatin1String("/");
|
||||||
}
|
}
|
||||||
// add numeration in case of repeated filename in the directory
|
// add numeration in case of repeated filename in the directory
|
||||||
// find unused name adding _n where n is a number
|
// find unused name adding _n where n is a number
|
||||||
QFileInfo checkFile(directory + filename + ".png");
|
QFileInfo checkFile(directory + filename + ".png");
|
||||||
if (checkFile.exists()) {
|
if (checkFile.exists()) {
|
||||||
filename += "_";
|
filename += QLatin1String("_");
|
||||||
int i = 1;
|
int i = 1;
|
||||||
while (true) {
|
while (true) {
|
||||||
checkFile.setFile(
|
checkFile.setFile(
|
||||||
|
|||||||
@@ -21,11 +21,11 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
const QString PathInfo::whiteIconPath() {
|
const QString PathInfo::whiteIconPath() {
|
||||||
return ":/img/material/white/";
|
return QStringLiteral(":/img/material/white/");
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString PathInfo::blackIconPath() {
|
const QString PathInfo::blackIconPath() {
|
||||||
return ":/img/material/black/";
|
return QStringLiteral(":/img/material/black/");
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList PathInfo::translationsPaths() {
|
QStringList PathInfo::translationsPaths() {
|
||||||
@@ -34,10 +34,10 @@ QStringList PathInfo::translationsPaths() {
|
|||||||
QString trPath = QDir::toNativeSeparators(binaryPath + "/translations") ;
|
QString trPath = QDir::toNativeSeparators(binaryPath + "/translations") ;
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
|
||||||
return QStringList()
|
return QStringList()
|
||||||
<< QString(APP_PREFIX) + "/share/flameshot/translations"
|
<< QStringLiteral(APP_PREFIX) + "/share/flameshot/translations"
|
||||||
<< trPath
|
<< trPath
|
||||||
<< "/usr/share/flameshot/translations"
|
<< QStringLiteral("/usr/share/flameshot/translations")
|
||||||
<< "/usr/local/share/flameshot/translations";
|
<< QStringLiteral("/usr/local/share/flameshot/translations");
|
||||||
#elif defined(Q_OS_WIN)
|
#elif defined(Q_OS_WIN)
|
||||||
return QStringList()
|
return QStringList()
|
||||||
<< trPath;
|
<< trPath;
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool &ok) {
|
|||||||
QDBusInterface gnomeInterface(QStringLiteral("org.gnome.Shell"),
|
QDBusInterface gnomeInterface(QStringLiteral("org.gnome.Shell"),
|
||||||
QStringLiteral("/org/gnome/Shell/Screenshot"),
|
QStringLiteral("/org/gnome/Shell/Screenshot"),
|
||||||
QStringLiteral("org.gnome.Shell.Screenshot"));
|
QStringLiteral("org.gnome.Shell.Screenshot"));
|
||||||
QDBusReply<bool> reply = gnomeInterface.call("Screenshot", false, false, path);
|
QDBusReply<bool> reply = gnomeInterface.call(QStringLiteral("Screenshot"), false, false, path);
|
||||||
if (reply.value()) {
|
if (reply.value()) {
|
||||||
res = QPixmap(path);
|
res = QPixmap(path);
|
||||||
QFile dbusResult(path);
|
QFile dbusResult(path);
|
||||||
@@ -61,7 +61,7 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool &ok) {
|
|||||||
QDBusInterface kwinInterface(QStringLiteral("org.kde.KWin"),
|
QDBusInterface kwinInterface(QStringLiteral("org.kde.KWin"),
|
||||||
QStringLiteral("/Screenshot"),
|
QStringLiteral("/Screenshot"),
|
||||||
QStringLiteral("org.kde.kwin.Screenshot"));
|
QStringLiteral("org.kde.kwin.Screenshot"));
|
||||||
QDBusReply<QString> reply = kwinInterface.call("screenshotFullscreen");
|
QDBusReply<QString> reply = kwinInterface.call(QStringLiteral("screenshotFullscreen"));
|
||||||
res = QPixmap(reply.value());
|
res = QPixmap(reply.value());
|
||||||
if (!res.isNull()) {
|
if (!res.isNull()) {
|
||||||
QFile dbusResult(reply.value());
|
QFile dbusResult(reply.value());
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ bool ScreenshotSaver::saveToFilesystem(const QPixmap &capture,
|
|||||||
const QString &path)
|
const QString &path)
|
||||||
{
|
{
|
||||||
QString completePath = FileNameHandler().generateAbsolutePath(path);
|
QString completePath = FileNameHandler().generateAbsolutePath(path);
|
||||||
completePath += ".png";
|
completePath += QLatin1String(".png");
|
||||||
bool ok = capture.save(completePath);
|
bool ok = capture.save(completePath);
|
||||||
QString saveMessage;
|
QString saveMessage;
|
||||||
|
|
||||||
@@ -66,14 +66,14 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap &capture) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!savePath.endsWith(".png")) {
|
if (!savePath.endsWith(QLatin1String(".png"))) {
|
||||||
savePath += ".png";
|
savePath += QLatin1String(".png");
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = capture.save(savePath);
|
ok = capture.save(savePath);
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
QString pathNoFile = savePath.left(savePath.lastIndexOf("/"));
|
QString pathNoFile = savePath.left(savePath.lastIndexOf(QLatin1String("/")));
|
||||||
ConfigHandler().setSavePath(pathNoFile);
|
ConfigHandler().setSavePath(pathNoFile);
|
||||||
QString msg = QObject::tr("Capture saved as ") + savePath;
|
QString msg = QObject::tr("Capture saved as ") + savePath;
|
||||||
SystemNotification().sendMessage(msg);
|
SystemNotification().sendMessage(msg);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ void SystemNotification::sendMessage(
|
|||||||
<< QStringList() //actions
|
<< QStringList() //actions
|
||||||
<< QVariantMap() //hints
|
<< QVariantMap() //hints
|
||||||
<< timeout; //timeout
|
<< timeout; //timeout
|
||||||
m_interface->callWithArgumentList(QDBus::AutoDetect, "Notify", args);
|
m_interface->callWithArgumentList(QDBus::AutoDetect, QStringLiteral("Notify"), args);
|
||||||
#else
|
#else
|
||||||
auto c = Controller::getInstance();
|
auto c = Controller::getInstance();
|
||||||
c->sendTrayNotification(text, title, timeout);
|
c->sendTrayNotification(text, title, timeout);
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ void CaptureButton::animatedShow() {
|
|||||||
if(!isVisible()) {
|
if(!isVisible()) {
|
||||||
show();
|
show();
|
||||||
m_emergeAnimation->start();
|
m_emergeAnimation->start();
|
||||||
connect(m_emergeAnimation, &QPropertyAnimation::finished, this, [this](){
|
connect(m_emergeAnimation, &QPropertyAnimation::finished, this, [](){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,5 +63,5 @@ void NotifierBox::showMessage(const QString &msg) {
|
|||||||
|
|
||||||
void NotifierBox::showColor(const QColor &color) {
|
void NotifierBox::showColor(const QColor &color) {
|
||||||
Q_UNUSED(color);
|
Q_UNUSED(color);
|
||||||
m_message = "";
|
m_message = QLatin1String("");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ void InfoWindow::initLabels() {
|
|||||||
QLabel *licenseTitleLabel = new QLabel(tr("<u><b>License</b></u>"), this);
|
QLabel *licenseTitleLabel = new QLabel(tr("<u><b>License</b></u>"), this);
|
||||||
licenseTitleLabel->setAlignment(Qt::AlignHCenter);
|
licenseTitleLabel->setAlignment(Qt::AlignHCenter);
|
||||||
m_layout->addWidget(licenseTitleLabel);
|
m_layout->addWidget(licenseTitleLabel);
|
||||||
QLabel *licenseLabel = new QLabel("GPLv3+", this);
|
QLabel *licenseLabel = new QLabel(QStringLiteral("GPLv3+"), this);
|
||||||
licenseLabel->setAlignment(Qt::AlignHCenter);
|
licenseLabel->setAlignment(Qt::AlignHCenter);
|
||||||
m_layout->addWidget(licenseLabel);
|
m_layout->addWidget(licenseLabel);
|
||||||
m_layout->addStretch();
|
m_layout->addStretch();
|
||||||
@@ -129,7 +129,7 @@ void InfoWindow::initLabels() {
|
|||||||
QLabel *versionTitleLabel = new QLabel(tr("<u><b>Version</b></u>"), this);
|
QLabel *versionTitleLabel = new QLabel(tr("<u><b>Version</b></u>"), this);
|
||||||
versionTitleLabel->setAlignment(Qt::AlignHCenter);
|
versionTitleLabel->setAlignment(Qt::AlignHCenter);
|
||||||
m_layout->addWidget(versionTitleLabel);
|
m_layout->addWidget(versionTitleLabel);
|
||||||
QString versionMsg = "Flameshot " + QString(APP_VERSION) + "\nCompiled with Qt "
|
QString versionMsg = "Flameshot " + QStringLiteral(APP_VERSION) + "\nCompiled with Qt "
|
||||||
+ QT_VERSION_STR;
|
+ QT_VERSION_STR;
|
||||||
QLabel *versionLabel = new QLabel(versionMsg, this);
|
QLabel *versionLabel = new QLabel(versionMsg, this);
|
||||||
versionLabel->setAlignment(Qt::AlignHCenter);
|
versionLabel->setAlignment(Qt::AlignHCenter);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ LoadSpinner::LoadSpinner(QWidget *parent) :
|
|||||||
updateFrame();
|
updateFrame();
|
||||||
// init timer
|
// init timer
|
||||||
m_timer = new QTimer(this);
|
m_timer = new QTimer(this);
|
||||||
connect(m_timer, SIGNAL(timeout()), this, SLOT(rotate()));
|
connect(m_timer, &QTimer::timeout, this, &LoadSpinner::rotate);
|
||||||
m_timer->setInterval(30);
|
m_timer->setInterval(30);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ SidePanelWidget::SidePanelWidget(QPixmap *p, QWidget *parent) :
|
|||||||
QString modifier = isDark ? PathInfo::whiteIconPath() :
|
QString modifier = isDark ? PathInfo::whiteIconPath() :
|
||||||
PathInfo::blackIconPath();
|
PathInfo::blackIconPath();
|
||||||
QIcon grabIcon(modifier + "colorize.svg");
|
QIcon grabIcon(modifier + "colorize.svg");
|
||||||
m_colorGrabButton = new QPushButton(grabIcon, "");
|
m_colorGrabButton = new QPushButton(grabIcon, QLatin1String(""));
|
||||||
updateGrabButton(false);
|
updateGrabButton(false);
|
||||||
connect(m_colorGrabButton, &QPushButton::pressed,
|
connect(m_colorGrabButton, &QPushButton::pressed,
|
||||||
this, &SidePanelWidget::colorGrabberActivated);
|
this, &SidePanelWidget::colorGrabberActivated);
|
||||||
@@ -96,7 +96,7 @@ SidePanelWidget::SidePanelWidget(QPixmap *p, QWidget *parent) :
|
|||||||
void SidePanelWidget::updateColor(const QColor &c) {
|
void SidePanelWidget::updateColor(const QColor &c) {
|
||||||
m_color = c;
|
m_color = c;
|
||||||
m_colorLabel->setStyleSheet(
|
m_colorLabel->setStyleSheet(
|
||||||
QString("QLabel { background-color : %1; }").arg(c.name()));
|
QStringLiteral("QLabel { background-color : %1; }").arg(c.name()));
|
||||||
m_colorWheel->setColor(m_color);
|
m_colorWheel->setColor(m_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ void SidePanelWidget::updateThickness(const int &t)
|
|||||||
void SidePanelWidget::updateColorNoWheel(const QColor &c) {
|
void SidePanelWidget::updateColorNoWheel(const QColor &c) {
|
||||||
m_color = c;
|
m_color = c;
|
||||||
m_colorLabel->setStyleSheet(
|
m_colorLabel->setStyleSheet(
|
||||||
QString("QLabel { background-color : %1; }").arg(c.name()));
|
QStringLiteral("QLabel { background-color : %1; }").arg(c.name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SidePanelWidget::updateCurrentThickness()
|
void SidePanelWidget::updateCurrentThickness()
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ void UtilityPanel::initInternalPanel() {
|
|||||||
|
|
||||||
QColor bgColor = palette().background().color();
|
QColor bgColor = palette().background().color();
|
||||||
bgColor.setAlphaF(0.0);
|
bgColor.setAlphaF(0.0);
|
||||||
m_internalPanel->setStyleSheet(QString("QScrollArea {background-color: %1}")
|
m_internalPanel->setStyleSheet(QStringLiteral("QScrollArea {background-color: %1}")
|
||||||
.arg(bgColor.name()));
|
.arg(bgColor.name()));
|
||||||
m_internalPanel->hide();
|
m_internalPanel->hide();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user