Fix warnings and enable Werror

This commit is contained in:
Adam Lamar 2024-03-08 04:24:31 +00:00
parent 0205db459d
commit fc67c0d76c
8 changed files with 33 additions and 16 deletions

View File

@ -15,7 +15,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = kiwix-desktop
TEMPLATE = app
QMAKE_CXXFLAGS += -std=c++17
QMAKE_CXXFLAGS += -std=c++17 -Werror
QMAKE_LFLAGS += -std=c++17
# Also change resources/org.kiwix.desktop.appdata.xml

View File

@ -543,6 +543,9 @@ void ContentManager::downloadBook(const QString &id)
void ContentManager::eraseBookFilesFromComputer(const QString dirPath, const QString fileName, const bool moveToTrash)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
Q_UNUSED(moveToTrash);
#endif
if (fileName == "*") {
return;
}
@ -638,6 +641,8 @@ void ContentManager::resumeBook(const QString& id)
void ContentManager::cancelBook(const QString& id, QModelIndex index)
{
Q_UNUSED(index);
auto text = gt("cancel-download-text");
text = text.replace("{{ZIM}}", QString::fromStdString(mp_library->getBookById(id).getTitle()));
showConfirmBox(gt("cancel-download"), text, mp_view, [=]() {
@ -738,7 +743,7 @@ QString makeHttpUrl(QString host, int port)
} // unnamed namespace
void ContentManager::updateRemoteLibrary(const QString& content) {
QtConcurrent::run([=]() {
(void) QtConcurrent::run([=]() {
QMutexLocker locker(&remoteLibraryLocker);
mp_remoteLibrary = kiwix::Library::create();
kiwix::Manager manager(mp_remoteLibrary);

View File

@ -210,6 +210,8 @@ void ContentManagerDelegate::paint(QPainter *painter, const QStyleOptionViewItem
bool ContentManagerDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
{
Q_UNUSED(model);
if(event->type() == QEvent::MouseButtonRelease )
{
QMouseEvent * e = (QMouseEvent *)event;
@ -270,6 +272,8 @@ void ContentManagerDelegate::handleLastColumnClicked(const QModelIndex& index, Q
QSize ContentManagerDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
Q_UNUSED(option);
if (index.parent().isValid()) {
return QSize(300, 70);
}

View File

@ -41,17 +41,14 @@ KiwixApp::KiwixApp(int& argc, char *argv[])
QMessageBox::critical(nullptr, "Translation error", e.what());
return;
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
m_qtTranslator.load(QLocale(), "qt", "_",
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
#else
m_qtTranslator.load(QLocale(), "qt", "_",
QLibraryInfo::path(QLibraryInfo::TranslationsPath));
#endif
installTranslator(&m_qtTranslator);
m_appTranslator.load(QLocale(), "kiwix-desktop", "_", ":/i18n/");
installTranslator(&m_appTranslator);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QString path = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
#else
QString path = QLibraryInfo::path(QLibraryInfo::TranslationsPath);
#endif
loadAndInstallTranslations(m_qtTranslator, "qt", path);
loadAndInstallTranslations(m_appTranslator, "kiwix-desktop", ":/i18n/");
QFontDatabase::addApplicationFont(":/fonts/Selawik/selawkb.ttf");
QFontDatabase::addApplicationFont(":/fonts/Selawik/selawkl.ttf");
@ -61,6 +58,12 @@ KiwixApp::KiwixApp(int& argc, char *argv[])
setFont(QFont("Selawik"));
}
void KiwixApp::loadAndInstallTranslations(QTranslator& translator, const QString& filename, const QString& directory) {
if (translator.load(QLocale(), filename, "_", directory)) {
installTranslator(&translator);
}
}
void KiwixApp::init()
{
try {
@ -441,10 +444,10 @@ void KiwixApp::createActions()
mpa_actions[FindInPageAction]->setShortcuts({QKeySequence::Find, Qt::Key_F3});
connect(mpa_actions[FindInPageAction], &QAction::triggered,
this, [=]() { getTabWidget()->openFindInPageBar(); });
const auto fullScreenKeySeq = QKeySequence(QKeySequence::FullScreen).isEmpty()
? Qt::Key_F11
: QKeySequence::FullScreen;
? (int) Qt::Key_F11
: (int) QKeySequence::FullScreen;
CREATE_ACTION_ICON_SHORTCUT(ToggleFullscreenAction, "full-screen-enter", gt("set-fullscreen"), fullScreenKeySeq);
connect(mpa_actions[ToggleFullscreenAction], &QAction::toggled,
this, [=](bool checked) {

View File

@ -123,6 +123,7 @@ private:
QString findLibraryDirectory();
void restoreTabs();
void loadAndInstallTranslations(QTranslator& translator, const QString& filename, const QString& directory);
};
QString gt(const QString &key);

View File

@ -16,6 +16,8 @@ void KiwixLineEdit::resizeEvent(QResizeEvent *event)
}
bool KiwixLineEdit::eventFilter(QObject* object, QEvent* event)
{
Q_UNUSED(object);
if (event->type() == QEvent::MouseButtonPress) {
emit(clicked());
} else if (event->type() == QEvent::FocusIn) {

View File

@ -41,6 +41,8 @@ void createArc(QPainter &painter, int startAngle, int spanAngle, QRect rectangle
void KiwixLoader::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);

View File

@ -170,7 +170,7 @@ void Library::updateFromDir(QString monitorDir)
void Library::asyncUpdateFromDir(QString dir)
{
QtConcurrent::run( [=]() {
(void) QtConcurrent::run([=]() {
updateFromDir(dir);
});
}