Fix some issues detected by Clazy (#384)

* Fix old style connect

* Fix unneeded QString memory allocations
This commit is contained in:
Alfredo Ramos
2018-10-23 18:04:42 -05:00
committed by Dharkael
parent 7d91b00072
commit ee2f583acd
48 changed files with 231 additions and 231 deletions

View File

@@ -31,9 +31,9 @@ QTextStream out(stdout);
QTextStream err(stderr);
auto versionOption = CommandOption({"v", "version"},
"Displays version information");
QStringLiteral("Displays version information"));
auto helpOption = CommandOption({"h", "help"},
"Displays this help");
QStringLiteral("Displays this help"));
QString optionsToString(const QList<CommandOption> &options,
const QList<CommandArgument> &arguments) {
@@ -43,7 +43,7 @@ QString optionsToString(const QList<CommandOption> &options,
// of every option at the same horizontal character position.
for (auto const &option: options) {
QStringList dashedOptions = option.dashedNames();
QString joinedDashedOptions = dashedOptions.join(", ");
QString joinedDashedOptions = dashedOptions.join(QStringLiteral(", "));
if (!option.valueName().isEmpty()) {
joinedDashedOptions += QStringLiteral(" <%1>")
.arg(option.valueName());
@@ -61,20 +61,20 @@ QString optionsToString(const QList<CommandOption> &options,
// generate the text
QString result;
if(!dashedOptionList.isEmpty()) {
result += "Options:\n";
QString linePadding = QString(" ").repeated(size + 4).prepend("\n");
result += QLatin1String("Options:\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("\n", linePadding));
.replace(QLatin1String("\n"), linePadding));
}
if (!arguments.isEmpty()) {
result += "\n";
result += QLatin1String("\n");
}
}
if (!arguments.isEmpty()) {
result += "Arguments:\n";
result += QLatin1String("Arguments:\n");
}
for (int i = 0; i < arguments.length(); ++i) {
result += QStringLiteral(" %1 %2\n")
@@ -121,14 +121,14 @@ bool CommandLineParser::processOptions(const QStringList &args,
QString arg = *actualIt;
bool ok = true;
// track values
int equalsPos = arg.indexOf("=");
int equalsPos = arg.indexOf(QLatin1String("="));
QString valueStr;
if (equalsPos != -1) {
valueStr = arg.mid(equalsPos +1); // right
arg = arg.mid(0, equalsPos); // left
}
// check format -x --xx...
bool isDoubleDashed = arg.startsWith("--");
bool isDoubleDashed = arg.startsWith(QLatin1String("--"));
ok = isDoubleDashed ? arg.length() > 3 :
arg.length() == 2;
if (!ok) {
@@ -182,8 +182,8 @@ bool CommandLineParser::processOptions(const QStringList &args,
ok = option.checkValue(valueStr);
if (!ok) {
QString err = option.errorMsg();
if (!err.endsWith("."))
err += ".";
if (!err.endsWith(QLatin1String(".")))
err += QLatin1String(".");
out << err;
return ok;
}
@@ -219,7 +219,7 @@ bool CommandLineParser::parse(const QStringList &args) {
// process the other args
for (; it != args.cend() && ok; ++it) {
const QString &value = *it;
if (value.startsWith("-")) {
if (value.startsWith(QLatin1String("-"))) {
ok = processOptions(args, it, actualNode);
} else {
@@ -326,7 +326,7 @@ 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(" "))
.arg(args.join(QStringLiteral(" ")))
.arg(argName).arg(argText);
// add command options and subarguments
QList<CommandArgument> subArgs;

View File

@@ -70,7 +70,7 @@ QString CommandOption::valueName() const {
void CommandOption::setValue(const QString &value) {
if (m_valueName.isEmpty()) {
m_valueName = "value";
m_valueName = QLatin1String("value");
}
m_value = value;
}

View File

@@ -99,7 +99,7 @@ void GeneneralConf::importConfiguration() {
void GeneneralConf::exportFileConfiguration() {
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
"flameshot.conf");
QStringLiteral("flameshot.conf"));
// Cancel button
if (fileName.isNull()) {

View File

@@ -125,7 +125,7 @@ void UIcolorEditor::initButtons() {
h2->addWidget(frame2);
frame2->setFixedSize(frameSize, frameSize);
m_labelContrast = new ClickableLabel(tr("Contrast Color"), this);
m_labelContrast->setStyleSheet("color : gray");
m_labelContrast->setStyleSheet(QStringLiteral("color : gray"));
h2->addWidget(m_labelContrast);
m_vLayout->addLayout(h2);
@@ -149,7 +149,7 @@ void UIcolorEditor::changeLastButton(CaptureButton *b) {
if (m_lastButtonPressed != b) {
m_lastButtonPressed = b;
QString offStyle("QLabel { color : gray; }");
QString offStyle(QStringLiteral("QLabel { color : gray; }"));
if (b == m_buttonMainColor) {
m_colorWheel->setColor(m_uiColor);

View File

@@ -45,9 +45,9 @@ void VisualsEditor::initOpacitySlider() {
connect(m_opacitySlider, &ExtendedSlider::modificationsEnded,
this, &VisualsEditor::saveOpacity);
QHBoxLayout *localLayout = new QHBoxLayout();
localLayout->addWidget(new QLabel("0%"));
localLayout->addWidget(new QLabel(QStringLiteral("0%")));
localLayout->addWidget(m_opacitySlider);
localLayout->addWidget(new QLabel("100%"));
localLayout->addWidget(new QLabel(QStringLiteral("100%")));
QLabel *label = new QLabel();
QString labelMsg = tr("Opacity of area outside selection:") + " %1%";

View File

@@ -37,7 +37,7 @@ public:
CaptureRequest(CaptureMode mode,
const uint delay = 0,
const QString &path = "",
const QString &path = QLatin1String(""),
const QVariant &data = QVariant(),
ExportTask tasks = NO_TASK);

View File

@@ -189,7 +189,7 @@ void Controller::enableTrayIcon() {
trayIconMenu->addAction(quitAction);
m_trayIcon = new QSystemTrayIcon();
m_trayIcon->setToolTip("Flameshot");
m_trayIcon->setToolTip(QStringLiteral("Flameshot"));
m_trayIcon->setContextMenu(trayIconMenu);
QIcon trayicon = QIcon::fromTheme("flameshot-tray", QIcon(":img/app/flameshot.png"));
m_trayIcon->setIcon(trayicon);

View File

@@ -55,7 +55,7 @@ public slots:
void enableTrayIcon();
void disableTrayIcon();
void sendTrayNotification(const QString &text,
const QString &title = "Flameshot Info",
const QString &title = QStringLiteral("Flameshot Info"),
const int timeout = 5000);
void updateConfigComponents();

View File

@@ -51,7 +51,7 @@ int main(int argc, char *argv[]) {
for (const QString &path: trPaths) {
bool match = translator.load(QLocale(),
"Internationalization", "_",
QStringLiteral("Internationalization"), QStringLiteral("_"),
path);
if (match) {
break;
@@ -60,8 +60,8 @@ int main(int argc, char *argv[]) {
app.installTranslator(&translator);
app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
app.setApplicationName("flameshot");
app.setOrganizationName("Dharkael");
app.setApplicationName(QStringLiteral("flameshot"));
app.setOrganizationName(QStringLiteral("Dharkael"));
auto c = Controller::getInstance();
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
@@ -71,8 +71,8 @@ int main(int argc, char *argv[]) {
SystemNotification().sendMessage(
QObject::tr("Unable to connect via DBus"));
}
dbus.registerObject("/", c);
dbus.registerService("org.dharkael.Flameshot");
dbus.registerObject(QStringLiteral("/"), c);
dbus.registerService(QStringLiteral("org.dharkael.Flameshot"));
#endif
// Exporting captures must be connected after the dbus interface
// or the dbus signal gets blocked until we end the exports.
@@ -85,66 +85,66 @@ int main(int argc, char *argv[]) {
* CLI parsing |
* ------------*/
QCoreApplication app(argc, argv);
app.setApplicationName("flameshot");
app.setOrganizationName("Dharkael");
app.setApplicationName(QStringLiteral("flameshot"));
app.setOrganizationName(QStringLiteral("Dharkael"));
app.setApplicationVersion(qApp->applicationVersion());
CommandLineParser parser;
// Add description
parser.setDescription(
"Powerful yet simple to use screenshot software.");
parser.setGeneralErrorMessage("See 'flameshot --help'.");
QStringLiteral("Powerful yet simple to use screenshot software."));
parser.setGeneralErrorMessage(QStringLiteral("See 'flameshot --help'."));
// Arguments
CommandArgument fullArgument("full", "Capture the entire desktop.");
CommandArgument guiArgument("gui", "Start a manual capture in GUI mode.");
CommandArgument configArgument("config", "Configure flameshot.");
CommandArgument screenArgument("screen", "Capture a single screen.");
CommandArgument fullArgument(QStringLiteral("full"), QStringLiteral("Capture the entire desktop."));
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"},
"Path where the capture will be saved",
"path");
QStringLiteral("Path where the capture will be saved"),
QStringLiteral("path"));
CommandOption clipboardOption(
{"c", "clipboard"},
"Save the capture to the clipboard");
QStringLiteral("Save the capture to the clipboard"));
CommandOption delayOption(
{"d", "delay"},
"Delay time in milliseconds",
"milliseconds");
QStringLiteral("Delay time in milliseconds"),
QStringLiteral("milliseconds"));
CommandOption filenameOption(
{"f", "filename"},
"Set the filename pattern",
"pattern");
QStringLiteral("Set the filename pattern"),
QStringLiteral("pattern"));
CommandOption trayOption(
{"t", "trayicon"},
"Enable or disable the trayicon",
"bool");
QStringLiteral("Enable or disable the trayicon"),
QStringLiteral("bool"));
CommandOption autostartOption(
{"a", "autostart"},
"Enable or disable run at startup",
"bool");
QStringLiteral("Enable or disable run at startup"),
QStringLiteral("bool"));
CommandOption showHelpOption(
{"s", "showhelp"},
"Show the help message in the capture mode",
"bool");
QStringLiteral("Show the help message in the capture mode"),
QStringLiteral("bool"));
CommandOption mainColorOption(
{"m", "maincolor"},
"Define the main UI color",
"color-code");
QStringLiteral("Define the main UI color"),
QStringLiteral("color-code"));
CommandOption contrastColorOption(
{"k", "contrastcolor"},
"Define the contrast UI color",
"color-code");
QStringLiteral("Define the contrast UI color"),
QStringLiteral("color-code"));
CommandOption rawImageOption(
{"r", "raw"},
"Print raw PNG capture");
QStringLiteral("Print raw PNG capture"));
CommandOption screenNumberOption(
{"n", "number"},
"Define the screen to capture,\ndefault: screen containing the cursor",
"Screen number", "-1");
QStringLiteral("Define the screen to capture,\ndefault: screen containing the cursor"),
QStringLiteral("Screen number"), QStringLiteral("-1"));
// Add checkers
auto colorChecker = [&parser](const QString &colorCode) -> bool {
auto colorChecker = [](const QString &colorCode) -> bool {
QColor parsedColor(colorCode);
return parsedColor.isValid() && parsedColor.alphaF() == 1.0;
};
@@ -156,15 +156,15 @@ 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 = "Invalid delay, it must be higher than 0";
const QString numberErr = "Invalid screen number, it must be non negative";
auto numericChecker = [&parser](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 = "Invalid path, it must be a real path in the system";
auto pathChecker = [&parser, 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()));
@@ -172,9 +172,9 @@ int main(int argc, char *argv[]) {
return res;
};
const QString booleanErr = "Invalid value, it must be defined as 'true' or 'false'";
auto booleanChecker = [&parser](const QString &value) -> bool {
return value == "true" || value == "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);
@@ -220,8 +220,8 @@ int main(int argc, char *argv[]) {
uint id = req.id();
// Send message
QDBusMessage m = QDBusMessage::createMethodCall("org.dharkael.Flameshot",
"/", "", "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,10 +248,10 @@ int main(int argc, char *argv[]) {
QTextStream out(stdout);
out << "Invalid format, set where to save the content with one of "
<< "the following flags:\n "
<< pathOption.dashedNames().join(", ") << "\n "
<< rawImageOption.dashedNames().join(", ") << "\n "
<< clipboardOption.dashedNames().join(", ") << "\n\n";
parser.parse(QStringList() << argv[0] << "full" << "-h");
<< 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"));
goto finish;
}
@@ -266,8 +266,8 @@ int main(int argc, char *argv[]) {
DBusUtils dbusUtils;
// Send message
QDBusMessage m = QDBusMessage::createMethodCall("org.dharkael.Flameshot",
"/", "", "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);
@@ -287,7 +287,7 @@ int main(int argc, char *argv[]) {
}
else if (parser.isSet(screenArgument)) { // SCREEN
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);
int delay = parser.value(delayOption).toInt();
bool toClipboard = parser.isSet(clipboardOption);
@@ -297,10 +297,10 @@ int main(int argc, char *argv[]) {
QTextStream out(stdout);
out << "Invalid format, set where to save the content with one of "
<< "the following flags:\n "
<< pathOption.dashedNames().join(", ") << "\n "
<< rawImageOption.dashedNames().join(", ") << "\n "
<< clipboardOption.dashedNames().join(", ") << "\n\n";
parser.parse(QStringList() << argv[0] << "screen" << "-h");
<< 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"));
goto finish;
}
@@ -316,8 +316,8 @@ int main(int argc, char *argv[]) {
DBusUtils dbusUtils;
// Send message
QDBusMessage m = QDBusMessage::createMethodCall("org.dharkael.Flameshot",
"/", "", "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);
@@ -346,11 +346,11 @@ int main(int argc, char *argv[]) {
mainColor || contrastColor);
ConfigHandler config;
if (autostart) {
QDBusMessage m = QDBusMessage::createMethodCall("org.dharkael.Flameshot",
"/", "", "autostartEnabled");
if (parser.value(autostartOption) == "false") {
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) == "true") {
} else if (parser.value(autostartOption) == QLatin1String("true")) {
m << true;
}
QDBusConnection sessionBus = QDBusConnection::sessionBus();
@@ -370,11 +370,11 @@ int main(int argc, char *argv[]) {
.arg(fh.parsedPattern());
}
if (tray) {
QDBusMessage m = QDBusMessage::createMethodCall("org.dharkael.Flameshot",
"/", "", "trayIconEnabled");
if (parser.value(trayOption) == "false") {
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) == "true") {
} else if (parser.value(trayOption) == QLatin1String("true")) {
m << true;
}
QDBusConnection sessionBus = QDBusConnection::sessionBus();
@@ -385,9 +385,9 @@ int main(int argc, char *argv[]) {
sessionBus.call(m);
}
if (help) {
if (parser.value(showHelpOption) == "false") {
if (parser.value(showHelpOption) == QLatin1String("false")) {
config.setShowHelp(false);
} else if (parser.value(showHelpOption) == "true") {
} else if (parser.value(showHelpOption) == QLatin1String("true")) {
config.setShowHelp(true);
}
}
@@ -404,8 +404,8 @@ int main(int argc, char *argv[]) {
// Open gui when no options
if (!someFlagSet) {
QDBusMessage m = QDBusMessage::createMethodCall("org.dharkael.Flameshot",
"/", "", "openConfig");
QDBusMessage m = QDBusMessage::createMethodCall(QStringLiteral("org.dharkael.Flameshot"),
QStringLiteral("/"), QLatin1String(""), QStringLiteral("openConfig"));
QDBusConnection sessionBus = QDBusConnection::sessionBus();
if (!sessionBus.isConnected()) {
SystemNotification().sendMessage(

View File

@@ -107,7 +107,7 @@ void SingleApplicationPrivate::genBlockServerName( int timeout )
#endif
#ifdef Q_OS_UNIX
QProcess process;
process.start( "whoami" );
process.start( QStringLiteral("whoami") );
if( process.waitForFinished( timeout ) &&
process.exitCode() == QProcess::NormalExit) {
appData.addData( process.readLine() );

View File

@@ -81,7 +81,7 @@ QString ArrowTool::name() const {
}
QString ArrowTool::nameID() {
return "";
return QLatin1String("");
}
QString ArrowTool::description() const {

View File

@@ -35,7 +35,7 @@ QString BlurTool::name() const {
}
QString BlurTool::nameID() {
return "";
return QLatin1String("");
}
QString BlurTool::description() const {

View File

@@ -35,7 +35,7 @@ QString CircleTool::name() const {
}
QString CircleTool::nameID() {
return "";
return QLatin1String("");
}
QString CircleTool::description() const {

View File

@@ -36,7 +36,7 @@ QString CopyTool::name() const {
}
QString CopyTool::nameID() {
return "";
return QLatin1String("");
}
QString CopyTool::description() const {

View File

@@ -35,7 +35,7 @@ QString ExitTool::name() const {
}
QString ExitTool::nameID() {
return "";
return QLatin1String("");
}
QString ExitTool::description() const {

View File

@@ -72,10 +72,10 @@ void ImgurUploader::handleReply(QNetworkReply *reply) {
if (reply->error() == QNetworkReply::NoError) {
QJsonDocument response = QJsonDocument::fromJson(reply->readAll());
QJsonObject json = response.object();
QJsonObject data = json["data"].toObject();
m_imageURL.setUrl(data["link"].toString());
m_deleteImageURL.setUrl(QString("https://imgur.com/delete/%1").arg(
data["deletehash"].toString()));
QJsonObject data = json[QStringLiteral("data")].toObject();
m_imageURL.setUrl(data[QStringLiteral("link")].toString());
m_deleteImageURL.setUrl(QStringLiteral("https://imgur.com/delete/%1").arg(
data[QStringLiteral("deletehash")].toString()));
onUploadOk();
} else {
m_infoLabel->setText(reply->errorString());
@@ -101,16 +101,16 @@ void ImgurUploader::upload() {
m_pixmap.save(&buffer, "PNG");
QUrlQuery urlQuery;
urlQuery.addQueryItem("title", "flameshot_screenshot");
urlQuery.addQueryItem(QStringLiteral("title"), QStringLiteral("flameshot_screenshot"));
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);
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader,
"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);
}

View File

@@ -36,7 +36,7 @@ QString ImgurUploaderTool::name() const {
}
QString ImgurUploaderTool::nameID() {
return "";
return QLatin1String("");
}
QString ImgurUploaderTool::description() const {

View File

@@ -35,7 +35,7 @@ QString AppLauncher::name() const {
}
QString AppLauncher::nameID() {
return "";
return QLatin1String("");
}
QString AppLauncher::description() const {

View File

@@ -61,7 +61,7 @@ AppLauncherWidget::AppLauncherWidget(const QPixmap &p, QWidget *parent):
QDir appsDirLocal(dirLocal);
m_parser.processDirectory(appsDirLocal);
QString dir = "/usr/share/applications/";
QString dir = QStringLiteral("/usr/share/applications/");
QDir appsDir(dir);
m_parser.processDirectory(appsDir);
@@ -173,9 +173,9 @@ void AppLauncherWidget::initListWidget() {
const QVector<DesktopAppData> &appList = m_appsMap[cat];
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);
if (cat == "Graphics") {
if (cat == QLatin1String("Graphics")) {
m_tabWidget->setCurrentIndex(m_tabWidget->count() -1);
}
}
@@ -199,7 +199,7 @@ void AppLauncherWidget::initAppMap() {
// Unify multimedia.
QVector<DesktopAppData> multimediaList;
QStringList multimediaNames;
multimediaNames << "AudioVideo" << "Audio" << "Video";
multimediaNames << QStringLiteral("AudioVideo") << QStringLiteral("Audio") << QStringLiteral("Video");
for (const QString &name : multimediaNames) {
if(!m_appsMap.contains(name)) {
continue;
@@ -211,7 +211,7 @@ void AppLauncherWidget::initAppMap() {
}
m_appsMap.remove(name);
}
m_appsMap.insert("Multimedia", multimediaList);
m_appsMap.insert(QStringLiteral("Multimedia"), multimediaList);
}
void AppLauncherWidget::configureListView(QListWidget *widget) {

View File

@@ -43,7 +43,7 @@ QString LineTool::name() const {
}
QString LineTool::nameID() {
return "";
return QLatin1String("");
}
QString LineTool::description() const {

View File

@@ -43,7 +43,7 @@ QString MarkerTool::name() const {
}
QString MarkerTool::nameID() {
return "";
return QLatin1String("");
}
QString MarkerTool::description() const {

View File

@@ -35,7 +35,7 @@ QString MoveTool::name() const {
}
QString MoveTool::nameID() {
return "";
return QLatin1String("");
}
QString MoveTool::description() const {

View File

@@ -31,7 +31,7 @@ QString PencilTool::name() const {
}
QString PencilTool::nameID() {
return "";
return QLatin1String("");
}
QString PencilTool::description() const {

2
src/tools/pin/pintool.cpp Executable file → Normal file
View File

@@ -35,7 +35,7 @@ QString PinTool::name() const {
}
QString PinTool::nameID() {
return "";
return QLatin1String("");
}
QString PinTool::description() const {

View File

@@ -35,7 +35,7 @@ QString RectangleTool::name() const {
}
QString RectangleTool::nameID() {
return "";
return QLatin1String("");
}
QString RectangleTool::description() const {

View File

@@ -35,7 +35,7 @@ QString RedoTool::name() const {
}
QString RedoTool::nameID() {
return "";
return QLatin1String("");
}
QString RedoTool::description() const {

View File

@@ -36,7 +36,7 @@ QString SaveTool::name() const {
}
QString SaveTool::nameID() {
return "";
return QLatin1String("");
}
QString SaveTool::description() const {

View File

@@ -39,7 +39,7 @@ QString SelectionTool::name() const {
}
QString SelectionTool::nameID() {
return "";
return QLatin1String("");
}
QString SelectionTool::description() const {

View File

@@ -35,7 +35,7 @@ QString SizeIndicatorTool::name() const {
}
QString SizeIndicatorTool::nameID() {
return "";
return QLatin1String("");
}
QString SizeIndicatorTool::description() const {

View File

@@ -42,28 +42,28 @@ TextConfig::TextConfig(QWidget *parent) : QWidget(parent) {
PathInfo::blackIconPath();
m_strikeOutButton = new QPushButton(
QIcon(iconPrefix + "format_strikethrough.svg"), "");
QIcon(iconPrefix + "format_strikethrough.svg"), QLatin1String(""));
m_strikeOutButton->setCheckable(true);
connect(m_strikeOutButton, &QPushButton::clicked,
this, &TextConfig::fontStrikeOutChanged);
m_strikeOutButton->setToolTip(tr("StrikeOut"));
m_underlineButton = new QPushButton(
QIcon(iconPrefix + "format_underlined.svg"), "");
QIcon(iconPrefix + "format_underlined.svg"), QLatin1String(""));
m_underlineButton->setCheckable(true);
connect(m_underlineButton, &QPushButton::clicked,
this, &TextConfig::fontUnderlineChanged);
m_underlineButton->setToolTip(tr("Underline"));
m_weightButton = new QPushButton(
QIcon(iconPrefix + "format_bold.svg"), "");
QIcon(iconPrefix + "format_bold.svg"), QLatin1String(""));
m_weightButton->setCheckable(true);
connect(m_weightButton, &QPushButton::clicked,
this, &TextConfig::weightButtonPressed);
m_weightButton->setToolTip(tr("Bold"));
m_italicButton = new QPushButton(
QIcon(iconPrefix + "format_italic.svg"), "");
QIcon(iconPrefix + "format_italic.svg"), QLatin1String(""));
m_italicButton->setCheckable(true);
connect(m_italicButton, &QPushButton::clicked,
this, &TextConfig::fontItalicChanged);

View File

@@ -51,7 +51,7 @@ QString TextTool::name() const {
}
QString TextTool::nameID() {
return "";
return QLatin1String("");
}
QString TextTool::description() const {

View File

@@ -18,7 +18,7 @@
#include "textwidget.h"
TextWidget::TextWidget(QWidget *parent) : QTextEdit(parent) {
setStyleSheet("TextWidget { background: transparent; }");
setStyleSheet(QStringLiteral("TextWidget { background: transparent; }"));
connect(this, &TextWidget::textChanged,
this, &TextWidget::adjustSize);
connect(this, &TextWidget::textChanged,
@@ -61,7 +61,7 @@ void TextWidget::setFontPointSize(qreal s) {
}
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()));
}

View File

@@ -35,7 +35,7 @@ QString UndoTool::name() const {
}
QString UndoTool::nameID() {
return "";
return QLatin1String("");
}
QString UndoTool::description() const {

View File

@@ -27,13 +27,13 @@ ConfigHandler::ConfigHandler(){
QVector<CaptureButton::ButtonType> ConfigHandler::getButtons() {
QVector<CaptureButton::ButtonType> buttons;
if (m_settings.contains("buttons")) {
if (m_settings.contains(QStringLiteral("buttons"))) {
// TODO: remove toList in v1.0
QVector<int> buttonsInt =
m_settings.value("buttons").value<QList<int> >().toVector();
m_settings.value(QStringLiteral("buttons")).value<QList<int> >().toVector();
bool modified = normalizeButtons(buttonsInt);
if (modified) {
m_settings.setValue("buttons", QVariant::fromValue(buttonsInt.toList()));
m_settings.setValue(QStringLiteral("buttons"), QVariant::fromValue(buttonsInt.toList()));
}
buttons = fromIntToButton(buttonsInt);
} else {
@@ -69,7 +69,7 @@ void ConfigHandler::setButtons(const QVector<CaptureButton::ButtonType> &buttons
QVector<int> l = fromButtonToInt(buttons);
normalizeButtons(l);
// 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() {
@@ -86,8 +86,8 @@ QVector<QColor> ConfigHandler::getUserColors() {
Qt::darkMagenta
};
if (m_settings.contains("userColors")) {
for (const QString &hex : m_settings.value("userColors").toStringList()) {
if (m_settings.contains(QStringLiteral("userColors"))) {
for (const QString &hex : m_settings.value(QStringLiteral("userColors")).toStringList()) {
if (QColor::isValidColor(hex)) {
colors.append(QColor(hex));
}
@@ -110,22 +110,22 @@ void ConfigHandler::setUserColors(const QVector<QColor> &l) {
hexColors.append(color.name());
}
m_settings.setValue("userColors", QVariant::fromValue(hexColors));
m_settings.setValue(QStringLiteral("userColors"), QVariant::fromValue(hexColors));
}
QString ConfigHandler::savePathValue() {
return m_settings.value("savePath").toString();
return m_settings.value(QStringLiteral("savePath")).toString();
}
void ConfigHandler::setSavePath(const QString &savePath) {
m_settings.setValue("savePath", savePath);
m_settings.setValue(QStringLiteral("savePath"), savePath);
}
QColor ConfigHandler::uiMainColorValue() {
QColor res = QColor(116, 0, 150);
if (m_settings.contains("uiColor")) {
QString hex = m_settings.value("uiColor").toString();
if (m_settings.contains(QStringLiteral("uiColor"))) {
QString hex = m_settings.value(QStringLiteral("uiColor")).toString();
if (QColor::isValidColor(hex)) {
res = QColor(hex);
@@ -135,14 +135,14 @@ QColor ConfigHandler::uiMainColorValue() {
}
void ConfigHandler::setUIMainColor(const QColor &c) {
m_settings.setValue("uiColor", c.name());
m_settings.setValue(QStringLiteral("uiColor"), c.name());
}
QColor ConfigHandler::uiContrastColorValue() {
QColor res = QColor(86, 0, 120);
if (m_settings.contains("contastUiColor")) {
QString hex = m_settings.value("contastUiColor").toString();
if (m_settings.contains(QStringLiteral("contastUiColor"))) {
QString hex = m_settings.value(QStringLiteral("contastUiColor")).toString();
if (QColor::isValidColor(hex)) {
res = QColor(hex);
@@ -153,14 +153,14 @@ QColor ConfigHandler::uiContrastColorValue() {
}
void ConfigHandler::setUIContrastColor(const QColor &c) {
m_settings.setValue("contastUiColor", c.name());
m_settings.setValue(QStringLiteral("contastUiColor"), c.name());
}
QColor ConfigHandler::drawColorValue() {
QColor res(Qt::red);
if (m_settings.contains("drawColor")) {
QString hex = m_settings.value("drawColor").toString();
if (m_settings.contains(QStringLiteral("drawColor"))) {
QString hex = m_settings.value(QStringLiteral("drawColor")).toString();
if (QColor::isValidColor(hex)) {
res = QColor(hex);
@@ -171,71 +171,71 @@ QColor ConfigHandler::drawColorValue() {
}
void ConfigHandler::setDrawColor(const QColor &c) {
m_settings.setValue("drawColor", c.name());
m_settings.setValue(QStringLiteral("drawColor"), c.name());
}
bool ConfigHandler::showHelpValue() {
bool res = true;
if (m_settings.contains("showHelp")) {
res = m_settings.value("showHelp").toBool();
if (m_settings.contains(QStringLiteral("showHelp"))) {
res = m_settings.value(QStringLiteral("showHelp")).toBool();
}
return res;
}
void ConfigHandler::setShowHelp(const bool showHelp) {
m_settings.setValue("showHelp", showHelp);
m_settings.setValue(QStringLiteral("showHelp"), showHelp);
}
bool ConfigHandler::desktopNotificationValue() {
bool res = true;
if (m_settings.contains("showDesktopNotification")) {
res = m_settings.value("showDesktopNotification").toBool();
if (m_settings.contains(QStringLiteral("showDesktopNotification"))) {
res = m_settings.value(QStringLiteral("showDesktopNotification")).toBool();
}
return res;
}
void ConfigHandler::setDesktopNotification(const bool showDesktopNotification) {
m_settings.setValue("showDesktopNotification", showDesktopNotification);
m_settings.setValue(QStringLiteral("showDesktopNotification"), showDesktopNotification);
}
QString ConfigHandler::filenamePatternValue() {
return m_settings.value("filenamePattern").toString();
return m_settings.value(QStringLiteral("filenamePattern")).toString();
}
void ConfigHandler::setFilenamePattern(const QString &pattern) {
return m_settings.setValue("filenamePattern", pattern);
return m_settings.setValue(QStringLiteral("filenamePattern"), pattern);
}
bool ConfigHandler::disabledTrayIconValue() {
bool res = false;
if (m_settings.contains("disabledTrayIcon")) {
res = m_settings.value("disabledTrayIcon").toBool();
if (m_settings.contains(QStringLiteral("disabledTrayIcon"))) {
res = m_settings.value(QStringLiteral("disabledTrayIcon")).toBool();
}
return res;
}
void ConfigHandler::setDisabledTrayIcon(const bool disabledTrayIcon) {
m_settings.setValue("disabledTrayIcon", disabledTrayIcon);
m_settings.setValue(QStringLiteral("disabledTrayIcon"), disabledTrayIcon);
}
int ConfigHandler::drawThicknessValue() {
int res = 0;
if (m_settings.contains("drawThickness")) {
res = m_settings.value("drawThickness").toInt();
if (m_settings.contains(QStringLiteral("drawThickness"))) {
res = m_settings.value(QStringLiteral("drawThickness")).toInt();
}
return res;
}
void ConfigHandler::setdrawThickness(const int thickness) {
m_settings.setValue("drawThickness", thickness);
m_settings.setValue(QStringLiteral("drawThickness"), thickness);
}
bool ConfigHandler::keepOpenAppLauncherValue() {
return m_settings.value("keepOpenAppLauncher").toBool();
return m_settings.value(QStringLiteral("keepOpenAppLauncher")).toBool();
}
void ConfigHandler::setKeepOpenAppLauncher(const bool keepOpen) {
m_settings.setValue("keepOpenAppLauncher", keepOpen);
m_settings.setValue(QStringLiteral("keepOpenAppLauncher"), keepOpen);
}
bool ConfigHandler::startupLaunchValue() {
@@ -283,15 +283,15 @@ void ConfigHandler::setStartupLaunch(const bool start) {
int ConfigHandler::contrastOpacityValue() {
int opacity = 190;
if (m_settings.contains("contrastOpacity")) {
opacity = m_settings.value("contrastOpacity").toInt();
if (m_settings.contains(QStringLiteral("contrastOpacity"))) {
opacity = m_settings.value(QStringLiteral("contrastOpacity")).toInt();
opacity = qBound(0, opacity, 255);
}
return opacity;
}
void ConfigHandler::setContrastOpacity(const int transparency) {
m_settings.setValue("contrastOpacity", transparency);
m_settings.setValue(QStringLiteral("contrastOpacity"), transparency);
}
void ConfigHandler::setDefaults() {
@@ -305,7 +305,7 @@ void ConfigHandler::setAllTheButtons() {
buttons << static_cast<int>(t);
}
// 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 {

View File

@@ -27,13 +27,13 @@ DBusUtils::DBusUtils(QObject *parent) : QObject(parent) {
void DBusUtils::connectPrintCapture(QDBusConnection &session, uint id) {
m_id = id;
// captureTaken
session.connect("org.dharkael.Flameshot",
"/", "", "captureTaken",
session.connect(QStringLiteral("org.dharkael.Flameshot"),
QStringLiteral("/"), QLatin1String(""), QStringLiteral("captureTaken"),
this,
SLOT(captureTaken(uint, QByteArray)));
// captureFailed
session.connect("org.dharkael.Flameshot",
"/", "", "captureFailed",
session.connect(QStringLiteral("org.dharkael.Flameshot"),
QStringLiteral("/"), QLatin1String(""), QStringLiteral("captureFailed"),
this,
SLOT(captureFailed(uint)));
}

View File

@@ -30,7 +30,7 @@ DesktopFileParser::DesktopFileParser() {
m_localeNameShort = QStringLiteral("Name[%1]").arg(localeShort);
m_localeDescriptionShort = QStringLiteral("Comment[%1]")
.arg(localeShort);
m_defaultIcon = QIcon::fromTheme("application-x-executable");
m_defaultIcon = QIcon::fromTheme(QStringLiteral("application-x-executable"));
}
DesktopAppData DesktopFileParser::parseDesktopFile(
@@ -48,62 +48,62 @@ DesktopAppData DesktopFileParser::parseDesktopFile(
bool isApplication = false;
QTextStream in(&file);
// enter the desktop entry definition
while (!in.atEnd() && in.readLine() != "[Desktop Entry]") {
while (!in.atEnd() && in.readLine() != QLatin1String("[Desktop Entry]")) {
}
// start parsing
while (!in.atEnd()) {
QString line = in.readLine();
if (line.startsWith("Icon")) {
if (line.startsWith(QLatin1String("Icon"))) {
res.icon = QIcon::fromTheme(
line.mid(line.indexOf("=")+1).trimmed(),
line.mid(line.indexOf(QLatin1String("="))+1).trimmed(),
m_defaultIcon);
}
else if (!nameLocaleSet && line.startsWith("Name")) {
else if (!nameLocaleSet && line.startsWith(QLatin1String("Name"))) {
if (line.startsWith(m_localeName) ||
line.startsWith(m_localeNameShort))
{
res.name = line.mid(line.indexOf("=")+1).trimmed();
res.name = line.mid(line.indexOf(QLatin1String("="))+1).trimmed();
nameLocaleSet = true;
} else if (line.startsWith("Name=")) {
res.name = line.mid(line.indexOf("=")+1).trimmed();
} else if (line.startsWith(QLatin1String("Name="))) {
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) ||
line.startsWith(m_localeDescriptionShort))
{
res.description = line.mid(line.indexOf("=")+1).trimmed();
res.description = line.mid(line.indexOf(QLatin1String("="))+1).trimmed();
descriptionLocaleSet = true;
} else if (line.startsWith("Comment=")) {
res.description = line.mid(line.indexOf("=")+1).trimmed();
} else if (line.startsWith(QLatin1String("Comment="))) {
res.description = line.mid(line.indexOf(QLatin1String("="))+1).trimmed();
}
}
else if (line.startsWith("Exec")) {
if (line.contains("%")) {
res.exec = line.mid(line.indexOf("=")+1)
else if (line.startsWith(QLatin1String("Exec"))) {
if (line.contains(QLatin1String("%"))) {
res.exec = line.mid(line.indexOf(QLatin1String("="))+1)
.trimmed();
} else {
ok = false;
break;
}
}
else if (line.startsWith("Type")) {
if (line.contains("Application")) {
else if (line.startsWith(QLatin1String("Type"))) {
if (line.contains(QLatin1String("Application"))) {
isApplication = true;
}
}
else if (line.startsWith("Categories")) {
res.categories = line.mid(line.indexOf("=")+1).split(";");
else if (line.startsWith(QLatin1String("Categories"))) {
res.categories = line.mid(line.indexOf(QLatin1String("="))+1).split(QStringLiteral(";"));
}
else if (line == "NoDisplay=true") {
else if (line == QLatin1String("NoDisplay=true")) {
ok = false;
break;
}
else if (line == "Terminal=true") {
else if (line == QLatin1String("Terminal=true")) {
res.showInTerminal = true;
}
// ignore the other entries
else if (line.startsWith("[")) {
else if (line.startsWith(QLatin1String("["))) {
break;
}
}

View File

@@ -20,26 +20,26 @@
DesktopInfo::DesktopInfo() {
auto e = QProcessEnvironment::systemEnvironment();
XDG_CURRENT_DESKTOP = e.value("XDG_CURRENT_DESKTOP");
XDG_SESSION_TYPE = e.value("XDG_SESSION_TYPE");
WAYLAND_DISPLAY = e.value("WAYLAND_DISPLAY");
KDE_FULL_SESSION = e.value("KDE_FULL_SESSION");
GNOME_DESKTOP_SESSION_ID = e.value("GNOME_DESKTOP_SESSION_ID");
DESKTOP_SESSION = e.value("DESKTOP_SESSION");
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"));
DESKTOP_SESSION = e.value(QStringLiteral("DESKTOP_SESSION"));
}
bool DesktopInfo::waylandDectected() {
return XDG_SESSION_TYPE == "wayland" ||
WAYLAND_DISPLAY.contains("wayland", Qt::CaseInsensitive);
return XDG_SESSION_TYPE == QLatin1String("wayland") ||
WAYLAND_DISPLAY.contains(QLatin1String("wayland"), Qt::CaseInsensitive);
}
DesktopInfo::WM DesktopInfo::windowManager() {
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())
{
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;
}
return res;

View File

@@ -33,7 +33,7 @@ QString FileNameHandler::parsedPattern() {
QString FileNameHandler::parseFilename(const QString &name) {
QString res = name;
if (name.isEmpty()) {
res = "%F_%H-%M";
res = QLatin1String("%F_%H-%M");
}
std::time_t t = std::time(NULL);
@@ -45,7 +45,7 @@ QString FileNameHandler::parseFilename(const QString &name) {
free(tempData);
// 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;
}
@@ -87,14 +87,14 @@ char * FileNameHandler::QStringTocharArr(const QString &s) {
void FileNameHandler::fixPath(QString &directory, QString &filename) {
// add '/' at the end of the directory
if (!directory.endsWith("/")) {
directory += "/";
if (!directory.endsWith(QLatin1String("/"))) {
directory += QLatin1String("/");
}
// add numeration in case of repeated filename in the directory
// find unused name adding _n where n is a number
QFileInfo checkFile(directory + filename + ".png");
if (checkFile.exists()) {
filename += "_";
filename += QLatin1String("_");
int i = 1;
while (true) {
checkFile.setFile(

View File

@@ -21,11 +21,11 @@
#include <QDir>
const QString PathInfo::whiteIconPath() {
return ":/img/material/white/";
return QStringLiteral(":/img/material/white/");
}
const QString PathInfo::blackIconPath() {
return ":/img/material/black/";
return QStringLiteral(":/img/material/black/");
}
QStringList PathInfo::translationsPaths() {
@@ -34,10 +34,10 @@ QStringList PathInfo::translationsPaths() {
QString trPath = QDir::toNativeSeparators(binaryPath + "/translations") ;
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
return QStringList()
<< QString(APP_PREFIX) + "/share/flameshot/translations"
<< QStringLiteral(APP_PREFIX) + "/share/flameshot/translations"
<< trPath
<< "/usr/share/flameshot/translations"
<< "/usr/local/share/flameshot/translations";
<< QStringLiteral("/usr/share/flameshot/translations")
<< QStringLiteral("/usr/local/share/flameshot/translations");
#elif defined(Q_OS_WIN)
return QStringList()
<< trPath;

View File

@@ -47,7 +47,7 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool &ok) {
QDBusInterface gnomeInterface(QStringLiteral("org.gnome.Shell"),
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()) {
res = QPixmap(path);
QFile dbusResult(path);
@@ -61,7 +61,7 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool &ok) {
QDBusInterface kwinInterface(QStringLiteral("org.kde.KWin"),
QStringLiteral("/Screenshot"),
QStringLiteral("org.kde.kwin.Screenshot"));
QDBusReply<QString> reply = kwinInterface.call("screenshotFullscreen");
QDBusReply<QString> reply = kwinInterface.call(QStringLiteral("screenshotFullscreen"));
res = QPixmap(reply.value());
if (!res.isNull()) {
QFile dbusResult(reply.value());

View File

@@ -38,7 +38,7 @@ bool ScreenshotSaver::saveToFilesystem(const QPixmap &capture,
const QString &path)
{
QString completePath = FileNameHandler().generateAbsolutePath(path);
completePath += ".png";
completePath += QLatin1String(".png");
bool ok = capture.save(completePath);
QString saveMessage;
@@ -66,14 +66,14 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap &capture) {
break;
}
if (!savePath.endsWith(".png")) {
savePath += ".png";
if (!savePath.endsWith(QLatin1String(".png"))) {
savePath += QLatin1String(".png");
}
ok = capture.save(savePath);
if (ok) {
QString pathNoFile = savePath.left(savePath.lastIndexOf("/"));
QString pathNoFile = savePath.left(savePath.lastIndexOf(QLatin1String("/")));
ConfigHandler().setSavePath(pathNoFile);
QString msg = QObject::tr("Capture saved as ") + savePath;
SystemNotification().sendMessage(msg);

View File

@@ -47,7 +47,7 @@ void SystemNotification::sendMessage(
<< QStringList() //actions
<< QVariantMap() //hints
<< timeout; //timeout
m_interface->callWithArgumentList(QDBus::AutoDetect, "Notify", args);
m_interface->callWithArgumentList(QDBus::AutoDetect, QStringLiteral("Notify"), args);
#else
auto c = Controller::getInstance();
c->sendTrayNotification(text, title, timeout);

View File

@@ -129,7 +129,7 @@ void CaptureButton::animatedShow() {
if(!isVisible()) {
show();
m_emergeAnimation->start();
connect(m_emergeAnimation, &QPropertyAnimation::finished, this, [this](){
connect(m_emergeAnimation, &QPropertyAnimation::finished, this, [](){
});
}
}

View File

@@ -63,5 +63,5 @@ void NotifierBox::showMessage(const QString &msg) {
void NotifierBox::showColor(const QColor &color) {
Q_UNUSED(color);
m_message = "";
m_message = QLatin1String("");
}

View File

@@ -121,7 +121,7 @@ void InfoWindow::initLabels() {
QLabel *licenseTitleLabel = new QLabel(tr("<u><b>License</b></u>"), this);
licenseTitleLabel->setAlignment(Qt::AlignHCenter);
m_layout->addWidget(licenseTitleLabel);
QLabel *licenseLabel = new QLabel("GPLv3+", this);
QLabel *licenseLabel = new QLabel(QStringLiteral("GPLv3+"), this);
licenseLabel->setAlignment(Qt::AlignHCenter);
m_layout->addWidget(licenseLabel);
m_layout->addStretch();
@@ -129,7 +129,7 @@ void InfoWindow::initLabels() {
QLabel *versionTitleLabel = new QLabel(tr("<u><b>Version</b></u>"), this);
versionTitleLabel->setAlignment(Qt::AlignHCenter);
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;
QLabel *versionLabel = new QLabel(versionMsg, this);
versionLabel->setAlignment(Qt::AlignHCenter);

View File

@@ -32,7 +32,7 @@ LoadSpinner::LoadSpinner(QWidget *parent) :
updateFrame();
// init timer
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);
}

View File

@@ -78,7 +78,7 @@ SidePanelWidget::SidePanelWidget(QPixmap *p, QWidget *parent) :
QString modifier = isDark ? PathInfo::whiteIconPath() :
PathInfo::blackIconPath();
QIcon grabIcon(modifier + "colorize.svg");
m_colorGrabButton = new QPushButton(grabIcon, "");
m_colorGrabButton = new QPushButton(grabIcon, QLatin1String(""));
updateGrabButton(false);
connect(m_colorGrabButton, &QPushButton::pressed,
this, &SidePanelWidget::colorGrabberActivated);
@@ -96,7 +96,7 @@ SidePanelWidget::SidePanelWidget(QPixmap *p, QWidget *parent) :
void SidePanelWidget::updateColor(const QColor &c) {
m_color = c;
m_colorLabel->setStyleSheet(
QString("QLabel { background-color : %1; }").arg(c.name()));
QStringLiteral("QLabel { background-color : %1; }").arg(c.name()));
m_colorWheel->setColor(m_color);
}
@@ -109,7 +109,7 @@ void SidePanelWidget::updateThickness(const int &t)
void SidePanelWidget::updateColorNoWheel(const QColor &c) {
m_color = c;
m_colorLabel->setStyleSheet(
QString("QLabel { background-color : %1; }").arg(c.name()));
QStringLiteral("QLabel { background-color : %1; }").arg(c.name()));
}
void SidePanelWidget::updateCurrentThickness()

View File

@@ -98,7 +98,7 @@ void UtilityPanel::initInternalPanel() {
QColor bgColor = palette().background().color();
bgColor.setAlphaF(0.0);
m_internalPanel->setStyleSheet(QString("QScrollArea {background-color: %1}")
m_internalPanel->setStyleSheet(QStringLiteral("QScrollArea {background-color: %1}")
.arg(bgColor.name()));
m_internalPanel->hide();
}