[UI] Focus in text message entry field if a text message tab is requested

* requested by AF
* added signals/slots
* foucs functions
This commit is contained in:
Klaus Basan
2019-11-30 00:59:58 +01:00
committed by Mat Sutcliffe
parent 03afc8968a
commit 1deeaf39e8
7 changed files with 49 additions and 5 deletions

View File

@@ -107,14 +107,19 @@ namespace BlackGui
if (pb) { pb->setChecked(true); } if (pb) { pb->setChecked(true); }
} }
Q_UNUSED(dockedIndexes); Q_UNUSED(dockedIndexes)
}
void CMainKeypadAreaComponent::focusInEntryField()
{
ui->lep_CommandLineInput->setFocus();
} }
void CMainKeypadAreaComponent::buttonSelected() void CMainKeypadAreaComponent::buttonSelected()
{ {
if (!sGui || sGui->isShuttingDown()) { return; }
QPushButton *senderButton = static_cast<QPushButton *>(QObject::sender()); QPushButton *senderButton = static_cast<QPushButton *>(QObject::sender());
Q_ASSERT_X(senderButton, Q_FUNC_INFO, "No sender button"); Q_ASSERT_X(senderButton, Q_FUNC_INFO, "No sender button");
if (!sGui || sGui->isShuttingDown()) { return; }
if (!senderButton) { return; } if (!senderButton) { return; }
const CMainInfoAreaComponent::InfoArea infoArea = buttonToMainInfoArea(senderButton); const CMainInfoAreaComponent::InfoArea infoArea = buttonToMainInfoArea(senderButton);
if (infoArea != CMainInfoAreaComponent::InfoAreaNone) if (infoArea != CMainInfoAreaComponent::InfoAreaNone)
@@ -157,7 +162,7 @@ namespace BlackGui
void CMainKeypadAreaComponent::connectionStatusChanged(const CConnectionStatus &from, const CConnectionStatus &to) void CMainKeypadAreaComponent::connectionStatusChanged(const CConnectionStatus &from, const CConnectionStatus &to)
{ {
Q_UNUSED(from); Q_UNUSED(from)
// Connected button // Connected button
if (to.isConnected()) if (to.isConnected())

View File

@@ -46,6 +46,9 @@ namespace BlackGui
//! Main info area changed //! Main info area changed
void onMainInfoAreaChanged(int currentTabIndex, QList<int> dockedIndexes, QList<int> floatingIndexes); void onMainInfoAreaChanged(int currentTabIndex, QList<int> dockedIndexes, QList<int> floatingIndexes);
//! Focus in entry fields
void focusInEntryField();
signals: signals:
//! Button to select main info area has been pressed //! Button to select main info area has been pressed
//! \sa CMainInfoAreaComponent //! \sa CMainInfoAreaComponent

View File

@@ -795,6 +795,8 @@ namespace BlackGui
// force display // force display
if (!m_usedAsOverlayWidget) { this->displayMyself(); } if (!m_usedAsOverlayWidget) { this->displayMyself(); }
emit this->textMessageTabSelected();
} }
void CTextMessageComponent::showCorrespondingTabForFrequency(const CFrequency &frequency) void CTextMessageComponent::showCorrespondingTabForFrequency(const CFrequency &frequency)
@@ -828,6 +830,8 @@ namespace BlackGui
case TextMessagesUnicom: ui->tw_TextMessages->setCurrentWidget(ui->tb_TextMessagesUnicom); break; case TextMessagesUnicom: ui->tw_TextMessages->setCurrentWidget(ui->tb_TextMessagesUnicom); break;
default: break; default: break;
} }
emit this->textMessageTabSelected();
} }
void CTextMessageComponent::setAtcButtonsRowsColumns(int rows, int cols, bool setMaxElements) void CTextMessageComponent::setAtcButtonsRowsColumns(int rows, int cols, bool setMaxElements)

View File

