Merge pull request #7010 from bparker06/qt_grid

Qt: initial working grid view
This commit is contained in:
Twinaphex 2018-07-23 17:45:43 +02:00 committed by GitHub
commit 6150bd9772
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 1257 additions and 135 deletions

View File

@ -334,14 +334,16 @@ OBJ += ui/drivers/ui_qt.o \
ui/drivers/qt/ui_qt_window.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/ui_qt_msg_window.o \
ui/drivers/qt/flowlayout.o
MOC_HEADERS += ui/drivers/ui_qt.h \
ui/drivers/qt/ui_qt_load_core_window.h
ui/drivers/qt/ui_qt_load_core_window.h \
ui/drivers/qt/flowlayout.h
DEFINES += $(QT5CORE_CFLAGS) $(QT5GUI_CFLAGS) $(QT5WIDGETS_CFLAGS) -DHAVE_MAIN
DEFINES += $(QT5CORE_CFLAGS) $(QT5GUI_CFLAGS) $(QT5WIDGETS_CFLAGS) $(QT5CONCURRENT_CFLAGS) -DHAVE_MAIN
#DEFINES += $(QT5WEBENGINE_CFLAGS)
LIBS += $(QT5CORE_LIBS) $(QT5GUI_LIBS) $(QT5WIDGETS_LIBS)
LIBS += $(QT5CORE_LIBS) $(QT5GUI_LIBS) $(QT5WIDGETS_LIBS) $(QT5CONCURRENT_LIBS)
#LIBS += $(QT5WEBENGINE_LIBS)
NEED_CXX_LINKER = 1

View File

@ -3562,6 +3562,14 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_FILE_DOES_NOT_EXIST,
"ファイルは存在しません。")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SUGGEST_LOADED_CORE_FIRST,
"ロードしたコアを最初に優先する")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_ZOOM,
"ズーム")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_VIEW,
"表示")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_ICONS,
"アイコン")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_LIST,
"一覧")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_OVERRIDE_OPTIONS,
"オーバーライド")
MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_OVERRIDE_OPTIONS,
@ -3622,3 +3630,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSTAINED_PERFORMANCE_MODE,
"パフォーマンス維持モード")
MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT,
"mpv対応")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PROGRESS,
"進行状況:")

View File

@ -3710,6 +3710,14 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_FILE_DOES_NOT_EXIST,
"File does not exist.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SUGGEST_LOADED_CORE_FIRST,
"Suggest loaded core first")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_ZOOM,
"Zoom")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_VIEW,
"View")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_ICONS,
"Icons")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_LIST,
"List")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_OVERRIDE_OPTIONS,
"Overrides")
MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_OVERRIDE_OPTIONS,
@ -3780,3 +3788,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSTAINED_PERFORMANCE_MODE,
"Sustained Performance Mode")
MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT,
"mpv support")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PROGRESS,
"Progress:")

View File

@ -1871,6 +1871,11 @@ enum msg_hash_enums
MENU_ENUM_LABEL_VALUE_QT_FILE_IS_EMPTY,
MENU_ENUM_LABEL_VALUE_QT_FILE_READ_OPEN_FAILED,
MENU_ENUM_LABEL_VALUE_QT_FILE_DOES_NOT_EXIST,
MENU_ENUM_LABEL_VALUE_QT_ZOOM,
MENU_ENUM_LABEL_VALUE_QT_VIEW,
MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_ICONS,
MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_LIST,
MENU_ENUM_LABEL_VALUE_QT_PROGRESS,
MENU_LABEL(MIDI_INPUT),
MENU_LABEL(MIDI_OUTPUT),

View File

