Cleanups, comments, style nits

This commit is contained in:
twinaphex 2020-06-04 14:41:28 +02:00
parent 9fda2bdebd
commit 88f7515d1d
15 changed files with 216 additions and 179 deletions

View File

@ -59,25 +59,23 @@
#define SM_SERVERR2 89
#endif
/* static public global variable */
VOID (WINAPI *DragAcceptFiles_func)(HWND, BOOL);
/* static global variables */
static bool dwm_composition_disabled = false;
static bool console_needs_free = false;
static char win32_cpu_model_name[64] = {0};
static bool pi_set = false;
#ifdef HAVE_DYNAMIC
/* We only load this library once, so we let it be
* unloaded at application shutdown, since unloading
* it early seems to cause issues on some systems.
*/
#ifdef HAVE_DYNAMIC
static dylib_t dwmlib;
static dylib_t shell32lib;
#endif
static char win32_cpu_model_name[64] = {0};
VOID (WINAPI *DragAcceptFiles_func)(HWND, BOOL);
static bool dwm_composition_disabled = false;
static bool console_needs_free = false;
static bool pi_set = false;
#if defined(HAVE_LANGEXTRA) && !defined(_XBOX)
#if (defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500) || !defined(_MSC_VER)
struct win32_lang_pair

View File

@ -39,22 +39,24 @@ CoreInfoDialog::CoreInfoDialog(MainWindow *mainwindow, QWidget *parent) :
void CoreInfoDialog::showCoreInfo()
{
int row = 0;
int rowCount = m_formLayout->rowCount();
int i = 0;
QVector<QHash<QString, QString> > infoList = m_mainwindow->getCoreInfo();
int row = 0;
int row_count = m_formLayout->rowCount();
int i = 0;
QVector<QHash<QString, QString> > info_list
= m_mainwindow->getCoreInfo();
if (rowCount > 0)
if (row_count > 0)
{
for (row = 0; row < rowCount; row++)
for (row = 0; row < row_count; row++)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
/* removeRow() and takeRow() was only added in 5.8! */
m_formLayout->removeRow(0);
#else
/* something is buggy here... sometimes items appear duplicated, and other times not */
/* something is buggy here...
* sometimes items appear duplicated, and other times not */
QLayoutItem *item = m_formLayout->itemAt(0);
QWidget *w = NULL;
QWidget *w = NULL;
if (item)
{
@ -76,12 +78,12 @@ void CoreInfoDialog::showCoreInfo()
}
}
if (infoList.count() == 0)
if (info_list.count() == 0)
return;
for (i = 0; i < infoList.count(); i++)
for (i = 0; i < info_list.count(); i++)
{
const QHash<QString, QString> &line = infoList.at(i);
const QHash<QString, QString> &line = info_list.at(i);
QLabel *label = new QLabel(line.value("key"));
CoreInfoLabel *value = new CoreInfoLabel(line.value("value"));
QString labelStyle = line.value("label_style");

View File

@ -128,16 +128,16 @@ void CoreOptionsDialog::onSaveGameSpecificOptions()
void CoreOptionsDialog::onCoreOptionComboBoxCurrentIndexChanged(int index)
{
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
QString key, val;
size_t opts = 0;
unsigned i, k;
QString key, val;
size_t opts = 0;
QComboBox *combo_box = qobject_cast<QComboBox*>(sender());
if (!comboBox)
if (!combo_box)
return;
key = comboBox->itemData(index, Qt::UserRole).toString();
val = comboBox->itemText(index);
key = combo_box->itemData(index, Qt::UserRole).toString();
val = combo_box->itemText(index);
if (rarch_ctl(RARCH_CTL_HAS_CORE_OPTIONS, NULL))
{
@ -179,14 +179,15 @@ void CoreOptionsDialog::onCoreOptionComboBoxCurrentIndexChanged(int index)
void CoreOptionsDialog::buildLayout()
{
QFormLayout *form = NULL;
settings_t *settings = config_get_ptr();
size_t opts = 0;
unsigned j, k;
size_t opts = 0;
QFormLayout *form = NULL;
settings_t *settings = config_get_ptr();
bool has_core_options = rarch_ctl(RARCH_CTL_HAS_CORE_OPTIONS, NULL);
clearLayout();
if (rarch_ctl(RARCH_CTL_HAS_CORE_OPTIONS, NULL))
if (has_core_options)
{
rarch_ctl(RARCH_CTL_GET_CORE_OPTION_SIZE, &opts);
@ -240,12 +241,14 @@ void CoreOptionsDialog::buildLayout()
for (j = 0; j < opts; j++)
{
QString desc = core_option_manager_get_desc(coreopts, j);
QString val = core_option_manager_get_val(coreopts, j);
QComboBox *comboBox = NULL;
QLabel *descLabel = NULL;
QHBoxLayout *comboLayout = NULL;
QToolButton *resetButton = NULL;
QString desc =
core_option_manager_get_desc(coreopts, j);
QString val =
core_option_manager_get_val(coreopts, j);
QComboBox *combo_box = NULL;
QLabel *descLabel = NULL;
QHBoxLayout *comboLayout = NULL;
QToolButton *resetButton = NULL;
struct core_option *option = NULL;
if (desc.isEmpty() || !coreopts->opts)
@ -257,35 +260,40 @@ void CoreOptionsDialog::buildLayout()
continue;
comboLayout = new QHBoxLayout();
descLabel = new QLabel(desc, this);
comboBox = new QComboBox(this);
comboBox->setObjectName("coreOptionComboBox");
descLabel = new QLabel(desc, this);
combo_box = new QComboBox(this);
combo_box->setObjectName("coreOptionComboBox");
resetButton = new QToolButton(this);
resetButton->setObjectName("resetButton");
resetButton->setDefaultAction(new QAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_RESET), this));
resetButton->setProperty("comboBox", QVariant::fromValue(comboBox));
resetButton->setProperty("comboBox",
QVariant::fromValue(combo_box));
connect(resetButton, SIGNAL(clicked()), this, SLOT(onCoreOptionResetClicked()));
connect(resetButton, SIGNAL(clicked()),
this, SLOT(onCoreOptionResetClicked()));
if (!string_is_empty(option->info))
{
char *new_info = strdup(option->info);
word_wrap(new_info, new_info, 50, true, 0);
descLabel->setToolTip(new_info);
comboBox->setToolTip(new_info);
combo_box->setToolTip(new_info);
free(new_info);
}
for (k = 0; k < option->vals->size; k++)
comboBox->addItem(option->vals->elems[k].data, option->key);
combo_box->addItem(option->vals->elems[k].data, option->key);
comboBox->setCurrentText(val);
comboBox->setProperty("default_index", static_cast<unsigned>(option->default_index));
combo_box->setCurrentText(val);
combo_box->setProperty("default_index",
static_cast<unsigned>(option->default_index));
/* Only connect the signal after setting the default item */
connect(comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onCoreOptionComboBoxCurrentIndexChanged(int)));
connect(combo_box, SIGNAL(currentIndexChanged(int)),
this,
SLOT(onCoreOptionComboBoxCurrentIndexChanged(int)));
comboLayout->addWidget(comboBox);
comboLayout->addWidget(combo_box);
comboLayout->addWidget(resetButton);
form->addRow(descLabel, comboLayout);
@ -300,13 +308,15 @@ void CoreOptionsDialog::buildLayout()
if (!opts)
{
QLabel *noParamsLabel = new QLabel(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_CORE_OPTIONS_AVAILABLE), this);
QLabel *noParamsLabel = new QLabel(msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_NO_CORE_OPTIONS_AVAILABLE), this);
noParamsLabel->setAlignment(Qt::AlignCenter);
m_layout->addWidget(noParamsLabel);
}
m_layout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
m_layout->addItem(new QSpacerItem(20, 20,
QSizePolicy::Minimum, QSizePolicy::Expanding));
resize(width() + 1, height());
show();
@ -315,48 +325,48 @@ void CoreOptionsDialog::buildLayout()
void CoreOptionsDialog::onCoreOptionResetClicked()
{
QToolButton *button = qobject_cast<QToolButton*>(sender());
QComboBox *comboBox = NULL;
int default_index = 0;
bool ok = false;
bool ok = false;
QToolButton *button = qobject_cast<QToolButton*>(sender());
QComboBox *combo_box = NULL;
int default_index = 0;
if (!button)
return;
comboBox = qobject_cast<QComboBox*>(button->property("comboBox").value<QComboBox*>());
combo_box = qobject_cast<QComboBox*>(button->property("comboBox").value<QComboBox*>());
if (!comboBox)
if (!combo_box)
return;
default_index = comboBox->property("default_index").toInt(&ok);
default_index = combo_box->property("default_index").toInt(&ok);
if (!ok)
return;
if (default_index >= 0 && default_index < comboBox->count())
comboBox->setCurrentIndex(default_index);
if (default_index >= 0 && default_index < combo_box->count())
combo_box->setCurrentIndex(default_index);
}
void CoreOptionsDialog::onCoreOptionResetAllClicked()
{
QList<QComboBox*> comboBoxes = findChildren<QComboBox*>("coreOptionComboBox");
int i;
QList<QComboBox*> combo_boxes = findChildren<QComboBox*>("coreOptionComboBox");
for (i = 0; i < comboBoxes.count(); i++)
for (i = 0; i < combo_boxes.count(); i++)
{
QComboBox *comboBox = comboBoxes.at(i);
int default_index = 0;
bool ok = false;
int default_index = 0;
bool ok = false;
QComboBox *combo_box = combo_boxes.at(i);
if (!comboBox)
if (!combo_box)
continue;
default_index = comboBox->property("default_index").toInt(&ok);
default_index = combo_box->property("default_index").toInt(&ok);
if (!ok)
continue;
if (default_index >= 0 && default_index < comboBox->count())
comboBox->setCurrentIndex(default_index);
if (default_index >= 0 && default_index < combo_box->count())
combo_box->setCurrentIndex(default_index);
}
}

View File

@ -13,14 +13,14 @@ ThumbnailDelegate::ThumbnailDelegate(const GridItem &gridItem, QObject* parent)
void ThumbnailDelegate::paint(QPainter* painter, const QStyleOptionViewItem &option, const QModelIndex& index) const
{
QStyleOptionViewItem opt = option;
const QWidget *widget = opt.widget;
QStyle *style = widget->style();
int padding = m_style.padding;
int textTopMargin = 4; /* Qt seemingly reports -4 the actual line height. */
int textHeight = painter->fontMetrics().height() + padding + padding;
QRect rect = opt.rect;
QRect adjusted = rect.adjusted(padding, padding, -padding, -textHeight + textTopMargin);
QPixmap pixmap = index.data(PlaylistModel::THUMBNAIL).value<QPixmap>();
const QWidget *widget = opt.widget;
QStyle *style = widget->style();
int padding = m_style.padding;
int text_top_margin = 4; /* Qt seemingly reports -4 the actual line height. */
int text_height = painter->fontMetrics().height() + padding + padding;
QRect rect = opt.rect;
QRect adjusted = rect.adjusted(padding, padding, -padding, -text_height + text_top_margin);
QPixmap pixmap = index.data(PlaylistModel::THUMBNAIL).value<QPixmap>();
painter->save();
@ -40,7 +40,7 @@ void ThumbnailDelegate::paint(QPainter* painter, const QStyleOptionViewItem &opt
if (!opt.text.isEmpty())
{
QPalette::ColorGroup cg = opt.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
QRect textRect = QRect(rect.x() + padding, rect.y() + adjusted.height() - textTopMargin + padding, rect.width() - 2 * padding, textHeight);
QRect textRect = QRect(rect.x() + padding, rect.y() + adjusted.height() - text_top_margin + padding, rect.width() - 2 * padding, text_height);
QString elidedText = painter->fontMetrics().elidedText(opt.text, opt.textElideMode, textRect.width(), Qt::TextShowMnemonic);
if (cg == QPalette::Normal && !(opt.state & QStyle::State_Active))
@ -84,14 +84,13 @@ void GridView::setviewMode(ViewMode mode)
void GridView::calculateRectsIfNecessary() const
{
int row;
int nextX;
if (!m_hashIsDirty)
return;
int x = m_spacing;
int y = m_spacing;
int row;
int nextX;
int x = m_spacing;
int y = m_spacing;
const int maxWidth = viewport()->width();
if (m_size + m_spacing * 2 > maxWidth)
@ -113,7 +112,8 @@ void GridView::calculateRectsIfNecessary() const
int columns = (maxWidth - m_spacing) / (m_size + m_spacing);
if (columns > 0)
{
const int actualSpacing = (maxWidth - m_spacing - m_size - (columns - 1) * m_size) / columns;
const int actualSpacing = (maxWidth - m_spacing -
m_size - (columns - 1) * m_size) / columns;
for (row = 0; row < model()->rowCount(); ++row)
{
nextX = x + m_size + actualSpacing;
@ -134,8 +134,10 @@ void GridView::calculateRectsIfNecessary() const
int columns = (maxWidth - m_spacing) / (m_size + m_spacing);
if (columns > 0)
{
const int actualSpacing = (maxWidth - columns * m_size) / (columns + 1);
x = actualSpacing;
const int actualSpacing = (maxWidth - columns * m_size)
/ (columns + 1);
x = actualSpacing;
for (row = 0; row < model()->rowCount(); ++row)
{
nextX = x + m_size + actualSpacing;

View File

@ -169,7 +169,7 @@ void ShaderParamsDialog::clearLayout()
m_layout = new QVBoxLayout();
widget = new QWidget();
widget = new QWidget();
widget->setLayout(m_layout);
widget->setObjectName("shaderParamsWidget");

View File

@ -38,14 +38,9 @@ extern "C" {
#include "../ui_qt.h"
static AppHandler *appHandler;
static AppHandler *app_handler;
static ui_application_qt_t ui_application;
/* these must last for the lifetime of the QApplication */
static int app_argc = 1;
static char app_name[] = "retroarch";
static char *app_argv[] = { app_name, NULL };
/* ARGB 16x16 */
static const unsigned retroarch_qt_icon_data[] = {
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
@ -94,7 +89,12 @@ void AppHandler::onLastWindowClosed()
static void* ui_application_qt_initialize(void)
{
appHandler = new AppHandler();
/* These must last for the lifetime of the QApplication */
static int app_argc = 1;
static char app_name[] = "retroarch";
static char *app_argv[] = { app_name, NULL };
app_handler = new AppHandler();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
/* HiDpi supported since Qt 5.6 */
@ -107,7 +107,8 @@ static void* ui_application_qt_initialize(void)
ui_application.app->setOrganizationName("libretro");
ui_application.app->setApplicationName("RetroArch");
ui_application.app->setApplicationVersion(PACKAGE_VERSION);
ui_application.app->connect(ui_application.app, SIGNAL(lastWindowClosed()), appHandler, SLOT(onLastWindowClosed()));
ui_application.app->connect(ui_application.app, SIGNAL(lastWindowClosed()),
app_handler, SLOT(onLastWindowClosed()));
#ifdef Q_OS_UNIX
setlocale(LC_NUMERIC, "C");
@ -137,8 +138,8 @@ static void ui_application_qt_process_events(void)
static void ui_application_qt_quit(void)
{
if (appHandler)
appHandler->exit();
if (app_handler)
app_handler->exit();
}
#ifdef HAVE_MAIN

View File

@ -105,16 +105,16 @@ extern "C" {
static ui_window_qt_t ui_window = {0};
enum CoreSelection
enum core_selection
{
CORE_SELECTION_CURRENT,
CORE_SELECTION_CURRENT = 0,
CORE_SELECTION_PLAYLIST_SAVED,
CORE_SELECTION_PLAYLIST_DEFAULT,
CORE_SELECTION_ASK,
CORE_SELECTION_LOAD_CORE
};
static const QPixmap getInvader()
static const QPixmap getInvader(void)
{
QPixmap pix;
pix.loadFromData(invader_png, invader_png_len, "PNG");
@ -1179,7 +1179,7 @@ void MainWindow::onLaunchWithComboBoxIndexChanged(int)
QVector<QHash<QString, QString> > infoList = getCoreInfo();
QString coreInfoText;
QVariantMap coreMap = m_launchWithComboBox->currentData(Qt::UserRole).value<QVariantMap>();
CoreSelection coreSelection = static_cast<CoreSelection>(coreMap.value("core_selection").toInt());
core_selection coreSelection = static_cast<core_selection>(coreMap.value("core_selection").toInt());
int i = 0;
if (infoList.count() == 0)
@ -1795,7 +1795,7 @@ void MainWindow::onStartCoreClicked()
QHash<QString, QString> MainWindow::getSelectedCore()
{
QVariantMap coreMap = m_launchWithComboBox->currentData(Qt::UserRole).value<QVariantMap>();
CoreSelection coreSelection = static_cast<CoreSelection>(coreMap.value("core_selection").toInt());
core_selection coreSelection = static_cast<core_selection>(coreMap.value("core_selection").toInt());
QHash<QString, QString> coreHash;
QHash<QString, QString> contentHash;
ViewType viewType = getCurrentViewType();
@ -1864,7 +1864,7 @@ void MainWindow::loadContent(const QHash<QString, QString> &contentHash)
const char *contentDbName = NULL;
const char *contentCrc32 = NULL;
QVariantMap coreMap = m_launchWithComboBox->currentData(Qt::UserRole).value<QVariantMap>();
CoreSelection coreSelection = static_cast<CoreSelection>(coreMap.value("core_selection").toInt());
core_selection coreSelection = static_cast<core_selection>(coreMap.value("core_selection").toInt());
contentDbNameFull[0] = '\0';

View File

@ -25,7 +25,7 @@ extern "C" {
#define TEMP_EXTENSION ".update_tmp"
#define RETROARCH_NIGHTLY_UPDATE_PATH "../RetroArch_update.zip"
static void extractUpdateCB(retro_task_t *task,
static void extract_update_cb(retro_task_t *task,
void *task_data, void *user_data, const char *err)
{
decompress_task_data_t *dec = (decompress_task_data_t*)task_data;
@ -85,14 +85,16 @@ void MainWindow::onUpdateNetworkError(QNetworkReply::NetworkError code)
errorStringArray = reply->errorString().toUtf8();
errorStringData = errorStringArray.constData();
RARCH_ERR("[Qt]: Network error code %d received: %s\n", code, errorStringData);
RARCH_ERR("[Qt]: Network error code %d received: %s\n",
code, errorStringData);
/* Deleting the reply here seems to cause a strange heap-use-after-free crash. */
/*
/* Deleting the reply here seems to cause a
* strange heap-use-after-free crash. */
#if 0
reply->disconnect();
reply->abort();
reply->deleteLater();
*/
#endif
}
void MainWindow::onUpdateNetworkSslErrors(const QList<QSslError> &errors)
@ -106,7 +108,10 @@ void MainWindow::onUpdateNetworkSslErrors(const QList<QSslError> &errors)
for (i = 0; i < errors.count(); i++)
{
const QSslError &error = errors.at(i);
QString string = QString("Ignoring SSL error code ") + QString::number(error.error()) + ": " + error.errorString();
QString string = QString("Ignoring SSL error code ")
+ QString::number(error.error())
+ ": "
+ error.errorString();
QByteArray stringArray = string.toUtf8();
const char *stringData = stringArray.constData();
@ -150,7 +155,8 @@ void MainWindow::onRetroArchUpdateDownloadFinished()
emit showErrorMessageDeferred(QString(
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NETWORK_ERROR))
+ ": HTTP Code " + QString::number(code));
RARCH_ERR("[Qt]: RetroArch update failed with HTTP status code: %d\n", code);
RARCH_ERR("[Qt]: RetroArch update failed with HTTP status code: %d\n",
code);
reply->disconnect();
reply->abort();
reply->deleteLater();
@ -159,7 +165,7 @@ void MainWindow::onRetroArchUpdateDownloadFinished()
if (error == QNetworkReply::NoError)
{
int index = m_updateFile.fileName().lastIndexOf(PARTIAL_EXTENSION);
int index = m_updateFile.fileName().lastIndexOf(PARTIAL_EXTENSION);
QString newFileName = m_updateFile.fileName().left(index);
QFile newFile(newFileName);
@ -171,12 +177,15 @@ void MainWindow::onRetroArchUpdateDownloadFinished()
if (m_updateFile.rename(newFileName))
{
RARCH_LOG("[Qt]: RetroArch update finished downloading successfully.\n");
emit extractArchiveDeferred(newFileName, ".", TEMP_EXTENSION, extractUpdateCB);
emit extractArchiveDeferred(newFileName, ".", TEMP_EXTENSION,
extract_update_cb);
}
else
{
RARCH_ERR("[Qt]: RetroArch update finished, but temp file could not be renamed.\n");
emit showErrorMessageDeferred(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_COULD_NOT_RENAME_FILE));
emit showErrorMessageDeferred(
msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_QT_COULD_NOT_RENAME_FILE));
}
}
}
@ -212,10 +221,11 @@ void MainWindow::onUpdateRetroArchFinished(bool success)
emit showInfoMessageDeferred(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_UPDATE_RETROARCH_FINISHED));
}
void MainWindow::onUpdateDownloadProgress(qint64 bytesReceived, qint64 bytesTotal)
void MainWindow::onUpdateDownloadProgress(
qint64 bytesReceived, qint64 bytesTotal)
{
QNetworkReply *reply = m_updateReply.data();
int progress = (bytesReceived / (float)bytesTotal) * 100.0f;
int progress = (bytesReceived / (float)bytesTotal) * 100.0f;
if (!reply)
return;
@ -238,8 +248,8 @@ void MainWindow::updateRetroArchNightly()
QUrl url(QUrl(DEFAULT_BUILDBOT_SERVER_URL).resolved(QUrl(RETROARCH_NIGHTLY_UPDATE_PATH)));
QNetworkRequest request(url);
QNetworkReply *reply = NULL;
QByteArray urlArray = url.toString().toUtf8();
const char *urlData = urlArray.constData();
QByteArray urlArray = url.toString().toUtf8();
const char *urlData = urlArray.constData();
if (m_updateFile.isOpen())
{
@ -248,7 +258,8 @@ void MainWindow::updateRetroArchNightly()
}
else
{
QString fileName = QFileInfo(url.toString()).fileName() + PARTIAL_EXTENSION;
QString fileName = QFileInfo(url.toString()).fileName()
+ PARTIAL_EXTENSION;
QByteArray fileNameArray = fileName.toUtf8();
const char *fileNameData = fileNameArray.constData();
@ -273,7 +284,8 @@ void MainWindow::updateRetroArchNightly()
m_updateProgressDialog->setAutoClose(true);
m_updateProgressDialog->setAutoReset(true);
m_updateProgressDialog->setValue(0);
m_updateProgressDialog->setLabelText(QString(msg_hash_to_str(MSG_DOWNLOADING)) + "...");
m_updateProgressDialog->setLabelText(QString(
msg_hash_to_str(MSG_DOWNLOADING)) + "...");
m_updateProgressDialog->setCancelButtonText(tr("Cancel"));
m_updateProgressDialog->show();

View File

@ -34,10 +34,6 @@ extern "C" {
#endif
#ifdef HAVE_MENU
static const int MAX_MIN_WIDTH = 250;
static const int MAX_MIN_HEIGHT = 250;
QPixmap getColorizedPixmap(const QPixmap& oldPixmap, const QColor& color)
{
QPixmap pixmap = oldPixmap;
@ -90,7 +86,9 @@ private:
QSize minimumSizeHint() const final
{
QWidget *inner = widget();
static const int max_min_width = 250;
static const int max_min_height = 250;
QWidget *inner = widget();
if (inner)
{
@ -99,8 +97,8 @@ private:
minSize += QSize(fw, fw);
minSize += QSize(scrollBarWidth(), 0);
minSize.setWidth(qMin(minSize.width(), MAX_MIN_WIDTH));
minSize.setHeight(qMin(minSize.height(), MAX_MIN_HEIGHT));
minSize.setWidth(qMin(minSize.width(), max_min_width));
minSize.setHeight(qMin(minSize.height(), max_min_height));
return minSize;
}
return QSize(0, 0);
@ -236,9 +234,7 @@ void ViewOptionsDialog::repaintIcons()
for (i = 0; i < m_categoryList.size(); i++)
m_optionsList->item(i)->setIcon(getIcon(m_categoryList.at(i)));
}
#else
ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) :
QDialog(mainwindow)
, m_viewOptionsWidget(new ViewOptionsWidget(mainwindow))
@ -261,7 +257,6 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) :
setLayout(layout);
}
#endif
void ViewOptionsDialog::showDialog()
@ -336,8 +331,10 @@ ViewOptionsWidget::ViewOptionsWidget(MainWindow *mainwindow, QWidget *parent) :
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_LAST_TAB), m_saveLastTabCheckBox);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SHOW_HIDDEN_FILES), m_showHiddenFilesCheckBox);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SUGGEST_LOADED_CORE_FIRST), m_suggestLoadedCoreFirstCheckBox);
/* form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_LIST_MAX_COUNT), m_allPlaylistsListMaxCountSpinBox); */
/* form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_GRID_MAX_COUNT), m_allPlaylistsGridMaxCountSpinBox); */
#if 0
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_LIST_MAX_COUNT), m_allPlaylistsListMaxCountSpinBox);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_GRID_MAX_COUNT), m_allPlaylistsGridMaxCountSpinBox);
#endif
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_STARTUP_PLAYLIST), m_startupPlaylistComboBox);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THUMBNAIL_CACHE_LIMIT), m_thumbnailCacheSpinBox);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THUMBNAIL_DROP_SIZE_LIMIT), m_thumbnailDropSizeSpinBox);
@ -392,12 +389,16 @@ void ViewOptionsWidget::onThemeComboBoxIndexChanged(int)
void ViewOptionsWidget::onHighlightColorChoose()
{
QPixmap highlightPixmap(m_highlightColorPushButton->iconSize());
QColor currentHighlightColor = m_settings->value("highlight_color", QApplication::palette().highlight().color()).value<QColor>();
QColor newHighlightColor = QColorDialog::getColor(currentHighlightColor, this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SELECT_COLOR));
QColor currentHighlightColor = m_settings->value("highlight_color",
QApplication::palette().highlight().color()).value<QColor>();
QColor newHighlightColor = QColorDialog::getColor(
currentHighlightColor, this,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SELECT_COLOR));
if (newHighlightColor.isValid())
{
MainWindow::Theme theme = static_cast<MainWindow::Theme>(m_themeComboBox->currentData(Qt::UserRole).toInt());
MainWindow::Theme theme = static_cast<MainWindow::Theme>(
m_themeComboBox->currentData(Qt::UserRole).toInt());
m_highlightColor = newHighlightColor;
m_settings->setValue("highlight_color", m_highlightColor);
@ -422,8 +423,10 @@ void ViewOptionsWidget::loadViewOptions()
m_saveLastTabCheckBox->setChecked(m_settings->value("save_last_tab", false).toBool());
m_showHiddenFilesCheckBox->setChecked(m_settings->value("show_hidden_files", true).toBool());
m_suggestLoadedCoreFirstCheckBox->setChecked(m_settings->value("suggest_loaded_core_first", false).toBool());
/* m_allPlaylistsListMaxCountSpinBox->setValue(m_settings->value("all_playlists_list_max_count", 0).toInt()); */
/* m_allPlaylistsGridMaxCountSpinBox->setValue(m_settings->value("all_playlists_grid_max_count", 5000).toInt()); */
#if 0
m_allPlaylistsListMaxCountSpinBox->setValue(m_settings->value("all_playlists_list_max_count", 0).toInt());
m_allPlaylistsGridMaxCountSpinBox->setValue(m_settings->value("all_playlists_grid_max_count", 5000).toInt());
#endif
m_thumbnailCacheSpinBox->setValue(m_settings->value("thumbnail_cache_limit", 512).toInt());
m_thumbnailDropSizeSpinBox->setValue(m_settings->value("thumbnail_max_size", 0).toInt());
@ -479,8 +482,10 @@ void ViewOptionsWidget::saveViewOptions()
m_settings->setValue("show_hidden_files", m_showHiddenFilesCheckBox->isChecked());
m_settings->setValue("highlight_color", m_highlightColor);
m_settings->setValue("suggest_loaded_core_first", m_suggestLoadedCoreFirstCheckBox->isChecked());
/* m_settings->setValue("all_playlists_list_max_count", m_allPlaylistsListMaxCountSpinBox->value()); */
/* m_settings->setValue("all_playlists_grid_max_count", m_allPlaylistsGridMaxCountSpinBox->value()); */
#if 0
m_settings->setValue("all_playlists_list_max_count", m_allPlaylistsListMaxCountSpinBox->value());
m_settings->setValue("all_playlists_grid_max_count", m_allPlaylistsGridMaxCountSpinBox->value());
#endif
m_settings->setValue("initial_playlist", m_startupPlaylistComboBox->currentData(Qt::UserRole).toString());
m_settings->setValue("thumbnail_cache_limit", m_thumbnailCacheSpinBox->value());
m_settings->setValue("thumbnail_max_size", m_thumbnailDropSizeSpinBox->value());
@ -488,8 +493,10 @@ void ViewOptionsWidget::saveViewOptions()
if (!m_mainwindow->customThemeString().isEmpty())
m_settings->setValue("custom_theme", m_customThemePath);
/* m_mainwindow->setAllPlaylistsListMaxCount(m_allPlaylistsListMaxCountSpinBox->value()); */
/* m_mainwindow->setAllPlaylistsGridMaxCount(m_allPlaylistsGridMaxCountSpinBox->value()); */
#if 0
m_mainwindow->setAllPlaylistsListMaxCount(m_allPlaylistsListMaxCountSpinBox->value());
m_mainwindow->setAllPlaylistsGridMaxCount(m_allPlaylistsGridMaxCountSpinBox->value());
#endif
m_mainwindow->setThumbnailCacheLimit(m_thumbnailCacheSpinBox->value());
}

