forked from mapeditor/tiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Double-clicking to set a shortcut now works on the entire row, rather than just the Shortcut column. * Enter/Return keys now also trigger the setting of a shortcut. * Up/Down/PageUp/PageDown/Enter/Return keys can be used to interact with the shortcut list, even when the focus is in the filter widget. Issue mapeditor#215
- Loading branch information
Showing
8 changed files
with
138 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* filteredit.cpp | ||
* Copyright 2019, Thorbjørn Lindeijer <bjorn@lindeijer.nl> | ||
* | ||
* This file is part of Tiled. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the Free | ||
* Software Foundation; either version 2 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "filteredit.h" | ||
|
||
#include <QCoreApplication> | ||
#include <QKeyEvent> | ||
|
||
namespace Tiled { | ||
|
||
FilterEdit::FilterEdit(QWidget *parent) | ||
: QLineEdit(parent) | ||
{ | ||
setClearButtonEnabled(true); | ||
} | ||
|
||
bool FilterEdit::event(QEvent *event) | ||
{ | ||
if (mFilteredView) { | ||
switch (event->type()) { | ||
case QEvent::KeyPress: | ||
case QEvent::KeyRelease: { | ||
auto key = static_cast<QKeyEvent*>(event)->key(); | ||
if ( key == Qt::Key_Up || | ||
key == Qt::Key_Down || | ||
key == Qt::Key_PageUp || | ||
key == Qt::Key_PageDown || | ||
key == Qt::Key_Return || | ||
key == Qt::Key_Enter) { | ||
|
||
// Forward some keys to the view, to allow changing the | ||
// selection and activating items while the focus is in the | ||
// filter edit. | ||
QCoreApplication::sendEvent(mFilteredView, event); | ||
return true; | ||
} | ||
break; | ||
} | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
return QLineEdit::event(event); | ||
} | ||
|
||
} // namespace Tiled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* filteredit.h | ||
* Copyright 2019, Thorbjørn Lindeijer <bjorn@lindeijer.nl> | ||
* | ||
* This file is part of Tiled. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the Free | ||
* Software Foundation; either version 2 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <QLineEdit> | ||
|
||
namespace Tiled { | ||
|
||
class FilterEdit : public QLineEdit | ||
{ | ||
public: | ||
FilterEdit(QWidget *parent = nullptr); | ||
|
||
void setFilteredView(QWidget *view); | ||
|
||
bool event(QEvent *event) override; | ||
|
||
private: | ||
QWidget *mFilteredView = nullptr; | ||
}; | ||
|
||
|
||
inline void FilterEdit::setFilteredView(QWidget *view) | ||
{ | ||
mFilteredView = view; | ||
} | ||
|
||
} // namespace Tiled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters