mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
generic: adjust to Katie changes
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
ef262ab3bd
commit
6d0274d417
6 changed files with 45 additions and 45 deletions
|
@ -27,8 +27,6 @@
|
||||||
#include <QMetaProperty>
|
#include <QMetaProperty>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
static const QSettings::Format defaultformat = QSettings::IniFormat;
|
|
||||||
|
|
||||||
static QString getSettingsPath(const QString &filename)
|
static QString getSettingsPath(const QString &filename)
|
||||||
{
|
{
|
||||||
const QFileInfo info(filename);
|
const QFileInfo info(filename);
|
||||||
|
@ -39,7 +37,7 @@ static QString getSettingsPath(const QString &filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
KSettings::KSettings(const QString& file, const OpenFlags mode)
|
KSettings::KSettings(const QString& file, const OpenFlags mode)
|
||||||
: QSettings(getSettingsPath(file), defaultformat)
|
: QSettings(getSettingsPath(file))
|
||||||
{
|
{
|
||||||
if ((mode & IncludeGlobals) != mode) {
|
if ((mode & IncludeGlobals) != mode) {
|
||||||
addSource(KStandardDirs::locateLocal("config", QLatin1String("kdeglobals")));
|
addSource(KStandardDirs::locateLocal("config", QLatin1String("kdeglobals")));
|
||||||
|
@ -48,10 +46,10 @@ KSettings::KSettings(const QString& file, const OpenFlags mode)
|
||||||
|
|
||||||
void KSettings::addSource(const QString &source)
|
void KSettings::addSource(const QString &source)
|
||||||
{
|
{
|
||||||
QSettings settings(source, defaultformat);
|
QSettings settings(source);
|
||||||
foreach (const QString &key, settings.keys()) {
|
foreach (const QString &key, settings.keys()) {
|
||||||
if (!QSettings::contains(key)) {
|
if (!QSettings::contains(key)) {
|
||||||
QSettings::setValue(key, settings.value(key));
|
QSettings::setString(key, settings.string(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,11 +80,13 @@ bool KSettings::save(const QObject *object)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const QVariant propertyvalue = property.read(widget);
|
const QVariant propertyvalue = property.read(widget);
|
||||||
if (propertyvalue.isValid()) {
|
if (!propertyvalue.canConvert<QString>()) {
|
||||||
kDebug() << "saving property" << propertyname << "with value" << propertyvalue << "of" << objectname;
|
kWarning() << "property value not QString-convertable" << propertyname << propertyvalue;
|
||||||
QSettings::setValue(objectname + QLatin1Char('/') + propertyname, propertyvalue);
|
} else if (!propertyvalue.isValid()) {
|
||||||
} else {
|
|
||||||
kWarning() << "invalid property value" << propertyname << propertyvalue;
|
kWarning() << "invalid property value" << propertyname << propertyvalue;
|
||||||
|
} else {
|
||||||
|
kDebug() << "saving property" << propertyname << "with value" << propertyvalue << "of" << objectname;
|
||||||
|
QSettings::setString(objectname + QLatin1Char('/') + propertyname, propertyvalue.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ bool KSettings::restore(QObject *object)
|
||||||
kDebug() << "skipping non-writable property" << propertyname << "of" << objectname;
|
kDebug() << "skipping non-writable property" << propertyname << "of" << objectname;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const QVariant propertyvalue = QSettings::value(objectname + QLatin1Char('/') + propertyname, property.read(widget));
|
const QVariant propertyvalue = QSettings::string(objectname + QLatin1Char('/') + propertyname, property.read(widget).toString());
|
||||||
if (propertyvalue.isValid()) {
|
if (propertyvalue.isValid()) {
|
||||||
kDebug() << "restoring property" << propertyname << "with value" << propertyvalue << "of" << objectname;
|
kDebug() << "restoring property" << propertyname << "with value" << propertyvalue << "of" << objectname;
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
|
@ -111,34 +111,34 @@ public:
|
||||||
CfgConfig( const QString &codegenFilename )
|
CfgConfig( const QString &codegenFilename )
|
||||||
{
|
{
|
||||||
// Configure the compiler with some settings
|
// Configure the compiler with some settings
|
||||||
QSettings codegenConfig(codegenFilename, QSettings::IniFormat);
|
QSettings codegenConfig(codegenFilename);
|
||||||
|
|
||||||
nameSpace = codegenConfig.value("NameSpace").toString();
|
nameSpace = codegenConfig.string("NameSpace");
|
||||||
className = codegenConfig.value("ClassName").toString();
|
className = codegenConfig.string("ClassName");
|
||||||
if ( className.isEmpty() ) {
|
if ( className.isEmpty() ) {
|
||||||
cerr << "Class name missing" << endl;
|
cerr << "Class name missing" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
inherits = codegenConfig.value("Inherits").toString();
|
inherits = codegenConfig.string("Inherits");
|
||||||
if ( inherits.isEmpty() ) inherits = "KConfigSkeleton";
|
if ( inherits.isEmpty() ) inherits = "KConfigSkeleton";
|
||||||
visibility = codegenConfig.value("Visibility").toString();
|
visibility = codegenConfig.string("Visibility");
|
||||||
if ( !visibility.isEmpty() ) visibility += ' ';
|
if ( !visibility.isEmpty() ) visibility += ' ';
|
||||||
forceStringFilename = codegenConfig.value("ForceStringFilename", false).toBool();
|
forceStringFilename = codegenConfig.boolean("ForceStringFilename", false);
|
||||||
singleton = codegenConfig.value("Singleton", false).toBool();
|
singleton = codegenConfig.boolean("Singleton", false);
|
||||||
staticAccessors = singleton;
|
staticAccessors = singleton;
|
||||||
customAddons = codegenConfig.value("CustomAdditions", false).toBool();
|
customAddons = codegenConfig.boolean("CustomAdditions", false);
|
||||||
memberVariables = codegenConfig.value("MemberVariables").toString();
|
memberVariables = codegenConfig.string("MemberVariables");
|
||||||
dpointer = (memberVariables == "dpointer");
|
dpointer = (memberVariables == "dpointer");
|
||||||
headerIncludes = codegenConfig.value("IncludeFiles", QStringList()).toStringList();
|
headerIncludes = codegenConfig.stringList("IncludeFiles", QStringList());
|
||||||
sourceIncludes = codegenConfig.value("SourceIncludeFiles", QStringList()).toStringList();
|
sourceIncludes = codegenConfig.stringList("SourceIncludeFiles", QStringList());
|
||||||
mutators = codegenConfig.value("Mutators", QStringList()).toStringList();
|
mutators = codegenConfig.stringList("Mutators", QStringList());
|
||||||
allMutators = ((mutators.count() == 1) && (mutators.at(0).toLower() == "true"));
|
allMutators = ((mutators.count() == 1) && (mutators.at(0).toLower() == "true"));
|
||||||
itemAccessors = codegenConfig.value("ItemAccessors", false).toBool();
|
itemAccessors = codegenConfig.boolean("ItemAccessors", false);
|
||||||
setUserTexts = codegenConfig.value("SetUserTexts", false).toBool();
|
setUserTexts = codegenConfig.boolean("SetUserTexts", false);
|
||||||
defaultGetters = codegenConfig.value("DefaultValueGetters", QStringList()).toStringList();
|
defaultGetters = codegenConfig.stringList("DefaultValueGetters", QStringList());
|
||||||
allDefaultGetters = (defaultGetters.count() == 1) && (defaultGetters.at(0).toLower() == "true");
|
allDefaultGetters = (defaultGetters.count() == 1) && (defaultGetters.at(0).toLower() == "true");
|
||||||
globalEnums = codegenConfig.value("GlobalEnums", false).toBool();
|
globalEnums = codegenConfig.boolean("GlobalEnums", false);
|
||||||
useEnumTypes = codegenConfig.value("UseEnumTypes", false).toBool();
|
useEnumTypes = codegenConfig.boolean("UseEnumTypes", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -46,7 +46,7 @@ KFilePlacesItem::KFilePlacesItem(const KBookmark &bookmark,
|
||||||
} else if (udi.isEmpty() && m_bookmark.url() == KUrl("trash:/")) {
|
} else if (udi.isEmpty() && m_bookmark.url() == KUrl("trash:/")) {
|
||||||
KDirWatch::self()->addFile(KStandardDirs::locateLocal("config", "trashrc"));
|
KDirWatch::self()->addFile(KStandardDirs::locateLocal("config", "trashrc"));
|
||||||
KSettings trashConfig("trashrc", KSettings::SimpleConfig);
|
KSettings trashConfig("trashrc", KSettings::SimpleConfig);
|
||||||
m_trashIsEmpty = trashConfig.value("Status/Empty", true).toBool();
|
m_trashIsEmpty = trashConfig.boolean("Status/Empty", true);
|
||||||
connect(KDirWatch::self(), SIGNAL(dirty(QString)),
|
connect(KDirWatch::self(), SIGNAL(dirty(QString)),
|
||||||
this, SLOT(trashConfigChanged(QString)));
|
this, SLOT(trashConfigChanged(QString)));
|
||||||
} else if (!udi.isEmpty() && m_device.isValid()) {
|
} else if (!udi.isEmpty() && m_device.isValid()) {
|
||||||
|
@ -298,7 +298,7 @@ void KFilePlacesItem::trashConfigChanged(const QString &config)
|
||||||
{
|
{
|
||||||
Q_UNUSED(config);
|
Q_UNUSED(config);
|
||||||
KSettings trashConfig("trashrc", KSettings::SimpleConfig);
|
KSettings trashConfig("trashrc", KSettings::SimpleConfig);
|
||||||
m_trashIsEmpty = trashConfig.value("Status/Empty", true).toBool();
|
m_trashIsEmpty = trashConfig.boolean("Status/Empty", true);
|
||||||
emit itemChanged(id());
|
emit itemChanged(id());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -578,7 +578,7 @@ void KFilePlacesView::contextMenuEvent(QContextMenuEvent *event)
|
||||||
if (placesModel->url(index) == KUrl("trash:/")) {
|
if (placesModel->url(index) == KUrl("trash:/")) {
|
||||||
emptyTrash = menu.addAction(KIcon("trash-empty"), i18nc("@action:inmenu", "Empty Trash"));
|
emptyTrash = menu.addAction(KIcon("trash-empty"), i18nc("@action:inmenu", "Empty Trash"));
|
||||||
KSettings trashConfig("trashrc", KSettings::SimpleConfig);
|
KSettings trashConfig("trashrc", KSettings::SimpleConfig);
|
||||||
emptyTrash->setEnabled(!trashConfig.value("Status/Empty", true).toBool());
|
emptyTrash->setEnabled(!trashConfig.boolean("Status/Empty", true));
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
}
|
}
|
||||||
add = menu.addAction(KIcon("document-new"), i18n("Add Entry..."));
|
add = menu.addAction(KIcon("document-new"), i18n("Add Entry..."));
|
||||||
|
|
|
@ -37,18 +37,18 @@
|
||||||
*/
|
*/
|
||||||
#define COMMON_STATE_LOAD \
|
#define COMMON_STATE_LOAD \
|
||||||
d->m_settings->sync(); \
|
d->m_settings->sync(); \
|
||||||
const QString globalaudio = d->m_settings->value("global/audiooutput", "auto").toString(); \
|
const QString globalaudio = d->m_settings->string("global/audiooutput", "auto"); \
|
||||||
const int globalvolume = d->m_settings->value("global/volume", 90).toInt(); \
|
const int globalvolume = d->m_settings->integer("global/volume", 90); \
|
||||||
const bool globalmute = d->m_settings->value("global/mute", false).toBool(); \
|
const bool globalmute = d->m_settings->boolean("global/mute", false); \
|
||||||
setAudioOutput(d->m_settings->value(d->m_playerid + "/audiooutput", globalaudio).toString()); \
|
setAudioOutput(d->m_settings->string(d->m_playerid + "/audiooutput", globalaudio)); \
|
||||||
setVolume(d->m_settings->value(d->m_playerid + "/volume", globalvolume).toInt()); \
|
setVolume(int(d->m_settings->integer(d->m_playerid + "/volume", globalvolume))); \
|
||||||
setMute(d->m_settings->value(d->m_playerid + "/mute", globalmute).toBool());
|
setMute(d->m_settings->boolean(d->m_playerid + "/mute", globalmute));
|
||||||
|
|
||||||
#define COMMON_STATE_SAVE \
|
#define COMMON_STATE_SAVE \
|
||||||
if (d->m_handle && d->m_settings && d->m_settings->isWritable()) { \
|
if (d->m_handle && d->m_settings && d->m_settings->isWritable()) { \
|
||||||
d->m_settings->setValue(d->m_playerid + "/audiooutput", audiooutput()); \
|
d->m_settings->setString(d->m_playerid + "/audiooutput", audiooutput()); \
|
||||||
d->m_settings->setValue(d->m_playerid + "/volume", int(volume())); \
|
d->m_settings->setInteger(d->m_playerid + "/volume", int(volume())); \
|
||||||
d->m_settings->setValue(d->m_playerid + "/mute", mute()); \
|
d->m_settings->setBoolean(d->m_playerid + "/mute", mute()); \
|
||||||
d->m_settings->sync(); \
|
d->m_settings->sync(); \
|
||||||
} else { \
|
} else { \
|
||||||
kWarning() << "Could not save state"; \
|
kWarning() << "Could not save state"; \
|
||||||
|
|
|
@ -79,8 +79,8 @@ KPasswdStoreImpl::KPasswdStoreImpl(const QString &id)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
KSettings ksettings("kpasswdstorerc", KSettings::SimpleConfig);
|
KSettings ksettings("kpasswdstorerc", KSettings::SimpleConfig);
|
||||||
m_retries = ksettings.value("KPasswdStore/Retries", kpasswdstore_passretries).toUInt();
|
m_retries = ksettings.integer("KPasswdStore/Retries", kpasswdstore_passretries);
|
||||||
m_timeout = (ksettings.value("KPasswdStore/Timeout", kpasswdstore_passtimeout).toUInt() * 60000);
|
m_timeout = (ksettings.integer("KPasswdStore/Timeout", kpasswdstore_passtimeout) * 60000);
|
||||||
}
|
}
|
||||||
|
|
||||||
KPasswdStoreImpl::~KPasswdStoreImpl()
|
KPasswdStoreImpl::~KPasswdStoreImpl()
|
||||||
|
@ -146,7 +146,7 @@ QString KPasswdStoreImpl::getPasswd(const QByteArray &key, const qlonglong windo
|
||||||
QString storekey = m_storeid;
|
QString storekey = m_storeid;
|
||||||
storekey.append(QLatin1Char('/'));
|
storekey.append(QLatin1Char('/'));
|
||||||
storekey.append(QString::fromLatin1(key.constData(), key.size()));
|
storekey.append(QString::fromLatin1(key.constData(), key.size()));
|
||||||
const QString passwd = ksettings.value(storekey).toString();
|
const QString passwd = ksettings.string(storekey);
|
||||||
if (passwd.isEmpty()) {
|
if (passwd.isEmpty()) {
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ bool KPasswdStoreImpl::storePasswd(const QByteArray &key, const QString &passwd,
|
||||||
QString storekey = m_storeid;
|
QString storekey = m_storeid;
|
||||||
storekey.append(QLatin1Char('/'));
|
storekey.append(QLatin1Char('/'));
|
||||||
storekey.append(QString::fromLatin1(key.constData(), key.size()));
|
storekey.append(QString::fromLatin1(key.constData(), key.size()));
|
||||||
ksettings.setValue(storekey, encryptPasswd(passwd, &ok));
|
ksettings.setString(storekey, encryptPasswd(passwd, &ok));
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ bool KPasswdStoreImpl::ensurePasswd(const qlonglong windowid, const bool showerr
|
||||||
KSettings ksettings(m_passwdstore, KSettings::SimpleConfig);
|
KSettings ksettings(m_passwdstore, KSettings::SimpleConfig);
|
||||||
QString storekey = QString::fromLatin1("KPasswdStore/");
|
QString storekey = QString::fromLatin1("KPasswdStore/");
|
||||||
storekey.append(m_storeid);
|
storekey.append(m_storeid);
|
||||||
const QString storepasswdhash = ksettings.value(storekey).toString();
|
const QString storepasswdhash = ksettings.string(storekey);
|
||||||
if (storepasswdhash.isEmpty()) {
|
if (storepasswdhash.isEmpty()) {
|
||||||
KNewPasswordDialog knewpasswddialog(widgetForWindowID(windowid));
|
KNewPasswordDialog knewpasswddialog(widgetForWindowID(windowid));
|
||||||
knewpasswddialog.setPrompt(i18n("Enter a password for <b>%1</b> password storage", m_storeid));
|
knewpasswddialog.setPrompt(i18n("Enter a password for <b>%1</b> password storage", m_storeid));
|
||||||
|
@ -243,7 +243,7 @@ bool KPasswdStoreImpl::ensurePasswd(const qlonglong windowid, const bool showerr
|
||||||
}
|
}
|
||||||
|
|
||||||
if (storepasswdhash.isEmpty()) {
|
if (storepasswdhash.isEmpty()) {
|
||||||
ksettings.setValue(storekey, passhash);
|
ksettings.setString(storekey, passhash);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (passhash != storepasswdhash) {
|
if (passhash != storepasswdhash) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue