summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2015-02-13 18:16:11 +0100
committerArno <am@disconnect.de>2015-02-13 18:16:11 +0100
commitd44010d181847c6fa52b828afb0b673c0e9645ab (patch)
tree59cf927a5522646c71bc003d17fdd00d7f66aa5e
parent6aecc4f8060c72471c80c99a576a7a7e8c74777e (diff)
downloadSheMov-d44010d181847c6fa52b828afb0b673c0e9645ab.tar.gz
SheMov-d44010d181847c6fa52b828afb0b673c0e9645ab.tar.bz2
SheMov-d44010d181847c6fa52b828afb0b673c0e9645ab.zip
Center on selected directory on startup
Center on the selected dir in Filemanager on startup. Unfortunately it's not as straight as one would think. scrollTo doesn't work until the widget is painted, so we have to take a little detour...
-rw-r--r--filesystemwidget.cpp7
-rw-r--r--filesystemwidget.h1
-rw-r--r--shemov.cpp3
3 files changed, 10 insertions, 1 deletions
diff --git a/filesystemwidget.cpp b/filesystemwidget.cpp
index 60c2d78..5568db0 100644
--- a/filesystemwidget.cpp
+++ b/filesystemwidget.cpp
@@ -375,7 +375,7 @@ void FilesystemWidget::readSettings(){
QModelIndex diridx = mModel->index(selectedDir);
if(diridx.isValid()){
QModelIndex pidx = mDirProxy->mapFromSource(diridx);
- mDirView->selectionModel()->setCurrentIndex(pidx, QItemSelectionModel::ClearAndSelect);
+ mDirView->selectionModel()->setCurrentIndex(pidx, QItemSelectionModel::ClearAndSelect);
}
}
bool expensiveOps = s.value("ui/expensiveops", true).toBool();
@@ -513,6 +513,11 @@ void FilesystemWidget::selectUnpackDir(){
}
}
+void FilesystemWidget::centerCurrent(){
+ QModelIndex curIdx = mDirView->currentIndex();
+ mDirView->scrollTo(curIdx, QAbstractItemView::PositionAtCenter);
+}
+
void FilesystemWidget::deleteRecursive(const QFileInfo &start){
if(start.isDir()){
QDir curDir = QDir(start.absoluteFilePath());;
diff --git a/filesystemwidget.h b/filesystemwidget.h
index 0284fb6..efff13a 100644
--- a/filesystemwidget.h
+++ b/filesystemwidget.h
@@ -70,6 +70,7 @@ class FilesystemWidget : public QWidget {
void preview();
void unpack();
void selectUnpackDir();
+ void centerCurrent();
private slots:
void dirExpanded(const QModelIndex &idx);
diff --git a/shemov.cpp b/shemov.cpp
index 4a6094b..6e3943c 100644
--- a/shemov.cpp
+++ b/shemov.cpp
@@ -144,6 +144,9 @@ SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, fla
mArchiveBrowser->readConfig();
readSettings();
Helper::centerWidget(picViewer);
+ // craptastic... We can't center until it's painted,
+ // hence this indirection :(
+ mFSWidget->centerCurrent();
}
void SheMov::closeEvent(QCloseEvent *event){