Merge pull request #6060 from leoetlino/misc-qt-fixes

Misc Qt fixes
This commit is contained in:
Leo Lam 2017-09-27 20:11:17 +02:00 committed by GitHub
commit c004848fd4
10 changed files with 41 additions and 32 deletions

View File

@ -14,22 +14,20 @@ AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent)
{ {
setWindowTitle(tr("About Dolphin")); setWindowTitle(tr("About Dolphin"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setAttribute(Qt::WA_DeleteOnClose);
QString text = QStringLiteral(""); QString text = QStringLiteral("");
QString small = QStringLiteral("<p style='margin-top:0px; margin-bottom:0px; font-size:9pt;'>"); QString small = QStringLiteral("<p style='margin-top:0; margin-bottom:0; font-size:small;'>");
QString medium = QStringLiteral("<p style='margin-top:15px; font-size:11pt;'>"); QString medium = QStringLiteral("<p style='margin-top:15px;'>");
text.append(QStringLiteral("<p style='font-size:50pt; font-weight:400; margin-bottom:0px;'>") + text.append(QStringLiteral("<p style='font-size:38pt; font-weight:400; margin-bottom:0;'>") +
tr("Dolphin") + QStringLiteral("</p>")); tr("Dolphin") + QStringLiteral("</p>"));
text.append(QStringLiteral("<p style='font-size:18pt; margin-top:0px;'>%1</p>") text.append(QStringLiteral("<p style='font-size:18pt; margin-top:0;'>%1</p>")
.arg(QString::fromUtf8(Common::scm_desc_str.c_str()))); .arg(QString::fromUtf8(Common::scm_desc_str.c_str())));
text.append(small + tr("Branch: ") + QString::fromUtf8(Common::scm_branch_str.c_str()) + text.append(small + tr("Branch: ") + QString::fromUtf8(Common::scm_branch_str.c_str()) +
QStringLiteral("</p>")); QStringLiteral("</p>"));
text.append(small + tr("Revision: ") + QString::fromUtf8(Common::scm_rev_git_str.c_str()) + text.append(small + tr("Revision: ") + QString::fromUtf8(Common::scm_rev_git_str.c_str()) +
QStringLiteral("</p>")); QStringLiteral("</p>"));
text.append(small + tr("Compiled: ") + QStringLiteral(__DATE__ " " __TIME__ "</p>"));
text.append(medium + tr("Check for updates: ") + text.append(medium + tr("Check for updates: ") +
QStringLiteral( QStringLiteral(
@ -62,9 +60,10 @@ AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent)
// in your translation, please use the type of curly quotes that's appropriate for // in your translation, please use the type of curly quotes that's appropriate for
// your language. If you aren't sure which type is appropriate, see // your language. If you aren't sure which type is appropriate, see
// https://en.wikipedia.org/wiki/Quotation_mark#Specific_language_features // https://en.wikipedia.org/wiki/Quotation_mark#Specific_language_features
new QLabel(tr("\u00A9 2003-%1 Dolphin Team. \u201cGameCube\u201d and \u201cWii\u201d are " new QLabel(small +
"trademarks of Nintendo. Dolphin is not affiliated with Nintendo in any way.") tr("\u00A9 2003-2015+ Dolphin Team. \u201cGameCube\u201d and \u201cWii\u201d are "
.arg(QStringLiteral(__DATE__).right(4))); "trademarks of Nintendo. Dolphin is not affiliated with Nintendo in any way.") +
QStringLiteral("</p>"));
QLabel* logo = new QLabel(); QLabel* logo = new QLabel();
logo->setPixmap(Resources::GetMisc(Resources::LOGO_LARGE)); logo->setPixmap(Resources::GetMisc(Resources::LOGO_LARGE));

View File

@ -100,6 +100,7 @@ void AdvancedWidget::CreateWidgets()
main_layout->addWidget(debugging_box); main_layout->addWidget(debugging_box);
main_layout->addWidget(utility_box); main_layout->addWidget(utility_box);
main_layout->addWidget(misc_box); main_layout->addWidget(misc_box);
main_layout->addStretch();
setLayout(main_layout); setLayout(main_layout);
} }

View File

@ -113,6 +113,7 @@ void EnhancementsWidget::CreateWidgets()
main_layout->addWidget(enhancements_box); main_layout->addWidget(enhancements_box);
main_layout->addWidget(stereoscopy_box); main_layout->addWidget(stereoscopy_box);
main_layout->addStretch();
setLayout(main_layout); setLayout(main_layout);
} }

View File

@ -116,6 +116,7 @@ void GeneralWidget::CreateWidgets()
main_layout->addWidget(m_video_box); main_layout->addWidget(m_video_box);
main_layout->addWidget(m_options_box); main_layout->addWidget(m_options_box);
main_layout->addStretch();
setLayout(main_layout); setLayout(main_layout);
} }

View File

@ -94,6 +94,7 @@ void HacksWidget::CreateWidgets()
main_layout->addWidget(texture_cache_box); main_layout->addWidget(texture_cache_box);
main_layout->addWidget(xfb_box); main_layout->addWidget(xfb_box);
main_layout->addWidget(other_box); main_layout->addWidget(other_box);
main_layout->addStretch();
setLayout(main_layout); setLayout(main_layout);
} }

