khotkeys: added 'waiting' action to the list of available choices.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit 7fed9587e9)
r14.0.x
Michele Calgaro 2 years ago
parent 12007bb689
commit a2cb178bed
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -37,7 +37,7 @@ tde_create_translated_desktop( khotkeys.desktop )
tde_add_kpart( kcm_khotkeys AUTOMOC tde_add_kpart( kcm_khotkeys AUTOMOC
SOURCES SOURCES
menuedit.cpp window_trigger_widget.cpp tab_widget.cpp main_buttons_widget.cpp menuedit.cpp window_trigger_widget.cpp tab_widget.cpp main_buttons_widget.cpp
actions_listview_widget.cpp menuentry_widget.cpp general_tab.cpp actions_listview_widget.cpp menuentry_widget.cpp general_tab.cpp waiting_widget.cpp
action_group_tab.cpp kcmkhotkeys.cpp command_url_widget.cpp windowdef_list_widget.cpp action_group_tab.cpp kcmkhotkeys.cpp command_url_widget.cpp windowdef_list_widget.cpp
windowdef_simple_widget.cpp triggers_tab.cpp dcop_widget.cpp info_tab.cpp windowdef_simple_widget.cpp triggers_tab.cpp dcop_widget.cpp info_tab.cpp
action_list_widget.cpp keyboard_input_widget.cpp condition_list_widget.cpp action_list_widget.cpp keyboard_input_widget.cpp condition_list_widget.cpp

@ -4,7 +4,7 @@ kde_module_LTLIBRARIES = kcm_khotkeys.la kcm_khotkeys_init.la
kcm_khotkeys_la_SOURCES = \ kcm_khotkeys_la_SOURCES = \
menuedit.cpp window_trigger_widget.cpp tab_widget.cpp main_buttons_widget.cpp \ menuedit.cpp window_trigger_widget.cpp tab_widget.cpp main_buttons_widget.cpp \
actions_listview_widget.cpp menuentry_widget.cpp general_tab.cpp \ actions_listview_widget.cpp menuentry_widget.cpp general_tab.cpp waiting_widget.cpp \
action_group_tab.cpp kcmkhotkeys.cpp command_url_widget.cpp windowdef_list_widget.cpp \ action_group_tab.cpp kcmkhotkeys.cpp command_url_widget.cpp windowdef_list_widget.cpp \
windowdef_simple_widget.cpp triggers_tab.cpp dcop_widget.cpp info_tab.cpp \ windowdef_simple_widget.cpp triggers_tab.cpp dcop_widget.cpp info_tab.cpp \
action_list_widget.cpp keyboard_input_widget.cpp condition_list_widget.cpp \ action_list_widget.cpp keyboard_input_widget.cpp condition_list_widget.cpp \

@ -32,6 +32,7 @@
#include "dcop_widget.h" #include "dcop_widget.h"
#include "keyboard_input_widget.h" #include "keyboard_input_widget.h"
#include "activate_window_widget.h" #include "activate_window_widget.h"
#include "waiting_widget.h"
#include "kcmkhotkeys.h" #include "kcmkhotkeys.h"
namespace KHotKeys namespace KHotKeys
@ -48,6 +49,7 @@ Action_list_widget::Action_list_widget( TQWidget* parent_P, const char* name_P )
popup->insertItem( i18n( "DCOP Call..." ), TYPE_DCOP_ACTION ); popup->insertItem( i18n( "DCOP Call..." ), TYPE_DCOP_ACTION );
popup->insertItem( i18n( "Keyboard Input..." ), TYPE_KEYBOARD_INPUT_ACTION ); popup->insertItem( i18n( "Keyboard Input..." ), TYPE_KEYBOARD_INPUT_ACTION );
popup->insertItem( i18n( "Activate Window..." ), TYPE_ACTIVATE_WINDOW_ACTION ); popup->insertItem( i18n( "Activate Window..." ), TYPE_ACTIVATE_WINDOW_ACTION );
popup->insertItem( i18n( "Waiting..." ), TYPE_WAITING_ACTION );
connect( popup, TQT_SIGNAL( activated( int )), TQT_SLOT( new_selected( int ))); connect( popup, TQT_SIGNAL( activated( int )), TQT_SLOT( new_selected( int )));
new_button->setPopup( popup ); new_button->setPopup( popup );
actions_listview->header()->hide(); actions_listview->header()->hide();
@ -129,6 +131,9 @@ void Action_list_widget::new_selected( int type_P )
case TYPE_ACTIVATE_WINDOW_ACTION: // Activate_window_action_dialog case TYPE_ACTIVATE_WINDOW_ACTION: // Activate_window_action_dialog
dlg = new Activate_window_action_dialog( NULL ); dlg = new Activate_window_action_dialog( NULL );
break; break;
case TYPE_WAITING_ACTION: // Waiting_action_dialog
dlg = new Waiting_action_dialog( NULL );
break;
default: default:
assert( false ); assert( false );
} }
@ -271,6 +276,8 @@ void Action_list_widget::edit_listview_item( Action_list_item* item_P )
else if( Activate_window_action* action else if( Activate_window_action* action
= dynamic_cast< Activate_window_action* >( item_P->action())) = dynamic_cast< Activate_window_action* >( item_P->action()))
dlg = new Activate_window_action_dialog( action ); dlg = new Activate_window_action_dialog( action );
else if( Waiting_action* action = dynamic_cast< Waiting_action* >( item_P->action()))
dlg = new Waiting_action_dialog( action );
else // CHECKME TODO pridat dalsi else // CHECKME TODO pridat dalsi
assert( false ); assert( false );
Action* new_action = dlg->edit_action(); Action* new_action = dlg->edit_action();
@ -405,6 +412,28 @@ void Activate_window_action_dialog::accept()
action = new Activate_window_action( NULL, widget->get_data()); // CHECKME NULL ? action = new Activate_window_action( NULL, widget->get_data()); // CHECKME NULL ?
} }
// Waiting_action_dialog
Waiting_action_dialog::Waiting_action_dialog( Waiting_action* action_P )
: KDialogBase( NULL, NULL, true, "", Ok | Cancel ), action( NULL )
{
widget = new Waiting_widget( this );
widget->set_data( action_P );
setMainWidget( widget );
}
Action* Waiting_action_dialog::edit_action()
{
exec();
return action;
}
void Waiting_action_dialog::accept()
{
KDialogBase::accept();
action = widget->get_data( NULL );
}
} // namespace KHotKeys } // namespace KHotKeys
#include "action_list_widget.moc" #include "action_list_widget.moc"