@ -278,14 +278,16 @@ if [ "$HAVE_QT" != 'no' ] && [ "$MOC_PATH" != 'none' ]; then
check_pkgconf QT5CORE Qt5Core 5.2
check_pkgconf QT5GUI Qt5Gui 5.2
check_pkgconf QT5WIDGETS Qt5Widgets 5.2
check_pkgconf QT5CONCURRENT Qt5Concurrent 5.2
#check_pkgconf QT5WEBENGINE Qt5WebEngine 5.4
check_val '' QT5CORE -lQt5Core QT5CORE
check_val '' QT5GUI -lQt5Gui QT5GUI
check_val '' QT5WIDGETS -lQt5Widgets QT5WIDGETS
check_val '' QT5CONCURRENT -lQt5Widgets QT5CONCURRENT
#check_val '' QT5WEBENGINE -lQt5WebEngine QT5WEBENGINE
if [ "$HAVE_QT5CORE" = "no" ] || [ "$HAVE_QT5GUI" = "no" ] || [ "$HAVE_QT5WIDGETS" = "no" ]; then
if [ "$HAVE_QT5CORE" = "no" ] || [ "$HAVE_QT5GUI" = "no" ] || [ "$HAVE_QT5WIDGETS" = "no" ] || [ "$HAVE_QT5CONCURRENT" = "no" ]; then
die : 'Notice: Not building Qt support, required libraries were not found.'
HAVE_QT=no
else

View File

@ -0,0 +1,248 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
/* Original work Copyright (C) 2016 The Qt Company Ltd.
* Modified work Copyright (C) 2018 - Brad Parker
*/
#include <QtWidgets>
#include "flowlayout.h"
#include "../ui_qt.h"
FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing)
: QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing)
{
setContentsMargins(margin, margin, margin, margin);
connect(this, SIGNAL(signalAddWidgetDeferred(QPointer<ThumbnailWidget>)), this, SLOT(onAddWidgetDeferred(QPointer<ThumbnailWidget>)), Qt::QueuedConnection);
}
FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing)
: m_hSpace(hSpacing), m_vSpace(vSpacing)
{
setContentsMargins(margin, margin, margin, margin);
}
FlowLayout::~FlowLayout()
{
QLayoutItem *item = NULL;
while ((item = takeAt(0)) != NULL)
delete item;
}
void FlowLayout::addItem(QLayoutItem *item)
{
itemList.append(item);
}
int FlowLayout::horizontalSpacing() const
{
if (m_hSpace >= 0)
return m_hSpace;
else
return smartSpacing(QStyle::PM_LayoutHorizontalSpacing);
}
int FlowLayout::verticalSpacing() const
{
if (m_vSpace >= 0)
return m_vSpace;
else
return smartSpacing(QStyle::PM_LayoutVerticalSpacing);
}
int FlowLayout::count() const
{
return itemList.size();
}
QLayoutItem* FlowLayout::itemAt(int index) const
{
return itemList.value(index);
}
QLayoutItem* FlowLayout::takeAt(int index)
{
if (index >= 0 && index < itemList.size())
return itemList.takeAt(index);
else
return NULL;
}
Qt::Orientations FlowLayout::expandingDirections() const
{
return 0;
}
bool FlowLayout::hasHeightForWidth() const
{
return true;
}
int FlowLayout::heightForWidth(int width) const
{
int height = doLayout(QRect(0, 0, width, 0), true);
return height;
}
void FlowLayout::setGeometry(const QRect &rect)
{
QLayout::setGeometry(rect);
doLayout(rect, false);
}
QSize FlowLayout::sizeHint() const
{
return minimumSize();
}
QSize FlowLayout::minimumSize() const
{
QSize size;
int i = 0;
if (itemList.isEmpty())
return size;
for (i = 0; i < itemList.count(); i++)
{
const QLayoutItem *item = itemList.at(i);
size = size.expandedTo(item->minimumSize());
}
size += QSize(2 * margin(), 2 * margin());
return size;
}
int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
{
QRect effectiveRect;
int left = 0, top = 0, right = 0, bottom = 0;
int x = 0;
int y = 0;
int lineHeight = 0;
int i = 0;
getContentsMargins(&left, &top, &right, &bottom);
effectiveRect = rect.adjusted(+left, +top, -right, -bottom);
x = effectiveRect.x();
y = effectiveRect.y();
if (itemList.isEmpty())
return y + lineHeight - rect.y() + bottom;
for (i = 0; i < itemList.count(); i++)
{
QLayoutItem *item = itemList.at(i);
const QWidget *wid = item->widget();
int spaceX = horizontalSpacing();
int spaceY = 0;
int nextX = 0;
if (spaceX == -1)
spaceX = wid->style()->layoutSpacing(
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal);
spaceY = verticalSpacing();
if (spaceY == -1)
spaceY = wid->style()->layoutSpacing(
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);
nextX = x + item->sizeHint().width() + spaceX;
if (nextX - spaceX > effectiveRect.right() && lineHeight > 0)
{
x = effectiveRect.x();
y = y + lineHeight + spaceY;
nextX = x + item->sizeHint().width() + spaceX;
lineHeight = 0;
}
if (!testOnly)
item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));
x = nextX;
lineHeight = qMax(lineHeight, item->sizeHint().height());
}
return y + lineHeight - rect.y() + bottom;
}
int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
{
const QObject *parentObj = parent();
if (!parentObj)
return -1;
else if (parentObj->isWidgetType())
{
const QWidget *pw = static_cast<const QWidget*>(parentObj);
return pw->style()->pixelMetric(pm, NULL, pw);
}
else
return static_cast<const QLayout*>(parentObj)->spacing();
}
void FlowLayout::addWidgetDeferred(QPointer<ThumbnailWidget> widget)
{
emit signalAddWidgetDeferred(widget);
}
void FlowLayout::onAddWidgetDeferred(QPointer<ThumbnailWidget> widget)
{
/* widget might have been deleted before we got to it since this uses a queued connection, hence the guarded QPointer */
if (!widget)
return;
addWidget(widget);
}

