diff options
author | David Faure <faure@kde.org> | 2013-12-18 09:53:59 +0100 |
---|---|---|
committer | David Faure <faure@kde.org> | 2013-12-18 09:53:59 +0100 |
commit | 159963832457e6307282308455330acc7b5bd153 (patch) | |
tree | ce1cc0234d37e9afc75bc86d734beb963ed57d02 /src/gui | |
parent | 867e7a50e6396338ab4fe9aa22ad141e4cd344d2 (diff) | |
download | kconfig-159963832457e6307282308455330acc7b5bd153.tar.gz kconfig-159963832457e6307282308455330acc7b5bd153.tar.bz2 |
Code reformatted using kde-dev-scripts/astyle-kdelibs.
Use git blame -w 867e7a5 to show authorship as it was before this commit.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kconfiggroupgui.cpp | 33 | ||||
-rw-r--r-- | src/gui/kconfiggui.cpp | 9 | ||||
-rw-r--r-- | src/gui/kconfiggui.h | 46 | ||||
-rw-r--r-- | src/gui/kconfigloader.cpp | 34 | ||||
-rw-r--r-- | src/gui/kconfigloader.h | 2 | ||||
-rw-r--r-- | src/gui/kconfigloader_p.h | 385 | ||||
-rw-r--r-- | src/gui/kconfigskeleton.cpp | 88 | ||||
-rw-r--r-- | src/gui/kconfigskeleton.h | 183 | ||||
-rw-r--r-- | src/gui/kstandardshortcut.cpp | 485 | ||||
-rw-r--r-- | src/gui/kstandardshortcut.h | 765 | ||||
-rw-r--r-- | src/gui/kwindowconfig.cpp | 29 | ||||
-rw-r--r-- | src/gui/kwindowconfig.h | 48 |
12 files changed, 1131 insertions, 976 deletions
diff --git a/src/gui/kconfiggroupgui.cpp b/src/gui/kconfiggroupgui.cpp index 22706e77..fc0a55b1 100644 --- a/src/gui/kconfiggroupgui.cpp +++ b/src/gui/kconfiggroupgui.cpp @@ -35,7 +35,7 @@ * @returns true if something was handled (even if output was set to clear or default) * or false if nothing was handled (e.g., Core type) */ -static bool readEntryGui(const QByteArray& data, const char* key, const QVariant &input, +static bool readEntryGui(const QByteArray &data, const char *key, const QVariant &input, QVariant &output) { const QString errString = QString::fromLatin1("\"%1\" - conversion from \"%3\" to %2 failed") @@ -60,8 +60,9 @@ static bool readEntryGui(const QByteArray& data, const char* key, const QVariant } else if (!data.contains(',')) { QColor col; col.setNamedColor(QString::fromUtf8(data.constData(), data.length())); - if (!col.isValid()) + if (!col.isValid()) { qCritical() << qPrintable(errString); + } output = col; return true; } else { @@ -75,7 +76,7 @@ static bool readEntryGui(const QByteArray& data, const char* key, const QVariant int temp[4]; // bounds check components - for(int i = 0; i < count; i++) { + for (int i = 0; i < count; i++) { bool ok; const int j = temp[i] = list.at(i).toInt(&ok); if (!ok) { // failed to convert to int @@ -88,28 +89,31 @@ static bool readEntryGui(const QByteArray& data, const char* key, const QVariant }; const QString boundsError = QLatin1String(" (bounds error: %1 component %2)"); qCritical() << qPrintable(errString) - << qPrintable(boundsError.arg(QLatin1String(components[i])).arg(j < 0? QLatin1String("< 0"): QLatin1String("> 255"))); + << qPrintable(boundsError.arg(QLatin1String(components[i])).arg(j < 0 ? QLatin1String("< 0") : QLatin1String("> 255"))); return true; // return default } } QColor aColor(temp[0], temp[1], temp[2]); - if (count == 4) + if (count == 4) { aColor.setAlpha(temp[3]); + } - if (aColor.isValid()) + if (aColor.isValid()) { output = aColor; - else + } else { qCritical() << qPrintable(errString); + } return true; } } case QVariant::Font: { QVariant tmp = QString::fromUtf8(data.constData(), data.length()); - if (tmp.convert(QVariant::Font)) + if (tmp.convert(QVariant::Font)) { output = tmp; - else + } else { qCritical() << qPrintable(errString); + } return true; } case QVariant::Pixmap: @@ -122,7 +126,7 @@ static bool readEntryGui(const QByteArray& data, const char* key, const QVariant case QVariant::Cursor: case QVariant::SizePolicy: case QVariant::Pen: - // we may want to handle these in the future + // we may want to handle these in the future default: break; @@ -137,7 +141,7 @@ static bool readEntryGui(const QByteArray& data, const char* key, const QVariant * @returns true if something was handled (even if an empty value was written) * or false if nothing was handled (e.g., Core type) */ -static bool writeEntryGui(KConfigGroup *cg, const char* key, const QVariant &prop, +static bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &prop, KConfigGroup::WriteConfigFlags pFlags) { switch (prop.type()) { @@ -153,14 +157,15 @@ static bool writeEntryGui(KConfigGroup *cg, const char* key, const QVariant &pro list.insert(0, rColor.red()); list.insert(1, rColor.green()); list.insert(2, rColor.blue()); - if (rColor.alpha() != 255) + if (rColor.alpha() != 255) { list.insert(3, rColor.alpha()); + } - cg->writeEntry( key, list, pFlags ); + cg->writeEntry(key, list, pFlags); return true; } case QVariant::Font: - cg->writeEntry( key, prop.toString().toUtf8(), pFlags ); + cg->writeEntry(key, prop.toString().toUtf8(), pFlags); return true; case QVariant::Pixmap: diff --git a/src/gui/kconfiggui.cpp b/src/gui/kconfiggui.cpp index 88da6b56..1eee8ce5 100644 --- a/src/gui/kconfiggui.cpp +++ b/src/gui/kconfiggui.cpp @@ -25,12 +25,13 @@ #include <kconfig.h> -static KConfig* s_sessionConfig = 0; +static KConfig *s_sessionConfig = 0; -KConfig* KConfigGui::sessionConfig() +KConfig *KConfigGui::sessionConfig() { - if (!s_sessionConfig) // create an instance specific config object - s_sessionConfig = new KConfig( sessionConfigName(), KConfig::SimpleConfig ); + if (!s_sessionConfig) { // create an instance specific config object + s_sessionConfig = new KConfig(sessionConfigName(), KConfig::SimpleConfig); + } return s_sessionConfig; } diff --git a/src/gui/kconfiggui.h b/src/gui/kconfiggui.h index 4e2313f3..173400fd 100644 --- a/src/gui/kconfiggui.h +++ b/src/gui/kconfiggui.h @@ -30,29 +30,29 @@ class KConfig; namespace KConfigGui { - /** - * Returns the application session config object. - * - * @return A pointer to the application's instance specific - * KConfig object. - * @see KConfig - */ - KCONFIGGUI_EXPORT KConfig* sessionConfig(); - - /** - * Indicates if a session config has been created for that application - * (ie. if sessionConfig() got called at least once) - * - * @return true if a sessionConfig object was created, false otherwise - */ - KCONFIGGUI_EXPORT bool hasSessionConfig(); - - /** - * Returns the name of the application session - * - * @return the application session name - */ - KCONFIGGUI_EXPORT QString sessionConfigName(); +/** + * Returns the application session config object. + * + * @return A pointer to the application's instance specific + * KConfig object. + * @see KConfig + */ +KCONFIGGUI_EXPORT KConfig *sessionConfig(); + +/** + * Indicates if a session config has been created for that application + * (ie. if sessionConfig() got called at least once) + * + * @return true if a sessionConfig object was created, false otherwise + */ +KCONFIGGUI_EXPORT bool hasSessionConfig(); + +/** + * Returns the name of the application session + * + * @return the application session name + */ +KCONFIGGUI_EXPORT QString sessionConfigName(); } #endif // KCONFIGGUI_H diff --git a/src/gui/kconfigloader.cpp b/src/gui/kconfigloader.cpp index 150c6b69..4713e324 100644 --- a/src/gui/kconfigloader.cpp +++ b/src/gui/kconfigloader.cpp @@ -152,7 +152,7 @@ QString ConfigLoaderHandler::defaultValue() const } bool ConfigLoaderHandler::endElement(const QString &namespaceURI, - const QString &localName, const QString &qName) + const QString &localName, const QString &qName) { Q_UNUSED(namespaceURI) Q_UNUSED(qName) @@ -224,7 +224,7 @@ void ConfigLoaderHandler::addItem() item = m_config->addItemFont(m_name, *d->newFont(), QFont(m_default), m_key); } else if (m_type == QStringLiteral("int")) { KConfigSkeleton::ItemInt *intItem = m_config->addItemInt(m_name, *d->newInt(), - m_default.toInt(), m_key); + m_default.toInt(), m_key); if (m_haveMin) { intItem->setMinValue(m_min); @@ -290,11 +290,11 @@ void ConfigLoaderHandler::addItem() longlongItem->setMaxValue(m_max); } item = longlongItem; - /* No addItemPathList in KConfigSkeleton ? - } else if (m_type == "PathList") { - //FIXME: the split() is naive and will break on lists with ,'s in them - item = m_config->addItemPathList(m_name, *d->newStringList(), m_default.split(","), m_key); - */ + /* No addItemPathList in KConfigSkeleton ? + } else if (m_type == "PathList") { + //FIXME: the split() is naive and will break on lists with ,'s in them + item = m_config->addItemPathList(m_name, *d->newStringList(), m_default.split(","), m_key); + */ } else if (m_type == QStringLiteral("point")) { QPoint defaultPoint; QStringList tmpList = m_default.split(QStringLiteral(",")); @@ -329,15 +329,15 @@ void ConfigLoaderHandler::addItem() ulonglongItem->setMaxValue(m_max); } item = ulonglongItem; - /* No addItemUrlList in KConfigSkeleton ? - } else if (m_type == "urllist") { - //FIXME: the split() is naive and will break on lists with ,'s in them - QStringList tmpList = m_default.split(","); - QList<QUrl> defaultList; - foreach (const QString& tmp, tmpList) { - defaultList.append(QUrl(tmp)); - } - item = m_config->addItemUrlList(m_name, *d->newUrlList(), defaultList, m_key);*/ + /* No addItemUrlList in KConfigSkeleton ? + } else if (m_type == "urllist") { + //FIXME: the split() is naive and will break on lists with ,'s in them + QStringList tmpList = m_default.split(","); + QList<QUrl> defaultList; + foreach (const QString& tmp, tmpList) { + defaultList.append(QUrl(tmp)); + } + item = m_config->addItemUrlList(m_name, *d->newUrlList(), defaultList, m_key);*/ } if (item) { @@ -433,7 +433,7 @@ bool KConfigLoader::usrWriteConfig() { if (d->saveDefaults) { KConfigSkeletonItem::List itemList = items(); - for(int i = 0; i < itemList.size(); i++) { + for (int i = 0; i < itemList.size(); i++) { KConfigGroup cg(config(), itemList.at(i)->group()); cg.writeEntry(itemList.at(i)->key(), ""); } diff --git a/src/gui/kconfigloader.h b/src/gui/kconfigloader.h index df38ce79..36eb182f 100644 --- a/src/gui/kconfigloader.h +++ b/src/gui/kconfigloader.h @@ -170,7 +170,7 @@ protected: bool usrWriteConfig(); private: - ConfigLoaderPrivate * const d; + ConfigLoaderPrivate *const d; }; #endif //multiple inclusion guard diff --git a/src/gui/kconfigloader_p.h b/src/gui/kconfigloader_p.h index f9aa9191..b030fc30 100644 --- a/src/gui/kconfigloader_p.h +++ b/src/gui/kconfigloader_p.h @@ -24,199 +24,198 @@ class ConfigLoaderPrivate { - public: - ConfigLoaderPrivate() - : saveDefaults(false) - { - } - - ~ConfigLoaderPrivate() - { - clearData(); - } - - void clearData() - { - qDeleteAll(bools); - qDeleteAll(strings); - qDeleteAll(stringlists); - qDeleteAll(colors); - qDeleteAll(fonts); - qDeleteAll(ints); - qDeleteAll(uints); - qDeleteAll(urls); - qDeleteAll(dateTimes); - qDeleteAll(doubles); - qDeleteAll(intlists); - qDeleteAll(longlongs); - qDeleteAll(points); - qDeleteAll(rects); - qDeleteAll(sizes); - qDeleteAll(ulonglongs); - qDeleteAll(urllists); - } - - bool *newBool() - { - bool *v = new bool; - bools.append(v); - return v; - } - - QString *newString() - { - QString *v = new QString; - strings.append(v); - return v; - } - - QStringList *newStringList() - { - QStringList *v = new QStringList; - stringlists.append(v); - return v; - } - - QColor *newColor() - { - QColor *v = new QColor; - colors.append(v); - return v; - } - - QFont *newFont() - { - QFont *v = new QFont; - fonts.append(v); - return v; - } - - qint32 *newInt() - { - qint32 *v = new qint32; - ints.append(v); - return v; - } - - quint32 *newUint() - { - quint32 *v = new quint32; - uints.append(v); - return v; - } - - QUrl *newUrl() - { - QUrl *v = new QUrl; - urls.append(v); - return v; - } - - QDateTime *newDateTime() - { - QDateTime *v = new QDateTime; - dateTimes.append(v); - return v; - } - - double *newDouble() - { - double *v = new double; - doubles.append(v); - return v; - } - - QList<qint32>* newIntList() - { - QList<qint32> *v = new QList<qint32>; - intlists.append(v); - return v; - } - - qint64 *newLongLong() - { - qint64 *v = new qint64; - longlongs.append(v); - return v; - } - - QPoint *newPoint() - { - QPoint *v = new QPoint; - points.append(v); - return v; - } - - QRect *newRect() - { - QRect *v = new QRect; - rects.append(v); - return v; - } - - QSize *newSize() - { - QSize *v = new QSize; - sizes.append(v); - return v; - } - - quint64 *newULongLong() - { - quint64 *v = new quint64; - ulonglongs.append(v); - return v; - } - - QList<QUrl> *newUrlList() - { - QList<QUrl> *v = new QList<QUrl>(); - urllists.append(v); - return v; - } - - void parse(KConfigLoader *loader, QIODevice *xml); - - /** - * Whether or not to write out default values. - * - * @param writeDefaults true if defaults should be written out - */ - void setWriteDefaults(bool writeDefaults) - { - saveDefaults = writeDefaults; - } - - /** - * @return true if default values will also be written out - */ - bool writeDefaults() const - { - return saveDefaults; - } - - - QList<bool *> bools; - QList<QString *> strings; - QList<QStringList *> stringlists; - QList<QColor *> colors; - QList<QFont *> fonts; - QList<qint32 *> ints; - QList<quint32 *> uints; - QList<QUrl *> urls; - QList<QDateTime *> dateTimes; - QList<double *> doubles; - QList<QList<qint32> *> intlists; - QList<qint64 *> longlongs; - QList<QPoint *> points; - QList<QRect *> rects; - QList<QSize *> sizes; - QList<quint64 *> ulonglongs; - QList<QList<QUrl> *> urllists; - QString baseGroup; - QStringList groups; - QHash<QString, QString> keysToNames; - bool saveDefaults; +public: + ConfigLoaderPrivate() + : saveDefaults(false) + { + } + + ~ConfigLoaderPrivate() + { + clearData(); + } + + void clearData() + { + qDeleteAll(bools); + qDeleteAll(strings); + qDeleteAll(stringlists); + qDeleteAll(colors); + qDeleteAll(fonts); + qDeleteAll(ints); + qDeleteAll(uints); + qDeleteAll(urls); + qDeleteAll(dateTimes); + qDeleteAll(doubles); + qDeleteAll(intlists); + qDeleteAll(longlongs); + qDeleteAll(points); + qDeleteAll(rects); + qDeleteAll(sizes); + qDeleteAll(ulonglongs); + qDeleteAll(urllists); + } + + bool *newBool() + { + bool *v = new bool; + bools.append(v); + return v; + } + + QString *newString() + { + QString *v = new QString; + strings.append(v); + return v; + } + + QStringList *newStringList() + { + QStringList *v = new QStringList; + stringlists.append(v); + return v; + } + + QColor *newColor() + { + QColor *v = new QColor; + colors.append(v); + return v; + } + + QFont *newFont() + { + QFont *v = new QFont; + fonts.append(v); + return v; + } + + qint32 *newInt() + { + qint32 *v = new qint32; + ints.append(v); + return v; + } + + quint32 *newUint() + { + quint32 *v = new quint32; + uints.append(v); + return v; + } + + QUrl *newUrl() + { + QUrl *v = new QUrl; + urls.append(v); + return v; + } + + QDateTime *newDateTime() + { + QDateTime *v = new QDateTime; + dateTimes.append(v); + return v; + } + + double *newDouble() + { + double *v = new double; + doubles.append(v); + return v; + } + + QList<qint32> *newIntList() + { + QList<qint32> *v = new QList<qint32>; + intlists.append(v); + return v; + } + + qint64 *newLongLong() + { + qint64 *v = new qint64; + longlongs.append(v); + return v; + } + + QPoint *newPoint() + { + QPoint *v = new QPoint; + points.append(v); + return v; + } + + QRect *newRect() + { + QRect *v = new QRect; + rects.append(v); + return v; + } + + QSize *newSize() + { + QSize *v = new QSize; + sizes.append(v); + return v; + } + + quint64 *newULongLong() + { + quint64 *v = new quint64; + ulonglongs.append(v); + return v; + } + + QList<QUrl> *newUrlList() + { + QList<QUrl> *v = new QList<QUrl>(); + urllists.append(v); + return v; + } + + void parse(KConfigLoader *loader, QIODevice *xml); + + /** + * Whether or not to write out default values. + * + * @param writeDefaults true if defaults should be written out + */ + void setWriteDefaults(bool writeDefaults) + { + saveDefaults = writeDefaults; + } + + /** + * @return true if default values will also be written out + */ + bool writeDefaults() const + { + return saveDefaults; + } + + QList<bool *> bools; + QList<QString *> strings; + QList<QStringList *> stringlists; + QList<QColor *> colors; + QList<QFont *> fonts; + QList<qint32 *> ints; + QList<quint32 *> uints; + QList<QUrl *> urls; + QList<QDateTime *> dateTimes; + QList<double *> doubles; + QList<QList<qint32> *> intlists; + QList<qint64 *> longlongs; + QList<QPoint *> points; + QList<QRect *> rects; + QList<QSize *> sizes; + QList<quint64 *> ulonglongs; + QList<QList<QUrl> *> urllists; + QString baseGroup; + QStringList groups; + QHash<QString, QString> keysToNames; + bool saveDefaults; }; #endif diff --git a/src/gui/kconfigskeleton.cpp b/src/gui/kconfigskeleton.cpp index 7704d36e..22f3c25c 100644 --- a/src/gui/kconfigskeleton.cpp +++ b/src/gui/kconfigskeleton.cpp @@ -23,36 +23,35 @@ #include <kcoreconfigskeleton_p.h> -KConfigSkeleton::KConfigSkeleton(const QString &configname, QObject* parent) - : KCoreConfigSkeleton(configname, parent) +KConfigSkeleton::KConfigSkeleton(const QString &configname, QObject *parent) + : KCoreConfigSkeleton(configname, parent) { } -KConfigSkeleton::KConfigSkeleton(KSharedConfig::Ptr pConfig, QObject* parent) - : KCoreConfigSkeleton(pConfig, parent) +KConfigSkeleton::KConfigSkeleton(KSharedConfig::Ptr pConfig, QObject *parent) + : KCoreConfigSkeleton(pConfig, parent) { } - -KConfigSkeleton::ItemColor::ItemColor( const QString &_group, const QString &_key, - QColor &reference, - const QColor &defaultValue ) - : KConfigSkeletonGenericItem<QColor>( _group, _key, reference, defaultValue ) +KConfigSkeleton::ItemColor::ItemColor(const QString &_group, const QString &_key, + QColor &reference, + const QColor &defaultValue) + : KConfigSkeletonGenericItem<QColor>(_group, _key, reference, defaultValue) { } -void KConfigSkeleton::ItemColor::readConfig( KConfig *config ) +void KConfigSkeleton::ItemColor::readConfig(KConfig *config) { - KConfigGroup cg(config, mGroup ); - mReference = cg.readEntry( mKey, mDefault ); - mLoadedValue = mReference; + KConfigGroup cg(config, mGroup); + mReference = cg.readEntry(mKey, mDefault); + mLoadedValue = mReference; - readImmutability( cg ); + readImmutability(cg); } -void KConfigSkeleton::ItemColor::setProperty(const QVariant & p) +void KConfigSkeleton::ItemColor::setProperty(const QVariant &p) { - mReference = qvariant_cast<QColor>(p); + mReference = qvariant_cast<QColor>(p); } bool KConfigSkeleton::ItemColor::isEqual(const QVariant &v) const @@ -62,29 +61,28 @@ bool KConfigSkeleton::ItemColor::isEqual(const QVariant &v) const QVariant KConfigSkeleton::ItemColor::property() const { - return QVariant(mReference); + return QVariant(mReference); } - -KConfigSkeleton::ItemFont::ItemFont( const QString &_group, const QString &_key, - QFont &reference, - const QFont &defaultValue ) - : KConfigSkeletonGenericItem<QFont>( _group, _key, reference, defaultValue ) +KConfigSkeleton::ItemFont::ItemFont(const QString &_group, const QString &_key, + QFont &reference, + const QFont &defaultValue) + : KConfigSkeletonGenericItem<QFont>(_group, _key, reference, defaultValue) { } -void KConfigSkeleton::ItemFont::readConfig( KConfig *config ) +void KConfigSkeleton::ItemFont::readConfig(KConfig *config) { - KConfigGroup cg(config, mGroup ); - mReference = cg.readEntry( mKey, mDefault ); - mLoadedValue = mReference; + KConfigGroup cg(config, mGroup); + mReference = cg.readEntry(mKey, mDefault); + mLoadedValue = mReference; - readImmutability( cg ); + readImmutability(cg); } -void KConfigSkeleton::ItemFont::setProperty(const QVariant & p) +void KConfigSkeleton::ItemFont::setProperty(const QVariant &p) { - mReference = qvariant_cast<QFont>(p); + mReference = qvariant_cast<QFont>(p); } bool KConfigSkeleton::ItemFont::isEqual(const QVariant &v) const @@ -94,28 +92,26 @@ bool KConfigSkeleton::ItemFont::isEqual(const QVariant &v) const QVariant KConfigSkeleton::ItemFont::property() const { - return QVariant(mReference); + return QVariant(mReference); } - -KConfigSkeleton::ItemColor *KConfigSkeleton::addItemColor( const QString &name, QColor &reference, - const QColor &defaultValue, const QString &key ) +KConfigSkeleton::ItemColor *KConfigSkeleton::addItemColor(const QString &name, QColor &reference, + const QColor &defaultValue, const QString &key) { - KConfigSkeleton::ItemColor *item; - item = new KConfigSkeleton::ItemColor( d->mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; + KConfigSkeleton::ItemColor *item; + item = new KConfigSkeleton::ItemColor(d->mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue); + addItem(item, name); + return item; } -KConfigSkeleton::ItemFont *KConfigSkeleton::addItemFont( const QString &name, QFont &reference, - const QFont &defaultValue, const QString &key ) +KConfigSkeleton::ItemFont *KConfigSkeleton::addItemFont(const QString &name, QFont &reference, + const QFont &defaultValue, const QString &key) { - KConfigSkeleton::ItemFont *item; - item = new KConfigSkeleton::ItemFont( d->mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; + KConfigSkeleton::ItemFont *item; + item = new KConfigSkeleton::ItemFont(d->mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue); + addItem(item, name); + return item; } - diff --git a/src/gui/kconfigskeleton.h b/src/gui/kconfigskeleton.h index e62e60b4..8262f5ce 100644 --- a/src/gui/kconfigskeleton.h +++ b/src/gui/kconfigskeleton.h @@ -39,101 +39,100 @@ */ class KCONFIGGUI_EXPORT KConfigSkeleton : public KCoreConfigSkeleton { - Q_OBJECT + Q_OBJECT public: - /** - * Class for handling a color preferences item. - */ - class KCONFIGGUI_EXPORT ItemColor:public KConfigSkeletonGenericItem < QColor > - { - public: - /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemColor(const QString & _group, const QString & _key, - QColor & reference, - const QColor & defaultValue = QColor(128, 128, 128)); - - /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ - void readConfig(KConfig * config); - - /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */ - void setProperty(const QVariant & p); - - /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) */ - bool isEqual(const QVariant &p) const; - - /** @copydoc KConfigSkeletonItem::property() */ - QVariant property() const; - }; - - - /** - * Class for handling a font preferences item. - */ - class KCONFIGGUI_EXPORT ItemFont:public KConfigSkeletonGenericItem < QFont > - { - public: - /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemFont(const QString & _group, const QString & _key, QFont & reference, - const QFont & defaultValue = QFont()); - - /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ - void readConfig(KConfig * config); - - /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */ - void setProperty(const QVariant & p); - - /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) */ - bool isEqual(const QVariant &p) const; - - /** @copydoc KConfigSkeletonItem::property() */ - QVariant property() const; - }; + /** + * Class for handling a color preferences item. + */ + class KCONFIGGUI_EXPORT ItemColor: public KConfigSkeletonGenericItem < QColor > + { + public: + /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ + ItemColor(const QString &_group, const QString &_key, + QColor &reference, + const QColor &defaultValue = QColor(128, 128, 128)); + + /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ + void readConfig(KConfig *config); + + /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */ + void setProperty(const QVariant &p); + + /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) */ + bool isEqual(const QVariant &p) const; + + /** @copydoc KConfigSkeletonItem::property() */ + QVariant property() const; + }; + + /** + * Class for handling a font preferences item. + */ + class KCONFIGGUI_EXPORT ItemFont: public KConfigSkeletonGenericItem < QFont > + { + public: + /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ + ItemFont(const QString &_group, const QString &_key, QFont &reference, + const QFont &defaultValue = QFont()); + + /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ + void readConfig(KConfig *config); + + /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */ + void setProperty(const QVariant &p); + + /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) */ + bool isEqual(const QVariant &p) const; + + /** @copydoc KConfigSkeletonItem::property() */ + QVariant property() const; + }; public: - /** - * Constructor. - * - * @param configname name of config file. If no name is given, the default - * config file as returned by KSharedConfig::openConfig() is used. - */ - explicit KConfigSkeleton(const QString & configname = QString(), QObject* parent = 0); - - /** - * Constructor. - * - * @param config configuration object to use. - */ - explicit KConfigSkeleton(KSharedConfig::Ptr config, QObject* parent = 0); - - /** - * Register an item of type QColor. - * - * @param name Name used to identify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemColor *addItemColor(const QString & name, QColor & reference, - const QColor & defaultValue = QColor(128, 128, 128), - const QString & key = QString()); - - /** - * Register an item of type QFont. - * - * @param name Name used to identify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemFont *addItemFont(const QString & name, QFont & reference, - const QFont & defaultValue = QFont(), - const QString & key = QString()); + /** + * Constructor. + * + * @param configname name of config file. If no name is given, the default + * config file as returned by KSharedConfig::openConfig() is used. + */ + explicit KConfigSkeleton(const QString &configname = QString(), QObject *parent = 0); + + /** + * Constructor. + * + * @param config configuration object to use. + */ + explicit KConfigSkeleton(KSharedConfig::Ptr config, QObject *parent = 0); + + /** + * Register an item of type QColor. + * + * @param name Name used to identify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemColor *addItemColor(const QString &name, QColor &reference, + const QColor &defaultValue = QColor(128, 128, 128), + const QString &key = QString()); + + /** + * Register an item of type QFont. + * + * @param name Name used to identify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemFont *addItemFont(const QString &name, QFont &reference, + const QFont &defaultValue = QFont(), + const QString &key = QString()); }; diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp index a377ff0f..83d91360 100644 --- a/src/gui/kstandardshortcut.cpp +++ b/src/gui/kstandardshortcut.cpp @@ -31,23 +31,22 @@ namespace KStandardShortcut { -struct KStandardShortcutInfo -{ +struct KStandardShortcutInfo { //! The standard shortcut id. @see StandardShortcut StandardShortcut id; - /** + /** * Unique name for the given accel. The name is used to save the user * settings. It's not representable. Use description for that. * @warning NEVER EVER CHANGE IT OR TRANSLATE IT! */ - const char* name; + const char *name; //! Context for the translation - const char* translation_context; + const char *translation_context; //! Localized label for user-visible display - const char* description; + const char *description; //! The keys for this shortcut int cutDefault, cutDefault2; @@ -75,121 +74,120 @@ struct KStandardShortcutInfo */ // STUFF WILL BREAK IF YOU DON'T READ THIS!!! // Read the comments of the big enum in kstandardshortcut.h before you change anything! -static KStandardShortcutInfo g_infoStandardShortcut[] = -{ +static KStandardShortcutInfo g_infoStandardShortcut[] = { //Group File, - {AccelNone, 0 , 0 , 0 , 0 , 0 , QList<QKeySequence>(), false }, - { Open , "Open" , I18N_NOOP2("@action", "Open") , CTRL(O), 0 , QList<QKeySequence>(), false } , - { New , "New" , I18N_NOOP2("@action", "New") , CTRL(N), 0 , QList<QKeySequence>(), false } , - { Close , "Close", I18N_NOOP2("@action", "Close"), CTRL(W), CTRL(Escape), QList<QKeySequence>(), false } , - { Save , "Save" , I18N_NOOP2("@action", "Save") , CTRL(S), 0 , QList<QKeySequence>(), false } , - { Print , "Print", I18N_NOOP2("@action", "Print"), CTRL(P), 0 , QList<QKeySequence>(), false } , - { Quit , "Quit" , I18N_NOOP2("@action", "Quit") , CTRL(Q), 0 , QList<QKeySequence>(), false } , + {AccelNone, 0, 0, 0, 0, 0, QList<QKeySequence>(), false }, + { Open, "Open", I18N_NOOP2("@action", "Open"), CTRL(O), 0, QList<QKeySequence>(), false }, + { New, "New", I18N_NOOP2("@action", "New"), CTRL(N), 0, QList<QKeySequence>(), false }, + { Close, "Close", I18N_NOOP2("@action", "Close"), CTRL(W), CTRL(Escape), QList<QKeySequence>(), false }, + { Save, "Save", I18N_NOOP2("@action", "Save"), CTRL(S), 0, QList<QKeySequence>(), false }, + { Print, "Print", I18N_NOOP2("@action", "Print"), CTRL(P), 0, QList<QKeySequence>(), false }, + { Quit, "Quit", I18N_NOOP2("@action", "Quit"), CTRL(Q), 0, QList<QKeySequence>(), false }, //Group Edit - { Undo , "Undo" , I18N_NOOP2("@action", "Undo") , CTRL(Z) , 0 , QList<QKeySequence>(), false }, - { Redo , "Redo" , I18N_NOOP2("@action", "Redo") , CTRLSHIFT(Z) , 0 , QList<QKeySequence>(), false }, - { Cut , "Cut" , I18N_NOOP2("@action", "Cut") , CTRL(X) , SHIFT(Delete), QList<QKeySequence>(), false }, - { Copy , "Copy" , I18N_NOOP2("@action", "Copy") , CTRL(C) , CTRL(Insert) , QList<QKeySequence>(), false }, - { Paste , "Paste" , I18N_NOOP2("@action", "Paste") , CTRL(V) , SHIFT(Insert), QList<QKeySequence>(), false }, - { PasteSelection , "Paste Selection" , I18N_NOOP2("@action", "Paste Selection") , CTRLSHIFT(Insert), 0 , QList<QKeySequence>(), false }, - - { SelectAll , "SelectAll" , I18N_NOOP2("@action", "Select All") , CTRL(A) , 0 , QList<QKeySequence>(), false }, - { Deselect , "Deselect" , I18N_NOOP2("@action", "Deselect") , CTRLSHIFT(A) , 0 , QList<QKeySequence>(), false }, - { DeleteWordBack , "DeleteWordBack" , I18N_NOOP2("@action", "Delete Word Backwards"), CTRL(Backspace) , 0 , QList<QKeySequence>(), false }, - { DeleteWordForward, "DeleteWordForward", I18N_NOOP2("@action", "Delete Word Forward") , CTRL(Delete) , 0 , QList<QKeySequence>(), false }, - - { Find , "Find" , I18N_NOOP2("@action", "Find") , CTRL(F) , 0 , QList<QKeySequence>(), false }, - { FindNext , "FindNext" , I18N_NOOP2("@action", "Find Next") , Qt::Key_F3 , 0 , QList<QKeySequence>(), false }, - { FindPrev , "FindPrev" , I18N_NOOP2("@action", "Find Prev") , SHIFT(F3) , 0 , QList<QKeySequence>(), false }, - { Replace , "Replace" , I18N_NOOP2("@action", "Replace") , CTRL(R) , 0 , QList<QKeySequence>(), false }, + { Undo, "Undo", I18N_NOOP2("@action", "Undo"), CTRL(Z), 0, QList<QKeySequence>(), false }, + { Redo, "Redo", I18N_NOOP2("@action", "Redo"), CTRLSHIFT(Z), 0, QList<QKeySequence>(), false }, + { Cut, "Cut", I18N_NOOP2("@action", "Cut"), CTRL(X), SHIFT(Delete), QList<QKeySequence>(), false }, + { Copy, "Copy", I18N_NOOP2("@action", "Copy"), CTRL(C), CTRL(Insert), QList<QKeySequence>(), false }, + { Paste, "Paste", I18N_NOOP2("@action", "Paste"), CTRL(V), SHIFT(Insert), QList<QKeySequence>(), false }, + { PasteSelection, "Paste Selection", I18N_NOOP2("@action", "Paste Selection"), CTRLSHIFT(Insert), 0, QList<QKeySequence>(), false }, + + { SelectAll, "SelectAll", I18N_NOOP2("@action", "Select All"), CTRL(A), 0, QList<QKeySequence>(), false }, + { Deselect, "Deselect", I18N_NOOP2("@action", "Deselect"), CTRLSHIFT(A), 0, QList<QKeySequence>(), false }, + { DeleteWordBack, "DeleteWordBack", I18N_NOOP2("@action", "Delete Word Backwards"), CTRL(Backspace), 0, QList<QKeySequence>(), false }, + { DeleteWordForward, "DeleteWordForward", I18N_NOOP2("@action", "Delete Word Forward"), CTRL(Delete), 0, QList<QKeySequence>(), false }, + + { Find, "Find", I18N_NOOP2("@action", "Find"), CTRL(F), 0, QList<QKeySequence>(), false }, + { FindNext, "FindNext", I18N_NOOP2("@action", "Find Next"), Qt::Key_F3, 0, QList<QKeySequence>(), false }, + { FindPrev, "FindPrev", I18N_NOOP2("@action", "Find Prev"), SHIFT(F3), 0, QList<QKeySequence>(), false }, + { Replace, "Replace", I18N_NOOP2("@action", "Replace"), CTRL(R), 0, QList<QKeySequence>(), false }, //Group Navigation - { Home , "Home" , I18N_NOOP2("@action Go to main page" , "Home") , ALT(Home) , Qt::Key_HomePage , QList<QKeySequence>(), false }, - { Begin , "Begin" , I18N_NOOP2("@action Beginning of document", "Begin") , CTRL(Home) , 0 , QList<QKeySequence>(), false }, - { End , "End" , I18N_NOOP2("@action End of document" , "End") , CTRL(End) , 0 , QList<QKeySequence>(), false }, - { Prior , "Prior" , I18N_NOOP2("@action" , "Prior") , Qt::Key_PageUp , 0 , QList<QKeySequence>(), false }, - { Next , "Next" , I18N_NOOP2("@action Opposite to Prior" , "Next") , Qt::Key_PageDown, 0 , QList<QKeySequence>(), false }, - - { Up , "Up" , I18N_NOOP2("@action" , "Up") , ALT(Up) , 0 , QList<QKeySequence>(), false }, - { Back , "Back" , I18N_NOOP2("@action" , "Back") , ALT(Left) , Qt::Key_Back , QList<QKeySequence>(), false }, - { Forward , "Forward" , I18N_NOOP2("@action" , "Forward") , ALT(Right) , Qt::Key_Forward , QList<QKeySequence>(), false }, - { Reload , "Reload" , I18N_NOOP2("@action" , "Reload") , Qt::Key_F5 , Qt::Key_Refresh , QList<QKeySequence>(), false }, - - { BeginningOfLine, "BeginningOfLine" , I18N_NOOP2("@action" , "Beginning of Line") , Qt::Key_Home , 0 , QList<QKeySequence>(), false }, - { EndOfLine , "EndOfLine" , I18N_NOOP2("@action" , "End of Line") , Qt::Key_End , 0 , QList<QKeySequence>(), false }, - { GotoLine , "GotoLine" , I18N_NOOP2("@action" , "Go to Line") , CTRL(G) , 0 , QList<QKeySequence>(), false }, - { BackwardWord , "BackwardWord" , I18N_NOOP2("@action" , "Backward Word") , CTRL(Left) , 0 , QList<QKeySequence>(), false }, - { ForwardWord , "ForwardWord" , I18N_NOOP2("@action" , "Forward Word") , CTRL(Right) , 0 , QList<QKeySequence>(), false }, - - { AddBookmark , "AddBookmark" , I18N_NOOP2("@action" , "Add Bookmark") , CTRL(B) , 0 , QList<QKeySequence>(), false }, - { ZoomIn , "ZoomIn" , I18N_NOOP2("@action" , "Zoom In") , CTRL(Plus) , CTRL(Equal) , QList<QKeySequence>(), false }, - { ZoomOut , "ZoomOut" , I18N_NOOP2("@action" , "Zoom Out") , CTRL(Minus) , 0 , QList<QKeySequence>(), false }, - { FullScreen , "FullScreen" , I18N_NOOP2("@action" , "Full Screen Mode") , CTRLSHIFT(F) , 0 , QList<QKeySequence>(), false }, - - { ShowMenubar , "ShowMenubar" , I18N_NOOP2("@action" , "Show Menu Bar") , CTRL(M) , 0 , QList<QKeySequence>(), false }, - { TabNext , "Activate Next Tab" , I18N_NOOP2("@action" , "Activate Next Tab") , CTRL(Period) , CTRL(BracketRight), QList<QKeySequence>(), false }, - { TabPrev , "Activate Previous Tab", I18N_NOOP2("@action" , "Activate Previous Tab"), CTRL(Comma) , CTRL(BracketLeft) , QList<QKeySequence>(), false }, + { Home, "Home", I18N_NOOP2("@action Go to main page", "Home"), ALT(Home), Qt::Key_HomePage, QList<QKeySequence>(), false }, + { Begin, "Begin", I18N_NOOP2("@action Beginning of document", "Begin"), CTRL(Home), 0, QList<QKeySequence>(), false }, + { End, "End", I18N_NOOP2("@action End of document", "End"), CTRL(End), 0, QList<QKeySequence>(), false }, + { Prior, "Prior", I18N_NOOP2("@action", "Prior"), Qt::Key_PageUp, 0, QList<QKeySequence>(), false }, + { Next, "Next", I18N_NOOP2("@action Opposite to Prior", "Next"), Qt::Key_PageDown, 0, QList<QKeySequence>(), false }, + + { Up, "Up", I18N_NOOP2("@action", "Up"), ALT(Up), 0, QList<QKeySequence>(), false }, + { Back, "Back", I18N_NOOP2("@action", "Back"), ALT(Left), Qt::Key_Back, QList<QKeySequence>(), false }, + { Forward, "Forward", I18N_NOOP2("@action", "Forward"), ALT(Right), Qt::Key_Forward, QList<QKeySequence>(), false }, + { Reload, "Reload", I18N_NOOP2("@action", "Reload"), Qt::Key_F5, Qt::Key_Refresh, QList<QKeySequence>(), false }, + + { BeginningOfLine, "BeginningOfLine", I18N_NOOP2("@action", "Beginning of Line"), Qt::Key_Home, 0, QList<QKeySequence>(), false }, + { EndOfLine, "EndOfLine", I18N_NOOP2("@action", "End of Line"), Qt::Key_End, 0, QList<QKeySequence>(), false }, + { GotoLine, "GotoLine", I18N_NOOP2("@action", "Go to Line"), CTRL(G), 0, QList<QKeySequence>(), false }, + { BackwardWord, "BackwardWord", I18N_NOOP2("@action", "Backward Word"), CTRL(Left), 0, QList<QKeySequence>(), false }, + { ForwardWord, "ForwardWord", I18N_NOOP2("@action", "Forward Word"), CTRL(Right), 0, QList<QKeySequence>(), false }, + + { AddBookmark, "AddBookmark", I18N_NOOP2("@action", "Add Bookmark"), CTRL(B), 0, QList<QKeySequence>(), false }, + { ZoomIn, "ZoomIn", I18N_NOOP2("@action", "Zoom In"), CTRL(Plus), CTRL(Equal), QList<QKeySequence>(), false }, + { ZoomOut, "ZoomOut", I18N_NOOP2("@action", "Zoom Out"), CTRL(Minus), 0, QList<QKeySequence>(), false }, + { FullScreen, "FullScreen", I18N_NOOP2("@action", "Full Screen Mode"), CTRLSHIFT(F), 0, QList<QKeySequence>(), false }, + + { ShowMenubar, "ShowMenubar", I18N_NOOP2("@action", "Show Menu Bar"), CTRL(M), 0, QList<QKeySequence>(), false }, + { TabNext, "Activate Next Tab", I18N_NOOP2("@action", "Activate Next Tab"), CTRL(Period), CTRL(BracketRight), QList<QKeySequence>(), false }, + { TabPrev, "Activate Previous Tab", I18N_NOOP2("@action", "Activate Previous Tab"), CTRL(Comma), CTRL(BracketLeft), QList<QKeySequence>(), false }, //Group Help - { Help , "Help" , I18N_NOOP2("@action" , "Help") , Qt::Key_F1 , 0 , QList<QKeySequence>(), false }, - { WhatsThis , "WhatsThis" , I18N_NOOP2("@action" , "What's This") , SHIFT(F1) , 0 , QList<QKeySequence>(), false }, + { Help, "Help", I18N_NOOP2("@action", "Help"), Qt::Key_F1, 0, QList<QKeySequence>(), false }, + { WhatsThis, "WhatsThis", I18N_NOOP2("@action", "What's This"), SHIFT(F1), 0, QList<QKeySequence>(), false }, //Group TextCompletion - { TextCompletion , "TextCompletion" , I18N_NOOP2("@action", "Text Completion") , CTRL(E) , 0, QList<QKeySequence>(), false }, - { PrevCompletion , "PrevCompletion" , I18N_NOOP2("@action", "Previous Completion Match"), CTRL(Up) , 0, QList<QKeySequence>(), false }, - { NextCompletion , "NextCompletion" , I18N_NOOP2("@action", "Next Completion Match") , CTRL(Down) , 0, QList<QKeySequence>(), false }, - { SubstringCompletion , "SubstringCompletion" , I18N_NOOP2("@action", "Substring Completion") , CTRL(T) , 0, QList<QKeySequence>(), false }, - - { RotateUp , "RotateUp" , I18N_NOOP2("@action", "Previous Item in List") , Qt::Key_Up , 0, QList<QKeySequence>(), false }, - { RotateDown , "RotateDown" , I18N_NOOP2("@action", "Next Item in List") , Qt::Key_Down, 0, QList<QKeySequence>(), false }, - - { OpenRecent , "OpenRecent" , I18N_NOOP2("@action", "Open Recent") , 0 , 0, QList<QKeySequence>(), false }, - { SaveAs , "SaveAs" , I18N_NOOP2("@action", "Save As") , CTRLSHIFT(S), 0, QList<QKeySequence>(), false }, - { Revert , "Revert" , I18N_NOOP2("@action", "Revert") , 0 , 0, QList<QKeySequence>(), false }, - { PrintPreview , "PrintPreview" , I18N_NOOP2("@action", "Print Preview") , 0 , 0, QList<QKeySequence>(), false }, - { Mail , "Mail" , I18N_NOOP2("@action", "Mail") , 0 , 0, QList<QKeySequence>(), false }, - { Clear , "Clear" , I18N_NOOP2("@action", "Clear") , 0 , 0, QList<QKeySequence>(), false }, - { ActualSize , "ActualSize" , I18N_NOOP2("@action", "Actual Size") , 0 , 0, QList<QKeySequence>(), false }, - { FitToPage , "FitToPage" , I18N_NOOP2("@action", "Fit To Page") , 0 , 0, QList<QKeySequence>(), false }, - { FitToWidth , "FitToWidth" , I18N_NOOP2("@action", "Fit To Width") , 0 , 0, QList<QKeySequence>(), false }, - { FitToHeight , "FitToHeight" , I18N_NOOP2("@action", "Fit To Height") , 0 , 0, QList<QKeySequence>(), false }, - { Zoom , "Zoom" , I18N_NOOP2("@action", "Zoom") , 0 , 0, QList<QKeySequence>(), false }, - { Goto , "Goto" , I18N_NOOP2("@action", "Goto") , 0 , 0, QList<QKeySequence>(), false }, - { GotoPage , "GotoPage" , I18N_NOOP2("@action", "Goto Page") , 0 , 0, QList<QKeySequence>(), false }, - { DocumentBack , "DocumentBack" , I18N_NOOP2("@action", "Document Back") , ALTSHIFT(Left), 0, QList<QKeySequence>(), false }, - { DocumentForward , "DocumentForward" , I18N_NOOP2("@action", "Document Forward") , ALTSHIFT(Right), 0, QList<QKeySequence>(), false }, - { EditBookmarks , "EditBookmarks" , I18N_NOOP2("@action", "Edit Bookmarks") , 0 , 0, QList<QKeySequence>(), false }, - { Spelling , "Spelling" , I18N_NOOP2("@action", "Spelling") , 0 , 0, QList<QKeySequence>(), false }, - { ShowToolbar , "ShowToolbar" , I18N_NOOP2("@action", "Show Toolbar") , 0 , 0, QList<QKeySequence>(), false }, - { ShowStatusbar , "ShowStatusbar" , I18N_NOOP2("@action", "Show Statusbar") , 0 , 0, QList<QKeySequence>(), false }, - { SaveOptions , "SaveOptions" , I18N_NOOP2("@action", "Save Options") , 0 , 0, QList<QKeySequence>(), false }, - { KeyBindings , "KeyBindings" , I18N_NOOP2("@action", "Key Bindings") , 0 , 0, QList<QKeySequence>(), false }, - { Preferences , "Preferences" , I18N_NOOP2("@action", "Preferences") , 0 , 0, QList<QKeySequence>(), false }, - { ConfigureToolbars , "ConfigureToolbars" , I18N_NOOP2("@action", "Configure Toolbars") , 0 , 0, QList<QKeySequence>(), false }, - { ConfigureNotifications , "ConfigureNotifications" , I18N_NOOP2("@action", "Configure Notifications") , 0 , 0, QList<QKeySequence>(), false }, - { TipofDay , "TipofDay" , I18N_NOOP2("@action", "Tip Of Day") , 0 , 0, QList<QKeySequence>(), false }, - { ReportBug , "ReportBug" , I18N_NOOP2("@action", "Report Bug") , 0 , 0, QList<QKeySequence>(), false }, - { SwitchApplicationLanguage, "SwitchApplicationLanguage", I18N_NOOP2("@action", "Switch Application Language"), 0 , 0, QList<QKeySequence>(), false }, - { AboutApp , "AboutApp" , I18N_NOOP2("@action", "About Application") , 0 , 0, QList<QKeySequence>(), false }, - { AboutKDE , "AboutKDE" , I18N_NOOP2("@action", "About KDE") , 0 , 0, QList<QKeySequence>(), false }, + { TextCompletion, "TextCompletion", I18N_NOOP2("@action", "Text Completion"), CTRL(E), 0, QList<QKeySequence>(), false }, + { PrevCompletion, "PrevCompletion", I18N_NOOP2("@action", "Previous Completion Match"), CTRL(Up), 0, QList<QKeySequence>(), false }, + { NextCompletion, "NextCompletion", I18N_NOOP2("@action", "Next Completion Match"), CTRL(Down), 0, QList<QKeySequence>(), false }, + { SubstringCompletion, "SubstringCompletion", I18N_NOOP2("@action", "Substring Completion"), CTRL(T), 0, QList<QKeySequence>(), false }, + + { RotateUp, "RotateUp", I18N_NOOP2("@action", "Previous Item in List"), Qt::Key_Up, 0, QList<QKeySequence>(), false }, + { RotateDown, "RotateDown", I18N_NOOP2("@action", "Next Item in List"), Qt::Key_Down, 0, QList<QKeySequence>(), false }, + + { OpenRecent, "OpenRecent", I18N_NOOP2("@action", "Open Recent"), 0, 0, QList<QKeySequence>(), false }, + { SaveAs, "SaveAs", I18N_NOOP2("@action", "Save As"), CTRLSHIFT(S), 0, QList<QKeySequence>(), false }, + { Revert, "Revert", I18N_NOOP2("@action", "Revert"), 0, 0, QList<QKeySequence>(), false }, + { PrintPreview, "PrintPreview", I18N_NOOP2("@action", "Print Preview"), 0, 0, QList<QKeySequence>(), false }, + { Mail, "Mail", I18N_NOOP2("@action", "Mail"), 0, 0, QList<QKeySequence>(), false }, + { Clear, "Clear", I18N_NOOP2("@action", "Clear"), 0, 0, QList<QKeySequence>(), false }, + { ActualSize, "ActualSize", I18N_NOOP2("@action", "Actual Size"), 0, 0, QList<QKeySequence>(), false }, + { FitToPage, "FitToPage", I18N_NOOP2("@action", "Fit To Page"), 0, 0, QList<QKeySequence>(), false }, + { FitToWidth, "FitToWidth", I18N_NOOP2("@action", "Fit To Width"), 0, 0, QList<QKeySequence>(), false }, + { FitToHeight, "FitToHeight", I18N_NOOP2("@action", "Fit To Height"), 0, 0, QList<QKeySequence>(), false }, + { Zoom, "Zoom", I18N_NOOP2("@action", "Zoom"), 0, 0, QList<QKeySequence>(), false }, + { Goto, "Goto", I18N_NOOP2("@action", "Goto"), 0, 0, QList<QKeySequence>(), false }, + { GotoPage, "GotoPage", I18N_NOOP2("@action", "Goto Page"), 0, 0, QList<QKeySequence>(), false }, + { DocumentBack, "DocumentBack", I18N_NOOP2("@action", "Document Back"), ALTSHIFT(Left), 0, QList<QKeySequence>(), false }, + { DocumentForward, "DocumentForward", I18N_NOOP2("@action", "Document Forward"), ALTSHIFT(Right), 0, QList<QKeySequence>(), false }, + { EditBookmarks, "EditBookmarks", I18N_NOOP2("@action", "Edit Bookmarks"), 0, 0, QList<QKeySequence>(), false }, + { Spelling, "Spelling", I18N_NOOP2("@action", "Spelling"), 0, 0, QList<QKeySequence>(), false }, + { ShowToolbar, "ShowToolbar", I18N_NOOP2("@action", "Show Toolbar"), 0, 0, QList<QKeySequence>(), false }, + { ShowStatusbar, "ShowStatusbar", I18N_NOOP2("@action", "Show Statusbar"), 0, 0, QList<QKeySequence>(), false }, + { SaveOptions, "SaveOptions", I18N_NOOP2("@action", "Save Options"), 0, 0, QList<QKeySequence>(), false }, + { KeyBindings, "KeyBindings", I18N_NOOP2("@action", "Key Bindings"), 0, 0, QList<QKeySequence>(), false }, + { Preferences, "Preferences", I18N_NOOP2("@action", "Preferences"), 0, 0, QList<QKeySequence>(), false }, + { ConfigureToolbars, "ConfigureToolbars", I18N_NOOP2("@action", "Configure Toolbars"), 0, 0, QList<QKeySequence>(), false }, + { ConfigureNotifications, "ConfigureNotifications", I18N_NOOP2("@action", "Configure Notifications"), 0, 0, QList<QKeySequence>(), false }, + { TipofDay, "TipofDay", I18N_NOOP2("@action", "Tip Of Day"), 0, 0, QList<QKeySequence>(), false }, + { ReportBug, "ReportBug", I18N_NOOP2("@action", "Report Bug"), 0, 0, QList<QKeySequence>(), false }, + { SwitchApplicationLanguage, "SwitchApplicationLanguage", I18N_NOOP2("@action", "Switch Application Language"), 0, 0, QList<QKeySequence>(), false }, + { AboutApp, "AboutApp", I18N_NOOP2("@action", "About Application"), 0, 0, QList<QKeySequence>(), false }, + { AboutKDE, "AboutKDE", I18N_NOOP2("@action", "About KDE"), 0, 0, QList<QKeySequence>(), false }, //dummy entry to catch simple off-by-one errors. Insert new entries before this line. - { AccelNone , 0 , 0 , 0 , 0, 0, QList<QKeySequence>(), false } + { AccelNone, 0, 0, 0, 0, 0, QList<QKeySequence>(), false } }; - /** Search for the KStandardShortcutInfo object associated with the given @p id. Return a dummy entry with no name and an empty shortcut if @p id is invalid. */ static KStandardShortcutInfo *guardedStandardShortcutInfo(StandardShortcut id) { if (id >= static_cast<int>(sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo)) || - id < 0) { + id < 0) { qWarning() << "KStandardShortcut: id not found!"; return &g_infoStandardShortcut[AccelNone]; - } else + } else { return &g_infoStandardShortcut[id]; + } } /** Initialize the accelerator @p id by checking if it is overridden @@ -202,7 +200,7 @@ static void initialize(StandardShortcut id) KStandardShortcutInfo *info = guardedStandardShortcutInfo(id); // All three are needed. - if (info->id!=AccelNone) { + if (info->id != AccelNone) { Q_ASSERT(info->description); Q_ASSERT(info->translation_context); Q_ASSERT(info->name); @@ -212,10 +210,11 @@ static void initialize(StandardShortcut id) if (cg.hasKey(info->name)) { QString s = cg.readEntry(info->name); - if (s != QLatin1String("none")) + if (s != QLatin1String("none")) { info->cut = QKeySequence::listFromString(s); - else + } else { info->cut = QList<QKeySequence>(); + } } else { info->cut = hardcodedDefaultShortcut(id); } @@ -228,8 +227,9 @@ void saveShortcut(StandardShortcut id, const QList<QKeySequence> &newShortcut) KStandardShortcutInfo *info = guardedStandardShortcutInfo(id); // If the action has no standard shortcut associated there is nothing to // save - if(info->id == AccelNone) + if (info->id == AccelNone) { return; + } KConfigGroup cg(KSharedConfig::openConfig(), "Shortcuts"); @@ -239,14 +239,15 @@ void saveShortcut(StandardShortcut id, const QList<QKeySequence> &newShortcut) if (sameAsDefault) { // If the shortcut is the equal to the hardcoded one we remove it from // kdeglobal if necessary and return. - if(cg.hasKey(info->name)) - cg.deleteEntry(info->name, KConfig::Global|KConfig::Persistent); + if (cg.hasKey(info->name)) { + cg.deleteEntry(info->name, KConfig::Global | KConfig::Persistent); + } return; } // Write the changed shortcut to kdeglobals - cg.writeEntry(info->name, QKeySequence::listToString(info->cut), KConfig::Global|KConfig::Persistent); + cg.writeEntry(info->name, QKeySequence::listToString(info->cut), KConfig::Global | KConfig::Persistent); } QString name(StandardShortcut id) @@ -256,42 +257,45 @@ QString name(StandardShortcut id) QString label(StandardShortcut id) { - KStandardShortcutInfo *info = guardedStandardShortcutInfo( id ); + KStandardShortcutInfo *info = guardedStandardShortcutInfo(id); return QCoreApplication::translate("KStandardShortcut", info->description, info->translation_context); } // TODO: Add psWhatsThis entry to KStandardShortcutInfo -QString whatsThis( StandardShortcut /*id*/ ) +QString whatsThis(StandardShortcut /*id*/) { // KStandardShortcutInfo* info = guardedStandardShortcutInfo( id ); // if( info && info->whatsThis ) // return i18n(info->whatsThis); // else - return QString(); + return QString(); } const QList<QKeySequence> &shortcut(StandardShortcut id) { KStandardShortcutInfo *info = guardedStandardShortcutInfo(id); - if(!info->isInitialized) + if (!info->isInitialized) { initialize(id); + } return info->cut; } StandardShortcut find(const QKeySequence &seq) { - if( !seq.isEmpty() ) { - for(uint i = 0; i < sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo); i++) { + if (!seq.isEmpty()) { + for (uint i = 0; i < sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo); i++) { StandardShortcut id = g_infoStandardShortcut[i].id; - if( id != AccelNone ) { - if(!g_infoStandardShortcut[i].isInitialized) + if (id != AccelNone) { + if (!g_infoStandardShortcut[i].isInitialized) { initialize(id); - if(g_infoStandardShortcut[i].cut.contains(seq)) + } + if (g_infoStandardShortcut[i].cut.contains(seq)) { return id; + } } } } @@ -300,9 +304,10 @@ StandardShortcut find(const QKeySequence &seq) StandardShortcut find(const char *keyName) { - for(uint i = 0; i < sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo); i++) - if (qstrcmp(g_infoStandardShortcut[i].name, keyName)) + for (uint i = 0; i < sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo); i++) + if (qstrcmp(g_infoStandardShortcut[i].name, keyName)) { return g_infoStandardShortcut[i].id; + } return AccelNone; } @@ -312,12 +317,14 @@ QList<QKeySequence> hardcodedDefaultShortcut(StandardShortcut id) QList<QKeySequence> cut; KStandardShortcutInfo *info = guardedStandardShortcutInfo(id); - if (info->cutDefault != 0) + if (info->cutDefault != 0) { cut << info->cutDefault; + } if (info->cutDefault2 != 0) { - if (cut.isEmpty()) + if (cut.isEmpty()) { cut << QKeySequence(); + } cut << info->cutDefault2; } @@ -325,53 +332,197 @@ QList<QKeySequence> hardcodedDefaultShortcut(StandardShortcut id) return cut; } -const QList<QKeySequence> &open() { return shortcut( Open ); } -const QList<QKeySequence> &openNew() { return shortcut( New ); } -const QList<QKeySequence> &close() { return shortcut( Close ); } -const QList<QKeySequence> &save() { return shortcut( Save ); } -const QList<QKeySequence> &print() { return shortcut( Print ); } -const QList<QKeySequence> &quit() { return shortcut( Quit ); } -const QList<QKeySequence> &cut() { return shortcut( Cut ); } -const QList<QKeySequence> ©() { return shortcut( Copy ); } -const QList<QKeySequence> &paste() { return shortcut( Paste ); } -const QList<QKeySequence> &pasteSelection() { return shortcut( PasteSelection ); } -const QList<QKeySequence> &deleteWordBack() { return shortcut( DeleteWordBack ); } -const QList<QKeySequence> &deleteWordForward() { return shortcut( DeleteWordForward ); } -const QList<QKeySequence> &undo() { return shortcut( Undo ); } -const QList<QKeySequence> &redo() { return shortcut( Redo ); } -const QList<QKeySequence> &find() { return shortcut( Find ); } -const QList<QKeySequence> &findNext() { return shortcut( FindNext ); } -const QList<QKeySequence> &findPrev() { return shortcut( FindPrev ); } -const QList<QKeySequence> &replace() { return shortcut( Replace ); } -const QList<QKeySequence> &home() { return shortcut( Home ); } -const QList<QKeySequence> &begin() { return shortcut( Begin ); } -const QList<QKeySequence> &end() { return shortcut( End ); } -const QList<QKeySequence> &beginningOfLine() { return shortcut( BeginningOfLine ); } -const QList<QKeySequence> &endOfLine() { return shortcut( EndOfLine ); } -const QList<QKeySequence> &prior() { return shortcut( Prior ); } -const QList<QKeySequence> &next() { return shortcut( Next ); } -const QList<QKeySequence> &backwardWord() { return shortcut( BackwardWord ); } -const QList<QKeySequence> &forwardWord() { return shortcut( ForwardWord ); } -const QList<QKeySequence> &gotoLine() { return shortcut( GotoLine ); } -const QList<QKeySequence> &addBookmark() { return shortcut( AddBookmark ); } -const QList<QKeySequence> &tabNext() { return shortcut( TabNext ); } -const QList<QKeySequence> &tabPrev() { return shortcut( TabPrev ); } -const QList<QKeySequence> &fullScreen() { return shortcut( FullScreen ); } -const QList<QKeySequence> &zoomIn() { return shortcut( ZoomIn ); } -const QList<QKeySequence> &zoomOut() { return shortcut( ZoomOut ); } -const QList<QKeySequence> &help() { return shortcut( Help ); } -const QList<QKeySequence> &completion() { return shortcut( TextCompletion ); } -const QList<QKeySequence> &prevCompletion() { return shortcut( PrevCompletion ); } -const QList<QKeySequence> &nextCompletion() { return shortcut( NextCompletion ); } -const QList<QKeySequence> &rotateUp() { return shortcut( RotateUp ); } -const QList<QKeySequence> &rotateDown() { return shortcut( RotateDown ); } -const QList<QKeySequence> &substringCompletion() { return shortcut( SubstringCompletion ); } -const QList<QKeySequence> &whatsThis() { return shortcut( WhatsThis ); } -const QList<QKeySequence> &reload() { return shortcut( Reload ); } -const QList<QKeySequence> &selectAll() { return shortcut( SelectAll ); } -const QList<QKeySequence> &up() { return shortcut( Up ); } -const QList<QKeySequence> &back() { return shortcut( Back ); } -const QList<QKeySequence> &forward() { return shortcut( Forward ); } -const QList<QKeySequence> &showMenubar() { return shortcut( ShowMenubar ); } +const QList<QKeySequence> &open() +{ + return shortcut(Open); +} +const QList<QKeySequence> &openNew() +{ + return shortcut(New); +} +const QList<QKeySequence> &close() +{ + return shortcut(Close); +} +const QList<QKeySequence> &save() +{ + return shortcut(Save); +} +const QList<QKeySequence> &print() +{ + return shortcut(Print); +} +const QList<QKeySequence> &quit() +{ + return shortcut(Quit); +} +const QList<QKeySequence> &cut() +{ + return shortcut(Cut); +} +const QList<QKeySequence> ©() +{ + return shortcut(Copy); +} +const QList<QKeySequence> &paste() +{ + return shortcut(Paste); +} +const QList<QKeySequence> &pasteSelection() +{ + return shortcut(PasteSelection); +} +const QList<QKeySequence> &deleteWordBack() +{ + return shortcut(DeleteWordBack); +} +const QList<QKeySequence> &deleteWordForward() +{ + return shortcut(DeleteWordForward); +} +const QList<QKeySequence> &undo() +{ + return shortcut(Undo); +} +const QList<QKeySequence> &redo() +{ + return shortcut(Redo); +} +const QList<QKeySequence> &find() +{ + return shortcut(Find); +} +const QList<QKeySequence> &findNext() +{ + return shortcut(FindNext); +} +const QList<QKeySequence> &findPrev() +{ + return shortcut(FindPrev); +} +const QList<QKeySequence> &replace() +{ + return shortcut(Replace); +} +const QList<QKeySequence> &home() +{ + return shortcut(Home); +} +const QList<QKeySequence> &begin() +{ + return shortcut(Begin); +} +const QList<QKeySequence> &end() +{ + return shortcut(End); +} +const QList<QKeySequence> &beginningOfLine() +{ + return shortcut(BeginningOfLine); +} +const QList<QKeySequence> &endOfLine() +{ + return shortcut(EndOfLine); +} +const QList<QKeySequence> &prior() +{ + return shortcut(Prior); +} +const QList<QKeySequence> &next() +{ + return shortcut(Next); +} +const QList<QKeySequence> &backwardWord() +{ + return shortcut(BackwardWord); +} +const QList<QKeySequence> &forwardWord() +{ + return shortcut(ForwardWord); +} +const QList<QKeySequence> &gotoLine() +{ + return shortcut(GotoLine); +} +const QList<QKeySequence> &addBookmark() +{ + return shortcut(AddBookmark); +} +const QList<QKeySequence> &tabNext() +{ + return shortcut(TabNext); +} +const QList<QKeySequence> &tabPrev() +{ + return shortcut(TabPrev); +} +const QList<QKeySequence> &fullScreen() +{ + return shortcut(FullScreen); +} +const QList<QKeySequence> &zoomIn() +{ + return shortcut(ZoomIn); +} +const QList<QKeySequence> &zoomOut() +{ + return shortcut(ZoomOut); +} +const QList<QKeySequence> &help() +{ + return shortcut(Help); +} +const QList<QKeySequence> &completion() +{ + return shortcut(TextCompletion); +} +const QList<QKeySequence> &prevCompletion() +{ + return shortcut(PrevCompletion); +} +const QList<QKeySequence> &nextCompletion() +{ + return shortcut(NextCompletion); +} +const QList<QKeySequence> &rotateUp() +{ + return shortcut(RotateUp); +} +const QList<QKeySequence> &rotateDown() +{ + return shortcut(RotateDown); +} +const QList<QKeySequence> &substringCompletion() +{ + return shortcut(SubstringCompletion); +} +const QList<QKeySequence> &whatsThis() +{ + return shortcut(WhatsThis); +} +const QList<QKeySequence> &reload() +{ + return shortcut(Reload); +} +const QList<QKeySequence> &selectAll() +{ + return shortcut(SelectAll); +} +const QList<QKeySequence> &up() +{ + return shortcut(Up); +} +const QList<QKeySequence> &back() +{ + return shortcut(Back); +} +const QList<QKeySequence> &forward() +{ + return shortcut(Forward); +} +const QList<QKeySequence> &showMenubar() +{ + return shortcut(ShowMenubar); +} } diff --git a/src/gui/kstandardshortcut.h b/src/gui/kstandardshortcut.h index b02a6ebf..5bb07fb9 100644 --- a/src/gui/kstandardshortcut.h +++ b/src/gui/kstandardshortcut.h @@ -33,29 +33,30 @@ * so do not hardcode the default behavior. */ namespace KStandardShortcut -{ // STUFF WILL BREAK IF YOU DON'T READ THIS!!! - /* - *Always add new std-accels to the end of this enum, never in the middle! - *Don't forget to add the corresponding entries in g_infoStandardShortcut[] in kstandardshortcut.cpp, too. - *Values of elements here and positions of the corresponding entries in - *the big array g_infoStandardShortcut[] ABSOLUTELY MUST BE THE SAME. - * !!! !!!! !!!!! !!!! - * !!!! !!! !!!! !!!! - * Remember to also update kdoctools/genshortcutents.cpp. - * - * Other Rules: - * - * - Never change the name of an existing shortcut - * - Never translate the name of a shortcut - */ - - /** - * Defines the identifier of all standard accelerators. - */ - enum StandardShortcut { +{ +// STUFF WILL BREAK IF YOU DON'T READ THIS!!! +/* + *Always add new std-accels to the end of this enum, never in the middle! + *Don't forget to add the corresponding entries in g_infoStandardShortcut[] in kstandardshortcut.cpp, too. + *Values of elements here and positions of the corresponding entries in + *the big array g_infoStandardShortcut[] ABSOLUTELY MUST BE THE SAME. + * !!! !!!! !!!!! !!!! + * !!!! !!! !!!! !!!! + * Remember to also update kdoctools/genshortcutents.cpp. + * + * Other Rules: + * + * - Never change the name of an existing shortcut + * - Never translate the name of a shortcut + */ + +/** + * Defines the identifier of all standard accelerators. + */ +enum StandardShortcut { //C++ requires that the value of an enum symbol be one more than the previous one. - //This means that everything will be well-ordered from here on. - AccelNone=0, + //This means that everything will be well-ordered from here on. + AccelNone = 0, // File menu Open, New, Close, Save, // The Print item @@ -116,366 +117,366 @@ namespace KStandardShortcut // Insert new items here! StandardShortcutCount // number of standard shortcuts - }; - - /** - * Returns the keybinding for @p accel. - * On X11, if QApplication was initialized with GUI disabled, the - * default keybinding will always be returned. - * @param id the id of the accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &shortcut(StandardShortcut id); - - /** - * Returns a unique name for the given accel. - * @param id the id of the accelerator - * @return the unique name of the accelerator - */ - KCONFIGGUI_EXPORT QString name(StandardShortcut id); - - /** - * Returns a localized label for user-visible display. - * @param id the id of the accelerator - * @return a localized label for the accelerator - */ - KCONFIGGUI_EXPORT QString label(StandardShortcut id); - - /** - * Returns an extended WhatsThis description for the given accelerator. - * @param id the id of the accelerator - * @return a localized description of the accelerator - */ - KCONFIGGUI_EXPORT QString whatsThis(StandardShortcut id); - - /** - * Return the StandardShortcut id of the standard accel action which - * uses this key sequence, or AccelNone if none of them do. - * This is used by class KKeyChooser. - * @param keySeq the key sequence to search - * @return the id of the standard accelerator, or AccelNone if there - * is none - */ - KCONFIGGUI_EXPORT StandardShortcut find(const QKeySequence &keySeq); - - /** - * Return the StandardShortcut id of the standard accel action which - * has \a keyName as its name, or AccelNone if none of them do. - * This is used by class KKeyChooser. - * @param keyName the key sequence to search - * @return the id of the standard accelerator, or AccelNone if there - * is none - */ - KCONFIGGUI_EXPORT StandardShortcut find(const char *keyName); - - /** - * Returns the hardcoded default shortcut for @p id. - * This does not take into account the user's configuration. - * @param id the id of the accelerator - * @return the default shortcut of the accelerator - */ - KCONFIGGUI_EXPORT QList<QKeySequence> hardcodedDefaultShortcut(StandardShortcut id); - - /** - * Saves the new shortcut \a cut for standard accel \a id. - */ - KCONFIGGUI_EXPORT void saveShortcut(StandardShortcut id, const QList<QKeySequence> &newShortcut); - - /** - * Open file. Default: Ctrl-o - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &open(); - - /** - * Create a new document (or whatever). Default: Ctrl-n - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &openNew(); - - /** - * Close current document. Default: Ctrl-w - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &close(); - - /** - * Save current document. Default: Ctrl-s - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &save(); - - /** - * Print current document. Default: Ctrl-p - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &print(); - - /** - * Quit the program. Default: Ctrl-q - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &quit(); - - /** - * Undo last operation. Default: Ctrl-z - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &undo(); - - /** - * Redo. Default: Shift-Ctrl-z - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &redo(); - - /** - * Cut selected area and store it in the clipboard. Default: Ctrl-x - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &cut(); - - /** - * Copy selected area into the clipboard. Default: Ctrl-c - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> ©(); - - /** - * Paste contents of clipboard at mouse/cursor position. Default: Ctrl-v - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &paste(); - - /** - * Paste the selection at mouse/cursor position. Default: Ctrl-Shift-Insert - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &pasteSelection(); - - /** - * Select all. Default: Ctrl-A - * @return the shortcut of the standard accelerator - **/ - KCONFIGGUI_EXPORT const QList<QKeySequence> &selectAll(); - - /** - * Delete a word back from mouse/cursor position. Default: Ctrl-Backspace - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteWordBack(); - - /** - * Delete a word forward from mouse/cursor position. Default: Ctrl-Delete - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteWordForward(); - - /** - * Find, search. Default: Ctrl-f - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &find(); - - /** - * Find/search next. Default: F3 - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &findNext(); - - /** - * Find/search previous. Default: Shift-F3 - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &findPrev(); - - /** - * Find and replace matches. Default: Ctrl-r - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &replace(); - - /** - * Zoom in. Default: Ctrl-Plus - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &zoomIn(); - - /** - * Zoom out. Default: Ctrl-Minus - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &zoomOut(); - - /** - * Toggle insert/overwrite (with visual feedback, e.g. in the statusbar). Default: Insert - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &insert(); - - /** - * Goto home page. Default: Alt-Home - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &home(); - - /** - * Goto beginning of the document. Default: Ctrl-Home - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &begin(); - - /** - * Goto end of the document. Default: Ctrl-End - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &end(); - - /** - * Goto beginning of current line. Default: Home - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &beginningOfLine(); - - /** - * Goto end of current line. Default: End - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &endOfLine(); - - /** - * Scroll up one page. Default: Prior - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &prior(); - - /** - * Scroll down one page. Default: Next - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &next(); - - /** - * Go to line. Default: Ctrl+G - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &gotoLine(); - - /** - * Add current page to bookmarks. Default: Ctrl+B - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &addBookmark(); - - /** - * Next Tab. Default: Ctrl-< - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &tabNext(); - - /** - * Previous Tab. Default: Ctrl-> - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &tabPrev(); - - /** - * Full Screen Mode. Default: Ctrl+Shift+F - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &fullScreen(); - - /** - * Help the user in the current situation. Default: F1 - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &help(); - - /** - * Complete text in input widgets. Default Ctrl+E - * @return the shortcut of the standard accelerator - **/ - KCONFIGGUI_EXPORT const QList<QKeySequence> &completion(); - - /** - * Iterate through a list when completion returns - * multiple items. Default: Ctrl+Up - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &prevCompletion(); - - /** - * Iterate through a list when completion returns - * multiple items. Default: Ctrl+Down - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &nextCompletion(); - - /** - * Find a string within another string or list of strings. - * Default: Ctrl-T - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &substringCompletion(); - - /** - * Help users iterate through a list of entries. Default: Up - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &rotateUp(); - - /** - * Help users iterate through a list of entries. Default: Down - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &rotateDown(); - - /** - * What's This button. Default: Shift+F1 - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &whatsThis(); - - /** - * Reload. Default: F5 - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &reload(); - - /** - * Up. Default: Alt+Up - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &up(); - - /** - * Back. Default: Alt+Left - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &back(); - - /** - * Forward. Default: ALT+Right - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &forward(); - - /** - * BackwardWord. Default: Ctrl+Left - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &backwardWord(); - - /** - * ForwardWord. Default: Ctrl+Right - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &forwardWord(); - - /** - * Show Menu Bar. Default: Ctrl-M - * @return the shortcut of the standard accelerator - */ - KCONFIGGUI_EXPORT const QList<QKeySequence> &showMenubar(); +}; + +/** + * Returns the keybinding for @p accel. + * On X11, if QApplication was initialized with GUI disabled, the + * default keybinding will always be returned. + * @param id the id of the accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &shortcut(StandardShortcut id); + +/** + * Returns a unique name for the given accel. + * @param id the id of the accelerator + * @return the unique name of the accelerator + */ +KCONFIGGUI_EXPORT QString name(StandardShortcut id); + +/** + * Returns a localized label for user-visible display. + * @param id the id of the accelerator + * @return a localized label for the accelerator + */ +KCONFIGGUI_EXPORT QString label(StandardShortcut id); + +/** + * Returns an extended WhatsThis description for the given accelerator. + * @param id the id of the accelerator + * @return a localized description of the accelerator + */ +KCONFIGGUI_EXPORT QString whatsThis(StandardShortcut id); + +/** + * Return the StandardShortcut id of the standard accel action which + * uses this key sequence, or AccelNone if none of them do. + * This is used by class KKeyChooser. + * @param keySeq the key sequence to search + * @return the id of the standard accelerator, or AccelNone if there + * is none + */ +KCONFIGGUI_EXPORT StandardShortcut find(const QKeySequence &keySeq); + +/** + * Return the StandardShortcut id of the standard accel action which + * has \a keyName as its name, or AccelNone if none of them do. + * This is used by class KKeyChooser. + * @param keyName the key sequence to search + * @return the id of the standard accelerator, or AccelNone if there + * is none + */ +KCONFIGGUI_EXPORT StandardShortcut find(const char *keyName); + +/** + * Returns the hardcoded default shortcut for @p id. + * This does not take into account the user's configuration. + * @param id the id of the accelerator + * @return the default shortcut of the accelerator + */ +KCONFIGGUI_EXPORT QList<QKeySequence> hardcodedDefaultShortcut(StandardShortcut id); + +/** + * Saves the new shortcut \a cut for standard accel \a id. + */ +KCONFIGGUI_EXPORT void saveShortcut(StandardShortcut id, const QList<QKeySequence> &newShortcut); + +/** + * Open file. Default: Ctrl-o + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &open(); + +/** + * Create a new document (or whatever). Default: Ctrl-n + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &openNew(); + +/** + * Close current document. Default: Ctrl-w + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &close(); + +/** + * Save current document. Default: Ctrl-s + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &save(); + +/** + * Print current document. Default: Ctrl-p + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &print(); + +/** + * Quit the program. Default: Ctrl-q + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &quit(); + +/** + * Undo last operation. Default: Ctrl-z + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &undo(); + +/** + * Redo. Default: Shift-Ctrl-z + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &redo(); + +/** + * Cut selected area and store it in the clipboard. Default: Ctrl-x + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &cut(); + +/** + * Copy selected area into the clipboard. Default: Ctrl-c + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> ©(); + +/** + * Paste contents of clipboard at mouse/cursor position. Default: Ctrl-v + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &paste(); + +/** + * Paste the selection at mouse/cursor position. Default: Ctrl-Shift-Insert + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &pasteSelection(); + +/** + * Select all. Default: Ctrl-A + * @return the shortcut of the standard accelerator + **/ +KCONFIGGUI_EXPORT const QList<QKeySequence> &selectAll(); + +/** + * Delete a word back from mouse/cursor position. Default: Ctrl-Backspace + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteWordBack(); + +/** + * Delete a word forward from mouse/cursor position. Default: Ctrl-Delete + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteWordForward(); + +/** + * Find, search. Default: Ctrl-f + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &find(); + +/** + * Find/search next. Default: F3 + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &findNext(); + +/** + * Find/search previous. Default: Shift-F3 + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &findPrev(); + +/** + * Find and replace matches. Default: Ctrl-r + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &replace(); + +/** + * Zoom in. Default: Ctrl-Plus + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &zoomIn(); + +/** + * Zoom out. Default: Ctrl-Minus + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &zoomOut(); + +/** + * Toggle insert/overwrite (with visual feedback, e.g. in the statusbar). Default: Insert + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &insert(); + +/** + * Goto home page. Default: Alt-Home + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &home(); + +/** + * Goto beginning of the document. Default: Ctrl-Home + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &begin(); + +/** + * Goto end of the document. Default: Ctrl-End + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &end(); + +/** + * Goto beginning of current line. Default: Home + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &beginningOfLine(); + +/** + * Goto end of current line. Default: End + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &endOfLine(); + +/** + * Scroll up one page. Default: Prior + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &prior(); + +/** + * Scroll down one page. Default: Next + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &next(); + +/** + * Go to line. Default: Ctrl+G + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &gotoLine(); + +/** + * Add current page to bookmarks. Default: Ctrl+B + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &addBookmark(); + +/** + * Next Tab. Default: Ctrl-< + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &tabNext(); + +/** + * Previous Tab. Default: Ctrl-> + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &tabPrev(); + +/** + * Full Screen Mode. Default: Ctrl+Shift+F + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &fullScreen(); + +/** + * Help the user in the current situation. Default: F1 + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &help(); + +/** + * Complete text in input widgets. Default Ctrl+E + * @return the shortcut of the standard accelerator + **/ +KCONFIGGUI_EXPORT const QList<QKeySequence> &completion(); + +/** + * Iterate through a list when completion returns + * multiple items. Default: Ctrl+Up + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &prevCompletion(); + +/** + * Iterate through a list when completion returns + * multiple items. Default: Ctrl+Down + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &nextCompletion(); + +/** + * Find a string within another string or list of strings. + * Default: Ctrl-T + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &substringCompletion(); + +/** + * Help users iterate through a list of entries. Default: Up + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &rotateUp(); + +/** + * Help users iterate through a list of entries. Default: Down + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &rotateDown(); + +/** + * What's This button. Default: Shift+F1 + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &whatsThis(); + +/** + * Reload. Default: F5 + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &reload(); + +/** + * Up. Default: Alt+Up + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &up(); + +/** + * Back. Default: Alt+Left + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &back(); + +/** + * Forward. Default: ALT+Right + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &forward(); + +/** + * BackwardWord. Default: Ctrl+Left + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &backwardWord(); + +/** + * ForwardWord. Default: Ctrl+Right + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &forwardWord(); + +/** + * Show Menu Bar. Default: Ctrl-M + * @return the shortcut of the standard accelerator + */ +KCONFIGGUI_EXPORT const QList<QKeySequence> &showMenubar(); } diff --git a/src/gui/kwindowconfig.cpp b/src/gui/kwindowconfig.cpp index 6b7ae5f0..c3cefb74 100644 --- a/src/gui/kwindowconfig.cpp +++ b/src/gui/kwindowconfig.cpp @@ -24,13 +24,14 @@ #include <QScreen> #include <QWindow> -static const char* s_initialSizePropertyName = "_kconfig_initial_size"; -static const char* s_initialScreenSizePropertyName = "_kconfig_initial_screen_size"; +static const char *s_initialSizePropertyName = "_kconfig_initial_size"; +static const char *s_initialScreenSizePropertyName = "_kconfig_initial_screen_size"; void KWindowConfig::saveWindowSize(const QWindow *window, KConfigGroup &config, KConfigGroup::WriteConfigFlags options) { - if (!window) + if (!window) { return; + } const QRect desk = window->screen()->geometry(); const QSize sizeToSave = window->size(); @@ -41,25 +42,27 @@ void KWindowConfig::saveWindowSize(const QWindow *window, KConfigGroup &config, if (!isMaximized) { const QSize defaultSize(window->property(s_initialSizePropertyName).toSize()); const QSize defaultScreenSize(window->property(s_initialScreenSizePropertyName).toSize()); - const bool sizeValid = defaultSize.isValid() && defaultScreenSize.isValid(); - if (!sizeValid || (sizeValid && (defaultSize != sizeToSave || defaultScreenSize != desk.size()))) { - const QString wString(QString::fromLatin1("Width %1").arg(desk.width())); - const QString hString(QString::fromLatin1("Height %1").arg(desk.height())); - config.writeEntry(wString, sizeToSave.width(), options); - config.writeEntry(hString, sizeToSave.height(), options); + const bool sizeValid = defaultSize.isValid() && defaultScreenSize.isValid(); + if (!sizeValid || (sizeValid && (defaultSize != sizeToSave || defaultScreenSize != desk.size()))) { + const QString wString(QString::fromLatin1("Width %1").arg(desk.width())); + const QString hString(QString::fromLatin1("Height %1").arg(desk.height())); + config.writeEntry(wString, sizeToSave.width(), options); + config.writeEntry(hString, sizeToSave.height(), options); } } - if ( (isMaximized == false) && !config.hasDefault(screenMaximizedString) ) + if ((isMaximized == false) && !config.hasDefault(screenMaximizedString)) { config.revertToDefault(screenMaximizedString); - else + } else { config.writeEntry(screenMaximizedString, isMaximized, options); + } } -void KWindowConfig::restoreWindowSize(QWindow* window, const KConfigGroup& config) +void KWindowConfig::restoreWindowSize(QWindow *window, const KConfigGroup &config) { - if (!window) + if (!window) { return; + } const QRect desk = window->screen()->geometry(); diff --git a/src/gui/kwindowconfig.h b/src/gui/kwindowconfig.h index 2c70571d..e21d3d61 100644 --- a/src/gui/kwindowconfig.h +++ b/src/gui/kwindowconfig.h @@ -29,30 +29,30 @@ class QWindow; namespace KWindowConfig { - /** - * Saves the window's size dependent on the screen dimension either to the - * global or application config file. - * - * @note the group must be set before calling - * - * @param window The window to save size. - * @param config The config group to read from. - * @param options passed to KConfigGroup::writeEntry() - * @since 5.0 - */ - KCONFIGGUI_EXPORT void saveWindowSize( const QWindow* window, KConfigGroup& config, KConfigGroup::WriteConfigFlags options = KConfigGroup::Normal ); - - /** - * Restores the dialog's size from the configuration according to - * the screen size. - * - * @note the group must be set before calling - * - * @param dialog The dialog to restore size. - * @param config The config group to read from. - * @since 5.0. - */ - KCONFIGGUI_EXPORT void restoreWindowSize( QWindow* window, const KConfigGroup& config ); +/** + * Saves the window's size dependent on the screen dimension either to the + * global or application config file. + * + * @note the group must be set before calling + * + * @param window The window to save size. + * @param config The config group to read from. + * @param options passed to KConfigGroup::writeEntry() + * @since 5.0 + */ +KCONFIGGUI_EXPORT void saveWindowSize(const QWindow *window, KConfigGroup &config, KConfigGroup::WriteConfigFlags options = KConfigGroup::Normal); + +/** + * Restores the dialog's size from the configuration according to + * the screen size. + * + * @note the group must be set before calling + * + * @param dialog The dialog to restore size. + * @param config The config group to read from. + * @since 5.0. + */ +KCONFIGGUI_EXPORT void restoreWindowSize(QWindow *window, const KConfigGroup &config); } #endif // KWINDOWCONFIG_H |