Ghetto disambiguation for the quick switcher

Fix the Ctrl+K shortcut

Fix keyboard focus when the quick switcher is closed

Linting
This commit is contained in:
Jani Mustonen 2017-11-01 19:26:41 +02:00
parent ddb23105f1
commit fda8fa1f44
4 changed files with 22 additions and 6 deletions

View File

@ -79,6 +79,9 @@ signals:
void startedTyping(); void startedTyping();
void stoppedTyping(); void stoppedTyping();
protected:
void focusInEvent(QFocusEvent *event);
private: private:
void showUploadSpinner(); void showUploadSpinner();
QString parseEmoteCommand(const QString &cmd); QString parseEmoteCommand(const QString &cmd);

View File

@ -562,6 +562,7 @@ ChatPage::showQuickSwitcher()
connect(quickSwitcher_.data(), &QuickSwitcher::closing, this, [=]() { connect(quickSwitcher_.data(), &QuickSwitcher::closing, this, [=]() {
if (!this->quickSwitcherModal_.isNull()) if (!this->quickSwitcherModal_.isNull())
this->quickSwitcherModal_->fadeOut(); this->quickSwitcherModal_->fadeOut();
this->text_input_->setFocus(Qt::FocusReason::PopupFocusReason);
}); });
} }
@ -575,8 +576,12 @@ ChatPage::showQuickSwitcher()
QMap<QString, QString> rooms; QMap<QString, QString> rooms;
for (auto it = state_manager_.constBegin(); it != state_manager_.constEnd(); ++it) for (auto it = state_manager_.constBegin(); it != state_manager_.constEnd(); ++it) {
rooms.insert(it.value().getName(), it.key()); QString deambiguator = it.value().canonical_alias.content().alias();
if (deambiguator == "")
deambiguator = it.key();
rooms.insert(it.value().getName() + " (" + deambiguator + ")", it.key());
}
quickSwitcher_->setRoomList(rooms); quickSwitcher_->setRoomList(rooms);
quickSwitcherModal_->fadeIn(); quickSwitcherModal_->fadeIn();

View File

@ -111,6 +111,11 @@ MainWindow::MainWindow(QWidget *parent)
QShortcut *quitShortcut = new QShortcut(QKeySequence::Quit, this); QShortcut *quitShortcut = new QShortcut(QKeySequence::Quit, this);
connect(quitShortcut, &QShortcut::activated, this, QApplication::quit); connect(quitShortcut, &QShortcut::activated, this, QApplication::quit);
QShortcut *quickSwitchShortcut = new QShortcut(QKeySequence("Ctrl+K"), this);
connect(quickSwitchShortcut, &QShortcut::activated, this, [=]() {
chat_page_->showQuickSwitcher();
});
QSettings settings; QSettings settings;
if (hasActiveUser()) { if (hasActiveUser()) {
@ -125,10 +130,7 @@ MainWindow::MainWindow(QWidget *parent)
void void
MainWindow::keyPressEvent(QKeyEvent *e) MainWindow::keyPressEvent(QKeyEvent *e)
{ {
if ((e->key() == Qt::Key_K) && (e->modifiers().testFlag(Qt::ControlModifier))) QMainWindow::keyPressEvent(e);
chat_page_->showQuickSwitcher();
else
QMainWindow::keyPressEvent(e);
} }
void void

View File

@ -259,3 +259,9 @@ TextInputWidget::stopTyping()
{ {
input_->stopTyping(); input_->stopTyping();
} }
void
TextInputWidget::focusInEvent(QFocusEvent *event)
{
input_->setFocus(event->reason());
}