aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-fm/widgets
diff options
context:
space:
mode:
authorWeblate <noreply@weblate.org>2017-07-19 19:01:31 +0000
committerWeblate <noreply@weblate.org>2017-07-19 19:01:31 +0000
commitb687e491eea208afba43b67a072ddf430bfeb1fc (patch)
tree80c24ebc2a04e3d20e74004ebf9e5411252a697d /src-qt5/desktop-utils/lumina-fm/widgets
parentPush local changes (diff)
parentMerge branch 'master' of github.com:trueos/lumina (diff)
downloadlumina-b687e491eea208afba43b67a072ddf430bfeb1fc.tar.gz
lumina-b687e491eea208afba43b67a072ddf430bfeb1fc.tar.bz2
lumina-b687e491eea208afba43b67a072ddf430bfeb1fc.zip
Merge branch 'master' of github.com:trueos/lumina
Diffstat (limited to 'src-qt5/desktop-utils/lumina-fm/widgets')
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp128
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h27
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.ui2
3 files changed, 97 insertions, 60 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
index 6c2d4f35..3790d145 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
@@ -16,9 +16,9 @@
#include <QInputDialog>
#include <QScrollBar>
#include <QSettings>
-#include <QtConcurrent/QtConcurrentRun>
+#include <QtConcurrent>
#include <QFileSystemModel>
-
+#include <QCompleter>
#include <LuminaOS.h>
#include <LuminaXDG.h>
#include <LUtils.h>
@@ -71,7 +71,7 @@ DirWidget::DirWidget(QString objID, QWidget *parent) : QWidget(parent), ui(new U
dirtreeModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs); // remove extraneous dirs
dirtreeModel->setRootPath(folderTreePath);
ui->folderViewPane->setModel(dirtreeModel);
- ui->splitter->setSizes( QList<int>() << this->width()/3 << 2*this->width()/3);
+ ui->splitter->setSizes( QList<int>() << this->width()/4 << 3*this->width()/4);
ui->folderViewPane->setHeaderHidden(true);
ui->folderViewPane->resizeColumnToContents(0);
ui->folderViewPane->setColumnHidden(1, true);
@@ -83,11 +83,13 @@ DirWidget::DirWidget(QString objID, QWidget *parent) : QWidget(parent), ui(new U
contextMenu = new QMenu(this);
cNewMenu = cOpenMenu = cFModMenu = cFViewMenu = cOpenWithMenu = 0; //not created yet
connect(contextMenu, SIGNAL(aboutToShow()), this, SLOT(UpdateContextMenu()) );
+ connect(ui->splitter, SIGNAL(splitterMoved(int,int)), this, SLOT(splitterMoved()) );
UpdateIcons();
UpdateText();
createShortcuts();
createMenus();
+ line_dir->setCompleter(new QCompleter(dirtreeModel, this));
}
DirWidget::~DirWidget(){
@@ -112,7 +114,7 @@ void DirWidget::ChangeDir(QString dirpath){
}
void DirWidget::setDirCompleter(QCompleter *comp){
- //line_dir->setCompleter(comp);
+ line_dir->setCompleter(comp);
}
QString DirWidget::id(){
@@ -131,6 +133,9 @@ void DirWidget::setShowDetails(bool show){
void DirWidget::showHidden(bool show){
BW->showHiddenFiles(show);
if(RCBW!=0){ RCBW->showHiddenFiles(show); }
+ //Also make sure the tree model is showing hidden files as needed
+ if(show){ dirtreeModel->setFilter(QDir::NoDotAndDotDot | QDir::Hidden | QDir::AllDirs); }
+ else{ dirtreeModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs); }
}
void DirWidget::showThumbnails(bool show){
@@ -148,15 +153,8 @@ void DirWidget::setThumbnailSize(int px){
//====================
// Folder Pane
//====================
-
-void DirWidget::showDirTreePane(bool show){
- if(show !=showdirtree){
- showdirtree = show;
- }
-}
-
-bool DirWidget::showingDirTreePane(){
- return showdirtree;
+void DirWidget::adjustTreeWidget(float percent){
+ ui->splitter->setSizes( QList<int>() << this->width()*(percent/100.0) << this->width() * ((100.0-percent)/100.0) );
}
void DirWidget::on_folderViewPane_clicked(const QModelIndex &index){
@@ -297,35 +295,15 @@ void DirWidget::createMenus(){
*/
//---------------------------------------------------//
- /*
- if(cOpenWithMenu==0){ cOpenWithMenu = new QMenu(this); }
- else{ cOpenWithMenu->clear(); }
- cOpenWithMenu->setTitle(tr("Open with..."));
- cOpenWithMenu->setIcon( LXDG::findIcon("run-build-configure","") );
- XDGDesktopList applist;
- applist.updateList();
- PREFAPPS = getPreferredApplications();
- //qDebug() << "Preferred Apps:" << PREFAPPS;
- cOpenWithMenu->clear();
- //Now get the application mimetype for the file extension (if available)
- QStringList mimetypes = LXDG::findAppMimeForFile(filePath, true).split("::::"); //use all mimetypes
- //Now add all the detected applications
- QHash< QString, QList<XDGDesktop*> > hash = LXDG::sortDesktopCats( applist.apps(false,true) );
- QStringList cat = hash.keys();
- cat.sort(); //sort alphabetically
- for(int c=0; c<cat.length(); c++){
- QList<XDGDesktop*> app = hash[cat[c]];
- if(app.length()<1){ cOpenWithMenu =0; continue; }
- for(int a=0; a<app.length(); a++){
- QString program = app[a]->filePath;
- QStringList arguments;
- arguments << "%u";
- QProcess *p = new QProcess();
- p->start(program, arguments);
-
- cOpenWithMenu->addAction(LXDG::findIcon(app[a]->icon), (app[a]->name), this, SLOT(p->start(program, arguments)) );}}
- cOpenWithMenu->addAction(LXDG::findIcon("run-build-configure",""), tr("Other..."), this, SLOT(runWithFiles()) );
-*/
+
+ if(cOpenWithMenu==0){
+ cOpenWithMenu = new QMenu(this);
+ connect(cOpenWithMenu, SIGNAL(triggered(QAction*)), this, SLOT(OpenWithApp(QAction*)) );
+ }
+ else{ cOpenWithMenu->clear(); }
+ cOpenWithMenu->setTitle(tr("Open with..."));
+ cOpenWithMenu->setIcon( LXDG::findIcon("system-run-with","") );
+
//---------------------------------------------------//
if(cFViewMenu==0){ cFViewMenu = new QMenu(this); }
else{ cFViewMenu->clear(); }
@@ -349,6 +327,10 @@ QStringList DirWidget::currentDirFiles(){
// =================
// PRIVATE SLOTS
// =================
+void DirWidget::splitterMoved(){
+ float percent = (ui->splitter->sizes().first() / ( (float) this->width()) )*100.0;
+ this->emit treeWidgetSizeChanged(percent);
+}
//UI BUTTONS
void DirWidget::on_tool_zoom_in_clicked(){
@@ -559,6 +541,7 @@ void DirWidget::UpdateContextMenu(){
if(!sel.isEmpty()){
contextMenu->addAction(LXDG::findIcon("system-run",""), tr("Open"), this, SLOT(runFiles()) );
//contextMenu->addAction(LXDG::findIcon("system-run-with",""), tr("Open With..."), this, SLOT(runWithFiles()) );
+ contextMenu->addMenu(cOpenWithMenu);
}
contextMenu->addSection(LXDG::findIcon("unknown",""), tr("File Operations"));
// contextMenu->addMenu(cFModMenu);
@@ -587,6 +570,50 @@ void DirWidget::UpdateContextMenu(){
contextMenu->addMenu(cNewMenu);
}
contextMenu->addMenu(cOpenMenu);
+ //=====================
+ //PREFAPPS = getPreferredApplications();
+ //qDebug() << "Preferred Apps:" << PREFAPPS;
+ cOpenWithMenu->clear();
+ //Now get the application mimetype for the file extension (if available)
+ QStringList mimetypes;
+ for(int i=0; i<sel.length(); i++){
+ QStringList mimes = LXDG::findAppMimeForFile(sel[i], true).split("::::"); //use all mimetypes
+ if(mimetypes.isEmpty()){ mimetypes << mimes; }
+ else{
+ //need to verify that the mimetypes are the same before adding them.
+ QStringList test; test << mimetypes << mimes;
+ if(test.removeDuplicates()>0){ mimetypes = test; }
+ else{
+ //Bad match - incompatible file types are selected - disable the recommendations
+ mimetypes.clear();
+ break;
+ }
+ }
+ }
+ //Now add all the detected applications
+ if(!mimetypes.isEmpty()){
+ static XDGDesktopList applist;
+ applist.updateList();
+ QList<XDGDesktop*> apps = applist.apps(false,true);
+ QList<XDGDesktop*> found;
+ for(int a=0; a<apps.length(); a++){
+ if(apps[a]->mimeList.isEmpty()){ continue; } //no corresponding mime types for this app
+ QStringList test; test << mimetypes << apps[a]->mimeList;
+ if(test.removeDuplicates()>0){ found << apps[a]; }
+ }
+ if(!found.isEmpty()){
+ //sort the apps by name
+ found = LXDG::sortDesktopNames(found);
+ //add apps to the menu
+ for(int i=0; i<found.length(); i++){
+ QAction *act = cOpenWithMenu->addAction( LXDG::findIcon(found[i]->icon, ""), found[i]->name );
+ act->setToolTip(found[i]->comment);
+ act->setWhatsThis(found[i]->filePath);
+ }
+ cOpenWithMenu->addSeparator();
+ }
+ }
+ cOpenWithMenu->addAction(LXDG::findIcon("system-run-with",""), tr("Other..."), this, SLOT(runWithFiles()) );
}
void DirWidget::currentDirectoryChanged(bool widgetonly){
@@ -600,17 +627,17 @@ void DirWidget::currentDirectoryChanged(bool widgetonly){
normalbasedir = cur;
ui->group_snaps->setVisible(false);
emit findSnaps(ID, cur);
- qDebug() << "Changed to directory:" << cur;
+ //qDebug() << "Changed to directory:" << cur;
}else{
//Re-assemble the normalbasedir variable (in case moving around within a snapshot)
normalbasedir = cur;
normalbasedir.replace( QRegExp("\\/\\.zfs\\/snapshot/([^/]+)\\/"), "/" );
- qDebug() << "Changed to snapshot:" << cur << normalbasedir;
+ //qDebug() << "Changed to snapshot:" << cur << normalbasedir;
}
ui->actionBack->setEnabled( currentBrowser()->history().length()>1 );
- line_dir->setText(normalbasedir);
+ line_dir->setText(normalbasedir);
emit TabNameChanged(ID, normalbasedir.section("/",-1));
- QModelIndex index = dirtreeModel->index(cur,0);
+ QModelIndex index = dirtreeModel->index(normalbasedir,0);
ui->folderViewPane->setCurrentIndex( index );
ui->folderViewPane->scrollTo(index);
}
@@ -842,6 +869,15 @@ void DirWidget::openMultimedia(){
if(!list.isEmpty()){ emit PlayFiles(list); }
}
+void DirWidget::OpenWithApp(QAction* act){
+ if(act->whatsThis().isEmpty()){ return; }
+ QStringList sel = currentBrowser()->currentSelection();
+ //Now we need to open the app file, and create the process
+ XDGDesktop desk(act->whatsThis());
+ QString exec = desk.generateExec(sel);
+ ExternalProcess::launch(exec);
+}
+
void DirWidget::autoExtractFiles(){
QStringList files = currentBrowser()->currentSelection();
qDebug() << "Starting auto-extract:" << files;
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h
index 20b677d7..e1dafaa8 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h
@@ -44,17 +44,16 @@ public:
//Information
QString id();
QString currentDir();
- QFileSystemModel *dirtreeModel;
- QStringList PREFAPPS;
+ QFileSystemModel *dirtreeModel;
+ QStringList PREFAPPS;
//View Settings
void setShowDetails(bool show);
void showHidden(bool show);
void showThumbnails(bool show);
void setThumbnailSize(int px);
- void setFocusLineDir();
- void showDirTreePane(bool show);
- bool showingDirTreePane();
+ void setFocusLineDir();
+ void adjustTreeWidget(float percent); //percent between 0-100
@@ -76,7 +75,7 @@ private:
QString ID, cBID; //unique ID assigned by the parent, and currently active browser widget
QString normalbasedir, snapbasedir, snaprelpath; //for maintaining directory context while moving between snapshots
QStringList snapshots, needThumbs, tmpSel;
- bool canmodify, showdirtree;
+ bool canmodify;
//The Toolbar and associated items
QToolBar *toolbar;
@@ -96,7 +95,7 @@ private:
BrowserWidget* currentBrowser();
QStringList currentDirFiles(); //all the "files" available within the current dir/browser
- QProcess *pExtract;
+ //QProcess *pExtract;
//OpenWithMenu
QString fileEXT, filePath;
@@ -106,6 +105,7 @@ private:
private slots:
//UI BUTTONS/Actions
+ void splitterMoved();
// -- Bottom Action Buttons
void on_tool_zoom_in_clicked();
@@ -157,24 +157,25 @@ private slots:
void runFiles();
void runWithFiles();
//void attachToNewEmail();
- void autoExtractFiles();
+ void autoExtractFiles();
// - Context-specific operations
void openInSlideshow();
- void openMultimedia();
-
+ void openMultimedia();
+ void OpenWithApp(QAction*);
signals:
//Directory loading/finding signals
void OpenDirectories(QStringList); //Directories to open in other tabs/columns
void findSnaps(QString, QString); //ID, dirpath (Request snapshot information for a directory)
void CloseBrowser(QString); //ID (Request that this browser be closed)
+ void treeWidgetSizeChanged(float); //percent width
//External App/Widget launching
void PlayFiles(LFileInfoList); //open in multimedia player
void ViewFiles(LFileInfoList); //open in slideshow
void LaunchTerminal(QString); //dirpath
-
+
//System Interactions
void CutFiles(QStringList); //file selection
void CopyFiles(QStringList); //file selection
@@ -183,10 +184,10 @@ signals:
void RenameFiles(QStringList); //file selection
void RemoveFiles(QStringList); //file selection
void TabNameChanged(QString, QString); //objID, new tab name
-
+
protected:
void mouseReleaseEvent(QMouseEvent *);
-
+
};
#endif
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.ui b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.ui
index c49e99ac..277d8bfb 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.ui
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.ui
@@ -238,7 +238,7 @@
<bool>true</bool>
</property>
<property name="text">
- <string>SingleColumn</string>
+ <string>Single Column</string>
</property>
<property name="toolTip">
<string>Single column view</string>
bgstack15