mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 12:35:43 +08:00
Ref T506, SUP text message with red close buttons
This commit is contained in:
committed by
Mat Sutcliffe
parent
8696f45a7c
commit
a08b2fff3c
@@ -394,33 +394,36 @@ namespace BlackGui
|
|||||||
if (callsign.isEmpty()) { return nullptr; }
|
if (callsign.isEmpty()) { return nullptr; }
|
||||||
QWidget *w = this->findTextMessageTabByCallsign(callsign, false);
|
QWidget *w = this->findTextMessageTabByCallsign(callsign, false);
|
||||||
if (w) { return w; }
|
if (w) { return w; }
|
||||||
return this->addNewTextMessageTab(callsign.asString());
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *CTextMessageComponent::addNewTextMessageTab(const QString &tabName)
|
const QString tabName = callsign.asString();
|
||||||
{
|
QWidget *newTabWidget = new QWidget(this);
|
||||||
QWidget *newTab = new QWidget(this);
|
newTabWidget->setObjectName("Tab widget " + tabName);
|
||||||
newTab->setObjectName("Tab widget " + tabName);
|
QPushButton *closeButton = new QPushButton("Close", newTabWidget);
|
||||||
QPushButton *closeButton = new QPushButton("Close", newTab);
|
QVBoxLayout *layout = new QVBoxLayout(newTabWidget);
|
||||||
QVBoxLayout *layout = new QVBoxLayout(newTab);
|
CTextMessageTextEdit *textEdit = new CTextMessageTextEdit(newTabWidget);
|
||||||
CTextMessageTextEdit *textEdit = new CTextMessageTextEdit(newTab);
|
|
||||||
textEdit->setObjectName("tep_" + tabName);
|
textEdit->setObjectName("tep_" + tabName);
|
||||||
int marginLeft, marginRight, marginTop, marginBottom;
|
int marginLeft, marginRight, marginTop, marginBottom;
|
||||||
ui->tb_TextMessagesAll->layout()->getContentsMargins(&marginLeft, &marginTop, &marginRight, &marginBottom);
|
ui->tb_TextMessagesAll->layout()->getContentsMargins(&marginLeft, &marginTop, &marginRight, &marginBottom);
|
||||||
newTab->layout()->setContentsMargins(marginLeft, marginTop, marginRight, 2);
|
newTabWidget->layout()->setContentsMargins(marginLeft, marginTop, marginRight, 2);
|
||||||
layout->addWidget(textEdit);
|
layout->addWidget(textEdit);
|
||||||
layout->addWidget(closeButton);
|
layout->addWidget(closeButton);
|
||||||
newTab->setLayout(layout);
|
newTabWidget->setLayout(layout);
|
||||||
textEdit->setContextMenuPolicy(Qt::CustomContextMenu);
|
textEdit->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
const int index = ui->tw_TextMessages->addTab(newTab, tabName);
|
const int index = ui->tw_TextMessages->addTab(newTabWidget, tabName);
|
||||||
QToolButton *closeButtonInTab = new QToolButton(newTab);
|
QToolButton *closeButtonInTab = new QToolButton(newTabWidget);
|
||||||
closeButtonInTab->setText("[X]");
|
closeButtonInTab->setText("[X]");
|
||||||
ui->tw_TextMessages->tabBar()->setTabButton(index, QTabBar::RightSide, closeButtonInTab); // changes parent
|
QTabBar *bar = ui->tw_TextMessages->tabBar();
|
||||||
|
bar->setTabButton(index, QTabBar::RightSide, closeButtonInTab); // changes parent
|
||||||
|
if (callsign.isSupervisorCallsign())
|
||||||
|
{
|
||||||
|
//! \fixme hardcoded stylesheet color
|
||||||
|
closeButtonInTab->setStyleSheet("background-color: red;");
|
||||||
|
bar->setTabIcon(index, callsign.toPixmap());
|
||||||
|
bar->setTabTextColor(index, QColor(Qt::yellow));
|
||||||
|
}
|
||||||
ui->tw_TextMessages->setCurrentIndex(index);
|
ui->tw_TextMessages->setCurrentIndex(index);
|
||||||
closeButton->setProperty("tabName", tabName);
|
|
||||||
closeButtonInTab->setProperty("tabName", tabName);
|
closeButtonInTab->setProperty("tabName", tabName);
|
||||||
// closeButton->setProperty("index", index);
|
closeButton->setProperty("tabName", tabName);
|
||||||
// closeButtonInTab->setProperty("index", index);
|
|
||||||
|
|
||||||
connect(closeButton, &QPushButton::released, this, &CTextMessageComponent::closeTextMessageTab);
|
connect(closeButton, &QPushButton::released, this, &CTextMessageComponent::closeTextMessageTab);
|
||||||
connect(closeButtonInTab, &QPushButton::released, this, &CTextMessageComponent::closeTextMessageTab);
|
connect(closeButtonInTab, &QPushButton::released, this, &CTextMessageComponent::closeTextMessageTab);
|
||||||
@@ -430,7 +433,7 @@ namespace BlackGui
|
|||||||
const QString realName = sGui->getIContextNetwork()->getUserForCallsign(CCallsign(tabName)).getRealName();
|
const QString realName = sGui->getIContextNetwork()->getUserForCallsign(CCallsign(tabName)).getRealName();
|
||||||
if (!realName.isEmpty()) { ui->tw_TextMessages->setTabToolTip(index, realName); }
|
if (!realName.isEmpty()) { ui->tw_TextMessages->setTabToolTip(index, realName); }
|
||||||
}
|
}
|
||||||
return newTab;
|
return newTabWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTextMessageComponent::addPrivateChannelTextMessage(const CTextMessage &textMessage)
|
void CTextMessageComponent::addPrivateChannelTextMessage(const CTextMessage &textMessage)
|
||||||
|
|||||||
@@ -136,10 +136,6 @@ namespace BlackGui
|
|||||||
//! 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);
|
||||||
|
|
||||||
//! Add new text message tab
|
|
||||||
//! \param tabName name of the new tab, usually the channel name
|
|
||||||
QWidget *addNewTextMessageTab(const QString &tabName);
|
|
||||||
|
|
||||||
//! Find text message tab by callsign
|
//! Find text message tab by callsign
|
||||||
QWidget *findTextMessageTabByCallsign(const BlackMisc::Aviation::CCallsign &callsign, bool callsignResolution = false) const;
|
QWidget *findTextMessageTabByCallsign(const BlackMisc::Aviation::CCallsign &callsign, bool callsignResolution = false) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user