From 12007bb689082f356835ae6ad4412ee414230e83 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Thu, 11 Aug 2022 18:01:06 +0900 Subject: TCC khotkeys: added 'move up' and 'move down' buttons to 'Actions' and 'Conditions' listviews for input actions. Signed-off-by: Michele Calgaro (cherry picked from commit 5e4ca4df9bb34e10a897e32e7e0ca8645b97f293) --- khotkeys/kcontrol/action_list_widget.cpp | 55 ++++++++++++++++++---- khotkeys/kcontrol/action_list_widget.h | 24 +++++----- khotkeys/kcontrol/actions_listview_widget.cpp | 10 ++-- khotkeys/kcontrol/actions_listview_widget.h | 16 +++---- khotkeys/kcontrol/condition_list_widget.cpp | 58 ++++++++++++++++++++---- khotkeys/kcontrol/condition_list_widget.h | 18 ++++---- khotkeys/kcontrol/ui/action_list_widget_ui.ui | 30 ++++++++++++ khotkeys/kcontrol/ui/condition_list_widget_ui.ui | 32 ++++++++++++- 8 files changed, 190 insertions(+), 53 deletions(-) diff --git a/khotkeys/kcontrol/action_list_widget.cpp b/khotkeys/kcontrol/action_list_widget.cpp index ffa71bce0..e94e561e2 100644 --- a/khotkeys/kcontrol/action_list_widget.cpp +++ b/khotkeys/kcontrol/action_list_widget.cpp @@ -62,16 +62,13 @@ Action_list_widget::Action_list_widget( TQWidget* parent_P, const char* name_P ) this, TQT_SLOT( modify_pressed() ) ); // KHotKeys::Module::changed() - connect( new_button, TQT_SIGNAL( clicked()), - module, TQT_SLOT( changed())); - connect( copy_button, TQT_SIGNAL( clicked()), - module, TQT_SLOT( changed())); - connect( modify_button, TQT_SIGNAL( clicked()), - module, TQT_SLOT( changed())); - connect( delete_button, TQT_SIGNAL( clicked()), - module, TQT_SLOT( changed())); - connect( comment_lineedit, TQT_SIGNAL( textChanged( const TQString& )), - module, TQT_SLOT( changed())); + connect(new_button, TQT_SIGNAL(clicked()), module, TQT_SLOT(changed())); + connect(copy_button, TQT_SIGNAL(clicked()), module, TQT_SLOT(changed())); + connect(modify_button, TQT_SIGNAL(clicked()), module, TQT_SLOT(changed())); + connect(delete_button, TQT_SIGNAL(clicked()), module, TQT_SLOT(changed())); + connect(move_up_button, TQT_SIGNAL(clicked()), module, TQT_SLOT(changed())); + connect(move_down_button, TQT_SIGNAL(clicked()), module, TQT_SLOT(changed())); + connect(comment_lineedit, TQT_SIGNAL(textChanged(const TQString&)), module, TQT_SLOT(changed())); } Action_list_widget::~Action_list_widget() @@ -189,6 +186,42 @@ void Action_list_widget::modify_pressed() edit_listview_item( selected_item ); } +void Action_list_widget::move_up_pressed() + { + if ( !selected_item ) + { + return; + } + + Action_list_item *prevItem = nullptr; + TQListViewItem *currItem = actions_listview->firstChild(); + while (currItem != selected_item) + { + prevItem = static_cast< Action_list_item* >(currItem); + currItem = currItem->nextSibling(); + } + if (prevItem) + { + prevItem->moveItem(selected_item); + current_changed(selected_item); + } + } + +void Action_list_widget::move_down_pressed() + { + if ( !selected_item ) + { + return; + } + + Action_list_item *nextItem = static_cast< Action_list_item* >(selected_item->nextSibling()); + if (nextItem) + { + selected_item->moveItem(nextItem); + current_changed(selected_item); + } + } + void Action_list_widget::current_changed( TQListViewItem* item_P ) { // if( item_P == selected_item ) @@ -198,6 +231,8 @@ void Action_list_widget::current_changed( TQListViewItem* item_P ) copy_button->setEnabled( item_P != NULL ); modify_button->setEnabled( item_P != NULL ); delete_button->setEnabled( item_P != NULL ); + move_up_button->setEnabled(selected_item != actions_listview->firstChild()); + move_down_button->setEnabled(selected_item != actions_listview->lastChild()); } Action_list_item* Action_list_widget::create_listview_item( Action* action_P, diff --git a/khotkeys/kcontrol/action_list_widget.h b/khotkeys/kcontrol/action_list_widget.h index c2f32477e..38676b886 100644 --- a/khotkeys/kcontrol/action_list_widget.h +++ b/khotkeys/kcontrol/action_list_widget.h @@ -1,11 +1,11 @@ /**************************************************************************** KHotKeys - + Copyright (C) 1999-2001 Lubos Lunak Distributed under the terms of the GNU General Public License version 2. - + ****************************************************************************/ #ifndef _ACTION_LIST_WIDGET_H_ @@ -53,6 +53,8 @@ class Action_list_widget virtual void copy_pressed(); virtual void delete_pressed(); virtual void modify_pressed(); + virtual void move_up_pressed(); + virtual void move_down_pressed(); virtual void current_changed( TQListViewItem* item_P ); protected: Action_list_item* selected_item; @@ -75,14 +77,14 @@ class Action_list_item protected: Action* _action; // owns it }; - + class Action_dialog { public: virtual Action* edit_action() = 0; virtual ~Action_dialog(); }; - + class Command_url_action_dialog : public KDialogBase, public Action_dialog { @@ -95,7 +97,7 @@ class Command_url_action_dialog Command_url_widget* widget; Command_url_action* action; }; - + class Menuentry_action_dialog : public KDialogBase, public Action_dialog { @@ -108,7 +110,7 @@ class Menuentry_action_dialog Menuentry_widget* widget; Menuentry_action* action; }; - + class Dcop_action_dialog : public KDialogBase, public Action_dialog { @@ -121,7 +123,7 @@ class Dcop_action_dialog Dcop_widget* widget; Dcop_action* action; }; - + class Keyboard_input_action_dialog : public KDialogBase, public Action_dialog { @@ -134,7 +136,7 @@ class Keyboard_input_action_dialog Keyboard_input_widget* widget; Keyboard_input_action* action; }; - + class Activate_window_action_dialog : public KDialogBase, public Action_dialog { @@ -147,7 +149,7 @@ class Activate_window_action_dialog Activate_window_widget* widget; Activate_window_action* action; }; - + //*************************************************************************** // Inline //*************************************************************************** @@ -159,7 +161,7 @@ Action_list_item::Action_list_item( TQListView* parent_P, Action* action_P ) : TQListViewItem( parent_P ), _action( action_P ) { } - + inline Action_list_item::Action_list_item( TQListViewItem* parent_P, Action* action_P ) : TQListViewItem( parent_P ), _action( action_P ) @@ -185,7 +187,7 @@ Action* Action_list_item::action() const { return _action; } - + inline void Action_list_item::set_action( Action* action_P ) { diff --git a/khotkeys/kcontrol/actions_listview_widget.cpp b/khotkeys/kcontrol/actions_listview_widget.cpp index e528005ed..1b6c7a743 100644 --- a/khotkeys/kcontrol/actions_listview_widget.cpp +++ b/khotkeys/kcontrol/actions_listview_widget.cpp @@ -1,11 +1,11 @@ /**************************************************************************** KHotKeys - + Copyright (C) 1999-2001 Lubos Lunak Distributed under the terms of the GNU General Public License version 2. - + ****************************************************************************/ #define _ACTIONS_LISTVIEW_WIDGET_CPP_ @@ -138,7 +138,7 @@ void Actions_listview_widget::build_up() { build_up_recursively( module->actions_root(), NULL ); } - + void Actions_listview_widget::build_up_recursively( Action_data_group* parent_P, Action_listview_item* item_parent_P ) { @@ -147,13 +147,13 @@ void Actions_listview_widget::build_up_recursively( Action_data_group* parent_P, it; ++it ) { - prev = create_item( item_parent_P, prev, ( *it )); + prev = create_item( item_parent_P, prev, ( *it )); Action_data_group* grp = dynamic_cast< Action_data_group* >( *it ); if( grp != NULL ) build_up_recursively( grp, prev ); } } - + Action_listview_item* Actions_listview_widget::create_item( TQListViewItem* parent_P, TQListViewItem* after_P, Action_data_base* data_P ) { diff --git a/khotkeys/kcontrol/actions_listview_widget.h b/khotkeys/kcontrol/actions_listview_widget.h index 0f3a632f4..e380791ee 100644 --- a/khotkeys/kcontrol/actions_listview_widget.h +++ b/khotkeys/kcontrol/actions_listview_widget.h @@ -1,11 +1,11 @@ /**************************************************************************** KHotKeys - + Copyright (C) 1999-2001 Lubos Lunak Distributed under the terms of the GNU General Public License version 2. - + ****************************************************************************/ #ifndef _ACTIONS_LISTVIEW_WIDGET_H_ @@ -27,13 +27,13 @@ class Action_data_base; class Actions_listview_widget : public Actions_listview_widget_ui - { + { Q_OBJECT public: Actions_listview_widget( TQWidget* parent_P = NULL, const char* name_P = NULL ); Action_listview_item* current_action() const; void set_current_action( Action_listview_item* item ); - Action_data_base* current_action_data() const; + Action_data_base* current_action_data() const; void set_action_data( Action_data_base* data_P, bool recent_action_P = false ); void action_name_changed( const TQString& name_P ); void clear(); @@ -54,7 +54,7 @@ class Actions_listview_widget }; class Actions_listview - : public KHListView + : public KHListView { Q_OBJECT public: @@ -78,7 +78,7 @@ class Action_listview_item Action_data_base* data_P ); protected: Action_data_base* _data; // CHECKME doesn't own !!! - }; + }; //*************************************************************************** // Inline @@ -113,7 +113,7 @@ Actions_listview_widget* Actions_listview::widget() { return _widget; } - + // Action_listview_item inline @@ -139,7 +139,7 @@ Action_data_base* Action_listview_item::data() const { return _data; } - + inline void Action_listview_item::set_data( Action_data_base* data_P ) { diff --git a/khotkeys/kcontrol/condition_list_widget.cpp b/khotkeys/kcontrol/condition_list_widget.cpp index 864c2d4a5..817602a12 100644 --- a/khotkeys/kcontrol/condition_list_widget.cpp +++ b/khotkeys/kcontrol/condition_list_widget.cpp @@ -62,18 +62,18 @@ Condition_list_widget::Condition_list_widget( TQWidget* parent_P, const char* na copy_button->setEnabled( false ); modify_button->setEnabled( false ); delete_button->setEnabled( false ); + move_up_button->setEnabled( false ); + move_down_button->setEnabled( false ); clear_data(); // KHotKeys::Module::changed() - connect( new_button, TQT_SIGNAL( clicked()), - module, TQT_SLOT( changed())); - connect( copy_button, TQT_SIGNAL( clicked()), - module, TQT_SLOT( changed())); - connect( modify_button, TQT_SIGNAL( clicked()), - module, TQT_SLOT( changed())); - connect( delete_button, TQT_SIGNAL( clicked()), - module, TQT_SLOT( changed())); - connect( comment_lineedit, TQT_SIGNAL( textChanged( const TQString& )), - module, TQT_SLOT( changed())); + connect(new_button, TQT_SIGNAL(clicked()), module, TQT_SLOT(changed())); + connect(copy_button, TQT_SIGNAL(clicked()), module, TQT_SLOT(changed())); + connect(modify_button, TQT_SIGNAL(clicked()), module, TQT_SLOT( changed())); + connect(delete_button, TQT_SIGNAL(clicked()), module, TQT_SLOT( changed())); + connect(move_up_button, TQT_SIGNAL(clicked()), module, TQT_SLOT(changed())); + connect(move_down_button, TQT_SIGNAL(clicked()), module, TQT_SLOT(changed())); + connect(comment_lineedit, TQT_SIGNAL(textChanged(const TQString&)), + module, TQT_SLOT(changed())); } Condition_list_widget::~Condition_list_widget() @@ -256,6 +256,42 @@ void Condition_list_widget::modify_pressed() edit_listview_item( selected_item ); } +void Condition_list_widget::move_up_pressed() + { + if ( !selected_item ) + { + return; + } + + Condition_list_item *prevItem = nullptr; + TQListViewItem *currItem = conditions_listview->firstChild(); + while (currItem != selected_item) + { + prevItem = static_cast< Condition_list_item* >(currItem); + currItem = currItem->nextSibling(); + } + if (prevItem) + { + prevItem->moveItem(selected_item); + current_changed(selected_item); + } + } + +void Condition_list_widget::move_down_pressed() + { + if ( !selected_item ) + { + return; + } + + Condition_list_item *nextItem = static_cast< Condition_list_item* >(selected_item->nextSibling()); + if (nextItem) + { + selected_item->moveItem(nextItem); + current_changed(selected_item); + } + } + void Condition_list_widget::current_changed( TQListViewItem* item_P ) { // if( item_P == selected_item ) @@ -277,6 +313,8 @@ void Condition_list_widget::current_changed( TQListViewItem* item_P ) } else modify_button->setEnabled( false ); + move_up_button->setEnabled(selected_item != conditions_listview->firstChild()); + move_down_button->setEnabled(selected_item != conditions_listview->lastChild()); } Condition_list_item* Condition_list_widget::create_listview_item( Condition* condition_P, diff --git a/khotkeys/kcontrol/condition_list_widget.h b/khotkeys/kcontrol/condition_list_widget.h index 0c99fd46c..04c9d3deb 100644 --- a/khotkeys/kcontrol/condition_list_widget.h +++ b/khotkeys/kcontrol/condition_list_widget.h @@ -1,11 +1,11 @@ /**************************************************************************** KHotKeys - + Copyright (C) 1999-2001 Lubos Lunak Distributed under the terms of the GNU General Public License version 2. - + ****************************************************************************/ #ifndef _CONDITIONS_LIST_WIDGET_H_ @@ -48,6 +48,8 @@ class Condition_list_widget virtual void copy_pressed(); virtual void delete_pressed(); virtual void modify_pressed(); + virtual void move_up_pressed(); + virtual void move_down_pressed(); virtual void current_changed( TQListViewItem* item_P ); private: void insert_listview_items( const Condition_list_base* parent_P, @@ -74,14 +76,14 @@ class Condition_list_item protected: Condition* _condition; // owns it }; - + class Condition_dialog { public: virtual Condition* edit_condition() = 0; virtual ~Condition_dialog(); }; - + class Active_window_condition_dialog : public KDialogBase, public Condition_dialog { @@ -94,7 +96,7 @@ class Active_window_condition_dialog Windowdef_list_widget* widget; Active_window_condition* condition; }; - + class Existing_window_condition_dialog : public KDialogBase, public Condition_dialog { @@ -107,7 +109,7 @@ class Existing_window_condition_dialog Windowdef_list_widget* widget; Existing_window_condition* condition; }; - + //*************************************************************************** // Inline @@ -120,7 +122,7 @@ Condition_list_item::Condition_list_item( TQListView* parent_P, Condition* condi : TQListViewItem( parent_P ), _condition( condition_P ) { } - + inline Condition_list_item::Condition_list_item( TQListViewItem* parent_P, Condition* condition_P ) : TQListViewItem( parent_P ), _condition( condition_P ) @@ -146,7 +148,7 @@ Condition* Condition_list_item::condition() const { return _condition; } - + inline void Condition_list_item::set_condition( Condition* condition_P ) { diff --git a/khotkeys/kcontrol/ui/action_list_widget_ui.ui b/khotkeys/kcontrol/ui/action_list_widget_ui.ui index d78c6b5f1..2895e5752 100644 --- a/khotkeys/kcontrol/ui/action_list_widget_ui.ui +++ b/khotkeys/kcontrol/ui/action_list_widget_ui.ui @@ -97,6 +97,22 @@ Delete + + + move_up_button + + + Move &up + + + + + move_down_button + + + Move &down + + @@ -147,6 +163,18 @@ Action_list_widget_ui delete_pressed() + + move_up_button + clicked() + Action_list_widget_ui + move_up_pressed() + + + move_down_button + clicked() + Action_list_widget_ui + move_down_pressed() + actions_listview current_changed(TQListViewItem*) @@ -162,6 +190,8 @@ current_changed(TQListViewItem*) delete_pressed() modify_pressed() + move_up_pressed() + move_down_pressed() kdialog.h diff --git a/khotkeys/kcontrol/ui/condition_list_widget_ui.ui b/khotkeys/kcontrol/ui/condition_list_widget_ui.ui index 9b3727ffd..269b889ce 100644 --- a/khotkeys/kcontrol/ui/condition_list_widget_ui.ui +++ b/khotkeys/kcontrol/ui/condition_list_widget_ui.ui @@ -94,7 +94,23 @@ delete_button - Delete + D&elete + + + + + move_up_button + + + Move &up + + + + + move_down_button + + + Move &down @@ -146,6 +162,18 @@ Condition_list_widget_ui delete_pressed() + + move_up_button + clicked() + Condition_list_widget_ui + move_up_pressed() + + + move_down_button + clicked() + Condition_list_widget_ui + move_down_pressed() + conditions_listview current_changed(TQListViewItem*) @@ -161,6 +189,8 @@ current_changed(TQListViewItem*) delete_pressed() modify_pressed() + move_up_pressed() + move_down_pressed() kdialog.h -- cgit v1.2.1