mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-03 16:25:54 +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;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *CTextMessageComponent::getTabWidget(CTextMessageComponent::Tab tab) const
|
QWidget *CTextMessageComponent::getTabWidget(TextMessageTab tab) const
|
||||||
{
|
{
|
||||||
switch (tab)
|
switch (tab)
|
||||||
{
|
{
|
||||||
@@ -125,14 +125,14 @@ namespace BlackGui
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CTextMessageTextEdit *CTextMessageComponent::getTextEdit(CTextMessageComponent::Tab tab) const
|
CTextMessageTextEdit *CTextMessageComponent::getTextEdit(TextMessageTab tab) const
|
||||||
{
|
{
|
||||||
QWidget *w = this->getTabWidget(tab);
|
QWidget *w = this->getTabWidget(tab);
|
||||||
if (!w) { return nullptr; }
|
if (!w) { return nullptr; }
|
||||||
return this->findChild<CTextMessageTextEdit *>();
|
return this->findChild<CTextMessageTextEdit *>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTextMessageComponent::selectTabWidget(CTextMessageComponent::Tab tab)
|
void CTextMessageComponent::selectTabWidget(TextMessageTab tab)
|
||||||
{
|
{
|
||||||
QWidget *w = this->getTabWidget(tab);
|
QWidget *w = this->getTabWidget(tab);
|
||||||
if (w)
|
if (w)
|
||||||
@@ -272,7 +272,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
bool CTextMessageComponent::isCorrespondingTextMessageTabSelected(CTextMessage textMessage) const
|
bool CTextMessageComponent::isCorrespondingTextMessageTabSelected(CTextMessage textMessage) const
|
||||||
{
|
{
|
||||||
if (!this->isVisibleWidget()) { return false; }
|
if (!this->isVisibleWidgetHack()) { return false; }
|
||||||
if (!textMessage.hasValidRecipient()) { return false; }
|
if (!textMessage.hasValidRecipient()) { return false; }
|
||||||
if (textMessage.isEmpty()) { return false; } // ignore empty message
|
if (textMessage.isEmpty()) { return false; } // ignore empty message
|
||||||
if (textMessage.isPrivateMessage())
|
if (textMessage.isPrivateMessage())
|
||||||
@@ -460,9 +460,14 @@ namespace BlackGui
|
|||||||
this->handleEnteredTextMessage(cl);
|
this->handleEnteredTextMessage(cl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CTextMessageComponent::isVisibleWidgetHack() const
|
||||||
|
{
|
||||||
|
return m_usedAsOverlayWidget ? true : this->isVisibleWidget();
|
||||||
|
}
|
||||||
|
|
||||||
void CTextMessageComponent::handleEnteredTextMessage(const QString &textMessage)
|
void CTextMessageComponent::handleEnteredTextMessage(const QString &textMessage)
|
||||||
{
|
{
|
||||||
if (!this->isVisibleWidget()) { return; }
|
if (!this->isVisibleWidgetHack()) { return; }
|
||||||
|
|
||||||
QString cl(textMessage.trimmed().simplified());
|
QString cl(textMessage.trimmed().simplified());
|
||||||
if (cl.isEmpty()) { return; }
|
if (cl.isEmpty()) { return; }
|
||||||
@@ -549,7 +554,7 @@ namespace BlackGui
|
|||||||
if (commandLine.isEmpty() || commandLine.startsWith(".")) { return false; }
|
if (commandLine.isEmpty() || commandLine.startsWith(".")) { return false; }
|
||||||
|
|
||||||
// no "dot" command input
|
// 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
|
this->handleEnteredTextMessage(commandLine); // handle as it was entered by own command line
|
||||||
|
|
||||||
return false; // we never handle the message directly, but forward it
|
return false; // we never handle the message directly, but forward it
|
||||||
@@ -587,5 +592,20 @@ namespace BlackGui
|
|||||||
ui->comp_SettingsStyle->fontSizePlus();
|
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
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#ifndef BLACKGUI_COMPONENTS_TEXTMESSAGECOMPONENT_H
|
#ifndef BLACKGUI_COMPONENTS_TEXTMESSAGECOMPONENT_H
|
||||||
#define BLACKGUI_COMPONENTS_TEXTMESSAGECOMPONENT_H
|
#define BLACKGUI_COMPONENTS_TEXTMESSAGECOMPONENT_H
|
||||||
|
|
||||||
|
#include "textmessagecomponenttab.h"
|
||||||
#include "blackgui/settings/textmessagesettings.h"
|
#include "blackgui/settings/textmessagesettings.h"
|
||||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||||
#include "blackgui/blackguiexport.h"
|
#include "blackgui/blackguiexport.h"
|
||||||
@@ -40,15 +41,6 @@ namespace BlackGui
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Tabs
|
|
||||||
enum Tab
|
|
||||||
{
|
|
||||||
TextMessagesAll,
|
|
||||||
TextMessagesUnicom,
|
|
||||||
TextMessagesCom1,
|
|
||||||
TextMessagesCom2
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
explicit CTextMessageComponent(QWidget *parent = nullptr);
|
explicit CTextMessageComponent(QWidget *parent = nullptr);
|
||||||
|
|
||||||
@@ -76,6 +68,18 @@ namespace BlackGui
|
|||||||
void fontSizePlus();
|
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:
|
signals:
|
||||||
//! Message to be displayed in info window
|
//! Message to be displayed in info window
|
||||||
void displayInInfoWindow(const BlackMisc::CVariant &message, int displayDurationMs) const;
|
void displayInInfoWindow(const BlackMisc::CVariant &message, int displayDurationMs) const;
|
||||||
@@ -87,15 +91,16 @@ namespace BlackGui
|
|||||||
QScopedPointer<Ui::CTextMessageComponent> ui;
|
QScopedPointer<Ui::CTextMessageComponent> ui;
|
||||||
BlackMisc::CIdentifier m_identifier { "TextMessageComponent", this };
|
BlackMisc::CIdentifier m_identifier { "TextMessageComponent", this };
|
||||||
BlackMisc::CSetting<Settings::TextMessageSettings> m_messageSettings { this, &CTextMessageComponent::onSettingsChanged };
|
BlackMisc::CSetting<Settings::TextMessageSettings> m_messageSettings { this, &CTextMessageComponent::onSettingsChanged };
|
||||||
|
bool m_usedAsOverlayWidget = false; //!< disables dockwidget parts
|
||||||
|
|
||||||
//! Enum to widget
|
//! Enum to widget
|
||||||
QWidget *getTabWidget(Tab tab) const;
|
QWidget *getTabWidget(TextMessageTab tab) const;
|
||||||
|
|
||||||
//! Related text edit
|
//! Related text edit
|
||||||
CTextMessageTextEdit *getTextEdit(Tab tab) const;
|
CTextMessageTextEdit *getTextEdit(TextMessageTab tab) const;
|
||||||
|
|
||||||
//! Select given tab
|
//! Select given tab
|
||||||
void selectTabWidget(Tab tab);
|
void selectTabWidget(TextMessageTab tab);
|
||||||
|
|
||||||
//! New message tab for given callsign
|
//! New message tab for given callsign
|
||||||
QWidget *addNewTextMessageTab(const BlackMisc::Aviation::CCallsign &callsign);
|
QWidget *addNewTextMessageTab(const BlackMisc::Aviation::CCallsign &callsign);
|
||||||
@@ -166,6 +171,9 @@ namespace BlackGui
|
|||||||
|
|
||||||
//! Command line entered
|
//! Command line entered
|
||||||
void textMessageEntered();
|
void textMessageEntered();
|
||||||
|
|
||||||
|
//! Visible widget hack
|
||||||
|
bool isVisibleWidgetHack() const;
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
} // 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