Commit b4206819 authored by Michel Ludwig's avatar Michel Ludwig

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).
parent ee7437eb
......@@ -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" >
......
......@@ -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);
......
......@@ -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
......
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