From a2cb178bed086ae98097b5bded1817cc7704d2b4 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Wed, 24 Aug 2022 20:55:24 +0900 Subject: khotkeys: added 'waiting' action to the list of available choices. Signed-off-by: Michele Calgaro (cherry picked from commit 7fed9587e9673983fe4128557baa33b23b71076f) --- khotkeys/kcontrol/CMakeLists.txt | 2 +- khotkeys/kcontrol/Makefile.am | 2 +- khotkeys/kcontrol/action_list_widget.cpp | 29 +++++++++++++ khotkeys/kcontrol/action_list_widget.h | 16 ++++++- khotkeys/kcontrol/ui/CMakeLists.txt | 2 +- khotkeys/kcontrol/ui/Makefile.am | 2 +- khotkeys/kcontrol/ui/waiting_widget_ui.ui | 72 +++++++++++++++++++++++++++++++ khotkeys/kcontrol/waiting_widget.cpp | 56 ++++++++++++++++++++++++ khotkeys/kcontrol/waiting_widget.h | 36 ++++++++++++++++ 9 files changed, 212 insertions(+), 5 deletions(-) create mode 100644 khotkeys/kcontrol/ui/waiting_widget_ui.ui create mode 100644 khotkeys/kcontrol/waiting_widget.cpp create mode 100644 khotkeys/kcontrol/waiting_widget.h (limited to 'khotkeys/kcontrol') diff --git a/khotkeys/kcontrol/CMakeLists.txt b/khotkeys/kcontrol/CMakeLists.txt index 5028763ce..902c5a0e6 100644 --- a/khotkeys/kcontrol/CMakeLists.txt +++ b/khotkeys/kcontrol/CMakeLists.txt @@ -37,7 +37,7 @@ tde_create_translated_desktop( khotkeys.desktop ) tde_add_kpart( kcm_khotkeys AUTOMOC SOURCES 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 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 diff --git a/khotkeys/kcontrol/Makefile.am b/khotkeys/kcontrol/Makefile.am index 7eb3f2f6d..03a728ae3 100644 --- a/khotkeys/kcontrol/Makefile.am +++ b/khotkeys/kcontrol/Makefile.am @@ -4,7 +4,7 @@ kde_module_LTLIBRARIES = kcm_khotkeys.la kcm_khotkeys_init.la kcm_khotkeys_la_SOURCES = \ 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 \ 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 \ diff --git a/khotkeys/kcontrol/action_list_widget.cpp b/khotkeys/kcontrol/action_list_widget.cpp index e94e561e2..d007ab5f5 100644 --- a/khotkeys/kcontrol/action_list_widget.cpp +++ b/khotkeys/kcontrol/action_list_widget.cpp @@ -32,6 +32,7 @@ #include "dcop_widget.h" #include "keyboard_input_widget.h" #include "activate_window_widget.h" +#include "waiting_widget.h" #include "kcmkhotkeys.h" 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( "Keyboard Input..." ), TYPE_KEYBOARD_INPUT_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 ))); new_button->setPopup( popup ); 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 dlg = new Activate_window_action_dialog( NULL ); break; + case TYPE_WAITING_ACTION: // Waiting_action_dialog + dlg = new Waiting_action_dialog( NULL ); + break; default: assert( false ); } @@ -271,6 +276,8 @@ void Action_list_widget::edit_listview_item( Action_list_item* item_P ) else if( Activate_window_action* action = dynamic_cast< Activate_window_action* >( item_P->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 assert( false ); 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 ? } +// 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 #include "action_list_widget.moc" diff --git a/khotkeys/kcontrol/action_list_widget.h b/khotkeys/kcontrol/action_list_widget.h index 38676b886..91bee9417 100644 --- a/khotkeys/kcontrol/action_list_widget.h +++ b/khotkeys/kcontrol/action_list_widget.h @@ -28,6 +28,7 @@ class Command_url_widget; class Menuentry_widget; class Dcop_widget; class Keyboard_input_widget; +class Waiting_widget; class Action_list_item; @@ -47,7 +48,7 @@ class Action_list_widget TQListViewItem* parent2_P, TQListViewItem* after_P, bool copy_P ); void edit_listview_item( Action_list_item* item_P ); 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: void new_selected( int type_P ); virtual void copy_pressed(); @@ -150,6 +151,19 @@ class Activate_window_action_dialog 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 //*************************************************************************** diff --git a/khotkeys/kcontrol/ui/CMakeLists.txt b/khotkeys/kcontrol/ui/CMakeLists.txt index 85212affb..ab8db9e78 100644 --- a/khotkeys/kcontrol/ui/CMakeLists.txt +++ b/khotkeys/kcontrol/ui/CMakeLists.txt @@ -28,7 +28,7 @@ link_directories( tde_add_library( ui STATIC_PIC AUTOMOC SOURCES 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 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 diff --git a/khotkeys/kcontrol/ui/Makefile.am b/khotkeys/kcontrol/ui/Makefile.am index 14ea5c44d..ee63c6871 100644 --- a/khotkeys/kcontrol/ui/Makefile.am +++ b/khotkeys/kcontrol/ui/Makefile.am @@ -1,6 +1,6 @@ noinst_LTLIBRARIES = libui.la 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 \ 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 \ diff --git a/khotkeys/kcontrol/ui/waiting_widget_ui.ui b/khotkeys/kcontrol/ui/waiting_widget_ui.ui new file mode 100644 index 000000000..5942a34ba --- /dev/null +++ b/khotkeys/kcontrol/ui/waiting_widget_ui.ui @@ -0,0 +1,72 @@ + +KHotKeys::Waiting_widget_ui + + + Waiting_widget_ui + + + + 0 + 0 + 580 + 480 + + + + + unnamed + + + 11 + + + 6 + + + + waiting_label + + + Waiting time (ms): + + + waiting_spinbox + + + + + waiting_spinbox + + + 0 + + + 20000 + + + + + Spacer16 + + + Horizontal + + + Expanding + + + + 0 + 20 + + + + + + + kdialog.h + knuminput.h + + + + diff --git a/khotkeys/kcontrol/waiting_widget.cpp b/khotkeys/kcontrol/waiting_widget.cpp new file mode 100644 index 000000000..6f1c0c657 --- /dev/null +++ b/khotkeys/kcontrol/waiting_widget.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** + + KHotKeys + + Copyright (C) 1999-2001 Lubos Lunak + + Distributed under the terms of the GNU General Public License version 2. + +****************************************************************************/ + +#define _WAITING_WIDGET_CPP_ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "waiting_widget.h" + +#include + +#include + +#include +#include + +#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" diff --git a/khotkeys/kcontrol/waiting_widget.h b/khotkeys/kcontrol/waiting_widget.h new file mode 100644 index 000000000..520e7742e --- /dev/null +++ b/khotkeys/kcontrol/waiting_widget.h @@ -0,0 +1,36 @@ +/**************************************************************************** + + KHotKeys + + Copyright (C) 1999-2001 Lubos Lunak + + Distributed under the terms of the GNU General Public License version 2. + +****************************************************************************/ + +#ifndef _WAITING_WIDGET_H_ +#define _WAITING_WIDGET_H_ + +#include + +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 -- cgit v1.2.1