mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 04:14:00 +00:00
Merge pull request #7925 from CozmoP/sync
Qt: Detailed file browser table and other changes.
This commit is contained in:
commit
fd17970f61
@ -6854,6 +6854,10 @@ MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_QT_LOG,
|
||||
"Log"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_QT_ITEMS_COUNT,
|
||||
"%1 items"
|
||||
)
|
||||
#ifdef HAVE_QT
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_QT_SCAN_FINISHED,
|
||||
|
@ -2125,6 +2125,7 @@ enum msg_hash_enums
|
||||
MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_PACK_DOWNLOADED_SUCCESSFULLY,
|
||||
MENU_ENUM_LABEL_VALUE_QT_DOWNLOAD_PLAYLIST_THUMBNAIL_PROGRESS,
|
||||
MENU_ENUM_LABEL_VALUE_QT_CORE_OPTIONS,
|
||||
MENU_ENUM_LABEL_VALUE_QT_ITEMS_COUNT,
|
||||
|
||||
MENU_LABEL(MIDI_INPUT),
|
||||
MENU_LABEL(MIDI_OUTPUT),
|
||||
|
@ -27,7 +27,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
FileDropWidget::FileDropWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
QStackedWidget(parent)
|
||||
{
|
||||
setAcceptDrops(true);
|
||||
}
|
||||
@ -106,9 +106,6 @@ void MainWindow::onFileDropWidgetContextMenuRequested(const QPoint &pos)
|
||||
bool allPlaylist = currentPlaylistIsAll();
|
||||
bool actionsAdded = false;
|
||||
|
||||
if (m_browserAndPlaylistTabWidget->tabText(m_browserAndPlaylistTabWidget->currentIndex()) != msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS))
|
||||
return;
|
||||
|
||||
menu.reset(new QMenu(this));
|
||||
|
||||
if (!specialPlaylist)
|
||||
|
@ -1,14 +1,14 @@
|
||||
#ifndef FILEDROPWIDGET_H
|
||||
#define FILEDROPWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStackedWidget>
|
||||
|
||||
class QDragEnterEvent;
|
||||
class QDropEvent;
|
||||
class QKeyEvent;
|
||||
class QPaintEvent;
|
||||
|
||||
class FileDropWidget : public QWidget
|
||||
class FileDropWidget : public QStackedWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -16,6 +16,12 @@ static const QString qt_theme_default_stylesheet = QStringLiteral(R"(
|
||||
background-color:#d4d4d4;
|
||||
border:3px solid %1;
|
||||
}
|
||||
QFrame#playlistWidget, QFrame#browserWidget, QFrame#logWidget {
|
||||
padding: 8px;
|
||||
}
|
||||
ListWidget {
|
||||
icon-size: 32px;
|
||||
}
|
||||
)");
|
||||
|
||||
static const QString qt_theme_dark_stylesheet = QStringLiteral(R"(
|
||||
@ -24,13 +30,17 @@ static const QString qt_theme_dark_stylesheet = QStringLiteral(R"(
|
||||
background-color:rgb(53,53,53);
|
||||
selection-background-color:%1;
|
||||
}
|
||||
QWidget#playlistWidget, QWidget#browserWidget, QWidget#tableWidget, QWidget#logWidget {
|
||||
QFrame#playlistWidget, QFrame#browserWidget, QStackedWidget#centralWidget, QFrame#logWidget {
|
||||
padding: 8px;
|
||||
background-color:rgb(66,66,66);
|
||||
border-top:1px solid rgba(175,175,175,50%);
|
||||
border-left:1px solid rgba(125,125,125,50%);
|
||||
border-right:1px solid rgba(125,125,125,50%);
|
||||
border-bottom:1px solid rgba(25,25,25,75%);
|
||||
}
|
||||
ListWidget {
|
||||
icon-size: 32px;
|
||||
}
|
||||
QTextEdit, LogTextEdit {
|
||||
background-color:rgb(25,25,25);
|
||||
}
|
||||
@ -436,4 +446,7 @@ static const QString qt_theme_dark_stylesheet = QStringLiteral(R"(
|
||||
GridItem {
|
||||
qproperty-thumbnailvalign: "center";
|
||||
}
|
||||
QLabel#itemsCountLabel {
|
||||
padding-left: 5px;
|
||||
}
|
||||
)");
|
||||
|
@ -253,6 +253,27 @@ void LogTextEdit::appendMessage(const QString& text)
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||
}
|
||||
|
||||
/* only accept indexes from current path. https://www.qtcentre.org/threads/50700-QFileSystemModel-and-QSortFilterProxyModel-don-t-work-well-together */
|
||||
bool FileSystemProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
{
|
||||
QModelIndex rootIndex;
|
||||
|
||||
QFileSystemModel *sm = qobject_cast<QFileSystemModel*>(sourceModel());
|
||||
rootIndex = sm->index(sm->rootPath());
|
||||
|
||||
if (sourceParent == rootIndex)
|
||||
{
|
||||
return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void FileSystemProxyModel::sort(int column, Qt::SortOrder order)
|
||||
{
|
||||
/* sort the source (QFileSystemModel to keep directories before files) */
|
||||
sourceModel()->sort(column, order);
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent)
|
||||
,m_loadCoreWindow(new LoadCoreWindow(this))
|
||||
@ -262,8 +283,12 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
,m_statusLabel(new QLabel(this))
|
||||
,m_dirTree(new TreeView(this))
|
||||
,m_dirModel(new QFileSystemModel(m_dirTree))
|
||||
,m_fileModel(new QFileSystemModel(this))
|
||||
,m_listWidget(new ListWidget(this))
|
||||
,m_centralWidget(new QStackedWidget(this))
|
||||
,m_tableView(new TableView(this))
|
||||
,m_fileTableView(new QTableView(this))
|
||||
,m_playlistViews(new FileDropWidget(this))
|
||||
,m_searchWidget(new QWidget(this))
|
||||
,m_searchLineEdit(new QLineEdit(this))
|
||||
,m_searchDock(new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_EDIT_SEARCH), this))
|
||||
@ -289,15 +314,13 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
,m_coreInfoLabel(new CoreInfoLabel(QString(), this))
|
||||
,m_coreInfoWidget(new CoreInfoWidget(m_coreInfoLabel, this))
|
||||
,m_logDock(new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_LOG), this))
|
||||
,m_logWidget(new QWidget(this))
|
||||
,m_logWidget(new QFrame(this))
|
||||
,m_logTextEdit(new LogTextEdit(m_logWidget))
|
||||
,m_historyPlaylistsItem(NULL)
|
||||
,m_folderIcon()
|
||||
,m_customThemeString()
|
||||
,m_gridView(new GridView(this))
|
||||
,m_gridWidget(new QWidget(this))
|
||||
,m_gridScrollArea(new QScrollArea(m_gridWidget))
|
||||
,m_gridLayoutWidget(new FileDropWidget())
|
||||
,m_playlistViewsAndFooter(new QWidget(this))
|
||||
,m_zoomSlider(NULL)
|
||||
,m_lastZoomSliderValue(0)
|
||||
,m_viewType(VIEW_TYPE_LIST)
|
||||
@ -305,7 +328,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
,m_gridProgressBar(NULL)
|
||||
,m_gridProgressWidget(NULL)
|
||||
,m_currentGridHash()
|
||||
,m_lastViewType(m_viewType)
|
||||
,m_currentGridWidget(NULL)
|
||||
,m_allPlaylistsListMaxCount(0)
|
||||
,m_allPlaylistsGridMaxCount(0)
|
||||
@ -334,15 +356,19 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
,m_pendingDirScrollPath()
|
||||
,m_thumbnailTimer(new QTimer(this))
|
||||
,m_gridItem(this)
|
||||
,m_currentBrowser(BROWSER_TYPE_PLAYLISTS)
|
||||
,m_searchRegExp()
|
||||
,m_zoomWidget(new QWidget(this))
|
||||
,m_itemsCountLiteral(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ITEMS_COUNT))
|
||||
,m_itemsCountLabel(new QLabel(this))
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
QDir playlistDir(settings->paths.directory_playlist);
|
||||
QString configDir = QFileInfo(path_get(RARCH_PATH_CONFIG)).dir().absolutePath();
|
||||
QToolButton *searchResetButton = NULL;
|
||||
QWidget *zoomWidget = new QWidget();
|
||||
QHBoxLayout *zoomLayout = new QHBoxLayout();
|
||||
QLabel *zoomLabel = new QLabel(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ZOOM), zoomWidget);
|
||||
QPushButton *viewTypePushButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_VIEW), zoomWidget);
|
||||
QLabel *zoomLabel = new QLabel(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ZOOM), m_zoomWidget);
|
||||
QPushButton *viewTypePushButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_VIEW), m_zoomWidget);
|
||||
QMenu *viewTypeMenu = new QMenu(viewTypePushButton);
|
||||
QAction *viewTypeIconsAction = NULL;
|
||||
QAction *viewTypeListAction = NULL;
|
||||
@ -378,7 +404,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
zoomLabel->setObjectName("zoomLabel");
|
||||
|
||||
m_zoomSlider = new QSlider(Qt::Horizontal, zoomWidget);
|
||||
m_zoomSlider = new QSlider(Qt::Horizontal, m_zoomWidget);
|
||||
|
||||
m_zoomSlider->setMinimum(0);
|
||||
m_zoomSlider->setMaximum(100);
|
||||
@ -387,14 +413,18 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
m_lastZoomSliderValue = m_zoomSlider->value();
|
||||
|
||||
m_gridWidget->setLayout(new QVBoxLayout());
|
||||
m_playlistViewsAndFooter->setLayout(new QVBoxLayout());
|
||||
|
||||
m_gridView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_gridView->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
|
||||
m_gridWidget->layout()->addWidget(m_gridView);
|
||||
m_gridWidget->layout()->setAlignment(Qt::AlignCenter);
|
||||
m_gridWidget->layout()->setContentsMargins(0, 0, 0, 0);
|
||||
m_playlistViews->addWidget(m_gridView);
|
||||
m_playlistViews->addWidget(m_tableView);
|
||||
m_centralWidget->setObjectName("centralWidget");
|
||||
|
||||
m_playlistViewsAndFooter->layout()->addWidget(m_playlistViews);
|
||||
m_playlistViewsAndFooter->layout()->setAlignment(Qt::AlignCenter);
|
||||
m_playlistViewsAndFooter->layout()->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
m_gridProgressWidget->setLayout(gridProgressLayout);
|
||||
gridProgressLayout->setContentsMargins(0, 0, 0, 0);
|
||||
@ -402,20 +432,23 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
gridProgressLayout->addWidget(gridProgressLabel);
|
||||
gridProgressLayout->addWidget(m_gridProgressBar);
|
||||
|
||||
m_gridWidget->layout()->addWidget(m_gridProgressWidget);
|
||||
m_playlistViewsAndFooter->layout()->addWidget(m_gridProgressWidget);
|
||||
|
||||
zoomWidget->setLayout(zoomLayout);
|
||||
m_zoomWidget->setLayout(zoomLayout);
|
||||
zoomLayout->setContentsMargins(0, 0, 0, 0);
|
||||
zoomLayout->addWidget(zoomLabel);
|
||||
zoomLayout->addWidget(m_zoomSlider);
|
||||
zoomLayout->addWidget(viewTypePushButton);
|
||||
|
||||
m_itemsCountLabel->setObjectName("itemsCountLabel");
|
||||
|
||||
gridFooterLayout = new QHBoxLayout();
|
||||
gridFooterLayout->addWidget(m_itemsCountLabel);
|
||||
gridFooterLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Preferred));
|
||||
gridFooterLayout->addWidget(m_gridProgressWidget);
|
||||
gridFooterLayout->addWidget(zoomWidget);
|
||||
gridFooterLayout->addWidget(m_zoomWidget);
|
||||
gridFooterLayout->addWidget(viewTypePushButton);
|
||||
|
||||
static_cast<QVBoxLayout*>(m_gridWidget->layout())->addLayout(gridFooterLayout);
|
||||
static_cast<QVBoxLayout*>(m_playlistViewsAndFooter->layout())->addLayout(gridFooterLayout);
|
||||
|
||||
m_gridProgressWidget->hide();
|
||||
|
||||
@ -424,14 +457,38 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
m_proxyModel->setSourceModel(m_playlistModel);
|
||||
m_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
|
||||
m_proxyFileModel = new FileSystemProxyModel();
|
||||
m_proxyFileModel->setSourceModel(m_fileModel);
|
||||
m_proxyFileModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
|
||||
m_tableView->setAlternatingRowColors(true);
|
||||
m_tableView->setModel(m_proxyModel);
|
||||
m_tableView->setSortingEnabled(true);
|
||||
m_tableView->verticalHeader()->setVisible(false);
|
||||
m_tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_tableView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_tableView->setEditTriggers(QAbstractItemView::SelectedClicked | QAbstractItemView::EditKeyPressed);
|
||||
m_tableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
m_tableView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
m_tableView->horizontalHeader()->setStretchLastSection(true);
|
||||
m_tableView->setWordWrap(false);
|
||||
|
||||
m_fileTableView->setModel(m_fileModel);
|
||||
m_fileTableView->sortByColumn(0, Qt::AscendingOrder);
|
||||
m_fileTableView->setSortingEnabled(true);
|
||||
m_fileTableView->setAlternatingRowColors(true);
|
||||
m_fileTableView->verticalHeader()->setVisible(false);
|
||||
m_fileTableView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_fileTableView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_fileTableView->horizontalHeader()->setStretchLastSection(true);
|
||||
m_fileTableView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
m_fileTableView->setWordWrap(false);
|
||||
|
||||
m_gridView->setItemDelegate(new ThumbnailDelegate(m_gridItem, this));
|
||||
m_gridView->setModel(m_proxyModel);
|
||||
|
||||
m_gridView->setSelectionModel(m_tableView->selectionModel());
|
||||
|
||||
m_logWidget->setObjectName("logWidget");
|
||||
|
||||
m_folderIcon = QIcon(QString(settings->paths.directory_assets) + GENERIC_FOLDER_ICON);
|
||||
@ -468,14 +525,23 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
QDir::Drives |
|
||||
(m_settings->value("show_hidden_files", true).toBool() ? (QDir::Hidden | QDir::System) : static_cast<QDir::Filter>(0)));
|
||||
|
||||
m_fileModel->setFilter(QDir::NoDot |
|
||||
QDir::AllEntries |
|
||||
(m_settings->value("show_hidden_files", true).toBool() ? (QDir::Hidden | QDir::System) : static_cast<QDir::Filter>(0)));
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
m_dirModel->setRootPath("");
|
||||
m_fileModel->setRootPath("");
|
||||
#else
|
||||
m_dirModel->setRootPath("/");
|
||||
m_fileModel->setRootPath("/");
|
||||
#endif
|
||||
|
||||
m_dirTree->setModel(m_dirModel);
|
||||
m_dirTree->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_dirTree->header()->setVisible(false);
|
||||
|
||||
m_fileTableView->setModel(m_proxyFileModel);
|
||||
|
||||
if (m_dirModel->columnCount() > 3)
|
||||
{
|
||||
@ -487,10 +553,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
m_dirTree->hideColumn(3);
|
||||
}
|
||||
|
||||
m_dirTree->setCurrentIndex(m_dirModel->index(settings->paths.directory_menu_content));
|
||||
m_dirTree->scrollTo(m_dirTree->currentIndex(), QAbstractItemView::PositionAtTop);
|
||||
m_dirTree->expand(m_dirTree->currentIndex());
|
||||
|
||||
reloadPlaylists();
|
||||
|
||||
m_searchWidget->setLayout(new QHBoxLayout());
|
||||
@ -501,6 +563,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
m_searchDock->setProperty("default_area", Qt::LeftDockWidgetArea);
|
||||
m_searchDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SEARCH));
|
||||
m_searchDock->setWidget(m_searchWidget);
|
||||
m_searchDock->setFixedHeight(m_searchDock->minimumSizeHint().height());
|
||||
|
||||
addDockWidget(static_cast<Qt::DockWidgetArea>(m_searchDock->property("default_area").toInt()), m_searchDock);
|
||||
|
||||
@ -518,6 +581,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
m_logWidget->setLayout(new QVBoxLayout());
|
||||
m_logWidget->layout()->addWidget(m_logTextEdit);
|
||||
m_logWidget->layout()->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
m_logDock->setObjectName("logDock");
|
||||
m_logDock->setProperty("default_area", Qt::BottomDockWidgetArea);
|
||||
@ -535,7 +599,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
m_dirTree->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
m_listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
m_gridLayoutWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
connect(m_searchLineEdit, SIGNAL(returnPressed()), this, SLOT(onSearchEnterPressed()));
|
||||
connect(m_searchLineEdit, SIGNAL(textEdited(const QString&)), this, SLOT(onSearchLineEditEdited(const QString&)));
|
||||
@ -554,9 +617,12 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(onZoomValueChanged(int)));
|
||||
connect(viewTypeIconsAction, SIGNAL(triggered()), this, SLOT(onIconViewClicked()));
|
||||
connect(viewTypeListAction, SIGNAL(triggered()), this, SLOT(onListViewClicked()));
|
||||
connect(m_gridLayoutWidget, SIGNAL(filesDropped(QStringList)), this, SLOT(onPlaylistFilesDropped(QStringList)));
|
||||
connect(m_gridLayoutWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(onFileDropWidgetContextMenuRequested(const QPoint&)));
|
||||
connect(m_dirModel, SIGNAL(directoryLoaded(const QString&)), this, SLOT(onFileSystemDirLoaded(const QString&)));
|
||||
connect(m_fileModel, SIGNAL(directoryLoaded(const QString&)), this, SLOT(onFileBrowserTableDirLoaded(const QString&)));
|
||||
|
||||
m_dirTree->setCurrentIndex(m_dirModel->index(settings->paths.directory_menu_content));
|
||||
m_dirTree->scrollTo(m_dirTree->currentIndex(), QAbstractItemView::PositionAtTop);
|
||||
m_dirTree->expand(m_dirTree->currentIndex());
|
||||
|
||||
/* must use queued connection */
|
||||
connect(this, SIGNAL(scrollToDownloads(QString)), this, SLOT(onDownloadScroll(QString)), Qt::QueuedConnection);
|
||||
@ -581,14 +647,12 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
/* TODO: Handle scroll and resize differently. */
|
||||
connect(m_gridView, SIGNAL(visibleItemsChangedMaybe()), this, SLOT(startTimer()));
|
||||
|
||||
connect(m_gridView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(currentItemChanged(const QModelIndex&)));
|
||||
connect(m_tableView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(currentItemChanged(const QModelIndex&)));
|
||||
|
||||
connect(m_gridView->selectionModel(), SIGNAL(currentChanged(const QModelIndex& , const QModelIndex&)), this, SLOT(currentItemChanged(const QModelIndex&)));
|
||||
connect(m_tableView->selectionModel(), SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(currentItemChanged(const QModelIndex&)));
|
||||
connect(m_tableView->selectionModel(), SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(onCurrentItemChanged(const QModelIndex&)));
|
||||
connect(m_fileTableView->selectionModel(), SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(onCurrentFileChanged(const QModelIndex&)));
|
||||
|
||||
connect(m_gridView, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(onContentItemDoubleClicked(const QModelIndex&)));
|
||||
connect(m_tableView, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(onContentItemDoubleClicked(const QModelIndex&)));
|
||||
connect(m_fileTableView, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(onFileDoubleClicked(const QModelIndex&)));
|
||||
|
||||
connect(m_playlistModel, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)), this, SLOT(onCurrentTableItemDataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)));
|
||||
|
||||
@ -665,7 +729,7 @@ void MainWindow::startTimer() {
|
||||
}
|
||||
|
||||
void MainWindow::updateVisibleItems() {
|
||||
if (m_viewType == VIEW_TYPE_ICONS)
|
||||
if (m_currentBrowser == BROWSER_TYPE_PLAYLISTS && m_viewType == VIEW_TYPE_ICONS)
|
||||
{
|
||||
QVector<QModelIndex> indexes = m_gridView->visibleIndexes();
|
||||
int i;
|
||||
@ -697,6 +761,15 @@ void MainWindow::onFileSystemDirLoaded(const QString &path)
|
||||
}
|
||||
}
|
||||
|
||||
/* workaround for columns being resized */
|
||||
void MainWindow::onFileBrowserTableDirLoaded(const QString &path)
|
||||
{
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
|
||||
m_fileTableView->horizontalHeader()->restoreState(m_fileTableHeaderState);
|
||||
}
|
||||
|
||||
QVector<QPair<QString, QString> > MainWindow::getPlaylists()
|
||||
{
|
||||
QVector<QPair<QString, QString> > playlists;
|
||||
@ -728,7 +801,7 @@ void MainWindow::onItemChanged()
|
||||
{
|
||||
QModelIndex index = getCurrentContentIndex();
|
||||
m_playlistModel->reloadThumbnail(index);
|
||||
currentItemChanged(index);
|
||||
onCurrentItemChanged(index);
|
||||
}
|
||||
|
||||
QString MainWindow::getSpecialPlaylistPath(SpecialPlaylist playlist)
|
||||
@ -742,20 +815,24 @@ QString MainWindow::getSpecialPlaylistPath(SpecialPlaylist playlist)
|
||||
}
|
||||
}
|
||||
|
||||
double MainWindow::lerp(double x, double y, double a, double b, double d) {
|
||||
return a + (b - a) * ((double)(d - x) / (double)(y - x));
|
||||
double MainWindow::lerp(double x, double y, double a, double b, double d)
|
||||
{
|
||||
return a + (b - a) * ((double)(d - x) / (double)(y - x));
|
||||
}
|
||||
|
||||
void MainWindow::onIconViewClicked()
|
||||
{
|
||||
setCurrentViewType(VIEW_TYPE_ICONS);
|
||||
onCurrentListItemChanged(m_listWidget->currentItem(), NULL);
|
||||
}
|
||||
|
||||
void MainWindow::onListViewClicked()
|
||||
{
|
||||
setCurrentViewType(VIEW_TYPE_LIST);
|
||||
onCurrentListItemChanged(m_listWidget->currentItem(), NULL);
|
||||
}
|
||||
|
||||
void MainWindow::setIconViewZoom(int zoomValue)
|
||||
{
|
||||
m_zoomSlider->setValue(zoomValue);
|
||||
}
|
||||
|
||||
void MainWindow::onZoomValueChanged(int zoomValue)
|
||||
@ -988,8 +1065,8 @@ void MainWindow::onGotStatusMessage(QString msg, unsigned priority, unsigned dur
|
||||
|
||||
Q_UNUSED(priority)
|
||||
|
||||
if (msg.isEmpty())
|
||||
return;
|
||||
if (msg.isEmpty())
|
||||
return;
|
||||
|
||||
if (!status)
|
||||
return;
|
||||
@ -1495,9 +1572,37 @@ void MainWindow::onTreeViewItemsSelected(QModelIndexList selectedIndexes)
|
||||
selectBrowserDir(dir);
|
||||
}
|
||||
|
||||
void MainWindow::onFileDoubleClicked(const QModelIndex &proxyIndex)
|
||||
{
|
||||
const QModelIndex index = m_proxyFileModel->mapToSource(proxyIndex);
|
||||
|
||||
if (m_fileModel->isDir(index))
|
||||
m_dirTree->setCurrentIndex(m_dirModel->index(m_fileModel->filePath(index)));
|
||||
else
|
||||
loadContent(getFileContentHash(index));
|
||||
}
|
||||
|
||||
void MainWindow::selectBrowserDir(QString path)
|
||||
{
|
||||
m_playlistModel->addDir(path, m_settings->value("show_hidden_files", true).toBool() ? (QDir::Hidden | QDir::System) : static_cast<QDir::Filter>(0));
|
||||
if (!path.isEmpty())
|
||||
{
|
||||
QModelIndex sourceIndex = m_fileModel->setRootPath(path);
|
||||
QModelIndex proxyIndex = m_proxyFileModel->mapFromSource(sourceIndex);
|
||||
m_fileTableHeaderState = m_fileTableView->horizontalHeader()->saveState();
|
||||
|
||||
if (proxyIndex.isValid())
|
||||
{
|
||||
m_fileTableView->setRootIndex(proxyIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* the directory is filtered out. Remove the filter for a moment. FIXME find a way to not have to do this (not filtering dirs is one). */
|
||||
m_proxyFileModel->setFilterRegExp(QRegExp());
|
||||
m_fileTableView->setRootIndex(m_proxyFileModel->mapFromSource(sourceIndex));
|
||||
m_proxyFileModel->setFilterRegExp(m_searchRegExp);
|
||||
}
|
||||
}
|
||||
setCoreActions();
|
||||
}
|
||||
|
||||
QTabWidget* MainWindow::browserAndPlaylistTabWidget()
|
||||
@ -1536,6 +1641,19 @@ QHash<QString, QString> MainWindow::getCurrentContentHash()
|
||||
return getCurrentContentIndex().data(PlaylistModel::HASH).value<QHash<QString, QString> >();
|
||||
}
|
||||
|
||||
QHash<QString, QString> MainWindow::getFileContentHash(const QModelIndex &index)
|
||||
{
|
||||
QFileInfo fileInfo = m_fileModel->fileInfo(index);
|
||||
QHash<QString, QString> hash;
|
||||
|
||||
hash["path"] = m_fileModel->filePath(index);;
|
||||
hash["label"] = hash["path"];
|
||||
hash["label_noext"] = fileInfo.completeBaseName();
|
||||
hash["db_name"] = fileInfo.dir().dirName();
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
void MainWindow::onContentItemDoubleClicked(const QModelIndex &index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
@ -1768,11 +1886,21 @@ void MainWindow::loadContent(const QHash<QString, QString> &contentHash)
|
||||
|
||||
void MainWindow::onRunClicked()
|
||||
{
|
||||
QHash<QString, QString> contentHash = getCurrentContentHash();
|
||||
|
||||
QHash<QString, QString> contentHash;
|
||||
|
||||
switch (m_currentBrowser)
|
||||
{
|
||||
case BROWSER_TYPE_FILES:
|
||||
contentHash = getFileContentHash(m_proxyFileModel->mapToSource(m_fileTableView->currentIndex()));
|
||||
break;
|
||||
case BROWSER_TYPE_PLAYLISTS:
|
||||
contentHash = getCurrentContentHash();
|
||||
break;
|
||||
}
|
||||
|
||||
if (contentHash.isEmpty())
|
||||
return;
|
||||
|
||||
|
||||
loadContent(contentHash);
|
||||
}
|
||||
|
||||
@ -1806,6 +1934,7 @@ void MainWindow::setCoreActions()
|
||||
QListWidgetItem *currentPlaylistItem = m_listWidget->currentItem();
|
||||
ViewType viewType = getCurrentViewType();
|
||||
QHash<QString, QString> hash = getCurrentContentHash();
|
||||
QString currentPlaylistFileName = QString();
|
||||
|
||||
m_launchWithComboBox->clear();
|
||||
|
||||
@ -1823,7 +1952,7 @@ void MainWindow::setCoreActions()
|
||||
m_launchWithComboBox->addItem(m_currentCore, QVariant::fromValue(comboBoxMap));
|
||||
}
|
||||
|
||||
if (m_browserAndPlaylistTabWidget->tabText(m_browserAndPlaylistTabWidget->currentIndex()) == msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS))
|
||||
if (m_currentBrowser == BROWSER_TYPE_PLAYLISTS)
|
||||
{
|
||||
if (!hash.isEmpty())
|
||||
{
|
||||
@ -1869,7 +1998,17 @@ void MainWindow::setCoreActions()
|
||||
}
|
||||
}
|
||||
|
||||
if (!hash["db_name"].isEmpty())
|
||||
switch(m_currentBrowser)
|
||||
{
|
||||
case BROWSER_TYPE_PLAYLISTS:
|
||||
currentPlaylistFileName = hash["db_name"];
|
||||
break;
|
||||
case BROWSER_TYPE_FILES:
|
||||
currentPlaylistFileName = m_fileModel->rootDirectory().dirName();
|
||||
break;
|
||||
}
|
||||
|
||||
if (!currentPlaylistFileName.isEmpty())
|
||||
{
|
||||
QVector<QHash<QString, QString> > defaultCores = getPlaylistDefaultCores();
|
||||
int i = 0;
|
||||
@ -1904,7 +2043,6 @@ void MainWindow::setCoreActions()
|
||||
{
|
||||
QString playlist = defaultCores.at(i)["playlist_filename"];
|
||||
QString core = defaultCores.at(i)["core_path"];
|
||||
QString currentPlaylistFileName = hash["db_name"];
|
||||
|
||||
playlist.remove(file_path_str(FILE_PATH_LPL_EXTENSION));
|
||||
|
||||
@ -1972,35 +2110,25 @@ void MainWindow::setCoreActions()
|
||||
|
||||
void MainWindow::onTabWidgetIndexChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index)
|
||||
|
||||
if (m_browserAndPlaylistTabWidget->tabText(m_browserAndPlaylistTabWidget->currentIndex()) == msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_FILE_BROWSER))
|
||||
if (m_browserAndPlaylistTabWidget->tabText(index) == msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_FILE_BROWSER))
|
||||
{
|
||||
QModelIndex index = m_dirTree->currentIndex();
|
||||
m_currentBrowser = BROWSER_TYPE_FILES;
|
||||
|
||||
/* force list view for file browser, will set it back to whatever the user had when switching back to playlist tab */
|
||||
setCurrentViewType(VIEW_TYPE_LIST);
|
||||
m_centralWidget->setCurrentWidget(m_fileTableView);
|
||||
|
||||
if (index.isValid())
|
||||
{
|
||||
m_dirTree->clearSelection();
|
||||
m_dirTree->setCurrentIndex(index);
|
||||
}
|
||||
onCurrentFileChanged(m_fileTableView->currentIndex());
|
||||
}
|
||||
else if (m_browserAndPlaylistTabWidget->tabText(m_browserAndPlaylistTabWidget->currentIndex()) == msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS))
|
||||
else if (m_browserAndPlaylistTabWidget->tabText(index) == msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS))
|
||||
{
|
||||
QListWidgetItem *item = m_listWidget->currentItem();
|
||||
m_currentBrowser = BROWSER_TYPE_PLAYLISTS;
|
||||
|
||||
if (m_lastViewType != getCurrentViewType())
|
||||
setCurrentViewType(m_lastViewType);
|
||||
m_centralWidget->setCurrentWidget(m_playlistViewsAndFooter);
|
||||
|
||||
if (item)
|
||||
{
|
||||
m_listWidget->setCurrentItem(NULL);
|
||||
m_listWidget->setCurrentItem(item);
|
||||
}
|
||||
onCurrentItemChanged(m_tableView->currentIndex());
|
||||
}
|
||||
|
||||
applySearch();
|
||||
|
||||
setCoreActions();
|
||||
}
|
||||
|
||||
@ -2030,7 +2158,6 @@ void MainWindow::onSearchLineEditEdited(const QString &text)
|
||||
QVector<unsigned> textUnicode = text.toUcs4();
|
||||
QVector<unsigned> textHiraToKata;
|
||||
QVector<unsigned> textKataToHira;
|
||||
ViewType viewType = getCurrentViewType();
|
||||
bool foundHira = false;
|
||||
bool foundKata = false;
|
||||
|
||||
@ -2057,19 +2184,41 @@ void MainWindow::onSearchLineEditEdited(const QString &text)
|
||||
|
||||
if (!foundHira && !foundKata)
|
||||
{
|
||||
m_proxyModel->setFilterRegExp(QRegExp(text, Qt::CaseInsensitive));
|
||||
m_searchRegExp = QRegExp(text, Qt::CaseInsensitive);
|
||||
}
|
||||
else if (foundHira && !foundKata)
|
||||
{
|
||||
m_proxyModel->setFilterRegExp(QRegExp(text + "|" + QString::fromUcs4(textHiraToKata.constData(), textHiraToKata.size()), Qt::CaseInsensitive));
|
||||
m_searchRegExp = QRegExp(text + "|" + QString::fromUcs4(textHiraToKata.constData(), textHiraToKata.size()), Qt::CaseInsensitive);
|
||||
}
|
||||
else if (!foundHira && foundKata)
|
||||
{
|
||||
m_proxyModel->setFilterRegExp(QRegExp(text + "|" + QString::fromUcs4(textKataToHira.constData(), textKataToHira.size()), Qt::CaseInsensitive));
|
||||
m_searchRegExp = QRegExp(text + "|" + QString::fromUcs4(textKataToHira.constData(), textKataToHira.size()), Qt::CaseInsensitive);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_proxyModel->setFilterRegExp(QRegExp(text + "|" + QString::fromUcs4(textHiraToKata.constData(), textHiraToKata.size()) + "|" + QString::fromUcs4(textKataToHira.constData(), textKataToHira.size()), Qt::CaseInsensitive));
|
||||
m_searchRegExp = QRegExp(text + "|" + QString::fromUcs4(textHiraToKata.constData(), textHiraToKata.size()) + "|" + QString::fromUcs4(textKataToHira.constData(), textKataToHira.size()), Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
applySearch();
|
||||
}
|
||||
|
||||
void MainWindow::applySearch()
|
||||
{
|
||||
switch (m_currentBrowser)
|
||||
{
|
||||
case BROWSER_TYPE_PLAYLISTS:
|
||||
if (m_proxyModel->filterRegExp() != m_searchRegExp)
|
||||
{
|
||||
m_proxyModel->setFilterRegExp(m_searchRegExp);
|
||||
updateItemsCount();
|
||||
}
|
||||
break;
|
||||
case BROWSER_TYPE_FILES:
|
||||
if (m_proxyFileModel->filterRegExp() != m_searchRegExp)
|
||||
{
|
||||
m_proxyFileModel->setFilterRegExp(m_searchRegExp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2159,7 +2308,7 @@ void MainWindow::onCurrentTableItemDataChanged(const QModelIndex &topLeft, const
|
||||
|
||||
updateCurrentPlaylistEntry(hash);
|
||||
|
||||
currentItemChanged(topLeft);
|
||||
onCurrentItemChanged(topLeft);
|
||||
}
|
||||
|
||||
void MainWindow::onCurrentListItemDataChanged(QListWidgetItem *item)
|
||||
@ -2234,7 +2383,17 @@ void MainWindow::renamePlaylistItem(QListWidgetItem *item, QString newName)
|
||||
connect(m_listWidget, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(onCurrentListItemDataChanged(QListWidgetItem*)));
|
||||
}
|
||||
|
||||
void MainWindow::currentItemChanged(const QModelIndex &index)
|
||||
void MainWindow::onCurrentItemChanged(const QModelIndex &index)
|
||||
{
|
||||
onCurrentItemChanged(index.data(PlaylistModel::HASH).value<QHash<QString, QString>>());
|
||||
}
|
||||
|
||||
void MainWindow::onCurrentFileChanged(const QModelIndex &index)
|
||||
{
|
||||
onCurrentItemChanged(getFileContentHash(m_proxyFileModel->mapToSource(index)));
|
||||
}
|
||||
|
||||
void MainWindow::onCurrentItemChanged(const QHash<QString, QString> &hash)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
QString label;
|
||||
@ -2243,8 +2402,6 @@ void MainWindow::currentItemChanged(const QModelIndex &index)
|
||||
QString extensionStr;
|
||||
int lastIndex = -1;
|
||||
|
||||
const QHash<QString, QString> &hash = index.data(PlaylistModel::HASH).value<QHash<QString, QString>>();
|
||||
|
||||
label = hash["label_noext"];
|
||||
label.replace(m_fileSanitizerRegex, "_");
|
||||
|
||||
@ -2362,23 +2519,21 @@ void MainWindow::resizeThumbnails(bool one, bool two, bool three)
|
||||
|
||||
void MainWindow::setCurrentViewType(ViewType viewType)
|
||||
{
|
||||
m_lastViewType = m_viewType;
|
||||
m_viewType = viewType;
|
||||
|
||||
switch (viewType)
|
||||
{
|
||||
case VIEW_TYPE_ICONS:
|
||||
{
|
||||
m_tableView->hide();
|
||||
m_gridWidget->show();
|
||||
m_playlistViews->setCurrentWidget(m_gridView);
|
||||
m_zoomWidget->show();
|
||||
break;
|
||||
}
|
||||
case VIEW_TYPE_LIST:
|
||||
default:
|
||||
{
|
||||
m_viewType = VIEW_TYPE_LIST;
|
||||
m_gridWidget->hide();
|
||||
m_tableView->show();
|
||||
m_playlistViews->setCurrentWidget(m_tableView);
|
||||
m_zoomWidget->hide();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2386,7 +2541,6 @@ void MainWindow::setCurrentViewType(ViewType viewType)
|
||||
|
||||
void MainWindow::setCurrentThumbnailType(ThumbnailType thumbnailType)
|
||||
{
|
||||
m_lastThumbnailType = m_thumbnailType;
|
||||
m_thumbnailType = thumbnailType;
|
||||
|
||||
m_playlistModel->setThumbnailType(thumbnailType);
|
||||
@ -2409,9 +2563,6 @@ void MainWindow::onCurrentListItemChanged(QListWidgetItem *current, QListWidgetI
|
||||
Q_UNUSED(current)
|
||||
Q_UNUSED(previous)
|
||||
|
||||
if (m_browserAndPlaylistTabWidget->tabText(m_browserAndPlaylistTabWidget->currentIndex()) != msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS))
|
||||
return;
|
||||
|
||||
initContentTableWidget();
|
||||
|
||||
setCoreActions();
|
||||
@ -2422,9 +2573,24 @@ TableView* MainWindow::contentTableView()
|
||||
return m_tableView;
|
||||
}
|
||||
|
||||
QWidget* MainWindow::contentGridWidget()
|
||||
QTableView* MainWindow::fileTableView()
|
||||
{
|
||||
return m_gridWidget;
|
||||
return m_fileTableView;
|
||||
}
|
||||
|
||||
QStackedWidget* MainWindow::centralWidget()
|
||||
{
|
||||
return m_centralWidget;
|
||||
}
|
||||
|
||||
FileDropWidget* MainWindow::playlistViews()
|
||||
{
|
||||
return m_playlistViews;
|
||||
}
|
||||
|
||||
QWidget* MainWindow::playlistViewsAndFooter()
|
||||
{
|
||||
return m_playlistViewsAndFooter;
|
||||
}
|
||||
|
||||
GridView* MainWindow::contentGridView()
|
||||
@ -2641,9 +2807,7 @@ void MainWindow::onLoadCoreClicked(const QStringList &extensionFilters)
|
||||
void MainWindow::initContentTableWidget()
|
||||
{
|
||||
QListWidgetItem *item = m_listWidget->currentItem();
|
||||
QStringList horizontal_header_labels;
|
||||
QString path;
|
||||
QModelIndex index;
|
||||
int i = 0;
|
||||
|
||||
if (!item)
|
||||
@ -2660,12 +2824,6 @@ void MainWindow::initContentTableWidget()
|
||||
|
||||
m_currentGridWidget = NULL;
|
||||
|
||||
m_tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_tableView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_tableView->setEditTriggers(QAbstractItemView::SelectedClicked | QAbstractItemView::EditKeyPressed);
|
||||
m_tableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
m_tableView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
|
||||
path = item->data(Qt::UserRole).toString();
|
||||
|
||||
if (path == ALL_PLAYLISTS_TOKEN)
|
||||
@ -2691,13 +2849,15 @@ void MainWindow::initContentTableWidget()
|
||||
else
|
||||
m_proxyModel->sort(-1);
|
||||
|
||||
m_tableView->resizeColumnsToContents();
|
||||
updateItemsCount();
|
||||
|
||||
index = m_proxyModel->index(0, 0);
|
||||
m_gridView->scrollToTop();
|
||||
m_gridView->setCurrentIndex(index);
|
||||
m_tableView->setCurrentIndex(index);
|
||||
currentItemChanged(index);
|
||||
m_gridView->setCurrentIndex(m_proxyModel->index(0, 0));
|
||||
}
|
||||
|
||||
void MainWindow::updateItemsCount()
|
||||
{
|
||||
m_itemsCountLabel->setText(m_itemsCountLiteral.arg(m_proxyModel->rowCount()));
|
||||
}
|
||||
|
||||
void MainWindow::keyPressEvent(QKeyEvent *event)
|
||||
@ -2781,6 +2941,8 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
m_settings->setValue("last_tab", m_browserAndPlaylistTabWidget->currentIndex());
|
||||
|
||||
m_settings->setValue("view_type", getCurrentViewTypeString());
|
||||
m_settings->setValue("file_browser_table_headers", m_fileTableView->horizontalHeader()->saveState());
|
||||
m_settings->setValue("icon_view_zoom", m_lastZoomSliderValue);
|
||||
|
||||
QMainWindow::closeEvent(event);
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ui_qt.h"
|
||||
#include "qt/filedropwidget.h"
|
||||
#include "qt/viewoptionsdialog.h"
|
||||
|
||||
#include <QApplication>
|
||||
@ -225,6 +224,7 @@ static void* ui_companion_qt_init(void)
|
||||
MainWindow *mainwindow = NULL;
|
||||
QHBoxLayout *browserButtonsHBoxLayout = NULL;
|
||||
QVBoxLayout *layout = NULL;
|
||||
QVBoxLayout *playlistViewsLayout = NULL;
|
||||
QVBoxLayout *launchWithWidgetLayout = NULL;
|
||||
QHBoxLayout *coreComboBoxLayout = NULL;
|
||||
QMenuBar *menu = NULL;
|
||||
@ -245,9 +245,10 @@ static void* ui_companion_qt_init(void)
|
||||
QDockWidget *browserAndPlaylistTabDock = NULL;
|
||||
QDockWidget *coreSelectionDock = NULL;
|
||||
QTabWidget *browserAndPlaylistTabWidget = NULL;
|
||||
QWidget *widget = NULL;
|
||||
QWidget *browserWidget = NULL;
|
||||
QWidget *playlistWidget = NULL;
|
||||
QStackedWidget *centralWidget = NULL;
|
||||
QStackedWidget *widget = NULL;
|
||||
QFrame *browserWidget = NULL;
|
||||
QFrame *playlistWidget = NULL;
|
||||
QWidget *coreSelectionWidget = NULL;
|
||||
QWidget *launchWithWidget = NULL;
|
||||
ThumbnailWidget *thumbnailWidget = NULL;
|
||||
@ -294,8 +295,7 @@ static void* ui_companion_qt_init(void)
|
||||
|
||||
listWidget = mainwindow->playlistListWidget();
|
||||
|
||||
widget = new FileDropWidget(mainwindow);
|
||||
widget->setObjectName("tableWidget");
|
||||
widget = mainwindow->playlistViews();
|
||||
widget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
QObject::connect(widget, SIGNAL(filesDropped(QStringList)), mainwindow, SLOT(onPlaylistFilesDropped(QStringList)));
|
||||
@ -303,13 +303,12 @@ static void* ui_companion_qt_init(void)
|
||||
QObject::connect(widget, SIGNAL(deletePressed()), mainwindow, SLOT(deleteCurrentPlaylistItem()));
|
||||
QObject::connect(widget, SIGNAL(customContextMenuRequested(const QPoint&)), mainwindow, SLOT(onFileDropWidgetContextMenuRequested(const QPoint&)));
|
||||
|
||||
layout = new QVBoxLayout();
|
||||
layout->addWidget(mainwindow->contentTableView());
|
||||
layout->addWidget(mainwindow->contentGridWidget());
|
||||
centralWidget = mainwindow->centralWidget();
|
||||
|
||||
widget->setLayout(layout);
|
||||
centralWidget->addWidget(mainwindow->playlistViewsAndFooter());
|
||||
centralWidget->addWidget(mainwindow->fileTableView());
|
||||
|
||||
mainwindow->setCentralWidget(widget);
|
||||
mainwindow->setCentralWidget(centralWidget);
|
||||
|
||||
menu = mainwindow->menuBar();
|
||||
|
||||
@ -355,15 +354,17 @@ static void* ui_companion_qt_init(void)
|
||||
helpMenu->addAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_HELP_ABOUT)) + "...", mainwindow, SLOT(showAbout()));
|
||||
helpMenu->addAction("About Qt...", qApp, SLOT(aboutQt()));
|
||||
|
||||
playlistWidget = new QWidget();
|
||||
playlistWidget = new QFrame();
|
||||
playlistWidget->setLayout(new QVBoxLayout());
|
||||
playlistWidget->setObjectName("playlistWidget");
|
||||
playlistWidget->layout()->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
playlistWidget->layout()->addWidget(mainwindow->playlistListWidget());
|
||||
|
||||
browserWidget = new QWidget();
|
||||
browserWidget = new QFrame();
|
||||
browserWidget->setLayout(new QVBoxLayout());
|
||||
browserWidget->setObjectName("browserWidget");
|
||||
browserWidget->layout()->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
browserDownloadsButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_ASSETS_DIRECTORY));
|
||||
browserUpButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_FILE_BROWSER_UP));
|
||||
@ -502,6 +503,7 @@ static void* ui_companion_qt_init(void)
|
||||
coreSelectionDock->setProperty("default_area", Qt::LeftDockWidgetArea);
|
||||
coreSelectionDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE));
|
||||
coreSelectionDock->setWidget(coreSelectionWidget);
|
||||
coreSelectionDock->setFixedHeight(coreSelectionDock->minimumSizeHint().height());
|
||||
|
||||
mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(coreSelectionDock->property("default_area").toInt()), coreSelectionDock);
|
||||
|
||||
@ -533,6 +535,14 @@ static void* ui_companion_qt_init(void)
|
||||
if (qsettings->contains("dock_positions"))
|
||||
mainwindow->restoreState(qsettings->value("dock_positions").toByteArray());
|
||||
|
||||
if (qsettings->contains("file_browser_table_headers"))
|
||||
mainwindow->fileTableView()->horizontalHeader()->restoreState(qsettings->value("file_browser_table_headers").toByteArray());
|
||||
else
|
||||
mainwindow->fileTableView()->horizontalHeader()->resizeSection(0, 300);
|
||||
|
||||
if (qsettings->contains("icon_view_zoom"))
|
||||
mainwindow->setIconViewZoom(qsettings->value("icon_view_zoom", 50).toInt());
|
||||
|
||||
if (qsettings->contains("theme"))
|
||||
{
|
||||
QString themeStr = qsettings->value("theme").toString();
|
||||
@ -560,9 +570,6 @@ static void* ui_companion_qt_init(void)
|
||||
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);
|
||||
@ -579,12 +586,7 @@ static void* ui_companion_qt_init(void)
|
||||
mainwindow->setCurrentThumbnailType(THUMBNAIL_TYPE_TITLE_SCREEN);
|
||||
else
|
||||
mainwindow->setCurrentThumbnailType(THUMBNAIL_TYPE_BOXART);
|
||||
|
||||
/* we set it to the same thing a second time so that m_lastThumbnailType is also equal to the startup view type */
|
||||
mainwindow->setCurrentThumbnailType(mainwindow->getCurrentThumbnailType());
|
||||
}
|
||||
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.
|
||||
@ -642,6 +644,8 @@ static void* ui_companion_qt_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
mainwindow->initContentTableWidget();
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,9 @@
|
||||
#include <QCache>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QDir>
|
||||
#include <QStackedWidget>
|
||||
|
||||
#include "qt/filedropwidget.h"
|
||||
|
||||
#ifndef CXX_BUILD
|
||||
extern "C" {
|
||||
@ -194,11 +197,11 @@ protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
private:
|
||||
void updateMargins();
|
||||
void updateMargins();
|
||||
|
||||
QPixmap *m_pixmap;
|
||||
int m_pixmapWidth;
|
||||
int m_pixmapHeight;
|
||||
QPixmap *m_pixmap;
|
||||
int m_pixmapWidth;
|
||||
int m_pixmapHeight;
|
||||
};
|
||||
|
||||
class TreeView : public QTreeView
|
||||
@ -297,6 +300,13 @@ public:
|
||||
void setThumbnailVerticalAlign(const QString valign);
|
||||
};
|
||||
|
||||
class FileSystemProxyModel : public QSortFilterProxyModel
|
||||
{
|
||||
protected:
|
||||
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
||||
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
|
||||
};
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -308,6 +318,12 @@ public:
|
||||
VIEW_TYPE_LIST
|
||||
};
|
||||
|
||||
enum BrowserType
|
||||
{
|
||||
BROWSER_TYPE_PLAYLISTS,
|
||||
BROWSER_TYPE_FILES
|
||||
};
|
||||
|
||||
enum Theme
|
||||
{
|
||||
THEME_SYSTEM_DEFAULT,
|
||||
@ -329,9 +345,12 @@ public:
|
||||
TreeView* dirTreeView();
|
||||
PlaylistModel* playlistModel();
|
||||
ListWidget* playlistListWidget();
|
||||
QStackedWidget* centralWidget();
|
||||
TableView* contentTableView();
|
||||
QTableView* fileTableView();
|
||||
FileDropWidget* playlistViews();
|
||||
GridView* contentGridView();
|
||||
QWidget* contentGridWidget();
|
||||
QWidget* playlistViewsAndFooter();
|
||||
QWidget* searchWidget();
|
||||
QLineEdit* searchLineEdit();
|
||||
QComboBox* launchWithComboBox();
|
||||
@ -369,11 +388,13 @@ public:
|
||||
QString getCurrentPlaylistPath();
|
||||
QModelIndex getCurrentContentIndex();
|
||||
QHash<QString, QString> getCurrentContentHash();
|
||||
QHash<QString, QString> getFileContentHash(const QModelIndex &index);
|
||||
static double lerp(double x, double y, double a, double b, double d);
|
||||
QString getSpecialPlaylistPath(SpecialPlaylist playlist);
|
||||
QVector<QPair<QString, QString> > getPlaylists();
|
||||
QString getScrubbedString(QString str);
|
||||
void setDefaultCustomProperties();
|
||||
void setIconViewZoom(int zoomValue);
|
||||
|
||||
signals:
|
||||
void thumbnailChanged(const QPixmap &pixmap);
|
||||
@ -445,10 +466,13 @@ private slots:
|
||||
void onCurrentTableItemDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
|
||||
void onCurrentListItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
|
||||
void onCurrentListItemDataChanged(QListWidgetItem *item);
|
||||
void currentItemChanged(const QModelIndex &index);
|
||||
void onCurrentItemChanged(const QModelIndex &index);
|
||||
void onCurrentItemChanged(const QHash<QString, QString> &hash);
|
||||
void onCurrentFileChanged(const QModelIndex &index);
|
||||
void onSearchEnterPressed();
|
||||
void onSearchLineEditEdited(const QString &text);
|
||||
void onContentItemDoubleClicked(const QModelIndex &index);
|
||||
void onFileDoubleClicked(const QModelIndex &index);
|
||||
void onCoreLoadWindowClosed();
|
||||
void onTreeViewItemsSelected(QModelIndexList selectedIndexes);
|
||||
void onSearchResetClicked();
|
||||
@ -465,6 +489,7 @@ private slots:
|
||||
void onContributorsClicked();
|
||||
void onItemChanged();
|
||||
void onFileSystemDirLoaded(const QString &path);
|
||||
void onFileBrowserTableDirLoaded(const QString &path);
|
||||
void onDownloadScroll(QString path);
|
||||
void onDownloadScrollAgain(QString path);
|
||||
int onExtractArchive(QString path, QString extractionDir, QString tempExtension, retro_task_callback_t cb);
|
||||
@ -513,9 +538,12 @@ private:
|
||||
void renamePlaylistItem(QListWidgetItem *item, QString newName);
|
||||
bool currentPlaylistIsSpecial();
|
||||
bool currentPlaylistIsAll();
|
||||
void applySearch();
|
||||
void updateItemsCount();
|
||||
|
||||
PlaylistModel *m_playlistModel;
|
||||
QSortFilterProxyModel *m_proxyModel;
|
||||
FileSystemProxyModel *m_proxyFileModel;
|
||||
LoadCoreWindow *m_loadCoreWindow;
|
||||
QTimer *m_timer;
|
||||
QString m_currentCore;
|
||||
@ -523,8 +551,12 @@ private:
|
||||
QLabel *m_statusLabel;
|
||||
TreeView *m_dirTree;
|
||||
QFileSystemModel *m_dirModel;
|
||||
QFileSystemModel *m_fileModel;
|
||||
ListWidget *m_listWidget;
|
||||
QStackedWidget *m_centralWidget;
|
||||
TableView *m_tableView;
|
||||
QTableView *m_fileTableView;
|
||||
FileDropWidget *m_playlistViews;
|
||||
QWidget *m_searchWidget;
|
||||
QLineEdit *m_searchLineEdit;
|
||||
QDockWidget *m_searchDock;
|
||||
@ -550,15 +582,14 @@ private:
|
||||
CoreInfoLabel *m_coreInfoLabel;
|
||||
CoreInfoWidget *m_coreInfoWidget;
|
||||
QDockWidget *m_logDock;
|
||||
QWidget *m_logWidget;
|
||||
QFrame *m_logWidget;
|
||||
LogTextEdit *m_logTextEdit;
|
||||
QVector<QByteArray> m_imageFormats;
|
||||
QListWidgetItem *m_historyPlaylistsItem;
|
||||
QIcon m_folderIcon;
|
||||
QString m_customThemeString;
|
||||
GridView *m_gridView;
|
||||
QWidget *m_gridWidget;
|
||||
QScrollArea *m_gridScrollArea;
|
||||
QWidget *m_playlistViewsAndFooter;
|
||||
QWidget *m_gridLayoutWidget;
|
||||
QSlider *m_zoomSlider;
|
||||
int m_lastZoomSliderValue;
|
||||
@ -567,8 +598,6 @@ private:
|
||||
QProgressBar *m_gridProgressBar;
|
||||
QWidget *m_gridProgressWidget;
|
||||
QHash<QString, QString> m_currentGridHash;
|
||||
ViewType m_lastViewType;
|
||||
ThumbnailType m_lastThumbnailType;
|
||||
QPointer<ThumbnailWidget> m_currentGridWidget;
|
||||
int m_allPlaylistsListMaxCount;
|
||||
int m_allPlaylistsGridMaxCount;
|
||||
@ -602,6 +631,12 @@ private:
|
||||
|
||||
QTimer *m_thumbnailTimer;
|
||||
GridItem m_gridItem;
|
||||
BrowserType m_currentBrowser;
|
||||
QRegExp m_searchRegExp;
|
||||
QByteArray m_fileTableHeaderState;
|
||||
QWidget *m_zoomWidget;
|
||||
QString m_itemsCountLiteral;
|
||||
QLabel *m_itemsCountLabel;
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
Loading…
x
Reference in New Issue
Block a user