View File

@ -99,6 +99,7 @@ void SoftwareRendererWidget::CreateWidgets()
main_layout->addWidget(overlay_box); main_layout->addWidget(overlay_box);
main_layout->addWidget(utility_box); main_layout->addWidget(utility_box);
main_layout->addWidget(object_range_box); main_layout->addWidget(object_range_box);
main_layout->addStretch();
setLayout(main_layout); setLayout(main_layout);
} }

View File

@ -74,6 +74,8 @@ void GameList::MakeListView()
m_list->setCurrentIndex(QModelIndex()); m_list->setCurrentIndex(QModelIndex());
m_list->setContextMenuPolicy(Qt::CustomContextMenu); m_list->setContextMenuPolicy(Qt::CustomContextMenu);
m_list->setWordWrap(false); m_list->setWordWrap(false);
m_list->verticalHeader()->setDefaultSectionSize(m_list->verticalHeader()->defaultSectionSize() *
1.25);
connect(m_list, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu); connect(m_list, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu);
connect(m_list->selectionModel(), &QItemSelectionModel::selectionChanged, connect(m_list->selectionModel(), &QItemSelectionModel::selectionChanged,
@ -484,7 +486,8 @@ void GameList::OnColumnVisibilityToggled(const QString& row, bool visible)
{tr("Platform"), GameListModel::COL_PLATFORM}, {tr("Platform"), GameListModel::COL_PLATFORM},
{tr("Size"), GameListModel::COL_SIZE}, {tr("Size"), GameListModel::COL_SIZE},
{tr("Title"), GameListModel::COL_TITLE}, {tr("Title"), GameListModel::COL_TITLE},
{tr("State"), GameListModel::COL_RATING}}; {tr("State"), GameListModel::COL_RATING},
{tr("File Name"), GameListModel::COL_FILE_NAME}};
m_list->setColumnHidden(rowname_to_col_index[row], !visible); m_list->setColumnHidden(rowname_to_col_index[row], !visible);
} }

View File

@ -101,6 +101,7 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
case COL_FILE_NAME: case COL_FILE_NAME:
if (role == Qt::DisplayRole || role == Qt::InitialSortOrderRole) if (role == Qt::DisplayRole || role == Qt::InitialSortOrderRole)
return game->GetFileName(); return game->GetFileName();
break;
case COL_SIZE: case COL_SIZE:
if (role == Qt::DisplayRole) if (role == Qt::DisplayRole)
return FormatSize(game->GetFileSize()); return FormatSize(game->GetFileSize());

View File

