Display Registered Hosts in SettingsDialog

This commit is contained in:
Florian Märkl 2019-08-16 14:39:54 +02:00
commit c993ca611e
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
12 changed files with 192 additions and 16 deletions

View file

@ -32,12 +32,23 @@ class HostMAC
public:
HostMAC() { memset(mac, 0, sizeof(mac)); }
HostMAC(const HostMAC &o) { memcpy(mac, o.GetMAC(), sizeof(mac)); }
explicit HostMAC(const uint8_t mac[6]) { memcpy(this->mac, mac, sizeof(this->mac)); }
const uint8_t *GetMAC() const { return mac; }
QString ToString() const { return QByteArray((const char *)mac, sizeof(mac)).toHex(); }
uint64_t GetValue() const
{
return ((uint64_t)mac[0] << 0x28)
| ((uint64_t)mac[1] << 0x20)
| ((uint64_t)mac[2] << 0x18)
| ((uint64_t)mac[3] << 0x10)
| ((uint64_t)mac[4] << 0x8)
| mac[5];
}
};
static bool operator==(const HostMAC &a, const HostMAC &b) { return memcmp(a.GetMAC(), b.GetMAC(), 6) == 0; }
static bool operator==(const HostMAC &a, const HostMAC &b) { return memcmp(a.GetMAC(), b.GetMAC(), 6) == 0; }
static bool operator<(const HostMAC &a, const HostMAC &b) { return a.GetValue() < b.GetValue(); }
class RegisteredHost
{
@ -54,14 +65,18 @@ class RegisteredHost
public:
RegisteredHost();
RegisteredHost(const RegisteredHost &o);
RegisteredHost(const ChiakiRegisteredHost &chiaki_host);
const HostMAC &GetPS4MAC() const { return ps4_mac; }
const QString &GetPS4Nickname() const { return ps4_nickname; }
void SaveToSettings(QSettings *settings);
void SaveToSettings(QSettings *settings) const;
static RegisteredHost LoadFromSettings(QSettings *settings);
};
Q_DECLARE_METATYPE(RegisteredHost)
Q_DECLARE_METATYPE(HostMAC)
#endif //CHIAKI_HOST_H