refs #288, some GUI elements

* tick label, shows OK/failure
* serverlist selector, select 1 of servers
* used tick label in selcal selector
* fixed include in transponder mode selector
This commit is contained in:
Klaus Basan
2014-11-10 20:31:03 +01:00
committed by Roland Winklmeier
parent 0098fd3d58
commit 89806e69ce
7 changed files with 231 additions and 13 deletions

View File

@@ -23,6 +23,7 @@ namespace BlackGui
this->ui->setupUi(this);
this->resetSelcalCodes(true);
this->setValidityHint();
this->ui->lblp_ValidCodeIcon->setToolTips("valid SELCAL", "invalid SELCAL");
bool c;
c = connect(this->ui->cb_SelcalPairs1, SIGNAL(currentIndexChanged(int)), this, SLOT(ps_selcalIndexChanged()));
@@ -103,15 +104,6 @@ namespace BlackGui
void CSelcalCodeSelector::setValidityHint()
{
if (this->hasValidCode())
{
this->ui->lbl_ValidCodeIcon->setPixmap(CIcons::tick16());
this->ui->lbl_ValidCodeIcon->setToolTip("valid SELCAL");
}
else
{
this->ui->lbl_ValidCodeIcon->setPixmap(CIcons::cross16());
this->ui->lbl_ValidCodeIcon->setToolTip("invalid SELCAL");
}
this->ui->lblp_ValidCodeIcon->setTicked(this->hasValidCode());
}
} // namespace

View File

@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>143</width>
<width>151</width>
<height>22</height>
</rect>
</property>
@@ -42,7 +42,7 @@
<widget class="QComboBox" name="cb_SelcalPairs2"/>
</item>
<item>
<widget class="QLabel" name="lbl_ValidCodeIcon">
<widget class="BlackGui::CTickLabel" name="lblp_ValidCodeIcon">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
@@ -59,6 +59,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::CTickLabel</class>
<extends>QLabel</extends>
<header>blackgui/ticklabel.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../blackmisc/blackmisc.qrc"/>
</resources>

View File

@@ -0,0 +1,48 @@
/* Copyright (C) 2013
* 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 top-level
* directory of this distribution and at http://www.swift-project.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.
*/
#include "serverlistselector.h"
using namespace BlackMisc::Network;
namespace BlackGui
{
CServerListSelector::CServerListSelector(QWidget *parent) :
QComboBox(parent)
{
}
void CServerListSelector::setServers(const BlackMisc::Network::CServerList &servers)
{
if (this->m_servers == servers) { return; }
this->setItemStrings(servers);
}
BlackMisc::Network::CServer CServerListSelector::currentServer() const
{
int i = currentIndex();
if (i < 0 || i >= m_servers.size()) { return CServer(); }
return m_servers[i];
}
void CServerListSelector::setItemStrings(const CServerList &servers)
{
this->m_servers = servers;
this->m_items.clear();
foreach(CServer server, servers)
{
QString d(server.getName() + ": " + server.getDescription());
m_items.append(d);
}
this->clear(); // ui
this->addItems(m_items);
}
} // namespace

View File

@@ -0,0 +1,49 @@
/* Copyright (C) 2013
* 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 top-level
* directory of this distribution and at http://www.swift-project.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_SERVERLISTSELECTOR_H
#define BLACKGUI_SERVERLISTSELECTOR_H
#include <QComboBox>
#include <QStringList>
#include "blackmisc/nwserverlist.h"
namespace BlackGui
{
//! List of servers
class CServerListSelector : public QComboBox
{
Q_OBJECT
public:
//! Constructor
explicit CServerListSelector(QWidget *parent = nullptr);
//! Set the servers
void setServers(const BlackMisc::Network::CServerList &servers);
//! Get the current server
BlackMisc::Network::CServer currentServer() const;
private:
//! Build the item string descriptions
void setItemStrings(const BlackMisc::Network::CServerList &servers);
BlackMisc::Network::CServerList m_servers; //!< corresponding servers
QStringList m_items; //!< items strings
};
} // namespace
#endif // guard

View File

@@ -0,0 +1,62 @@
/* Copyright (C) 2013
* 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 top-level
* directory of this distribution and at http://www.swift-project.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.
*/
#include "ticklabel.h"
#include "blackmisc/icons.h"
using namespace BlackMisc;
namespace BlackGui
{
CTickLabel::CTickLabel(QWidget *parent) :
QLabel(parent)
{
this->setText("");
this->setMargin(0);
this->setMaximumSize(CIcons::tick16().size());
this->setLabel();
}
void CTickLabel::setTicked(bool ticked)
{
if (m_isPixmapTicked == ticked) { return; }
this->m_isPixmapTicked = ticked;
this->setLabel();
emit tickChanged(this->m_isPixmapTicked);
}
void BlackGui::CTickLabel::setToolTips(const QString &ticked, const QString &unticked)
{
m_toolTipTicked = ticked;
m_toolTipUnticked = unticked;
this->setLabel();
}
void CTickLabel::setPixmapTicked(const QPixmap &pixmap)
{
m_pixmapTicked = pixmap;
this->setLabel();
}
void CTickLabel::setPixmapUnticked(const QPixmap &pixmap)
{
m_pixmapUnticked = pixmap;
this->setLabel();
}
void CTickLabel::setLabel()
{
this->setText("");
this->setPixmap(this->m_isPixmapTicked ? m_pixmapTicked : m_pixmapUnticked);
this->setToolTip(this->m_isPixmapTicked ? m_toolTipTicked : m_toolTipUnticked);
}
} // namespace

61
src/blackgui/ticklabel.h Normal file
View File

@@ -0,0 +1,61 @@
/* Copyright (C) 2013
* 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 top-level
* directory of this distribution and at http://www.swift-project.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 TICKLABEL_H
#define TICKLABEL_H
#include "blackmisc/icons.h"
#include <QLabel>
#include <QPixmap>
namespace BlackGui
{
//! Representing a ticked or crossed icon
class CTickLabel : public QLabel
{
Q_OBJECT
public:
//! Constructor
explicit CTickLabel(QWidget *parent = nullptr);
//! Set ticked
void setTicked(bool ticked);
//! Set the tool tips
void setToolTips(const QString &ticked, const QString &unticked);
//! Ticked pixmap
void setPixmapTicked(const QPixmap &pixmap);
//! Unticked pixmap
void setPixmapUnticked(const QPixmap &pixmap);
signals:
//! Changed ticked state
void tickChanged(bool ticked);
private:
bool m_isPixmapTicked = false; //!< ticked state
QString m_toolTipTicked = "on";
QString m_toolTipUnticked = "off";
QPixmap m_pixmapTicked = BlackMisc::CIcons::tick16();
QPixmap m_pixmapUnticked = BlackMisc::CIcons::cross16();
//! Set the label according to \sa
void setLabel();
};
} // namespace
#endif // guard

View File

@@ -12,7 +12,6 @@
#ifndef BLACKGUI_TRANSPONDERMODESELECTOR_H
#define BLACKGUI_TRANSPONDERMODESELECTOR_H
#include "blackmisc/aviotransponder.h"
#include "blackmisc/aviotransponder.h"
#include <QTimer>
#include <QComboBox>