@ -353,7 +353,7 @@ void MainWindow::Pause()
void MainWindow::OnStopComplete() void MainWindow::OnStopComplete()
{ {
m_stop_requested = false; m_stop_requested = false;
m_render_widget->hide(); HideRenderWidget();
if (m_exit_requested) if (m_exit_requested)
QGuiApplication::instance()->quit(); QGuiApplication::instance()->quit();
@ -425,7 +425,6 @@ bool MainWindow::RequestStop()
void MainWindow::ForceStop() void MainWindow::ForceStop()
{ {
BootManager::Stop(); BootManager::Stop();
HideRenderWidget();
} }
void MainWindow::Reset() void MainWindow::Reset()
@ -553,8 +552,8 @@ void MainWindow::ShowAudioWindow()
void MainWindow::ShowAboutDialog() void MainWindow::ShowAboutDialog()
{ {
AboutDialog* about = new AboutDialog(this); AboutDialog about{this};
about->show(); about.exec();
} }
void MainWindow::ShowHotkeyDialog() void MainWindow::ShowHotkeyDialog()

View File

@ -2,6 +2,9 @@
// Licensed under GPLv2+ // Licensed under GPLv2+
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <algorithm>
#include <vector>
#include <QIcon> #include <QIcon>
#include "Core/Core.h" #include "Core/Core.h"
@ -32,7 +35,6 @@ void ToolBar::OnEmulationStateChanged(Core::State state)
{ {
bool running = state != Core::State::Uninitialized; bool running = state != Core::State::Uninitialized;
m_stop_action->setEnabled(running); m_stop_action->setEnabled(running);
m_stop_action->setVisible(running);
m_fullscreen_action->setEnabled(running); m_fullscreen_action->setEnabled(running);
m_screenshot_action->setEnabled(running); m_screenshot_action->setEnabled(running);
@ -45,36 +47,36 @@ void ToolBar::OnEmulationStateChanged(Core::State state)
void ToolBar::MakeActions() void ToolBar::MakeActions()
{ {
constexpr int button_width = 65;
m_open_action = AddAction(this, tr("Open"), this, &ToolBar::OpenPressed); m_open_action = AddAction(this, tr("Open"), this, &ToolBar::OpenPressed);
widgetForAction(m_open_action)->setMinimumWidth(button_width);
m_play_action = AddAction(this, tr("Play"), this, &ToolBar::PlayPressed); m_play_action = AddAction(this, tr("Play"), this, &ToolBar::PlayPressed);
widgetForAction(m_play_action)->setMinimumWidth(button_width);
m_pause_action = AddAction(this, tr("Pause"), this, &ToolBar::PausePressed); m_pause_action = AddAction(this, tr("Pause"), this, &ToolBar::PausePressed);
widgetForAction(m_pause_action)->setMinimumWidth(button_width);
m_stop_action = AddAction(this, tr("Stop"), this, &ToolBar::StopPressed); m_stop_action = AddAction(this, tr("Stop"), this, &ToolBar::StopPressed);
widgetForAction(m_stop_action)->setMinimumWidth(button_width);
m_fullscreen_action = AddAction(this, tr("FullScr"), this, &ToolBar::FullScreenPressed); m_fullscreen_action = AddAction(this, tr("FullScr"), this, &ToolBar::FullScreenPressed);
widgetForAction(m_fullscreen_action)->setMinimumWidth(button_width);
m_screenshot_action = AddAction(this, tr("ScrShot"), this, &ToolBar::ScreenShotPressed); m_screenshot_action = AddAction(this, tr("ScrShot"), this, &ToolBar::ScreenShotPressed);
widgetForAction(m_screenshot_action)->setMinimumWidth(button_width);
addSeparator(); addSeparator();
m_config_action = AddAction(this, tr("Config"), this, &ToolBar::SettingsPressed); m_config_action = AddAction(this, tr("Config"), this, &ToolBar::SettingsPressed);
widgetForAction(m_config_action)->setMinimumWidth(button_width);
m_graphics_action = AddAction(this, tr("Graphics"), this, &ToolBar::GraphicsPressed); m_graphics_action = AddAction(this, tr("Graphics"), this, &ToolBar::GraphicsPressed);
widgetForAction(m_graphics_action)->setMinimumWidth(button_width);
m_controllers_action = AddAction(this, tr("Controllers"), this, &ToolBar::ControllersPressed); m_controllers_action = AddAction(this, tr("Controllers"), this, &ToolBar::ControllersPressed);
widgetForAction(m_controllers_action)->setMinimumWidth(button_width);
m_controllers_action->setEnabled(true); m_controllers_action->setEnabled(true);
// Ensure every button has about the same width
std::vector<QWidget*> items;
for (const auto& action : {m_open_action, m_play_action, m_pause_action, m_stop_action,
m_stop_action, m_fullscreen_action, m_screenshot_action,
m_config_action, m_graphics_action, m_controllers_action})
{
items.emplace_back(widgetForAction(action));
}
std::vector<int> widths;
std::transform(items.begin(), items.end(), std::back_inserter(widths),
[](QWidget* item) { return item->sizeHint().width(); });
const int min_width = *std::max_element(widths.begin(), widths.end()) * 0.85;
for (QWidget* widget : items)
widget->setMinimumWidth(min_width);
} }
void ToolBar::UpdateIcons() void ToolBar::UpdateIcons()