mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Elements panel: added contextual actions so users can easily find elements, title block templates and projects on their filesystem.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2023 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
9c32815887
commit
6ea0a96bd4
@ -53,6 +53,8 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
|
||||
elements_panel = new ElementsPanel(this);
|
||||
|
||||
// initialise les actions
|
||||
open_directory = new QAction(QET::Icons::DocumentOpen, tr("Ouvrir le dossier correspondant"), this);
|
||||
copy_path = new QAction(QET::Icons::CopyFile, tr("Copier le chemin"), this);
|
||||
reload = new QAction(QET::Icons::ViewRefresh, tr("Recharger les collections"), this);
|
||||
new_category = new QAction(QET::Icons::FolderNew, tr("Nouvelle cat\351gorie"), this);
|
||||
edit_category = new QAction(QET::Icons::FolderEdit, tr("\311diter la cat\351gorie"), this);
|
||||
@ -95,6 +97,8 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
|
||||
|
||||
context_menu = new QMenu(this);
|
||||
|
||||
connect(open_directory, SIGNAL(triggered()), this, SLOT(openDirectoryForSelectedItem()));
|
||||
connect(copy_path, SIGNAL(triggered()), this, SLOT(copyPathForSelectedItem()));
|
||||
connect(reload, SIGNAL(triggered()), this, SLOT(reloadAndFilter()));
|
||||
connect(new_category, SIGNAL(triggered()), this, SLOT(newCategory()));
|
||||
connect(edit_category, SIGNAL(triggered()), this, SLOT(editCategory()));
|
||||
@ -189,6 +193,33 @@ void ElementsPanelWidget::clearFilterTextField() {
|
||||
filterEdited(QString());
|
||||
}
|
||||
|
||||
/**
|
||||
Require the desktop environment to open the directory containing the file
|
||||
represented by the selected item, if any.
|
||||
*/
|
||||
void ElementsPanelWidget::openDirectoryForSelectedItem() {
|
||||
if (QTreeWidgetItem *qtwi = elements_panel -> currentItem()) {
|
||||
QString dir_path = elements_panel -> dirPathForItem(qtwi);
|
||||
if (!dir_path.isEmpty()) {
|
||||
QDesktopServices::openUrl(dir_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Copy the full path to the file represented by the selected item to the
|
||||
clipboard.
|
||||
*/
|
||||
void ElementsPanelWidget::copyPathForSelectedItem() {
|
||||
if (QTreeWidgetItem *qtwi = elements_panel -> currentItem()) {
|
||||
QString file_path = elements_panel -> filePathForItem(qtwi);
|
||||
file_path = QDir::toNativeSeparators(file_path);
|
||||
if (!file_path.isEmpty()) {
|
||||
QApplication::clipboard() -> setText(file_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Recharge le panel d'elements
|
||||
*/
|
||||
@ -468,6 +499,13 @@ void ElementsPanelWidget::handleContextMenu(const QPoint &pos) {
|
||||
updateButtons();
|
||||
context_menu -> clear();
|
||||
|
||||
QString dir_path = elements_panel -> dirPathForItem(item);
|
||||
if (!dir_path.isEmpty()) {
|
||||
context_menu -> addAction(open_directory);
|
||||
context_menu -> addAction(copy_path);
|
||||
context_menu -> addSeparator();
|
||||
}
|
||||
|
||||
switch(item -> type()) {
|
||||
case QET::ElementsCategory:
|
||||
context_menu -> addAction(new_category);
|
||||
|
@ -39,6 +39,7 @@ class ElementsPanelWidget : public QWidget {
|
||||
private:
|
||||
ElementsPanel *elements_panel;
|
||||
QToolBar *toolbar, *filter_toolbar;
|
||||
QAction *open_directory, *copy_path;
|
||||
QAction *reload;
|
||||
QAction *new_category, *edit_category, *delete_category;
|
||||
QAction *delete_collection;
|
||||
@ -69,6 +70,8 @@ class ElementsPanelWidget : public QWidget {
|
||||
|
||||
public slots:
|
||||
void clearFilterTextField();
|
||||
void openDirectoryForSelectedItem();
|
||||
void copyPathForSelectedItem();
|
||||
void reloadAndFilter();
|
||||
void activateProject();
|
||||
void closeProject();
|
||||
|
Loading…
x
Reference in New Issue
Block a user