mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 13:20:30 +00:00
Qt: split functions into separate files
This commit is contained in:
parent
6ef3567ea5
commit
648705154e
@ -339,11 +339,23 @@ OBJ += ui/drivers/ui_qt.o \
|
||||
ui/drivers/qt/ui_qt_browser_window.o \
|
||||
ui/drivers/qt/ui_qt_load_core_window.o \
|
||||
ui/drivers/qt/ui_qt_msg_window.o \
|
||||
ui/drivers/qt/flowlayout.o
|
||||
ui/drivers/qt/flowlayout.o \
|
||||
ui/drivers/qt/shaderparamsdialog.o \
|
||||
ui/drivers/qt/filedropwidget.o \
|
||||
ui/drivers/qt/coreinfodialog.o \
|
||||
ui/drivers/qt/playlistentrydialog.o \
|
||||
ui/drivers/qt/viewoptionsdialog.o \
|
||||
ui/drivers/qt/playlist.o \
|
||||
ui/drivers/qt/updateretroarch.o
|
||||
|
||||
MOC_HEADERS += ui/drivers/ui_qt.h \
|
||||
ui/drivers/qt/ui_qt_load_core_window.h \
|
||||
ui/drivers/qt/flowlayout.h
|
||||
ui/drivers/qt/flowlayout.h \
|
||||
ui/drivers/qt/shaderparamsdialog.h \
|
||||
ui/drivers/qt/filedropwidget.h \
|
||||
ui/drivers/qt/coreinfodialog.h \
|
||||
ui/drivers/qt/playlistentrydialog.h \
|
||||
ui/drivers/qt/viewoptionsdialog.h
|
||||
|
||||
DEFINES += $(QT5CORE_CFLAGS) $(QT5GUI_CFLAGS) $(QT5WIDGETS_CFLAGS) $(QT5CONCURRENT_CFLAGS) $(QT5NETWORK_CFLAGS) -DHAVE_MAIN
|
||||
#DEFINES += $(QT5WEBENGINE_CFLAGS)
|
||||
|
@ -42,6 +42,13 @@ UI
|
||||
#include "../ui/drivers/qt/ui_qt_msg_window.cpp"
|
||||
#include "../ui/drivers/qt/ui_qt_application.cpp"
|
||||
#include "../ui/drivers/qt/flowlayout.cpp"
|
||||
#include "../ui/drivers/qt/shaderparamsdialog.cpp"
|
||||
#include "../ui/drivers/qt/filedropwidget.cpp"
|
||||
#include "../ui/drivers/qt/coreinfodialog.cpp"
|
||||
#include "../ui/drivers/qt/playlistentrydialog.cpp"
|
||||
#include "../ui/drivers/qt/viewoptionsdialog.cpp"
|
||||
#include "../ui/drivers/qt/playlist.cpp"
|
||||
#include "../ui/drivers/qt/updateretroarch.cpp"
|
||||
#endif
|
||||
|
||||
/*============================================================
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include <retro_common_api.h>
|
||||
#include <lists/file_list.h>
|
||||
|
||||
#include "../setting_list.h"
|
||||
|
||||
#ifndef COLLECTION_SIZE
|
||||
#define COLLECTION_SIZE 99999
|
||||
#endif
|
||||
|
96
ui/drivers/qt/coreinfodialog.cpp
Normal file
96
ui/drivers/qt/coreinfodialog.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
#include <QMainWindow>
|
||||
#include <QFormLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QLabel>
|
||||
#include "coreinfodialog.h"
|
||||
#include "../ui_qt.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../msg_hash.h"
|
||||
}
|
||||
|
||||
CoreInfoDialog::CoreInfoDialog(MainWindow *mainwindow, QWidget *parent) :
|
||||
QDialog(parent)
|
||||
,m_formLayout(new QFormLayout())
|
||||
,m_mainwindow(mainwindow)
|
||||
{
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||
|
||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
|
||||
setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFORMATION));
|
||||
|
||||
m_formLayout->setFormAlignment(Qt::AlignCenter);
|
||||
m_formLayout->setLabelAlignment(Qt::AlignCenter);
|
||||
|
||||
setLayout(new QVBoxLayout());
|
||||
|
||||
qobject_cast<QVBoxLayout*>(layout())->addLayout(m_formLayout);
|
||||
layout()->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||
layout()->addWidget(buttonBox);
|
||||
}
|
||||
|
||||
void CoreInfoDialog::showCoreInfo()
|
||||
{
|
||||
int row = 0;
|
||||
int rowCount = m_formLayout->rowCount();
|
||||
int i = 0;
|
||||
QVector<QHash<QString, QString> > infoList = m_mainwindow->getCoreInfo();
|
||||
|
||||
if (rowCount > 0)
|
||||
{
|
||||
for (row = 0; row < rowCount; 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 */
|
||||
QLayoutItem *item = m_formLayout->itemAt(0);
|
||||
QWidget *w = NULL;
|
||||
|
||||
if (item)
|
||||
{
|
||||
w = item->widget();
|
||||
|
||||
if (w)
|
||||
{
|
||||
QWidget *label = m_formLayout->labelForField(w);
|
||||
|
||||
if (label)
|
||||
delete label;
|
||||
|
||||
m_formLayout->removeWidget(w);
|
||||
|
||||
delete w;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (infoList.count() == 0)
|
||||
return;
|
||||
|
||||
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");
|
||||
|
||||
if (!labelStyle.isEmpty())
|
||||
label->setStyleSheet(labelStyle);
|
||||
|
||||
if (!valueStyle.isEmpty())
|
||||
value->setStyleSheet(valueStyle);
|
||||
|
||||
m_formLayout->addRow(label, value);
|
||||
}
|
||||
|
||||
show();
|
||||
}
|
||||
|
21
ui/drivers/qt/coreinfodialog.h
Normal file
21
ui/drivers/qt/coreinfodialog.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef COREINFODIALOG_H
|
||||
#define COREINFODIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class QFormLayout;
|
||||
class MainWindow;
|
||||
|
||||
class CoreInfoDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CoreInfoDialog(MainWindow *mainwindow, QWidget *parent = 0);
|
||||
public slots:
|
||||
void showCoreInfo();
|
||||
private:
|
||||
QFormLayout *m_formLayout;
|
||||
MainWindow *m_mainwindow;
|
||||
};
|
||||
|
||||
#endif
|
69
ui/drivers/qt/filedropwidget.cpp
Normal file
69
ui/drivers/qt/filedropwidget.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
#include <QDragEnterEvent>
|
||||
#include <QDropEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QPaintEvent>
|
||||
#include <QStyle>
|
||||
#include <QStyleOption>
|
||||
#include <QMimeData>
|
||||
#include <QPainter>
|
||||
#include "filedropwidget.h"
|
||||
|
||||
FileDropWidget::FileDropWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
setAcceptDrops(true);
|
||||
}
|
||||
|
||||
void FileDropWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QStyleOption o;
|
||||
QPainter p;
|
||||
o.initFrom(this);
|
||||
p.begin(this);
|
||||
style()->drawPrimitive(
|
||||
QStyle::PE_Widget, &o, &p, this);
|
||||
p.end();
|
||||
|
||||
QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
void FileDropWidget::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Delete)
|
||||
{
|
||||
event->accept();
|
||||
emit deletePressed();
|
||||
}
|
||||
else
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void FileDropWidget::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
const QMimeData *data = event->mimeData();
|
||||
|
||||
if (data->hasUrls())
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
|
||||
void FileDropWidget::dropEvent(QDropEvent *event)
|
||||
{
|
||||
const QMimeData *data = event->mimeData();
|
||||
|
||||
if (data->hasUrls())
|
||||
{
|
||||
QList<QUrl> urls = data->urls();
|
||||
QStringList files;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < urls.count(); i++)
|
||||
{
|
||||
QString path(urls.at(i).toLocalFile());
|
||||
|
||||
files.append(path);
|
||||
}
|
||||
|
||||
emit filesDropped(files);
|
||||
}
|
||||
}
|
||||
|
26
ui/drivers/qt/filedropwidget.h
Normal file
26
ui/drivers/qt/filedropwidget.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef FILEDROPWIDGET_H
|
||||
#define FILEDROPWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QDragEnterEvent;
|
||||
class QDropEvent;
|
||||
class QKeyEvent;
|
||||
class QPaintEvent;
|
||||
|
||||
class FileDropWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FileDropWidget(QWidget *parent = 0);
|
||||
signals:
|
||||
void filesDropped(QStringList files);
|
||||
void deletePressed();
|
||||
protected:
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dropEvent(QDropEvent *event);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
};
|
||||
|
||||
#endif
|
1149
ui/drivers/qt/playlist.cpp
Normal file
1149
ui/drivers/qt/playlist.cpp
Normal file
File diff suppressed because it is too large
Load Diff
259
ui/drivers/qt/playlistentrydialog.cpp
Normal file
259
ui/drivers/qt/playlistentrydialog.cpp
Normal file
@ -0,0 +1,259 @@
|
||||
#include <QSettings>
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
#include <QFormLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QToolButton>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "playlistentrydialog.h"
|
||||
#include "../ui_qt.h"
|
||||
|
||||
extern "C" {
|
||||
#include "../../../core_info.h"
|
||||
#include "../../../file_path_special.h"
|
||||
}
|
||||
|
||||
inline static bool comp_string_lower(const QString &lhs, const QString &rhs)
|
||||
{
|
||||
return lhs.toLower() < rhs.toLower();
|
||||
}
|
||||
|
||||
inline static bool comp_hash_ui_display_name_key_lower(const QHash<QString, QString> &lhs, const QHash<QString, QString> &rhs)
|
||||
{
|
||||
return lhs.value("ui_display_name").toLower() < rhs.value("ui_display_name").toLower();
|
||||
}
|
||||
|
||||
PlaylistEntryDialog::PlaylistEntryDialog(MainWindow *mainwindow, QWidget *parent) :
|
||||
QDialog(parent)
|
||||
,m_mainwindow(mainwindow)
|
||||
,m_settings(mainwindow->settings())
|
||||
,m_nameLineEdit(new QLineEdit(this))
|
||||
,m_pathLineEdit(new QLineEdit(this))
|
||||
,m_coreComboBox(new QComboBox(this))
|
||||
,m_databaseComboBox(new QComboBox(this))
|
||||
{
|
||||
QFormLayout *form = new QFormLayout();
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
QVBoxLayout *databaseVBoxLayout = new QVBoxLayout();
|
||||
QHBoxLayout *pathHBoxLayout = new QHBoxLayout();
|
||||
QLabel *databaseLabel = new QLabel(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_FOR_THUMBNAILS), this);
|
||||
QToolButton *pathPushButton = new QToolButton(this);
|
||||
|
||||
pathPushButton->setText("...");
|
||||
|
||||
pathHBoxLayout->addWidget(m_pathLineEdit);
|
||||
pathHBoxLayout->addWidget(pathPushButton);
|
||||
|
||||
databaseVBoxLayout->addWidget(m_databaseComboBox);
|
||||
databaseVBoxLayout->addWidget(databaseLabel);
|
||||
|
||||
setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_PLAYLIST_ENTRY));
|
||||
|
||||
form->setFormAlignment(Qt::AlignCenter);
|
||||
form->setLabelAlignment(Qt::AlignCenter);
|
||||
|
||||
setLayout(new QVBoxLayout(this));
|
||||
|
||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
|
||||
connect(this, SIGNAL(accepted()), this, SLOT(onAccepted()));
|
||||
connect(this, SIGNAL(rejected()), this, SLOT(onRejected()));
|
||||
|
||||
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_PLAYLIST_ENTRY_NAME), m_nameLineEdit);
|
||||
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_PLAYLIST_ENTRY_PATH), pathHBoxLayout);
|
||||
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_PLAYLIST_ENTRY_CORE), m_coreComboBox);
|
||||
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_PLAYLIST_ENTRY_DATABASE), databaseVBoxLayout);
|
||||
|
||||
qobject_cast<QVBoxLayout*>(layout())->addLayout(form);
|
||||
layout()->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||
layout()->addWidget(buttonBox);
|
||||
|
||||
connect(pathPushButton, SIGNAL(clicked()), this, SLOT(onPathClicked()));
|
||||
}
|
||||
|
||||
void PlaylistEntryDialog::onPathClicked()
|
||||
{
|
||||
QString filePath = QFileDialog::getOpenFileName(this);
|
||||
|
||||
if (filePath.isEmpty())
|
||||
return;
|
||||
|
||||
m_pathLineEdit->setText(filePath);
|
||||
}
|
||||
|
||||
void PlaylistEntryDialog::loadPlaylistOptions()
|
||||
{
|
||||
core_info_list_t *core_info_list = NULL;
|
||||
const core_info_t *core_info = NULL;
|
||||
unsigned i = 0;
|
||||
int j = 0;
|
||||
|
||||
m_nameLineEdit->clear();
|
||||
m_pathLineEdit->clear();
|
||||
m_coreComboBox->clear();
|
||||
m_databaseComboBox->clear();
|
||||
|
||||
m_coreComboBox->addItem(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE_SELECTION_ASK));
|
||||
m_databaseComboBox->addItem(QString("<") + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE) + ">", QFileInfo(m_mainwindow->getCurrentPlaylistPath()).fileName().remove(file_path_str(FILE_PATH_LPL_EXTENSION)));
|
||||
|
||||
core_info_get_list(&core_info_list);
|
||||
|
||||
if (core_info_list && core_info_list->count > 0)
|
||||
{
|
||||
QVector<QHash<QString, QString> > allCores;
|
||||
QStringList allDatabases;
|
||||
|
||||
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;
|
||||
|
||||
hash["core_name"] = core->core_name;
|
||||
hash["core_display_name"] = core->display_name;
|
||||
hash["core_path"] = core->path;
|
||||
hash["core_databases"] = core->databases;
|
||||
|
||||
ui_display_name = hash.value("core_name");
|
||||
|
||||
if (ui_display_name.isEmpty())
|
||||
ui_display_name = hash.value("core_display_name");
|
||||
if (ui_display_name.isEmpty())
|
||||
ui_display_name = QFileInfo(hash.value("core_path")).fileName();
|
||||
if (ui_display_name.isEmpty())
|
||||
continue;
|
||||
|
||||
hash["ui_display_name"] = ui_display_name;
|
||||
|
||||
for (j = 0; j < databases.count(); j++)
|
||||
{
|
||||
QString database = databases.at(j);
|
||||
|
||||
if (database.isEmpty())
|
||||
continue;
|
||||
|
||||
if (!allDatabases.contains(database))
|
||||
allDatabases.append(database);
|
||||
}
|
||||
|
||||
if (!allCores.contains(hash))
|
||||
allCores.append(hash);
|
||||
}
|
||||
|
||||
std::sort(allCores.begin(), allCores.end(), comp_hash_ui_display_name_key_lower);
|
||||
std::sort(allDatabases.begin(), allDatabases.end(), comp_string_lower);
|
||||
|
||||
for (j = 0; j < allCores.count(); j++)
|
||||
{
|
||||
const QHash<QString, QString> &hash = allCores.at(j);
|
||||
|
||||
m_coreComboBox->addItem(hash.value("ui_display_name"), QVariant::fromValue(hash));
|
||||
}
|
||||
|
||||
for (j = 0; j < allDatabases.count(); j++)
|
||||
{
|
||||
QString database = allDatabases.at(j);
|
||||
m_databaseComboBox->addItem(database, database);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PlaylistEntryDialog::setEntryValues(const QHash<QString, QString> &contentHash)
|
||||
{
|
||||
QString db;
|
||||
QString coreName = contentHash.value("core_name");
|
||||
int foundDB = 0;
|
||||
int i = 0;
|
||||
|
||||
loadPlaylistOptions();
|
||||
|
||||
if (contentHash.isEmpty())
|
||||
{
|
||||
m_nameLineEdit->setText(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_FIELD_MULTIPLE));
|
||||
m_pathLineEdit->setText(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_FIELD_MULTIPLE));
|
||||
m_nameLineEdit->setEnabled(false);
|
||||
m_pathLineEdit->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nameLineEdit->setEnabled(true);
|
||||
m_pathLineEdit->setEnabled(true);
|
||||
m_nameLineEdit->setText(contentHash.value("label"));
|
||||
m_pathLineEdit->setText(contentHash.value("path"));
|
||||
}
|
||||
|
||||
for (i = 0; i < m_coreComboBox->count(); i++)
|
||||
{
|
||||
const QHash<QString, QString> hash = m_coreComboBox->itemData(i, Qt::UserRole).value<QHash<QString, QString> >();
|
||||
|
||||
if (hash.isEmpty() || coreName.isEmpty())
|
||||
continue;
|
||||
|
||||
if (hash.value("core_name") == coreName)
|
||||
{
|
||||
m_coreComboBox->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
db = contentHash.value("db_name");
|
||||
|
||||
if (!db.isEmpty())
|
||||
{
|
||||
foundDB = m_databaseComboBox->findText(db);
|
||||
|
||||
if (foundDB >= 0)
|
||||
m_databaseComboBox->setCurrentIndex(foundDB);
|
||||
}
|
||||
}
|
||||
|
||||
const QHash<QString, QString> PlaylistEntryDialog::getSelectedCore()
|
||||
{
|
||||
return m_coreComboBox->currentData(Qt::UserRole).value<QHash<QString, QString> >();
|
||||
}
|
||||
|
||||
const QString PlaylistEntryDialog::getSelectedName()
|
||||
{
|
||||
return m_nameLineEdit->text();
|
||||
}
|
||||
|
||||
const QString PlaylistEntryDialog::getSelectedPath()
|
||||
{
|
||||
return m_pathLineEdit->text();
|
||||
}
|
||||
|
||||
const QString PlaylistEntryDialog::getSelectedDatabase()
|
||||
{
|
||||
return m_databaseComboBox->currentData(Qt::UserRole).toString();
|
||||
}
|
||||
|
||||
void PlaylistEntryDialog::onAccepted()
|
||||
{
|
||||
}
|
||||
|
||||
void PlaylistEntryDialog::onRejected()
|
||||
{
|
||||
}
|
||||
|
||||
bool PlaylistEntryDialog::showDialog(const QHash<QString, QString> &hash)
|
||||
{
|
||||
loadPlaylistOptions();
|
||||
setEntryValues(hash);
|
||||
|
||||
if (exec() == QDialog::Accepted)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void PlaylistEntryDialog::hideDialog()
|
||||
{
|
||||
reject();
|
||||
}
|
||||
|
39
ui/drivers/qt/playlistentrydialog.h
Normal file
39
ui/drivers/qt/playlistentrydialog.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef PLAYLISTENTRYDIALOG_H
|
||||
#define PLAYLISTENTRYDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class QSettings;
|
||||
class QLineEdit;
|
||||
class QComboBox;
|
||||
class MainWindow;
|
||||
|
||||
class PlaylistEntryDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PlaylistEntryDialog(MainWindow *mainwindow, QWidget *parent = 0);
|
||||
const QHash<QString, QString> getSelectedCore();
|
||||
const QString getSelectedDatabase();
|
||||
const QString getSelectedName();
|
||||
const QString getSelectedPath();
|
||||
void setEntryValues(const QHash<QString, QString> &contentHash);
|
||||
public slots:
|
||||
bool showDialog(const QHash<QString, QString> &hash = QHash<QString, QString>());
|
||||
void hideDialog();
|
||||
void onAccepted();
|
||||
void onRejected();
|
||||
private slots:
|
||||
void onPathClicked();
|
||||
private:
|
||||
void loadPlaylistOptions();
|
||||
|
||||
MainWindow *m_mainwindow;
|
||||
QSettings *m_settings;
|
||||
QLineEdit *m_nameLineEdit;
|
||||
QLineEdit *m_pathLineEdit;
|
||||
QComboBox *m_coreComboBox;
|
||||
QComboBox *m_databaseComboBox;
|
||||
};
|
||||
|
||||
#endif
|
27
ui/drivers/qt/shaderparamsdialog.cpp
Normal file
27
ui/drivers/qt/shaderparamsdialog.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include <QCloseEvent>
|
||||
#include <QResizeEvent>
|
||||
#include "shaderparamsdialog.h"
|
||||
|
||||
ShaderParamsDialog::ShaderParamsDialog(QWidget *parent) :
|
||||
QDialog(parent)
|
||||
{
|
||||
}
|
||||
|
||||
ShaderParamsDialog::~ShaderParamsDialog()
|
||||
{
|
||||
}
|
||||
|
||||
void ShaderParamsDialog::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QDialog::resizeEvent(event);
|
||||
|
||||
emit resized(event->size());
|
||||
}
|
||||
|
||||
void ShaderParamsDialog::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
QDialog::closeEvent(event);
|
||||
|
||||
emit closed();
|
||||
}
|
||||
|
23
ui/drivers/qt/shaderparamsdialog.h
Normal file
23
ui/drivers/qt/shaderparamsdialog.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef SHADERPARAMSDIALOG_H
|
||||
#define SHADERPARAMSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class QCloseEvent;
|
||||
class QResizeEvent;
|
||||
|
||||
class ShaderParamsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ShaderParamsDialog(QWidget *parent = 0);
|
||||
~ShaderParamsDialog();
|
||||
signals:
|
||||
void closed();
|
||||
void resized(QSize size);
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
};
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
355
ui/drivers/qt/updateretroarch.cpp
Normal file
355
ui/drivers/qt/updateretroarch.cpp
Normal file
@ -0,0 +1,355 @@
|
||||
#include <QDir>
|
||||
#include <QApplication>
|
||||
#include <QProgressDialog>
|
||||
|
||||
#include "../ui_qt.h"
|
||||
|
||||
extern "C" {
|
||||
#include <string/stdstring.h>
|
||||
#include <streams/file_stream.h>
|
||||
#include <file/archive_file.h>
|
||||
#include "../../../tasks/tasks_internal.h"
|
||||
#include "../../../verbosity.h"
|
||||
#include "../../../config.def.h"
|
||||
}
|
||||
|
||||
#define USER_AGENT "RetroArch-WIMP/1.0"
|
||||
#define PARTIAL_EXTENSION ".partial"
|
||||
#define TEMP_EXTENSION ".update_tmp"
|
||||
#define RETROARCH_NIGHTLY_UPDATE_PATH "../RetroArch_update.zip"
|
||||
|
||||
static void extractCB(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;
|
||||
|
||||
if (err)
|
||||
RARCH_ERR("%s", err);
|
||||
|
||||
if (dec)
|
||||
{
|
||||
if (filestream_exists(dec->source_file))
|
||||
filestream_delete(dec->source_file);
|
||||
|
||||
free(dec->source_file);
|
||||
free(dec);
|
||||
}
|
||||
|
||||
mainwindow->onUpdateRetroArchFinished(string_is_empty(err));
|
||||
}
|
||||
|
||||
void MainWindow::removeUpdateTempFiles()
|
||||
{
|
||||
/* a QDir with no path means the current working directory */
|
||||
QDir dir;
|
||||
QStringList dirList = dir.entryList(QStringList(), QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System, QDir::Name);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < dirList.count(); i++)
|
||||
{
|
||||
QString path(dir.path() + "/" + dirList.at(i));
|
||||
QFile file(path);
|
||||
|
||||
if (path.endsWith(TEMP_EXTENSION))
|
||||
{
|
||||
QByteArray pathArray = path.toUtf8();
|
||||
const char *pathData = pathArray.constData();
|
||||
|
||||
if (file.remove())
|
||||
RARCH_LOG("[Qt]: removed temporary update file %s\n", pathData);
|
||||
else
|
||||
RARCH_LOG("[Qt]: could not remove temporary update file %s\n", pathData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onUpdateNetworkError(QNetworkReply::NetworkError code)
|
||||
{
|
||||
QNetworkReply *reply = m_updateReply.data();
|
||||
QByteArray errorStringArray;
|
||||
const char *errorStringData = NULL;
|
||||
|
||||
m_updateProgressDialog->cancel();
|
||||
|
||||
if (!reply)
|
||||
return;
|
||||
|
||||
errorStringArray = reply->errorString().toUtf8();
|
||||
errorStringData = errorStringArray.constData();
|
||||
|
||||
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. */
|
||||
/*
|
||||
reply->disconnect();
|
||||
reply->abort();
|
||||
reply->deleteLater();
|
||||
*/
|
||||
}
|
||||
|
||||
void MainWindow::onUpdateNetworkSslErrors(const QList<QSslError> &errors)
|
||||
{
|
||||
QNetworkReply *reply = m_updateReply.data();
|
||||
int i;
|
||||
|
||||
if (!reply)
|
||||
return;
|
||||
|
||||
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();
|
||||
QByteArray stringArray = string.toUtf8();
|
||||
const char *stringData = stringArray.constData();
|
||||
RARCH_ERR("[Qt]: %s\n", stringData);
|
||||
}
|
||||
|
||||
/* ignore all SSL errors for now, like self-signed, expired etc. */
|
||||
reply->ignoreSslErrors();
|
||||
}
|
||||
|
||||
void MainWindow::onUpdateDownloadCanceled()
|
||||
{
|
||||
m_updateProgressDialog->cancel();
|
||||
}
|
||||
|
||||
void MainWindow::onRetroArchUpdateDownloadFinished()
|
||||
{
|
||||
QNetworkReply *reply = m_updateReply.data();
|
||||
QNetworkReply::NetworkError error;
|
||||
int code;
|
||||
|
||||
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. */
|
||||
qApp->processEvents();
|
||||
|
||||
if (!reply)
|
||||
return;
|
||||
|
||||
error = reply->error();
|
||||
code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
|
||||
if (m_updateFile.isOpen())
|
||||
m_updateFile.close();
|
||||
|
||||
if (code != 200)
|
||||
{
|
||||
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();
|
||||
reply->deleteLater();
|
||||
return;
|
||||
}
|
||||
|
||||
if (error == QNetworkReply::NoError)
|
||||
{
|
||||
int index = m_updateFile.fileName().lastIndexOf(PARTIAL_EXTENSION);
|
||||
QString newFileName = m_updateFile.fileName().left(index);
|
||||
QFile newFile(newFileName);
|
||||
|
||||
/* rename() requires the old file to be deleted first if it exists */
|
||||
if (newFile.exists() && !newFile.remove())
|
||||
RARCH_ERR("[Qt]: RetroArch update finished, but old file could not be deleted.\n");
|
||||
else
|
||||
{
|
||||
if (m_updateFile.rename(newFileName))
|
||||
{
|
||||
RARCH_LOG("[Qt]: RetroArch update finished downloading successfully.\n");
|
||||
emit extractArchiveDeferred(newFileName);
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QByteArray errorArray = reply->errorString().toUtf8();
|
||||
const char *errorData = errorArray.constData();
|
||||
|
||||
RARCH_ERR("[Qt]: RetroArch update ended prematurely: %s\n", errorData);
|
||||
emit showErrorMessageDeferred(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NETWORK_ERROR)) + ": Code " + QString::number(code) + ": " + errorData);
|
||||
}
|
||||
|
||||
reply->disconnect();
|
||||
reply->close();
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
void MainWindow::onUpdateRetroArchFinished(bool success)
|
||||
{
|
||||
m_updateProgressDialog->cancel();
|
||||
|
||||
if (!success)
|
||||
{
|
||||
RARCH_ERR("[Qt]: RetroArch update failed.\n");
|
||||
emit showErrorMessageDeferred(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_UPDATE_RETROARCH_FAILED));
|
||||
return;
|
||||
}
|
||||
|
||||
RARCH_LOG("[Qt]: RetroArch update finished successfully.\n");
|
||||
|
||||
emit showInfoMessageDeferred(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_UPDATE_RETROARCH_FINISHED));
|
||||
}
|
||||
|
||||
int MainWindow::onExtractArchive(QString path)
|
||||
{
|
||||
QByteArray pathArray = path.toUtf8();
|
||||
const char *file = pathArray.constData();
|
||||
file_archive_transfer_t state;
|
||||
struct archive_extract_userdata userdata;
|
||||
struct string_list *file_list = file_archive_get_file_list(file, NULL);
|
||||
bool returnerr = true;
|
||||
unsigned i;
|
||||
|
||||
if (!file_list || file_list->size == 0)
|
||||
{
|
||||
showMessageBox("Error: Archive is empty.", MainWindow::MSGBOX_TYPE_ERROR, Qt::ApplicationModal, false);
|
||||
RARCH_ERR("[Qt]: Downloaded archive is empty?\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < file_list->size; i++)
|
||||
{
|
||||
QFile fileObj(file_list->elems[i].data);
|
||||
|
||||
if (fileObj.exists())
|
||||
{
|
||||
if (!fileObj.remove())
|
||||
{
|
||||
/* if we cannot delete the existing file to update it, rename it for now and delete later */
|
||||
QFile fileTemp(fileObj.fileName() + TEMP_EXTENSION);
|
||||
|
||||
if (fileTemp.exists())
|
||||
{
|
||||
if (!fileTemp.remove())
|
||||
{
|
||||
showMessageBox(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_COULD_NOT_DELETE_FILE), MainWindow::MSGBOX_TYPE_ERROR, Qt::ApplicationModal, false);
|
||||
RARCH_ERR("[Qt]: Could not delete file: %s\n", file_list->elems[i].data);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fileObj.rename(fileTemp.fileName()))
|
||||
{
|
||||
showMessageBox(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_COULD_NOT_RENAME_FILE), MainWindow::MSGBOX_TYPE_ERROR, Qt::ApplicationModal, false);
|
||||
RARCH_ERR("[Qt]: Could not rename file: %s\n", file_list->elems[i].data);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string_list_free(file_list);
|
||||
|
||||
memset(&state, 0, sizeof(state));
|
||||
memset(&userdata, 0, sizeof(userdata));
|
||||
|
||||
state.type = ARCHIVE_TRANSFER_INIT;
|
||||
|
||||
m_updateProgressDialog->setWindowModality(Qt::NonModal);
|
||||
m_updateProgressDialog->setMinimumDuration(0);
|
||||
m_updateProgressDialog->setRange(0, 0);
|
||||
m_updateProgressDialog->setAutoClose(true);
|
||||
m_updateProgressDialog->setAutoReset(true);
|
||||
m_updateProgressDialog->setValue(0);
|
||||
m_updateProgressDialog->setLabelText(QString(msg_hash_to_str(MSG_EXTRACTING)) + "...");
|
||||
m_updateProgressDialog->setCancelButtonText(QString());
|
||||
m_updateProgressDialog->show();
|
||||
|
||||
if (!task_push_decompress(file, ".",
|
||||
NULL, NULL, NULL,
|
||||
extractCB, this))
|
||||
{
|
||||
m_updateProgressDialog->cancel();
|
||||
return -1;
|
||||
}
|
||||
|
||||
return returnerr;
|
||||
}
|
||||
|
||||
void MainWindow::onUpdateDownloadProgress(qint64 bytesReceived, qint64 bytesTotal)
|
||||
{
|
||||
QNetworkReply *reply = m_updateReply.data();
|
||||
int progress = (bytesReceived / (float)bytesTotal) * 100.0f;
|
||||
|
||||
if (!reply)
|
||||
return;
|
||||
|
||||
m_updateProgressDialog->setValue(progress);
|
||||
}
|
||||
|
||||
void MainWindow::onUpdateDownloadReadyRead()
|
||||
{
|
||||
QNetworkReply *reply = m_updateReply.data();
|
||||
|
||||
if (!reply)
|
||||
return;
|
||||
|
||||
m_updateFile.write(reply->readAll());
|
||||
}
|
||||
|
||||
void MainWindow::updateRetroArchNightly()
|
||||
{
|
||||
QUrl url(QUrl(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();
|
||||
|
||||
if (m_updateFile.isOpen())
|
||||
{
|
||||
RARCH_ERR("[Qt]: File is already open.\n");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
QString fileName = QFileInfo(url.toString()).fileName() + PARTIAL_EXTENSION;
|
||||
QByteArray fileNameArray = fileName.toUtf8();
|
||||
const char *fileNameData = fileNameArray.constData();
|
||||
|
||||
m_updateFile.setFileName(fileName);
|
||||
|
||||
if (!m_updateFile.open(QIODevice::WriteOnly))
|
||||
{
|
||||
showMessageBox(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_FILE_WRITE_OPEN_FAILED), MainWindow::MSGBOX_TYPE_ERROR, Qt::ApplicationModal, false);
|
||||
RARCH_ERR("[Qt]: Could not open file for writing: %s\n", fileNameData);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
RARCH_LOG("[Qt]: Starting update of RetroArch...\n");
|
||||
RARCH_LOG("[Qt]: Downloading URL %s\n", urlData);
|
||||
|
||||
request.setHeader(QNetworkRequest::UserAgentHeader, USER_AGENT);
|
||||
|
||||
m_updateProgressDialog->setWindowModality(Qt::NonModal);
|
||||
m_updateProgressDialog->setMinimumDuration(0);
|
||||
m_updateProgressDialog->setRange(0, 100);
|
||||
m_updateProgressDialog->setAutoClose(true);
|
||||
m_updateProgressDialog->setAutoReset(true);
|
||||
m_updateProgressDialog->setValue(0);
|
||||
m_updateProgressDialog->setLabelText(QString(msg_hash_to_str(MSG_DOWNLOADING)) + "...");
|
||||
m_updateProgressDialog->setCancelButtonText(tr("Cancel"));
|
||||
m_updateProgressDialog->show();
|
||||
|
||||
m_updateReply = m_networkManager->get(request);
|
||||
reply = m_updateReply.data();
|
||||
|
||||
/* make sure any previous connection is removed first */
|
||||
disconnect(m_updateProgressDialog, SIGNAL(canceled()), reply, SLOT(abort()));
|
||||
disconnect(m_updateProgressDialog, SIGNAL(canceled()), m_updateProgressDialog, SLOT(cancel()));
|
||||
connect(m_updateProgressDialog, SIGNAL(canceled()), reply, SLOT(abort()));
|
||||
connect(m_updateProgressDialog, SIGNAL(canceled()), m_updateProgressDialog, SLOT(cancel()));
|
||||
|
||||
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onUpdateNetworkError(QNetworkReply::NetworkError)));
|
||||
connect(reply, SIGNAL(sslErrors(const QList<QSslError>&)), this, SLOT(onUpdateNetworkSslErrors(const QList<QSslError>&)));
|
||||
connect(reply, SIGNAL(finished()), this, SLOT(onRetroArchUpdateDownloadFinished()));
|
||||
connect(reply, SIGNAL(readyRead()), this, SLOT(onUpdateDownloadReadyRead()));
|
||||
connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(onUpdateDownloadProgress(qint64, qint64)));
|
||||
|
||||
}
|
218
ui/drivers/qt/viewoptionsdialog.cpp
Normal file
218
ui/drivers/qt/viewoptionsdialog.cpp
Normal file
@ -0,0 +1,218 @@
|
||||
#include <QSettings>
|
||||
#include <QComboBox>
|
||||
#include <QCheckBox>
|
||||
#include <QPushButton>
|
||||
#include <QColor>
|
||||
#include <QLabel>
|
||||
#include <QSpinBox>
|
||||
#include <QFormLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QFileDialog>
|
||||
#include <QApplication>
|
||||
#include <QColorDialog>
|
||||
|
||||
#include "viewoptionsdialog.h"
|
||||
#include "../ui_qt.h"
|
||||
|
||||
extern "C" {
|
||||
#include "../../../msg_hash.h"
|
||||
}
|
||||
|
||||
ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) :
|
||||
QDialog(parent)
|
||||
,m_mainwindow(mainwindow)
|
||||
,m_settings(mainwindow->settings())
|
||||
,m_saveGeometryCheckBox(new QCheckBox(this))
|
||||
,m_saveDockPositionsCheckBox(new QCheckBox(this))
|
||||
,m_saveLastTabCheckBox(new QCheckBox(this))
|
||||
,m_showHiddenFilesCheckBox(new QCheckBox(this))
|
||||
,m_themeComboBox(new QComboBox(this))
|
||||
,m_highlightColorPushButton(new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CHOOSE), this))
|
||||
,m_highlightColor()
|
||||
,m_highlightColorLabel(new QLabel(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_HIGHLIGHT_COLOR), this))
|
||||
,m_customThemePath()
|
||||
,m_suggestLoadedCoreFirstCheckBox(new QCheckBox(this))
|
||||
,m_allPlaylistsListMaxCountSpinBox(new QSpinBox(this))
|
||||
,m_allPlaylistsGridMaxCountSpinBox(new QSpinBox(this))
|
||||
{
|
||||
QFormLayout *form = new QFormLayout();
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
|
||||
setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_TITLE));
|
||||
|
||||
m_themeComboBox->addItem(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME_SYSTEM_DEFAULT), MainWindow::THEME_SYSTEM_DEFAULT);
|
||||
m_themeComboBox->addItem(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME_DARK), MainWindow::THEME_DARK);
|
||||
m_themeComboBox->addItem(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME_CUSTOM), MainWindow::THEME_CUSTOM);
|
||||
|
||||
m_allPlaylistsListMaxCountSpinBox->setRange(0, 99999);
|
||||
m_allPlaylistsGridMaxCountSpinBox->setRange(0, 99999);
|
||||
|
||||
form->setFormAlignment(Qt::AlignCenter);
|
||||
form->setLabelAlignment(Qt::AlignCenter);
|
||||
|
||||
setLayout(new QVBoxLayout(this));
|
||||
|
||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
|
||||
connect(this, SIGNAL(accepted()), this, SLOT(onAccepted()));
|
||||
connect(this, SIGNAL(rejected()), this, SLOT(onRejected()));
|
||||
|
||||
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_GEOMETRY), m_saveGeometryCheckBox);
|
||||
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_DOCK_POSITIONS), m_saveDockPositionsCheckBox);
|
||||
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);
|
||||
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME), m_themeComboBox);
|
||||
form->addRow(m_highlightColorLabel, m_highlightColorPushButton);
|
||||
|
||||
qobject_cast<QVBoxLayout*>(layout())->addLayout(form);
|
||||
layout()->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||
layout()->addWidget(buttonBox);
|
||||
|
||||
loadViewOptions();
|
||||
|
||||
connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onThemeComboBoxIndexChanged(int)));
|
||||
connect(m_highlightColorPushButton, SIGNAL(clicked()), this, SLOT(onHighlightColorChoose()));
|
||||
}
|
||||
|
||||
void ViewOptionsDialog::onThemeComboBoxIndexChanged(int)
|
||||
{
|
||||
MainWindow::Theme theme = static_cast<MainWindow::Theme>(m_themeComboBox->currentData(Qt::UserRole).toInt());
|
||||
|
||||
if (theme == MainWindow::THEME_CUSTOM)
|
||||
{
|
||||
QString filePath = QFileDialog::getOpenFileName(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SELECT_THEME));
|
||||
|
||||
if (filePath.isEmpty())
|
||||
{
|
||||
int oldThemeIndex = m_themeComboBox->findData(m_mainwindow->getThemeFromString(m_settings->value("theme", "default").toString()));
|
||||
|
||||
if (m_themeComboBox->count() > oldThemeIndex)
|
||||
{
|
||||
disconnect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onThemeComboBoxIndexChanged(int)));
|
||||
m_themeComboBox->setCurrentIndex(oldThemeIndex);
|
||||
connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onThemeComboBoxIndexChanged(int)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_customThemePath = filePath;
|
||||
|
||||
if (m_mainwindow->setCustomThemeFile(filePath))
|
||||
m_mainwindow->setTheme(theme);
|
||||
}
|
||||
}
|
||||
else
|
||||
m_mainwindow->setTheme(theme);
|
||||
|
||||
showOrHideHighlightColor();
|
||||
}
|
||||
|
||||
void ViewOptionsDialog::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));
|
||||
|
||||
if (newHighlightColor.isValid())
|
||||
{
|
||||
MainWindow::Theme theme = static_cast<MainWindow::Theme>(m_themeComboBox->currentData(Qt::UserRole).toInt());
|
||||
|
||||
m_highlightColor = newHighlightColor;
|
||||
m_settings->setValue("highlight_color", m_highlightColor);
|
||||
highlightPixmap.fill(m_highlightColor);
|
||||
m_highlightColorPushButton->setIcon(highlightPixmap);
|
||||
m_mainwindow->setTheme(theme);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewOptionsDialog::loadViewOptions()
|
||||
{
|
||||
QColor highlightColor = m_settings->value("highlight_color", QApplication::palette().highlight().color()).value<QColor>();
|
||||
QPixmap highlightPixmap(m_highlightColorPushButton->iconSize());
|
||||
int themeIndex = 0;
|
||||
|
||||
m_saveGeometryCheckBox->setChecked(m_settings->value("save_geometry", false).toBool());
|
||||
m_saveDockPositionsCheckBox->setChecked(m_settings->value("save_dock_positions", false).toBool());
|
||||
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());
|
||||
|
||||
themeIndex = m_themeComboBox->findData(m_mainwindow->getThemeFromString(m_settings->value("theme", "default").toString()));
|
||||
|
||||
if (m_themeComboBox->count() > themeIndex)
|
||||
m_themeComboBox->setCurrentIndex(themeIndex);
|
||||
|
||||
if (highlightColor.isValid())
|
||||
{
|
||||
m_highlightColor = highlightColor;
|
||||
highlightPixmap.fill(m_highlightColor);
|
||||
m_highlightColorPushButton->setIcon(highlightPixmap);
|
||||
}
|
||||
|
||||
showOrHideHighlightColor();
|
||||
}
|
||||
|
||||
void ViewOptionsDialog::showOrHideHighlightColor()
|
||||
{
|
||||
if (m_mainwindow->theme() == MainWindow::THEME_DARK)
|
||||
{
|
||||
m_highlightColorLabel->show();
|
||||
m_highlightColorPushButton->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_highlightColorLabel->hide();
|
||||
m_highlightColorPushButton->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewOptionsDialog::saveViewOptions()
|
||||
{
|
||||
m_settings->setValue("save_geometry", m_saveGeometryCheckBox->isChecked());
|
||||
m_settings->setValue("save_dock_positions", m_saveDockPositionsCheckBox->isChecked());
|
||||
m_settings->setValue("save_last_tab", m_saveLastTabCheckBox->isChecked());
|
||||
m_settings->setValue("theme", m_mainwindow->getThemeString(static_cast<MainWindow::Theme>(m_themeComboBox->currentData(Qt::UserRole).toInt())));
|
||||
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 (!m_mainwindow->customThemeString().isEmpty())
|
||||
m_settings->setValue("custom_theme", m_customThemePath);
|
||||
|
||||
m_mainwindow->setAllPlaylistsListMaxCount(m_allPlaylistsListMaxCountSpinBox->value());
|
||||
m_mainwindow->setAllPlaylistsGridMaxCount(m_allPlaylistsGridMaxCountSpinBox->value());
|
||||
}
|
||||
|
||||
void ViewOptionsDialog::onAccepted()
|
||||
{
|
||||
MainWindow::Theme newTheme = static_cast<MainWindow::Theme>(m_themeComboBox->currentData(Qt::UserRole).toInt());
|
||||
|
||||
m_mainwindow->setTheme(newTheme);
|
||||
|
||||
saveViewOptions();
|
||||
}
|
||||
|
||||
void ViewOptionsDialog::onRejected()
|
||||
{
|
||||
loadViewOptions();
|
||||
}
|
||||
|
||||
void ViewOptionsDialog::showDialog()
|
||||
{
|
||||
loadViewOptions();
|
||||
show();
|
||||
}
|
||||
|
||||
void ViewOptionsDialog::hideDialog()
|
||||
{
|
||||
reject();
|
||||
}
|
||||
|
49
ui/drivers/qt/viewoptionsdialog.h
Normal file
49
ui/drivers/qt/viewoptionsdialog.h
Normal file
@ -0,0 +1,49 @@
|
||||
#ifndef VIEWOPTIONSDIALOG_H
|
||||
#define VIEWOPTIONSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class MainWindow;
|
||||
class QSettings;
|
||||
class QCheckBox;
|
||||
class QComboBox;
|
||||
class QPushButton;
|
||||
class QColor;
|
||||
class QLabel;
|
||||
class QSpinBox;
|
||||
|
||||
class ViewOptionsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent = 0);
|
||||
public slots:
|
||||
void showDialog();
|
||||
void hideDialog();
|
||||
void onAccepted();
|
||||
void onRejected();
|
||||
private slots:
|
||||
void onThemeComboBoxIndexChanged(int index);
|
||||
void onHighlightColorChoose();
|
||||
private:
|
||||
void loadViewOptions();
|
||||
void saveViewOptions();
|
||||
void showOrHideHighlightColor();
|
||||
|
||||
MainWindow *m_mainwindow;
|
||||
QSettings *m_settings;
|
||||
QCheckBox *m_saveGeometryCheckBox;
|
||||
QCheckBox *m_saveDockPositionsCheckBox;
|
||||
QCheckBox *m_saveLastTabCheckBox;
|
||||
QCheckBox *m_showHiddenFilesCheckBox;
|
||||
QComboBox *m_themeComboBox;
|
||||
QPushButton *m_highlightColorPushButton;
|
||||
QColor m_highlightColor;
|
||||
QLabel *m_highlightColorLabel;
|
||||
QString m_customThemePath;
|
||||
QCheckBox *m_suggestLoadedCoreFirstCheckBox;
|
||||
QSpinBox *m_allPlaylistsListMaxCountSpinBox;
|
||||
QSpinBox *m_allPlaylistsGridMaxCountSpinBox;
|
||||
};
|
||||
|
||||
#endif
|
@ -16,6 +16,7 @@
|
||||
|
||||
extern "C" {
|
||||
#include <file/file_path.h>
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../../config.h"
|
||||
@ -31,6 +32,8 @@ extern "C" {
|
||||
}
|
||||
|
||||
#include "ui_qt.h"
|
||||
#include "qt/filedropwidget.h"
|
||||
#include "qt/viewoptionsdialog.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QtWidgets>
|
||||
|
@ -45,6 +45,10 @@ extern "C" {
|
||||
#include "../../gfx/video_driver.h"
|
||||
}
|
||||
|
||||
#define ALL_PLAYLISTS_TOKEN "|||ALL|||"
|
||||
#define ICON_PATH "/xmb/dot-art/png/"
|
||||
#define THUMBNAIL_BOXART "Named_Boxarts"
|
||||
|
||||
class QApplication;
|
||||
class QCloseEvent;
|
||||
class QKeyEvent;
|
||||
@ -78,6 +82,10 @@ class MainWindow;
|
||||
class ThumbnailWidget;
|
||||
class ThumbnailLabel;
|
||||
class FlowLayout;
|
||||
class ShaderParamsDialog;
|
||||
class CoreInfoDialog;
|
||||
class PlaylistEntryDialog;
|
||||
class ViewOptionsDialog;
|
||||
|
||||
class GridItem : public QObject
|
||||
{
|
||||
@ -147,21 +155,6 @@ protected slots:
|
||||
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
||||
};
|
||||
|
||||
class FileDropWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FileDropWidget(QWidget *parent = 0);
|
||||
signals:
|
||||
void filesDropped(QStringList files);
|
||||
void deletePressed();
|
||||
protected:
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dropEvent(QDropEvent *event);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
};
|
||||
|
||||
class TableWidget : public QTableWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -188,82 +181,6 @@ private slots:
|
||||
void onLastWindowClosed();
|
||||
};
|
||||
|
||||
class PlaylistEntryDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PlaylistEntryDialog(MainWindow *mainwindow, QWidget *parent = 0);
|
||||
const QHash<QString, QString> getSelectedCore();
|
||||
const QString getSelectedDatabase();
|
||||
const QString getSelectedName();
|
||||
const QString getSelectedPath();
|
||||
void setEntryValues(const QHash<QString, QString> &contentHash);
|
||||
public slots:
|
||||
bool showDialog(const QHash<QString, QString> &hash = QHash<QString, QString>());
|
||||
void hideDialog();
|
||||
void onAccepted();
|
||||
void onRejected();
|
||||
private slots:
|
||||
void onPathClicked();
|
||||
private:
|
||||
void loadPlaylistOptions();
|
||||
|
||||
MainWindow *m_mainwindow;
|
||||
QSettings *m_settings;
|
||||
QLineEdit *m_nameLineEdit;
|
||||
QLineEdit *m_pathLineEdit;
|
||||
QComboBox *m_coreComboBox;
|
||||
QComboBox *m_databaseComboBox;
|
||||
};
|
||||
|
||||
class ViewOptionsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent = 0);
|
||||
public slots:
|
||||
void showDialog();
|
||||
void hideDialog();
|
||||
void onAccepted();
|
||||
void onRejected();
|
||||
private slots:
|
||||
void onThemeComboBoxIndexChanged(int index);
|
||||
void onHighlightColorChoose();
|
||||
private:
|
||||
void loadViewOptions();
|
||||
void saveViewOptions();
|
||||
void showOrHideHighlightColor();
|
||||
|
||||
MainWindow *m_mainwindow;
|
||||
QSettings *m_settings;
|
||||
QCheckBox *m_saveGeometryCheckBox;
|
||||
QCheckBox *m_saveDockPositionsCheckBox;
|
||||
QCheckBox *m_saveLastTabCheckBox;
|
||||
QCheckBox *m_showHiddenFilesCheckBox;
|
||||
QComboBox *m_themeComboBox;
|
||||
QPushButton *m_highlightColorPushButton;
|
||||
QColor m_highlightColor;
|
||||
QLabel *m_highlightColorLabel;
|
||||
QString m_customThemePath;
|
||||
QCheckBox *m_suggestLoadedCoreFirstCheckBox;
|
||||
QSpinBox *m_allPlaylistsListMaxCountSpinBox;
|
||||
QSpinBox *m_allPlaylistsGridMaxCountSpinBox;
|
||||
};
|
||||
|
||||
class ShaderParamsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ShaderParamsDialog(QWidget *parent = 0);
|
||||
~ShaderParamsDialog();
|
||||
signals:
|
||||
void closed();
|
||||
void resized(QSize size);
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
};
|
||||
|
||||
class CoreInfoLabel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -271,18 +188,6 @@ public:
|
||||
CoreInfoLabel(QString text = QString(), QWidget *parent = 0);
|
||||
};
|
||||
|
||||
class CoreInfoDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CoreInfoDialog(MainWindow *mainwindow, QWidget *parent = 0);
|
||||
public slots:
|
||||
void showCoreInfo();
|
||||
private:
|
||||
QFormLayout *m_formLayout;
|
||||
MainWindow *m_mainwindow;
|
||||
};
|
||||
|
||||
class CoreInfoWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
Loading…
x
Reference in New Issue
Block a user