mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-23 03:58:56 -04:00
Fix warnings and enable Werror
This commit is contained in:
parent
0205db459d
commit
fc67c0d76c
@ -15,7 +15,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
|||||||
TARGET = kiwix-desktop
|
TARGET = kiwix-desktop
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
|
|
||||||
QMAKE_CXXFLAGS += -std=c++17
|
QMAKE_CXXFLAGS += -std=c++17 -Werror
|
||||||
QMAKE_LFLAGS += -std=c++17
|
QMAKE_LFLAGS += -std=c++17
|
||||||
|
|
||||||
# Also change resources/org.kiwix.desktop.appdata.xml
|
# Also change resources/org.kiwix.desktop.appdata.xml
|
||||||
|
@ -543,6 +543,9 @@ void ContentManager::downloadBook(const QString &id)
|
|||||||
|
|
||||||
void ContentManager::eraseBookFilesFromComputer(const QString dirPath, const QString fileName, const bool moveToTrash)
|
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 == "*") {
|
if (fileName == "*") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -638,6 +641,8 @@ void ContentManager::resumeBook(const QString& id)
|
|||||||
|
|
||||||
void ContentManager::cancelBook(const QString& id, QModelIndex index)
|
void ContentManager::cancelBook(const QString& id, QModelIndex index)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(index);
|
||||||
|
|
||||||
auto text = gt("cancel-download-text");
|
auto text = gt("cancel-download-text");
|
||||||
text = text.replace("{{ZIM}}", QString::fromStdString(mp_library->getBookById(id).getTitle()));
|
text = text.replace("{{ZIM}}", QString::fromStdString(mp_library->getBookById(id).getTitle()));
|
||||||
showConfirmBox(gt("cancel-download"), text, mp_view, [=]() {
|
showConfirmBox(gt("cancel-download"), text, mp_view, [=]() {
|
||||||
@ -738,7 +743,7 @@ QString makeHttpUrl(QString host, int port)
|
|||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
void ContentManager::updateRemoteLibrary(const QString& content) {
|
void ContentManager::updateRemoteLibrary(const QString& content) {
|
||||||
QtConcurrent::run([=]() {
|
(void) QtConcurrent::run([=]() {
|
||||||
QMutexLocker locker(&remoteLibraryLocker);
|
QMutexLocker locker(&remoteLibraryLocker);
|
||||||
mp_remoteLibrary = kiwix::Library::create();
|
mp_remoteLibrary = kiwix::Library::create();
|
||||||
kiwix::Manager manager(mp_remoteLibrary);
|
kiwix::Manager manager(mp_remoteLibrary);
|
||||||
|
@ -210,6 +210,8 @@ void ContentManagerDelegate::paint(QPainter *painter, const QStyleOptionViewItem
|
|||||||
|
|
||||||
bool ContentManagerDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
|
bool ContentManagerDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(model);
|
||||||
|
|
||||||
if(event->type() == QEvent::MouseButtonRelease )
|
if(event->type() == QEvent::MouseButtonRelease )
|
||||||
{
|
{
|
||||||
QMouseEvent * e = (QMouseEvent *)event;
|
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
|
QSize ContentManagerDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(option);
|
||||||
|
|
||||||
if (index.parent().isValid()) {
|
if (index.parent().isValid()) {
|
||||||
return QSize(300, 70);
|
return QSize(300, 70);
|
||||||
}
|
}
|
||||||
|
@ -41,17 +41,14 @@ KiwixApp::KiwixApp(int& argc, char *argv[])
|
|||||||
QMessageBox::critical(nullptr, "Translation error", e.what());
|
QMessageBox::critical(nullptr, "Translation error", e.what());
|
||||||
return;
|
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/");
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
installTranslator(&m_appTranslator);
|
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/selawkb.ttf");
|
||||||
QFontDatabase::addApplicationFont(":/fonts/Selawik/selawkl.ttf");
|
QFontDatabase::addApplicationFont(":/fonts/Selawik/selawkl.ttf");
|
||||||
@ -61,6 +58,12 @@ KiwixApp::KiwixApp(int& argc, char *argv[])
|
|||||||
setFont(QFont("Selawik"));
|
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()
|
void KiwixApp::init()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -441,10 +444,10 @@ void KiwixApp::createActions()
|
|||||||
mpa_actions[FindInPageAction]->setShortcuts({QKeySequence::Find, Qt::Key_F3});
|
mpa_actions[FindInPageAction]->setShortcuts({QKeySequence::Find, Qt::Key_F3});
|
||||||
connect(mpa_actions[FindInPageAction], &QAction::triggered,
|
connect(mpa_actions[FindInPageAction], &QAction::triggered,
|
||||||
this, [=]() { getTabWidget()->openFindInPageBar(); });
|
this, [=]() { getTabWidget()->openFindInPageBar(); });
|
||||||
|
|
||||||
const auto fullScreenKeySeq = QKeySequence(QKeySequence::FullScreen).isEmpty()
|
const auto fullScreenKeySeq = QKeySequence(QKeySequence::FullScreen).isEmpty()
|
||||||
? Qt::Key_F11
|
? (int) Qt::Key_F11
|
||||||
: QKeySequence::FullScreen;
|
: (int) QKeySequence::FullScreen;
|
||||||
CREATE_ACTION_ICON_SHORTCUT(ToggleFullscreenAction, "full-screen-enter", gt("set-fullscreen"), fullScreenKeySeq);
|
CREATE_ACTION_ICON_SHORTCUT(ToggleFullscreenAction, "full-screen-enter", gt("set-fullscreen"), fullScreenKeySeq);
|
||||||
connect(mpa_actions[ToggleFullscreenAction], &QAction::toggled,
|
connect(mpa_actions[ToggleFullscreenAction], &QAction::toggled,
|
||||||
this, [=](bool checked) {
|
this, [=](bool checked) {
|
||||||
|
@ -123,6 +123,7 @@ private:
|
|||||||
|
|
||||||
QString findLibraryDirectory();
|
QString findLibraryDirectory();
|
||||||
void restoreTabs();
|
void restoreTabs();
|
||||||
|
void loadAndInstallTranslations(QTranslator& translator, const QString& filename, const QString& directory);
|
||||||
};
|
};
|
||||||
|
|
||||||
QString gt(const QString &key);
|
QString gt(const QString &key);
|
||||||
|
@ -16,6 +16,8 @@ void KiwixLineEdit::resizeEvent(QResizeEvent *event)
|
|||||||
}
|
}
|
||||||
bool KiwixLineEdit::eventFilter(QObject* object, QEvent* event)
|
bool KiwixLineEdit::eventFilter(QObject* object, QEvent* event)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(object);
|
||||||
|
|
||||||
if (event->type() == QEvent::MouseButtonPress) {
|
if (event->type() == QEvent::MouseButtonPress) {
|
||||||
emit(clicked());
|
emit(clicked());
|
||||||
} else if (event->type() == QEvent::FocusIn) {
|
} else if (event->type() == QEvent::FocusIn) {
|
||||||
|
@ -41,6 +41,8 @@ void createArc(QPainter &painter, int startAngle, int spanAngle, QRect rectangle
|
|||||||
|
|
||||||
void KiwixLoader::paintEvent(QPaintEvent *event)
|
void KiwixLoader::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(event);
|
||||||
|
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ void Library::updateFromDir(QString monitorDir)
|
|||||||
|
|
||||||
void Library::asyncUpdateFromDir(QString dir)
|
void Library::asyncUpdateFromDir(QString dir)
|
||||||
{
|
{
|
||||||
QtConcurrent::run( [=]() {
|
(void) QtConcurrent::run([=]() {
|
||||||
updateFromDir(dir);
|
updateFromDir(dir);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user