mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
Fixed several issues detected during testing / review (refs #304)
* MS report 1-5 https://dev.vatsim-germany.org/issues/304#change-1800 * Clang warning https://dev.vatsim-germany.org/boards/22/topics/1982?r=1997#message-1997 * Wrong indexes for dockable widgets, RW: https://dev.vatsim-germany.org/issues/304#note-13 * Fixed wrong offset in Fsuipc class * Improved position handling for floating widgets opened 1st time
This commit is contained in:
@@ -28,7 +28,7 @@ namespace BlackMisc
|
||||
CIcon() {}
|
||||
|
||||
//! Constructor.
|
||||
CIcon(CIcons::IconIndexes index, const QString &descriptiveText) :
|
||||
CIcon( CIcons::IconIndex index, const QString &descriptiveText) :
|
||||
m_index(static_cast<int>(index)), m_descriptiveText(descriptiveText) {}
|
||||
|
||||
//! \copydoc CValueObject::toQVariant
|
||||
@@ -38,7 +38,7 @@ namespace BlackMisc
|
||||
const QString &getDescriptiveText() const { return this->m_descriptiveText; }
|
||||
|
||||
//! Index
|
||||
CIcons::IconIndexes getIndex() const { return static_cast<CIcons::IconIndexes>(this->m_index);}
|
||||
CIcons::IconIndex getIndex() const { return static_cast< CIcons::IconIndex>(this->m_index);}
|
||||
|
||||
//! Corresponding pixmap
|
||||
QPixmap toPixmap() const;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace BlackMisc
|
||||
CSequence<CIcon>(other)
|
||||
{ }
|
||||
|
||||
CIcon CIconList::findByIndex(CIcons::IconIndexes index) const
|
||||
CIcon CIconList::findByIndex(CIcons::IconIndex index) const
|
||||
{
|
||||
return this->findBy(&CIcon::getIndex, index).frontOrDefault();
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace BlackMisc
|
||||
CIconList(const CSequence<CIcon> &other);
|
||||
|
||||
//! Find by index
|
||||
CIcon findByIndex(CIcons::IconIndexes index) const;
|
||||
CIcon findByIndex(CIcons::IconIndex index) const;
|
||||
|
||||
//! \copydoc CValueObject::asQVariant
|
||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||
@@ -126,24 +126,18 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
//! Icon for given index
|
||||
static const CIcon &iconForIndex(CIcons::IconIndexes index)
|
||||
static const CIcon &iconForIndex(CIcons::IconIndex index)
|
||||
{
|
||||
// remark, find by is copy, need reference of icon
|
||||
int s = allIcons().size();
|
||||
for (int i = 0; i < s; i++)
|
||||
{
|
||||
if (allIcons()[i].getIndex() == index)
|
||||
{
|
||||
return allIcons()[i];
|
||||
}
|
||||
}
|
||||
auto foundRange = allIcons().findBy(&CIcon::getIndex, index);
|
||||
if (!foundRange.isEmpty()) { return foundRange.front(); }
|
||||
Q_ASSERT_X(false, "iconForIndex", "Missing index");
|
||||
return iconForIndex(CIcons::StandardIconUnknown16);
|
||||
}
|
||||
|
||||
//! Icon for given index
|
||||
static const CIcon &iconForIndex(int index) {
|
||||
return iconForIndex(static_cast<CIcons::IconIndexes>(index));
|
||||
static const CIcon &iconForIndex(int index)
|
||||
{
|
||||
return iconForIndex(static_cast<CIcons::IconIndex>(index));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -19,14 +19,13 @@ namespace BlackMisc
|
||||
//! Standard icons
|
||||
class CIcons
|
||||
{
|
||||
private:
|
||||
//! Constructor, use class static only
|
||||
CIcons();
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor, use class static only
|
||||
CIcons() = delete;
|
||||
|
||||
//! Index for each icon, allows to send them via DBus, efficiently store them, etc.
|
||||
enum IconIndexes
|
||||
enum IconIndex
|
||||
{
|
||||
NotSet,
|
||||
StandardIconInfo16,
|
||||
@@ -606,7 +605,7 @@ namespace BlackMisc
|
||||
// -------------------------------------------------------------
|
||||
|
||||
//! Pixmap by given index
|
||||
static const QPixmap &pixmapByIndex(IconIndexes index)
|
||||
static const QPixmap &pixmapByIndex(IconIndex index)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
@@ -687,7 +686,7 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
//! Pixmap by given index rotated
|
||||
static QPixmap pixmapByIndex(IconIndexes index, int rotateDegrees)
|
||||
static QPixmap pixmapByIndex(IconIndex index, int rotateDegrees)
|
||||
{
|
||||
const QPixmap original = pixmapByIndex(index);
|
||||
if (rotateDegrees == 0) return original;
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace BlackMisc
|
||||
case IndexIcon:
|
||||
if (variant.canConvert<int>())
|
||||
{
|
||||
CIcons::IconIndexes index = static_cast<CIcons::IconIndexes>(variant.toInt());
|
||||
CIcons::IconIndex index = static_cast<CIcons::IconIndex>(variant.toInt());
|
||||
this->m_icon = CIconList::iconForIndex(index);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user