aboutsummaryrefslogtreecommitdiff
path: root/lumina-fm/MainUI.cpp
diff options
context:
space:
mode:
authorKen Moore <moorekou@gmail.com>2015-09-25 09:56:20 -0400
committerKen Moore <moorekou@gmail.com>2015-09-25 09:56:20 -0400
commit8ad545f5e31fb2053ccb55cafddf7054b72e1c9d (patch)
tree65803a42ef938ad1e0ad94a55445280af8bf8907 /lumina-fm/MainUI.cpp
parentAdjust the window workspace detection routine to also check whether the given... (diff)
downloadlumina-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/MainUI.cpp')
-rw-r--r--lumina-fm/MainUI.cpp62
1 files changed, 39 insertions, 23 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() );
bgstack15