23#define INCLUDE_MENUITEM_DEF 
   24#include <tqmenudata.h> 
   28#include "kcheckaccelerators.h" 
   29#include "tdeaccelmanager.h" 
   30#include <tqpopupmenu.h> 
   31#include <tqapplication.h> 
   34#include <tqtextview.h> 
   35#include <tqobjectlist.h> 
   38#include <tqpushbutton.h> 
   39#include <tqmetaobject.h> 
   40#include <tqcheckbox.h> 
   45#include <tdeshortcut.h> 
   79KCheckAccelerators::KCheckAccelerators( TQObject* parent )
 
   80    : TQObject( parent, 
"kapp_accel_filter" ), 
key(0), block( false ), drklash(0)
 
   82    parent->installEventFilter( 
this );
 
   85    if( !sKey.isEmpty() ) {
 
   87      if( cuts.count() > 0 )
 
   88        key = int(cuts.seq(0).qt());
 
   92    connect( &autoCheckTimer, TQ_SIGNAL( timeout()), TQ_SLOT( autoCheckSlot()));
 
   95bool KCheckAccelerators::eventFilter( TQObject * , TQEvent * e)
 
  100    switch ( e->type() ) { 
 
  102        if ( key && (
static_cast<TQKeyEvent*
>(e)->
key() == key) ) {
 
  104        checkAccelerators( 
false );
 
  106        static_cast<TQKeyEvent*
>(e)->accept();
 
  110    case TQEvent::ChildInserted:
 
  111    case TQEvent::ChildRemoved:
 
  112    case TQEvent::Resize:
 
  113    case TQEvent::LayoutHint:
 
  114    case TQEvent::WindowActivate:
 
  115    case TQEvent::WindowDeactivate:
 
  117            autoCheckTimer.start( 20, 
true ); 
 
  120    case TQEvent::MouseMove:
 
  130void KCheckAccelerators::autoCheckSlot()
 
  134        autoCheckTimer.start( 20, 
true );
 
  138    checkAccelerators( !alwaysShow );
 
  142void KCheckAccelerators::createDialog(TQWidget *actWin, 
bool automatic)
 
  147    drklash = 
new TQDialog( actWin, 
"kapp_accel_check_dlg", 
false, (WFlags)TQt::WDestructiveClose);
 
  148    drklash->setCaption( 
i18n( 
"Dr. Klash' Accelerator Diagnosis" ));
 
  149    drklash->resize( 500, 460 );
 
  150    TQVBoxLayout* layout = 
new TQVBoxLayout( drklash, 11, 6 );
 
  151    layout->setAutoAdd( 
true );
 
  152    drklash_view = 
new TQTextView( drklash );
 
  153    TQCheckBox* disableAutoCheck = NULL;
 
  155        disableAutoCheck = 
new TQCheckBox( 
i18n( 
"&Disable automatic checking" ), drklash );
 
  156        connect(disableAutoCheck, TQ_SIGNAL(toggled(
bool)), TQ_SLOT(slotDisableCheck(
bool)));
 
  158    TQPushButton* btnClose = 
new TQPushButton( 
i18n( 
"&Close" ), drklash );
 
  159    btnClose->setDefault( 
true );
 
  160    connect( btnClose, TQ_SIGNAL( clicked() ), drklash, TQ_SLOT( 
close() ) );
 
  161    if (disableAutoCheck)
 
  162        disableAutoCheck->setFocus();
 
  164        drklash_view->setFocus();
 
  167void KCheckAccelerators::slotDisableCheck(
bool on)
 
  174void KCheckAccelerators::checkAccelerators( 
bool automatic )
 
  176    TQWidget* actWin = tqApp->activeWindow();
 
  182    TDEAcceleratorManager::last_manage(a, c,  r);
 
  187    if (c.isEmpty() && r.isEmpty() && (automatic || a.isEmpty()))
 
  192    if ( ! c.isEmpty() )  {
 
  193        s += 
i18n(
"<h2>Accelerators changed</h2>");
 
  194        s += 
"<table border><tr><th><b>Old Text</b></th><th><b>New Text</b></th></tr>" 
  198    if ( ! r.isEmpty() )  {
 
  199        s += 
i18n(
"<h2>Accelerators removed</h2>");
 
  200        s += 
"<table border><tr><th><b>Old Text</b></th></tr>" + r + 
"</table>";
 
  203    if ( ! a.isEmpty() )  {
 
  204        s += 
i18n(
"<h2>Accelerators added (just for your info)</h2>");
 
  205        s += 
"<table border><tr><th><b>New Text</b></th></tr>" + a + 
"</table>";
 
  208    createDialog(actWin, automatic);
 
  209    drklash_view->setText(s);
 
  216#include "kcheckaccelerators.moc" 
static void manage(TQWidget *widget)
Manages the accelerators of a widget.
TQString readEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads the value of an entry specified by pKey in the current group.
bool readBoolEntry(const TQString &pKey, bool bDefault=false) const
Reads a boolean entry.
Helper class to facilitate working with TDEConfig / TDESimpleConfig groups.
static TDEConfig * config()
Returns the general config object.
TQString i18n(const char *text)
i18n is the function that does everything you need to translate a string.
The TDEShortcut class is used to represent a keyboard shortcut to an action.
TDEAction * close(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)