(QT/UI) Cleanups

This commit is contained in:
twinaphex 2019-04-21 03:28:23 +02:00
parent 254c48707d
commit c662da11c3
12 changed files with 214 additions and 196 deletions

View File

@ -82,10 +82,10 @@ void CoreInfoDialog::showCoreInfo()
for (i = 0; i < infoList.count(); i++)
{
const QHash<QString, QString> &line = infoList.at(i);
QLabel *label = new QLabel(line.value("key"));
CoreInfoLabel *value = new CoreInfoLabel(line.value("value"));
QString labelStyle = line.value("label_style");
QString valueStyle = line.value("value_style");
QLabel *label = new QLabel(line.value("key"));
CoreInfoLabel *value = new CoreInfoLabel(line.value("value"));
QString labelStyle = line.value("label_style");
QString valueStyle = line.value("value_style");
if (!labelStyle.isEmpty())
label->setStyleSheet(labelStyle);

View File

@ -284,9 +284,7 @@ void CoreOptionsDialog::buildLayout()
comboBox = new QComboBox(this);
for (k = 0; k < option->vals->size; k++)
{
comboBox->addItem(option->vals->elems[k].data, option->key);
}
comboBox->setCurrentText(val);

View File

@ -106,11 +106,11 @@ void MainWindow::onFileDropWidgetContextMenuRequested(const QPoint &pos)
QScopedPointer<QAction> editAction;
QScopedPointer<QAction> deleteAction;
QPointer<QAction> selectedAction;
QPoint cursorPos = QCursor::pos();
QPoint cursorPos = QCursor::pos();
QHash<QString, QString> contentHash = getCurrentContentHash();
bool specialPlaylist = currentPlaylistIsSpecial();
bool allPlaylist = currentPlaylistIsAll();
bool actionsAdded = false;
bool specialPlaylist = currentPlaylistIsSpecial();
bool allPlaylist = currentPlaylistIsAll();
bool actionsAdded = false;
menu.reset(new QMenu(this));
@ -178,37 +178,40 @@ void MainWindow::onFileDropWidgetContextMenuRequested(const QPoint &pos)
{
if (selectedAction == addFilesAction.data())
{
QStringList filePaths = QFileDialog::getOpenFileNames(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SELECT_FILES));
QStringList filePaths = QFileDialog::getOpenFileNames(
this,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SELECT_FILES));
if (!filePaths.isEmpty())
addFilesToPlaylist(filePaths);
}
else if (selectedAction == addEntryAction.data())
{
addFilesToPlaylist(QStringList());
}
else if (selectedAction == addFolderAction.data())
{
QString dirPath = QFileDialog::getExistingDirectory(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SELECT_FOLDER), QString(), QFileDialog::ShowDirsOnly);
QString dirPath = QFileDialog::getExistingDirectory(
this,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SELECT_FOLDER),
QString(), QFileDialog::ShowDirsOnly);
if (!dirPath.isEmpty())
addFilesToPlaylist(QStringList() << dirPath);
}
else if (selectedAction == editAction.data())
{
PlaylistEntryDialog *playlistDialog = playlistEntryDialog();
QHash<QString, QString> selectedCore;
QString selectedDatabase;
QString selectedName;
QString selectedPath;
QString currentPlaylistPath = getCurrentPlaylistPath();
QHash<QString, QString> selectedCore;
PlaylistEntryDialog *playlistDialog = playlistEntryDialog();
QString currentPlaylistPath = getCurrentPlaylistPath();
if (!playlistDialog->showDialog(contentHash))
return;
selectedName = m_playlistEntryDialog->getSelectedName();
selectedPath = m_playlistEntryDialog->getSelectedPath();
selectedCore = m_playlistEntryDialog->getSelectedCore();
selectedName = m_playlistEntryDialog->getSelectedName();
selectedPath = m_playlistEntryDialog->getSelectedPath();
selectedCore = m_playlistEntryDialog->getSelectedCore();
selectedDatabase = m_playlistEntryDialog->getSelectedDatabase();
if (selectedCore.isEmpty())
@ -218,15 +221,13 @@ void MainWindow::onFileDropWidgetContextMenuRequested(const QPoint &pos)
}
if (selectedDatabase.isEmpty())
{
selectedDatabase = QFileInfo(currentPlaylistPath).fileName().remove(file_path_str(FILE_PATH_LPL_EXTENSION));
}
contentHash["label"] = selectedName;
contentHash["path"] = selectedPath;
contentHash["label"] = selectedName;
contentHash["path"] = selectedPath;
contentHash["core_name"] = selectedCore.value("core_name");
contentHash["core_path"] = selectedCore.value("core_path");
contentHash["db_name"] = selectedDatabase;
contentHash["db_name"] = selectedDatabase;
if (!updateCurrentPlaylistEntry(contentHash))
{
@ -235,8 +236,6 @@ void MainWindow::onFileDropWidgetContextMenuRequested(const QPoint &pos)
}
}
else if (selectedAction == deleteAction.data())
{
deleteCurrentPlaylistItem();
}
}
}

