2
0
Эх сурвалжийг харах

Improve online lobby visual

nordsoft 3 жил өмнө
parent
commit
179cdee424

BIN
launcher/icons/room-private.png


+ 7 - 3
launcher/lobby/lobby_moc.cpp

@@ -67,7 +67,11 @@ void Lobby::serverCommand(const ServerCommand & command) try
 			QTableWidgetItem * sessionPlayerItem = new QTableWidgetItem(QString("%1/%2").arg(playersJoined).arg(playersTotal));
 			ui->sessionsTable->setItem(i, 1, sessionPlayerItem);
 
-			QTableWidgetItem * sessionProtectedItem = new QTableWidgetItem(args[tagPoint++]);
+			QTableWidgetItem * sessionProtectedItem = new QTableWidgetItem();
+			bool isPrivate = (args[tagPoint++] == "True");
+			sessionProtectedItem->setData(Qt::UserRole, isPrivate);
+			if(isPrivate)
+				sessionProtectedItem->setIcon(QIcon("icons:room-private.png"));
 			ui->sessionsTable->setItem(i, 2, sessionProtectedItem);
 		}
 		break;
@@ -236,8 +240,8 @@ void Lobby::on_joinButton_clicked()
 	auto * item = ui->sessionsTable->item(ui->sessionsTable->currentRow(), 0);
 	if(item)
 	{
-		auto isPrivate = ui->sessionsTable->item(ui->sessionsTable->currentRow(), 2)->text(); //check if private
-		if(isPrivate == "True")
+		auto isPrivate = ui->sessionsTable->item(ui->sessionsTable->currentRow(), 2)->data(Qt::UserRole).toBool();
+		if(isPrivate)
 			new LobbyRoomRequest(socketLobby, item->text(), this);
 		else
 			socketLobby.requestJoinSession(item->text(), "");

+ 19 - 1
launcher/lobby/lobby_moc.ui

@@ -95,6 +95,24 @@
          <property name="selectionBehavior">
           <enum>QAbstractItemView::SelectRows</enum>
          </property>
+         <attribute name="horizontalHeaderCascadingSectionResizes">
+          <bool>false</bool>
+         </attribute>
+         <attribute name="horizontalHeaderDefaultSectionSize">
+          <number>80</number>
+         </attribute>
+         <attribute name="horizontalHeaderShowSortIndicator" stdset="0">
+          <bool>false</bool>
+         </attribute>
+         <attribute name="horizontalHeaderStretchLastSection">
+          <bool>true</bool>
+         </attribute>
+         <attribute name="verticalHeaderMinimumSectionSize">
+          <number>20</number>
+         </attribute>
+         <attribute name="verticalHeaderDefaultSectionSize">
+          <number>20</number>
+         </attribute>
          <column>
           <property name="text">
            <string>Session</string>
@@ -107,7 +125,7 @@
          </column>
          <column>
           <property name="text">
-           <string>Private</string>
+           <string/>
           </property>
          </column>
         </widget>