| 1 |
/*************************************************************************** |
| 2 |
* Copyright (c) 2005 Werner Mayer <wmayer[at]users.sourceforge.net> * |
| 3 |
* * |
| 4 |
* This file is part of the FreeCAD CAx development system. * |
| 5 |
* * |
| 6 |
* This library is free software; you can redistribute it and/or * |
| 7 |
* modify it under the terms of the GNU Library General Public * |
| 8 |
* License as published by the Free Software Foundation; either * |
| 9 |
* version 2 of the License, or (at your option) any later version. * |
| 10 |
* * |
| 11 |
* This library is distributed in the hope that it will be useful, * |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 |
* GNU Library General Public License for more details. * |
| 15 |
* * |
| 16 |
* You should have received a copy of the GNU Library General Public * |
| 17 |
* License along with this library; see the file COPYING.LIB. If not, * |
| 18 |
* write to the Free Software Foundation, Inc., 59 Temple Place, * |
| 19 |
* Suite 330, Boston, MA 02111-1307, USA * |
| 20 |
* * |
| 21 |
***************************************************************************/ |
| 22 |
|
| 23 |
|
| 24 |
#ifndef GUI_DIALOG_DLGKEYBOARD_IMP_H |
| 25 |
#define GUI_DIALOG_DLGKEYBOARD_IMP_H |
| 26 |
|
| 27 |
#include <boost/signals2.hpp> |
| 28 |
#include <memory> |
| 29 |
#include <QPointer> |
| 30 |
#include <QAction> |
| 31 |
#include "PropertyPage.h" |
| 32 |
|
| 33 |
class QTreeWidget; |
| 34 |
class QTreeWidgetItem; |
| 35 |
class QComboBox; |
| 36 |
class QLineEdit; |
| 37 |
class QAbstractButton; |
| 38 |
|
| 39 |
namespace Gui |
| 40 |
{ |
| 41 |
|
| 42 |
class AccelLineEdit; |
| 43 |
|
| 44 |
namespace Dialog |
| 45 |
{ |
| 46 |
class Ui_DlgCustomKeyboard; |
| 47 |
|
| 48 |
/** Shows an overview of all available commands of all groups and modules. |
| 49 |
* You can customize your workbenches just by drag&dropping any commands |
| 50 |
* onto the toolbars or commandbars. But you cannot modify any standard toolbars or |
| 51 |
* commandbars such as "File, View, ...". It is only possible to |
| 52 |
* customize your own toolbars or commandbars. |
| 53 |
* \author Werner Mayer |
| 54 |
*/ |
| 55 |
class DlgCustomKeyboardImp: public CustomizeActionPage |
| 56 |
{ |
| 57 |
Q_OBJECT |
| 58 |
|
| 59 |
public: |
| 60 |
explicit DlgCustomKeyboardImp(QWidget* parent = nullptr); |
| 61 |
~DlgCustomKeyboardImp() override; |
| 62 |
|
| 63 |
/** Public helper function for handling command widgets |
| 64 |
* |
| 65 |
* @param commandTreeWidget: a tree widget listing commands |
| 66 |
* @param separatorItem: optional separator item |
| 67 |
* @param comboGroups: a combo box widget for choosing categories of commands |
| 68 |
* @param editCommand: a line edit for searching command with auto complete |
| 69 |
* @param priroityList: a tree widget listing commands with the same shortcut in order of priority |
| 70 |
* @param buttonUp: a button widget to increase command priority |
| 71 |
* @param buttonDown: a button widget to decrease command priority |
| 72 |
* @param editShortcut: an accelerator editor for setting user defined shortcut |
| 73 |
* @param currentShortcut: optional accelerator editor showing the current shortcut of a command |
| 74 |
* |
| 75 |
* @return Return a boost signal connection for monitoring command changes. |
| 76 |
* Most disconnect the signal before widgets gets destroyed. |
| 77 |
*/ |
| 78 |
static boost::signals2::connection initCommandWidgets( |
| 79 |
QTreeWidget* commandTreeWidget, |
| 80 |
QTreeWidgetItem* separatorItem, |
| 81 |
QComboBox* comboGroups, |
| 82 |
QLineEdit* editCommand, |
| 83 |
QTreeWidget* priorityList = nullptr, |
| 84 |
QAbstractButton* buttonUp = nullptr, |
| 85 |
QAbstractButton* buttonDown = nullptr, |
| 86 |
Gui::AccelLineEdit* editShortcut = nullptr, |
| 87 |
Gui::AccelLineEdit* currentShortcut = nullptr |
| 88 |
); |
| 89 |
|
| 90 |
protected: |
| 91 |
/** @name Internal helper function for handling command list widgets |
| 92 |
*/ |
| 93 |
//@{ |
| 94 |
static void initCommandCompleter( |
| 95 |
QLineEdit*, |
| 96 |
QComboBox* combo, |
| 97 |
QTreeWidget* treeWidget, |
| 98 |
QTreeWidgetItem* separatorItem |
| 99 |
); |
| 100 |
static boost::signals2::connection initCommandList(QTreeWidget*, QTreeWidgetItem*, QComboBox* combo); |
| 101 |
static void initPriorityList(QTreeWidget*, QAbstractButton* buttonUp, QAbstractButton* buttonDown); |
| 102 |
static void populateCommandGroups(QComboBox*); |
| 103 |
static void populateCommandList(QTreeWidget*, QTreeWidgetItem*, QComboBox*); |
| 104 |
static void populatePriorityList( |
| 105 |
QTreeWidget* priorityList, |
| 106 |
AccelLineEdit* editor, |
| 107 |
AccelLineEdit* current |
| 108 |
); |
| 109 |
//@} |
| 110 |
protected: |
| 111 |
void setupConnections(); |
| 112 |
void onCategoryBoxActivated(int index); |
| 113 |
void onCommandTreeWidgetCurrentItemChanged(QTreeWidgetItem*); |
| 114 |
void onButtonAssignClicked(); |
| 115 |
void onButtonClearClicked(); |
| 116 |
void onButtonResetClicked(); |
| 117 |
void onButtonResetAllClicked(); |
| 118 |
void onEditShortcutTextChanged(const QKeySequence&); |
| 119 |
|
| 120 |
protected Q_SLOTS: |
| 121 |
void onAddMacroAction(const QByteArray&) override; |
| 122 |
void onRemoveMacroAction(const QByteArray&) override; |
| 123 |
void onModifyMacroAction(const QByteArray&) override; |
| 124 |
|
| 125 |
protected: |
| 126 |
void showEvent(QShowEvent* e) override; |
| 127 |
void changeEvent(QEvent* e) override; |
| 128 |
void setShortcutOfCurrentAction(const QString&); |
| 129 |
|
| 130 |
private: |
| 131 |
std::unique_ptr<Ui_DlgCustomKeyboard> ui; |
| 132 |
bool firstShow; |
| 133 |
boost::signals2::scoped_connection conn; |
| 134 |
}; |
| 135 |
|
| 136 |
} // namespace Dialog |
| 137 |
} // namespace Gui |
| 138 |
|
| 139 |
#endif // GUI_DIALOG_DLGKEYBOARD_IMP_H |