~ubuntu-branches/debian/sid/kde-style-qtcurve/sid

« back to all changes in this revision

Viewing changes to style/macmenu.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fathi Boudra
  • Date: 2009-10-11 14:35:38 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20091011143538-705l6lh4v46hiy5t
Tags: 0.69.2-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
173
173
    // register the menu via dbus
174
174
    QStringList entries;
175
175
    foreach (QAction* action, menu->actions())
176
 
        entries << action->text();
177
 
    
 
176
        if (action->isSeparator())
 
177
            entries << "<XBAR_SEPARATOR/>";
 
178
        else
 
179
            entries << action->text();
178
180
    xbar->call(QDBus::NoBlock, "registerMenu", service, (qlonglong)menu, title, entries);
179
181
    // TODO cause of now async call, the following should - maybe - attached to the above?!!
180
182
    if (menu->isActiveWindow())
321
323
            continue;
322
324
        disconnect (pop, SIGNAL(aboutToHide()), this, SLOT(menuClosed()));
323
325
        pop->hide();
 
326
//         menu->activateWindow();
 
327
        break;
324
328
    }
325
329
}
326
330
 
347
351
    }
348
352
}
349
353
 
 
354
static QMenuBar *bar4menu(QMenu *menu)
 
355
{
 
356
    if (!menu->menuAction())
 
357
        return 0;
 
358
    if (menu->menuAction()->associatedWidgets().isEmpty())
 
359
        return 0;
 
360
    foreach (QWidget *w, menu->menuAction()->associatedWidgets())
 
361
        if (qobject_cast<QMenuBar*>(w))
 
362
            return static_cast<QMenuBar *>(w);
 
363
    return 0;
 
364
}
 
365
 
350
366
void
351
367
MacMenu::menuClosed()
352
368
{
353
 
    if (!sender()) return;
 
369
    QObject * _sender = sender();
 
370
    
 
371
    if (!_sender)
 
372
        return;
 
373
 
354
374
    disconnect (sender(), SIGNAL(aboutToHide()), this, SLOT(menuClosed()));
355
375
    if (!inHover)
356
376
    {
357
377
        xbar->call(QDBus::NoBlock, "setOpenPopup", -500);
 
378
 
 
379
        if (QMenu *menu = qobject_cast<QMenu*>(_sender))
 
380
        if (QMenuBar *bar = bar4menu(menu))
 
381
            bar->activateWindow(); // CDP: QtCurve fix 'setActiveWindow' is in Qt3Support! ORIG: bar->setActiveWindow();
358
382
    }
359
383
}
360
384
 
362
386
MacMenu::changeAction(QMenuBar *menu, QActionEvent *ev)
363
387
{
364
388
    int idx;
 
389
    const QString title = ev->action()->isSeparator() ? "<XBAR_SEPARATOR/>" : ev->action()->text();
365
390
    if (ev->type() == QEvent::ActionAdded)
366
391
    {
367
392
        idx = ev->before() ? menu->actions().indexOf(ev->before())-1 : -1;
368
 
        xbar->call(QDBus::NoBlock, "addEntry", (qlonglong)menu, idx, ev->action()->text());
 
393
        xbar->call(QDBus::NoBlock, "addEntry", (qlonglong)menu, idx, title);
369
394
        actions[menu].insert(idx, ev->action());
370
395
        return;
371
396
    }
372
397
    if (ev->type() == QEvent::ActionChanged)
373
398
    {
374
399
        idx = menu->actions().indexOf(ev->action());
375
 
        xbar->call(QDBus::NoBlock, "changeEntry", (qlonglong)menu, idx, ev->action()->text());
 
400
        xbar->call(QDBus::NoBlock, "changeEntry", (qlonglong)menu, idx, title);
376
401
    }
377
402
    else
378
403
    { // remove