Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Graphics
Okular
Commits
53a9f566
Commit
53a9f566
authored
Feb 04, 2021
by
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
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
conf/okular.kcfg
View file @
53a9f566
...
...
@@ -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>
...
...
part/dlgpresentation.cpp
View file @
53a9f566
...
...
@@ -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
));
...
...
part/part.cpp
View file @
53a9f566
...
...
@@ -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
...
...
part/part.h
View file @
53a9f566
...
...
@@ -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
;
...
...
part/presentationwidget.cpp
View file @
53a9f566
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment