Commit 53a9f566 authored by David Hurka's avatar David Hurka 🐬
Browse files

Presentation config: Replace transitions checkbox by “Instant” item in combobox

parent f69026dd
Pipeline #49694 passed with stage
in 10 minutes and 39 seconds
......@@ -207,6 +207,9 @@
<entry key="SlidesTransition" type="Enum" >
<default>Replace</default>
<choices>
<choice name="NoTransitions" />
<choice name="Replace" />
<choice name="Random" />
<choice name="BlindsHorizontal" />
<choice name="BlindsVertical" />
<choice name="BoxIn" />
......@@ -216,8 +219,6 @@
<choice name="GlitterDown" />
<choice name="GlitterRight" />
<choice name="GlitterRightDown" />
<choice name="Random" />
<choice name="Replace" />
<choice name="SplitHorizontalIn" />
<choice name="SplitHorizontalOut" />
<choice name="SplitVerticalIn" />
......@@ -242,9 +243,6 @@
<entry key="SlidesShowSummary" type="Bool" >
<default>false</default>
</entry>
<entry key="SlidesTransitionsEnabled" type="Bool" >
<default>true</default>
</entry>
<entry key="SlidesScreen" type="Int" >
<default>-2</default>
<min>-2</min>
......
......@@ -98,14 +98,11 @@ DlgPresentation::DlgPresentation(QWidget *parent)
layout->addRow(new QLabel(this));
// BEGIN Transitions section
// Checkbox: Enable transitions
QCheckBox *enableTransitions = new QCheckBox(this);
enableTransitions->setText(i18nc("@option:check Config dialog, presentation page, transitions", "Enable transitions"));
enableTransitions->setObjectName(QStringLiteral("kcfg_SlidesTransitionsEnabled"));
layout->addRow(QString(), enableTransitions);
// Combobox: Default transition
QComboBox *defaultTransition = new QComboBox(this);
defaultTransition->addItem(i18nc("@item:inlistbox Config dialog, presentation page, transitions", "Instant (Never use animations)"));
defaultTransition->addItem(i18nc("@item:inlistbox Config dialog, presentation page, transitions", "Replace"));
defaultTransition->addItem(i18nc("@item:inlistbox Config dialog, presentation page, transitions", "Random transition"));
defaultTransition->addItem(i18nc("@item:inlistbox Config dialog, presentation page, transitions", "Blinds vertical"));
defaultTransition->addItem(i18nc("@item:inlistbox Config dialog, presentation page, transitions", "Blinds horizontal"));
defaultTransition->addItem(i18nc("@item:inlistbox Config dialog, presentation page, transitions", "Box in"));
......@@ -115,8 +112,6 @@ DlgPresentation::DlgPresentation(QWidget *parent)
defaultTransition->addItem(i18nc("@item:inlistbox Config dialog, presentation page, transitions", "Glitter down"));
defaultTransition->addItem(i18nc("@item:inlistbox Config dialog, presentation page, transitions", "Glitter right"));
defaultTransition->addItem(i18nc("@item:inlistbox Config dialog, presentation page, transitions", "Glitter right-down"));
defaultTransition->addItem(i18nc("@item:inlistbox Config dialog, presentation page, transitions", "Random transition"));
defaultTransition->addItem(i18nc("@item:inlistbox Config dialog, presentation page, transitions", "Replace"));
defaultTransition->addItem(i18nc("@item:inlistbox Config dialog, presentation page, transitions", "Split horizontal in"));
defaultTransition->addItem(i18nc("@item:inlistbox Config dialog, presentation page, transitions", "Split horizontal out"));
defaultTransition->addItem(i18nc("@item:inlistbox Config dialog, presentation page, transitions", "Split vertical in"));
......@@ -127,8 +122,6 @@ DlgPresentation::DlgPresentation(QWidget *parent)
defaultTransition->addItem(i18nc("@item:inlistbox Config dialog, presentation page, transitions", "Wipe up"));
defaultTransition->setObjectName(QStringLiteral("kcfg_SlidesTransition"));
layout->addRow(i18nc("@label:listbox Config dialog, presentation page, transitions", "Default transition:"), defaultTransition);
defaultTransition->setEnabled(Okular::Settings::slidesTransitionsEnabled());
connect(enableTransitions, &QCheckBox::toggled, defaultTransition, &QComboBox::setEnabled);
// END Transitions section
layout->addRow(new QLabel(this));
......
......@@ -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
......
......@@ -297,6 +297,15 @@ private:
bool tryOpeningUrlWithFragmentAsName();
/**
* Initializes Okular::Settings.
* Determines the config file path, and performs configuration updates not handled by kconf_update.
*
* @param args As passed to Part::Part().
* @param componentName As KXMLGUIClient::componentName(), probably "okular".
*/
void setupConfigSkeleton(const QVariantList &args, const QString &componentName);
static int numberOfParts;
QTemporaryFile *m_tempfile;
......
......@@ -1046,7 +1046,8 @@ void PresentationWidget::generatePage(bool disableTransition)
#endif
// start transition on pages that have one
if (!disableTransition && Okular::Settings::slidesTransitionsEnabled()) {
disableTransition |= (Okular::Settings::slidesTransition() == Okular::Settings::EnumSlidesTransition::NoTransitions);
if (!disableTransition) {
const Okular::PageTransition *transition = m_frameIndex != -1 ? m_frames[m_frameIndex]->page->transition() : nullptr;
if (transition)
initTransition(transition);
......@@ -1819,6 +1820,7 @@ const Okular::PageTransition PresentationWidget::defaultTransition(int type) con
return Okular::PageTransition(Okular::PageTransition::Fade);
break;
}
case Okular::Settings::EnumSlidesTransition::NoTransitions:
case Okular::Settings::EnumSlidesTransition::Replace:
default:
return Okular::PageTransition(Okular::PageTransition::Replace);
......
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