Commit 2d615ac7 authored by Carl Schwan's avatar Carl Schwan 🚴
Browse files

Correct errors in cmake pointed out by frinring

* xi18nc() -> i18nc
* KLocalizedString::setApplicationDomain("kontrast"); should be done right after QApplication
* add_definitions() should be before add_subdirectory()
parent 6080a981
cmake_minimum_required(VERSION 3.8)
project(kontrast)
project(kontrast VERSION "1.0.0")
set(QT_MIN_VERSION "5.14.0")
set(KF5_MIN_VERSION "5.70.0")
......@@ -26,13 +26,13 @@ find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Gui Qml QuickControl
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Kirigami2 I18n CoreAddons Declarative)
################# build and install #################
add_subdirectory(src)
add_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_URL_CAST_FROM_STRING)
add_definitions(-DQT_USE_QSTRINGBUILDER)
add_definitions(-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT)
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00)
add_subdirectory(src)
install(PROGRAMS org.kde.kontrast.desktop DESTINATION ${KDE_INSTALL_APPDIR})
install(FILES org.kde.kontrast.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
install(FILES org.kde.kontrast.svg DESTINATION ${KDE_INSTALL_FULL_ICONDIR}/hicolor/scalable/apps)
......
......@@ -13,7 +13,7 @@ Kontrast::Kontrast(KAboutData about, QObject *parent)
: QObject(parent)
, m_about(about)
{
setObjectName("Kontrast");
setObjectName(QStringLiteral("Kontrast"));
}
QColor Kontrast::textColor() const
......
......@@ -17,18 +17,17 @@
Q_DECL_EXPORT int main(int argc, char *argv[])
{
KLocalizedString::setApplicationDomain("kontrast");
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
app.setApplicationName("Kontrast");
KLocalizedString::setApplicationDomain("kontrast");
KAboutData aboutData("kontrast", xi18nc("@title", "Kontrast"), "1.0",
xi18nc("@title", "A contrast checker application"),
KAboutData aboutData(QStringLiteral("kontrast"), i18nc("@title", "Kontrast"), QStringLiteral("1.0"),
i18nc("@title", "A contrast checker application"),
KAboutLicense::GPL_V3);
aboutData.addAuthor(xi18nc("@info:credit", "Carl Schwan"), xi18nc("@info:credit", "Maintainer and creator"), "carl@carlschwan.eu", "https://carlschwan.eu");
aboutData.addCredit(xi18nc("@info:credit", "Wikipedia"), xi18nc("@info:credit", "Text on the main page CC-BY-SA-4.0"));
aboutData.addAuthor(xi18nc("@info:credit", "Carson Black"), xi18nc("@info:credit", "SQLite backend for favorite colors"));
aboutData.addAuthor(i18nc("@info:credit", "Carl Schwan"), i18nc("@info:credit", "Maintainer and creator"), QStringLiteral("carl@carlschwan.eu"), QStringLiteral("https://carlschwan.eu"));
aboutData.addCredit(i18nc("@info:credit", "Wikipedia"), i18nc("@info:credit", "Text on the main page CC-BY-SA-4.0"));
aboutData.addAuthor(i18nc("@info:credit", "Carson Black"), i18nc("@info:credit", "SQLite backend for favorite colors"));
KAboutData::setApplicationData(aboutData);
QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("org.kde.kontrast")));
......
......@@ -13,7 +13,7 @@
#include <QStandardPaths>
#include <QSqlError>
const QString DRIVER("QSQLITE");
const QString DRIVER(QStringLiteral("QSQLITE"));
SavedColorModel::SavedColorModel(QObject *parent)
: QAbstractListModel(parent)
......@@ -21,7 +21,7 @@ SavedColorModel::SavedColorModel(QObject *parent)
Q_ASSERT(QSqlDatabase::isDriverAvailable(DRIVER));
Q_ASSERT(QDir().mkpath(QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation))));
m_db = QSqlDatabase::addDatabase(DRIVER);
const auto path = QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + qApp->applicationName());
const auto path = QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/") + qApp->applicationName());
m_db.setDatabaseName(path);
if (!m_db.open()) {
qCritical() << m_db.lastError() << "while opening database at" << path;
......@@ -41,7 +41,7 @@ SavedColorModel::SavedColorModel(QObject *parent)
qCritical() << query.lastError() << "while creating table";
}
m_query = QSqlQuery(m_db);
ok = m_query.prepare("SELECT * FROM SavedColorModel");
ok = m_query.prepare(QStringLiteral("SELECT * FROM SavedColorModel"));
if (!ok) {
qCritical() << m_query.lastError() << "while preparing query";
}
......@@ -120,11 +120,11 @@ QVariant SavedColorModel::data(const QModelIndex &index, int role) const
switch (role) {
case Qt::DisplayRole:
return m_query.value("Name");
return m_query.value(QStringLiteral("Name"));
case TextColor:
return m_query.value("ForegroundColor");
return m_query.value(QStringLiteral("ForegroundColor"));
case BackgroundColor:
return m_query.value("BackgroundColor");
return m_query.value(QStringLiteral("BackgroundColor"));
}
return QVariant();
......@@ -144,19 +144,19 @@ auto SavedColorModel::setData(const QModelIndex &idx, const QVariant &value, int
switch (role) {
case Qt::DisplayRole:
mutated = statement.arg("Name"); break;
mutated = statement.arg(QStringLiteral("Name")); break;
case TextColor:
mutated = statement.arg("ForegroundColor"); break;
mutated = statement.arg(QStringLiteral("ForegroundColor")); break;
case BackgroundColor:
mutated = statement.arg("BackgroundColor"); break;
mutated = statement.arg(QStringLiteral("BackgroundColor")); break;
default:
return false;
}
QSqlQuery query;
query.prepare(mutated);
query.bindValue(":value", value);
query.bindValue(":id", m_query.value("ID"));
query.bindValue(QStringLiteral(":value"), value);
query.bindValue(QStringLiteral(":id"), m_query.value(QStringLiteral("ID")));
auto ok = query.exec();
if (!ok) {
......@@ -183,9 +183,9 @@ bool SavedColorModel::addColor(const QString& name, const QColor& foreground, co
)RJIENRLWEY");
QSqlQuery query;
query.prepare(statement);
query.bindValue(":name", name);
query.bindValue(":foreground", foreground);
query.bindValue(":background", background);
query.bindValue(QStringLiteral(":name"), name);
query.bindValue(QStringLiteral(":foreground"), foreground);
query.bindValue(QStringLiteral(":background"), background);
auto ok = query.exec();
if (!ok) {
......@@ -204,7 +204,7 @@ bool SavedColorModel::removeColor(int index)
)RJIENRLWEY");
QSqlQuery query;
query.prepare(statement);
query.bindValue(":id", index);
query.bindValue(QStringLiteral(":id"), index);
auto ok = query.exec();
if (!ok) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment