Add Horizontal Scroll Bar to the File Browser (#8184)
This commit is contained in:
@@ -147,6 +147,8 @@ protected:
|
||||
void keyReleaseEvent( QKeyEvent * ke ) override;
|
||||
void hideEvent( QHideEvent * he ) override;
|
||||
void focusOutEvent( QFocusEvent * fe ) override;
|
||||
void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override;
|
||||
void wheelEvent(QWheelEvent * event) override;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -29,12 +29,14 @@
|
||||
#include <QApplication>
|
||||
#include <QCheckBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QHeaderView>
|
||||
#include <QLineEdit>
|
||||
#include <QMdiArea>
|
||||
#include <QMdiSubWindow>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QProgressBar>
|
||||
#include <QScrollBar>
|
||||
#include <QPushButton>
|
||||
#include <QShortcut>
|
||||
#include <QStringList>
|
||||
@@ -461,6 +463,11 @@ FileBrowserTreeWidget::FileBrowserTreeWidget(QWidget * parent ) :
|
||||
m_pressPos(),
|
||||
m_previewPlayHandle( nullptr )
|
||||
{
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
setHorizontalScrollMode(ScrollPerPixel);
|
||||
header()->setStretchLastSection(false);
|
||||
header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
|
||||
setColumnCount( 1 );
|
||||
headerItem()->setHidden( true );
|
||||
setSortingEnabled( false );
|
||||
@@ -500,6 +507,28 @@ QList<QString> FileBrowserTreeWidget::expandedDirs( QTreeWidgetItem * item ) con
|
||||
return dirs;
|
||||
}
|
||||
|
||||
void FileBrowserTreeWidget::scrollTo(const QModelIndex &index, ScrollHint hint)
|
||||
{
|
||||
// Overide scrollTo to ensure the horizontal scrollbar stay in place
|
||||
int barPos = horizontalScrollBar()->value();
|
||||
QTreeWidget::scrollTo(index, hint);
|
||||
horizontalScrollBar()->setValue(barPos);
|
||||
}
|
||||
|
||||
void FileBrowserTreeWidget::wheelEvent(QWheelEvent * event)
|
||||
{
|
||||
// When shift is pressed, scroll horizontally instead of vertically
|
||||
if (event->modifiers() & Qt::ShiftModifier)
|
||||
{
|
||||
horizontalScrollBar()->setValue(
|
||||
horizontalScrollBar()->value() - event->angleDelta().y());
|
||||
event->accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
QTreeWidget::wheelEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void FileBrowserTreeWidget::keyPressEvent(QKeyEvent * ke )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user