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
remotes/origin/Applications/18.08
Michael Eden 8 years ago committed by Albert Astals Cid
parent 862b2ab664
commit 031b794ec8
  1. 9
      part.cpp
  2. 2
      part.h
  3. 9
      ui/pageview.cpp
  4. 4
      ui/pageview.h

@ -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()
{

@ -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();

@ -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;

@ -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();
};

Loading…
Cancel
Save