void MainUI::goToDevice(QAction *act){ if(act==ui->actionScan){ RebuildDeviceMenu(); }else{ 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() ); } }
MainWindow::MainWindow() { mUI.setupUi(this); libxdiff_tools_init(); connect(mUI.mActionExit, SIGNAL(triggered()), this, SLOT(close())); connect(mUI.mActionOpenDirs, SIGNAL(triggered()), this, SLOT(OpenDirs())); connect(mUI.mActionOpenFiles, SIGNAL(triggered()), this, SLOT(OpenFiles())); connect(mUI.mActionToolBarMain, SIGNAL(toggled(bool)), this, SLOT(ToggleMainToolBar())); connect(mUI.mActionStatusBar, SIGNAL(toggled(bool)), this, SLOT(ToggleStatusBar())); connect(mUI.mActionAboutWinMerge, SIGNAL(triggered()), this, SLOT(AboutWinMerge())); }
void MainUI::goToBookmark(QAction *act){ if(act==ui->actionManage_Bookmarks){ BMMDialog dlg(this); dlg.loadSettings(settings); dlg.exec(); RebuildBookmarksMenu(); }else{ //Find the current directory 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() ); } }
void MainUI::CloseBrowser(QString ID){ //Find the tab associated with this browser first for(int i=0; i<tabBar->count(); i++){ if(tabBar->tabWhatsThis(i)==ID){ tabBar->removeTab(i); break; } } //Now remove the browser itself for(int i=0; i<DWLIST.length(); i++){ if(DWLIST[i]->id()==ID){ delete DWLIST.takeAt(i); break; } } //If the last browser was just closed, create a new one if(DWLIST.isEmpty()){ OpenDirs(QStringList() << QDir::homePath()); } }
void MainUI::tabClosed(int tab){ if(tabBar->count()==1){ return; } //Can't close the only tab if(tab < 0){ tab = tabBar->currentIndex(); } QString info = tabBar->tabWhatsThis(tab); if(info=="browser"){ return; } //qDebug() << "Tab Closed:" << info; if(!info.startsWith("#")){ for(int i=0; i<DWLIST.length(); i++){ if(info == DWLIST[i]->id()){ DWLIST[i]->cleanup(); delete DWLIST.takeAt(i); break; } } }else if(info=="#MW"){ MW->Cleanup(); //prepare it to be hidden/removed } //Remove the tab (will automatically move to a different one); qDebug() << "Closing tab:" << tab << tabBar->tabText(tab); tabBar->removeTab(tab); tabBar->setVisible( tabBar->count() > 1 ); if(DWLIST.isEmpty()){ OpenDirs(QStringList() << QDir::homePath() ); } }
void MainUI::on_actionNew_Tab_triggered(){ OpenDirs(QStringList() << QDir::homePath()); }
void MainUI::OpenDirs(QStringList dirs){ //Now open the dirs if(dirs.isEmpty()){ dirs << QDir::homePath(); } QStringList invalid; for(int i=0; i<dirs.length(); i++){ if(dirs[i].simplified().isEmpty()){ continue; } //Open this directory in a viewer if(dirs[i].endsWith("/")){ dirs[i].chop(1); } if(!QFile::exists(dirs[i])){ invalid << dirs[i]; continue; } if(DEBUG){ qDebug() << "Open Directory:" << dirs[i]; } ///Get a new Unique ID int id = 0; for(int j=0; j<DWLIST.length(); j++){ if(DWLIST[j]->id().section("-",1,1).toInt() >= id){ id = DWLIST[j]->id().section("-",1,1).toInt()+1; } } //Create the new DirWidget DirWidget *DW = new DirWidget("DW-"+QString::number(id), this); DW->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); ui->BrowserLayout->addWidget(DW); DWLIST << DW; //Connect the signals/slots for it connect(DW, SIGNAL(OpenDirectories(QStringList)), this, SLOT(OpenDirs(QStringList)) ); connect(DW, SIGNAL(LoadDirectory(QString, QString)), worker, SLOT(GetDirData(QString, QString)) ); connect(DW, SIGNAL(findSnaps(QString, QString)), worker, SLOT(GetSnapshotData(QString, QString)) ); connect(DW, SIGNAL(PlayFiles(LFileInfoList)), this, SLOT(OpenPlayer(LFileInfoList)) ); connect(DW, SIGNAL(ViewFiles(LFileInfoList)), this, SLOT(OpenImages(LFileInfoList)) ); connect(DW, SIGNAL(LaunchTerminal(QString)), this, SLOT(OpenTerminal(QString)) ); connect(DW, SIGNAL(CutFiles(QStringList)), this, SLOT(CutFiles(QStringList)) ); connect(DW, SIGNAL(CopyFiles(QStringList)), this, SLOT(CopyFiles(QStringList)) ); connect(DW, SIGNAL(FavoriteFiles(QStringList)), this, SLOT(FavoriteFiles(QStringList)) ); connect(DW, SIGNAL(RenameFiles(QStringList)), this, SLOT(RenameFiles(QStringList)) ); connect(DW, SIGNAL(RemoveFiles(QStringList)), this, SLOT(RemoveFiles(QStringList)) ); connect(DW, SIGNAL(PasteFiles(QString,QStringList)), this, SLOT(PasteFiles(QString, QStringList)) ); connect(DW, SIGNAL(CloseBrowser(QString)), this, SLOT(CloseBrowser(QString)) ); //Now create the tab for this if(radio_view_tabs->isChecked()){ int index = tabBar->addTab( LXDG::findIcon("folder-open",""), dirs[i].section("/",-1) ); tabBar->setTabWhatsThis( index, "DW-"+QString::number(id) ); tabBar->setCurrentIndex(index); }else{ //Just make sure the browser tab is visible bool found = false; for(int i=0; i<tabBar->count() && !found; i++){ if(tabBar->tabWhatsThis(i)=="browser"){ tabBar->setCurrentIndex(i); found=true; } } if(!found){ //Need to create the generic Browser tab int index = tabBar->addTab( LXDG::findIcon("folder-open",""), "Browser" ); tabBar->setTabWhatsThis( index, "browser" ); tabBar->setCurrentIndex(index); } } //Initialize the widget with the proper settings DW->setShowDetails(radio_view_details->isChecked()); DW->setShowSidebar(ui->actionShow_Action_Buttons->isChecked()); QList<DirWidget::DETAILTYPES> details; details <<DirWidget::NAME << DirWidget::SIZE << DirWidget::TYPE << DirWidget::DATEMOD; DW->setDetails(details); //Which details to show and in which order (L->R) DW->setShowThumbnails(ui->actionShow_Thumbnails->isChecked()); DW->setThumbnailSize(settings->value("iconsize", 32).toInt()); DW->setDirCompleter(dirCompleter); DW->setShowCloseButton(!radio_view_tabs->isChecked()); //Now load the directory DW->ChangeDir(dirs[i]); //kick off loading the directory info } //Update visibilities tabChanged(tabBar->currentIndex()); tabBar->setVisible( tabBar->count() > 1 ); if(!invalid.isEmpty()){ QMessageBox::warning(this, tr("Invalid Directories"), tr("The following directories are invalid and could not be opened:")+"\n"+invalid.join(", ") ); } //Double check that there is at least 1 dir loaded //qDebug() << "OpenDirs:" << DWLIST.length() << dirs << invalid << tabBar->currentIndex(); if(DWLIST.isEmpty()){ OpenDirs(QStringList()); } }
//Tab Interactions void TermWindow::New_Tab() { OpenDirs(QStringList() << QDir::homePath()); }