View File

@ -430,8 +430,10 @@ QString GridView::getLayout() const
return "anchored";
case Centered:
default:
return "centered";
break;
}
return "centered";
}
void GridView::setLayout(QString layout)
@ -474,14 +476,16 @@ QString GridItem::getThumbnailVerticalAlign() const
{
switch (thumbnailVerticalAlignmentFlag)
{
case Qt::AlignTop:
return "top";
case Qt::AlignVCenter:
return "center";
case Qt::AlignBottom:
default:
return "bottom";
case Qt::AlignTop:
return "top";
case Qt::AlignVCenter:
return "center";
case Qt::AlignBottom:
default:
break;
}
return "bottom";
}
void GridItem::setThumbnailVerticalAlign(const QString valign)

View File

@ -132,22 +132,24 @@ void PlaylistEntryDialog::loadPlaylistOptions()
for (i = 0; i < core_info_list->count; i++)
{
const core_info_t *core = &core_info_list->list[i];
QStringList databases = QString(core->databases).split("|");
QHash<QString, QString> hash;
QString ui_display_name;
QHash<QString, QString> hash;
const core_info_t *core = &core_info_list->list[i];
QStringList databases = QString(core->databases).split("|");
hash["core_name"] = core->core_name;
hash["core_name"] = core->core_name;
hash["core_display_name"] = core->display_name;
hash["core_path"] = core->path;
hash["core_databases"] = core->databases;
hash["core_path"] = core->path;
hash["core_databases"] = core->databases;
ui_display_name = hash.value("core_name");
ui_display_name = hash.value("core_name");
if (ui_display_name.isEmpty())
ui_display_name = hash.value("core_display_name");
ui_display_name = hash.value("core_display_name");
if (ui_display_name.isEmpty())
ui_display_name = QFileInfo(hash.value("core_path")).fileName();
ui_display_name = QFileInfo(
hash.value("core_path")).fileName();
if (ui_display_name.isEmpty())
continue;
@ -191,12 +193,13 @@ bool PlaylistEntryDialog::nameFieldEnabled()
return m_nameLineEdit->isEnabled();
}
void PlaylistEntryDialog::setEntryValues(const QHash<QString, QString> &contentHash)
void PlaylistEntryDialog::setEntryValues(
const QHash<QString, QString> &contentHash)
{
QString db;
QString coreName = contentHash.value("core_name");
int foundDB = 0;
int i = 0;
int i = 0;
loadPlaylistOptions();

View File

@ -293,9 +293,7 @@ void MainWindow::downloadNextPlaylistThumbnail(QString system, QString title, QS
void MainWindow::downloadPlaylistThumbnails(QString playlistPath)
{
QFile playlistFile(playlistPath);
QString system;
QString title;
QString type;
QString system, title, type;
settings_t *settings = config_get_ptr();
int i;
int count;
@ -304,8 +302,8 @@ void MainWindow::downloadPlaylistThumbnails(QString playlistPath)
return;
m_pendingPlaylistThumbnails.clear();
m_downloadedThumbnails = 0;
m_failedThumbnails = 0;
m_downloadedThumbnails = 0;
m_failedThumbnails = 0;
m_playlistThumbnailDownloadWasCanceled = false;
count = m_playlistModel->rowCount();
@ -320,15 +318,15 @@ void MainWindow::downloadPlaylistThumbnails(QString playlistPath)
QHash<QString, QString> hash2;
QHash<QString, QString> hash3;
hash["db_name"] = itemHash.value("db_name");
hash["db_name"] = itemHash.value("db_name");
hash["label_noext"] = itemHash.value("label_noext");
hash["type"] = THUMBNAIL_BOXART;
hash["type"] = THUMBNAIL_BOXART;
hash2 = hash;
hash3 = hash;
hash2 = hash;
hash3 = hash;
hash2["type"] = THUMBNAIL_SCREENSHOT;
hash3["type"] = THUMBNAIL_TITLE;
hash2["type"] = THUMBNAIL_SCREENSHOT;
hash3["type"] = THUMBNAIL_TITLE;
m_pendingPlaylistThumbnails.append(hash);
m_pendingPlaylistThumbnails.append(hash2);

View File

@ -94,7 +94,8 @@ Qt::ItemFlags PlaylistModel::flags(const QModelIndex &index) const
bool PlaylistModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (index.isValid() && role == Qt::EditRole) {
if (index.isValid() && role == Qt::EditRole)
{
QHash<QString, QString> hash = m_contents.at(index.row());
hash["label"] = value.toString();
@ -114,8 +115,7 @@ QVariant PlaylistModel::headerData(int section, Qt::Orientation orientation, int
if (orientation == Qt::Horizontal)
return msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NAME);
else
return section + 1;
return section + 1;
}
void PlaylistModel::setThumbnailType(const ThumbnailType type)
@ -151,9 +151,7 @@ bool PlaylistModel::isSupportedImage(const QString path) const
extensionStr = path.mid(lastIndex + 1);
if (!extensionStr.isEmpty())
{
extension = extensionStr.toLower().toUtf8();
}
}
if (!extension.isEmpty() && m_imageFormats.contains(extension))
@ -174,30 +172,32 @@ QString PlaylistModel::getThumbnailPath(const QHash<QString, QString> &hash, QSt
/* use thumbnail widgets to show regular image files */
return hash["path"];
}
else
{
return getPlaylistThumbnailsDir(hash.value("db_name")) + "/" + type + "/" + getSanitizedThumbnailName(hash["label_noext"]);
}
return getPlaylistThumbnailsDir(hash.value("db_name"))
+ "/" + type + "/" + getSanitizedThumbnailName(hash["label_noext"]);
}
QString PlaylistModel::getCurrentTypeThumbnailPath(const QModelIndex &index) const
{
switch (m_thumbnailType)
{
case THUMBNAIL_TYPE_BOXART:
return getThumbnailPath(index, THUMBNAIL_BOXART);
case THUMBNAIL_TYPE_SCREENSHOT:
return getThumbnailPath(index, THUMBNAIL_SCREENSHOT);
case THUMBNAIL_TYPE_TITLE_SCREEN:
return getThumbnailPath(index, THUMBNAIL_TITLE);
default:
return QString();
case THUMBNAIL_TYPE_BOXART:
return getThumbnailPath(index, THUMBNAIL_BOXART);
case THUMBNAIL_TYPE_SCREENSHOT:
return getThumbnailPath(index, THUMBNAIL_SCREENSHOT);
case THUMBNAIL_TYPE_TITLE_SCREEN:
return getThumbnailPath(index, THUMBNAIL_TITLE);
default:
break;
}
return QString();
}
void PlaylistModel::reloadThumbnail(const QModelIndex &index)
{
if (index.isValid()) {
if (index.isValid())
{
reloadThumbnailPath(getCurrentTypeThumbnailPath(index));
loadThumbnail(index);
}
@ -281,16 +281,16 @@ bool MainWindow::addDirectoryFilesToList(QProgressDialog *dialog, QStringList &l
if (dialog->wasCanceled())
return false;
/* Needed to update progress dialog while doing
* a lot of stuff on the main thread. */
if (i % 25 == 0)
{
/* Needed to update progress dialog while doing a lot of stuff on the main thread. */
qApp->processEvents();
}
if (fileInfo.isDir())
{
QDir fileInfoDir(path);
bool success = addDirectoryFilesToList(dialog, list, fileInfoDir, extensions);
bool success = addDirectoryFilesToList(
dialog, list, fileInfoDir, extensions);
if (!success)
return false;
@ -449,11 +449,10 @@ void MainWindow::addFilesToPlaylist(QStringList files)
if (dialog->wasCanceled())
return;
/* Needed to update progress dialog while
* doing a lot of stuff on the main thread. */
if (i % 25 == 0)
{
/* Needed to update progress dialog while doing a lot of stuff on the main thread. */
qApp->processEvents();
}
if (fileInfo.isDir())
{
@ -517,9 +516,11 @@ void MainWindow::addFilesToPlaylist(QStringList files)
const char *coreNameData = NULL;
const char *databaseData = NULL;
/* Cancel out of everything, the
* current progress will not be written
* to the playlist at all. */
if (dialog->wasCanceled())
{
/* Cancel out of everything, the current progress will not be written to the playlist at all. */
playlist_free(playlist);
return;
}
@ -1202,9 +1203,7 @@ void MainWindow::reloadPlaylists()
if (!foundCurrent)
{
if (foundInitial && initialItem)
{
m_listWidget->setCurrentItem(initialItem);
}
else
{
/* the previous playlist must be gone now, just select the first one */
@ -1218,8 +1217,8 @@ void MainWindow::reloadPlaylists()
QString MainWindow::getCurrentPlaylistPath()
{
QListWidgetItem *playlistItem = m_listWidget->currentItem();
QString playlistPath;
QListWidgetItem *playlistItem = m_listWidget->currentItem();
if (!playlistItem)
return playlistPath;
@ -1231,23 +1230,24 @@ QString MainWindow::getCurrentPlaylistPath()
bool MainWindow::currentPlaylistIsSpecial()
{
settings_t *settings = config_get_ptr();
QDir playlistDir(settings->paths.directory_playlist);
QString playlistDirAbsPath = playlistDir.absolutePath();
QFileInfo currentPlaylistFileInfo;
QString currentPlaylistPath;
QString currentPlaylistDirPath;
bool specialPlaylist = false;
settings_t *settings = config_get_ptr();
QDir playlistDir(settings->paths.directory_playlist);
QString playlistDirAbsPath = playlistDir.absolutePath();
QListWidgetItem *currentPlaylistItem = m_listWidget->currentItem();
bool specialPlaylist = false;
if (!currentPlaylistItem)
return false;
currentPlaylistPath = currentPlaylistItem->data(Qt::UserRole).toString();
currentPlaylistPath = currentPlaylistItem->data(Qt::UserRole).toString();
currentPlaylistFileInfo = QFileInfo(currentPlaylistPath);
currentPlaylistDirPath = currentPlaylistFileInfo.absoluteDir().absolutePath();
currentPlaylistDirPath = currentPlaylistFileInfo.absoluteDir().absolutePath();
/* Don't just compare strings in case there are case differences on Windows that should be ignored. */
/* Don't just compare strings in case there are
* case differences on Windows that should be ignored. */
if (QDir(currentPlaylistDirPath) != QDir(playlistDirAbsPath))
specialPlaylist = true;
@ -1262,7 +1262,8 @@ bool MainWindow::currentPlaylistIsAll()
if (!currentPlaylistItem)
return false;
if (currentPlaylistItem->data(Qt::UserRole).toString() == ALL_PLAYLISTS_TOKEN)
if (currentPlaylistItem->data(Qt::UserRole).toString()
== ALL_PLAYLISTS_TOKEN)
all = true;
return all;
@ -1310,10 +1311,12 @@ void MainWindow::deleteCurrentPlaylistItem()
QVector<QHash<QString, QString> > MainWindow::getPlaylistDefaultCores()
{
settings_t *settings = config_get_ptr();
struct string_list *playlists = string_split(settings->arrays.playlist_names, ";");
struct string_list *cores = string_split(settings->arrays.playlist_cores, ";");
unsigned i = 0;
settings_t *settings = config_get_ptr();
struct string_list *playlists = string_split(
settings->arrays.playlist_names, ";");
struct string_list *cores = string_split(
settings->arrays.playlist_cores, ";");
QVector<QHash<QString, QString> > coreList;
if (!playlists || !cores)
@ -1433,9 +1436,7 @@ void PlaylistModel::addPlaylistItems(const QStringList &paths, bool add)
m_contents.clear();
for (i = 0; i < paths.size(); i++)
{
getPlaylistItems(paths.at(i));
}
endResetModel();
}
@ -1466,10 +1467,10 @@ void PlaylistModel::addDir(QString path, QFlags<QDir::Filter> showHidden)
QString filePath(QDir::toNativeSeparators(dir.absoluteFilePath(fileName)));
QFileInfo fileInfo(filePath);
hash["path"] = filePath;
hash["label"] = hash["path"];
hash["path"] = filePath;
hash["label"] = hash["path"];
hash["label_noext"] = fileInfo.completeBaseName();
hash["db_name"] = fileInfo.dir().dirName();
hash["db_name"] = fileInfo.dir().dirName();
m_contents.append(hash);
}

View File

@ -150,9 +150,9 @@ void FormLayout::addFloatSliderAndSpinBox(rarch_setting_t *setting)
void FormLayout::addUIntColorButton(const QString &title, msg_hash_enums r, msg_hash_enums g, msg_hash_enums b)
{
rarch_setting_t *red = menu_setting_find_enum(r);
rarch_setting_t *red = menu_setting_find_enum(r);
rarch_setting_t *green = menu_setting_find_enum(g);
rarch_setting_t *blue = menu_setting_find_enum(b);
rarch_setting_t *blue = menu_setting_find_enum(b);
if (red && green && blue)
addRow(title, new UIntColorButton(red, green, blue));
@ -326,7 +326,7 @@ CheckableSettingsGroup::CheckableSettingsGroup(rarch_setting_t *setting, QWidget
if (setting && setting->short_description)
{
m_setting = setting;
m_value = setting->value.target.boolean;
m_value = setting->value.target.boolean;
setTitle(setting->short_description);
@ -1088,7 +1088,7 @@ ColorButton::ColorButton(msg_hash_enums red, msg_hash_enums green, msg_hash_enum
void ColorButton::paintEvent(QPaintEvent *event)
{
const int pixSize = 10;
const int corr = 5;
const int corr = 5;
const QColor frameColor1(0, 0, 0, 26);
const QColor frameColor2(0, 0, 0, 51);

View File

@ -57,7 +57,8 @@ static enum ui_msg_window_response ui_msg_window_qt_response(ui_msg_window_state
return UI_MSG_RESPONSE_NA;
}
static QFlags<QMessageBox::StandardButton> ui_msg_window_qt_buttons(ui_msg_window_state *state)
static QFlags<QMessageBox::StandardButton>
ui_msg_window_qt_buttons(ui_msg_window_state *state)
{
switch (state->buttons)
{
@ -74,7 +75,8 @@ static QFlags<QMessageBox::StandardButton> ui_msg_window_qt_buttons(ui_msg_windo
return QMessageBox::NoButton;
}
static enum ui_msg_window_response ui_msg_window_qt_error(ui_msg_window_state *state)
static enum ui_msg_window_response
ui_msg_window_qt_error(ui_msg_window_state *state)
{
QFlags<QMessageBox::StandardButton> flags = ui_msg_window_qt_buttons(state);
return ui_msg_window_qt_response(state, QMessageBox::critical((QWidget*)state->window, state->title, state->text, flags));

View File

@ -127,7 +127,7 @@ static void scan_finished_handler(retro_task_t *task,
void *task_data, void *user_data, const char *err)
{
bool dontAsk = false;
bool answer = false;
bool answer = false;
#ifdef HAVE_MENU
menu_ctx_environment_t menu_environ;
@ -730,19 +730,19 @@ MainWindow::~MainWindow()
delete m_proxyFileModel;
}
void MainWindow::startTimer() {
void MainWindow::startTimer()
{
if (m_thumbnailTimer->isActive())
{
m_thumbnailTimer->stop();
m_thumbnailTimer->start(50);
}
else
{
m_thumbnailTimer->start(50);
}
}
void MainWindow::updateVisibleItems() {
void MainWindow::updateVisibleItems()
{
if (m_currentBrowser == BROWSER_TYPE_PLAYLISTS && m_viewType == VIEW_TYPE_ICONS)
{
unsigned i;
@ -1194,13 +1194,9 @@ void MainWindow::onLaunchWithComboBoxIndexChanged(int)
m_coreInfoLabel->setText(coreInfoText);
if (coreSelection == CORE_SELECTION_LOAD_CORE)
{
onLoadCoreClicked();
}
else
{
m_loadCoreWindow->setProperty("last_launch_with_index", m_launchWithComboBox->currentIndex());
}
}
MainWindow::Theme MainWindow::getThemeFromString(QString themeString)
@ -1280,14 +1276,14 @@ void MainWindow::changeThumbnailType(ThumbnailType type)
QString MainWindow::changeThumbnail(const QImage &image, QString type)
{
QHash<QString, QString> hash = getCurrentContentHash();
QString dirString = m_playlistModel->getPlaylistThumbnailsDir(hash["db_name"]) + "/" + type;
QString thumbPath = dirString + "/" + m_playlistModel->getSanitizedThumbnailName(hash["label_noext"]);
QByteArray dirArray = QDir::toNativeSeparators(dirString).toUtf8();
const char *dirData = dirArray.constData();
QByteArray thumbArray = QDir::toNativeSeparators(thumbPath).toUtf8();
const char *thumbData = thumbArray.constData();
QString dirString = m_playlistModel->getPlaylistThumbnailsDir(hash["db_name"]) + "/" + type;
QString thumbPath = dirString + "/" + m_playlistModel->getSanitizedThumbnailName(hash["label_noext"]);
QByteArray dirArray = QDir::toNativeSeparators(dirString).toUtf8();
const char *dirData = dirArray.constData();
QByteArray thumbArray = QDir::toNativeSeparators(thumbPath).toUtf8();
const char *thumbData = thumbArray.constData();
int quality = -1;
QDir dir(dirString);
int quality = -1;
QImage scaledImage(image);
if (!dir.exists())
@ -1325,7 +1321,8 @@ QString MainWindow::changeThumbnail(const QImage &image, QString type)
return QString();
}
void MainWindow::onThumbnailDropped(const QImage &image, ThumbnailType thumbnailType)
void MainWindow::onThumbnailDropped(const QImage &image,
ThumbnailType thumbnailType)
{
switch (thumbnailType)
{
@ -1381,11 +1378,11 @@ void MainWindow::onThumbnailDropped(const QImage &image, ThumbnailType thumbnail
QVector<QHash<QString, QString> > MainWindow::getCoreInfo()
{
unsigned i;
QVector<QHash<QString, QString> > infoList;
QHash<QString, QString> currentCore = getSelectedCore();
core_info_list_t *core_info_list = NULL;
const core_info_t *core_info = NULL;
unsigned i = 0;
core_info_list_t *core_info_list = NULL;
const core_info_t *core_info = NULL;
core_info_get_list(&core_info_list);
@ -1407,7 +1404,8 @@ QVector<QHash<QString, QString> > MainWindow::getCoreInfo()
{
QHash<QString, QString> hash;
hash["key"] = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_CORE_INFORMATION_AVAILABLE);
hash["key"] = msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_NO_CORE_INFORMATION_AVAILABLE);
hash["value"] = "";
infoList.append(hash);
@ -1419,7 +1417,8 @@ QVector<QHash<QString, QString> > MainWindow::getCoreInfo()
{
QHash<QString, QString> hash;
hash["key"] = QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_CORE_NAME)) + ":";
hash["key"] = QString(
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_CORE_NAME)) + ":";
hash["value"] = core_info->core_name;
infoList.append(hash);
@ -1429,7 +1428,8 @@ QVector<QHash<QString, QString> > MainWindow::getCoreInfo()
{
QHash<QString, QString> hash;
hash["key"] = QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_CORE_LABEL)) + ":";
hash["key"] = QString(
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_CORE_LABEL)) + ":";
hash["value"] = core_info->display_name;
infoList.append(hash);
@ -1468,7 +1468,8 @@ QVector<QHash<QString, QString> > MainWindow::getCoreInfo()
categories += ", ";
}
hash["key"] = QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_CATEGORIES)) + ":";
hash["key"] = QString(
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_CATEGORIES)) + ":";
hash["value"] = categories;
infoList.append(hash);
@ -1487,7 +1488,8 @@ QVector<QHash<QString, QString> > MainWindow::getCoreInfo()
authors += ", ";
}
hash["key"] = QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_AUTHORS)) + ":";
hash["key"] = QString(
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_AUTHORS)) + ":";
hash["value"] = authors;
infoList.append(hash);
@ -1506,7 +1508,8 @@ QVector<QHash<QString, QString> > MainWindow::getCoreInfo()
permissions += ", ";
}
hash["key"] = QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_PERMISSIONS)) + ":";
hash["key"] = QString(
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_PERMISSIONS)) + ":";
hash["value"] = permissions;
infoList.append(hash);
@ -1525,7 +1528,8 @@ QVector<QHash<QString, QString> > MainWindow::getCoreInfo()
licenses += ", ";
}
hash["key"] = QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_LICENSES)) + ":";
hash["key"] = QString(
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_LICENSES)) + ":";
hash["value"] = licenses;
infoList.append(hash);
@ -1544,7 +1548,8 @@ QVector<QHash<QString, QString> > MainWindow::getCoreInfo()
supported_extensions += ", ";
}
hash["key"] = QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_SUPPORTED_EXTENSIONS)) + ":";
hash["key"] = QString(
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_SUPPORTED_EXTENSIONS)) + ":";
hash["value"] = supported_extensions;
infoList.append(hash);
@ -1590,13 +1595,13 @@ QVector<QHash<QString, QString> > MainWindow::getCoreInfo()
if (core_info->firmware[i].missing)
{
missing = true;
missing = true;
labelText += msg_hash_to_str(MENU_ENUM_LABEL_VALUE_MISSING);
}
else
labelText += msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PRESENT);
labelText += ", ";
labelText += ", ";
if (core_info->firmware[i].optional)
labelText += msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OPTIONAL);
@ -1690,8 +1695,8 @@ void MainWindow::selectBrowserDir(QString path)
if (!path.isEmpty())
{
QModelIndex sourceIndex = m_fileModel->setRootPath(path);
QModelIndex proxyIndex = m_proxyFileModel->mapFromSource(sourceIndex);
m_fileTableHeaderState = m_fileTableView->horizontalHeader()->saveState();
QModelIndex proxyIndex = m_proxyFileModel->mapFromSource(sourceIndex);
m_fileTableHeaderState = m_fileTableView->horizontalHeader()->saveState();
if (proxyIndex.isValid())
m_fileTableView->setRootIndex(proxyIndex);
@ -1846,10 +1851,10 @@ void MainWindow::loadContent(const QHash<QString, QString> &contentHash)
QByteArray corePathArray;
QByteArray contentPathArray;
QByteArray contentLabelArray;
const char *corePath = NULL;
const char *contentPath = NULL;
const char *corePath = NULL;
const char *contentPath = NULL;
const char *contentLabel = NULL;
QVariantMap coreMap = m_launchWithComboBox->currentData(Qt::UserRole).value<QVariantMap>();
QVariantMap coreMap = m_launchWithComboBox->currentData(Qt::UserRole).value<QVariantMap>();
CoreSelection coreSelection = static_cast<CoreSelection>(coreMap.value("core_selection").toInt());
if (m_pendingRun)
@ -1938,9 +1943,9 @@ void MainWindow::loadContent(const QHash<QString, QString> &contentHash)
return;
}
corePath = corePathArray.constData();
contentPath = contentPathArray.constData();
contentLabel = contentLabelArray.constData();
corePath = corePathArray.constData();
contentPath = contentPathArray.constData();
contentLabel = contentLabelArray.constData();
content_info.argc = 0;
content_info.argv = NULL;
@ -1957,7 +1962,8 @@ void MainWindow::loadContent(const QHash<QString, QString> &contentHash)
corePath, contentPath, contentLabel, &content_info,
NULL, NULL))
{
QMessageBox::critical(this, msg_hash_to_str(MSG_ERROR), msg_hash_to_str(MSG_FAILED_TO_LOAD_CONTENT));
QMessageBox::critical(this, msg_hash_to_str(MSG_ERROR),
msg_hash_to_str(MSG_FAILED_TO_LOAD_CONTENT));
return;
}
@ -1995,7 +2001,8 @@ bool MainWindow::isContentLessCore()
bool MainWindow::isCoreLoaded()
{
if (m_currentCore.isEmpty() || m_currentCore == msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_CORE))
if ( m_currentCore.isEmpty() ||
m_currentCore == msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_CORE))
return false;
return true;
@ -2028,8 +2035,8 @@ void MainWindow::setCoreActions()
if (isCoreLoaded() && m_settings->value("suggest_loaded_core_first", false).toBool())
{
QVariantMap comboBoxMap;
comboBoxMap["core_name"] = m_currentCore;
comboBoxMap["core_path"] = path_get(RARCH_PATH_CORE);
comboBoxMap["core_name"] = m_currentCore;
comboBoxMap["core_path"] = path_get(RARCH_PATH_CORE);
comboBoxMap["core_selection"] = CORE_SELECTION_CURRENT;
m_launchWithComboBox->addItem(m_currentCore, QVariant::fromValue(comboBoxMap));
}
@ -2067,8 +2074,8 @@ void MainWindow::setCoreActions()
if (!found_existing)
{
QVariantMap comboBoxMap;
comboBoxMap["core_name"] = coreName;
comboBoxMap["core_path"] = hash["core_path"];
comboBoxMap["core_name"] = coreName;
comboBoxMap["core_path"] = hash["core_path"];
comboBoxMap["core_selection"] = CORE_SELECTION_PLAYLIST_SAVED;
m_launchWithComboBox->addItem(coreName, QVariant::fromValue(comboBoxMap));
}
@ -2109,9 +2116,9 @@ void MainWindow::setCoreActions()
{
if (allPlaylists)
{
QListWidgetItem *listItem = m_listWidget->item(row);
QString listItemString = listItem->data(Qt::UserRole).toString();
QFileInfo info;
QListWidgetItem *listItem = m_listWidget->item(row);
QString listItemString = listItem->data(Qt::UserRole).toString();
info.setFile(listItemString);
@ -2122,7 +2129,7 @@ void MainWindow::setCoreActions()
for (i = 0; i < defaultCores.count(); i++)
{
QString playlist = defaultCores.at(i)["playlist_filename"];
QString core = defaultCores.at(i)["core_path"];
QString core = defaultCores.at(i)["core_path"];
playlist.remove(file_path_str(FILE_PATH_LPL_EXTENSION));
@ -2397,17 +2404,18 @@ void MainWindow::renamePlaylistItem(QListWidgetItem *item, QString newName)
QFileInfo playlistInfo;
QString playlistPath;
settings_t *settings = config_get_ptr();
QDir playlistDir(settings->paths.directory_playlist);
bool specialPlaylist = false;
QDir playlistDir(settings->paths.directory_playlist);
if (!item)
return;
playlistPath = item->data(Qt::UserRole).toString();
playlistInfo = playlistPath;
oldName = playlistInfo.completeBaseName();
oldName = playlistInfo.completeBaseName();
/* Don't just compare strings in case there are case differences on Windows that should be ignored. */
/* Don't just compare strings in case there are
* case differences on Windows that should be ignored. */
if (QDir(playlistInfo.absoluteDir()) != QDir(playlistDir))
{
/* special playlists like history etc. can't have an association */
@ -2465,7 +2473,7 @@ void MainWindow::onCurrentFileChanged(const QModelIndex &index)
void MainWindow::onCurrentItemChanged(const QHash<QString, QString> &hash)
{
QString path = hash["path"];
QString path = hash["path"];
bool acceptDrop = false;
if (m_thumbnailPixmap)
@ -2666,7 +2674,7 @@ TreeView* MainWindow::dirTreeView()
void MainWindow::onTimeout()
{
bool contentless = false;
bool is_inited = false;
bool is_inited = false;
content_get_status(&contentless, &is_inited);
@ -3025,15 +3033,15 @@ void MainWindow::onShowInfoMessage(QString msg)
int MainWindow::onExtractArchive(QString path, QString extractionDir, QString tempExtension, retro_task_callback_t cb)
{
QByteArray pathArray = path.toUtf8();
QByteArray dirArray = extractionDir.toUtf8();
const char *file = pathArray.constData();
const char *dir = dirArray.constData();
unsigned i;
file_archive_transfer_t state;
struct archive_extract_userdata userdata;
QByteArray pathArray = path.toUtf8();
QByteArray dirArray = extractionDir.toUtf8();
const char *file = pathArray.constData();
const char *dir = dirArray.constData();
struct string_list *file_list = file_archive_get_file_list(file, NULL);
bool returnerr = true;
unsigned i;
bool returnerr = true;
if (!file_list || file_list->size == 0)
{

View File

@ -29,7 +29,7 @@ static void extractUpdateCB(retro_task_t *task,
void *task_data, void *user_data, const char *err)
{
decompress_task_data_t *dec = (decompress_task_data_t*)task_data;
MainWindow *mainwindow = (MainWindow*)user_data;
MainWindow *mainwindow = (MainWindow*)user_data;
if (err)
RARCH_ERR("%s", err);
@ -106,9 +106,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();
RARCH_ERR("[Qt]: %s\n", stringData);
}
@ -129,7 +130,10 @@ void MainWindow::onRetroArchUpdateDownloadFinished()
m_updateProgressDialog->cancel();
/* At least on Linux, the progress dialog will refuse to hide itself and will stay on screen in a corrupted way if we happen to show an error message in this function. processEvents() will sometimes fix it, other times not... seems random. */
/* At least on Linux, the progress dialog will refuse to hide itself and
* will stay onscreen in a corrupted way if we happen to show an error
* message in this function. processEvents() will sometimes fix it,
* other times not... seems random. */
qApp->processEvents();
if (!reply)
@ -143,7 +147,9 @@ void MainWindow::onRetroArchUpdateDownloadFinished()
if (code != 200)
{
emit showErrorMessageDeferred(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NETWORK_ERROR)) + ": HTTP Code " + QString::number(code));
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);
reply->disconnect();
reply->abort();

View File

@ -41,7 +41,7 @@ static const int MAX_MIN_HEIGHT = 250;
QPixmap getColorizedPixmap(const QPixmap& oldPixmap, const QColor& color)
{
QPixmap pixmap = oldPixmap;
QBitmap mask = pixmap.createMaskFromColor(Qt::transparent, Qt::MaskInColor);
QBitmap mask = pixmap.createMaskFromColor(Qt::transparent, Qt::MaskInColor);
pixmap.fill(color);
pixmap.setMask(mask);
return pixmap;
@ -70,14 +70,16 @@ private:
void resizeEvent(QResizeEvent *event) final
{
QWidget *inner = widget();
if (inner)
{
int fw = frameWidth() * 2;
QSize innerSize = event->size() - QSize(fw, fw);
int fw = frameWidth() * 2;
QSize innerSize = event->size() - QSize(fw, fw);
QSize innerSizeHint = inner->minimumSizeHint();
/* Widget wants to be bigger than available space */
if (innerSizeHint.height() > innerSize.height())
{ /* Widget wants to be bigger than available space */
{
innerSize.setWidth(innerSize.width() - scrollBarWidth());
innerSize.setHeight(innerSizeHint.height());
}
@ -89,10 +91,12 @@ private:
QSize minimumSizeHint() const final
{
QWidget *inner = widget();
if (inner) {
int fw = frameWidth() * 2;
if (inner)
{
int fw = frameWidth() * 2;
QSize minSize = inner->minimumSizeHint();
minSize += QSize(fw, fw);
minSize += QSize(scrollBarWidth(), 0);
minSize.setWidth(qMin(minSize.width(), MAX_MIN_WIDTH));
@ -124,20 +128,21 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) :
,m_optionsList(new QListWidget(this))
,m_optionsStack(new QStackedLayout)
{
QGridLayout *layout = new QGridLayout(this);
QLabel *m_headerLabel = new QLabel(this);
// Header label with large font and a bit of spacing (align with group boxes)
QFont headerLabelFont = m_headerLabel->font();
const int pointSize = headerLabelFont.pointSize();
QHBoxLayout *headerHLayout = new QHBoxLayout;
const int leftMargin = QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
int width;
QGridLayout *layout = new QGridLayout(this);
QLabel *m_headerLabel = new QLabel(this);
/* Header label with large font and a bit of spacing
* (align with group boxes) */
QFont headerLabelFont = m_headerLabel->font();
const int pointSize = headerLabelFont.pointSize();
QHBoxLayout *headerHLayout = new QHBoxLayout;
const int leftMargin = QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
m_optionsStack->setMargin(0);
headerLabelFont.setBold(true);
// Paranoia: Should a font be set in pixels...
/* Paranoia: Should a font be set in pixels... */
if (pointSize > 0)
headerLabelFont.setPointSize(pointSize + 2);
@ -216,12 +221,10 @@ void ViewOptionsDialog::addCategory(OptionsCategory *category)
void ViewOptionsDialog::repaintIcons()
{
int i;
unsigned i;
for (i = 0; i < m_categoryList.size(); i++)
{
m_optionsList->item(i)->setIcon(getIcon(m_categoryList.at(i)));
}
}
#else
@ -230,7 +233,7 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) :
QDialog(mainwindow)
, m_viewOptionsWidget(new ViewOptionsWidget(mainwindow))
{
QVBoxLayout *layout = new QVBoxLayout;
QVBoxLayout *layout = new QVBoxLayout;
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
@ -256,11 +259,9 @@ void ViewOptionsDialog::showDialog()
#ifndef HAVE_MENU
m_viewOptionsWidget->loadViewOptions();
#else
int i;
unsigned i;
for (i = 0; i < m_categoryList.size(); i++)
{
m_categoryList.at(i)->load();
}
#endif
show();
activateWindow();
@ -277,9 +278,7 @@ void ViewOptionsDialog::onRejected()
int i;
for (i = 0; i < m_categoryList.size(); i++)
{
m_categoryList.at(i)->apply();
}
#endif
}
@ -395,13 +394,13 @@ void ViewOptionsWidget::onHighlightColorChoose()
void ViewOptionsWidget::loadViewOptions()
{
int i;
int themeIndex = 0;
int playlistIndex = 0;
QColor highlightColor = m_settings->value("highlight_color", QApplication::palette().highlight().color()).value<QColor>();
QPixmap highlightPixmap(m_highlightColorPushButton->iconSize());
QVector<QPair<QString, QString> > playlists = m_mainwindow->getPlaylists();
QString initialPlaylist = m_settings->value("initial_playlist", m_mainwindow->getSpecialPlaylistPath(SPECIAL_PLAYLIST_HISTORY)).toString();
int themeIndex = 0;
int playlistIndex = 0;
int i;
m_saveGeometryCheckBox->setChecked(m_settings->value("save_geometry", false).toBool());
m_saveDockPositionsCheckBox->setChecked(m_settings->value("save_dock_positions", false).toBool());