Add custom hotkeys. (#2340)
Co-authored-by: LosFarmosCTL <80157503+LosFarmosCTL@users.noreply.github.com> Co-authored-by: Paweł <zneix@zneix.eu> Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com> Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -31,6 +31,8 @@ private:
|
||||
QHBoxLayout *buttons_{};
|
||||
|
||||
void moveRow(int dir);
|
||||
|
||||
public:
|
||||
void selectRow(int row);
|
||||
};
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ ResizingTextEdit::ResizingTextEdit()
|
||||
});
|
||||
|
||||
this->setFocusPolicy(Qt::ClickFocus);
|
||||
this->installEventFilter(this);
|
||||
}
|
||||
|
||||
QSize ResizingTextEdit::sizeHint() const
|
||||
@@ -95,6 +96,22 @@ QString ResizingTextEdit::textUnderCursor(bool *hadSpace) const
|
||||
return lastWord;
|
||||
}
|
||||
|
||||
bool ResizingTextEdit::eventFilter(QObject *, QEvent *event)
|
||||
{
|
||||
// makes QShortcuts work in the ResizingTextEdit
|
||||
if (event->type() != QEvent::ShortcutOverride)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auto ev = static_cast<QKeyEvent *>(event);
|
||||
ev->ignore();
|
||||
if ((ev->key() == Qt::Key_C || ev->key() == Qt::Key_Insert) &&
|
||||
ev->modifiers() == Qt::ControlModifier)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
event->ignore();
|
||||
|
||||
@@ -43,6 +43,7 @@ private:
|
||||
QCompleter *completer_ = nullptr;
|
||||
bool completionInProgress_ = false;
|
||||
|
||||
bool eventFilter(QObject *widget, QEvent *event) override;
|
||||
private slots:
|
||||
void insertCompletion(const QString &completion);
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "common/Channel.hpp"
|
||||
#include "controllers/hotkeys/HotkeyController.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
#include "messages/search/AuthorPredicate.hpp"
|
||||
#include "messages/search/ChannelPredicate.hpp"
|
||||
@@ -13,7 +14,6 @@
|
||||
#include "messages/search/MessageFlagsPredicate.hpp"
|
||||
#include "messages/search/RegexPredicate.hpp"
|
||||
#include "messages/search/SubstringPredicate.hpp"
|
||||
#include "util/Shortcut.hpp"
|
||||
#include "widgets/helper/ChannelView.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
@@ -60,11 +60,32 @@ SearchPopup::SearchPopup(QWidget *parent)
|
||||
{
|
||||
this->initLayout();
|
||||
this->resize(400, 600);
|
||||
this->addShortcuts();
|
||||
}
|
||||
|
||||
createShortcut(this, "CTRL+F", [this] {
|
||||
this->searchInput_->setFocus();
|
||||
this->searchInput_->selectAll();
|
||||
});
|
||||
void SearchPopup::addShortcuts()
|
||||
{
|
||||
HotkeyController::HotkeyMap actions{
|
||||
{"search",
|
||||
[this](std::vector<QString>) -> QString {
|
||||
this->searchInput_->setFocus();
|
||||
this->searchInput_->selectAll();
|
||||
return "";
|
||||
}},
|
||||
{"delete",
|
||||
[this](std::vector<QString>) -> QString {
|
||||
this->close();
|
||||
return "";
|
||||
}},
|
||||
|
||||
{"reject", nullptr},
|
||||
{"accept", nullptr},
|
||||
{"openTab", nullptr},
|
||||
{"scrollPage", nullptr},
|
||||
};
|
||||
|
||||
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory(
|
||||
HotkeyCategory::PopupWindow, actions, this);
|
||||
}
|
||||
|
||||
void SearchPopup::setChannelFilters(FilterSetPtr filters)
|
||||
|
||||
@@ -26,6 +26,7 @@ protected:
|
||||
private:
|
||||
void initLayout();
|
||||
void search();
|
||||
void addShortcuts() override;
|
||||
|
||||
/**
|
||||
* @brief Only retains those message from a list of messages that satisfy a
|
||||
|
||||
Reference in New Issue
Block a user