mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-02 14:14:10 +00:00
Allow to specify which config file the part uses.
This is done through a string "ConfigFileName=<file name>" which can be given to the constructor in its argument list. Note that the file ui/fileinterpreterpreview.cpp currently still contains a reference to "okularrc", which we leave for now (as it just stores the size of a dialog in that config file).
This commit is contained in:
parent
ee7437eb61
commit
b4206819e3
|
@ -3,7 +3,7 @@
|
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
|
||||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
|
||||
<kcfgfile name="okularpartrc" />
|
||||
<kcfgfile arg="true" />
|
||||
<include>kuser.h</include>
|
||||
<group name="Debugging Options" >
|
||||
<entry key="DebugDrawBoundaries" type="Bool" >
|
||||
|
|
36
part.cpp
36
part.cpp
|
@ -227,6 +227,24 @@ static Okular::Part::EmbedMode detectEmbedMode( QWidget *parentWidget, QObject *
|
|||
return Okular::Part::UnknownEmbedMode;
|
||||
}
|
||||
|
||||
static QString detectConfigFileName( const QVariantList &args )
|
||||
{
|
||||
Q_FOREACH ( const QVariant &arg, args )
|
||||
{
|
||||
if ( arg.type() == QVariant::String )
|
||||
{
|
||||
QString argString = arg.toString();
|
||||
int separatorIndex = argString.indexOf( "=" );
|
||||
if ( separatorIndex >= 0 && argString.left( separatorIndex ) == QLatin1String( "ConfigFileName" ) )
|
||||
{
|
||||
return argString.mid( separatorIndex + 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
#undef OKULAR_KEEP_FILE_OPEN
|
||||
|
||||
#ifdef OKULAR_KEEP_FILE_OPEN
|
||||
|
@ -247,14 +265,20 @@ const QVariantList &args )
|
|||
m_tempfile( 0 ), m_fileWasRemoved( false ), m_showMenuBarAction( 0 ), m_showFullScreenAction( 0 ), m_actionsSearched( false ),
|
||||
m_cliPresentation(false), m_embedMode(detectEmbedMode(parentWidget, parent, args)), m_generatorGuiClient(0), m_keeper( 0 )
|
||||
{
|
||||
// first necessary step: copy the configuration from kpdf, if available
|
||||
QString newokularconffile = KStandardDirs::locateLocal( "config", "okularpartrc" );
|
||||
if ( !QFile::exists( newokularconffile ) )
|
||||
// first, we check if a config file name has been specified
|
||||
QString configFileName = detectConfigFileName( args );
|
||||
if( configFileName.isEmpty())
|
||||
{
|
||||
QString oldkpdfconffile = KStandardDirs::locateLocal( "config", "kpdfpartrc" );
|
||||
if ( QFile::exists( oldkpdfconffile ) )
|
||||
QFile::copy( oldkpdfconffile, newokularconffile );
|
||||
configFileName = KStandardDirs::locateLocal( "config", "okularpartrc" );
|
||||
// first necessary step: copy the configuration from kpdf, if available
|
||||
if ( !QFile::exists( configFileName ) )
|
||||
{
|
||||
QString oldkpdfconffile = KStandardDirs::locateLocal( "config", "kpdfpartrc" );
|
||||
if ( QFile::exists( oldkpdfconffile ) )
|
||||
QFile::copy( oldkpdfconffile, configFileName );
|
||||
}
|
||||
}
|
||||
Okular::Settings::instance( configFileName );
|
||||
|
||||
QDBusConnection::sessionBus().registerObject("/okular", this, QDBusConnection::ExportScriptableSlots);
|
||||
|
||||
|
|
6
part.h
6
part.h
|
@ -90,6 +90,12 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
|
|||
};
|
||||
|
||||
// Default constructor
|
||||
/**
|
||||
* If one element of 'args' contains one of the strings "Print/Preview" or "ViewerWidget",
|
||||
* the part will be set up in the corresponding mode. Additionally, it is possible to specify
|
||||
* which config file should be used by adding a string containing "ConfigFileName=<file name>"
|
||||
* to 'args'.
|
||||
**/
|
||||
Part(QWidget* parentWidget, QObject* parent, const QVariantList& args);
|
||||
|
||||
// Destructor
|
||||
|
|
Loading…
Reference in a new issue