From 0b8657008bf89226d24259dcbe5730aa76a483e2 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 13 Sep 2016 14:11:39 -0400 Subject: 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. --- src-qt5/desktop-utils/lumina-fm/MainUI.cpp | 24 ++++++++++++++++++++++++ src-qt5/desktop-utils/lumina-fm/MainUI.h | 26 +++++++++++++++----------- src-qt5/desktop-utils/lumina-fm/MainUI.ui | 18 ++++++++++++++++++ src-qt5/desktop-utils/lumina-fm/gitCompat.h | 25 ++++++++++++++----------- src-qt5/desktop-utils/lumina-fm/lumina-fm.pro | 3 ++- 5 files changed, 73 insertions(+), 23 deletions(-) (limited to 'src-qt5/desktop-utils') 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 +#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 @@ + + + Git + + + + + @@ -426,6 +434,16 @@ Qt::ApplicationShortcut + + + Repo Status + + + + + Clone Repository + + 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 @@ -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 \ -- cgit From 1a9776b2cda75c0fcbf989a15989f2e4ab1e2e37 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 14 Sep 2016 11:48:24 -0400 Subject: Add the new Git cloning wizard to the source tree. This has not been tied into the build/interface yet. --- src-qt5/desktop-utils/lumina-fm/gitWizard.ui | 253 +++++++++++++++++++++++++++ 1 file changed, 253 insertions(+) create mode 100644 src-qt5/desktop-utils/lumina-fm/gitWizard.ui (limited to 'src-qt5/desktop-utils') diff --git a/src-qt5/desktop-utils/lumina-fm/gitWizard.ui b/src-qt5/desktop-utils/lumina-fm/gitWizard.ui new file mode 100644 index 00000000..a576ef63 --- /dev/null +++ b/src-qt5/desktop-utils/lumina-fm/gitWizard.ui @@ -0,0 +1,253 @@ + + + GitWizard + + + + 0 + 0 + 456 + 346 + + + + Clone a Git Repository + + + + + + + background: transparent; + + + QFrame::NoFrame + + + QFrame::Plain + + + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">Welcome!</span></p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This wizard will guide you through the process of downloading a GIT repository from the internet.</p></body></html> + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + GitHub Repository Settings + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + Organization/User + + + + + + + + + + Repository Name + + + + + + + + + + Is Private Repository + + + + + + + + + + + + + + Type of Access + + + + + + Use my SSH Key + + + true + + + + + + + Login to server + + + + + + + + + Username + + + + + + + QLineEdit::Password + + + Password + + + + + + + + + Anonymous (public repositories only) + + + + + + + QLineEdit::Password + + + Optional SSH Password + + + + + + + + + + Advanced Options + + + + + + Custom Depth + + + + + + + Single Branch + + + + + + + + + branch name + + + + + + + + + + + 1 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 11 + 50 + true + false + + + + Click "Finish" to start downloading the repository + + + + + + + + + -- cgit From 188efd21b0255be16813438ad593d098526a6745 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 15 Sep 2016 07:44:58 -0400 Subject: Add in the new Git Cloning Wizard. Now fully finished yet, but almost there. --- src-qt5/desktop-utils/lumina-fm/MainUI.cpp | 5 +- src-qt5/desktop-utils/lumina-fm/gitWizard.cpp | 81 +++++++++++++++++++++++++++ src-qt5/desktop-utils/lumina-fm/gitWizard.h | 43 ++++++++++++++ src-qt5/desktop-utils/lumina-fm/gitWizard.ui | 45 +++++---------- src-qt5/desktop-utils/lumina-fm/lumina-fm.pro | 9 ++- 5 files changed, 149 insertions(+), 34 deletions(-) create mode 100644 src-qt5/desktop-utils/lumina-fm/gitWizard.cpp create mode 100644 src-qt5/desktop-utils/lumina-fm/gitWizard.h (limited to 'src-qt5/desktop-utils') diff --git a/src-qt5/desktop-utils/lumina-fm/MainUI.cpp b/src-qt5/desktop-utils/lumina-fm/MainUI.cpp index 0300438a..abe14c0d 100644 --- a/src-qt5/desktop-utils/lumina-fm/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-fm/MainUI.cpp @@ -9,6 +9,7 @@ #include #include "gitCompat.h" +#include "gitWizard.h" #define DEBUG 0 @@ -626,7 +627,9 @@ void MainUI::on_actionRepo_Status_triggered(){ } void MainUI::on_actionClone_Repository_triggered(){ - + GitWizard *dlg = new GitWizard(this); + dlg->setWorkingDir( FindActiveBrowser()->currentDir() ); + dlg->show(); } diff --git a/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp b/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp new file mode 100644 index 00000000..042f3c89 --- /dev/null +++ b/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp @@ -0,0 +1,81 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2016, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +// This is the dialog for cloning a git repository +//=========================================== +#include "gitWizard.h" +#include "ui_gitWizard.h" + +#include "gitCompat.h" +#include + +GitWizard::GitWizard(QWidget *parent) : QWizard(parent), ui(new Ui::GitWizard){ + ui->setupUi(this); //load the designer form + connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(pageChanged(int)) ); + connect(this, SIGNAL(finished(int)), this, SLOT(finished(int)) ); +} + +GitWizard::~GitWizard(){ + +} + +//Input values; +void GitWizard::setWorkingDir(QString path){ + inDir = path; +} + +//============ +// PRIVATE +// ============ +QString GitWizard::assembleURL(){ + +} + +void GitWizard::showDownload(QProcess *P){ + +} + +//================ +// PRIVATE SLOTS +// ================ +void GitWizard::pageChanged(int newpage){ + //called when the "next" button is clicked + if(this->page(newpage)==ui->page_repo){ + + }else if(this->page(newpage)==ui->page_type){ + //Need to adjust items on this page based on info on last page + ui->radio_type_anon->setEnabled( !ui->check_privaterepo->isChecked() ); + ui->radio_type_ssh->setEnabled( QFile::exists(QDir::homePath()+"/.ssh/id_rsa") ); + //Now set the preferred type of login based on which are available + if(ui->radio_type_ssh->isEnabled()){ ui->radio_type_ssh->setChecked(true); } //SSH is preferred if that is available + else if(ui->radio_type_anon->isEnabled()){ ui->radio_type_anon->setChecked(true); } //anonymous next since it is a public repo - no creds really needed + else{ ui->radio_type_login->setChecked(true); } + //Clear any of the UI as needed + ui->line_user->clear(); ui->line_pass->clear(); ui->line_ssh_pass->clear(); + + }else{ + //qDebug() << "Unknown page!" << newpage; + } +} + +void GitWizard::finished(int res){ + //called when the "finish" button is clicked: + // res==0: window closed (rejected state) + // res==1: "finish" clicked (accepted state) + //qDebug() << "Got Finished:" << res; + if(res == QDialog::Accepted){ + qDebug() << "Run git clone"; + QString url = assembleUrl(); + QString branch; if(ui->check_brach->isChecked()){ branch = ui->line_branch->text(); } + int depth = -1; if(ui->check_depth->isChecked()){ depth = ui->spin_depth->value(); } + QProcess *proc = GIT::setupClone(inDir, url, branch, depth); + if(proc!=0){ + showDownload(proc); + } + } + + this->deleteLater(); +} diff --git a/src-qt5/desktop-utils/lumina-fm/gitWizard.h b/src-qt5/desktop-utils/lumina-fm/gitWizard.h new file mode 100644 index 00000000..a95ecb2b --- /dev/null +++ b/src-qt5/desktop-utils/lumina-fm/gitWizard.h @@ -0,0 +1,43 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2016, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +// This is the dialog for cloning a git repository +//=========================================== +#ifndef _LUMINA_FM_GIT_DIALOG_H +#define _LUMINA_FM_GIT_DIALOG_H + +#include +#include +#include + +namespace Ui{ + class GitWizard; +}; + +class GitWizard : public QWizard{ + Q_OBJECT +public: + GitWizard(QWidget *parent = 0); + ~GitWizard(); + + //Input values; + void setWorkingDir(QString path); + +private: + Ui::GitWizard *ui; + QString inDir; + + QString assembleURL(); + void showDownload(QProcess *P); + +private slots: + //Page Change slots + void pageChanged(int newpage); //called when the "next" button is clicked + void finished(int); //called when the "finish" button is clicked + +}; + +#endif diff --git a/src-qt5/desktop-utils/lumina-fm/gitWizard.ui b/src-qt5/desktop-utils/lumina-fm/gitWizard.ui index a576ef63..94aec4e0 100644 --- a/src-qt5/desktop-utils/lumina-fm/gitWizard.ui +++ b/src-qt5/desktop-utils/lumina-fm/gitWizard.ui @@ -13,32 +13,17 @@ Clone a Git Repository - + + QWizard::ModernStyle + + + + Welcome! + + + This wizard will guide you through the process of downloading a GIT repository from the internet. + - - - - background: transparent; - - - QFrame::NoFrame - - - QFrame::Plain - - - true - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">Welcome!</span></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This wizard will guide you through the process of downloading a GIT repository from the internet.</p></body></html> - - - @@ -82,7 +67,7 @@ p, li { white-space: pre-wrap; } - + Is Private Repository @@ -93,7 +78,7 @@ p, li { white-space: pre-wrap; } - + @@ -173,7 +158,7 @@ p, li { white-space: pre-wrap; } - + Single Branch @@ -182,7 +167,7 @@ p, li { white-space: pre-wrap; } - + branch name @@ -193,7 +178,7 @@ p, li { white-space: pre-wrap; } - + 1 diff --git a/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro b/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro index 7876af64..56314ee6 100644 --- a/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro +++ b/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro @@ -15,7 +15,8 @@ SOURCES += main.cpp \ BMMDialog.cpp \ widgets/MultimediaWidget.cpp \ widgets/SlideshowWidget.cpp \ - widgets/DirWidget.cpp + widgets/DirWidget.cpp \ + gitWizard.cpp HEADERS += MainUI.h \ FODialog.h \ @@ -26,14 +27,16 @@ HEADERS += MainUI.h \ widgets/MultimediaWidget.h \ widgets/SlideshowWidget.h \ widgets/DirWidget.h \ - gitCompat.h + gitCompat.h \ + gitWizard.h FORMS += MainUI.ui \ FODialog.ui \ BMMDialog.ui \ widgets/MultimediaWidget.ui \ widgets/SlideshowWidget.ui \ - widgets/DirWidget.ui + widgets/DirWidget.ui \ + gitWizard.ui icons.files = Insight-FileManager.png icons.path = $${L_SHAREDIR}/pixmaps -- cgit From 9010b1d10b2242d965dc8b66fa7616fe302adfd3 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 15 Sep 2016 08:17:36 -0400 Subject: Fix a couple compile errors in lumina-fm. --- src-qt5/desktop-utils/lumina-fm/gitWizard.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src-qt5/desktop-utils') diff --git a/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp b/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp index 042f3c89..f6d6f3b3 100644 --- a/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp +++ b/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp @@ -36,6 +36,8 @@ QString GitWizard::assembleURL(){ void GitWizard::showDownload(QProcess *P){ + + P->deleteLater(); } //================ @@ -68,8 +70,8 @@ void GitWizard::finished(int res){ //qDebug() << "Got Finished:" << res; if(res == QDialog::Accepted){ qDebug() << "Run git clone"; - QString url = assembleUrl(); - QString branch; if(ui->check_brach->isChecked()){ branch = ui->line_branch->text(); } + QString url = assembleURL(); + QString branch; if(ui->check_branch->isChecked()){ branch = ui->line_branch->text(); } int depth = -1; if(ui->check_depth->isChecked()){ depth = ui->spin_depth->value(); } QProcess *proc = GIT::setupClone(inDir, url, branch, depth); if(proc!=0){ @@ -77,5 +79,5 @@ void GitWizard::finished(int res){ } } - this->deleteLater(); + //this->deleteLater(); } -- cgit From 4e8537a11832f00b58334e805e2b9aede0fcd0ff Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 15 Sep 2016 14:04:02 -0400 Subject: Get the Git clone functionality all functional. The last thing missing is a graphical dialog showing the status of the download. --- src-qt5/desktop-utils/lumina-fm/gitCompat.h | 35 ++++++++++++-- src-qt5/desktop-utils/lumina-fm/gitWizard.cpp | 70 ++++++++++++++++++++++++--- src-qt5/desktop-utils/lumina-fm/gitWizard.h | 8 ++- src-qt5/desktop-utils/lumina-fm/gitWizard.ui | 4 +- src-qt5/desktop-utils/lumina-fm/lumina-fm.pro | 1 + 5 files changed, 101 insertions(+), 17 deletions(-) (limited to 'src-qt5/desktop-utils') diff --git a/src-qt5/desktop-utils/lumina-fm/gitCompat.h b/src-qt5/desktop-utils/lumina-fm/gitCompat.h index 44c6d5b1..a8b5bd1f 100644 --- a/src-qt5/desktop-utils/lumina-fm/gitCompat.h +++ b/src-qt5/desktop-utils/lumina-fm/gitCompat.h @@ -4,7 +4,7 @@ // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== -// This is the backend classe for interacting with the "git" utility +// This is the backend class for interacting with the "git" utility //=========================================== #ifndef _LUMINA_FM_GIT_COMPAT_H #define _LUMINA_FM_GIT_COMPAT_H @@ -12,9 +12,35 @@ #include #include #include - +#include +#include #include +#include + +class GitProcess : public QProcess{ + Q_OBJECT +private: + QString log; + QFile tmpfile; +public: + GitProcess(); + ~GitProcess(); + + //Optional Inputs + void setSSHPassword(QString pass); //This is only used for SSH access + +private slots: + void cleanup(); + void printoutput(){ qDebug() << "Proc Output:" << this->readAllStandardOutput(); } + +protected: + virtual void setupChildProcess(){ + //Need to disable the controlling terminal within this process + setsid(); //Make current process new session leader - resulting in no controlling terminal for this session + } +}; + class GIT{ public: //Check if the git utility is installed and available @@ -45,10 +71,9 @@ public: } //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){ + static GitProcess* 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() ); + GitProcess *P = new GitProcess(); P->setWorkingDirectory(indir); P->setProgram("git"); QStringList args; diff --git a/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp b/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp index f6d6f3b3..8f0e6199 100644 --- a/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp +++ b/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp @@ -11,11 +11,23 @@ #include "gitCompat.h" #include +#include GitWizard::GitWizard(QWidget *parent) : QWizard(parent), ui(new Ui::GitWizard){ ui->setupUi(this); //load the designer form connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(pageChanged(int)) ); connect(this, SIGNAL(finished(int)), this, SLOT(finished(int)) ); + connect(ui->line_repo_org, SIGNAL(textChanged(const QString&)), this, SLOT(validateRepo()) ); + connect(ui->line_repo_name, SIGNAL(textChanged(const QString&)), this, SLOT(validateRepo()) ); + connect(ui->line_ssh_pass, SIGNAL(textChanged(const QString&)), this, SLOT(validateType()) ); + connect(ui->line_user, SIGNAL(textChanged(const QString&)), this, SLOT(validateType()) ); + connect(ui->line_pass, SIGNAL(textChanged(const QString&)), this, SLOT(validateType()) ); + connect(ui->radio_type_ssh, SIGNAL(clicked()), this, SLOT(validateType()) ); + connect(ui->radio_type_login, SIGNAL(clicked()), this, SLOT(validateType()) ); + connect(ui->radio_type_anon, SIGNAL(clicked()), this, SLOT(validateType()) ); + connect(ui->check_depth, SIGNAL(clicked()), this, SLOT(validateType()) ); + connect(ui->check_branch, SIGNAL(clicked()), this, SLOT(validateType()) ); + validateRepo(); } GitWizard::~GitWizard(){ @@ -31,12 +43,26 @@ void GitWizard::setWorkingDir(QString path){ // PRIVATE // ============ QString GitWizard::assembleURL(){ + QString repo = ui->line_repo_org->text()+"/"+ui->line_repo_name->text()+".git"; + QString url; + if(ui->radio_type_ssh->isChecked()){ url = "git@github.com:"+repo; } + else if(ui->radio_type_anon->isChecked()){ url = "https://github.com/"+repo; } + else if(ui->radio_type_login->isChecked()){ + url = "https://"+ui->line_user->text()+":"+ui->line_pass->text()+"@github.com/"+repo; + } + return url; } -void GitWizard::showDownload(QProcess *P){ - - +void GitWizard::showDownload(GitProcess *P){ + P->start(QIODevice::ReadOnly); + //P->closeWriteChannel(); + //P->closeReadChannel(GitProcess::StandardOutput); + //P->closeReadChannel(GitProcess::StandardError); + while(P->state()!=QProcess::NotRunning){ + this->thread()->usleep(50000); //50 ms + QApplication::processEvents(); + } P->deleteLater(); } @@ -46,18 +72,18 @@ void GitWizard::showDownload(QProcess *P){ void GitWizard::pageChanged(int newpage){ //called when the "next" button is clicked if(this->page(newpage)==ui->page_repo){ - + validateRepo(); }else if(this->page(newpage)==ui->page_type){ //Need to adjust items on this page based on info on last page ui->radio_type_anon->setEnabled( !ui->check_privaterepo->isChecked() ); - ui->radio_type_ssh->setEnabled( QFile::exists(QDir::homePath()+"/.ssh/id_rsa") ); + ui->radio_type_ssh->setEnabled( QFile::exists(QDir::homePath()+"/.ssh/id_rsa") ); //TODO - Disable for now until SSH passphrases can be used properly //Now set the preferred type of login based on which are available if(ui->radio_type_ssh->isEnabled()){ ui->radio_type_ssh->setChecked(true); } //SSH is preferred if that is available else if(ui->radio_type_anon->isEnabled()){ ui->radio_type_anon->setChecked(true); } //anonymous next since it is a public repo - no creds really needed else{ ui->radio_type_login->setChecked(true); } //Clear any of the UI as needed ui->line_user->clear(); ui->line_pass->clear(); ui->line_ssh_pass->clear(); - + validateType(); }else{ //qDebug() << "Unknown page!" << newpage; } @@ -73,11 +99,39 @@ void GitWizard::finished(int res){ QString url = assembleURL(); QString branch; if(ui->check_branch->isChecked()){ branch = ui->line_branch->text(); } int depth = -1; if(ui->check_depth->isChecked()){ depth = ui->spin_depth->value(); } - QProcess *proc = GIT::setupClone(inDir, url, branch, depth); + GitProcess *proc = GIT::setupClone(inDir, url, branch, depth); if(proc!=0){ + if(ui->radio_type_ssh->isChecked()){ + proc->setSSHPassword(ui->line_ssh_pass->text()); + } showDownload(proc); } } - //this->deleteLater(); + this->deleteLater(); +} + +//Page validation slots +void GitWizard::validateRepo(){ + bool ok = !ui->line_repo_org->text().isEmpty() && !ui->line_repo_name->text().isEmpty(); + this->button(QWizard::NextButton)->setEnabled(ok); +} + +void GitWizard::validateType(){ + bool ok = false; + //Check types first + if(ui->radio_type_login->isChecked()){ ok = !ui->line_user->text().isEmpty() && !ui->line_pass->text().isEmpty(); } + else{ ok = true; } + //Now check optional settings + if(ui->check_branch->isChecked()){ ok = ok && !ui->line_branch->text().isEmpty(); } + if(ui->check_branch->isChecked()){ ok = ok && !ui->line_branch->text().isEmpty(); } + //Now make interface boxes appear/disappear as needed + ui->line_ssh_pass->setVisible(ui->radio_type_ssh->isChecked()); + ui->line_user->setVisible(ui->radio_type_login->isChecked()); + ui->line_pass->setVisible(ui->radio_type_login->isChecked()); + ui->spin_depth->setVisible(ui->check_depth->isChecked()); + ui->line_branch->setVisible(ui->check_branch->isChecked()); + + //Update the button as needed + this->button(QWizard::FinishButton)->setEnabled(ok); } diff --git a/src-qt5/desktop-utils/lumina-fm/gitWizard.h b/src-qt5/desktop-utils/lumina-fm/gitWizard.h index a95ecb2b..e68ac82d 100644 --- a/src-qt5/desktop-utils/lumina-fm/gitWizard.h +++ b/src-qt5/desktop-utils/lumina-fm/gitWizard.h @@ -11,7 +11,8 @@ #include #include -#include + +#include "gitCompat.h" namespace Ui{ class GitWizard; @@ -31,13 +32,16 @@ private: QString inDir; QString assembleURL(); - void showDownload(QProcess *P); + void showDownload(GitProcess *P); private slots: //Page Change slots void pageChanged(int newpage); //called when the "next" button is clicked void finished(int); //called when the "finish" button is clicked + //Page validation slots + void validateRepo(); //for page_repo + void validateType(); //for page_type }; #endif diff --git a/src-qt5/desktop-utils/lumina-fm/gitWizard.ui b/src-qt5/desktop-utils/lumina-fm/gitWizard.ui index 94aec4e0..86a5ccb1 100644 --- a/src-qt5/desktop-utils/lumina-fm/gitWizard.ui +++ b/src-qt5/desktop-utils/lumina-fm/gitWizard.ui @@ -54,7 +54,7 @@ - + @@ -64,7 +64,7 @@ - + diff --git a/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro b/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro index 56314ee6..91e2952c 100644 --- a/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro +++ b/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro @@ -16,6 +16,7 @@ SOURCES += main.cpp \ widgets/MultimediaWidget.cpp \ widgets/SlideshowWidget.cpp \ widgets/DirWidget.cpp \ + gitCompat.cpp \ gitWizard.cpp HEADERS += MainUI.h \ -- cgit From 9f79342ab366a74a26b2957e88af265e90658025 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 15 Sep 2016 14:47:06 -0400 Subject: Get the progress reporting all setup for the git clone. Now it is all set and ready for use! --- src-qt5/desktop-utils/lumina-fm/gitCompat.cpp | 45 +++++++++++++++++++++++++++ src-qt5/desktop-utils/lumina-fm/gitCompat.h | 4 +-- src-qt5/desktop-utils/lumina-fm/gitWizard.cpp | 43 ++++++++++++------------- src-qt5/desktop-utils/lumina-fm/gitWizard.h | 24 ++++++++++++-- src-qt5/desktop-utils/lumina-fm/gitWizard.ui | 16 +++++++++- 5 files changed, 106 insertions(+), 26 deletions(-) create mode 100644 src-qt5/desktop-utils/lumina-fm/gitCompat.cpp (limited to 'src-qt5/desktop-utils') diff --git a/src-qt5/desktop-utils/lumina-fm/gitCompat.cpp b/src-qt5/desktop-utils/lumina-fm/gitCompat.cpp new file mode 100644 index 00000000..18e83e6a --- /dev/null +++ b/src-qt5/desktop-utils/lumina-fm/gitCompat.cpp @@ -0,0 +1,45 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2016, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +// This is the backend classe for interacting with the "git" utility +//=========================================== +#include "gitCompat.h" +#include + +#define TMPFILE QString("/tmp/.") +GitProcess::GitProcess() : QProcess(){ + this->setProcessChannelMode(QProcess::MergedChannels); + tmpfile.setFileName(TMPFILE +QString::number( (rand()%8999) + 1000 )); + //qDebug() << "Temporary File Name:" << tmpfile.fileName(); + tmpfile.setParent(this); + connect(this, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(cleanup()) ); + connect(this, SIGNAL(readyReadStandardOutput()), this, SLOT(printoutput()) ); +} + +GitProcess::~GitProcess(){ + if(tmpfile.exists()){ tmpfile.remove(); } //ensure that password file never gets left behind +} + +void GitProcess::setSSHPassword(QString pass){ + //Save the password into the temporary file + if( tmpfile.open(QIODevice::WriteOnly) ){ + QTextStream in(&tmpfile); + in << "#!/bin/sh"<<"\n"; + in << "echo \""+pass+"\"" << "\n"; + in << "rm "+tmpfile.fileName()+"\n"; //have the script clean itself up after running once + tmpfile.close(); + } + tmpfile.setPermissions( QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner ); + QApplication::processEvents(); + QProcessEnvironment env = this->processEnvironment(); + env.insert("SSH_ASKPASS", tmpfile.fileName()); + env.insert("DISPLAY",":0"); //will not actually be used - the tmp file sends the password back instantly + this->setProcessEnvironment(env); +} + +void GitProcess::cleanup(){ + if(tmpfile.exists()){ tmpfile.remove(); } //ensure that password file never gets left behind +} diff --git a/src-qt5/desktop-utils/lumina-fm/gitCompat.h b/src-qt5/desktop-utils/lumina-fm/gitCompat.h index a8b5bd1f..3e6cb15e 100644 --- a/src-qt5/desktop-utils/lumina-fm/gitCompat.h +++ b/src-qt5/desktop-utils/lumina-fm/gitCompat.h @@ -32,7 +32,7 @@ public: private slots: void cleanup(); - void printoutput(){ qDebug() << "Proc Output:" << this->readAllStandardOutput(); } + //void printoutput(){ qDebug() << "Proc Output:" << this->readAllStandardOutput(); } protected: virtual void setupChildProcess(){ @@ -77,7 +77,7 @@ public: P->setWorkingDirectory(indir); P->setProgram("git"); QStringList args; - args << "clone"; + args << "clone" << "--progress"; if(!branch.isEmpty()){ args << "-b" << branch; } if(depth>0){ args << "--depth" << QString::number(depth); } args << url; diff --git a/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp b/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp index 8f0e6199..7edfc95f 100644 --- a/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp +++ b/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp @@ -15,8 +15,9 @@ GitWizard::GitWizard(QWidget *parent) : QWizard(parent), ui(new Ui::GitWizard){ ui->setupUi(this); //load the designer form + proc = 0; //not initialized yet connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(pageChanged(int)) ); - connect(this, SIGNAL(finished(int)), this, SLOT(finished(int)) ); + //connect(this, SIGNAL(finished(int)), this, SLOT(finished(int)) ); connect(ui->line_repo_org, SIGNAL(textChanged(const QString&)), this, SLOT(validateRepo()) ); connect(ui->line_repo_name, SIGNAL(textChanged(const QString&)), this, SLOT(validateRepo()) ); connect(ui->line_ssh_pass, SIGNAL(textChanged(const QString&)), this, SLOT(validateType()) ); @@ -31,7 +32,7 @@ GitWizard::GitWizard(QWidget *parent) : QWizard(parent), ui(new Ui::GitWizard){ } GitWizard::~GitWizard(){ - + if(proc!=0){ proc->deleteLater(); } } //Input values; @@ -54,8 +55,8 @@ QString GitWizard::assembleURL(){ return url; } -void GitWizard::showDownload(GitProcess *P){ - P->start(QIODevice::ReadOnly); +/*void GitWizard::showDownload(GitProcess *P){ + //P->closeWriteChannel(); //P->closeReadChannel(GitProcess::StandardOutput); //P->closeReadChannel(GitProcess::StandardError); @@ -64,7 +65,7 @@ void GitWizard::showDownload(GitProcess *P){ QApplication::processEvents(); } P->deleteLater(); -} +}*/ //================ // PRIVATE SLOTS @@ -84,31 +85,22 @@ void GitWizard::pageChanged(int newpage){ //Clear any of the UI as needed ui->line_user->clear(); ui->line_pass->clear(); ui->line_ssh_pass->clear(); validateType(); - }else{ - //qDebug() << "Unknown page!" << newpage; - } -} - -void GitWizard::finished(int res){ - //called when the "finish" button is clicked: - // res==0: window closed (rejected state) - // res==1: "finish" clicked (accepted state) - //qDebug() << "Got Finished:" << res; - if(res == QDialog::Accepted){ + }else if(this->page(newpage)==ui->page_download){ qDebug() << "Run git clone"; QString url = assembleURL(); QString branch; if(ui->check_branch->isChecked()){ branch = ui->line_branch->text(); } int depth = -1; if(ui->check_depth->isChecked()){ depth = ui->spin_depth->value(); } - GitProcess *proc = GIT::setupClone(inDir, url, branch, depth); + proc = GIT::setupClone(inDir, url, branch, depth); if(proc!=0){ + connect(proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readProc()) ); + connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(procFinished(int)) ); if(ui->radio_type_ssh->isChecked()){ proc->setSSHPassword(ui->line_ssh_pass->text()); } - showDownload(proc); + proc->start(QIODevice::ReadOnly); + this->button(QWizard::FinishButton)->setEnabled(false); } } - - this->deleteLater(); } //Page validation slots @@ -133,5 +125,14 @@ void GitWizard::validateType(){ ui->line_branch->setVisible(ui->check_branch->isChecked()); //Update the button as needed - this->button(QWizard::FinishButton)->setEnabled(ok); + this->button(QWizard::NextButton)->setEnabled(ok); +} + +void GitWizard::readProc(){ + ui->text_procOutput->append( proc->readAllStandardOutput() ); } + +void GitWizard::procFinished(int retcode){ + this->button(QWizard::FinishButton)->setEnabled(true); +} + diff --git a/src-qt5/desktop-utils/lumina-fm/gitWizard.h b/src-qt5/desktop-utils/lumina-fm/gitWizard.h index e68ac82d..4a6ec2bc 100644 --- a/src-qt5/desktop-utils/lumina-fm/gitWizard.h +++ b/src-qt5/desktop-utils/lumina-fm/gitWizard.h @@ -11,6 +11,7 @@ #include #include +#include #include "gitCompat.h" @@ -30,18 +31,37 @@ public: private: Ui::GitWizard *ui; QString inDir; + GitProcess *proc; QString assembleURL(); - void showDownload(GitProcess *P); + //void showDownload(GitProcess *P); private slots: //Page Change slots void pageChanged(int newpage); //called when the "next" button is clicked - void finished(int); //called when the "finish" button is clicked + //void finished(int); //called when the "finish" button is clicked //Page validation slots void validateRepo(); //for page_repo void validateType(); //for page_type + + //process output + void readProc(); + void procFinished(int retcode); + +protected: + void closeEvent(QCloseEvent *ev){ + //Make sure the process is not running first + if(proc!=0 && proc->state()!=QProcess::NotRunning){ + ev->ignore(); + if(QMessageBox::Yes == QMessageBox::question(this, tr("Stop Download?"), tr("Kill the current download?") ) ){ + proc->kill(); + } + }else{ + QWizard::closeEvent(ev); + this->deleteLater(); //we need to clean this up completely + } + } }; #endif diff --git a/src-qt5/desktop-utils/lumina-fm/gitWizard.ui b/src-qt5/desktop-utils/lumina-fm/gitWizard.ui index 86a5ccb1..0f5894b6 100644 --- a/src-qt5/desktop-utils/lumina-fm/gitWizard.ui +++ b/src-qt5/desktop-utils/lumina-fm/gitWizard.ui @@ -16,6 +16,9 @@ QWizard::ModernStyle + + QWizard::NoBackButtonOnLastPage|QWizard::NoBackButtonOnStartPage|QWizard::NoCancelButtonOnLastPage + Welcome! @@ -226,7 +229,18 @@ - Click "Finish" to start downloading the repository + Click "Next" to start downloading the repository + + + + + + + + + + + true -- cgit From 2c2e23b4f48b7c631e00e774c01ec73c49ef5039 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 16 Sep 2016 09:00:09 -0400 Subject: Fix up the highlighting of characters where the start character is already within a different highlight block (do not stack them - that start char was already handled and is off limits). --- src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h | 2 +- src-qt5/desktop-utils/lumina-textedit/tests/test.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src-qt5/desktop-utils') diff --git a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h index 781ff65d..f834e275 100644 --- a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h +++ b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h @@ -101,7 +101,7 @@ protected: if(splitactive>=0 || index=0){ int len = patt.matchedLength(); - setFormat(index, len, rules[i].format); + if(format(index)==currentBlock().charFormat()){ setFormat(index, len, rules[i].format); } //only apply highlighting if not within a section already index = patt.indexIn(text, index+len); //go to the next match } }//end loop over normal (single-line) patterns diff --git a/src-qt5/desktop-utils/lumina-textedit/tests/test.cpp b/src-qt5/desktop-utils/lumina-textedit/tests/test.cpp index 1b50e302..e135227d 100644 --- a/src-qt5/desktop-utils/lumina-textedit/tests/test.cpp +++ b/src-qt5/desktop-utils/lumina-textedit/tests/test.cpp @@ -13,3 +13,6 @@ comment */ stuff some /*single line comment with multi-line tags */ + +"some text" +"some text with url: http://sample.com" -- cgit From 088eebf68aa06de3e9ec34ed9bbcc08625d44a9e Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 16 Sep 2016 09:42:50 -0400 Subject: Add syntax highlighting for "shell" files (.sh) --- .../lumina-textedit/syntaxSupport.cpp | 62 ++++++++++++++++++++++ .../desktop-utils/lumina-textedit/tests/test.sh | 10 ++++ 2 files changed, 72 insertions(+) create mode 100644 src-qt5/desktop-utils/lumina-textedit/tests/test.sh (limited to 'src-qt5/desktop-utils') diff --git a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp index 7dcad6c3..0edb2160 100644 --- a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp +++ b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp @@ -10,6 +10,7 @@ QStringList Custom_Syntax::availableRules(){ QStringList avail; avail << "C++"; //avail << "Python"; + avail << "Shell"; avail << "reST"; return avail; } @@ -40,6 +41,7 @@ QString Custom_Syntax::ruleForFile(QString filename){ QString suffix = filename.section(".",-1); if(suffix=="cpp" || suffix=="hpp" || suffix=="c" || suffix=="h"){ return "C++"; } //else if(suffix=="py" || suffix=="pyc"){ return "Python"; } + else if(suffix=="sh"){ return "Shell"; } else if(suffix=="rst"){ return "reST"; } return ""; } @@ -101,6 +103,66 @@ void Custom_Syntax::loadRules(QString type){ srule.endPattern = QRegExp("\\*/"); splitrules << srule; + }else if(type=="Shell"){ + //Keywords (standard Shell definitions) + QStringList keywords; + keywords << "alias" << "alloc" << "bg" << "bind" << " bindkey" << "break" \ + << "breaksw"<<"builtins"<<"case"<<"cd"<<"chdir"<<"command"<<"complete"<<"continue"<<"default" \ + <<"dirs"<<"do"<<"done"<<"echo"<<"echotc"<<"elif"<<"else"<<"end"<<"endif"<<"endsw"<<"esac"<<"eval" \ + <<"exec"<<"exit"<<"export"<<"false"<<"fc"<<"fg"<<"filetest"<<"fi"<<"for"<<"foreach"<<"getopts" \ + <<"glob"<<"goto"<<"hash"<<"hashstat"<<"history"<<"hup"<<"if"<<"jobid"<<"jobs"<<"kill"<<"limit" \ + <<"local"<<"log"<<"login"<<"logout"<<"ls-F"<<"nice"<<"nohup"<<"notify"<<"onintr"<<"popd" \ + <<"printenv"<<"printf"<<"pushd"<<"pwd"<<"read"<<"readonly"<<"rehash"<<"repeat"<<"return" \ + <<"sched"<<"set"<<"setenv"<<"settc"<<"setty"<<"setvar"<<"shift"<<"source"<<"stop"<<"suspend" \ + <<"switch"<<"telltc"<<"test"<<"then"<<"time"<<"times"<<"trap"<<"true"<<"type"<<"ulimit"<<"umask" \ + <<"unalias"<<"uncomplete"<<"unhash"<<"unlimit"<<"unset"<<"unsetenv"<<"until"<<"wait" \ + <<"where"<<"which"<<"while"; + + SyntaxRule rule; + rule.format.setForeground( QColor(settings->value("colors/keyword").toString()) ); + rule.format.setFontWeight(QFont::Bold); + for(int i=0; ivalue("colors/altkeyword").toString()) ); + for(int i=0; ivalue("colors/class").toString()) ); + rule.pattern = QRegExp("\\$\\{[^\\n\\}]+\\}"); + rules << rule; + rule.pattern = QRegExp("\\$[^\\s$]+(?=\\s|$)"); + rules << rule; + //Quotes + rule.format.setForeground( QColor(settings->value("colors/text").toString()) ); + rule.format.setFontWeight(QFont::Normal); + rule.pattern = QRegExp( "\"[^\"\\\\]*(\\\\(.|\\n)[^\"\\\\]*)*\"|'[^'\\\\]*(\\\\(.|\\n)[^'\\\\]*)*'"); + rules << rule; + //Functions + rule.format.setForeground( QColor(settings->value("colors/function").toString()) ); + rule.pattern = QRegExp("\\b[A-Za-z0-9_]+(?=\\()"); + rules << rule; + //Proprocessor commands + rule.format.setForeground( QColor(settings->value("colors/preprocessor").toString()) ); + rule.pattern = QRegExp("^#![^\n]*"); + rules << rule; + //Comment (single line) + rule.format.setForeground( QColor(settings->value("colors/comment").toString()) ); + rule.pattern = QRegExp("#[^\n]*"); + rules << rule; + //Comment (multi-line) + //SyntaxRuleSplit srule; + //srule.format = rule.format; //re-use the single-line comment format + //srule.startPattern = QRegExp("/\\*"); + //srule.endPattern = QRegExp("\\*/"); + //splitrules << srule; + }else if(type=="Python"){ //Keywords QStringList keywords; diff --git a/src-qt5/desktop-utils/lumina-textedit/tests/test.sh b/src-qt5/desktop-utils/lumina-textedit/tests/test.sh new file mode 100644 index 00000000..8eb7450c --- /dev/null +++ b/src-qt5/desktop-utils/lumina-textedit/tests/test.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +echo "some text" #with a comment +for i in ["a","b","c"] +do +echo ${i}withsometext +done + +variable$variable sdfgbuj +variable${variable}satoibnsoin -- cgit