Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / khotkeys / kcontrol / tab_widget.h
blob9f0326570a383e3814aed45bf3a9d85b4d7c9f7e
1 /****************************************************************************
3 KHotKeys
5 Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
7 Distributed under the terms of the GNU General Public License version 2.
9 ****************************************************************************/
11 #ifndef _TAB_WIDGET_H_
12 #define _TAB_WIDGET_H_
14 #include <QTabWidget>
16 #include <actions.h>
18 namespace KHotKeys
21 class Tab_widget
22 : public QTabWidget
24 Q_OBJECT
25 public:
26 enum action_type_t
28 TYPE_FIRST,
29 TYPE_GENERIC = TYPE_FIRST,
30 TYPE_COMMAND_URL_SHORTCUT,
31 TYPE_MENUENTRY_SHORTCUT,
32 TYPE_DBUS_SHORTCUT,
33 TYPE_KEYBOARD_INPUT_SHORTCUT,
34 TYPE_KEYBOARD_INPUT_GESTURE,
35 TYPE_ACTIVATE_WINDOW_SHORTCUT,
36 TYPE_END
38 Tab_widget( QWidget* parent_P = NULL, const char* name_P = NULL );
39 virtual ~Tab_widget();
40 void set_action_type( action_type_t type_P, bool force_P = false );
41 void save_current_action_changes();
42 void load_current_action();
43 void clear_pages();
44 static action_type_t type( const Action_data* data_P );
45 Q_SIGNALS: // internal
46 void clear_pages_signal();
47 protected Q_SLOTS:
48 void set_action_type_slot( int type_P );
49 protected:
50 void check_action_type();
51 class Pages_set;
52 void show_pages( const Pages_set& pages_P );
53 enum tab_pos_t { TAB_FIRST, TAB_INFO = TAB_FIRST, TAB_GENERAL_SETTINGS, TAB_GESTURES_SETTINGS,
54 TAB_GENERAL, TAB_GROUP_GENERAL,
55 TAB_TRIGGERS, TAB_SHORTCUT_TRIGGER, TAB_GESTURE_TRIGGER, TAB_ACTIONS, TAB_COMMAND_URL,
56 TAB_MENUENTRY, TAB_DBUS, TAB_KEYBOARD_INPUT, TAB_WINDOW, TAB_CONDITIONS, TAB_VOICE_SETTINGS, TAB_END };
57 QWidget* pages[ TAB_END ];
58 enum tab_show_type_t { NONE, DATA, GROUP };
59 tab_show_type_t current_type;
60 action_type_t current_data_type;
61 static const char* const tab_labels[];
62 class Pages_set // that main reason for existence of this class is the fact that
63 { // I was very curious if overloading operator, ( = comma ) really
64 public: // works ( it does, but not exactly as I expected :( )
65 Pages_set( tab_pos_t page_P );
66 Pages_set& operator,( tab_pos_t page_P );
67 bool is_set( tab_pos_t page_P ) const;
68 protected:
69 bool set[ TAB_END ];
71 friend Pages_set operator,( tab_pos_t page1_P, tab_pos_t page2_P ); // CHECKME
72 friend tab_pos_t& operator++( tab_pos_t& val_P ); // CHECKME
75 //***************************************************************************
76 // Inline
77 //***************************************************************************
79 // Tab_widget
81 // grrrr
82 inline
83 Tab_widget::tab_pos_t& operator++( Tab_widget::tab_pos_t& val_P )
85 val_P = static_cast< Tab_widget::tab_pos_t >( val_P + 1 );
86 return val_P;
89 inline
90 void Tab_widget::clear_pages()
92 emit clear_pages_signal();
95 // Tab_widget::Pages_set
97 inline
98 Tab_widget::Pages_set::Pages_set( tab_pos_t page_P )
100 for( tab_pos_t i = TAB_FIRST;
101 i < TAB_END;
102 ++i )
103 set[ i ] = false;
104 set[ page_P ] = true;
107 inline
108 bool Tab_widget::Pages_set::is_set( tab_pos_t page_P ) const
110 return set[ page_P ];
113 inline
114 Tab_widget::Pages_set& Tab_widget::Pages_set::operator,( tab_pos_t page_P )
116 set[ page_P ] = true;
117 return *this;
120 inline
121 Tab_widget::Pages_set operator,( Tab_widget::tab_pos_t page1_P, Tab_widget::tab_pos_t page2_P )
123 return Tab_widget::Pages_set( page1_P ), page2_P;
126 // grrrr
127 inline
128 Tab_widget::action_type_t& operator++( Tab_widget::action_type_t& val_P )
130 val_P = static_cast< Tab_widget::action_type_t >( val_P + 1 );
131 return val_P;
134 } // namespace KHotKeys
136 #endif