View File

@ -136,11 +136,13 @@ static void app_terminate(void)
pos = [[CocoaView get] convertPoint:[event locationInWindow] fromView:nil];
#endif
// FIXME: Disable clipping until graphical offset issues are fixed
//NSInteger window_number = [[[NSApplication sharedApplication] keyWindow] windowNumber];
//if ([NSWindow windowNumberAtPoint:pos belowWindowWithWindowNumber:0] != window_number) {
// return;
//}
/* FIXME: Disable clipping until graphical offset issues
* are fixed */
#if 0
NSInteger window_number = [[[NSApplication sharedApplication] keyWindow] windowNumber];
if ([NSWindow windowNumberAtPoint:pos belowWindowWithWindowNumber:0] != window_number)
return;
#endif
/* Relative */
apple->mouse_rel_x += (int16_t)event.deltaX;
@ -199,8 +201,9 @@ static void app_terminate(void)
@end
/* TODO/FIXME - static global variables */
static int waiting_argc;
static char** waiting_argv;
static char **waiting_argv;
@implementation RetroArch_OSX
@ -348,7 +351,7 @@ static char** waiting_argv;
if (mode.width > 0)
{
// HACK(sgc): ensure MTKView posts a drawable resize event
/* HACK(sgc): ensure MTKView posts a drawable resize event */
[self.window setContentSize:NSMakeSize(mode.width-1, mode.height)];
}
[self.window setContentSize:NSMakeSize(mode.width, mode.height)];

