Qt: switch to stacked layout to avoid bug. Add border to file browser table.

This commit is contained in:
CozmoP 2019-01-13 23:34:47 +01:00
parent a0b67424ca
commit 2ef9e5757b
6 changed files with 27 additions and 32 deletions

View File

@ -21,7 +21,7 @@ extern "C" {
}
FileDropWidget::FileDropWidget(QWidget *parent) :
QWidget(parent)
QStackedWidget(parent)
{
setAcceptDrops(true);
}

View File

@ -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:

View File

@ -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);
}

View File

@ -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<QVBoxLayout*>(m_gridWidget->layout())->addLayout(gridFooterLayout);
static_cast<QVBoxLayout*>(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()

View File

@ -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);

View File

@ -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;