diff options
author | Petr Mrázek <peterix@gmail.com> | 2019-07-19 08:29:31 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2019-07-19 08:29:31 +0200 |
commit | 81fdde6fddd0cb2bd0d2f4e69452a4c1f2742437 (patch) | |
tree | 858ec55495ab095db3ff97ba5a7ad8344c51843e /application/pages | |
parent | 3d5869e1cfc56aa1a8cc7b884fad0600cecc9e69 (diff) | |
download | PrismLauncher-81fdde6fddd0cb2bd0d2f4e69452a4c1f2742437.tar.gz PrismLauncher-81fdde6fddd0cb2bd0d2f4e69452a4c1f2742437.tar.bz2 PrismLauncher-81fdde6fddd0cb2bd0d2f4e69452a4c1f2742437.zip |
NOISSUE convert accounts page to use a toolbar for the side menu
Diffstat (limited to 'application/pages')
-rw-r--r-- | application/pages/global/AccountListPage.cpp | 43 | ||||
-rw-r--r-- | application/pages/global/AccountListPage.h | 17 | ||||
-rw-r--r-- | application/pages/global/AccountListPage.ui | 189 |
3 files changed, 126 insertions, 123 deletions
diff --git a/application/pages/global/AccountListPage.cpp b/application/pages/global/AccountListPage.cpp index 9b7f9d17..6ea6df9b 100644 --- a/application/pages/global/AccountListPage.cpp +++ b/application/pages/global/AccountListPage.cpp @@ -34,10 +34,14 @@ #include "MultiMC.h" AccountListPage::AccountListPage(QWidget *parent) - : QWidget(parent), ui(new Ui::AccountListPage) + : QMainWindow(parent), ui(new Ui::AccountListPage) { ui->setupUi(this); - ui->tabWidget->tabBar()->hide(); + ui->listView->setEmptyString(tr( + "Welcome!\n" + "If you're new here, you can click the \"Add\" button to add your Mojang or Minecraft account." + )); + ui->listView->setEmptyMode(VersionListView::String); m_accounts = MMC->accounts(); @@ -64,18 +68,27 @@ AccountListPage::~AccountListPage() delete ui; } +void AccountListPage::changeEvent(QEvent* event) +{ + if (event->type() == QEvent::LanguageChange) + { + ui->retranslateUi(this); + } + QMainWindow::changeEvent(event); +} + void AccountListPage::listChanged() { updateButtonStates(); } -void AccountListPage::on_addAccountBtn_clicked() +void AccountListPage::on_actionAdd_triggered() { addAccount(tr("Please enter your Mojang or Minecraft account username and password to add " "your account.")); } -void AccountListPage::on_rmAccountBtn_clicked() +void AccountListPage::on_actionRemove_triggered() { QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes(); if (selection.size() > 0) @@ -85,7 +98,7 @@ void AccountListPage::on_rmAccountBtn_clicked() } } -void AccountListPage::on_setDefaultBtn_clicked() +void AccountListPage::on_actionSetDefault_triggered() { QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes(); if (selection.size() > 0) @@ -97,7 +110,7 @@ void AccountListPage::on_setDefaultBtn_clicked() } } -void AccountListPage::on_noDefaultBtn_clicked() +void AccountListPage::on_actionNoDefault_triggered() { m_accounts->setActiveAccount(""); } @@ -107,11 +120,19 @@ void AccountListPage::updateButtonStates() // If there is no selection, disable buttons that require something selected. QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes(); - ui->rmAccountBtn->setEnabled(selection.size() > 0); - ui->setDefaultBtn->setEnabled(selection.size() > 0); - ui->uploadSkinBtn->setEnabled(selection.size() > 0); + ui->actionRemove->setEnabled(selection.size() > 0); + ui->actionSetDefault->setEnabled(selection.size() > 0); + ui->actionUploadSkin->setEnabled(selection.size() > 0); + + if(m_accounts->activeAccount().get() == nullptr) { + ui->actionNoDefault->setEnabled(false); + ui->actionNoDefault->setChecked(true); + } + else { + ui->actionNoDefault->setEnabled(true); + ui->actionNoDefault->setChecked(false); + } - ui->noDefaultBtn->setDown(m_accounts->activeAccount().get() == nullptr); } void AccountListPage::addAccount(const QString &errMsg) @@ -140,7 +161,7 @@ void AccountListPage::addAccount(const QString &errMsg) } } -void AccountListPage::on_uploadSkinBtn_clicked() +void AccountListPage::on_actionUploadSkin_triggered() { QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes(); if (selection.size() > 0) diff --git a/application/pages/global/AccountListPage.h b/application/pages/global/AccountListPage.h index 9db0db88..f4c94119 100644 --- a/application/pages/global/AccountListPage.h +++ b/application/pages/global/AccountListPage.h @@ -15,7 +15,7 @@ #pragma once -#include <QDialog> +#include <QMainWindow> #include <memory> #include "pages/BasePage.h" @@ -30,7 +30,7 @@ class AccountListPage; class AuthenticateTask; -class AccountListPage : public QWidget, public BasePage +class AccountListPage : public QMainWindow, public BasePage { Q_OBJECT public: @@ -59,17 +59,20 @@ public: return "Getting-Started#adding-an-account"; } +private: + void changeEvent(QEvent * event) override; + public slots: - void on_addAccountBtn_clicked(); + void on_actionAdd_triggered(); - void on_rmAccountBtn_clicked(); + void on_actionRemove_triggered(); - void on_setDefaultBtn_clicked(); + void on_actionSetDefault_triggered(); - void on_noDefaultBtn_clicked(); + void on_actionNoDefault_triggered(); - void on_uploadSkinBtn_clicked(); + void on_actionUploadSkin_triggered(); void listChanged(); diff --git a/application/pages/global/AccountListPage.ui b/application/pages/global/AccountListPage.ui index f4e87680..b56d0b59 100644 --- a/application/pages/global/AccountListPage.ui +++ b/application/pages/global/AccountListPage.ui @@ -1,122 +1,101 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>AccountListPage</class> - <widget class="QWidget" name="AccountListPage"> + <widget class="QMainWindow" name="AccountListPage"> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>694</width> - <height>609</height> + <width>800</width> + <height>600</height> </rect> </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <property name="leftMargin"> - <number>0</number> + <property name="windowTitle"> + <string>MainWindow</string> + </property> + <widget class="QWidget" name="centralwidget"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="VersionListView" name="listView"/> + </item> + </layout> + </widget> + <widget class="QToolBar" name="toolBar"> + <property name="windowTitle"> + <string>toolBar</string> + </property> + <property name="movable"> + <bool>true</bool> + </property> + <property name="allowedAreas"> + <set>Qt::LeftToolBarArea|Qt::RightToolBarArea</set> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextOnly</enum> + </property> + <property name="floatable"> + <bool>false</bool> + </property> + <attribute name="toolBarArea"> + <enum>RightToolBarArea</enum> + </attribute> + <attribute name="toolBarBreak"> + <bool>false</bool> + </attribute> + <addaction name="actionAdd"/> + <addaction name="actionRemove"/> + <addaction name="actionSetDefault"/> + <addaction name="actionNoDefault"/> + <addaction name="actionUploadSkin"/> + </widget> + <action name="actionAdd"> + <property name="text"> + <string>Add</string> + </property> + </action> + <action name="actionRemove"> + <property name="text"> + <string>Remove</string> + </property> + </action> + <action name="actionSetDefault"> + <property name="text"> + <string>Set Default</string> </property> - <property name="topMargin"> - <number>0</number> + </action> + <action name="actionNoDefault"> + <property name="checkable"> + <bool>true</bool> </property> - <property name="rightMargin"> - <number>0</number> + <property name="text"> + <string>No Default</string> </property> - <property name="bottomMargin"> - <number>0</number> + </action> + <action name="actionUploadSkin"> + <property name="text"> + <string>Upload Skin</string> </property> - <item> - <widget class="QTabWidget" name="tabWidget"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="tab"> - <attribute name="title"> - <string notr="true">Tab 1</string> - </attribute> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="welcomeLabel"> - <property name="text"> - <string><html><head/><body><p>Welcome! If you're new here, you can click the &quot;Add&quot; button to add your Mojang or Minecraft account.</p></body></html></string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QTreeView" name="listView"/> - </item> - <item> - <layout class="QVBoxLayout" name="manageAcctsBtnBox"> - <item> - <widget class="QPushButton" name="addAccountBtn"> - <property name="text"> - <string>&Add</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="rmAccountBtn"> - <property name="text"> - <string>&Remove</string> - </property> - </widget> - </item> - <item> - <spacer name="buttonSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="setDefaultBtn"> - <property name="toolTip"> - <string><html><head/><body><p>Set the currently selected account as the active account. The active account is the account that is used to log in (unless it is overridden in an instance-specific setting).</p></body></html></string> - </property> - <property name="text"> - <string>&Set Default</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="noDefaultBtn"> - <property name="toolTip"> - <string>Set no default account. This will cause MultiMC to prompt you to select an account every time you launch an instance that doesn't have its own default set.</string> - </property> - <property name="text"> - <string>&No Default</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="uploadSkinBtn"> - <property name="toolTip"> - <string>Opens a dialog to select and upload a skin image to the selected account.</string> - </property> - <property name="text"> - <string>&Upload Skin</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - </widget> - </item> - </layout> + </action> </widget> + <customwidgets> + <customwidget> + <class>VersionListView</class> + <extends>QTreeView</extends> + <header>widgets/VersionListView.h</header> + </customwidget> + </customwidgets> <resources/> <connections/> </ui> |