View File

@ -39,7 +39,6 @@
#import <AVFoundation/AVFoundation.h>
static char msg_old[PATH_MAX_LENGTH];
#ifdef HAVE_COCOA_METAL
id<ApplePlatform> apple_platform;
#else
@ -47,9 +46,7 @@ static id apple_platform;
#endif
static CFRunLoopObserverRef iterate_observer;
static size_t old_size = 0;
/* forward declaration */
/* Forward declaration */
static void apple_rarch_exited(void);
static void rarch_enable_ui(void)
@ -326,14 +323,15 @@ enum
}
-(NSString*)documentsDirectory {
if ( _documentsDirectory == nil ) {
if (_documentsDirectory == nil)
{
#if TARGET_OS_IOS
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
#elif TARGET_OS_TV
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
#endif
_documentsDirectory = paths.firstObject;
_documentsDirectory = paths.firstObject;
}
return _documentsDirectory;
}
@ -489,7 +487,7 @@ enum
- (void)mainMenuPushPop: (bool)pushp
{
#if TARGET_OS_IOS
if ( pushp )
if (pushp)
{
self.menu_count++;
RAMenuBase* next_menu = [RAMainMenu new];
@ -499,7 +497,7 @@ enum
}
else
{
if ( self.menu_count == 0 )
if (self.menu_count == 0)
[self.mainmenu reloadData];
else
{
@ -592,28 +590,29 @@ static void *ui_companion_cocoatouch_init(void)
static void ui_companion_cocoatouch_notify_list_pushed(void *data,
file_list_t *list, file_list_t *menu_list)
{
RetroArch_iOS *ap = (RetroArch_iOS *)apple_platform;
bool pushp = false;
size_t new_size = file_list_get_size( menu_list );
static size_t old_size = 0;
RetroArch_iOS *ap = (RetroArch_iOS *)apple_platform;
bool pushp = false;
size_t new_size = file_list_get_size(menu_list);
/* FIXME workaround for the double call */
if ( old_size == 0 )
if (old_size == 0)
{
old_size = new_size;
return;
}
if ( old_size == new_size )
pushp = false;
else if ( old_size < new_size )
pushp = true;
else if ( old_size > new_size )
printf( "notify_list_pushed: old size should not be larger\n" );
if (old_size == new_size)
pushp = false;
else if (old_size < new_size)
pushp = true;
else if (old_size > new_size)
printf("notify_list_pushed: old size should not be larger\n" );
old_size = new_size;
if (ap)
[ap mainMenuPushPop: pushp];
[ap mainMenuPushPop: pushp];
}
static void ui_companion_cocoatouch_notify_refresh(void *data)
@ -626,6 +625,7 @@ static void ui_companion_cocoatouch_notify_refresh(void *data)
static void ui_companion_cocoatouch_render_messagebox(const char *msg)
{
static char msg_old[PATH_MAX_LENGTH];
RetroArch_iOS *ap = (RetroArch_iOS *)apple_platform;
if (ap && !string_is_equal(msg, msg_old))

View File

@ -53,8 +53,6 @@ extern "C" {
#define GROUPED_DRAGGING static_cast<QMainWindow::DockOption>(0)
#endif
static bool already_started = false;
typedef struct ui_companion_qt
{
ui_application_qt_t *app;
@ -652,11 +650,12 @@ static void ui_companion_qt_notify_content_loaded(void *data) { }
static void ui_companion_qt_toggle(void *data, bool force)
{
ui_companion_qt_t *handle = (ui_companion_qt_t*)data;
ui_window_qt_t *win_handle = (ui_window_qt_t*)handle->window;
settings_t *settings = config_get_ptr();
bool ui_companion_toggle = settings->bools.ui_companion_toggle;
bool video_fullscreen = settings->bools.video_fullscreen;
static bool already_started = false;
ui_companion_qt_t *handle = (ui_companion_qt_t*)data;
ui_window_qt_t *win_handle = (ui_window_qt_t*)handle->window;
settings_t *settings = config_get_ptr();
bool ui_companion_toggle = settings->bools.ui_companion_toggle;
bool video_fullscreen = settings->bools.video_fullscreen;
if (ui_companion_toggle || force)
{

View File

@ -27,7 +27,8 @@
#include "../../ui_companion_driver.h"
#include "../../configuration.h"
static bool ui_browser_window_win32_core(ui_browser_window_state_t *state, bool save)
static bool ui_browser_window_win32_core(
ui_browser_window_state_t *state, bool save)
{
OPENFILENAME ofn;
bool okay = false;

View File

@ -23,7 +23,8 @@
#include "../../ui_companion_driver.h"
static enum ui_msg_window_response ui_msg_window_win32_response(ui_msg_window_state *state, UINT response)
static enum ui_msg_window_response ui_msg_window_win32_response(
ui_msg_window_state *state, UINT response)
{
switch (response)
{

View File

@ -82,9 +82,10 @@ static void ui_window_win32_set_title(void *data, char *buf)
void ui_window_win32_set_droppable(void *data, bool droppable)
{
/* Minimum supported client: Windows XP, minimum supported server: Windows 2000 Server */
/* Minimum supported client: Windows XP,
* minimum supported server: Windows 2000 Server */
ui_window_win32_t *window = (ui_window_win32_t*)data;
if (DragAcceptFiles_func != NULL)
if (DragAcceptFiles_func)
DragAcceptFiles_func(window->hwnd, droppable);
}