Use KXMLGUIClient::findVersionNumber if using new enough xmlgui

instead of the code we copied from there
remotes/origin/work/aacid/use_mimes_open_dialog
Albert Astals Cid 6 years ago
parent 5432541dfa
commit 9dcb5bc36b
  1. 14
      xmlgui_helper.cpp

@ -9,9 +9,17 @@
#include "xmlgui_helper.h"
#include "kxmlgui_version.h"
#if KXMLGUI_VERSION >= QT_VERSION_CHECK(5, 73, 0)
#include <KXMLGUIClient>
#endif
#include <QDebug>
#include <QFile>
#if KXMLGUI_VERSION < QT_VERSION_CHECK(5, 73, 0)
// Copied from KXmlGuiVersionHandler::findVersionNumber :/
static QString findVersionNumber(const QString &xml)
{
@ -85,6 +93,8 @@ static QString findVersionNumber(const QString &xml)
return QString();
}
#endif
namespace Okular
{
void removeRCFileIfVersionSmallerThan(const QString &filePath, int version)
@ -93,7 +103,11 @@ void removeRCFileIfVersionSmallerThan(const QString &filePath, int version)
if (f.open(QIODevice::ReadOnly)) {
const QByteArray contents = f.readAll();
f.close();
#if KXMLGUI_VERSION < QT_VERSION_CHECK(5, 73, 0)
const QString fileVersion = findVersionNumber(contents);
#else
const QString fileVersion = KXMLGUIClient::findVersionNumber(contents);
#endif
if (fileVersion.toInt() < version) {
QFile::remove(filePath);
}

Loading…
Cancel
Save