mirror of
https://github.com/leozide/leocad
synced 2024-12-25 21:58:23 +01:00
Added keyboard shortcut filter. Fixes #338.
This commit is contained in:
parent
d793373923
commit
46f58a4aaa
3 changed files with 44 additions and 1 deletions
|
@ -630,6 +630,39 @@ void lcQPreferencesDialog::commandChanged(QTreeWidgetItem *current)
|
|||
ui->shortcutEdit->setText(key.toString(QKeySequence::NativeText));
|
||||
}
|
||||
|
||||
void lcQPreferencesDialog::on_KeyboardFilterEdit_textEdited(const QString& Text)
|
||||
{
|
||||
if (Text.isEmpty())
|
||||
{
|
||||
std::function<void(QTreeWidgetItem*)> ShowItems = [&ShowItems](QTreeWidgetItem* ParentItem)
|
||||
{
|
||||
for (int ChildIdx = 0; ChildIdx < ParentItem->childCount(); ChildIdx++)
|
||||
ShowItems(ParentItem->child(ChildIdx));
|
||||
|
||||
ParentItem->setHidden(false);
|
||||
};
|
||||
|
||||
ShowItems(ui->commandList->invisibleRootItem());
|
||||
}
|
||||
else
|
||||
{
|
||||
std::function<bool(QTreeWidgetItem*,bool)> ShowItems = [&ShowItems, &Text](QTreeWidgetItem* ParentItem, bool ForceVisible)
|
||||
{
|
||||
ForceVisible |= ParentItem->text(0).contains(Text, Qt::CaseInsensitive) | ParentItem->text(1).contains(Text, Qt::CaseInsensitive);
|
||||
bool Visible = ForceVisible;
|
||||
|
||||
for (int ChildIdx = 0; ChildIdx < ParentItem->childCount(); ChildIdx++)
|
||||
Visible |= ShowItems(ParentItem->child(ChildIdx), ForceVisible);
|
||||
|
||||
ParentItem->setHidden(!Visible);
|
||||
|
||||
return Visible;
|
||||
};
|
||||
|
||||
ShowItems(ui->commandList->invisibleRootItem(), false);
|
||||
}
|
||||
}
|
||||
|
||||
void lcQPreferencesDialog::on_shortcutAssign_clicked()
|
||||
{
|
||||
QTreeWidgetItem *current = ui->commandList->currentItem();
|
||||
|
|
|
@ -49,6 +49,7 @@ public slots:
|
|||
void on_shortcutsExport_clicked();
|
||||
void on_shortcutsReset_clicked();
|
||||
void commandChanged(QTreeWidgetItem *current);
|
||||
void on_KeyboardFilterEdit_textEdited(const QString& Text);
|
||||
void on_mouseAssign_clicked();
|
||||
void on_mouseRemove_clicked();
|
||||
void on_mouseReset_clicked();
|
||||
|
|
|
@ -683,7 +683,7 @@
|
|||
<item>
|
||||
<widget class="QTreeWidget" name="commandList">
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="uniformRowHeights">
|
||||
<bool>true</bool>
|
||||
|
@ -700,6 +700,13 @@
|
|||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="KeyboardFilterEdit">
|
||||
<property name="placeholderText">
|
||||
<string>Search shortcuts</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<item>
|
||||
|
@ -1005,6 +1012,7 @@
|
|||
<tabstop>lgeoPathBrowse</tabstop>
|
||||
<tabstop>checkForUpdates</tabstop>
|
||||
<tabstop>fixedDirectionKeys</tabstop>
|
||||
<tabstop>autoLoadMostRecent</tabstop>
|
||||
<tabstop>antiAliasing</tabstop>
|
||||
<tabstop>antiAliasingSamples</tabstop>
|
||||
<tabstop>edgeLines</tabstop>
|
||||
|
@ -1030,6 +1038,7 @@
|
|||
<tabstop>editCategory</tabstop>
|
||||
<tabstop>deleteCategory</tabstop>
|
||||
<tabstop>commandList</tabstop>
|
||||
<tabstop>KeyboardFilterEdit</tabstop>
|
||||
<tabstop>shortcutsImport</tabstop>
|
||||
<tabstop>shortcutsExport</tabstop>
|
||||
<tabstop>shortcutsReset</tabstop>
|
||||
|
|
Loading…
Reference in a new issue