mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 08:30:16 +00:00
Merge pull request #8130 from CozmoP/thumbnail
Qt: thumbnails drop indicator
This commit is contained in:
commit
6c42d87303
@ -12,6 +12,14 @@ static const QString qt_theme_default_stylesheet = QStringLiteral(R"(
|
||||
ThumbnailWidget#thumbnailWidget, ThumbnailLabel#thumbnailGridLabel, QLabel#thumbnailQLabel {
|
||||
background-color:#d4d4d4;
|
||||
}
|
||||
|
||||
QLabel#dropIndicator {
|
||||
font-size: 9pt;
|
||||
color: darkgrey;
|
||||
border: 2px dashed lightgrey;
|
||||
border-radius: 5px;
|
||||
margin: 20px;
|
||||
}
|
||||
ThumbnailWidget#thumbnailWidgetSelected {
|
||||
background-color:#d4d4d4;
|
||||
border:3px solid %1;
|
||||
@ -41,6 +49,13 @@ static const QString qt_theme_dark_stylesheet = QStringLiteral(R"(
|
||||
ListWidget {
|
||||
icon-size: 32px;
|
||||
}
|
||||
QLabel#dropIndicator {
|
||||
font-size: 9pt;
|
||||
color: #575757;
|
||||
border: 2px dashed #575757;
|
||||
border-radius: 5px;
|
||||
margin: 20px;
|
||||
}
|
||||
QTextEdit, LogTextEdit {
|
||||
background-color:rgb(25,25,25);
|
||||
}
|
||||
|
@ -1328,7 +1328,7 @@ void MainWindow::onThumbnailDropped(const QImage &image, ThumbnailType thumbnail
|
||||
|
||||
m_thumbnailPixmap = new QPixmap(path);
|
||||
|
||||
onResizeThumbnailOne();
|
||||
onResizeThumbnailOne(*m_thumbnailPixmap, true);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1344,7 +1344,7 @@ void MainWindow::onThumbnailDropped(const QImage &image, ThumbnailType thumbnail
|
||||
|
||||
m_thumbnailPixmap2 = new QPixmap(path);
|
||||
|
||||
onResizeThumbnailTwo();
|
||||
onResizeThumbnailTwo(*m_thumbnailPixmap2, true);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1360,7 +1360,7 @@ void MainWindow::onThumbnailDropped(const QImage &image, ThumbnailType thumbnail
|
||||
|
||||
m_thumbnailPixmap3 = new QPixmap(path);
|
||||
|
||||
onResizeThumbnailThree();
|
||||
onResizeThumbnailThree(*m_thumbnailPixmap3, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2208,21 +2208,6 @@ void MainWindow::setCoreActions()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setThumbnailsAcceptDrops(bool accept)
|
||||
{
|
||||
ThumbnailWidget *thumbnail = findChild<ThumbnailWidget*>("thumbnail1Widget");
|
||||
ThumbnailWidget *thumbnail2 = findChild<ThumbnailWidget*>("thumbnail2Widget");
|
||||
ThumbnailWidget *thumbnail3 = findChild<ThumbnailWidget*>("thumbnail3Widget");
|
||||
|
||||
if (thumbnail)
|
||||
thumbnail->setAcceptDrops(accept);
|
||||
|
||||
if (thumbnail2)
|
||||
thumbnail2->setAcceptDrops(accept);
|
||||
|
||||
if (thumbnail3)
|
||||
thumbnail3->setAcceptDrops(accept);
|
||||
}
|
||||
|
||||
void MainWindow::onTabWidgetIndexChanged(int index)
|
||||
{
|
||||
@ -2512,6 +2497,7 @@ void MainWindow::onCurrentFileChanged(const QModelIndex &index)
|
||||
void MainWindow::onCurrentItemChanged(const QHash<QString, QString> &hash)
|
||||
{
|
||||
QString path = hash["path"];
|
||||
bool acceptDrop = false;
|
||||
|
||||
if (m_thumbnailPixmap)
|
||||
delete m_thumbnailPixmap;
|
||||
@ -2526,8 +2512,6 @@ void MainWindow::onCurrentItemChanged(const QHash<QString, QString> &hash)
|
||||
m_thumbnailPixmap = new QPixmap(path);
|
||||
m_thumbnailPixmap2 = new QPixmap(*m_thumbnailPixmap);
|
||||
m_thumbnailPixmap3 = new QPixmap(*m_thumbnailPixmap);
|
||||
|
||||
setThumbnailsAcceptDrops(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2538,90 +2522,38 @@ void MainWindow::onCurrentItemChanged(const QHash<QString, QString> &hash)
|
||||
m_thumbnailPixmap2 = new QPixmap(thumbnailsDir + "/" + THUMBNAIL_TITLE + "/" + thumbnailName);
|
||||
m_thumbnailPixmap3 = new QPixmap(thumbnailsDir + "/" + THUMBNAIL_SCREENSHOT + "/" + thumbnailName);
|
||||
|
||||
if (m_currentBrowser == BROWSER_TYPE_PLAYLISTS)
|
||||
{
|
||||
if (currentPlaylistIsSpecial())
|
||||
setThumbnailsAcceptDrops(false);
|
||||
else
|
||||
setThumbnailsAcceptDrops(true);
|
||||
}
|
||||
if (m_currentBrowser == BROWSER_TYPE_PLAYLISTS && !currentPlaylistIsSpecial())
|
||||
acceptDrop = true;
|
||||
}
|
||||
|
||||
resizeThumbnails(true, true, true);
|
||||
onResizeThumbnailOne(*m_thumbnailPixmap, acceptDrop);
|
||||
onResizeThumbnailTwo(*m_thumbnailPixmap2, acceptDrop);
|
||||
onResizeThumbnailThree(*m_thumbnailPixmap3, acceptDrop);
|
||||
|
||||
setCoreActions();
|
||||
}
|
||||
|
||||
void MainWindow::onResizeThumbnailOne()
|
||||
void MainWindow::setThumbnail(QString widgetName, QPixmap &pixmap, bool acceptDrop)
|
||||
{
|
||||
resizeThumbnails(true, false, false);
|
||||
ThumbnailWidget *thumbnail = findChild<ThumbnailWidget*>(widgetName);
|
||||
|
||||
if (thumbnail)
|
||||
thumbnail->setPixmap(pixmap, acceptDrop);
|
||||
}
|
||||
|
||||
void MainWindow::onResizeThumbnailTwo()
|
||||
void MainWindow::onResizeThumbnailOne(QPixmap &pixmap, bool acceptDrop)
|
||||
{
|
||||
resizeThumbnails(false, true, false);
|
||||
setThumbnail("thumbnail", pixmap, acceptDrop);
|
||||
}
|
||||
|
||||
void MainWindow::onResizeThumbnailThree()
|
||||
void MainWindow::onResizeThumbnailTwo(QPixmap &pixmap, bool acceptDrop)
|
||||
{
|
||||
resizeThumbnails(false, false, true);
|
||||
setThumbnail("thumbnail2", pixmap, acceptDrop);
|
||||
}
|
||||
|
||||
void MainWindow::resizeThumbnails(bool one, bool two, bool three)
|
||||
void MainWindow::onResizeThumbnailThree(QPixmap &pixmap, bool acceptDrop)
|
||||
{
|
||||
QPixmap pixmap;
|
||||
QPixmap pixmap2;
|
||||
QPixmap pixmap3;
|
||||
ThumbnailLabel *thumbnail = NULL;
|
||||
ThumbnailLabel *thumbnail2 = NULL;
|
||||
ThumbnailLabel *thumbnail3 = NULL;
|
||||
|
||||
if (m_thumbnailPixmap)
|
||||
pixmap = *m_thumbnailPixmap;
|
||||
if (m_thumbnailPixmap2)
|
||||
pixmap2 = *m_thumbnailPixmap2;
|
||||
if (m_thumbnailPixmap3)
|
||||
pixmap3 = *m_thumbnailPixmap3;
|
||||
|
||||
thumbnail = findChild<ThumbnailLabel*>("thumbnail");
|
||||
thumbnail2 = findChild<ThumbnailLabel*>("thumbnail2");
|
||||
thumbnail3 = findChild<ThumbnailLabel*>("thumbnail3");
|
||||
|
||||
if (thumbnail && one)
|
||||
{
|
||||
if (pixmap.isNull())
|
||||
thumbnail->hide();
|
||||
else
|
||||
{
|
||||
thumbnail->show();
|
||||
emit thumbnailChanged(pixmap);
|
||||
thumbnail->update();
|
||||
}
|
||||
}
|
||||
|
||||
if (thumbnail2 && two)
|
||||
{
|
||||
if (pixmap2.isNull())
|
||||
thumbnail2->hide();
|
||||
else
|
||||
{
|
||||
thumbnail2->show();
|
||||
emit thumbnail2Changed(pixmap2);
|
||||
thumbnail2->update();
|
||||
}
|
||||
}
|
||||
|
||||
if (thumbnail3 && three)
|
||||
{
|
||||
if (pixmap3.isNull())
|
||||
thumbnail3->hide();
|
||||
else
|
||||
{
|
||||
thumbnail3->show();
|
||||
emit thumbnail3Changed(pixmap3);
|
||||
thumbnail3->update();
|
||||
}
|
||||
}
|
||||
setThumbnail("thumbnail3", pixmap, acceptDrop);
|
||||
}
|
||||
|
||||
void MainWindow::setCurrentViewType(ViewType viewType)
|
||||
|
@ -64,52 +64,29 @@ typedef struct ui_companion_qt
|
||||
} ui_companion_qt_t;
|
||||
|
||||
ThumbnailWidget::ThumbnailWidget(ThumbnailType type, QWidget *parent) :
|
||||
QFrame(parent)
|
||||
,m_sizeHint(QSize(256, 256))
|
||||
QStackedWidget(parent)
|
||||
,m_thumbnailType(type)
|
||||
,m_thumbnailLabel(new ThumbnailLabel(this))
|
||||
,m_dropIndicator(new QLabel("Drop image here", this))
|
||||
{
|
||||
m_dropIndicator->setObjectName("dropIndicator");
|
||||
m_dropIndicator->setAlignment(Qt::AlignCenter);
|
||||
addWidget(m_dropIndicator);
|
||||
addWidget(m_thumbnailLabel);
|
||||
}
|
||||
|
||||
void ThumbnailWidget::mousePressEvent(QMouseEvent *event)
|
||||
void ThumbnailWidget::setPixmap(const QPixmap &pixmap, bool acceptDrops)
|
||||
{
|
||||
QWidget::mousePressEvent(event);
|
||||
m_thumbnailLabel->setPixmap(pixmap);
|
||||
|
||||
emit mousePressed();
|
||||
}
|
||||
if (acceptDrops && pixmap.isNull())
|
||||
setCurrentWidget(m_dropIndicator);
|
||||
else
|
||||
setCurrentWidget(m_thumbnailLabel);
|
||||
|
||||
void ThumbnailWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
QWidget::mouseDoubleClickEvent(event);
|
||||
m_thumbnailLabel->update();
|
||||
|
||||
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();
|
||||
|
||||
QFrame::paintEvent(event);
|
||||
}
|
||||
|
||||
void ThumbnailWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
QSize ThumbnailWidget::sizeHint() const
|
||||
{
|
||||
return m_sizeHint;
|
||||
}
|
||||
|
||||
void ThumbnailWidget::setSizeHint(QSize size)
|
||||
{
|
||||
m_sizeHint = size;
|
||||
QWidget::setAcceptDrops(acceptDrops);
|
||||
}
|
||||
|
||||
void ThumbnailWidget::dragEnterEvent(QDragEnterEvent *event)
|
||||
@ -439,47 +416,19 @@ static void* ui_companion_qt_init(void)
|
||||
browserButtonsHBoxLayout->addItem(new QSpacerItem(browserAndPlaylistTabWidget->tabBar()->width(), 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||
|
||||
thumbnailWidget = new ThumbnailWidget(THUMBNAIL_TYPE_BOXART);
|
||||
thumbnailWidget->setObjectName("thumbnail1Widget");
|
||||
thumbnailWidget->setObjectName("thumbnail");
|
||||
|
||||
thumbnail2Widget = new ThumbnailWidget(THUMBNAIL_TYPE_TITLE_SCREEN);
|
||||
thumbnail2Widget->setObjectName("thumbnail2Widget");
|
||||
thumbnail2Widget->setObjectName("thumbnail2");
|
||||
|
||||
thumbnail3Widget = new ThumbnailWidget(THUMBNAIL_TYPE_SCREENSHOT);
|
||||
thumbnail3Widget->setObjectName("thumbnail3Widget");
|
||||
thumbnail3Widget->setObjectName("thumbnail3");
|
||||
|
||||
thumbnailWidget->setLayout(new QVBoxLayout());
|
||||
thumbnail2Widget->setLayout(new QVBoxLayout());
|
||||
thumbnail3Widget->setLayout(new QVBoxLayout());
|
||||
|
||||
thumbnailWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
||||
thumbnail2Widget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
||||
thumbnail3Widget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
||||
|
||||
QObject::connect(thumbnailWidget, SIGNAL(filesDropped(const QImage&, ThumbnailType)), mainwindow, SLOT(onThumbnailDropped(const QImage&, ThumbnailType)));
|
||||
QObject::connect(thumbnail2Widget, SIGNAL(filesDropped(const QImage&, ThumbnailType)), mainwindow, SLOT(onThumbnailDropped(const QImage&, ThumbnailType)));
|
||||
QObject::connect(thumbnail3Widget, SIGNAL(filesDropped(const QImage&, ThumbnailType)), mainwindow, SLOT(onThumbnailDropped(const QImage&, ThumbnailType)));
|
||||
|
||||
thumbnail = new ThumbnailLabel();
|
||||
thumbnail->setObjectName("thumbnail");
|
||||
|
||||
thumbnail2 = new ThumbnailLabel();
|
||||
thumbnail2->setObjectName("thumbnail2");
|
||||
|
||||
thumbnail3 = new ThumbnailLabel();
|
||||
thumbnail3->setObjectName("thumbnail3");
|
||||
|
||||
thumbnail->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
||||
thumbnail2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
||||
thumbnail3->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
||||
|
||||
QObject::connect(mainwindow, SIGNAL(thumbnailChanged(const QPixmap&)), thumbnail, SLOT(setPixmap(const QPixmap&)));
|
||||
QObject::connect(mainwindow, SIGNAL(thumbnail2Changed(const QPixmap&)), thumbnail2, SLOT(setPixmap(const QPixmap&)));
|
||||
QObject::connect(mainwindow, SIGNAL(thumbnail3Changed(const QPixmap&)), thumbnail3, SLOT(setPixmap(const QPixmap&)));
|
||||
|
||||
thumbnailWidget->layout()->addWidget(thumbnail);
|
||||
thumbnail2Widget->layout()->addWidget(thumbnail2);
|
||||
thumbnail3Widget->layout()->addWidget(thumbnail3);
|
||||
|
||||
thumbnailDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART), mainwindow);
|
||||
thumbnailDock->setObjectName("thumbnailDock");
|
||||
thumbnailDock->setProperty("default_area", Qt::RightDockWidgetArea);
|
||||
@ -557,9 +506,6 @@ static void* ui_companion_qt_init(void)
|
||||
mainwindow->resizeDocks(QList<QDockWidget*>() << coreSelectionDock, QList<int>() << 1, Qt::Vertical);
|
||||
#endif
|
||||
|
||||
/* this should come last */
|
||||
mainwindow->resizeThumbnails(true, true, true);
|
||||
|
||||
if (qsettings->contains("all_playlists_list_max_count"))
|
||||
mainwindow->setAllPlaylistsListMaxCount(qsettings->value("all_playlists_list_max_count", 0).toInt());
|
||||
|
||||
|
@ -166,7 +166,8 @@ private:
|
||||
void loadImage(const QModelIndex &index, const QString &path);
|
||||
};
|
||||
|
||||
class ThumbnailWidget : public QFrame
|
||||
|
||||
class ThumbnailWidget : public QStackedWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@ -174,20 +175,15 @@ public:
|
||||
ThumbnailWidget(ThumbnailType type, QWidget *parent = 0);
|
||||
ThumbnailWidget(const ThumbnailWidget& other) { retro_assert(false && "DONT EVER USE THIS"); }
|
||||
|
||||
QSize sizeHint() const;
|
||||
void setSizeHint(QSize size);
|
||||
void setPixmap(const QPixmap &pixmap, bool acceptDrops);
|
||||
signals:
|
||||
void mouseDoubleClicked();
|
||||
void mousePressed();
|
||||
void filesDropped(const QImage& image, ThumbnailType type);
|
||||
private:
|
||||
QSize m_sizeHint;
|
||||
ThumbnailType m_thumbnailType;
|
||||
ThumbnailLabel *m_thumbnailLabel;
|
||||
QLabel *m_dropIndicator;
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dragMoveEvent(QDragMoveEvent *event);
|
||||
void dropEvent(QDropEvent *event);
|
||||
@ -437,10 +433,10 @@ public slots:
|
||||
void onStartCoreClicked();
|
||||
void onDropWidgetEnterPressed();
|
||||
void selectBrowserDir(QString path);
|
||||
void resizeThumbnails(bool one, bool two, bool three);
|
||||
void onResizeThumbnailOne();
|
||||
void onResizeThumbnailTwo();
|
||||
void onResizeThumbnailThree();
|
||||
void setThumbnail(QString widgetName, QPixmap &pixmap, bool acceptDrop);
|
||||
void onResizeThumbnailOne(QPixmap &pixmap, bool acceptDrop);
|
||||
void onResizeThumbnailTwo(QPixmap &pixmap, bool acceptDrop);
|
||||
void onResizeThumbnailThree(QPixmap &pixmap, bool acceptDrop);
|
||||
void appendLogMessage(const QString &msg);
|
||||
void onGotLogMessage(const QString &msg);
|
||||
void onGotStatusMessage(QString msg, unsigned priority, unsigned duration, bool flush);
|
||||
@ -550,7 +546,6 @@ private:
|
||||
bool currentPlaylistIsAll();
|
||||
void applySearch();
|
||||
void updateItemsCount();
|
||||
void setThumbnailsAcceptDrops(bool accept);
|
||||
QString changeThumbnail(const QImage &image, QString type);
|
||||
|
||||
PlaylistModel *m_playlistModel;
|
||||
|
Loading…
Reference in New Issue
Block a user