This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch master in repository x2goclient. from 0ac3903 Update Win32 OpenSSL to 1.0.1i and Cygwin OpenSSL to 1.0.1i-1 new 9a7a47e Add folder explorer - GUI to management of sessions folders. The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: debian/changelog | 1 + folderbutton.cpp | 54 +++++++-- folderbutton.h | 10 ++ folderexplorer.cpp | 160 +++++++++++++++++++++++++++ brokerpassdlg.h => folderexplorer.h | 41 ++++--- folderexplorer.ui | 118 ++++++++++++++++++++ onmainwindow.h | 5 + sessionbutton.cpp | 2 - sessionbutton.h | 5 + sessionexplorer.cpp | 209 +++++++++++++++++++++++++++++++++++ sessionexplorer.h | 12 ++ sessionwidget.cpp | 46 +++++++- sessionwidget.h | 3 + x2goclient.pro | 9 +- 14 files changed, 636 insertions(+), 39 deletions(-) create mode 100644 folderexplorer.cpp copy brokerpassdlg.h => folderexplorer.h (64%) create mode 100644 folderexplorer.ui -- Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goclient. commit 9a7a47e2fbe99d7d11a6712a83cdfc2da3b327c7 Author: Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> Date: Wed Aug 13 15:33:08 2014 +0200 Add folder explorer - GUI to management of sessions folders. --- debian/changelog | 1 + folderbutton.cpp | 54 ++++++++-- folderbutton.h | 10 ++ folderexplorer.cpp | 160 +++++++++++++++++++++++++++ folderbutton.h => folderexplorer.h | 63 ++++------- folderexplorer.ui | 118 ++++++++++++++++++++ onmainwindow.h | 5 + sessionbutton.cpp | 2 - sessionbutton.h | 5 + sessionexplorer.cpp | 209 ++++++++++++++++++++++++++++++++++++ sessionexplorer.h | 12 +++ sessionwidget.cpp | 46 +++++++- sessionwidget.h | 3 + x2goclient.pro | 9 +- 14 files changed, 632 insertions(+), 65 deletions(-) diff --git a/debian/changelog b/debian/changelog index a266a28..8534eec 100644 --- a/debian/changelog +++ b/debian/changelog @@ -29,6 +29,7 @@ x2goclient (4.0.3.0-0x2go1) UNRELEASED; urgency=low x2gohelper. - Add Makefile for x2gohelper. - Add support for sessions folders. + - Add folder explorer - GUI to management of sessions folders. [ Mike DePaulo ] * New upstream release (4.0.3.0): diff --git a/folderbutton.cpp b/folderbutton.cpp index 28c7a2b..1c12f97 100644 --- a/folderbutton.cpp +++ b/folderbutton.cpp @@ -76,34 +76,68 @@ FolderButton::FolderButton ( ONMainWindow* mw,QWidget *parent, QString folderPat icon=new QLabel ( this ); - QString sessIcon=":icons/128x128/folder.png"; - QPixmap* pix=new QPixmap( sessIcon ); nameLabel->setWordWrap(true); nameLabel->setTextInteractionFlags(Qt::NoTextInteraction); - icon->move ( 10,10 ); + icon->move ( 10,25 ); if ( !miniMode ) { nameLabel->move ( 80,34 ); nameLabel->setFixedSize(235,135); - icon->setPixmap ( pix->scaled ( 64,64,Qt::IgnoreAspectRatio, - Qt::SmoothTransformation ) ); } else { nameLabel->move ( 64,18 ); nameLabel->setFixedSize(170,120); - icon->setPixmap ( pix->scaled ( 48,48,Qt::IgnoreAspectRatio, - Qt::SmoothTransformation ) ); } - delete pix; - + loadIcon(); } FolderButton::~FolderButton() {} +void FolderButton::loadIcon() +{ + X2goSettings *st; + + if (par->getBrokerMode()) + st=new X2goSettings(par->getConfig()->iniFile,QSettings::IniFormat); + else + st= new X2goSettings( "sessions" ); + + QString sessIcon=":icons/128x128/folder.png"; + QPixmap* pix; + + QString normPath=(path+"/"+name).split("/",QString::SkipEmptyParts).join("::"); + + QByteArray picture=st->setting()->value ( normPath, + ( QVariant )QByteArray()).toByteArray(); + if(!picture.size()) + { + pix=new QPixmap( sessIcon ); + } + else + { + pix=new QPixmap(); + pix->loadFromData(picture); + } + bool miniMode=par->retMiniMode(); + + if ( !miniMode ) + { + icon->setPixmap ( pix->scaled ( 64,64,Qt::IgnoreAspectRatio, + Qt::SmoothTransformation ) ); + } + else + { + icon->setPixmap ( pix->scaled ( 48,48,Qt::IgnoreAspectRatio, + Qt::SmoothTransformation ) ); + } + + delete pix; +} + void FolderButton::slotClicked() { emit folderSelected ( this ); @@ -118,14 +152,12 @@ bool FolderButton::lessThen ( const FolderButton* b1, void FolderButton::mousePressEvent ( QMouseEvent * event ) { - x2goDebug<<"mpress"; SVGFrame::mousePressEvent ( event ); loadBg ( ":/svg/folder_grey.svg" ); } void FolderButton::mouseReleaseEvent ( QMouseEvent * event ) { - x2goDebug<<"mrelease"; SVGFrame::mouseReleaseEvent ( event ); int x=event->x(); int y=event->y(); diff --git a/folderbutton.h b/folderbutton.h index a5eaf99..9eba380 100644 --- a/folderbutton.h +++ b/folderbutton.h @@ -47,6 +47,16 @@ public: { return path; } + void setPath(QString path) + { + this->path=path; + } + void setName(QString name) + { + this->name=name; + } + void loadIcon(); + void setChildrenList(QStringList children); private: QString path; diff --git a/folderexplorer.cpp b/folderexplorer.cpp new file mode 100644 index 0000000..569cd2a --- /dev/null +++ b/folderexplorer.cpp @@ -0,0 +1,160 @@ +/************************************************************************** +* Copyright (C) 2005-2014 by Oleksandr Shneyder * +* o.shneyder@phoca-gmbh.de * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program. If not, see <http://www.gnu.org/licenses/>. * +***************************************************************************/ +#include "folderexplorer.h" +#include "x2gologdebug.h" +#include "sessionexplorer.h" +#include "folderbutton.h" +#include <QMenu> +#include <QFileDialog> +#include <QInputDialog> +#include <QMessageBox> + +FolderExplorer::FolderExplorer(QString path, SessionExplorer* explorer, QWidget* parent):QDialog(parent) +{ + setupUi(this); + this->explorer=explorer; + root=new QTreeWidgetItem(treeWidget); + root->setText(0,"/"); + root->setIcon(0,QIcon(":icons/128x128/folder.png")); + currentPath=path; + initFolders(root, ""); + root->setExpanded(true); + if(currentPath=="/") + root->setSelected(true); + root->setData(0,Qt::UserRole, "/"); + +} + +void FolderExplorer::initFolders(QTreeWidgetItem* parent, QString path) +{ + FolderButton* b; + foreach(b, *(explorer->getFoldersList())) + { + if(b->getPath()==path) + { + QTreeWidgetItem* it=new QTreeWidgetItem(parent); + it->setText(0,b->getName()); + it->setIcon(0, QIcon(*(b->folderIcon()))); + QString normPath=(b->getPath()+"/"+b->getName()).split("/",QString::SkipEmptyParts).join("/"); + it->setData(0,Qt::UserRole, normPath+"/"); + if(normPath+"/"==currentPath) + { + + it->setSelected(true); + QTreeWidgetItem* p=it->parent(); + while(p!=root) + { + p->setExpanded(true); + p=p->parent(); + } + } + initFolders(it, normPath); + } + } +} + +void FolderExplorer::slotContextMenu(QPoint p) +{ + menuItem=treeWidget->itemAt(p); + if(!menuItem) + return; + + QMenu menu(treeWidget); + connect(menu.addAction(tr("Create New Folder")), SIGNAL(triggered(bool)), this, SLOT(slotNewFolder())); + + if(menuItem!=root) + { + connect(menu.addAction(tr("Rename Folder...")), SIGNAL(triggered(bool)), this, SLOT(slotChangeName())); + connect(menu.addAction(tr("Change Icon...")), SIGNAL(triggered(bool)), this, SLOT(slotChangeIcon())); + connect(menu.addAction(tr("Delete Folder...")), SIGNAL(triggered(bool)), this, SLOT(slotDeleteFolder())); + } + menu.exec(treeWidget->viewport()->mapToGlobal(p)); +} + +void FolderExplorer::slotItemSelected(QTreeWidgetItem* it, int) +{ + currentPath=it->data(0,Qt::UserRole).toString(); +} + +void FolderExplorer::slotChangeIcon() +{ + QString path= QFileDialog::getOpenFileName ( + this, + tr ( "Open picture" ), + QDir::homePath(), + tr ( "Pictures" ) +" (*.png *.xpm *.jpg)" ); + if ( path!=QString::null ) + { + explorer->setFolderIcon(menuItem->data(0, Qt::UserRole).toString(), path); + menuItem->setIcon(0, QIcon(path)); + } +} + +void FolderExplorer::slotChangeName() +{ + bool ok; + QString oldPath=menuItem->data(0,Qt::UserRole).toString(); + QStringList parts=oldPath.split("/",QString::SkipEmptyParts); + QString text = QInputDialog::getText(this, tr("X2Go Client"), + tr("Folder Name:"), QLineEdit::Normal, + parts.last(), &ok); + if (ok && !text.isEmpty()) + { + menuItem->setText(0,text); + parts.pop_back(); + parts<<text; + currentPath= parts.join("/")+"/"; + menuItem->setData(0,Qt::UserRole, currentPath); + explorer->renameFolder(oldPath, currentPath); + } +} + +void FolderExplorer::slotDeleteFolder() +{ + if(!explorer->isFolderEmpty(menuItem->data(0, Qt::UserRole).toString())) + { + QMessageBox::critical(this, tr("Error"), tr("Unable to remove \"")+menuItem->text(0)+ + tr("\". Folder is not empty. Please remove content of folder and try again.")); + return; + } + if(QMessageBox::question(this, "X2Go Client", tr("Delete folder \"")+menuItem->text(0)+"\"?",QMessageBox::Ok|QMessageBox::Cancel) == QMessageBox::Ok) + { + explorer->deleteFolder(menuItem->data(0, Qt::UserRole).toString()); + currentPath="/"; + delete menuItem; + } +} + +void FolderExplorer::slotNewFolder() +{ + QTreeWidgetItem* it=new QTreeWidgetItem(menuItem); + QString name=tr("New Folder"); + it->setText(0,name); + it->setIcon(0, QIcon(":icons/128x128/folder.png")); + QString normPath=(menuItem->data(0,Qt::UserRole).toString()+"/"+name).split("/",QString::SkipEmptyParts).join("/"); + it->setData(0,Qt::UserRole, normPath+"/"); + treeWidget->clearSelection(); + it->setSelected(true); + QTreeWidgetItem* p=it->parent(); + while(p!=root) + { + p->setExpanded(true); + p=p->parent(); + } + slotItemSelected(it,0); + explorer->createNewFolder(normPath); +} diff --git a/folderbutton.h b/folderexplorer.h similarity index 55% copy from folderbutton.h copy to folderexplorer.h index a5eaf99..608c402 100644 --- a/folderbutton.h +++ b/folderexplorer.h @@ -14,56 +14,31 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ - -#ifndef FOLDERBUTTON_H -#define FOLDERBUTTON_H - -#include "SVGFrame.h" -#include <QPushButton> -#include <QLabel> -class ONMainWindow; -class QComboBox; -class QPushButton; - -/** - @author Oleksandr Shneyder <oleksandr.shneyder@obviously-nice.de> -*/ -class FolderButton : public SVGFrame +#ifndef FOLDEREXPLORER_H +#define FOLDEREXPLORER_H +#include "ui_folderexplorer.h" +class SessionExplorer; +class FolderExplorer: public QDialog, Ui_FolderExplorer { Q_OBJECT public: - FolderButton ( ONMainWindow* mw, QWidget* parent, QString folderPath, QString folderName ); - ~FolderButton(); - - const QPixmap* folderIcon() { - return icon->pixmap(); - } - static bool lessThen ( const FolderButton* b1, const FolderButton* b2 ); - QString getName() - { - return name; - } - QString getPath() + FolderExplorer(QString path, SessionExplorer* explorer, QWidget* parent=0); + QString getCurrentPath() { - return path; + return currentPath; } - void setChildrenList(QStringList children); private: - QString path; - QString name; - QString description; - QLabel* nameLabel; - QLabel* icon; - ONMainWindow* par; - + SessionExplorer* explorer; + QTreeWidgetItem* root; + QTreeWidgetItem* menuItem; + QString currentPath; + void initFolders(QTreeWidgetItem* parent, QString path); private slots: - void slotClicked(); -signals: - void folderSelected ( FolderButton* ); - void clicked(); -protected: - virtual void mousePressEvent ( QMouseEvent * event ); - virtual void mouseReleaseEvent ( QMouseEvent * event ); + void slotContextMenu(QPoint p); + void slotItemSelected(QTreeWidgetItem* it, int); + void slotNewFolder(); + void slotChangeName(); + void slotChangeIcon(); + void slotDeleteFolder(); }; - #endif diff --git a/folderexplorer.ui b/folderexplorer.ui new file mode 100644 index 0000000..65eeae2 --- /dev/null +++ b/folderexplorer.ui @@ -0,0 +1,118 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>FolderExplorer</class> + <widget class="QDialog" name="FolderExplorer"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Folders</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QTreeWidget" name="treeWidget"> + <property name="contextMenuPolicy"> + <enum>Qt::CustomContextMenu</enum> + </property> + <property name="rootIsDecorated"> + <bool>false</bool> + </property> + <attribute name="headerVisible"> + <bool>false</bool> + </attribute> + <column> + <property name="text"> + <string notr="true">1</string> + </property> + </column> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>FolderExplorer</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>9</x> + <y>290</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>FolderExplorer</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>35</x> + <y>290</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>treeWidget</sender> + <signal>customContextMenuRequested(QPoint)</signal> + <receiver>FolderExplorer</receiver> + <slot>slotContextMenu(QPoint)</slot> + <hints> + <hint type="sourcelabel"> + <x>152</x> + <y>93</y> + </hint> + <hint type="destinationlabel"> + <x>396</x> + <y>182</y> + </hint> + </hints> + </connection> + <connection> + <sender>treeWidget</sender> + <signal>itemActivated(QTreeWidgetItem*,int)</signal> + <receiver>FolderExplorer</receiver> + <slot>slotItemSelected(QTreeWidgetItem*,int)</slot> + <hints> + <hint type="sourcelabel"> + <x>150</x> + <y>106</y> + </hint> + <hint type="destinationlabel"> + <x>398</x> + <y>68</y> + </hint> + </hints> + </connection> + </connections> + <slots> + <slot>slotContextMenu(QPoint)</slot> + <slot>slotItemSelected(QTreeWidgetItem*,int)</slot> + </slots> +</ui> diff --git a/onmainwindow.h b/onmainwindow.h index f3e589c..e987a22 100644 --- a/onmainwindow.h +++ b/onmainwindow.h @@ -530,6 +530,11 @@ public: return fr; } + ConfigFile* getConfig() + { + return &config; + } + void runApplication(QString exec); diff --git a/sessionbutton.cpp b/sessionbutton.cpp index dc81171..3091b11 100644 --- a/sessionbutton.cpp +++ b/sessionbutton.cpp @@ -286,8 +286,6 @@ void SessionButton::redraw() else st= new X2goSettings( "sessions" ); - - QString name=st->setting()->value ( sid+"/name", ( QVariant ) tr ( "New Session" ) ).toString(); diff --git a/sessionbutton.h b/sessionbutton.h index bc4d8f9..6a39648 100644 --- a/sessionbutton.h +++ b/sessionbutton.h @@ -48,6 +48,11 @@ public: { return path; } + void setPath(QString path) + { + this->path=path; + } + private: QString sid; QString path; diff --git a/sessionexplorer.cpp b/sessionexplorer.cpp index d1604f3..06694f7 100644 --- a/sessionexplorer.cpp +++ b/sessionexplorer.cpp @@ -31,6 +31,7 @@ #include "imgframe.h" #include <QToolButton> #include "x2gologdebug.h" +#include <QBuffer> SessionExplorer::SessionExplorer(ONMainWindow* p):QObject(p) { @@ -78,6 +79,9 @@ void SessionExplorer::cleanSessions() for ( int i=0; i<sessions.size(); ++i ) sessions[i]->close(); sessions.clear(); + for ( int i=0; i<folders.size(); ++i ) + folders[i]->close(); + folders.clear(); } void SessionExplorer::exportsEdit ( SessionButton* bt ) @@ -93,6 +97,25 @@ void SessionExplorer::exportsEdit ( SessionButton* bt ) } } +void SessionExplorer::getFoldersFromConfig() +{ + X2goSettings *st; + + if (parent->getBrokerMode()) + st=new X2goSettings(parent->getConfig()->iniFile,QSettings::IniFormat); + else + st= new X2goSettings( "sessions" ); + + QStringList folders=st->setting()->childKeys(); + QString folder; + foreach(folder,folders) + { + folder.replace("::","/"); + if(findFolder(folder)==-1) + createFolder(folder); + } +} + void SessionExplorer::slotEdit ( SessionButton* bt ) { @@ -138,6 +161,7 @@ void SessionExplorer::slotCreateDesktopIcon ( SessionButton* bt ) // PyHoca-GUI uses the slash as separator for cascaded menus, so let's handle these on the file system name.replace("/","::"); + QString sessIcon=st.setting()->value ( bt->id() +"/icon", ( QVariant ) @@ -235,6 +259,8 @@ SessionButton* SessionExplorer::createBut ( const QString& id ) void SessionExplorer::placeButtons() { + getFoldersFromConfig(); + setNavigationVisible(currentPath.length()>0); resize(); int currentIndex=0; @@ -385,3 +411,186 @@ void SessionExplorer::slotLevelUp() } placeButtons(); } + +void SessionExplorer::setFolderIcon(QString path, QString icon) +{ + QPixmap pix(icon); + if(!pix.isNull()) + { + pix=pix.scaled(64,64,Qt::KeepAspectRatio, Qt::SmoothTransformation); + path=path.split("/",QString::SkipEmptyParts).join("::"); + + X2goSettings *st; + if (parent->getBrokerMode()) + st=new X2goSettings(parent->getConfig()->iniFile,QSettings::IniFormat); + else + st= new X2goSettings( "sessions" ); + QByteArray bytes; + QBuffer buffer(&bytes); + buffer.open(QIODevice::WriteOnly); + pix.save(&buffer,"PNG"); + x2goDebug<<"Save: "<<path; + st->setting()->setValue(path, bytes); + st->setting()->sync(); + FolderButton* b; + foreach(b, folders) + { + if((b->getPath()+"/"+b->getName()).split("/",QString::SkipEmptyParts).join("::")==path) + { + b->loadIcon(); + break; + } + } + } +} + +void SessionExplorer::createNewFolder(QString path) +{ + X2goSettings *st; + if (parent->getBrokerMode()) + st=new X2goSettings(parent->getConfig()->iniFile,QSettings::IniFormat); + else + st= new X2goSettings( "sessions" ); + + + if(findFolder(path)==-1) + { + QString name=path; + name.replace("/","::"); + st->setting()->setValue(name, QByteArray()); + st->setting()->sync(); + createFolder(path); + placeButtons(); + } +} + +void SessionExplorer::renameFolder(QString oldPath, QString currentPath) +{ + FolderButton* b; + oldPath=oldPath.split("/",QString::SkipEmptyParts).join("/"); + currentPath=currentPath.split("/",QString::SkipEmptyParts).join("/"); + + QStringList parts=oldPath.split("/",QString::SkipEmptyParts); + QString oldName=parts.last(); + parts.pop_back(); + QString pathOfFolder=parts.join("/"); + + + foreach(b, folders) + { + if(b->getPath()==pathOfFolder && b->getName()==oldName) + { + b->setName(currentPath.split("/",QString::SkipEmptyParts).last()); + } + if((b->getPath()+"/").indexOf(oldPath+"/")==0) + { + QString newPath=currentPath+b->getPath().mid(oldPath.length()); + b->setPath(newPath); + } + } + + SessionButton* s; + foreach(s, sessions) + { + if((s->getPath()+"/").indexOf(oldPath+"/")==0) + { + QString newPath=currentPath+s->getPath().mid(oldPath.length()); + s->setPath(newPath); + } + } + if((this->currentPath+"/").indexOf(oldPath+"/")==0) + { + this->currentPath=currentPath+this->currentPath.mid(oldPath.length()); + } + + X2goSettings *st; + if (parent->getBrokerMode()) + st=new X2goSettings(parent->getConfig()->iniFile,QSettings::IniFormat); + else + st= new X2goSettings( "sessions" ); + + QStringList folders=st->setting()->childKeys(); + QString folder; + foreach(folder,folders) + { + QString fname=folder; + folder.replace("::","/"); + if((folder+"/").indexOf(oldPath+"/")==0) + { + QVariant value=st->setting()->value(fname); + folder=currentPath+folder.mid(oldPath.length()); + folder.replace("/","::"); + st->setting()->setValue(folder,value); + st->setting()->remove(fname); + } + } + + QStringList sessions=st->setting()->childGroups(); + QString session; + foreach(session, sessions) + { + QString sname=st->setting()->value(session+"/name").toString(); + if((sname+"/").indexOf(oldPath+"/")==0) + { + sname=currentPath+sname.mid(oldPath.length()); + st->setting()->setValue(session+"/name",sname); + } + } + st->setting()->sync(); + placeButtons(); +} + +bool SessionExplorer::isFolderEmpty(QString path) +{ + FolderButton* b; + path=path.split("/",QString::SkipEmptyParts).join("/"); + + foreach(b, folders) + { + if(b->getPath()==path) + { + return false; + } + } + + SessionButton* s; + foreach(s, sessions) + { + if(s->getPath()==path) + { + return false; + } + } + return true; +} + +void SessionExplorer::deleteFolder(QString path) +{ + path=path.split("/",QString::SkipEmptyParts).join("::"); + X2goSettings *st; + if (parent->getBrokerMode()) + st=new X2goSettings(parent->getConfig()->iniFile,QSettings::IniFormat); + else + st= new X2goSettings( "sessions" ); + + st->setting()->remove(path); + + path.replace("::","/"); + + + for(int i=0; i< folders.count(); ++i) + { + FolderButton* b=folders[i]; + if((b->getPath()+"/"+b->getName()).split("/",QString::SkipEmptyParts).join("/")==path) + { + b->close(); + folders.removeAt(i); + break; + } + } + if(currentPath==path) + { + currentPath=""; + } + placeButtons(); +} diff --git a/sessionexplorer.h b/sessionexplorer.h index 84b8867..beaa471 100644 --- a/sessionexplorer.h +++ b/sessionexplorer.h @@ -39,6 +39,10 @@ public: { return &sessions; } + QList<FolderButton*> * getFoldersList() + { + return &folders; + } SessionButton* getLastSession() { return lastSession; } @@ -53,7 +57,14 @@ public: { return navigationLayout; } + bool isFolderEmpty(QString path); void resize(); + void setFolderIcon(QString path, QString icon); + void createNewFolder(QString path); + void renameFolder(QString oldPath, QString currentPath); + void deleteFolder(QString path); + + //vars private: QList<SessionButton*> sessions; @@ -70,6 +81,7 @@ private: void setNavigationVisible(bool value); int findFolder(QString path); void createFolder(QString path); + void getFoldersFromConfig(); public slots: void slotDeleteButton ( SessionButton * bt ); diff --git a/sessionwidget.cpp b/sessionwidget.cpp index 0b5265c..874c26f 100644 --- a/sessionwidget.cpp +++ b/sessionwidget.cpp @@ -35,6 +35,7 @@ #include <QMessageBox> #include <QButtonGroup> #include <QRadioButton> +#include "folderexplorer.h" SessionWidget::SessionWidget ( QString id, ONMainWindow * mw, QWidget * parent, Qt::WindowFlags f ) @@ -44,6 +45,7 @@ SessionWidget::SessionWidget ( QString id, ONMainWindow * mw, #ifdef Q_WS_HILDON sessLay->setMargin ( 2 ); #endif + this->parent=mw; sessName=new QLineEdit ( this ); icon=new QPushButton ( QString::null,this ); if ( !miniMode ) @@ -66,6 +68,14 @@ SessionWidget::SessionWidget ( QString id, ONMainWindow * mw, ilay->addWidget ( icon ); ilay->addWidget ( new QLabel ( tr ( "<< change icon" ),this ) ); + lPath=new QLabel(this); + lPath->setFrameStyle(QFrame::StyledPanel); + QPushButton* pathButton=new QPushButton("...",this); + QHBoxLayout* pathLay=new QHBoxLayout(); + pathLay->addWidget(new QLabel(tr("Path:"), this),0); + pathLay->addWidget(lPath,1); + pathLay->addWidget(pathButton,0); + #ifndef Q_WS_HILDON QGroupBox *sgb=new QGroupBox ( tr ( "&Server" ),this ); #else @@ -221,6 +231,7 @@ SessionWidget::SessionWidget ( QString id, ONMainWindow * mw, #ifndef Q_WS_HILDON sessLay->addLayout ( slay ); sessLay->addLayout ( ilay ); + sessLay->addLayout ( pathLay ); if ( !miniMode ) sessLay->addSpacing ( 15 ); sessLay->addWidget ( sgb ); @@ -271,6 +282,7 @@ SessionWidget::SessionWidget ( QString id, ONMainWindow * mw, connect ( proxyType, SIGNAL ( buttonClicked(int)) ,this,SLOT ( slot_proxyType())); connect (cbProxy, SIGNAL(clicked(bool)), this, SLOT(slot_proxyOptions())); connect (cbProxySameUser, SIGNAL(clicked(bool)), this, SLOT(slot_proxySameLogin())); + connect ( pathButton, SIGNAL(clicked(bool)), this, SLOT(slot_openFolder())); readConfig(); } @@ -508,10 +520,22 @@ void SessionWidget::readConfig() { X2goSettings st ( "sessions" ); - sessName->setText ( - st.setting()->value ( - sessionId+"/name", - ( QVariant ) tr ( "New session" ) ).toString().trimmed() ); + QString name=st.setting()->value ( + sessionId+"/name", + ( QVariant ) tr ( "New session" ) ).toString().trimmed(); + + QStringList tails=name.split("/",QString::SkipEmptyParts); + QString path; + if(tails.count()>0) + { + name=tails.last(); + tails.pop_back(); + path=tails.join("/")+"/"; + } + lPath->setText(path); + + sessName->setText (name); + sessIcon=st.setting()->value ( sessionId+"/icon", ( QVariant ) ":icons/128x128/x2gosession.png" ).toString().trimmed(); @@ -780,8 +804,11 @@ void SessionWidget::saveSettings() { X2goSettings st ( "sessions" ); + + QString normPath=(lPath->text()+"/"+sessName->text()).split("/",QString::SkipEmptyParts).join("/"); + st.setting()->setValue ( sessionId+"/name", - ( QVariant ) sessName->text().trimmed() ); + ( QVariant ) normPath.trimmed() ); st.setting()->setValue ( sessionId+"/icon", ( QVariant ) sessIcon ); st.setting()->setValue ( sessionId+"/host", @@ -904,3 +931,12 @@ void SessionWidget::slot_krbChecked() { cbKrbDelegation->setEnabled(cbKrbLogin->isChecked()); } + +void SessionWidget::slot_openFolder() +{ + FolderExplorer explorer(lPath->text(), parent->getSessionExplorer(), this); + if(explorer.exec()==QDialog::Accepted) + { + lPath->setText(explorer.getCurrentPath()); + } +} diff --git a/sessionwidget.h b/sessionwidget.h index 785a79e..4d07e6a 100644 --- a/sessionwidget.h +++ b/sessionwidget.h @@ -51,6 +51,7 @@ private slots: void slot_proxySameLogin(); void slot_proxyGetKey(); void slot_krbChecked(); + void slot_openFolder(); public slots: #ifdef Q_OS_LINUX void slot_rdpDirectClicked(); @@ -63,6 +64,7 @@ private: QLineEdit* uname; QLineEdit* server; QSpinBox* sshPort; + ONMainWindow* parent; #ifdef Q_OS_LINUX QSpinBox* rdpPort; #endif @@ -81,6 +83,7 @@ private: QLabel* leCmdIp; QLabel* lPort; QLabel* lKey; + QLabel* lPath; QPushButton* pbAdvanced; QString rdpOptions; QString rdpServer; diff --git a/x2goclient.pro b/x2goclient.pro index 22260fb..27ea502 100755 --- a/x2goclient.pro +++ b/x2goclient.pro @@ -19,7 +19,8 @@ FORMS += cupsprintsettingsdialog.ui \ brokerpassdialog.ui \ contest.ui \ appdialog.ui \ - helpdialog.ui + helpdialog.ui \ + folderexplorer.ui TRANSLATIONS += \ x2goclient_de.ts \ @@ -73,7 +74,8 @@ HEADERS += configdialog.h \ x2goutils.h \ helpdialog.h \ sessionexplorer.h \ - folderbutton.h + folderbutton.h \ + folderexplorer.h SOURCES += sharewidget.cpp \ settingswidget.cpp\ @@ -112,7 +114,8 @@ SOURCES += sharewidget.cpp \ x2goutils.cpp \ helpdialog.cpp \ sessionexplorer.cpp \ - folderbutton.cpp + folderbutton.cpp \ + folderexplorer.cpp LIBS += -lssh -- Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git