Conversation
becd36e to
1c10666
Compare
|
I tried to split the PR in multiple commits, but couldn't find a logic to make more atomic commits, so I submit the feature in one commit only. |
|
We don't see the menu in the video it seems |
Oops, screencast updated |
That's not the actual behavior where there is an empty menu if there is no template. IMHO, I think it's better to see an empty menu than not seeing a menu at all. It can confuse the user who would not understand why the menu is not there. |
|
Related to #66024 |
|
I like the proposed UI, but I would like to have @nirvn opinion, especially on the template look on welcoming page |
Yes, we could gray them (menu + toolbar button) out with setEnabled(False). But it's also arguable to lighten the UI I think. |
|
|
||
| // The default template directory depends on the active profile, which is not known now, so we use an empty default, | ||
| // and it will be handled later on by the getter QgsApplication::projectTemplatePaths. | ||
| const QgsSettingsEntryStringList *QgsApplication::settingsProjectTemplatePaths = new QgsSettingsEntryStringList( u"projectTemplatePaths"_s, QgsSettingsTree::sTreeQgis, QStringList() ); |
There was a problem hiding this comment.
Shall we not add this settings to sTreeProject instead ?
| /** | ||
| * Returns the paths to project template directories. | ||
| * | ||
| * Defaults to the template directory of the active user profile when no path |
There was a problem hiding this comment.
What happen if the user destroy the default path from the qgsoptions widget ? It would reappear next opening no? It seems it was the existing behavior but maybe we can do better here
| // Dialog that shows QGIS projects inside the current directory, but only directories are selectable. | ||
| QFileDialog dialog( this, tr( "Choose a directory" ), QDir::toNativeSeparators( QDir::homePath() ) ); | ||
| dialog.setFileMode( QFileDialog::Directory ); | ||
| dialog.setOption( QFileDialog::DontUseNativeDialog ); // to have the desired behavior on most platforms | ||
| dialog.setNameFilter( tr( "QGIS project files (*.qgs *.qgz)" ) ); | ||
| if ( dialog.exec() != QDialog::Accepted || dialog.selectedFiles().isEmpty() ) | ||
| return; |
There was a problem hiding this comment.
Cannot we not replace all this with QFileDialog::getExistingDirectory like it was done before ?
| for ( int i = 0; i < mListProjectTemplatePaths->count(); ++i ) | ||
| { | ||
| if ( mListProjectTemplatePaths->item( i )->text() == myDir ) | ||
| { |
There was a problem hiding this comment.
may I suggest to use std::find_if here to be more consise ?
| void QgsOptions::moveProjectTemplatePathUp() | ||
| { | ||
| QList<QListWidgetItem *> selectedItems = mListProjectTemplatePaths->selectedItems(); | ||
| QList<QListWidgetItem *>::iterator itemIt = selectedItems.begin(); |
There was a problem hiding this comment.
we autorize the use of auto for iterator
| if ( templateFiles.count() > 0 ) | ||
| { | ||
| const QString label = directoryNameCount.value( templateDir.dirName() ) > 1 ? QDir::toNativeSeparators( templateDirName ) : templateDir.dirName(); | ||
| QMenu *dirMenu = mProjectFromTemplateMenu->addMenu( fontMetrics.elidedText( label, Qt::ElideLeft, maxLabelWidth ) ); |
There was a problem hiding this comment.
Can we add the tooltip with the non-elided text
| mProjectFromTemplateMenu->addAction( tr( "< Blank >" ) ); | ||
| mProjectFromTemplateMenu->addAction( tr( "< Blank >" ), [this]() { fileNewBlank(); } ); | ||
|
|
||
| mProjectFromTemplateMenu->menuAction()->setVisible( !mProjectFromTemplateMenu->isEmpty() ); |
There was a problem hiding this comment.
Like I said, I prefer an empty menu, or a disabled one
| } | ||
| } | ||
|
|
||
| const QStringList watchedDirectories = mFileSystemWatcher.directories(); |
There was a problem hiding this comment.
this code is very much alike than the one in QgisApp. Can we put somewhere and reuse it?
|
|
||
| const QStringList watchedDirectories = mFileSystemWatcher.directories(); | ||
| if ( !watchedDirectories.isEmpty() ) | ||
| mFileSystemWatcher.removePaths( watchedDirectories ); |
There was a problem hiding this comment.
It would be cool to avoid to have 2 QFileSystemWatcher because it is ressource consuming, and move it elwere (QgsApplication maybe?). But it was already this way, so non blocking
| QHash<int, QByteArray> roleNames() const override; | ||
|
|
||
| private slots: | ||
| /** |
There was a problem hiding this comment.
Why do we need to reload if we have the file watcher ? Maybe it would be interesting to centralize all in QgsApplication maybe with a signal templatePathsChanged() ?
🪟 Windows Qt6 buildsDownload Windows Qt6 builds of this PR for testing. 🍎 MacOS Qt6 buildsDownload MacOS Qt6 builds of this PR for testing. |
Description
This PR adds the feature to have multiple directories for the project templates.
The need behind it is for instance having a team with its set of project templates, plus some templates coming from another centralized directory from an organization.
To clean the menu UI, the sub-menu for creating a project from a template is only available if there is at least one project template in one template directory.
A toolbar button has been added to be coherent with the menu.
A new icon for project templates is proposed:
The welcome screen has been adapted to show the directories as sections.
See screencast below:
Enregistrement.d.ecran_20260917_160105.webm
AI tool usage
Claude Fable 5.1 used
src/app/qgssaveprojecttemplatedialog.[cpp/h])