diff options
author | Ken Moore <moorekou@gmail.com> | 2015-09-25 09:56:20 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2015-09-25 09:56:20 -0400 |
commit | 8ad545f5e31fb2053ccb55cafddf7054b72e1c9d (patch) | |
tree | 65803a42ef938ad1e0ad94a55445280af8bf8907 /lumina-fm | |
parent | Adjust the window workspace detection routine to also check whether the given... (diff) | |
download | lumina-8ad545f5e31fb2053ccb55cafddf7054b72e1c9d.tar.gz lumina-8ad545f5e31fb2053ccb55cafddf7054b72e1c9d.tar.bz2 lumina-8ad545f5e31fb2053ccb55cafddf7054b72e1c9d.zip |
Fix up the active browser detection routine, ensure the browser gets updated after creating new files/dirs (just in case the filesystem does not report changes properly), and ensure that clicking the slideshow/player buttons always opens the player (even if an invalid file is selected at that moment).
Diffstat (limited to 'lumina-fm')
-rw-r--r-- | lumina-fm/MainUI.cpp | 62 | ||||
-rw-r--r-- | lumina-fm/MainUI.h | 2 | ||||
-rw-r--r-- | lumina-fm/widgets/DirWidget.cpp | 14 | ||||
-rw-r--r-- | lumina-fm/widgets/DirWidget.h | 2 |
4 files changed, 53 insertions, 27 deletions
diff --git a/lumina-fm/MainUI.cpp b/lumina-fm/MainUI.cpp index dbffdfc7..daa172d1 100644 --- a/lumina-fm/MainUI.cpp +++ b/lumina-fm/MainUI.cpp @@ -301,7 +301,38 @@ void MainUI::RebuildDeviceMenu(){ } } - +DirWidget* MainUI::FindActiveBrowser(){ + //Find the current directory + DirWidget *curB = 0; + //Get the current tab ID to start with + QString cur = tabBar->tabWhatsThis(tabBar->currentIndex()); + //if(cur.startsWith("#")){ cur.clear(); } //multimedia/player tab open + + if(DWLIST.length()==1){ + //Only 1 browser open - use it + curB = DWLIST[0]; + }else if(cur.startsWith("DW-")){ + //This is a tab for a browser - just find the matching widget + for(int i=0; i<DWLIST.length(); i++){ + if(DWLIST[i]->id()==cur){ curB = DWLIST[i]; break; } + } + }else{ + //This is a bit more complex - either showing multiple columns or a non-browser tab is active + if(cur=="Browser"){ + //Column View + QWidget *focus = QApplication::focusWidget(); //the widget which currently has focus + for(int i=0; i<DWLIST.length(); i++){ + if(DWLIST[i]->isAncestorOf(focus)){ curB = DWLIST[i]; break; } //This browser has focus + } + + }else{ + //Non-Browser in focus - use the fallback below + } + } + //if all else fails - just use the first browser in the list (there should always be at least one) + if(curB==0 && !DWLIST.isEmpty()){ curB = DWLIST[0]; } + return curB; +} //============== // PRIVATE SLOTS @@ -319,18 +350,9 @@ void MainUI::on_actionNew_Tab_triggered(){ } void MainUI::on_actionSearch_triggered(){ - //Find the current directory - QString cur = tabBar->tabWhatsThis(tabBar->currentIndex()); - if(cur.startsWith("#")){ cur.clear(); } //multimedia/player tab open - else{ - for(int i=0; i<DWLIST.length(); i++){ - if(DWLIST[i]->id()==cur){ - //Found the current browser - load it here - QProcess::startDetached("lumina-search -dir \""+DWLIST[i]->currentDir()+"\""); - return; - } - } - } + DirWidget *dir = FindActiveBrowser(); + if(dir==0){ return; } + QProcess::startDetached("lumina-search -dir \""+dir->currentDir()+"\""); } void MainUI::on_actionClose_triggered(){ @@ -374,16 +396,10 @@ void MainUI::goToBookmark(QAction *act){ RebuildBookmarksMenu(); }else{ //Find the current directory - QString cur = tabBar->tabWhatsThis(tabBar->currentIndex()); - if(cur.startsWith("#")){ cur.clear(); } //multimedia/player tab open - else{ - for(int i=0; i<DWLIST.length(); i++){ - if(DWLIST[i]->id()==cur){ - //Found the current browser - load it here - DWLIST[i]->ChangeDir(act->whatsThis()); - return; - } - } + DirWidget *dir = FindActiveBrowser(); + if(dir!=0){ + dir->ChangeDir(act->whatsThis()); + return; } //If no current dir could be found - open a new tab/column OpenDirs(QStringList() << act->whatsThis() ); diff --git a/lumina-fm/MainUI.h b/lumina-fm/MainUI.h index bec38249..0a68334a 100644 --- a/lumina-fm/MainUI.h +++ b/lumina-fm/MainUI.h @@ -98,6 +98,8 @@ private: void RebuildBookmarksMenu(); void RebuildDeviceMenu(); + DirWidget* FindActiveBrowser(); + private slots: void slotSingleInstance(QStringList in){ this->show(); diff --git a/lumina-fm/widgets/DirWidget.cpp b/lumina-fm/widgets/DirWidget.cpp index f62d4b94..1259a5e1 100644 --- a/lumina-fm/widgets/DirWidget.cpp +++ b/lumina-fm/widgets/DirWidget.cpp @@ -654,6 +654,7 @@ void DirWidget::on_tool_goToImages_clicked(){ } } if(!list.isEmpty()){ emit ViewFiles(list); } + else{ emit ViewFiles(CLIST); } //invalid file(s) selected - just do everything } } @@ -669,6 +670,7 @@ void DirWidget::on_tool_goToPlayer_clicked(){ } } if(!list.isEmpty()){ emit PlayFiles(list); } + else{ emit PlayFiles(CLIST); } //invalid file(s) selected - just do everything } } @@ -689,6 +691,8 @@ void DirWidget::on_tool_new_file_clicked(){ }else{ QMessageBox::warning(this, tr("Error Creating Document"), tr("The document could not be created. Please ensure that you have the proper permissions.")); } + //just in case the watcher does not work for this filesystem -queue up a sync + if(!synctimer->isActive()){ synctimer->start(); } } void DirWidget::on_tool_new_dir_clicked(){ @@ -711,7 +715,9 @@ void DirWidget::on_tool_new_dir_clicked(){ if(!dir.mkdir(newdir) ){ QMessageBox::warning(this, tr("Error Creating Directory"), tr("The directory could not be created. Please ensure that you have the proper permissions to modify the current directory.")); } - } + } + //just in case the watcher does not work for this filesystem -queue up a sync + if(!synctimer->isActive()){ synctimer->start(); } } // -- Top Snapshot Buttons @@ -903,8 +909,10 @@ void DirWidget::startSync(const QString &file){ //Update date_format based on user settings if(file == sessionsettings_config_file){ setDateFormat(); } else if(file == snapbasedir){ emit findSnaps(ID, normalbasedir); } //snapshot list changed - else if(file == normalbasedir){ emit LoadDirectory(ID, normalbasedir); } //Directory changed (new/removed files) - else{ + else if(file == normalbasedir){ + if(synctimer->isActive()){ synctimer->stop(); } //already starting a sync + emit LoadDirectory(ID, normalbasedir); //Directory changed (new/removed files) + }else{ //Some file in the directory got changed - start the time for a dir reload // -- This prevents a directory from refreshing constantly if a file within the directory is changing all the time (such as a log file) if(!synctimer->isActive()){ synctimer->start(); } diff --git a/lumina-fm/widgets/DirWidget.h b/lumina-fm/widgets/DirWidget.h index adf349a9..be6252ae 100644 --- a/lumina-fm/widgets/DirWidget.h +++ b/lumina-fm/widgets/DirWidget.h @@ -98,7 +98,7 @@ private: //Functions for internal use void setupConnections(); QStringList currentSelection(); - QStringList date_format; + QStringList date_format; private slots: //UI BUTTONS/Actions |