105
ui/drivers/qt/flowlayout.h Normal file
View File

@ -0,0 +1,105 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
/* Original work Copyright (C) 2016 The Qt Company Ltd.
* Modified work Copyright (C) 2018 - Brad Parker
*/
/* bparker: Removed C++11 override keyword from original source
* Changed QList to QVector
*/
#ifndef FLOWLAYOUT_H
#define FLOWLAYOUT_H
#include <QLayout>
#include <QRect>
#include <QStyle>
class ThumbnailWidget;
class FlowLayout : public QLayout
{
Q_OBJECT
public:
explicit FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1);
explicit FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1);
~FlowLayout();
void addItem(QLayoutItem *item);
int horizontalSpacing() const;
int verticalSpacing() const;
Qt::Orientations expandingDirections() const;
bool hasHeightForWidth() const;
int heightForWidth(int) const;
int count() const;
QLayoutItem* itemAt(int index) const;
QSize minimumSize() const;
void setGeometry(const QRect &rect);
QSize sizeHint() const;
QLayoutItem* takeAt(int index);
void addWidgetDeferred(QPointer<ThumbnailWidget> widget);
signals:
void signalAddWidgetDeferred(QPointer<ThumbnailWidget> widget);
private slots:
void onAddWidgetDeferred(QPointer<ThumbnailWidget> widget);
private:
int doLayout(const QRect &rect, bool testOnly) const;
int smartSpacing(QStyle::PixelMetric pm) const;
QVector<QLayoutItem*> itemList;
int m_hSpace;
int m_vSpace;
};
#endif // FLOWLAYOUT_H

View File

@ -266,8 +266,11 @@ void LoadCoreWindow::initCoreList(const QStringList &extensionFilters)
if (rowsToHide.size() != m_table->rowCount())
{
foreach (const int &row, rowsToHide)
int i = 0;
for (i = 0; i < rowsToHide.count() && rowsToHide.count() > 0; i++)
{
const int &row = rowsToHide.at(i);
m_table->setRowHidden(row, true);
}
}

View File

