void Backbone::init() {
_interval = 250; //msec
-
- _configPath = QDir::homePath() + "/.mdictionary/mdictionary.config";
- _defaultConfigPath = QDir::homePath() + "/.mdictionary/mdictionary.defaults";
- _pluginPath = "/usr/lib/mdictionary";
+ dryRun = false;
+
+ if(!_configPath.size())
+ _configPath = QDir::homePath() + "/.mdictionary/mdictionary.config";
+ if(!_defaultConfigPath.size())
+ _defaultConfigPath = QDir::homePath() + "/.mdictionary/mdictionary.defaults";
+ if(!_pluginPath.size())
+ _pluginPath = "/usr/lib/mdictionary";
_historyLen = 10;
_searchLimit = 15;
Backbone::Backbone(QString pluginPath, QString configPath, QObject *parent)
: QObject(parent)
{
+ init();
+ dryRun = true;
_pluginPath = pluginPath;
_configPath = configPath;
- init();
+ _defaultConfigPath = configPath;
}
void Backbone::loadPlugins() {
+ if(dryRun)
+ return;
QStringList nameFilter;
nameFilter << "*.so";
QStringList files = getFilesFromDir(_pluginPath, nameFilter);
void Backbone::loadPrefs(QString fileName) {
+ if(dryRun)
+ return;
QFileInfo file(QDir::toNativeSeparators(fileName));
QDir confDir(file.dir());
if(!confDir.exists()){
void Backbone::savePrefs(QSettings *set) {
+ if(dryRun)
+ return;
set->setValue("general/plugin_path", _pluginPath);
set->setValue("general/history_length", _historyLen);
set->setValue("general/search_limit", _searchLimit);
void Backbone::saveDefaultPrefs(QSettings *set) {
+ if(dryRun)
+ return;
set->setValue("general/plugin_path", _defaultPluginPath);
set->setValue("general/history_length", _defaultHistoryLen);
set->setValue("general/search_limit", _defaultSearchLimit);
void Backbone::loadDicts(QString fileName, bool _default) {
+ if(dryRun)
+ return;
QFileInfo file(QDir::toNativeSeparators(fileName));
qDebug() << file.filePath();
QDir confDir(file.dir());
void Backbone::dictUpdated() {
+ if(dryRun)
+ return;
QFileInfo file(QDir::toNativeSeparators(_configPath));
QDir confDir(file.dir());
if(!confDir.exists())
savePrefs(&set);
saveDefaultPrefs(&defSet);
- foreach(CommonDictInterface* dict, _dicts.keys())
+ foreach(CommonDictInterface* dict, _dicts.keys()){
+ if(!dict || !dict->settings())
+ continue;
if(!dict->settings()->keys().contains("_default_"))
saveState(&set, dict->settings(), _dicts[dict], dict->hash());
else
saveState(&defSet, dict->settings(), _dicts[dict], dict->hash());
+ }
}
void Backbone::saveState(QSettings* set, Settings* plugSet, bool active
, uint hash) {
+ if(dryRun)
+ return;
if(!set || !plugSet)
return;
QString section;