aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-fm/widgets
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2018-11-12 08:29:26 -0500
committerGitHub <noreply@github.com>2018-11-12 08:29:26 -0500
commit052488fb58e5c492b5bf56d4f9bf947f87dfb266 (patch)
tree9cf5e3791e7193de0a30cfe8fa2084ba79536de9 /src-qt5/desktop-utils/lumina-fm/widgets
parentFix a compilation error with loading the default quotes option. (diff)
parentcreate new folder in lumina-fm (diff)
downloadlumina-052488fb58e5c492b5bf56d4f9bf947f87dfb266.tar.gz
lumina-052488fb58e5c492b5bf56d4f9bf947f87dfb266.tar.bz2
lumina-052488fb58e5c492b5bf56d4f9bf947f87dfb266.zip
Merge pull request #634 from lbartoletti/new_folder
Add menu to create new directory in lumina-fm
Diffstat (limited to 'src-qt5/desktop-utils/lumina-fm/widgets')
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp56
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h271
2 files changed, 168 insertions, 159 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
index a35a29a5..44930511 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
@@ -246,7 +246,7 @@ void DirWidget::createShortcuts(){
kZoomIn= new QShortcut(QKeySequence(QKeySequence::ZoomIn),this);
kZoomOut= new QShortcut(QKeySequence(QKeySequence::ZoomOut),this);
kNewFile= new QShortcut(QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_F),this);
- kNewDir= new QShortcut(QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_N),this);
+ kNewDir= new QShortcut(QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_N), this);
kNewXDG= new QShortcut(QKeySequence(Qt::CTRL+Qt::Key_G),this);
kCut= new QShortcut(QKeySequence(QKeySequence::Cut),this);
kCopy= new QShortcut(QKeySequence(QKeySequence::Copy),this);
@@ -592,11 +592,11 @@ void DirWidget::UpdateContextMenu(){
}
if(LUtils::isValidBinary("lumina-archiver") && sel.length() >=1 && canmodify){
cArchiveMenu->clear();
- if(sel.length()==1 && ( XDGMime::fromFileName(sel[0]).endsWith("-tar") ||
- XDGMime::fromFileName(sel[0]).endsWith("-image") ||
- ( XDGMime::fromFileName(sel[0]).contains("zip") &&
- !XDGMime::fromFileName(sel[0]).endsWith("epub+zip") &&
- !XDGMime::fromFileName(sel[0]).endsWith("vnd.comicbook+zip" )
+ if(sel.length()==1 && ( XDGMime::fromFileName(sel[0]).endsWith("-tar") ||
+ XDGMime::fromFileName(sel[0]).endsWith("-image") ||
+ ( XDGMime::fromFileName(sel[0]).contains("zip") &&
+ !XDGMime::fromFileName(sel[0]).endsWith("epub+zip") &&
+ !XDGMime::fromFileName(sel[0]).endsWith("vnd.comicbook+zip" )
)
)
){
@@ -738,27 +738,33 @@ void DirWidget::createNewFile(){
}
}
+
+void DirWidget::createNewFolder(QWidget *parent, BrowserWidget *browser){
+
+ //Prompt for the new dir name
+ bool ok = false;
+ QString newdir = QInputDialog::getText(parent, tr("New Directory"), tr("Name:"), QLineEdit::Normal, "", \
+ &ok, 0, Qt::ImhFormattedNumbersOnly | Qt::ImhUppercaseOnly | Qt::ImhLowercaseOnly);
+ if(!ok || newdir.isEmpty()){ return; }
+ //Now create the new dir
+ QString full = browser->currentDirectory();
+ if(!full.endsWith("/")){ full.append("/"); }
+ QDir dir(full); //open the current dir
+ full.append(newdir); //append the new name to the current dir
+ //Verify that the new dir does not already exist
+ if(dir.exists(full)){
+ QMessageBox::warning(parent, tr("Invalid Name"), tr("A file or directory with that name already exists! Please pick a different name."));
+ QTimer::singleShot(0,parent, SLOT(createNewDir(parent, browser)) ); //repeat this function
+ }else{
+ if(!dir.mkdir(newdir) ){
+ QMessageBox::warning(parent, tr("Error Creating Directory"), tr("The directory could not be created. Please ensure that you have the proper permissions to modify the current directory."));
+ }
+ }
+}
+
void DirWidget::createNewDir(){
if(!canmodify){ return; } //cannot create anything here
- //Prompt for the new dir name
- bool ok = false;
- QString newdir = QInputDialog::getText(this, tr("New Directory"), tr("Name:"), QLineEdit::Normal, "", \
- &ok, 0, Qt::ImhFormattedNumbersOnly | Qt::ImhUppercaseOnly | Qt::ImhLowercaseOnly);
- if(!ok || newdir.isEmpty()){ return; }
- //Now create the new dir
- QString full = currentBrowser()->currentDirectory();
- if(!full.endsWith("/")){ full.append("/"); }
- QDir dir(full); //open the current dir
- full.append(newdir); //append the new name to the current dir
- //Verify that the new dir does not already exist
- if(dir.exists(full)){
- QMessageBox::warning(this, tr("Invalid Name"), tr("A file or directory with that name already exists! Please pick a different name."));
- QTimer::singleShot(0,this, SLOT(createNewDir()) ); //repeat this function
- }else{
- 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."));
- }
- }
+ createNewFolder(this, currentBrowser());
}
void DirWidget::createNewXDGEntry(){
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h
index 253ce2dd..c724ca35 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h
@@ -25,76 +25,79 @@
#define ZSNAPDIR QString("/.zfs/snapshot/")
namespace Ui{
- class DirWidget;
+ class DirWidget;
};
class DirWidget : public QWidget{
- Q_OBJECT
+ Q_OBJECT
public:
- enum DETAILTYPES{ NAME, SIZE, TYPE, DATEMOD, DATECREATE};
- DirWidget(QString objID, QSettings *settings, QWidget *parent = 0); //needs a unique ID (to distinguish from other DirWidgets)
- ~DirWidget();
+ enum DETAILTYPES{ NAME, SIZE, TYPE, DATEMOD, DATECREATE};
+ DirWidget(QString objID, QSettings *settings, QWidget *parent = 0); //needs a unique ID (to distinguish from other DirWidgets)
+ ~DirWidget();
- void cleanup(); //called before the browser is closed down
+ void cleanup(); //called before the browser is closed down
- //Directory Managment
- void ChangeDir(QString dirpath);
- void setDirCompleter(QCompleter *comp);
+ //Directory Managment
+ void ChangeDir(QString dirpath);
+ void setDirCompleter(QCompleter *comp);
- //Information
- QString id();
- QString currentDir();
- QFileSystemModel *dirtreeModel;
- QStringList PREFAPPS;
+ //Information
+ QString id();
+ QString currentDir();
+ 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 adjustTreeWidget(float percent); //percent between 0-100
- void setTreeSortMode(int num); //0-4
+ //View Settings
+ void setShowDetails(bool show);
+ void showHidden(bool show);
+ void showThumbnails(bool show);
+ void setThumbnailSize(int px);
+ void setFocusLineDir();
+ void adjustTreeWidget(float percent); //percent between 0-100
+ void setTreeSortMode(int num); //0-4
+ BrowserWidget* currentBrowser();
+
+ static void createNewFolder(QWidget *parent, BrowserWidget *browser);
public slots:
- //void LoadDir(QString dir, LFileInfoList list);
- void LoadSnaps(QString basedir, QStringList snaps);
+ //void LoadDir(QString dir, LFileInfoList list);
+ void LoadSnaps(QString basedir, QStringList snaps);
+
+ //Refresh options
+ void refresh(); //Refresh current directory
- //Refresh options
- void refresh(); //Refresh current directory
+ //Theme change functions
+ void UpdateIcons();
+ void UpdateText();
- //Theme change functions
- void UpdateIcons();
- void UpdateText();
private:
- Ui::DirWidget *ui;
- BrowserWidget *BW, *RCBW; //Main BrowserWidget and right-column browser widget
- QString ID, cBID; //unique ID assigned by the parent, and currently active browser widget
- QString normalbasedir, snapbasedir, snaprelpath, rootfmdir; //for maintaining directory context while moving between snapshots
- QStringList snapshots, needThumbs, tmpSel;
- QSettings *settings;
- bool canmodify;
-
- //The Toolbar and associated items
- QToolBar *toolbar;
- QLineEdit *line_dir;
-
- //The context menu and associated items
- QMenu *contextMenu, *cNewMenu, *cOpenMenu, *cFModMenu, *cFViewMenu, *cOpenWithMenu, *cArchiveMenu;
-
- //The keyboard shortcuts for context menu items
- QShortcut *kZoomIn, *kZoomOut, *kNewFile, *kNewDir, *kNewXDG, *kCut, *kCopy, *kPaste, *kRename, \
+ Ui::DirWidget *ui;
+ BrowserWidget *BW, *RCBW; //Main BrowserWidget and right-column browser widget
+ QString ID, cBID; //unique ID assigned by the parent, and currently active browser widget
+ QString normalbasedir, snapbasedir, snaprelpath, rootfmdir; //for maintaining directory context while moving between snapshots
+ QStringList snapshots, needThumbs, tmpSel;
+ QSettings *settings;
+ bool canmodify;
+
+ //The Toolbar and associated items
+ QToolBar *toolbar;
+ QLineEdit *line_dir;
+
+ //The context menu and associated items
+ QMenu *contextMenu, *cNewMenu, *cOpenMenu, *cFModMenu, *cFViewMenu, *cOpenWithMenu, *cArchiveMenu;
+
+ //The keyboard shortcuts for context menu items
+ QShortcut *kZoomIn, *kZoomOut, *kNewFile, *kNewDir, *kNewXDG, *kCut, *kCopy, *kPaste, *kRename, \
*kFav, *kDel, *kOpSS, *kOpMM, *kOpTerm, *kExtract, *kArchive;
- //Functions for internal use
- void createShortcuts(); //on init only
- void createMenus(); //on init only
+ //Functions for internal use
+ void createShortcuts(); //on init only
+ void createMenus(); //on init only
- BrowserWidget* currentBrowser();
- QStringList currentDirFiles(); //all the "files" available within the current dir/browser
+ QStringList currentDirFiles(); //all the "files" available within the current dir/browser
//QProcess *pExtract;
//OpenWithMenu
@@ -103,93 +106,93 @@ private:
//QStringList getPreferredApplications();
private slots:
- //UI BUTTONS/Actions
- void splitterMoved();
-
- // -- Bottom Action Buttons
- void on_tool_zoom_in_clicked();
- void on_tool_zoom_out_clicked();
-
- // -- Top Snapshot Buttons
- void on_tool_snap_newer_clicked();
- void on_tool_snap_older_clicked();
- void on_slider_snap_valueChanged(int val = -1);
- void direct_snap_selected(QAction*);
-
- //Top Toolbar buttons
- void on_actionBack_triggered();
- void on_actionUp_triggered();
- void on_actionHome_triggered();
- void dir_changed(); //user manually changed the directory
- void on_actionSingleColumn_triggered(bool);
- void on_actionDualColumn_triggered(bool);
- void on_actionMenu_triggered();
-
- // - Other Actions without a specific button on the side
- void fileCheckSums();
- void fileProperties();
- void openTerminal();
- void openRootFM();
-
-
- //Browser Functions
- void OpenContextMenu();
- void UpdateContextMenu();
- void currentDirectoryChanged(QString dir, bool widgetonly = false);
- void currentDirectoryChanged(bool widgetonly = false);
- void dirStatusChanged(QString);
- void setCurrentBrowser(QString);
- void on_folderViewPane_clicked(const QModelIndex &index);
-
- //Context Menu Functions
- // - DIRECTORY operations
- void createNewFile();
- void createNewDir();
- void createNewXDGEntry();
- //void createNewSymlink();
-
- // - Selected FILE operations
- void cutFiles();
- void copyFiles();
- void pasteFiles();
- void renameFiles();
- void favoriteFiles();
- void removeFiles();
- void runFiles();
- void runWithFiles();
- //void attachToNewEmail();
- void autoExtractFiles();
- void autoArchiveFiles();
- void setAsWallpaper();
-
- // - Context-specific operations
- void openInSlideshow();
- void openMultimedia();
- void OpenWithApp(QAction*);
+ //UI BUTTONS/Actions
+ void splitterMoved();
+
+ // -- Bottom Action Buttons
+ void on_tool_zoom_in_clicked();
+ void on_tool_zoom_out_clicked();
+
+ // -- Top Snapshot Buttons
+ void on_tool_snap_newer_clicked();
+ void on_tool_snap_older_clicked();
+ void on_slider_snap_valueChanged(int val = -1);
+ void direct_snap_selected(QAction*);
+
+ //Top Toolbar buttons
+ void on_actionBack_triggered();
+ void on_actionUp_triggered();
+ void on_actionHome_triggered();
+ void dir_changed(); //user manually changed the directory
+ void on_actionSingleColumn_triggered(bool);
+ void on_actionDualColumn_triggered(bool);
+ void on_actionMenu_triggered();
+
+ // - Other Actions without a specific button on the side
+ void fileCheckSums();
+ void fileProperties();
+ void openTerminal();
+ void openRootFM();
+
+
+ //Browser Functions
+ void OpenContextMenu();
+ void UpdateContextMenu();
+ void currentDirectoryChanged(QString dir, bool widgetonly = false);
+ void currentDirectoryChanged(bool widgetonly = false);
+ void dirStatusChanged(QString);
+ void setCurrentBrowser(QString);
+ void on_folderViewPane_clicked(const QModelIndex &index);
+
+ //Context Menu Functions
+ // - DIRECTORY operations
+ void createNewFile();
+ void createNewDir();
+ void createNewXDGEntry();
+ //void createNewSymlink();
+
+ // - Selected FILE operations
+ void cutFiles();
+ void copyFiles();
+ void pasteFiles();
+ void renameFiles();
+ void favoriteFiles();
+ void removeFiles();
+ void runFiles();
+ void runWithFiles();
+ //void attachToNewEmail();
+ void autoExtractFiles();
+ void autoArchiveFiles();
+ void setAsWallpaper();
+
+ // - Context-specific operations
+ void openInSlideshow();
+ 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
- void PasteFiles(QString, QStringList); //current dir
- void FavoriteFiles(QStringList); //file selection
- void RenameFiles(QStringList); //file selection
- void RemoveFiles(QStringList); //file selection
- void TabNameChanged(QString, QString); //objID, new tab name
+ //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
+ void PasteFiles(QString, QStringList); //current dir
+ void FavoriteFiles(QStringList); //file selection
+ void RenameFiles(QStringList); //file selection
+ void RemoveFiles(QStringList); //file selection
+ void TabNameChanged(QString, QString); //objID, new tab name
protected:
- void mouseReleaseEvent(QMouseEvent *);
+ void mouseReleaseEvent(QMouseEvent *);
};
bgstack15