mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
Ref T384, addjusted text message component to be used with overlay text messages
* Tab enum in own file * Funtions to change tab and hide UI elements
This commit is contained in:
@@ -110,7 +110,7 @@ namespace BlackGui
|
||||
return c;
|
||||
}
|
||||
|
||||
QWidget *CTextMessageComponent::getTabWidget(CTextMessageComponent::Tab tab) const
|
||||
QWidget *CTextMessageComponent::getTabWidget(TextMessageTab tab) const
|
||||
{
|
||||
switch (tab)
|
||||
{
|
||||
@@ -125,14 +125,14 @@ namespace BlackGui
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CTextMessageTextEdit *CTextMessageComponent::getTextEdit(CTextMessageComponent::Tab tab) const
|
||||
CTextMessageTextEdit *CTextMessageComponent::getTextEdit(TextMessageTab tab) const
|
||||
{
|
||||
QWidget *w = this->getTabWidget(tab);
|
||||
if (!w) { return nullptr; }
|
||||
return this->findChild<CTextMessageTextEdit *>();
|
||||
}
|
||||
|
||||
void CTextMessageComponent::selectTabWidget(CTextMessageComponent::Tab tab)
|
||||
void CTextMessageComponent::selectTabWidget(TextMessageTab tab)
|
||||
{
|
||||
QWidget *w = this->getTabWidget(tab);
|
||||
if (w)
|
||||
@@ -272,7 +272,7 @@ namespace BlackGui
|
||||
|
||||
bool CTextMessageComponent::isCorrespondingTextMessageTabSelected(CTextMessage textMessage) const
|
||||
{
|
||||
if (!this->isVisibleWidget()) { return false; }
|
||||
if (!this->isVisibleWidgetHack()) { return false; }
|
||||
if (!textMessage.hasValidRecipient()) { return false; }
|
||||
if (textMessage.isEmpty()) { return false; } // ignore empty message
|
||||
if (textMessage.isPrivateMessage())
|
||||
@@ -460,9 +460,14 @@ namespace BlackGui
|
||||
this->handleEnteredTextMessage(cl);
|
||||
}
|
||||
|
||||
bool CTextMessageComponent::isVisibleWidgetHack() const
|
||||
{
|
||||
return m_usedAsOverlayWidget ? true : this->isVisibleWidget();
|
||||
}
|
||||
|
||||
void CTextMessageComponent::handleEnteredTextMessage(const QString &textMessage)
|
||||
{
|
||||
if (!this->isVisibleWidget()) { return; }
|
||||
if (!this->isVisibleWidgetHack()) { return; }
|
||||
|
||||
QString cl(textMessage.trimmed().simplified());
|
||||
if (cl.isEmpty()) { return; }
|
||||
@@ -549,7 +554,7 @@ namespace BlackGui
|
||||
if (commandLine.isEmpty() || commandLine.startsWith(".")) { return false; }
|
||||
|
||||
// no "dot" command input
|
||||
if (!this->isVisibleWidget()) { return false; } // invisible, do ignore
|
||||
if (!this->isVisibleWidgetHack()) { return false; } // invisible, do ignore
|
||||
this->handleEnteredTextMessage(commandLine); // handle as it was entered by own command line
|
||||
|
||||
return false; // we never handle the message directly, but forward it
|
||||
@@ -587,5 +592,20 @@ namespace BlackGui
|
||||
ui->comp_SettingsStyle->fontSizePlus();
|
||||
}
|
||||
|
||||
void CTextMessageComponent::setTab(TextMessageTab tab)
|
||||
{
|
||||
ui->tw_TextMessages->setCurrentIndex(tab);;
|
||||
}
|
||||
|
||||
void CTextMessageComponent::showSettings(bool show)
|
||||
{
|
||||
ui->gb_Settings->setVisible(show);
|
||||
}
|
||||
|
||||
void CTextMessageComponent::showTextMessageEntry(bool show)
|
||||
{
|
||||
ui->le_textMessages->setVisible(show);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#ifndef BLACKGUI_COMPONENTS_TEXTMESSAGECOMPONENT_H
|
||||
#define BLACKGUI_COMPONENTS_TEXTMESSAGECOMPONENT_H
|
||||
|
||||
#include "textmessagecomponenttab.h"
|
||||
#include "blackgui/settings/textmessagesettings.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
@@ -40,15 +41,6 @@ namespace BlackGui
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Tabs
|
||||
enum Tab
|
||||
{
|
||||
TextMessagesAll,
|
||||
TextMessagesUnicom,
|
||||
TextMessagesCom1,
|
||||
TextMessagesCom2
|
||||
};
|
||||
|
||||
//! Constructor
|
||||
explicit CTextMessageComponent(QWidget *parent = nullptr);
|
||||
|
||||
@@ -76,6 +68,18 @@ namespace BlackGui
|
||||
void fontSizePlus();
|
||||
//! @}
|
||||
|
||||
//! Set tab
|
||||
void setTab(TextMessageTab tab);
|
||||
|
||||
//! Show the settings
|
||||
void showSettings(bool show);
|
||||
|
||||
//! Show an text entry field
|
||||
void showTextMessageEntry(bool show);
|
||||
|
||||
//! Used as overlay and not dock widget
|
||||
void setAsUsedInOverlayMode() { m_usedAsOverlayWidget = true; }
|
||||
|
||||
signals:
|
||||
//! Message to be displayed in info window
|
||||
void displayInInfoWindow(const BlackMisc::CVariant &message, int displayDurationMs) const;
|
||||
@@ -87,15 +91,16 @@ namespace BlackGui
|
||||
QScopedPointer<Ui::CTextMessageComponent> ui;
|
||||
BlackMisc::CIdentifier m_identifier { "TextMessageComponent", this };
|
||||
BlackMisc::CSetting<Settings::TextMessageSettings> m_messageSettings { this, &CTextMessageComponent::onSettingsChanged };
|
||||
bool m_usedAsOverlayWidget = false; //!< disables dockwidget parts
|
||||
|
||||
//! Enum to widget
|
||||
QWidget *getTabWidget(Tab tab) const;
|
||||
QWidget *getTabWidget(TextMessageTab tab) const;
|
||||
|
||||
//! Related text edit
|
||||
CTextMessageTextEdit *getTextEdit(Tab tab) const;
|
||||
CTextMessageTextEdit *getTextEdit(TextMessageTab tab) const;
|
||||
|
||||
//! Select given tab
|
||||
void selectTabWidget(Tab tab);
|
||||
void selectTabWidget(TextMessageTab tab);
|
||||
|
||||
//! New message tab for given callsign
|
||||
QWidget *addNewTextMessageTab(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
@@ -166,6 +171,9 @@ namespace BlackGui
|
||||
|
||||
//! Command line entered
|
||||
void textMessageEntered();
|
||||
|
||||
//! Visible widget hack
|
||||
bool isVisibleWidgetHack() const;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
29
src/blackgui/components/textmessagecomponenttab.h
Normal file
29
src/blackgui/components/textmessagecomponenttab.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/* Copyright (C) 2018
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the toplevel
|
||||
* directory of this distribution and at http://www.swiftproject.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_COMPONENTS_TEXTMESSAGECOMPONENT_TAB_H
|
||||
#define BLACKGUI_COMPONENTS_TEXTMESSAGECOMPONENT_TAB_H
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
//! Tabs
|
||||
enum TextMessageTab
|
||||
{
|
||||
TextMessagesAll,
|
||||
TextMessagesUnicom,
|
||||
TextMessagesCom1,
|
||||
TextMessagesCom2
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user