@ -28,6 +28,7 @@ class Command_url_widget;
class Menuentry_widget; class Menuentry_widget;
class Dcop_widget; class Dcop_widget;
class Keyboard_input_widget; class Keyboard_input_widget;
class Waiting_widget;
class Action_list_item; class Action_list_item;
@ -47,7 +48,7 @@ class Action_list_widget
TQListViewItem* parent2_P, TQListViewItem* after_P, bool copy_P ); TQListViewItem* parent2_P, TQListViewItem* after_P, bool copy_P );
void edit_listview_item( Action_list_item* item_P ); void edit_listview_item( Action_list_item* item_P );
enum type_t { TYPE_COMMAND_URL_ACTION, TYPE_MENUENTRY_ACTION, TYPE_DCOP_ACTION, enum type_t { TYPE_COMMAND_URL_ACTION, TYPE_MENUENTRY_ACTION, TYPE_DCOP_ACTION,
TYPE_KEYBOARD_INPUT_ACTION, TYPE_ACTIVATE_WINDOW_ACTION }; TYPE_KEYBOARD_INPUT_ACTION, TYPE_ACTIVATE_WINDOW_ACTION, TYPE_WAITING_ACTION };
protected slots: protected slots:
void new_selected( int type_P ); void new_selected( int type_P );
virtual void copy_pressed(); virtual void copy_pressed();
@ -150,6 +151,19 @@ class Activate_window_action_dialog
Activate_window_action* action; Activate_window_action* action;
}; };
class Waiting_action_dialog
: public KDialogBase, public Action_dialog
{
Q_OBJECT
public:
Waiting_action_dialog( Waiting_action* action_P );
virtual Action* edit_action();
protected:
virtual void accept();
Waiting_widget* widget;
Waiting_action* action;
};
//*************************************************************************** //***************************************************************************
// Inline // Inline
//*************************************************************************** //***************************************************************************

