summaryrefslogtreecommitdiffstats
path: root/fileview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fileview.cpp')
-rw-r--r--fileview.cpp128
1 files changed, 65 insertions, 63 deletions
diff --git a/fileview.cpp b/fileview.cpp
index 2da9bc6..fdd51e4 100644
--- a/fileview.cpp
+++ b/fileview.cpp
@@ -54,6 +54,13 @@ void FileView::createFolder(){
mCreateFolderDialog->show();
}
+void FileView::readConfig(){
+ QSettings s;
+ mHover = s.value("ui/hoverpics", true).toBool();
+ mHoverWin->setWindowOpacity(s.value("ui/hoveropacity", 10).toFloat() / 10.0);
+}
+
+
void FileView::doMark(){
int rowCount = model()->rowCount(rootIndex());
QString sRegex = mMarkDialog->text();
@@ -139,83 +146,78 @@ void FileView::resizeEvent(QResizeEvent *e){
}
bool FileView::event(QEvent *e){
- QSettings s;
- if(!s.value("ui/hoverpics").toBool()){
- return true;
- }
-
- if(e->type() == QEvent::HoverLeave){
- mHoverWin->setVisible(false);
- mCurHover = QModelIndex();
- return true;
- }
-
QHoverEvent *hEvent = static_cast<QHoverEvent*>(e);
- QPoint hotSpot(hEvent->pos().x(), hEvent->pos().y() - SmGlobals::instance()->cursorOffset());
- QModelIndex curIdx = indexAt(hotSpot);
-
- if(!curIdx.isValid()){
- return true;
- }
- if(curIdx.column() != 0){
- mHoverWin->setVisible(false);
- return true;
- }
-
- QFileInfo fi(curIdx.data(QFileSystemModel::FilePathRole).toString());
- if(!fi.exists()){
- return true;
- }
-
- QList<QVariant> hoverData;
- if(fi.isDir()){
- hoverData << fi.fileName();
- QDir curDir(fi.absoluteFilePath());
- QStringList files = curDir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot, QDir::Name);
- hoverData << files;
- }else if(fi.isFile()){
- QString mimeType = Helper::mimeType(fi.absoluteFilePath());
- if(mimeType.startsWith("image")){
- QPixmap pm(fi.absoluteFilePath());
- hoverData << pm;
- }else{
+ if((hEvent->type() == QEvent::HoverEnter) || (hEvent->type() == QEvent::HoverLeave) || (hEvent->type() == QEvent::HoverMove)){
+ if(!mHover){
+ return true;
+ }
+ if(e->type() == QEvent::HoverLeave){
mHoverWin->setVisible(false);
+ mCurHover = QModelIndex();
return true;
}
- }else{
- mHoverWin->setVisible(false);
- return true;
- }
-
- QPoint globalPos = mapToGlobal(hotSpot);
- QPoint where = globalPos + QPoint(30, 0);
- if(e->type() == QEvent::HoverEnter){
- mCurHover = curIdx;
- mHoverWin->setData(hoverData);
- if(mHoverWin->pixmapHeight()){
- where = QPoint(where.x(), where.y() - mHoverWin->pixmapHeight() / 2);
+ QPoint hotSpot(hEvent->pos().x(), hEvent->pos().y() - SmGlobals::instance()->cursorOffset());
+ QModelIndex curIdx = indexAt(hotSpot);
+ if(!curIdx.isValid()){
+ return true;
}
- mHoverWin->setPos(where);
- mHoverWin->setVisible(true);
- return true;
- }
- if(e->type() == QEvent::HoverMove){
- if(curIdx != mCurHover){
+ if(curIdx.column() != 0){
+ mHoverWin->setVisible(false);
+ return true;
+ }
+ QFileInfo fi(curIdx.data(QFileSystemModel::FilePathRole).toString());
+ if(!fi.exists()){
+ return true;
+ }
+ QList<QVariant> hoverData;
+ if(fi.isDir()){
+ hoverData << fi.fileName();
+ QDir curDir(fi.absoluteFilePath());
+ QStringList files = curDir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot, QDir::Name);
+ hoverData << files;
+ }else if(fi.isFile()){
+ QString mimeType = Helper::mimeType(fi.absoluteFilePath());
+ if(mimeType.startsWith("image")){
+ QPixmap pm(fi.absoluteFilePath());
+ hoverData << pm;
+ }else{
+ mHoverWin->setVisible(false);
+ return true;
+ }
+ }else{
+ mHoverWin->setVisible(false);
+ return true;
+ }
+ QPoint globalPos = mapToGlobal(hotSpot);
+ QPoint where = globalPos + QPoint(30, 0);
+ if(e->type() == QEvent::HoverEnter){
mCurHover = curIdx;
mHoverWin->setData(hoverData);
if(mHoverWin->pixmapHeight()){
where = QPoint(where.x(), where.y() - mHoverWin->pixmapHeight() / 2);
}
- mHoverWin->setVisible(false);
mHoverWin->setPos(where);
mHoverWin->setVisible(true);
return true;
- }else{
- if(mHoverWin->pixmapHeight()){
- where = QPoint(where.x(), where.y() - mHoverWin->pixmapHeight() / 2);
+ }
+ if(e->type() == QEvent::HoverMove){
+ if(curIdx != mCurHover){
+ mCurHover = curIdx;
+ mHoverWin->setData(hoverData);
+ if(mHoverWin->pixmapHeight()){
+ where = QPoint(where.x(), where.y() - mHoverWin->pixmapHeight() / 2);
+ }
+ mHoverWin->setVisible(false);
+ mHoverWin->setPos(where);
+ mHoverWin->setVisible(true);
+ return true;
+ }else{
+ if(mHoverWin->pixmapHeight()){
+ where = QPoint(where.x(), where.y() - mHoverWin->pixmapHeight() / 2);
+ }
+ mHoverWin->setPos(where);
+ return true;
}
- mHoverWin->setPos(where);
- return true;
}
}
return QTreeView::event(e);