mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-21 03:35:40 -04:00
UI: Massive revamp, new features and improvements
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
#include "qtutils.h"
|
||||
#include "common/byte_stream.h"
|
||||
#include "common/make_array.h"
|
||||
#include "core/system.h"
|
||||
#include "frontend-common/game_list.h"
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QMetaObject>
|
||||
#include <QtGui/QDesktopServices>
|
||||
@ -12,6 +14,7 @@
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
#include <QtWidgets/QScrollBar>
|
||||
#include <QtWidgets/QStatusBar>
|
||||
#include <QtWidgets/QStyle>
|
||||
#include <QtWidgets/QTableView>
|
||||
#include <QtWidgets/QTreeView>
|
||||
@ -729,22 +732,6 @@ void FillComboBoxWithMSAAModes(QComboBox* cb)
|
||||
cb->addItem(qApp->translate("GPUSettingsWidget", "%1x SSAA").arg(i), GetMSAAModeValue(i, true));
|
||||
}
|
||||
|
||||
void FillComboBoxWithEmulationSpeeds(QComboBox* cb)
|
||||
{
|
||||
cb->addItem(qApp->translate("GeneralSettingsWidget", "Unlimited"), QVariant(0.0f));
|
||||
|
||||
static constexpr auto speeds = make_array(10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 125, 150, 175, 200, 250, 300, 350,
|
||||
400, 450, 500, 600, 700, 800, 900, 1000);
|
||||
for (const int speed : speeds)
|
||||
{
|
||||
cb->addItem(qApp->translate("GeneralSettingsWidget", "%1% [%2 FPS (NTSC) / %3 FPS (PAL)]")
|
||||
.arg(speed)
|
||||
.arg((60 * speed) / 100)
|
||||
.arg((50 * speed) / 100),
|
||||
QVariant(static_cast<float>(speed) / 100.0f));
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<unsigned> PromptForAddress(QWidget* parent, const QString& title, const QString& label, bool code)
|
||||
{
|
||||
const QString address_str(
|
||||
@ -772,4 +759,107 @@ std::optional<unsigned> PromptForAddress(QWidget* parent, const QString& title,
|
||||
return address;
|
||||
}
|
||||
|
||||
QString StringViewToQString(const std::string_view& str)
|
||||
{
|
||||
return str.empty() ? QString() : QString::fromUtf8(str.data(), str.size());
|
||||
}
|
||||
|
||||
void SetWidgetFontForInheritedSetting(QWidget* widget, bool inherited)
|
||||
{
|
||||
if (widget->font().italic() != inherited)
|
||||
{
|
||||
QFont new_font(widget->font());
|
||||
new_font.setItalic(inherited);
|
||||
widget->setFont(new_font);
|
||||
}
|
||||
}
|
||||
|
||||
void SetWindowResizeable(QWidget* widget, bool resizeable)
|
||||
{
|
||||
if (QMainWindow* window = qobject_cast<QMainWindow*>(widget); window)
|
||||
{
|
||||
// update status bar grip if present
|
||||
if (QStatusBar* sb = window->statusBar(); sb)
|
||||
sb->setSizeGripEnabled(resizeable);
|
||||
}
|
||||
|
||||
if ((widget->sizePolicy().horizontalPolicy() == QSizePolicy::Preferred) != resizeable)
|
||||
{
|
||||
if (resizeable)
|
||||
{
|
||||
// Min/max numbers come from uic.
|
||||
widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
widget->setMinimumSize(1, 1);
|
||||
widget->setMaximumSize(16777215, 16777215);
|
||||
}
|
||||
else
|
||||
{
|
||||
widget->setFixedSize(widget->size());
|
||||
widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ResizePotentiallyFixedSizeWindow(QWidget* widget, int width, int height)
|
||||
{
|
||||
width = std::max(width, 1);
|
||||
height = std::max(height, 1);
|
||||
if (widget->sizePolicy().horizontalPolicy() == QSizePolicy::Fixed)
|
||||
widget->setFixedSize(width, height);
|
||||
|
||||
widget->resize(width, height);
|
||||
}
|
||||
|
||||
QIcon GetIconForRegion(ConsoleRegion region)
|
||||
{
|
||||
switch (region)
|
||||
{
|
||||
case ConsoleRegion::NTSC_J:
|
||||
return QIcon(QStringLiteral(":/icons/flag-jp.svg"));
|
||||
case ConsoleRegion::PAL:
|
||||
return QIcon(QStringLiteral(":/icons/flag-eu.svg"));
|
||||
case ConsoleRegion::NTSC_U:
|
||||
return QIcon(QStringLiteral(":/icons/flag-uc.svg"));
|
||||
default:
|
||||
return QIcon::fromTheme(QStringLiteral("file-unknow-line"));
|
||||
}
|
||||
}
|
||||
|
||||
QIcon GetIconForRegion(DiscRegion region)
|
||||
{
|
||||
switch (region)
|
||||
{
|
||||
case DiscRegion::NTSC_J:
|
||||
return QIcon(QStringLiteral(":/icons/flag-jp.svg"));
|
||||
case DiscRegion::PAL:
|
||||
return QIcon(QStringLiteral(":/icons/flag-eu.svg"));
|
||||
case DiscRegion::NTSC_U:
|
||||
return QIcon(QStringLiteral(":/icons/flag-uc.svg"));
|
||||
case DiscRegion::Other:
|
||||
default:
|
||||
return QIcon::fromTheme(QStringLiteral("file-unknow-line"));
|
||||
}
|
||||
}
|
||||
|
||||
QIcon GetIconForEntryType(GameList::EntryType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GameList::EntryType::Disc:
|
||||
return QIcon::fromTheme(QStringLiteral("dvd-line"));
|
||||
case GameList::EntryType::Playlist:
|
||||
return QIcon::fromTheme(QStringLiteral("play-list-2-line"));
|
||||
case GameList::EntryType::PSF:
|
||||
return QIcon::fromTheme(QStringLiteral("file-music-line"));
|
||||
case GameList::EntryType::PSExe:
|
||||
default:
|
||||
return QIcon::fromTheme(QStringLiteral("settings-5-line"));
|
||||
}
|
||||
}
|
||||
|
||||
QIcon GetIconForCompatibility(GameDatabase::CompatibilityRating rating)
|
||||
{
|
||||
return QIcon(QStringLiteral(":/icons/star-%1.png").arg(static_cast<u32>(rating)));
|
||||
}
|
||||
|
||||
} // namespace QtUtils
|
||||
|
Reference in New Issue
Block a user