@@ -118,6 +118,9 @@ namespace BlackGui
//! Command line was entered //! Command line was entered
void commandEntered(const QString &commandLine, const BlackMisc::CIdentifier &originator); void commandEntered(const QString &commandLine, const BlackMisc::CIdentifier &originator);
//! Text message tab selected
void textMessageTabSelected();
private: private:
QScopedPointer<Ui::CTextMessageComponent> ui; QScopedPointer<Ui::CTextMessageComponent> ui;
BlackMisc::CIdentifier m_identifier { "TextMessageComponent", this }; BlackMisc::CIdentifier m_identifier { "TextMessageComponent", this };

View File

@@ -16,6 +16,7 @@
#include "blackgui/components/logindialog.h" #include "blackgui/components/logindialog.h"
#include "blackgui/components/modelbrowserdialog.h" #include "blackgui/components/modelbrowserdialog.h"
#include "blackgui/components/settingscomponent.h" #include "blackgui/components/settingscomponent.h"
#include "blackgui/components/textmessagecomponent.h"
#include "blackgui/guiapplication.h" #include "blackgui/guiapplication.h"
#include "blackgui/guiutility.h" #include "blackgui/guiutility.h"
#include "blackgui/overlaymessagesframe.h" #include "blackgui/overlaymessagesframe.h"
@@ -442,6 +443,25 @@ void SwiftGuiStd::onRequestedConsoleMessage(const QString &logMsg, bool clear)
log->appendPlainTextToConsole(logMsg); log->appendPlainTextToConsole(logMsg);
} }
void SwiftGuiStd::focusInMainEntryField()
{
ui->comp_MainKeypadArea->focusInEntryField();
}
void SwiftGuiStd::focusInTextMessageEntryField()
{
if (!ui->comp_MainInfoArea->getTextMessageComponent()) { return; }
if (ui->comp_MainInfoArea->getTextMessageComponent()->isParentDockWidgetFloating())
{
ui->comp_MainInfoArea->getTextMessageComponent()->activateWindow();
ui->comp_MainInfoArea->getTextMessageComponent()->focusTextEntry();
}
else
{
this->focusInMainEntryField();
}
}
void SwiftGuiStd::showMinimized() void SwiftGuiStd::showMinimized()
{ {
this->showMinimizedModeChecked(); this->showMinimizedModeChecked();

View File

@@ -281,6 +281,12 @@ private:
//! UI Console message has been recevied //! UI Console message has been recevied
void onRequestedConsoleMessage(const QString &logMsg, bool clear); void onRequestedConsoleMessage(const QString &logMsg, bool clear);
//! Focus in main entry window
void focusInMainEntryField();
//! Focus in the text message entry field
void focusInTextMessageEntryField();
//! Show window minimized //! Show window minimized
void showMinimized(); void showMinimized();

View File

@@ -212,6 +212,9 @@ void SwiftGuiStd::initGuiSignals()
connect(ui->comp_MainKeypadArea, &CMainKeypadAreaComponent::audioPressed, ui->comp_MainInfoArea, &CMainInfoAreaComponent::selectAudioTab); connect(ui->comp_MainKeypadArea, &CMainKeypadAreaComponent::audioPressed, ui->comp_MainInfoArea, &CMainInfoAreaComponent::selectAudioTab);
connect(ui->comp_MainInfoArea, &CMainInfoAreaComponent::changedInfoAreaStatus, ui->comp_MainKeypadArea, &CMainKeypadAreaComponent::onMainInfoAreaChanged); connect(ui->comp_MainInfoArea, &CMainInfoAreaComponent::changedInfoAreaStatus, ui->comp_MainKeypadArea, &CMainKeypadAreaComponent::onMainInfoAreaChanged);
// text component
connect(ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::textMessageTabSelected, this, &SwiftGuiStd::focusInTextMessageEntryField, Qt::QueuedConnection);
// audio // audio
connect(ui->comp_MainInfoArea->getAtcStationComponent(), &CAtcStationComponent::requestAudioWidget, ui->comp_MainInfoArea, &CMainInfoAreaComponent::selectAudioTab); connect(ui->comp_MainInfoArea->getAtcStationComponent(), &CAtcStationComponent::requestAudioWidget, ui->comp_MainInfoArea, &CMainInfoAreaComponent::selectAudioTab);