From 2ef9e5757b7534caeedd9bf879dbc163e0148d9c Mon Sep 17 00:00:00 2001 From: CozmoP <25121396+CozmoP@users.noreply.github.com> Date: Sun, 13 Jan 2019 23:34:47 +0100 Subject: [PATCH] Qt: switch to stacked layout to avoid bug. Add border to file browser table. --- ui/drivers/qt/filedropwidget.cpp | 2 +- ui/drivers/qt/filedropwidget.h | 4 ++-- ui/drivers/qt/ui_qt_themes.h | 5 ++++- ui/drivers/qt/ui_qt_window.cpp | 33 ++++++++++++++++---------------- ui/drivers/ui_qt.cpp | 10 ++-------- ui/drivers/ui_qt.h | 5 ++--- 6 files changed, 27 insertions(+), 32 deletions(-) diff --git a/ui/drivers/qt/filedropwidget.cpp b/ui/drivers/qt/filedropwidget.cpp index 4bea0bb489..04eee2d47f 100644 --- a/ui/drivers/qt/filedropwidget.cpp +++ b/ui/drivers/qt/filedropwidget.cpp @@ -21,7 +21,7 @@ extern "C" { } FileDropWidget::FileDropWidget(QWidget *parent) : - QWidget(parent) + QStackedWidget(parent) { setAcceptDrops(true); } diff --git a/ui/drivers/qt/filedropwidget.h b/ui/drivers/qt/filedropwidget.h index 3a5d420e5a..83199295ca 100644 --- a/ui/drivers/qt/filedropwidget.h +++ b/ui/drivers/qt/filedropwidget.h @@ -1,14 +1,14 @@ #ifndef FILEDROPWIDGET_H #define FILEDROPWIDGET_H -#include +#include class QDragEnterEvent; class QDropEvent; class QKeyEvent; class QPaintEvent; -class FileDropWidget : public QWidget +class FileDropWidget : public QStackedWidget { Q_OBJECT public: diff --git a/ui/drivers/qt/ui_qt_themes.h b/ui/drivers/qt/ui_qt_themes.h index 701583a76e..0f24aef04b 100644 --- a/ui/drivers/qt/ui_qt_themes.h +++ b/ui/drivers/qt/ui_qt_themes.h @@ -24,13 +24,16 @@ 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 { + QWidget#playlistWidget, QWidget#browserWidget, QStackedWidget#centralWidget, QWidget#logWidget { 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%); } + QStackedWidget#centralWidget { + padding: 10px; + } QTextEdit, LogTextEdit { background-color:rgb(25,25,25); } diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 080426f27c..ce33700bf3 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -314,8 +314,7 @@ MainWindow::MainWindow(QWidget *parent) : ,m_folderIcon() ,m_customThemeString() ,m_gridView(new GridView(this)) - ,m_gridWidget(new QWidget(this)) - ,m_gridScrollArea(new QScrollArea(m_gridWidget)) + ,m_playlistViewsAndFooter(new QWidget(this)) ,m_zoomSlider(NULL) ,m_lastZoomSliderValue(0) ,m_viewType(VIEW_TYPE_LIST) @@ -408,15 +407,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()->addWidget(m_tableView); - 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); @@ -424,7 +426,7 @@ MainWindow::MainWindow(QWidget *parent) : gridProgressLayout->addWidget(gridProgressLabel); gridProgressLayout->addWidget(m_gridProgressBar); - m_gridWidget->layout()->addWidget(m_gridProgressWidget); + m_playlistViewsAndFooter->layout()->addWidget(m_gridProgressWidget); m_zoomWidget->setLayout(zoomLayout); zoomLayout->setContentsMargins(0, 0, 0, 0); @@ -440,7 +442,7 @@ MainWindow::MainWindow(QWidget *parent) : gridFooterLayout->addWidget(m_zoomWidget); gridFooterLayout->addWidget(viewTypePushButton); - static_cast(m_gridWidget->layout())->addLayout(gridFooterLayout); + static_cast(m_playlistViewsAndFooter->layout())->addLayout(gridFooterLayout); m_gridProgressWidget->hide(); @@ -2114,7 +2116,7 @@ void MainWindow::onTabWidgetIndexChanged(int index) { m_currentBrowser = BROWSER_TYPE_PLAYLISTS; - m_centralWidget->setCurrentWidget(m_playlistViews); + m_centralWidget->setCurrentWidget(m_playlistViewsAndFooter); onCurrentItemChanged(m_tableView->currentIndex()); } @@ -2517,18 +2519,15 @@ void MainWindow::setCurrentViewType(ViewType viewType) { case VIEW_TYPE_ICONS: { - m_tableView->hide(); + m_playlistViews->setCurrentWidget(m_gridView); m_zoomWidget->show(); - m_gridView->show(); break; } case VIEW_TYPE_LIST: default: { - m_viewType = VIEW_TYPE_LIST; - m_gridView->hide(); + m_playlistViews->setCurrentWidget(m_tableView); m_zoomWidget->hide(); - m_tableView->show(); break; } } @@ -2583,9 +2582,9 @@ FileDropWidget* MainWindow::playlistViews() return m_playlistViews; } -QWidget* MainWindow::contentGridWidget() +QWidget* MainWindow::playlistViewsAndFooter() { - return m_gridWidget; + return m_playlistViewsAndFooter; } GridView* MainWindow::contentGridView() diff --git a/ui/drivers/ui_qt.cpp b/ui/drivers/ui_qt.cpp index 4c15cf0c14..2885d0b8fe 100644 --- a/ui/drivers/ui_qt.cpp +++ b/ui/drivers/ui_qt.cpp @@ -240,7 +240,7 @@ static void* ui_companion_qt_init(void) QDockWidget *coreSelectionDock = NULL; QTabWidget *browserAndPlaylistTabWidget = NULL; QStackedWidget *centralWidget = NULL; - QWidget *widget = NULL; + QStackedWidget *widget = NULL; QWidget *browserWidget = NULL; QWidget *playlistWidget = NULL; QWidget *coreSelectionWidget = NULL; @@ -290,7 +290,6 @@ static void* ui_companion_qt_init(void) listWidget = mainwindow->playlistListWidget(); widget = mainwindow->playlistViews(); - widget->setObjectName("tableWidget"); widget->setContextMenuPolicy(Qt::CustomContextMenu); QObject::connect(widget, SIGNAL(filesDropped(QStringList)), mainwindow, SLOT(onPlaylistFilesDropped(QStringList))); @@ -298,14 +297,9 @@ 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&))); - playlistViewsLayout = new QVBoxLayout(); - playlistViewsLayout->addWidget(mainwindow->contentGridWidget()); - - widget->setLayout(playlistViewsLayout); - centralWidget = mainwindow->centralWidget(); - centralWidget->addWidget(widget); + centralWidget->addWidget(mainwindow->playlistViewsAndFooter()); centralWidget->addWidget(mainwindow->fileTableView()); mainwindow->setCentralWidget(centralWidget); diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index 25aac2bf6a..d3a331b447 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -344,7 +344,7 @@ public: QTableView* fileTableView(); FileDropWidget* playlistViews(); GridView* contentGridView(); - QWidget* contentGridWidget(); + QWidget* playlistViewsAndFooter(); QWidget* searchWidget(); QLineEdit* searchLineEdit(); QComboBox* launchWithComboBox(); @@ -583,8 +583,7 @@ private: 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;