From 3be7aa2cfce6dfb3fb41da78c4fe7a248882109b Mon Sep 17 00:00:00 2001
From: James Rowe <jroweboy@gmail.com>
Date: Mon, 9 Apr 2018 10:18:12 -0600
Subject: [PATCH] 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)
---
 .../qt_themes/qdarkstyle/icons/16x16/lock.png | Bin 0 -> 304 bytes
 dist/qt_themes/qdarkstyle/style.qrc           |   1 +
 src/citra_qt/multiplayer/lobby.cpp            |  10 ++---
 src/citra_qt/multiplayer/lobby_p.h            |  37 ++++++------------
 4 files changed, 17 insertions(+), 31 deletions(-)
 create mode 100644 dist/qt_themes/qdarkstyle/icons/16x16/lock.png

diff --git a/dist/qt_themes/qdarkstyle/icons/16x16/lock.png b/dist/qt_themes/qdarkstyle/icons/16x16/lock.png
new file mode 100644
index 0000000000000000000000000000000000000000..c750a39e855800fe4cde217a1bf28f841030e501
GIT binary patch
literal 304
zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b
z3=G`DAk4@xYmNj^kiEpy*OmPd3#R~&?yEVTSwNw^o-U3d7N_S<x+vIWAm9?-#uUUP
z>%ktxROZ0mC!4`O#esdB1N*JU5{0l2e>jubge>mPSJ^&&?%8KcL>WvAo_9+JoM2kO
zsn>V#-&Rc~i~Ae_tY5EP-=*8Ab(MpM;j*Q7#*{i)r8@>Yr!28i{4k+p>J|4L=dRCP
zQYgN$Vq(bz-seA`PP+eLPWpo{(p_gRe3@1fbK~xheFC)y^e0Hmy!rd&s^O(iEb1#g
wo=%oNY{h!`>vV^`LLZb)T(e+SzEHyuo5c9`w}kC2php-yUHx3vIVCg!0C@XzqyPW_

literal 0
HcmV?d00001

diff --git a/dist/qt_themes/qdarkstyle/style.qrc b/dist/qt_themes/qdarkstyle/style.qrc
index efbd0b9dc..54a96b680 100644
--- a/dist/qt_themes/qdarkstyle/style.qrc
+++ b/dist/qt_themes/qdarkstyle/style.qrc
@@ -1,6 +1,7 @@
 <RCC>
   <qresource prefix="icons/qdarkstyle">
     <file alias="index.theme">icons/index.theme</file>
+    <file alias="16x16/lock.png">icons/16x16/lock.png</file>
   </qresource>
   <qresource prefix="qss_icons">
     <file>rc/up_arrow_disabled.png</file>
diff --git a/src/citra_qt/multiplayer/lobby.cpp b/src/citra_qt/multiplayer/lobby.cpp
index 91ba080fb..6780ac430 100644
--- a/src/citra_qt/multiplayer/lobby.cpp
+++ b/src/citra_qt/multiplayer/lobby.cpp
@@ -119,8 +119,8 @@ void Lobby::OnJoinRoom(const QModelIndex& index) {
     }
 
     // Get a password to pass if the room is password protected
-    QModelIndex password_index = proxy->index(index.row(), Column::PASSWORD);
-    bool has_password = proxy->data(password_index, LobbyItemPassword::PasswordRole).toBool();
+    QModelIndex password_index = proxy->index(index.row(), Column::ROOM_NAME);
+    bool has_password = proxy->data(password_index, LobbyItemName::PasswordRole).toBool();
     const std::string password = has_password ? PasswordPrompt().toStdString() : "";
     if (has_password && password.empty()) {
         return;
@@ -161,7 +161,7 @@ void Lobby::OnStateChanged(const Network::RoomMember::State& state) {
 void Lobby::ResetModel() {
     model->clear();
     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::GAME_NAME, Qt::Horizontal, tr("Preferred Game"), Qt::DisplayRole);
     model->setHeaderData(Column::HOST, Qt::Horizontal, tr("Host"), Qt::DisplayRole);
@@ -200,10 +200,10 @@ void Lobby::OnRefreshLobby() {
             members.append(var);
         }
 
-        auto first_item = new LobbyItemPassword(room.has_password);
+        auto first_item = new LobbyItem();
         auto row = QList<QStandardItem*>({
             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),
                               smdh_icon),
             new LobbyItemHost(QString::fromStdString(room.owner), QString::fromStdString(room.ip),
diff --git a/src/citra_qt/multiplayer/lobby_p.h b/src/citra_qt/multiplayer/lobby_p.h
index a177bc66d..fa8580349 100644
--- a/src/citra_qt/multiplayer/lobby_p.h
+++ b/src/citra_qt/multiplayer/lobby_p.h
@@ -12,7 +12,7 @@
 
 namespace Column {
 enum List {
-    PASSWORD,
+    EXPAND,
     ROOM_NAME,
     GAME_NAME,
     HOST,
@@ -28,43 +28,28 @@ public:
     virtual ~LobbyItem() override {}
 };
 
-class LobbyItemPassword : public LobbyItem {
+class LobbyItemName : public LobbyItem {
 public:
-    static const int PasswordRole = Qt::UserRole + 1;
+    static const int NameRole = Qt::UserRole + 1;
+    static const int PasswordRole = Qt::UserRole + 2;
 
-    LobbyItemPassword() = default;
-    explicit LobbyItemPassword(const bool has_password) : LobbyItem() {
+    LobbyItemName() = default;
+    explicit LobbyItemName(bool has_password, QString name) : LobbyItem() {
+        setData(name, NameRole);
         setData(has_password, PasswordRole);
     }
 
     QVariant data(int role) const override {
-        if (role != Qt::DecorationRole) {
-            return LobbyItem::data(role);
+        if (role == Qt::DecorationRole) {
+            bool has_password = data(PasswordRole).toBool();
+            return has_password ? QIcon::fromTheme("lock").pixmap(16) : QIcon();
         }
-        bool has_password = data(PasswordRole).toBool();
-        return has_password ? QIcon(":/icons/lock.png") : 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) {
             return LobbyItem::data(role);
         }
         return data(NameRole).toString();
     }
+
     bool operator<(const QStandardItem& other) const override {
         return data(NameRole).toString().localeAwareCompare(other.data(NameRole).toString()) < 0;
     }