@ -28,7 +28,7 @@ link_directories(
tde_add_library( ui STATIC_PIC AUTOMOC tde_add_library( ui STATIC_PIC AUTOMOC
SOURCES SOURCES
windowdef_simple_widget_ui.ui windowdef_list_widget_ui.ui windowdef_simple_widget_ui.ui windowdef_list_widget_ui.ui
command_url_widget_ui.ui menuentry_widget_ui.ui command_url_widget_ui.ui menuentry_widget_ui.ui waiting_widget_ui.ui
triggers_tab_ui.ui general_tab_ui.ui action_group_tab_ui.ui triggers_tab_ui.ui general_tab_ui.ui action_group_tab_ui.ui
dcop_widget_ui.ui main_buttons_widget_ui.ui voice_settings_tab_ui.ui dcop_widget_ui.ui main_buttons_widget_ui.ui voice_settings_tab_ui.ui
info_tab_ui.ui window_trigger_widget_ui.ui action_list_widget_ui.ui info_tab_ui.ui window_trigger_widget_ui.ui action_list_widget_ui.ui

@ -1,6 +1,6 @@
noinst_LTLIBRARIES = libui.la noinst_LTLIBRARIES = libui.la
libui_la_SOURCES = dummy.cpp windowdef_simple_widget_ui.ui windowdef_list_widget_ui.ui \ libui_la_SOURCES = dummy.cpp windowdef_simple_widget_ui.ui windowdef_list_widget_ui.ui \
command_url_widget_ui.ui menuentry_widget_ui.ui triggers_tab_ui.ui general_tab_ui.ui \ command_url_widget_ui.ui menuentry_widget_ui.ui triggers_tab_ui.ui general_tab_ui.ui waiting_widget_ui.ui \
action_group_tab_ui.ui dcop_widget_ui.ui main_buttons_widget_ui.ui \ action_group_tab_ui.ui dcop_widget_ui.ui main_buttons_widget_ui.ui \
actions_listview_widget_ui.ui info_tab_ui.ui window_trigger_widget_ui.ui \ actions_listview_widget_ui.ui info_tab_ui.ui window_trigger_widget_ui.ui \
action_list_widget_ui.ui keyboard_input_widget_ui.ui condition_list_widget_ui.ui \ action_list_widget_ui.ui keyboard_input_widget_ui.ui condition_list_widget_ui.ui \

@ -0,0 +1,72 @@
<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
<class>KHotKeys::Waiting_widget_ui</class>
<widget class="TQWidget">
<property name="name">
<cstring>Waiting_widget_ui</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>580</width>
<height>480</height>
</rect>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>11</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<widget class="TQLabel">
<property name="name">
<cstring>waiting_label</cstring>
</property>
<property name="text">
<string>Waiting time (ms): </string>
</property>
<property name="buddy" stdset="0">
<cstring>waiting_spinbox</cstring>
</property>
</widget>
<widget class="KIntSpinBox">
<property name="name">
<cstring>waiting_spinbox</cstring>
</property>
<property name="minValue">
<number>0</number>
</property>
<property name="maxValue">
<number>20000</number>
</property>
</widget>
<spacer>
<property name="name">
<cstring>Spacer16</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</hbox>
</widget>
<includes>
<include location="global" impldecl="in implementation">kdialog.h</include>
<include location="global" impldecl="in implementation">knuminput.h</include>
</includes>
<layoutdefaults spacing="6" margin="11"/>
<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
</UI>

@ -0,0 +1,56 @@
/****************************************************************************
KHotKeys
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#define _WAITING_WIDGET_CPP_
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "waiting_widget.h"
#include <knuminput.h>
#include <kdebug.h>
#include <actions.h>
#include <action_data.h>
#include "windowdef_list_widget.h"
#include "kcmkhotkeys.h"
namespace KHotKeys
{
Waiting_widget::Waiting_widget( TQWidget* parent_P, const char* name_P )
: Waiting_widget_ui( parent_P, name_P )
{
// KHotKeys::Module::changed()
connect(waiting_spinbox, TQT_SIGNAL(valueChanged(int)),
module, TQT_SLOT(changed()));
}
void Waiting_widget::set_data( const Waiting_action* data_P )
{
if( data_P == NULL )
{
return;
}
waiting_spinbox->setValue(data_P->_waiting_time);
}
Waiting_action* Waiting_widget::get_data( Action_data* data_P ) const
{
return new Waiting_action( data_P, waiting_spinbox->value());
}
} // namespace KHotKeys
#include "waiting_widget.moc"

@ -0,0 +1,36 @@
/****************************************************************************
KHotKeys
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#ifndef _WAITING_WIDGET_H_
#define _WAITING_WIDGET_H_
#include <waiting_widget_ui.h>
namespace KHotKeys
{
class Waiting_action;
class Action_data;
class Waiting_widget
: public Waiting_widget_ui
{
Q_OBJECT
public:
Waiting_widget( TQWidget* parent_P = NULL, const char* name_P = NULL );
void set_data( const Waiting_action* data_P );
Waiting_action* get_data( Action_data* data_P ) const;
};
typedef Waiting_widget Waiting_tab;
} // namespace KHotKeys
#endif

@ -54,7 +54,9 @@ Action* Action::create_cfg_read( TDEConfig& cfg_P, Action_data* data_P )
return new Keyboard_input_action( cfg_P, data_P ); return new Keyboard_input_action( cfg_P, data_P );
if( type == "ACTIVATE_WINDOW" ) if( type == "ACTIVATE_WINDOW" )
return new Activate_window_action( cfg_P, data_P ); return new Activate_window_action( cfg_P, data_P );
kdWarning( 1217 ) << "Unknown Action type read from cfg file\n"; if( type == "WAITING" )
return new Waiting_action( cfg_P, data_P );
kdWarning( 1217 ) << "Unknown Action type read from cfg file: " << type << endl;
return NULL; return NULL;
} }
@ -452,4 +454,34 @@ Action* Activate_window_action::copy( Action_data* data_P ) const
return new Activate_window_action( data_P, window()->copy()); return new Activate_window_action( data_P, window()->copy());
} }
// Waiting_action
Waiting_action::Waiting_action( TDEConfig& cfg_P, Action_data* data_P )
: Action( cfg_P, data_P )
{
_waiting_time = cfg_P.readNumEntry("Time");
}
void Waiting_action::cfg_write( TDEConfig& cfg_P ) const
{
base::cfg_write( cfg_P );
cfg_P.writeEntry( "Type", "WAITING" ); // overwrites value set in base::cfg_write()
cfg_P.writeEntry( "Time", _waiting_time);
}
void Waiting_action::execute()
{
usleep(_waiting_time * 1000);
}
TQString Waiting_action::description() const
{
return i18n( "Waiting %1 ms" ).arg(_waiting_time);
}
Action* Waiting_action::copy( Action_data* data_P ) const
{
return new Waiting_action( data_P, _waiting_time);
}
} // namespace KHotKeys } // namespace KHotKeys

@ -50,7 +50,7 @@ class KDE_EXPORT Action_list
: public TQPtrList< Action > : public TQPtrList< Action >
{ {
public: public:
Action_list( const TQString& comment_P ); // CHECKME nebo i data ? Action_list( const TQString& comment_P );
Action_list( TDEConfig& cfg_P, Action_data* data_P ); Action_list( TDEConfig& cfg_P, Action_data* data_P );
void cfg_write( TDEConfig& cfg_P ) const; void cfg_write( TDEConfig& cfg_P ) const;
typedef TQPtrListIterator< Action > Iterator; typedef TQPtrListIterator< Action > Iterator;
@ -111,7 +111,7 @@ class KDE_EXPORT Dcop_action
virtual TQString description() const; virtual TQString description() const;
virtual Action* copy( Action_data* data_P ) const; virtual Action* copy( Action_data* data_P ) const;
private: private:
TQString app; // CHECKME TQCString ? TQString app;
TQString obj; TQString obj;
TQString call; TQString call;
TQString args; TQString args;
@ -159,6 +159,21 @@ class KDE_EXPORT Activate_window_action
const Windowdef_list* _window; const Windowdef_list* _window;
}; };
class KDE_EXPORT Waiting_action
: public Action
{
typedef Action base;
public:
Waiting_action( Action_data* data_P, const int waiting_time );
Waiting_action( TDEConfig& cfg_P, Action_data* data_P );
virtual void cfg_write( TDEConfig& cfg_P ) const;
virtual void execute();
virtual TQString description() const;
virtual Action* copy( Action_data* data_P ) const;
int _waiting_time;
};
//*************************************************************************** //***************************************************************************
// Inline // Inline
//*************************************************************************** //***************************************************************************
@ -300,6 +315,14 @@ const Windowdef_list* Activate_window_action::window() const
return _window; return _window;
} }
// Waiting_action
inline
Waiting_action::Waiting_action( Action_data* data_P, const int waiting_time)
: Action( data_P ), _waiting_time(waiting_time)
{
}
} // namespace KHotKeys } // namespace KHotKeys
#endif #endif

@ -145,9 +145,11 @@ void Settings::write_settings()
gestures_exclude->cfg_write( cfg ); gestures_exclude->cfg_write( cfg );
} }
else else
{
cfg.deleteGroup( "GesturesExclude" ); cfg.deleteGroup( "GesturesExclude" );
cfg.setGroup( "Voice" ); }
cfg.writeEntry("Shortcut" , voice_shortcut.toStringInternal() ); cfg.setGroup( "Voice" );
cfg.writeEntry("Shortcut" , voice_shortcut.toStringInternal() );
} }

@ -277,6 +277,7 @@ void Window_trigger::window_changed( WId window_P, unsigned int dirty_P )
bool matches = windows()->match( Window_data( window_P )); bool matches = windows()->match( Window_data( window_P ));
existing_windows[ window_P ] = matches; existing_windows[ window_P ] = matches;
if( active && matches && !was_match ) if( active && matches && !was_match )
{
if( window_actions & WINDOW_APPEARS ) if( window_actions & WINDOW_APPEARS )
{ {
windows_handler->set_action_window( window_P ); windows_handler->set_action_window( window_P );
@ -287,6 +288,7 @@ void Window_trigger::window_changed( WId window_P, unsigned int dirty_P )
windows_handler->set_action_window( window_P ); windows_handler->set_action_window( window_P );
data->execute(); data->execute();
} }
}
kdDebug( 1217 ) << "Window_trigger::w_changed() : " << was_match << "|" << matches << endl; kdDebug( 1217 ) << "Window_trigger::w_changed() : " << was_match << "|" << matches << endl;
} }

Loading…
Cancel
Save