Hi,

I'm trying to port KAction to QAction.

The old codes something like below:
--------------------------
KShortcut cubeShortcut, cylinderShortcut;
KAction* cubeAction, * cylinderAction;

cubeShortcut = cubeAction->globalShortcut();
connect(cubeAction, SIGNAL(globalShortcutChanged(QKeySequence)), this,
SLOT(cubeShortcutChanged(QKeySequence)));

void cubeShortcutChanged(const QKeySequence& seq)
{
    cubeShortcut = KShortcut(seq);
}
---------------------------

Below are the new codes(simplified), but i have doubt how to use
globalShortcutChanged, and effectShortcutChanged properly.
---------------------------
QList<QKeySequence> cubeShortcut;
QList<QKeySequence> cylinderShortcut;

QAction* cubeAction;
QAction* cylinderAction;

//Set shortcut
KGlobalAccel::self()->setShortcut(cubeAction, QList<QKeySequence>() <<
Qt::CTRL + Qt::Key_F11);
KGlobalAccel::self()->setShortcut(cylinderAction, QList<QKeySequence>());

//Get shortcut in new way.
cubeShortcut = KGlobalAccel::self()->shortcut(cubeAction);
cylinderShortcut = KGlobalAccel::self()->shortcut(cylinderAction);

//Is this correct?, also if i have many QAction only one connect needed?
connect(KGlobalAccel::self(), SIGNAL(globalShortcutChanged(QAction *,
QKeySequence)), this, SLOT(effectShortcutChanged(QAction *, QKeySequence)));

//Is this correct?
void effectShortcutChanged(QAction * action, const QKeySequence& seq)
{
    if (action == cubeAction) {
        cubeShortcut = QList<QKeySequence>()  <<  seq;
    } else if (action == cylinderAction) {
        cubeShortcut = QList<QKeySequence>()  <<  seq;
    }
}
------------------------------
Regards,
Reza
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

Reply via email to