dialog(new QDialog());
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
QTextEdit *textEdit = new QTextEdit(dialog.data());
connect(buttonBox, SIGNAL(accepted()), dialog.data(), SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), dialog.data(), SLOT(reject()));
dialog->setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_HELP_ABOUT_CONTRIBUTORS));
dialog->setLayout(new QVBoxLayout());
dialog->layout()->addWidget(textEdit);
dialog->layout()->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum));
dialog->layout()->addWidget(buttonBox);
textEdit->setReadOnly(true);
textEdit->setHtml(QString("") + retroarch_contributors_list + "
");
dialog->resize(480, 640);
dialog->exec();
}
void MainWindow::showAbout()
{
QScopedPointer dialog(new QDialog());
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
QString text = QString("RetroArch ") + PACKAGE_VERSION +
"
" + "www.libretro.com"
"
" + "www.retroarch.com"
#ifdef HAVE_GIT_VERSION
"
" + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_GIT_VERSION) + ": " + retroarch_git_version +
#endif
"
" + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_BUILD_DATE) + ": " + __DATE__;
QLabel *label = new QLabel(text, dialog.data());
QPixmap pix = getInvader();
QLabel *pixLabel = new QLabel(dialog.data());
QPushButton *contributorsPushButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_HELP_ABOUT_CONTRIBUTORS), dialog.data());
connect(contributorsPushButton, SIGNAL(clicked()), this, SLOT(onContributorsClicked()));
connect(buttonBox, SIGNAL(accepted()), dialog.data(), SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), dialog.data(), SLOT(reject()));
label->setTextFormat(Qt::RichText);
label->setAlignment(Qt::AlignCenter);
label->setTextInteractionFlags(Qt::TextBrowserInteraction);
label->setOpenExternalLinks(true);
pixLabel->setAlignment(Qt::AlignCenter);
pixLabel->setPixmap(pix);
dialog->setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_HELP_ABOUT));
dialog->setLayout(new QVBoxLayout());
dialog->layout()->addWidget(pixLabel);
dialog->layout()->addWidget(label);
dialog->layout()->addWidget(contributorsPushButton);
dialog->layout()->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
dialog->layout()->addWidget(buttonBox);
dialog->exec();
}
void MainWindow::showDocs()
{
QDesktopServices::openUrl(QUrl(DOCS_URL));
}
void MainWindow::onShowErrorMessage(QString msg)
{
showMessageBox(msg, MainWindow::MSGBOX_TYPE_ERROR, Qt::ApplicationModal, false);
}
void MainWindow::onShowInfoMessage(QString msg)
{
showMessageBox(msg, MainWindow::MSGBOX_TYPE_INFO, Qt::ApplicationModal, false);
}
int MainWindow::onExtractArchive(QString path, QString extractionDir, QString tempExtension, retro_task_callback_t cb)
{
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;
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() + tempExtension);
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, dir,
NULL, NULL, NULL,
cb, this, NULL))
{
m_updateProgressDialog->cancel();
return -1;
}
return returnerr;
}
QString MainWindow::getScrubbedString(QString str)
{
const QString chars("&*/:`\"<>?\\|");
int i;
for (i = 0; i < chars.count(); i++)
str.replace(chars.at(i), '_');
return str;
}
static void* ui_window_qt_init(void)
{
ui_window.qtWindow = new MainWindow();
return &ui_window;
}
static void ui_window_qt_destroy(void *data)
{
(void)data;
/*
ui_window_qt_t *window = (ui_window_qt_t*)data;
delete window->qtWindow;
*/
}
static void ui_window_qt_set_focused(void *data)
{
(void)data;
/*
ui_window_qt_t *window = (ui_window_qt_t*)data;
window->qtWindow->raise();
window->qtWindow->activateWindow();
*/
}
static void ui_window_qt_set_visible(void *data,
bool set_visible)
{
(void)data;
(void)set_visible;
/* TODO/FIXME */
}
static void ui_window_qt_set_title(void *data, char *buf)
{
(void)data;
(void)buf;
/*
ui_window_qt_t *window = (ui_window_qt_t*)data;
window->qtWindow->setWindowTitle(QString::fromUtf8(buf));
*/
}
static void ui_window_qt_set_droppable(void *data, bool droppable)
{
(void)data;
(void)droppable;
/*
ui_window_qt_t *window = (ui_window_qt_t*)data;
window->qtWindow->setAcceptDrops(droppable);
*/
}
static bool ui_window_qt_focused(void *data)
{
(void)data;
/*
ui_window_qt_t *window = (ui_window_qt_t*)data;
return window->qtWindow->isActiveWindow() && !window->qtWindow->isMinimized();
*/
return true;
}
ui_window_t ui_window_qt = {
ui_window_qt_init,
ui_window_qt_destroy,
ui_window_qt_set_focused,
ui_window_qt_set_visible,
ui_window_qt_set_title,
ui_window_qt_set_droppable,
ui_window_qt_focused,
"qt"
};