Merge pull request #855 from Gingeh/account-list
This commit is contained in:
		| @@ -473,7 +473,7 @@ QString AccountData::accountDisplayString() const { | |||||||
|             return userName(); |             return userName(); | ||||||
|         } |         } | ||||||
|         case AccountType::Offline: { |         case AccountType::Offline: { | ||||||
|             return userName(); |             return QObject::tr("<Offline>"); | ||||||
|         } |         } | ||||||
|         case AccountType::MSA: { |         case AccountType::MSA: { | ||||||
|             if(xboxApiToken.extra.contains("gtg")) { |             if(xboxApiToken.extra.contains("gtg")) { | ||||||
|   | |||||||
| @@ -282,6 +282,10 @@ QVariant AccountList::data(const QModelIndex &index, int role) const | |||||||
|         case Qt::DisplayRole: |         case Qt::DisplayRole: | ||||||
|             switch (index.column()) |             switch (index.column()) | ||||||
|             { |             { | ||||||
|  |             case ProfileNameColumn: { | ||||||
|  |                 return account->profileName(); | ||||||
|  |             } | ||||||
|  |  | ||||||
|             case NameColumn: |             case NameColumn: | ||||||
|                 return account->accountDisplayString(); |                 return account->accountDisplayString(); | ||||||
|  |  | ||||||
| @@ -300,7 +304,7 @@ QVariant AccountList::data(const QModelIndex &index, int role) const | |||||||
|                         return tr("Offline", "Account status"); |                         return tr("Offline", "Account status"); | ||||||
|                     } |                     } | ||||||
|                     case AccountState::Online: { |                     case AccountState::Online: { | ||||||
|                         return tr("Online", "Account status"); |                         return tr("Ready", "Account status"); | ||||||
|                     } |                     } | ||||||
|                     case AccountState::Working: { |                     case AccountState::Working: { | ||||||
|                         return tr("Working", "Account status"); |                         return tr("Working", "Account status"); | ||||||
| @@ -320,10 +324,6 @@ QVariant AccountList::data(const QModelIndex &index, int role) const | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             case ProfileNameColumn: { |  | ||||||
|                 return account->profileName(); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             case MigrationColumn: { |             case MigrationColumn: { | ||||||
|                 if(account->isMSA() || account->isOffline()) { |                 if(account->isMSA() || account->isOffline()) { | ||||||
|                     return tr("N/A", "Can Migrate?"); |                     return tr("N/A", "Can Migrate?"); | ||||||
| @@ -349,7 +349,7 @@ QVariant AccountList::data(const QModelIndex &index, int role) const | |||||||
|         case Qt::CheckStateRole: |         case Qt::CheckStateRole: | ||||||
|             switch (index.column()) |             switch (index.column()) | ||||||
|             { |             { | ||||||
|                 case NameColumn: |                 case ProfileNameColumn: | ||||||
|                     return account == m_defaultAccount ? Qt::Checked : Qt::Unchecked; |                     return account == m_defaultAccount ? Qt::Checked : Qt::Unchecked; | ||||||
|             } |             } | ||||||
|  |  | ||||||
| @@ -365,6 +365,8 @@ QVariant AccountList::headerData(int section, Qt::Orientation orientation, int r | |||||||
|     case Qt::DisplayRole: |     case Qt::DisplayRole: | ||||||
|         switch (section) |         switch (section) | ||||||
|         { |         { | ||||||
|  |         case ProfileNameColumn: | ||||||
|  |             return tr("Username"); | ||||||
|         case NameColumn: |         case NameColumn: | ||||||
|             return tr("Account"); |             return tr("Account"); | ||||||
|         case TypeColumn: |         case TypeColumn: | ||||||
| @@ -373,8 +375,6 @@ QVariant AccountList::headerData(int section, Qt::Orientation orientation, int r | |||||||
|             return tr("Status"); |             return tr("Status"); | ||||||
|         case MigrationColumn: |         case MigrationColumn: | ||||||
|             return tr("Can Migrate?"); |             return tr("Can Migrate?"); | ||||||
|         case ProfileNameColumn: |  | ||||||
|             return tr("Profile"); |  | ||||||
|         default: |         default: | ||||||
|             return QVariant(); |             return QVariant(); | ||||||
|         } |         } | ||||||
| @@ -382,6 +382,8 @@ QVariant AccountList::headerData(int section, Qt::Orientation orientation, int r | |||||||
|     case Qt::ToolTipRole: |     case Qt::ToolTipRole: | ||||||
|         switch (section) |         switch (section) | ||||||
|         { |         { | ||||||
|  |         case ProfileNameColumn: | ||||||
|  |             return tr("Minecraft username associated with the account."); | ||||||
|         case NameColumn: |         case NameColumn: | ||||||
|             return tr("User name of the account."); |             return tr("User name of the account."); | ||||||
|         case TypeColumn: |         case TypeColumn: | ||||||
| @@ -389,9 +391,7 @@ QVariant AccountList::headerData(int section, Qt::Orientation orientation, int r | |||||||
|         case StatusColumn: |         case StatusColumn: | ||||||
|             return tr("Current status of the account."); |             return tr("Current status of the account."); | ||||||
|         case MigrationColumn: |         case MigrationColumn: | ||||||
|             return tr("Can this account migrate to Microsoft account?"); |             return tr("Can this account migrate to a Microsoft account?"); | ||||||
|         case ProfileNameColumn: |  | ||||||
|             return tr("Name of the Minecraft profile associated with the account."); |  | ||||||
|         default: |         default: | ||||||
|             return QVariant(); |             return QVariant(); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -58,8 +58,8 @@ public: | |||||||
|     enum VListColumns |     enum VListColumns | ||||||
|     { |     { | ||||||
|         // TODO: Add icon column. |         // TODO: Add icon column. | ||||||
|         NameColumn = 0, |         ProfileNameColumn = 0, | ||||||
|         ProfileNameColumn, |         NameColumn, | ||||||
|         MigrationColumn, |         MigrationColumn, | ||||||
|         TypeColumn, |         TypeColumn, | ||||||
|         StatusColumn, |         StatusColumn, | ||||||
|   | |||||||
| @@ -73,9 +73,11 @@ AccountListPage::AccountListPage(QWidget *parent) | |||||||
|     m_accounts = APPLICATION->accounts(); |     m_accounts = APPLICATION->accounts(); | ||||||
|  |  | ||||||
|     ui->listView->setModel(m_accounts.get()); |     ui->listView->setModel(m_accounts.get()); | ||||||
|     ui->listView->header()->setSectionResizeMode(0, QHeaderView::Stretch); |     ui->listView->header()->setSectionResizeMode(AccountList::VListColumns::ProfileNameColumn, QHeaderView::Stretch); | ||||||
|     ui->listView->header()->setSectionResizeMode(1, QHeaderView::Stretch); |     ui->listView->header()->setSectionResizeMode(AccountList::VListColumns::NameColumn, QHeaderView::Stretch); | ||||||
|     ui->listView->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents); |     ui->listView->header()->setSectionResizeMode(AccountList::VListColumns::MigrationColumn, QHeaderView::ResizeToContents); | ||||||
|  |     ui->listView->header()->setSectionResizeMode(AccountList::VListColumns::TypeColumn, QHeaderView::ResizeToContents); | ||||||
|  |     ui->listView->header()->setSectionResizeMode(AccountList::VListColumns::StatusColumn, QHeaderView::ResizeToContents); | ||||||
|     ui->listView->setSelectionMode(QAbstractItemView::SingleSelection); |     ui->listView->setSelectionMode(QAbstractItemView::SingleSelection); | ||||||
|  |  | ||||||
|     // Expand the account column |     // Expand the account column | ||||||
| @@ -253,19 +255,21 @@ void AccountListPage::updateButtonStates() | |||||||
| { | { | ||||||
|     // If there is no selection, disable buttons that require something selected. |     // If there is no selection, disable buttons that require something selected. | ||||||
|     QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes(); |     QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes(); | ||||||
|     bool hasSelection = selection.size() > 0; |     bool hasSelection = !selection.empty(); | ||||||
|     bool accountIsReady = false; |     bool accountIsReady = false; | ||||||
|  |     bool accountIsOnline; | ||||||
|     if (hasSelection) |     if (hasSelection) | ||||||
|     { |     { | ||||||
|         QModelIndex selected = selection.first(); |         QModelIndex selected = selection.first(); | ||||||
|         MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value<MinecraftAccountPtr>(); |         MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value<MinecraftAccountPtr>(); | ||||||
|         accountIsReady = !account->isActive(); |         accountIsReady = !account->isActive(); | ||||||
|  |         accountIsOnline = !account->isOffline(); | ||||||
|     } |     } | ||||||
|     ui->actionRemove->setEnabled(accountIsReady); |     ui->actionRemove->setEnabled(accountIsReady); | ||||||
|     ui->actionSetDefault->setEnabled(accountIsReady); |     ui->actionSetDefault->setEnabled(accountIsReady); | ||||||
|     ui->actionUploadSkin->setEnabled(accountIsReady); |     ui->actionUploadSkin->setEnabled(accountIsReady && accountIsOnline); | ||||||
|     ui->actionDeleteSkin->setEnabled(accountIsReady); |     ui->actionDeleteSkin->setEnabled(accountIsReady && accountIsOnline); | ||||||
|     ui->actionRefresh->setEnabled(accountIsReady); |     ui->actionRefresh->setEnabled(accountIsReady && accountIsOnline); | ||||||
|  |  | ||||||
|     if(m_accounts->defaultAccount().get() == nullptr) { |     if(m_accounts->defaultAccount().get() == nullptr) { | ||||||
|         ui->actionNoDefault->setEnabled(false); |         ui->actionNoDefault->setEnabled(false); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Sefa Eyeoglu
					Sefa Eyeoglu