diff options
author | Ken Moore <ken@pcbsd.org> | 2016-09-13 14:11:39 -0400 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2016-09-13 14:11:39 -0400 |
commit | 0b8657008bf89226d24259dcbe5730aa76a483e2 (patch) | |
tree | 05423a3574acd27a924b6db4dafdb1a7e546bec9 /src-qt5/desktop-utils/lumina-fm | |
parent | Merge in all the translation files from the lumina-i18n repository into the m... (diff) | |
download | lumina-0b8657008bf89226d24259dcbe5730aa76a483e2.tar.gz lumina-0b8657008bf89226d24259dcbe5730aa76a483e2.tar.bz2 lumina-0b8657008bf89226d24259dcbe5730aa76a483e2.zip |
Add the beginnings of git integration within lumina-fm. Currently it can detect whether the user is looking at a git repo or not, and can probe/show the status of the repo if within one.
Diffstat (limited to 'src-qt5/desktop-utils/lumina-fm')
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/MainUI.cpp | 24 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/MainUI.h | 26 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/MainUI.ui | 18 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/gitCompat.h | 25 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/lumina-fm.pro | 3 |
5 files changed, 73 insertions, 23 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/MainUI.cpp b/src-qt5/desktop-utils/lumina-fm/MainUI.cpp index ea176846..0300438a 100644 --- a/src-qt5/desktop-utils/lumina-fm/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-fm/MainUI.cpp @@ -8,6 +8,7 @@ #include "ui_MainUI.h" #include <QFileInfo> +#include "gitCompat.h" #define DEBUG 0 @@ -21,6 +22,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ ui->setupUi(this); + ui->menuGit->setVisible( GIT::isAvailable() ); if(DEBUG){ qDebug() << "Initilization:"; } settings = new QSettings( QSettings::UserScope, "lumina-desktop", "lumina-fm", this); @@ -230,6 +232,10 @@ void MainUI::setupIcons(){ ui->actionManage_Bookmarks->setIcon( LXDG::findIcon("bookmarks-organize","") ); ui->actionAdd_Bookmark->setIcon( LXDG::findIcon("bookmark-new","") ); + //GIT menu + ui->actionRepo_Status->setIcon( LXDG::findIcon("git","document-edit-verify") ); + ui->actionClone_Repository->setIcon( LXDG::findIcon("git","download") ); + // External Devices menu ui->actionScan->setIcon( LXDG::findIcon("system-search","") ); } @@ -606,6 +612,24 @@ void MainUI::CreateBookMark(){ RebuildBookmarksMenu(); } +//Git Menu options +void MainUI::on_menuGit_aboutToShow(){ + QString dir = FindActiveBrowser()->currentDir(); + bool inrepo = GIT::isRepo(dir); + ui->actionRepo_Status->setEnabled( inrepo ); + ui->actionClone_Repository->setEnabled( !inrepo ); +} + +void MainUI::on_actionRepo_Status_triggered(){ + QString status = GIT::status( FindActiveBrowser()->currentDir() ); + QMessageBox::information(this, tr("Git Repository Status"), status); +} + +void MainUI::on_actionClone_Repository_triggered(){ + +} + + void MainUI::tabChanged(int tab){ if(tab<0){ tab = tabBar->currentIndex(); } if(tab < 0){ return; } diff --git a/src-qt5/desktop-utils/lumina-fm/MainUI.h b/src-qt5/desktop-utils/lumina-fm/MainUI.h index 007fff97..6df10a89 100644 --- a/src-qt5/desktop-utils/lumina-fm/MainUI.h +++ b/src-qt5/desktop-utils/lumina-fm/MainUI.h @@ -114,14 +114,14 @@ private slots: void on_actionNew_Window_triggered(); void on_actionNew_Tab_triggered(); void on_actionSearch_triggered(); - void on_actionClose_Browser_triggered(); + void on_actionClose_Browser_triggered(); void on_actionClose_triggered(); - void on_actionRename_triggered(); - void on_actionCut_Selection_triggered(); - void on_actionCopy_Selection_triggered(); - void on_actionPaste_triggered(); - void on_actionDelete_Selection_triggered(); - void on_actionRefresh_triggered(); + void on_actionRename_triggered(); + void on_actionCut_Selection_triggered(); + void on_actionCopy_Selection_triggered(); + void on_actionPaste_triggered(); + void on_actionDelete_Selection_triggered(); + void on_actionRefresh_triggered(); void on_actionView_Hidden_Files_triggered(); void on_actionShow_Action_Buttons_triggered(); void on_actionShow_Thumbnails_triggered(); @@ -132,15 +132,19 @@ private slots: void on_actionLarger_Icons_triggered(); void on_actionSmaller_Icons_triggered(); void CreateBookMark(); - + //Git Menu options + void on_menuGit_aboutToShow(); + void on_actionRepo_Status_triggered(); + void on_actionClone_Repository_triggered(); + //Tab interactions - void tabChanged(int tab = -1); + void tabChanged(int tab = -1); void tabClosed(int tab = -1); void nextTab(); //For keyboard shortcuts void prevTab(); //For keyboard shortcuts - //Other Shortcuts - void togglehiddenfiles(); + //Other Shortcuts + void togglehiddenfiles(); void focusDirWidget(); //Backend Info passing diff --git a/src-qt5/desktop-utils/lumina-fm/MainUI.ui b/src-qt5/desktop-utils/lumina-fm/MainUI.ui index 8078b804..3c11d87e 100644 --- a/src-qt5/desktop-utils/lumina-fm/MainUI.ui +++ b/src-qt5/desktop-utils/lumina-fm/MainUI.ui @@ -176,11 +176,19 @@ <addaction name="separator"/> <addaction name="actionDelete_Selection"/> </widget> + <widget class="QMenu" name="menuGit"> + <property name="title"> + <string>Git</string> + </property> + <addaction name="actionRepo_Status"/> + <addaction name="actionClone_Repository"/> + </widget> <addaction name="menuFile"/> <addaction name="menuEdit"/> <addaction name="menuView"/> <addaction name="menuBookmarks"/> <addaction name="menuExternal_Devices"/> + <addaction name="menuGit"/> </widget> <widget class="QStatusBar" name="statusbar"/> <action name="actionNew_Tab"> @@ -426,6 +434,16 @@ <enum>Qt::ApplicationShortcut</enum> </property> </action> + <action name="actionRepo_Status"> + <property name="text"> + <string>Repo Status</string> + </property> + </action> + <action name="actionClone_Repository"> + <property name="text"> + <string>Clone Repository</string> + </property> + </action> </widget> <resources/> <connections/> diff --git a/src-qt5/desktop-utils/lumina-fm/gitCompat.h b/src-qt5/desktop-utils/lumina-fm/gitCompat.h index 6578bd5b..44c6d5b1 100644 --- a/src-qt5/desktop-utils/lumina-fm/gitCompat.h +++ b/src-qt5/desktop-utils/lumina-fm/gitCompat.h @@ -6,7 +6,7 @@ //=========================================== // This is the backend classe for interacting with the "git" utility //=========================================== -#ifdef _LUMINA_FM_GIT_COMPAT_H +#ifndef _LUMINA_FM_GIT_COMPAT_H #define _LUMINA_FM_GIT_COMPAT_H #include <QProcess> @@ -19,8 +19,8 @@ class GIT{ public: //Check if the git utility is installed and available static bool isAvailable(){ - QString bin = "git" - return isValidBinary(bin); + QString bin = "git"; + return LUtils::isValidBinary(bin); } //Return if the current directory is a git repository @@ -28,7 +28,8 @@ public: QProcess P; P.setProcessEnvironment(QProcessEnvironment::systemEnvironment()); P.setWorkingDirectory(dir); - P.exec("git",QStringList() <<"status" << "--porcelain" ); + P.start("git",QStringList() <<"status" << "--porcelain" ); + P.waitForFinished(); return (0==P.exitCode()); } @@ -38,22 +39,24 @@ public: P.setProcessEnvironment(QProcessEnvironment::systemEnvironment()); P.setWorkingDirectory(dir); P.setProcessChannelMode(QProcess::MergedChannels); - P.exec("git",QStringList() <<"status" ); + P.start("git",QStringList() <<"status" ); + P.waitForFinished(); return P.readAllStandardOutput(); } //Setup a process for running the clone operation (so the calling process can hook up any watchers and start it when ready) - static QProcess setupClone(QString indir, QString url, QString branch = "", int depth = -1){ - QProcess P; - P.setProcessEnvironment( QProcessEnvironment::systemEnvironment() ); - P.setWorkingDirectory(indir); - P.setProgram("git"); + static QProcess* setupClone(QString indir, QString url, QString branch = "", int depth = -1){ + //NOTE: The returned QProcess needs to be cleaned up when finished + QProcess *P = new QProcess(); + P->setProcessEnvironment( QProcessEnvironment::systemEnvironment() ); + P->setWorkingDirectory(indir); + P->setProgram("git"); QStringList args; args << "clone"; if(!branch.isEmpty()){ args << "-b" << branch; } if(depth>0){ args << "--depth" << QString::number(depth); } args << url; - P.setArguments(args); + P->setArguments(args); return P; } }; diff --git a/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro b/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro index e47ba2f6..7876af64 100644 --- a/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro +++ b/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro @@ -25,7 +25,8 @@ HEADERS += MainUI.h \ widgets/DDListWidgets.h \ widgets/MultimediaWidget.h \ widgets/SlideshowWidget.h \ - widgets/DirWidget.h + widgets/DirWidget.h \ + gitCompat.h FORMS += MainUI.ui \ FODialog.ui \ |