mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
kdeui: format and indent
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
97b1ea46c1
commit
2bf47096e8
10 changed files with 316 additions and 315 deletions
|
@ -75,12 +75,18 @@ ShortcutEditWidget::ShortcutEditWidget(QWidget *viewport, const QKeySequence &de
|
|||
|
||||
setKeySequence(activeSeq);
|
||||
|
||||
connect(m_defaultRadio, SIGNAL(toggled(bool)),
|
||||
this, SLOT(defaultToggled(bool)));
|
||||
connect(m_customEditor, SIGNAL(keySequenceChanged(QKeySequence)),
|
||||
this, SLOT(setCustom(QKeySequence)));
|
||||
connect(m_customEditor, SIGNAL(stealShortcut(QKeySequence,KAction*)),
|
||||
this, SIGNAL(stealShortcut(QKeySequence,KAction*)));
|
||||
connect(
|
||||
m_defaultRadio, SIGNAL(toggled(bool)),
|
||||
this, SLOT(defaultToggled(bool))
|
||||
);
|
||||
connect(
|
||||
m_customEditor, SIGNAL(keySequenceChanged(QKeySequence)),
|
||||
this, SLOT(setCustom(QKeySequence))
|
||||
);
|
||||
connect(
|
||||
m_customEditor, SIGNAL(stealShortcut(QKeySequence,KAction*)),
|
||||
this, SIGNAL(stealShortcut(QKeySequence,KAction*))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
@ -92,8 +98,9 @@ KKeySequenceWidget::ShortcutTypes ShortcutEditWidget::checkForConflictsAgainst()
|
|||
//slot
|
||||
void ShortcutEditWidget::defaultToggled(bool checked)
|
||||
{
|
||||
if (m_isUpdating)
|
||||
if (m_isUpdating) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_isUpdating = true;
|
||||
if (checked) {
|
||||
|
@ -116,8 +123,7 @@ void ShortcutEditWidget::defaultToggled(bool checked)
|
|||
}
|
||||
|
||||
|
||||
void ShortcutEditWidget::setCheckActionCollections(
|
||||
const QList<KActionCollection*> checkActionCollections)
|
||||
void ShortcutEditWidget::setCheckActionCollections(const QList<KActionCollection*> &checkActionCollections)
|
||||
{
|
||||
// We just forward them to out KKeySequenceWidget.
|
||||
m_customEditor->setCheckActionCollections(checkActionCollections);
|
||||
|
@ -130,7 +136,7 @@ void ShortcutEditWidget::setCheckForConflictsAgainst(KKeySequenceWidget::Shortcu
|
|||
}
|
||||
|
||||
|
||||
void ShortcutEditWidget::setComponentName(const QString componentName)
|
||||
void ShortcutEditWidget::setComponentName(const QString &componentName)
|
||||
{
|
||||
m_customEditor->setComponentName(componentName);
|
||||
}
|
||||
|
@ -169,7 +175,6 @@ void ShortcutEditWidget::setCustom(const QKeySequence &seq)
|
|||
m_isUpdating = false;
|
||||
}
|
||||
|
||||
|
||||
void ShortcutEditWidget::setKeySequence(const QKeySequence &activeSeq)
|
||||
{
|
||||
if (activeSeq == m_defaultLabel->text()) {
|
||||
|
@ -184,4 +189,3 @@ void ShortcutEditWidget::setKeySequence(const QKeySequence &activeSeq)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -95,23 +95,26 @@ KShortcutSchemesEditor::KShortcutSchemesEditor(KShortcutsDialog *parent)
|
|||
|
||||
void KShortcutSchemesEditor::newScheme()
|
||||
{
|
||||
bool ok;
|
||||
const QString newName = KInputDialog::getText(i18n("Name for New Scheme"),
|
||||
i18n("Name for new scheme:"), i18n("New Scheme"), &ok,this);
|
||||
if (!ok )
|
||||
bool ok = false;
|
||||
const QString newName = KInputDialog::getText(
|
||||
i18n("Name for New Scheme"),
|
||||
i18n("Name for new scheme:"), i18n("New Scheme"),
|
||||
&ok, this
|
||||
);
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_schemesList->findText(newName) != -1)
|
||||
{
|
||||
if (m_schemesList->findText(newName) != -1) {
|
||||
KMessageBox::sorry(this, i18n("A scheme with this name already exists."));
|
||||
return;
|
||||
}
|
||||
|
||||
const QString newSchemeFileName = KShortcutSchemesHelper::applicationShortcutSchemeFileName(newName);
|
||||
|
||||
QFile schemeFile(newSchemeFileName);
|
||||
if (!schemeFile.open(QFile::WriteOnly | QFile::Truncate))
|
||||
if (!schemeFile.open(QFile::WriteOnly | QFile::Truncate)) {
|
||||
return;
|
||||
}
|
||||
|
||||
QDomDocument doc;
|
||||
QDomElement docElem = doc.createElement("kpartgui");
|
||||
|
@ -142,8 +145,9 @@ Note that this will not remove any system wide shortcut schemes.", currentScheme
|
|||
foreach (KActionCollection *collection, m_dialog->actionCollections())
|
||||
{
|
||||
const KXMLGUIClient *client = collection->parentGUIClient();
|
||||
if (!client)
|
||||
if (!client) {
|
||||
continue;
|
||||
}
|
||||
QFile::remove(KShortcutSchemesHelper::shortcutSchemeFileName(client, currentScheme()));
|
||||
}
|
||||
|
||||
|
@ -161,15 +165,16 @@ void KShortcutSchemesEditor::exportShortcutsScheme()
|
|||
{
|
||||
// ask user about dir, it is not possible to use KFileDialog here because kfile links against
|
||||
// kdeui. the dialog gets replaced anyway with the KDE one at runtime
|
||||
QString exportTo = QFileDialog::getExistingDirectory(this, i18n("Export to Location"),
|
||||
QDir::currentPath());
|
||||
QString exportTo = QFileDialog::getExistingDirectory(
|
||||
this, i18n("Export to Location"),
|
||||
QDir::currentPath()
|
||||
);
|
||||
if (exportTo.isEmpty())
|
||||
return;
|
||||
|
||||
QDir schemeRoot(exportTo);
|
||||
|
||||
if (!schemeRoot.exists(exportTo))
|
||||
{
|
||||
if (!schemeRoot.exists(exportTo)) {
|
||||
KMessageBox::error(this, i18n("Could not export shortcuts scheme because the location is invalid."));
|
||||
return;
|
||||
}
|
||||
|
@ -177,20 +182,22 @@ void KShortcutSchemesEditor::exportShortcutsScheme()
|
|||
foreach (KActionCollection *collection, m_dialog->actionCollections())
|
||||
{
|
||||
const KXMLGUIClient *client = collection->parentGUIClient();
|
||||
if (!client) continue;
|
||||
KShortcutSchemesHelper::exportActionCollection(collection,
|
||||
currentScheme(), exportTo + '/');
|
||||
if (!client) {
|
||||
continue;
|
||||
}
|
||||
KShortcutSchemesHelper::exportActionCollection(collection, currentScheme(), exportTo + '/');
|
||||
}
|
||||
}
|
||||
|
||||
void KShortcutSchemesEditor::saveAsDefaultsForScheme()
|
||||
{
|
||||
foreach (KActionCollection *collection, m_dialog->actionCollections())
|
||||
foreach (KActionCollection *collection, m_dialog->actionCollections()) {
|
||||
KShortcutSchemesHelper::exportActionCollection(collection, currentScheme());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KShortcutSchemesEditor::updateDeleteButton()
|
||||
{
|
||||
m_deleteScheme->setEnabled(m_schemesList->count()>=1);
|
||||
m_deleteScheme->setEnabled(m_schemesList->count() >= 1);
|
||||
}
|
||||
|
|
|
@ -55,8 +55,10 @@ class KShortcutsDialog::KShortcutsDialogPrivate
|
|||
{
|
||||
public:
|
||||
|
||||
KShortcutsDialogPrivate(KShortcutsDialog *q): q(q), m_keyChooser(0), m_schemeEditor(0)
|
||||
{}
|
||||
KShortcutsDialogPrivate(KShortcutsDialog *q)
|
||||
: q(q), m_keyChooser(0), m_schemeEditor(0)
|
||||
{
|
||||
}
|
||||
|
||||
QList<KActionCollection*> m_collections;
|
||||
|
||||
|
@ -76,7 +78,7 @@ public:
|
|||
// passing an empty stream forces the clients to reread the XML
|
||||
KXMLGUIClient *client = const_cast<KXMLGUIClient *>(collection->parentGUIClient());
|
||||
if (client) {
|
||||
client->setXMLGUIBuildDocument( QDomDocument() );
|
||||
client->setXMLGUIBuildDocument(QDomDocument());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,28 +125,30 @@ KShortcutsDialog::KShortcutsDialog( KShortcutsEditor::ActionTypes types, KShortc
|
|||
setButtonText(KDialog::User1, i18n("Print"));
|
||||
setButtonIcon(KDialog::User1, KIcon("document-print"));
|
||||
setModal(true);
|
||||
d->m_keyChooser = new KShortcutsEditor( this, types, allowLetterShortcuts );
|
||||
d->m_keyChooser = new KShortcutsEditor(this, types, allowLetterShortcuts);
|
||||
setMainWidget( d->m_keyChooser );
|
||||
setButtonText(Reset,i18n("Reset to Defaults"));
|
||||
|
||||
d->m_schemeEditor = new KShortcutSchemesEditor(this);
|
||||
connect( d->m_schemeEditor, SIGNAL(shortcutsSchemeChanged(QString)),
|
||||
this, SLOT(changeShortcutScheme(QString)) );
|
||||
connect(
|
||||
d->m_schemeEditor, SIGNAL(shortcutsSchemeChanged(QString)),
|
||||
this, SLOT(changeShortcutScheme(QString))
|
||||
);
|
||||
setDetailsWidget(d->m_schemeEditor);
|
||||
|
||||
connect( this, SIGNAL(resetClicked()), d->m_keyChooser, SLOT(allDefault()) );
|
||||
connect( this, SIGNAL(user1Clicked()), d->m_keyChooser, SLOT(printShortcuts()) );
|
||||
connect(this, SIGNAL(resetClicked()), d->m_keyChooser, SLOT(allDefault()));
|
||||
connect(this, SIGNAL(user1Clicked()), d->m_keyChooser, SLOT(printShortcuts()));
|
||||
connect(this, SIGNAL(cancelClicked()), SLOT(undoChanges()));
|
||||
|
||||
KConfigGroup group( KGlobal::config(), "KShortcutsDialog Settings" );
|
||||
resize( group.readEntry( "Dialog Size", sizeHint() ) );
|
||||
KConfigGroup group(KGlobal::config(), "KShortcutsDialog Settings");
|
||||
resize(group.readEntry( "Dialog Size", sizeHint()));
|
||||
}
|
||||
|
||||
|
||||
KShortcutsDialog::~KShortcutsDialog()
|
||||
{
|
||||
KConfigGroup group( KGlobal::config(), "KShortcutsDialog Settings" );
|
||||
group.writeEntry( "Dialog Size", size(), KConfigGroup::Persistent|KConfigGroup::Global );
|
||||
KConfigGroup group(KGlobal::config(), "KShortcutsDialog Settings");
|
||||
group.writeEntry("Dialog Size", size(), KConfigGroup::Persistent|KConfigGroup::Global);
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
@ -155,7 +159,6 @@ void KShortcutsDialog::addCollection(KActionCollection *collection, const QStrin
|
|||
d->m_collections << collection;
|
||||
}
|
||||
|
||||
|
||||
QList<KActionCollection*> KShortcutsDialog::actionCollections() const
|
||||
{
|
||||
return d->m_collections;
|
||||
|
@ -193,5 +196,3 @@ int KShortcutsDialog::configure(KActionCollection *collection, KShortcutsEditor:
|
|||
|
||||
#include "moc_kshortcutsdialog.cpp"
|
||||
#include "moc_kshortcutsdialog_p.cpp"
|
||||
|
||||
//kate: space-indent on; indent-width 4; replace-tabs on;tab-width 4;
|
||||
|
|
|
@ -69,7 +69,6 @@
|
|||
class KDEUI_EXPORT KShortcutsDialog : public KDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructs a KShortcutsDialog as a child of @p parent.
|
||||
|
@ -121,8 +120,8 @@ public:
|
|||
*
|
||||
* @return Accept if the dialog was closed with OK, Reject otherwise.
|
||||
*/
|
||||
static int configure( KActionCollection *collection, KShortcutsEditor::LetterShortcuts allowLetterShortcuts =
|
||||
KShortcutsEditor::LetterShortcutsAllowed, QWidget* parent = 0, bool bSaveSettings = true);
|
||||
static int configure(KActionCollection *collection, KShortcutsEditor::LetterShortcuts allowLetterShortcuts =
|
||||
KShortcutsEditor::LetterShortcutsAllowed, QWidget *parent = 0, bool bSaveSettings = true);
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
|
@ -143,5 +142,3 @@ private:
|
|||
};
|
||||
|
||||
#endif // KSHORTCUTSDIALOG_H
|
||||
|
||||
//kate: space-indent off; indent-width 4; replace-tabs off;tab-width 4;
|
||||
|
|
|
@ -163,7 +163,7 @@ public:
|
|||
bool allowLetterShortcuts);
|
||||
|
||||
//! @see KKeySequenceWidget::setCheckActionCollections()
|
||||
void setCheckActionCollections( const QList<KActionCollection*> checkActionCollections);
|
||||
void setCheckActionCollections(const QList<KActionCollection*> &checkActionCollections);
|
||||
|
||||
|
||||
//@{
|
||||
|
@ -179,7 +179,7 @@ public:
|
|||
//@}
|
||||
|
||||
//! @see KKeySequenceWidget::setComponentName
|
||||
void setComponentName(const QString componentName);
|
||||
void setComponentName(const QString &componentName);
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
|
@ -334,7 +334,7 @@ public:
|
|||
KShortcutsEditorPrivate(KShortcutsEditor *q);
|
||||
|
||||
void initGUI( KShortcutsEditor::ActionTypes actionTypes, KShortcutsEditor::LetterShortcuts allowLetterShortcuts );
|
||||
void appendToView( uint nList, const QString &title = QString() );
|
||||
void appendToView(uint nList, const QString &title = QString());
|
||||
//used in appendToView
|
||||
QTreeWidgetItem *findOrMakeItem(QTreeWidgetItem *parent, const QString &name);
|
||||
|
||||
|
@ -369,7 +369,7 @@ public:
|
|||
|
||||
void printShortcuts() const;
|
||||
|
||||
// members
|
||||
// members
|
||||
QList<KActionCollection *> actionCollections;
|
||||
KShortcutsEditor *q;
|
||||
|
||||
|
@ -380,9 +380,6 @@ public:
|
|||
|
||||
};
|
||||
|
||||
|
||||
Q_DECLARE_METATYPE(KShortcutsEditorItem *)
|
||||
Q_DECLARE_METATYPE(KShortcutsEditorItem*)
|
||||
|
||||
#endif /* KSHORTCUTSDIALOG_P_H */
|
||||
|
||||
//kate: space-indent on; indent-width 4; replace-tabs on;tab-width 4;
|
||||
|
|
|
@ -56,28 +56,25 @@
|
|||
|
||||
KShortcutsEditor::KShortcutsEditor(KActionCollection *collection, QWidget *parent, ActionTypes actionType,
|
||||
LetterShortcuts allowLetterShortcuts )
|
||||
: QWidget( parent )
|
||||
, d(new KShortcutsEditorPrivate(this))
|
||||
: QWidget(parent),
|
||||
d(new KShortcutsEditorPrivate(this))
|
||||
{
|
||||
d->initGUI(actionType, allowLetterShortcuts);
|
||||
addCollection(collection);
|
||||
}
|
||||
|
||||
|
||||
KShortcutsEditor::KShortcutsEditor(QWidget *parent, ActionTypes actionType, LetterShortcuts allowLetterShortcuts)
|
||||
: QWidget(parent)
|
||||
, d(new KShortcutsEditorPrivate(this))
|
||||
: QWidget(parent),
|
||||
d(new KShortcutsEditorPrivate(this))
|
||||
{
|
||||
d->initGUI(actionType, allowLetterShortcuts);
|
||||
}
|
||||
|
||||
|
||||
KShortcutsEditor::~KShortcutsEditor()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
bool KShortcutsEditor::isModified() const
|
||||
{
|
||||
// Iterate over all items
|
||||
|
@ -167,46 +164,38 @@ void KShortcutsEditor::addCollection(KActionCollection *collection, const QStrin
|
|||
QTimer::singleShot(0, this, SLOT(resizeColumns()));
|
||||
}
|
||||
|
||||
|
||||
void KShortcutsEditor::clearConfiguration()
|
||||
{
|
||||
d->clearConfiguration();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void KShortcutsEditor::importConfiguration( KConfigBase *config)
|
||||
void KShortcutsEditor::importConfiguration(KConfigBase *config)
|
||||
{
|
||||
d->importConfiguration(config);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void KShortcutsEditor::exportConfiguration( KConfigBase *config) const
|
||||
void KShortcutsEditor::exportConfiguration(KConfigBase *config) const
|
||||
{
|
||||
Q_ASSERT(config);
|
||||
if (!config) return;
|
||||
|
||||
if (d->actionTypes & KShortcutsEditor::GlobalAction) {
|
||||
QString groupName = "Global Shortcuts";
|
||||
KConfigGroup group( config, groupName );
|
||||
KConfigGroup group(config, groupName);
|
||||
foreach (KActionCollection* collection, d->actionCollections) {
|
||||
collection->exportGlobalShortcuts( &group, true );
|
||||
collection->exportGlobalShortcuts(&group, true);
|
||||
}
|
||||
}
|
||||
if (d->actionTypes & ~KShortcutsEditor::GlobalAction) {
|
||||
QString groupName = "Shortcuts";
|
||||
KConfigGroup group( config, groupName );
|
||||
KConfigGroup group(config, groupName);
|
||||
foreach (KActionCollection* collection, d->actionCollections) {
|
||||
collection->writeSettings( &group, true );
|
||||
collection->writeSettings(&group, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KShortcutsEditor::writeConfiguration( KConfigGroup *config) const
|
||||
void KShortcutsEditor::writeConfiguration(KConfigGroup *config) const
|
||||
{
|
||||
foreach (KActionCollection* collection, d->actionCollections)
|
||||
collection->writeSettings(config);
|
||||
|
@ -230,7 +219,6 @@ void KShortcutsEditor::commit()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void KShortcutsEditor::save()
|
||||
{
|
||||
writeConfiguration();
|
||||
|
@ -241,7 +229,6 @@ void KShortcutsEditor::save()
|
|||
commit();
|
||||
}
|
||||
|
||||
|
||||
// KDE5 : rename to undo()
|
||||
void KShortcutsEditor::undoChanges()
|
||||
{
|
||||
|
@ -264,23 +251,23 @@ void KShortcutsEditor::allDefault()
|
|||
d->allDefault();
|
||||
}
|
||||
|
||||
|
||||
void KShortcutsEditor::printShortcuts() const
|
||||
{
|
||||
d->printShortcuts();
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// KShortcutsEditorPrivate
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
KShortcutsEditorPrivate::KShortcutsEditorPrivate( KShortcutsEditor *q )
|
||||
KShortcutsEditorPrivate::KShortcutsEditorPrivate(KShortcutsEditor *q)
|
||||
: q(q),
|
||||
delegate(0)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
void KShortcutsEditorPrivate::initGUI( KShortcutsEditor::ActionTypes types, KShortcutsEditor::LetterShortcuts allowLetterShortcuts )
|
||||
void KShortcutsEditorPrivate::initGUI(KShortcutsEditor::ActionTypes types,
|
||||
KShortcutsEditor::LetterShortcuts allowLetterShortcuts)
|
||||
{
|
||||
actionTypes = types;
|
||||
|
||||
|
@ -288,7 +275,7 @@ void KShortcutsEditorPrivate::initGUI( KShortcutsEditor::ActionTypes types, KSho
|
|||
q->layout()->setMargin(0);
|
||||
ui.searchFilter->searchLine()->setTreeWidget(ui.list); // Plug into search line
|
||||
ui.list->header()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
ui.list->header()->hideSection(GlobalAlternate); //not expected to be very useful
|
||||
ui.list->header()->hideSection(GlobalAlternate); // not expected to be very useful
|
||||
if (!(actionTypes & KShortcutsEditor::GlobalAction)) {
|
||||
ui.list->header()->hideSection(GlobalPrimary);
|
||||
} else if (!(actionTypes & ~KShortcutsEditor::GlobalAction)) {
|
||||
|
@ -300,7 +287,8 @@ void KShortcutsEditorPrivate::initGUI( KShortcutsEditor::ActionTypes types, KSho
|
|||
// really change the shortcuts.
|
||||
delegate = new KShortcutsEditorDelegate(
|
||||
ui.list,
|
||||
allowLetterShortcuts == KShortcutsEditor::LetterShortcutsAllowed);
|
||||
allowLetterShortcuts == KShortcutsEditor::LetterShortcutsAllowed
|
||||
);
|
||||
|
||||
ui.list->setItemDelegate(delegate);
|
||||
ui.list->setSelectionBehavior(QAbstractItemView::SelectItems);
|
||||
|
@ -310,16 +298,19 @@ void KShortcutsEditorPrivate::initGUI( KShortcutsEditor::ActionTypes types, KSho
|
|||
ui.list->setAlternatingRowColors(true);
|
||||
|
||||
//TODO listen to changes to global shortcuts
|
||||
QObject::connect(delegate, SIGNAL(shortcutChanged(QVariant,QModelIndex)),
|
||||
q, SLOT(capturedShortcut(QVariant,QModelIndex)));
|
||||
QObject::connect(
|
||||
delegate, SIGNAL(shortcutChanged(QVariant,QModelIndex)),
|
||||
q, SLOT(capturedShortcut(QVariant,QModelIndex))
|
||||
);
|
||||
//hide the editor widget chen its item becomes hidden
|
||||
QObject::connect(ui.searchFilter->searchLine(), SIGNAL(hiddenChanged(QTreeWidgetItem*,bool)),
|
||||
delegate, SLOT(hiddenBySearchLine(QTreeWidgetItem*,bool)));
|
||||
QObject::connect(
|
||||
ui.searchFilter->searchLine(), SIGNAL(hiddenChanged(QTreeWidgetItem*,bool)),
|
||||
delegate, SLOT(hiddenBySearchLine(QTreeWidgetItem*,bool))
|
||||
);
|
||||
|
||||
ui.searchFilter->setFocus();
|
||||
}
|
||||
|
||||
|
||||
bool KShortcutsEditorPrivate::addAction(QAction *action, QTreeWidgetItem *hier[], hierarchyLevel level)
|
||||
{
|
||||
// If the action name starts with unnamed- spit out a warning and ignore
|
||||
|
@ -345,8 +336,9 @@ bool KShortcutsEditorPrivate::addAction(QAction *action, QTreeWidgetItem *hier[]
|
|||
void KShortcutsEditorPrivate::allDefault()
|
||||
{
|
||||
for (QTreeWidgetItemIterator it(ui.list); (*it); ++it) {
|
||||
if (!(*it)->parent() || (*it)->type() != ActionItem)
|
||||
if (!(*it)->parent() || (*it)->type() != ActionItem) {
|
||||
continue;
|
||||
}
|
||||
|
||||
KShortcutsEditorItem *item = static_cast<KShortcutsEditorItem *>(*it);
|
||||
KAction *act = item->m_action;
|
||||
|
@ -379,9 +371,10 @@ QTreeWidgetItem *KShortcutsEditorPrivate::findOrMakeItem(QTreeWidgetItem *parent
|
|||
{
|
||||
for (int i = 0; i < parent->childCount(); i++) {
|
||||
QTreeWidgetItem *child = parent->child(i);
|
||||
if (child->text(0) == name)
|
||||
if (child->text(0) == name) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
QTreeWidgetItem *ret = new QTreeWidgetItem(parent, NonActionItem);
|
||||
ret->setText(0, name);
|
||||
ui.list->expandItem(ret);
|
||||
|
@ -394,14 +387,16 @@ QTreeWidgetItem *KShortcutsEditorPrivate::findOrMakeItem(QTreeWidgetItem *parent
|
|||
void KShortcutsEditorPrivate::capturedShortcut(const QVariant &newShortcut, const QModelIndex &index)
|
||||
{
|
||||
//dispatch to the right handler
|
||||
if (!index.isValid())
|
||||
if (!index.isValid()) {
|
||||
return;
|
||||
}
|
||||
int column = index.column();
|
||||
KShortcutsEditorItem *item = itemFromIndex(ui.list, index);
|
||||
Q_ASSERT(item);
|
||||
|
||||
if (column >= LocalPrimary && column <= GlobalAlternate)
|
||||
if (column >= LocalPrimary && column <= GlobalAlternate) {
|
||||
changeKeyShortcut(item, column, newShortcut.value<QKeySequence>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -422,8 +417,9 @@ void KShortcutsEditorPrivate::changeKeyShortcut(KShortcutsEditorItem *item, uint
|
|||
void KShortcutsEditorPrivate::clearConfiguration()
|
||||
{
|
||||
for (QTreeWidgetItemIterator it(ui.list); (*it); ++it) {
|
||||
if (!(*it)->parent())
|
||||
if (!(*it)->parent()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
KShortcutsEditorItem *item = static_cast<KShortcutsEditorItem *>(*it);
|
||||
|
||||
|
@ -445,12 +441,11 @@ void KShortcutsEditorPrivate::importConfiguration(KConfigBase *config)
|
|||
if ((actionTypes & KShortcutsEditor::GlobalAction) && globalShortcutsGroup.exists()) {
|
||||
|
||||
for (QTreeWidgetItemIterator it(ui.list); (*it); ++it) {
|
||||
|
||||
if (!(*it)->parent())
|
||||
if (!(*it)->parent()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
KShortcutsEditorItem *item = static_cast<KShortcutsEditorItem *>(*it);
|
||||
|
||||
QString actionName = item->data(Id).toString();
|
||||
KShortcut sc(globalShortcutsGroup.readEntry(actionName, QString()));
|
||||
changeKeyShortcut(item, GlobalPrimary, sc.primary());
|
||||
|
@ -459,14 +454,12 @@ void KShortcutsEditorPrivate::importConfiguration(KConfigBase *config)
|
|||
|
||||
KConfigGroup localShortcutsGroup(config, QLatin1String("Shortcuts"));
|
||||
if (actionTypes & ~KShortcutsEditor::GlobalAction) {
|
||||
|
||||
for (QTreeWidgetItemIterator it(ui.list); (*it); ++it) {
|
||||
|
||||
if (!(*it)->parent())
|
||||
if (!(*it)->parent()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
KShortcutsEditorItem *item = static_cast<KShortcutsEditorItem *>(*it);
|
||||
|
||||
QString actionName = item->data(Name).toString();
|
||||
KShortcut sc(localShortcutsGroup.readEntry(actionName, QString()));
|
||||
changeKeyShortcut(item, LocalPrimary, sc.primary());
|
||||
|
@ -504,9 +497,13 @@ void KShortcutsEditorPrivate::printShortcuts() const
|
|||
QTextCharFormat headerFormat;
|
||||
headerFormat.setProperty(QTextFormat::FontSizeAdjustment, 3);
|
||||
headerFormat.setFontWeight(QFont::Bold);
|
||||
cursor.insertText(i18nc("header for an applications shortcut list","Shortcuts for %1",
|
||||
KGlobal::mainComponent().aboutData()->programName()),
|
||||
headerFormat);
|
||||
cursor.insertText(
|
||||
i18nc(
|
||||
"header for an applications shortcut list","Shortcuts for %1",
|
||||
KGlobal::mainComponent().aboutData()->programName()
|
||||
),
|
||||
headerFormat
|
||||
);
|
||||
QTextCharFormat componentFormat;
|
||||
componentFormat.setProperty(QTextFormat::FontSizeAdjustment, 2);
|
||||
componentFormat.setFontWeight(QFont::Bold);
|
||||
|
@ -551,8 +548,9 @@ void KShortcutsEditorPrivate::printShortcuts() const
|
|||
currow++;
|
||||
|
||||
for (QTreeWidgetItemIterator it(item); *it; ++it) {
|
||||
if ((*it)->type() != ActionItem)
|
||||
if ((*it)->type() != ActionItem) {
|
||||
continue;
|
||||
}
|
||||
|
||||
KShortcutsEditorItem* editoritem = static_cast<KShortcutsEditorItem*>(*it);
|
||||
table->insertRows(table->rows(),1);
|
||||
|
@ -565,7 +563,7 @@ void KShortcutsEditorPrivate::printShortcuts() const
|
|||
QString key = data.value<QKeySequence>().toString();
|
||||
|
||||
if(!key.isEmpty()) {
|
||||
if( !shortcutTable ) {
|
||||
if (!shortcutTable) {
|
||||
shortcutTable = table->cellAt(currow, 1).firstCursorPosition().insertTable(1,2);
|
||||
QTextTableFormat shortcutTableFormat = tableformat;
|
||||
shortcutTableFormat.setCellSpacing(0.0);
|
||||
|
|
|
@ -61,7 +61,6 @@ class KShortcutsEditorPrivate;
|
|||
class KDEUI_EXPORT KShortcutsEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum ActionType {
|
||||
/// Actions which are triggered by any keypress in a widget which has the action added to it
|
||||
|
@ -96,7 +95,9 @@ public:
|
|||
* @param allowLetterShortcuts set to LetterShortcutsDisallowed if unmodified alphanumeric
|
||||
* keys ('A', '1', etc.) are not permissible shortcuts.
|
||||
*/
|
||||
KShortcutsEditor(KActionCollection *collection, QWidget *parent, ActionTypes actionTypes = AllActions, LetterShortcuts allowLetterShortcuts = LetterShortcutsAllowed);
|
||||
KShortcutsEditor(KActionCollection *collection, QWidget *parent,
|
||||
ActionTypes actionTypes = AllActions,
|
||||
LetterShortcuts allowLetterShortcuts = LetterShortcutsAllowed);
|
||||
|
||||
/**
|
||||
* \overload
|
||||
|
@ -108,7 +109,8 @@ public:
|
|||
* @param allowLetterShortcuts set to LetterShortcutsDisallowed if unmodified alphanumeric
|
||||
* keys ('A', '1', etc.) are not permissible shortcuts.
|
||||
*/
|
||||
explicit KShortcutsEditor( QWidget* parent, ActionTypes actionTypes = AllActions, LetterShortcuts allowLetterShortcuts = LetterShortcutsAllowed );
|
||||
explicit KShortcutsEditor(QWidget* parent, ActionTypes actionTypes = AllActions,
|
||||
LetterShortcuts allowLetterShortcuts = LetterShortcutsAllowed);
|
||||
|
||||
/// Destructor
|
||||
virtual ~KShortcutsEditor();
|
||||
|
@ -155,7 +157,6 @@ public:
|
|||
*/
|
||||
void commit();
|
||||
|
||||
|
||||
/**
|
||||
* Removes all configured shortcuts.
|
||||
*/
|
||||
|
@ -175,7 +176,7 @@ public:
|
|||
* applications config object
|
||||
*
|
||||
*/
|
||||
void writeConfiguration( KConfigGroup* config = 0 ) const;
|
||||
void writeConfiguration(KConfigGroup* config = 0 ) const;
|
||||
|
||||
/**
|
||||
* Export the current setting to configuration @p config.
|
||||
|
@ -185,7 +186,7 @@ public:
|
|||
*
|
||||
* @param config Config object
|
||||
*/
|
||||
void exportConfiguration( KConfigBase *config) const;
|
||||
void exportConfiguration(KConfigBase *config) const;
|
||||
|
||||
/**
|
||||
* Import the settings from configuration @p config.
|
||||
|
@ -195,7 +196,7 @@ public:
|
|||
*
|
||||
* @param config Config object
|
||||
*/
|
||||
void importConfiguration( KConfigBase *config);
|
||||
void importConfiguration(KConfigBase *config);
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
|
|
|
@ -35,11 +35,11 @@
|
|||
#include <QtGui/qtreewidget.h>
|
||||
|
||||
KShortcutsEditorItem::KShortcutsEditorItem(QTreeWidgetItem *parent, KAction *action)
|
||||
: QTreeWidgetItem(parent, ActionItem)
|
||||
, m_action(action)
|
||||
, m_isNameBold(false)
|
||||
, m_oldLocalShortcut(0)
|
||||
, m_oldGlobalShortcut(0)
|
||||
: QTreeWidgetItem(parent, ActionItem),
|
||||
m_action(action),
|
||||
m_isNameBold(false),
|
||||
m_oldLocalShortcut(0),
|
||||
m_oldGlobalShortcut(0)
|
||||
{
|
||||
// Filtering message requested by translators (scripting).
|
||||
m_id = m_action->objectName();
|
||||
|
@ -234,19 +234,21 @@ bool KShortcutsEditorItem::isModified(uint column) const
|
|||
return false;
|
||||
case LocalPrimary:
|
||||
case LocalAlternate:
|
||||
if (!m_oldLocalShortcut)
|
||||
if (!m_oldLocalShortcut) {
|
||||
return false;
|
||||
if (column == LocalPrimary)
|
||||
}
|
||||
if (column == LocalPrimary) {
|
||||
return m_oldLocalShortcut->primary() != m_action->shortcut().primary();
|
||||
else
|
||||
}
|
||||
return m_oldLocalShortcut->alternate() != m_action->shortcut().alternate();
|
||||
case GlobalPrimary:
|
||||
case GlobalAlternate:
|
||||
if (!m_oldGlobalShortcut)
|
||||
if (!m_oldGlobalShortcut) {
|
||||
return false;
|
||||
if (column == GlobalPrimary)
|
||||
}
|
||||
if (column == GlobalPrimary) {
|
||||
return m_oldGlobalShortcut->primary() != m_action->globalShortcut().primary();
|
||||
else
|
||||
}
|
||||
return m_oldGlobalShortcut->alternate() != m_action->globalShortcut().alternate();
|
||||
default:
|
||||
return false;
|
||||
|
@ -268,8 +270,7 @@ void KShortcutsEditorItem::undo()
|
|||
}
|
||||
|
||||
if (m_oldGlobalShortcut) {
|
||||
m_action->setGlobalShortcut(*m_oldGlobalShortcut, KAction::ActiveShortcut,
|
||||
KAction::NoAutoloading);
|
||||
m_action->setGlobalShortcut(*m_oldGlobalShortcut, KAction::ActiveShortcut, KAction::NoAutoloading);
|
||||
}
|
||||
|
||||
updateModified();
|
||||
|
|
|
@ -53,14 +53,14 @@ const QDBusArgument &operator>> (const QDBusArgument &argument, KGlobalShortcutI
|
|||
>> shortcut.d->contextFriendlyName;
|
||||
argument.beginArray();
|
||||
while (!argument.atEnd()) {
|
||||
int key;
|
||||
int key = 0;
|
||||
argument >> key;
|
||||
shortcut.d->keys.append(QKeySequence(key));
|
||||
}
|
||||
argument.endArray();
|
||||
argument.beginArray();
|
||||
while (!argument.atEnd()) {
|
||||
int key;
|
||||
int key = 0;
|
||||
argument >> key;
|
||||
shortcut.d->defaultKeys.append(QKeySequence(key));
|
||||
}
|
||||
|
|
|
@ -26,11 +26,11 @@ class KShortcutWidgetPrivate
|
|||
public:
|
||||
KShortcutWidgetPrivate(KShortcutWidget *q) : q(q) {}
|
||||
|
||||
//private slots
|
||||
// private slots
|
||||
void priKeySequenceChanged(const QKeySequence &);
|
||||
void altKeySequenceChanged(const QKeySequence &);
|
||||
|
||||
//members
|
||||
// members
|
||||
KShortcutWidget *const q;
|
||||
Ui::KShortcutWidget ui;
|
||||
KShortcut cut;
|
||||
|
@ -44,10 +44,14 @@ KShortcutWidget::KShortcutWidget(QWidget *parent)
|
|||
{
|
||||
d->holdChangedSignal = false;
|
||||
d->ui.setupUi(this);
|
||||
connect(d->ui.priEditor, SIGNAL(keySequenceChanged(QKeySequence)),
|
||||
this, SLOT(priKeySequenceChanged(QKeySequence)));
|
||||
connect(d->ui.altEditor, SIGNAL(keySequenceChanged(QKeySequence)),
|
||||
this, SLOT(altKeySequenceChanged(QKeySequence)));
|
||||
connect(
|
||||
d->ui.priEditor, SIGNAL(keySequenceChanged(QKeySequence)),
|
||||
this, SLOT(priKeySequenceChanged(QKeySequence))
|
||||
);
|
||||
connect(
|
||||
d->ui.altEditor, SIGNAL(keySequenceChanged(QKeySequence)),
|
||||
this, SLOT(altKeySequenceChanged(QKeySequence))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,7 +60,6 @@ KShortcutWidget::~KShortcutWidget()
|
|||
delete d;
|
||||
}
|
||||
|
||||
|
||||
void KShortcutWidget::setModifierlessAllowed(bool allow)
|
||||
{
|
||||
d->ui.priEditor->setModifierlessAllowed(allow);
|
||||
|
@ -69,14 +72,12 @@ bool KShortcutWidget::isModifierlessAllowed()
|
|||
return d->ui.priEditor->isModifierlessAllowed();
|
||||
}
|
||||
|
||||
|
||||
void KShortcutWidget::setClearButtonsShown(bool show)
|
||||
{
|
||||
d->ui.priEditor->setClearButtonShown(show);
|
||||
d->ui.altEditor->setClearButtonShown(show);
|
||||
}
|
||||
|
||||
|
||||
KShortcut KShortcutWidget::shortcut() const
|
||||
{
|
||||
KShortcut ret;
|
||||
|
@ -85,26 +86,23 @@ KShortcut KShortcutWidget::shortcut() const
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void KShortcutWidget::setCheckActionCollections(const QList<KActionCollection *>& actionCollections)
|
||||
void KShortcutWidget::setCheckActionCollections(const QList<KActionCollection *> &actionCollections)
|
||||
{
|
||||
d->ui.priEditor->setCheckActionCollections(actionCollections);
|
||||
d->ui.altEditor->setCheckActionCollections(actionCollections);
|
||||
}
|
||||
|
||||
//slot
|
||||
void KShortcutWidget::applyStealShortcut()
|
||||
{
|
||||
d->ui.priEditor->applyStealShortcut();
|
||||
d->ui.altEditor->applyStealShortcut();
|
||||
}
|
||||
|
||||
|
||||
//slot
|
||||
void KShortcutWidget::setShortcut(const KShortcut &newSc)
|
||||
{
|
||||
if (newSc == d->cut)
|
||||
if (newSc == d->cut) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->holdChangedSignal = true;
|
||||
d->ui.priEditor->setKeySequence(newSc.primary());
|
||||
|
@ -114,29 +112,26 @@ void KShortcutWidget::setShortcut(const KShortcut &newSc)
|
|||
emit shortcutChanged(d->cut);
|
||||
}
|
||||
|
||||
|
||||
//slot
|
||||
void KShortcutWidget::clearShortcut()
|
||||
{
|
||||
setShortcut(KShortcut());
|
||||
}
|
||||
|
||||
|
||||
//private slot
|
||||
void KShortcutWidgetPrivate::priKeySequenceChanged(const QKeySequence &seq)
|
||||
{
|
||||
cut.setPrimary(seq);
|
||||
if (!holdChangedSignal)
|
||||
if (!holdChangedSignal) {
|
||||
emit q->shortcutChanged(cut);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//private slot
|
||||
void KShortcutWidgetPrivate::altKeySequenceChanged(const QKeySequence &seq)
|
||||
{
|
||||
cut.setAlternate(seq);
|
||||
if (!holdChangedSignal)
|
||||
if (!holdChangedSignal) {
|
||||
emit q->shortcutChanged(cut);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_kshortcutwidget.cpp"
|
||||
|
|
Loading…
Add table
Reference in a new issue