From 031b794ec83014fbcdac9ffc69f6cde6ddc5b26b Mon Sep 17 00:00:00 2001 From: Michael Eden Date: Tue, 26 Jun 2018 13:05:25 +0200 Subject: [PATCH] Expose 'change colors' through dbus interface Summary: This exposes the Okular's functionality of changing the document's colors through its d-bus interface. This is mainly useful for scripting Okular to switch to a 'day mode' or 'night mode'. [Example] Switching themes of two applications with one hotkey: {F5905771} Reviewers: #okular, aacid Reviewed By: #okular, aacid Subscribers: okular-devel Tags: #okular Differential Revision: https://phabricator.kde.org/D13471 --- part.cpp | 9 +++++++++ part.h | 2 ++ ui/pageview.cpp | 9 +++++++-- ui/pageview.h | 4 +++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/part.cpp b/part.cpp index 3baa4a9f6..3f95ea54e 100644 --- a/part.cpp +++ b/part.cpp @@ -2848,6 +2848,15 @@ void Part::slotPreferences() dialog->show(); } +void Part::slotToggleChangeColors() +{ + m_pageView->slotToggleChangeColors(); +} + +void Part::slotSetChangeColors(bool active) +{ + m_pageView->slotSetChangeColors(active); +} void Part::slotAnnotationPreferences() { diff --git a/part.h b/part.h index 1d7d52ae0..798330fd0 100644 --- a/part.h +++ b/part.h @@ -163,6 +163,8 @@ class OKULARPART_EXPORT Part : public KParts::ReadWritePart, public Okular::Docu Q_SCRIPTABLE void slotGotoFirst(); Q_SCRIPTABLE void slotGotoLast(); Q_SCRIPTABLE void slotTogglePresentation(); + Q_SCRIPTABLE void slotToggleChangeColors(); + Q_SCRIPTABLE void slotSetChangeColors(bool active); Q_SCRIPTABLE Q_NOREPLY void reload(); Q_SCRIPTABLE Q_NOREPLY void enableStartWithPrint(); Q_SCRIPTABLE Q_NOREPLY void enableExitAfterPrint(); diff --git a/ui/pageview.cpp b/ui/pageview.cpp index 16d99d2ed..61356abc7 100644 --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -5498,13 +5498,18 @@ void PageView::slotProcessRenditionAction( const Okular::RenditionAction *action }; } -void PageView::slotToggleChangeColors() +void PageView::slotSetChangeColors(bool active) { - Okular::SettingsCore::setChangeColors( !Okular::SettingsCore::changeColors() ); + Okular::SettingsCore::setChangeColors(active); Okular::Settings::self()->save(); viewport()->update(); } +void PageView::slotToggleChangeColors() +{ + slotSetChangeColors( !Okular::SettingsCore::changeColors() ); +} + void PageView::slotFitWindowToPage() { PageViewItem currentPageItem = nullptr; diff --git a/ui/pageview.h b/ui/pageview.h index d0d015ba7..a207c445f 100644 --- a/ui/pageview.h +++ b/ui/pageview.h @@ -124,6 +124,9 @@ Q_OBJECT void openAnnotationWindow( Okular::Annotation *annotation, int pageNumber ); void reloadForms(); + void slotToggleChangeColors(); + void slotSetChangeColors(bool active); + Q_SIGNALS: void rightClick( const Okular::Page *, const QPoint & ); void mouseBackButtonClick(); @@ -269,7 +272,6 @@ Q_OBJECT void slotAnnotationWindowDestroyed( QObject *window ); void slotProcessMovieAction( const Okular::MovieAction *action ); void slotProcessRenditionAction( const Okular::RenditionAction *action ); - void slotToggleChangeColors(); void slotFitWindowToPage(); };