mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-01 16:05:07 +01:00
Moved the password icon to the room name.
Also added a dark mode lock icon as well (and fixed a small bug preventing the lock icon from showing up)
This commit is contained in:
parent
aa391ed60d
commit
3be7aa2cfc
BIN
dist/qt_themes/qdarkstyle/icons/16x16/lock.png
vendored
Normal file
BIN
dist/qt_themes/qdarkstyle/icons/16x16/lock.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 304 B |
1
dist/qt_themes/qdarkstyle/style.qrc
vendored
1
dist/qt_themes/qdarkstyle/style.qrc
vendored
@ -1,6 +1,7 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="icons/qdarkstyle">
|
<qresource prefix="icons/qdarkstyle">
|
||||||
<file alias="index.theme">icons/index.theme</file>
|
<file alias="index.theme">icons/index.theme</file>
|
||||||
|
<file alias="16x16/lock.png">icons/16x16/lock.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="qss_icons">
|
<qresource prefix="qss_icons">
|
||||||
<file>rc/up_arrow_disabled.png</file>
|
<file>rc/up_arrow_disabled.png</file>
|
||||||
|
@ -119,8 +119,8 @@ void Lobby::OnJoinRoom(const QModelIndex& index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get a password to pass if the room is password protected
|
// Get a password to pass if the room is password protected
|
||||||
QModelIndex password_index = proxy->index(index.row(), Column::PASSWORD);
|
QModelIndex password_index = proxy->index(index.row(), Column::ROOM_NAME);
|
||||||
bool has_password = proxy->data(password_index, LobbyItemPassword::PasswordRole).toBool();
|
bool has_password = proxy->data(password_index, LobbyItemName::PasswordRole).toBool();
|
||||||
const std::string password = has_password ? PasswordPrompt().toStdString() : "";
|
const std::string password = has_password ? PasswordPrompt().toStdString() : "";
|
||||||
if (has_password && password.empty()) {
|
if (has_password && password.empty()) {
|
||||||
return;
|
return;
|
||||||
@ -161,7 +161,7 @@ void Lobby::OnStateChanged(const Network::RoomMember::State& state) {
|
|||||||
void Lobby::ResetModel() {
|
void Lobby::ResetModel() {
|
||||||
model->clear();
|
model->clear();
|
||||||
model->insertColumns(0, Column::TOTAL);
|
model->insertColumns(0, Column::TOTAL);
|
||||||
model->setHeaderData(Column::PASSWORD, Qt::Horizontal, tr("Password"), Qt::DisplayRole);
|
model->setHeaderData(Column::EXPAND, Qt::Horizontal, "", Qt::DisplayRole);
|
||||||
model->setHeaderData(Column::ROOM_NAME, Qt::Horizontal, tr("Room Name"), Qt::DisplayRole);
|
model->setHeaderData(Column::ROOM_NAME, Qt::Horizontal, tr("Room Name"), Qt::DisplayRole);
|
||||||
model->setHeaderData(Column::GAME_NAME, Qt::Horizontal, tr("Preferred Game"), Qt::DisplayRole);
|
model->setHeaderData(Column::GAME_NAME, Qt::Horizontal, tr("Preferred Game"), Qt::DisplayRole);
|
||||||
model->setHeaderData(Column::HOST, Qt::Horizontal, tr("Host"), Qt::DisplayRole);
|
model->setHeaderData(Column::HOST, Qt::Horizontal, tr("Host"), Qt::DisplayRole);
|
||||||
@ -200,10 +200,10 @@ void Lobby::OnRefreshLobby() {
|
|||||||
members.append(var);
|
members.append(var);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto first_item = new LobbyItemPassword(room.has_password);
|
auto first_item = new LobbyItem();
|
||||||
auto row = QList<QStandardItem*>({
|
auto row = QList<QStandardItem*>({
|
||||||
first_item,
|
first_item,
|
||||||
new LobbyItemName(QString::fromStdString(room.name)),
|
new LobbyItemName(room.has_password, QString::fromStdString(room.name)),
|
||||||
new LobbyItemGame(room.preferred_game_id, QString::fromStdString(room.preferred_game),
|
new LobbyItemGame(room.preferred_game_id, QString::fromStdString(room.preferred_game),
|
||||||
smdh_icon),
|
smdh_icon),
|
||||||
new LobbyItemHost(QString::fromStdString(room.owner), QString::fromStdString(room.ip),
|
new LobbyItemHost(QString::fromStdString(room.owner), QString::fromStdString(room.ip),
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
namespace Column {
|
namespace Column {
|
||||||
enum List {
|
enum List {
|
||||||
PASSWORD,
|
EXPAND,
|
||||||
ROOM_NAME,
|
ROOM_NAME,
|
||||||
GAME_NAME,
|
GAME_NAME,
|
||||||
HOST,
|
HOST,
|
||||||
@ -28,43 +28,28 @@ public:
|
|||||||
virtual ~LobbyItem() override {}
|
virtual ~LobbyItem() override {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class LobbyItemPassword : public LobbyItem {
|
class LobbyItemName : public LobbyItem {
|
||||||
public:
|
public:
|
||||||
static const int PasswordRole = Qt::UserRole + 1;
|
static const int NameRole = Qt::UserRole + 1;
|
||||||
|
static const int PasswordRole = Qt::UserRole + 2;
|
||||||
|
|
||||||
LobbyItemPassword() = default;
|
LobbyItemName() = default;
|
||||||
explicit LobbyItemPassword(const bool has_password) : LobbyItem() {
|
explicit LobbyItemName(bool has_password, QString name) : LobbyItem() {
|
||||||
|
setData(name, NameRole);
|
||||||
setData(has_password, PasswordRole);
|
setData(has_password, PasswordRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant data(int role) const override {
|
QVariant data(int role) const override {
|
||||||
if (role != Qt::DecorationRole) {
|
if (role == Qt::DecorationRole) {
|
||||||
return LobbyItem::data(role);
|
|
||||||
}
|
|
||||||
bool has_password = data(PasswordRole).toBool();
|
bool has_password = data(PasswordRole).toBool();
|
||||||
return has_password ? QIcon(":/icons/lock.png") : QIcon();
|
return has_password ? QIcon::fromTheme("lock").pixmap(16) : QIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator<(const QStandardItem& other) const override {
|
|
||||||
return data(PasswordRole).toBool() < other.data(PasswordRole).toBool();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class LobbyItemName : public LobbyItem {
|
|
||||||
public:
|
|
||||||
static const int NameRole = Qt::UserRole + 1;
|
|
||||||
|
|
||||||
LobbyItemName() = default;
|
|
||||||
explicit LobbyItemName(QString name) : LobbyItem() {
|
|
||||||
setData(name, NameRole);
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant data(int role) const override {
|
|
||||||
if (role != Qt::DisplayRole) {
|
if (role != Qt::DisplayRole) {
|
||||||
return LobbyItem::data(role);
|
return LobbyItem::data(role);
|
||||||
}
|
}
|
||||||
return data(NameRole).toString();
|
return data(NameRole).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator<(const QStandardItem& other) const override {
|
bool operator<(const QStandardItem& other) const override {
|
||||||
return data(NameRole).toString().localeAwareCompare(other.data(NameRole).toString()) < 0;
|
return data(NameRole).toString().localeAwareCompare(other.data(NameRole).toString()) < 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user