@ -1,7 +1,15 @@
#include <QString>
/* %1 is a placeholder for palette(highlight) or the equivalent chosen by the user */
static const QString qt_theme_default_stylesheet = QStringLiteral("");
static const QString qt_theme_default_stylesheet = QStringLiteral(""
"QPushButton[flat=\"true\"] {\n"
" min-height:20px;\n"
" min-width:80px;\n"
" padding:1px 3px 1px 3px;\n"
" background-color: transparent;\n"
" border: 1px solid #ddd;\n"
"}\n"
);
static const QString qt_theme_dark_stylesheet = QStringLiteral(""
"QWidget {\n"
@ -233,6 +241,10 @@ static const QString qt_theme_dark_stylesheet = QStringLiteral(""
" border:1px solid %1;\n"
" border-radius:4px;\n"
"}\n"
"QPushButton[flat=\"true\"] {\n"
" background-color: transparent;\n"
" border: 1px solid #ddd;\n"
"}\n"
"QRadioButton::indicator {\n"
" width:18px;\n"
" height:18px;\n"

File diff suppressed because it is too large Load Diff

View File

@ -57,20 +57,35 @@ typedef struct ui_companion_qt
ThumbnailWidget::ThumbnailWidget(QWidget *parent) :
QWidget(parent)
,m_sizeHint(QSize(256, 256))
{
}
void ThumbnailWidget::mousePressEvent(QMouseEvent *event)
{
QWidget::mousePressEvent(event);
emit mousePressed();
}
void ThumbnailWidget::mouseDoubleClickEvent(QMouseEvent *event)
{
QWidget::mouseDoubleClickEvent(event);
emit mouseDoubleClicked();
}
void ThumbnailWidget::paintEvent(QPaintEvent *event)
{
QStyleOption o;
QPainter p;
o.initFrom(this);
p.begin(this);
style()->drawPrimitive(
QStyle::PE_Widget, &o, &p, this);
p.end();
QStyleOption o;
QPainter p;
o.initFrom(this);
p.begin(this);
style()->drawPrimitive(
QStyle::PE_Widget, &o, &p, this);
p.end();
QWidget::paintEvent(event);
QWidget::paintEvent(event);
}
void ThumbnailWidget::resizeEvent(QResizeEvent *event)
@ -80,7 +95,12 @@ void ThumbnailWidget::resizeEvent(QResizeEvent *event)
QSize ThumbnailWidget::sizeHint() const
{
return QSize(256, 256);
return m_sizeHint;
}
void ThumbnailWidget::setSizeHint(QSize size)
{
m_sizeHint = size;
}
ThumbnailLabel::ThumbnailLabel(QWidget *parent) :
@ -231,6 +251,8 @@ static void* ui_companion_qt_init(void)
QAction *exitAction = NULL;
QComboBox *launchWithComboBox = NULL;
QSettings *qsettings = NULL;
QListWidget *listWidget = NULL;
int i = 0;
if (!handle)
return NULL;
@ -251,11 +273,14 @@ static void* ui_companion_qt_init(void)
mainwindow->setWindowTitle("RetroArch");
mainwindow->setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks | GROUPED_DRAGGING);
listWidget = mainwindow->playlistListWidget();
widget = new QWidget(mainwindow);
widget->setObjectName("tableWidget");
layout = new QVBoxLayout();
layout->addWidget(mainwindow->contentTableWidget());
layout->addWidget(mainwindow->contentGridWidget());
widget->setLayout(layout);
@ -286,6 +311,10 @@ static void* ui_companion_qt_init(void)
QObject::connect(viewClosedDocksMenu, SIGNAL(aboutToShow()), mainwindow, SLOT(onViewClosedDocksAboutToShow()));
viewMenu->addSeparator();
viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_ICONS), mainwindow, SLOT(onIconViewClicked()));
viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_LIST), mainwindow, SLOT(onListViewClicked()));
viewMenu->addSeparator();
viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS), mainwindow->viewOptionsDialog(), SLOT(showDialog()));
playlistWidget = new QWidget();
@ -455,17 +484,6 @@ static void* ui_companion_qt_init(void)
if (qsettings->contains("dock_positions"))
mainwindow->restoreState(qsettings->value("dock_positions").toByteArray());
if (qsettings->contains("save_last_tab"))
{
if (qsettings->contains("last_tab"))
{
int lastTabIndex = qsettings->value("last_tab", 0).toInt();
if (lastTabIndex >= 0 && browserAndPlaylistTabWidget->count() > lastTabIndex)
browserAndPlaylistTabWidget->setCurrentIndex(lastTabIndex);
}
}
if (qsettings->contains("theme"))
{
QString themeStr = qsettings->value("theme").toString();
@ -483,6 +501,58 @@ static void* ui_companion_qt_init(void)
else
mainwindow->setTheme();
if (qsettings->contains("view_type"))
{
QString viewType = qsettings->value("view_type", "list").toString();
if (viewType == "list")
mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST);
else if (viewType == "icons")
mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_ICONS);
else
mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST);
/* we set it to the same thing a second time so that m_lastViewType is also equal to the startup view type */
mainwindow->setCurrentViewType(mainwindow->getCurrentViewType());
}
else
mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST);
/* We make sure to hook up the tab widget callback only after the tabs themselves have been added,
* but before changing to a specific one, to avoid the callback firing before the view type is set.
*/
QObject::connect(browserAndPlaylistTabWidget, SIGNAL(currentChanged(int)), mainwindow, SLOT(onTabWidgetIndexChanged(int)));
/* setting the last tab must come after setting the view type */
if (qsettings->contains("save_last_tab"))
{
if (qsettings->contains("last_tab"))
{
int lastTabIndex = qsettings->value("last_tab", 0).toInt();
if (lastTabIndex >= 0 && browserAndPlaylistTabWidget->count() > lastTabIndex)
{
browserAndPlaylistTabWidget->setCurrentIndex(lastTabIndex);
mainwindow->onTabWidgetIndexChanged(lastTabIndex);
}
}
}
else
{
browserAndPlaylistTabWidget->setCurrentIndex(0);
mainwindow->onTabWidgetIndexChanged(0);
}
for (i = 0; i < listWidget->count() && listWidget->count() > 0; i++)
{
/* select the first non-hidden row */
if (!listWidget->isRowHidden(i))
{
listWidget->setCurrentRow(i);
break;
}
}
return handle;
}

