1 //=========================================== 2 // Lumina-DE source code 3 // Copyright (c) 2015, Ken Moore 4 // Available under the 3-clause BSD license 5 // See the LICENSE file for full details 6 //=========================================== 7 #ifndef _LUMINA_FM_DIRECTORY_BROWSER_WIDGET_H 8 #define _LUMINA_FM_DIRECTORY_BROWSER_WIDGET_H 9 10 #include <QList> 11 #include <QWidget> 12 #include <QObject> 13 #include <QMenu> 14 #include <QToolBar> 15 #include <QLineEdit> 16 #include <QShortcut> 17 #include <QFileSystemWatcher> 18 #include <QFileSystemModel> 19 #include <QTimer> 20 #include <QFuture> 21 22 #include "../BrowserWidget.h" 23 24 25 #define ZSNAPDIR QString("/.zfs/snapshot/") 26 27 namespace Ui{ 28 class DirWidget; 29 }; 30 31 class DirWidget : public QWidget{ 32 Q_OBJECT 33 public: 34 enum DETAILTYPES{ NAME, SIZE, TYPE, DATEMOD, DATECREATE}; 35 DirWidget(QString objID, QSettings *settings, QWidget *parent = 0); //needs a unique ID (to distinguish from other DirWidgets) 36 ~DirWidget(); 37 38 void cleanup(); //called before the browser is closed down 39 40 //Directory Managment 41 void ChangeDir(QString dirpath); 42 void setDirCompleter(QCompleter *comp); 43 44 //Information 45 QString id(); 46 QString currentDir(); 47 QFileSystemModel *dirtreeModel; 48 QStringList PREFAPPS; 49 50 //View Settings 51 void setShowDetails(bool show); 52 void showHidden(bool show); 53 void showThumbnails(bool show); 54 void setThumbnailSize(int px); 55 void setFocusLineDir(); 56 void adjustTreeWidget(float percent); //percent between 0-100 57 void setTreeSortMode(int num); //0-4 58 BrowserWidget* currentBrowser(); 59 60 static void createNewFolder(QWidget *parent, BrowserWidget *browser); 61 62 63 public slots: 64 //void LoadDir(QString dir, LFileInfoList list); 65 void LoadSnaps(QString basedir, QStringList snaps); 66 67 //Refresh options 68 void refresh(); //Refresh current directory 69 70 //Theme change functions 71 void UpdateIcons(); 72 void UpdateText(); 73 74 75 76 private: 77 Ui::DirWidget *ui; 78 BrowserWidget *BW, *RCBW; //Main BrowserWidget and right-column browser widget 79 QString ID, cBID; //unique ID assigned by the parent, and currently active browser widget 80 QString normalbasedir, snapbasedir, snaprelpath, rootfmdir; //for maintaining directory context while moving between snapshots 81 QStringList snapshots, needThumbs, tmpSel; 82 QSettings *settings; 83 bool canmodify; 84 85 //The Toolbar and associated items 86 QToolBar *toolbar; 87 QLineEdit *line_dir; 88 89 //The context menu and associated items 90 QMenu *contextMenu, *cNewMenu, *cOpenMenu, *cFModMenu, *cFViewMenu, *cOpenWithMenu, *cArchiveMenu; 91 92 //The keyboard shortcuts for context menu items 93 QShortcut *kZoomIn, *kZoomOut, *kNewFile, *kNewDir, *kNewXDG, *kCut, *kCopy, *kPaste, *kRename, \ 94 *kFav, *kDel, *kOpSS, *kOpMM, *kOpTerm, *kExtract, *kArchive; 95 96 //Functions for internal use 97 void createShortcuts(); //on init only 98 void createMenus(); //on init only 99 100 QStringList currentDirFiles(); //all the "files" available within the current dir/browser 101 102 //QProcess *pExtract; 103 //OpenWithMenu 104 QString fileEXT, filePath; 105 QStringList mimetypes, keys, files; 106 //QStringList getPreferredApplications(); 107 108 private slots: 109 //UI BUTTONS/Actions 110 void splitterMoved(); 111 112 // -- Bottom Action Buttons 113 void on_tool_zoom_in_clicked(); 114 void on_tool_zoom_out_clicked(); 115 116 // -- Top Snapshot Buttons 117 void on_tool_snap_newer_clicked(); 118 void on_tool_snap_older_clicked(); 119 void on_slider_snap_valueChanged(int val = -1); 120 void direct_snap_selected(QAction*); 121 122 //Top Toolbar buttons 123 void on_actionBack_triggered(); 124 void on_actionUp_triggered(); 125 void on_actionHome_triggered(); 126 void dir_changed(); //user manually changed the directory 127 void on_actionSingleColumn_triggered(bool); 128 void on_actionDualColumn_triggered(bool); 129 void on_actionMenu_triggered(); 130 131 // - Other Actions without a specific button on the side 132 void fileCheckSums(); 133 void fileProperties(); 134 void openTerminal(); 135 void openRootFM(); 136 137 138 //Browser Functions 139 void OpenContextMenu(); 140 void UpdateContextMenu(); 141 void currentDirectoryChanged(QString dir, bool widgetonly = false); 142 void currentDirectoryChanged(bool widgetonly = false); 143 void dirStatusChanged(QString); 144 void setCurrentBrowser(QString); 145 void on_folderViewPane_clicked(const QModelIndex &index); 146 147 //Context Menu Functions 148 // - DIRECTORY operations 149 void createNewFile(); 150 void createNewDir(); 151 void createNewXDGEntry(); 152 //void createNewSymlink(); 153 154 // - Selected FILE operations 155 void cutFiles(); 156 void copyFiles(); 157 void pasteFiles(); 158 void renameFiles(); 159 void favoriteFiles(); 160 void removeFiles(); 161 void runFiles(); 162 void runWithFiles(); 163 //void attachToNewEmail(); 164 void autoExtractFiles(); 165 void autoArchiveFiles(); 166 void setAsWallpaper(); 167 168 // - Context-specific operations 169 void openInSlideshow(); 170 void openMultimedia(); 171 void OpenWithApp(QAction*); 172 173 signals: 174 //Directory loading/finding signals 175 void OpenDirectories(QStringList); //Directories to open in other tabs/columns 176 void findSnaps(QString, QString); //ID, dirpath (Request snapshot information for a directory) 177 void CloseBrowser(QString); //ID (Request that this browser be closed) 178 void treeWidgetSizeChanged(float); //percent width 179 180 //External App/Widget launching 181 void PlayFiles(LFileInfoList); //open in multimedia player 182 void ViewFiles(LFileInfoList); //open in slideshow 183 void LaunchTerminal(QString); //dirpath 184 185 //System Interactions 186 void CutFiles(QStringList); //file selection 187 void CopyFiles(QStringList); //file selection 188 void PasteFiles(QString, QStringList); //current dir 189 void FavoriteFiles(QStringList); //file selection 190 void RenameFiles(QStringList); //file selection 191 void RemoveFiles(QStringList); //file selection 192 void TabNameChanged(QString, QString); //objID, new tab name 193 194 protected: 195 void mouseReleaseEvent(QMouseEvent *); 196 197 }; 198 199 #endif 200