|
|
|
|
@ -304,49 +304,7 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList &args) |
|
|
|
|
// when this part is used in an application other than okular (e.g. unit tests)
|
|
|
|
|
setComponentName(QStringLiteral("okular"), QString()); |
|
|
|
|
|
|
|
|
|
const QLatin1String configFileName("okularpartrc"); |
|
|
|
|
|
|
|
|
|
// first, we check if a config file name has been specified
|
|
|
|
|
QString configFilePath = detectConfigFileName(args); |
|
|
|
|
|
|
|
|
|
if (configFilePath.isEmpty()) { |
|
|
|
|
configFilePath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QLatin1Char('/') + configFileName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Migrate old config
|
|
|
|
|
if (!QFile::exists(configFilePath)) { |
|
|
|
|
qCDebug(OkularUiDebug) << "Did not find a config file, attempting to look for old config"; |
|
|
|
|
|
|
|
|
|
// Migrate old config + UI
|
|
|
|
|
Kdelibs4ConfigMigrator configMigrator(componentName()); |
|
|
|
|
// UI file is handled automatically, we only need to specify config name because we're a part
|
|
|
|
|
configMigrator.setConfigFiles(QStringList(configFileName)); |
|
|
|
|
|
|
|
|
|
// If there's no old okular config to migrate, look for kpdf
|
|
|
|
|
if (!configMigrator.migrate()) { |
|
|
|
|
qCDebug(OkularUiDebug) << "Did not find an old okular config file, attempting to look for kpdf config"; |
|
|
|
|
|
|
|
|
|
// First try the automatic detection, using $KDEHOME etc.
|
|
|
|
|
Kdelibs4Migration migration; |
|
|
|
|
QString kpdfConfig = migration.locateLocal("config", QStringLiteral("kpdfpartrc")); |
|
|
|
|
|
|
|
|
|
// Fallback just in case it tried e. g. ~/.kde4
|
|
|
|
|
if (kpdfConfig.isEmpty()) { |
|
|
|
|
kpdfConfig = QDir::homePath() + QStringLiteral("/.kde/share/config/kpdfpartrc"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (QFile::exists(kpdfConfig)) { |
|
|
|
|
qCDebug(OkularUiDebug) << "Found old kpdf config" << kpdfConfig << "copying to" << configFilePath; |
|
|
|
|
QFile::copy(kpdfConfig, configFilePath); |
|
|
|
|
} else { |
|
|
|
|
qCDebug(OkularUiDebug) << "Did not find an old kpdf config file"; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
qCDebug(OkularUiDebug) << "Migrated old okular config"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Okular::Settings::instance(configFilePath); |
|
|
|
|
setupConfigSkeleton(args, componentName()); |
|
|
|
|
|
|
|
|
|
#if KXMLGUI_VERSION < QT_VERSION_CHECK(5, 78, 0) // TODO KF6: Remove this section and part/xmlgui_helper.{cpp,h}.
|
|
|
|
|
// In KXMLGUI 5.78, https://invent.kde.org/frameworks/kxmlgui/-/merge_requests/5
|
|
|
|
|
@ -634,6 +592,64 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList &args) |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Part::setupConfigSkeleton(const QVariantList &args, const QString &componentName) |
|
|
|
|
{ |
|
|
|
|
const QLatin1String configFileName("okularpartrc"); |
|
|
|
|
|
|
|
|
|
// first, we check if a config file name has been specified
|
|
|
|
|
QString configFilePath = detectConfigFileName(args); |
|
|
|
|
|
|
|
|
|
if (configFilePath.isEmpty()) { |
|
|
|
|
configFilePath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QLatin1Char('/') + configFileName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Migrate old config
|
|
|
|
|
if (!QFile::exists(configFilePath)) { |
|
|
|
|
qCDebug(OkularUiDebug) << "Did not find a config file, attempting to look for old config"; |
|
|
|
|
|
|
|
|
|
// Migrate old config + UI
|
|
|
|
|
Kdelibs4ConfigMigrator configMigrator(componentName); |
|
|
|
|
// UI file is handled automatically, we only need to specify config name because we're a part
|
|
|
|
|
configMigrator.setConfigFiles(QStringList(configFileName)); |
|
|
|
|
|
|
|
|
|
// If there's no old okular config to migrate, look for kpdf
|
|
|
|
|
if (!configMigrator.migrate()) { |
|
|
|
|
qCDebug(OkularUiDebug) << "Did not find an old okular config file, attempting to look for kpdf config"; |
|
|
|
|
|
|
|
|
|
// First try the automatic detection, using $KDEHOME etc.
|
|
|
|
|
Kdelibs4Migration migration; |
|
|
|
|
QString kpdfConfig = migration.locateLocal("config", QStringLiteral("kpdfpartrc")); |
|
|
|
|
|
|
|
|
|
// Fallback just in case it tried e. g. ~/.kde4
|
|
|
|
|
if (kpdfConfig.isEmpty()) { |
|
|
|
|
kpdfConfig = QDir::homePath() + QStringLiteral("/.kde/share/config/kpdfpartrc"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (QFile::exists(kpdfConfig)) { |
|
|
|
|
qCDebug(OkularUiDebug) << "Found old kpdf config" << kpdfConfig << "copying to" << configFilePath; |
|
|
|
|
QFile::copy(kpdfConfig, configFilePath); |
|
|
|
|
} else { |
|
|
|
|
qCDebug(OkularUiDebug) << "Did not find an old kpdf config file"; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
qCDebug(OkularUiDebug) << "Migrated old okular config"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
KSharedConfigPtr config = KSharedConfig::openConfig(configFilePath); |
|
|
|
|
|
|
|
|
|
// Configuration update: SlidesTransitionsEnabled -> SlidesTransition = NoTransitions.
|
|
|
|
|
// See https://invent.kde.org/graphics/okular/-/merge_requests/357
|
|
|
|
|
KConfigGroup slidesConfigGroup = config.data()->group("Dlg Presentation"); |
|
|
|
|
if (slidesConfigGroup.readEntry<bool>("SlidesTransitionsEnabled", true) == false) { |
|
|
|
|
slidesConfigGroup.writeEntry("SlidesTransition", "NoTransitions"); |
|
|
|
|
} |
|
|
|
|
slidesConfigGroup.deleteEntry("SlidesTransitionsEnabled"); |
|
|
|
|
config.data()->sync(); |
|
|
|
|
|
|
|
|
|
Okular::Settings::instance(config); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Part::setupViewerActions() |
|
|
|
|
{ |
|
|
|
|
// ACTIONS
|
|
|
|
|
|