View File

@ -28,6 +28,11 @@
#include <QRegularExpression>
#include <QPalette>
#include <QPlainTextEdit>
#include <QFutureWatcher>
#include <QPixmap>
#include <QImage>
#include <QPointer>
#include <QProgressBar>
extern "C" {
#include <retro_common_api.h>
@ -55,8 +60,26 @@ class QCheckBox;
class QFormLayout;
class QStyle;
class QScrollArea;
class QSlider;
class LoadCoreWindow;
class MainWindow;
class ThumbnailWidget;
class ThumbnailLabel;
class FlowLayout;
class GridItem : public QObject
{
Q_OBJECT
public:
GridItem();
QPointer<ThumbnailWidget> widget;
QPointer<ThumbnailLabel> label;
QHash<QString, QString> hash;
QImage image;
QPixmap pixmap;
QFutureWatcher<GridItem*> imageWatcher;
};
class ThumbnailWidget : public QWidget
{
@ -64,9 +87,17 @@ class ThumbnailWidget : public QWidget
public:
ThumbnailWidget(QWidget *parent = 0);
QSize sizeHint() const;
void setSizeHint(QSize size);
signals:
void mouseDoubleClicked();
void mousePressed();
private:
QSize m_sizeHint;
protected:
void paintEvent(QPaintEvent *event);
void resizeEvent(QResizeEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
};
class ThumbnailLabel : public QWidget
@ -204,6 +235,12 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
enum ViewType
{
VIEW_TYPE_ICONS,
VIEW_TYPE_LIST
};
enum Theme
{
THEME_SYSTEM_DEFAULT,
@ -223,6 +260,8 @@ public:
TreeView* dirTreeView();
QListWidget* playlistListWidget();
TableWidget* contentTableWidget();
FlowLayout* contentGridLayout();
QWidget* contentGridWidget();
QWidget* searchWidget();
QLineEdit* searchLineEdit();
QComboBox* launchWithComboBox();
@ -231,10 +270,10 @@ public:
QToolButton* runPushButton();
QToolButton* stopPushButton();
QTabWidget* browserAndPlaylistTabWidget();
QList<QHash<QString, QString> > getPlaylistDefaultCores();
QVector<QHash<QString, QString> > getPlaylistDefaultCores();
ViewOptionsDialog* viewOptionsDialog();
QSettings* settings();
QList<QHash<QString, QString> > getCoreInfo();
QVector<QHash<QString, QString> > getCoreInfo();
void setTheme(Theme theme = THEME_SYSTEM_DEFAULT);
Theme theme();
Theme getThemeFromString(QString themeString);
@ -245,6 +284,10 @@ public:
bool setCustomThemeFile(QString filePath);
void setCustomThemeString(QString qss);
const QString& customThemeString() const;
GridItem* doDeferredImageLoad(GridItem *item, QString path);
void setCurrentViewType(ViewType viewType);
QString getCurrentViewTypeString();
ViewType getCurrentViewType();
signals:
void thumbnailChanged(const QPixmap &pixmap);
@ -259,10 +302,12 @@ public slots:
void onBrowserUpClicked();
void onBrowserStartClicked();
void initContentTableWidget();
void initContentGridLayout();
void onViewClosedDocksAboutToShow();
void onShowHiddenDockWidgetAction();
void setCoreActions();
void onRunClicked();
void loadContent(const QHash<QString, QString> &contentHash);
void onStartCoreClicked();
void onTableWidgetEnterPressed();
void selectBrowserDir(QString path);
@ -277,6 +322,9 @@ public slots:
void deferReloadPlaylists();
void onGotReloadPlaylists();
void showWelcomeScreen();
void onIconViewClicked();
void onListViewClicked();
void onTabWidgetIndexChanged(int index);
private slots:
void onLoadCoreClicked(const QStringList &extensionFilters = QStringList());
@ -285,24 +333,36 @@ private slots:
void onCoreLoaded();
void onCurrentListItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
void onCurrentTableItemChanged(QTableWidgetItem *current, QTableWidgetItem *previous);
void currentItemChanged(const QHash<QString, QString> &hash);
void onSearchEnterPressed();
void onSearchLineEditEdited(const QString &text);
void addPlaylistItemsToTable(QString path);
void addPlaylistItemsToGrid(const QString &path, bool setProgress = true);
void onContentItemDoubleClicked(QTableWidgetItem *item);
void onCoreLoadWindowClosed();
void onTabWidgetIndexChanged(int index);
void onTreeViewItemsSelected(QModelIndexList selectedIndexes);
void onSearchResetClicked();
void onLaunchWithComboBoxIndexChanged(int index);
void onFileBrowserTreeContextMenuRequested(const QPoint &pos);
void onPlaylistWidgetContextMenuRequested(const QPoint &pos);
void onStopClicked();
void onDeferredImageLoaded();
void onZoomValueChanged(int value);
void onContentGridInited();
void onUpdateGridItemPixmapFromImage(GridItem *item);
void onPendingItemUpdates();
void onGridItemDoubleClicked();
void onGridItemClicked();
private:
void setCurrentCoreLabel();
void getPlaylistFiles();
bool isCoreLoaded();
bool isContentLessCore();
void removeGridItems();
void loadImageDeferred(GridItem *item, QString path);
void calcGridItemSize(GridItem *item, int zoomValue);
QVector<QHash<QString, QString> > getPlaylistItems(QString pathString);
LoadCoreWindow *m_loadCoreWindow;
QTimer *m_timer;
@ -344,12 +404,27 @@ private:
QListWidgetItem *m_historyPlaylistsItem;
QIcon m_folderIcon;
QString m_customThemeString;
FlowLayout *m_gridLayout;
QWidget *m_gridWidget;
QScrollArea *m_gridScrollArea;
QVector<QPointer<GridItem> > m_gridItems;
QWidget *m_gridLayoutWidget;
QSlider *m_zoomSlider;
int m_lastZoomSliderValue;
QList<GridItem*> m_pendingItemUpdates;
ViewType m_viewType;
QProgressBar *m_gridProgressBar;
QWidget *m_gridProgressWidget;
QHash<QString, QString> m_currentGridHash;
ViewType m_lastViewType;
protected:
void closeEvent(QCloseEvent *event);
void keyPressEvent(QKeyEvent *event);
};
Q_DECLARE_METATYPE(QPointer<ThumbnailWidget>)
RETRO_BEGIN_DECLS
typedef struct ui_application_qt