Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STAC browser UI tweaks #59376

Merged
merged 6 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/gui/stac/qgsstacdataitemguiprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void QgsStacDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *

if ( catalogItem->stacCatalog() )
{
QAction *actionDetails = new QAction( tr( "Details" ), menu );
QAction *actionDetails = new QAction( tr( "Details" ), menu );
connect( actionDetails, &QAction::triggered, this, [catalogItem] { showDetails( catalogItem ); } );
menu->addAction( actionDetails );
}
Expand All @@ -93,11 +93,11 @@ void QgsStacDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *
{
menu->addSeparator();

QAction *actionDownload = new QAction( tr( "Download assets" ), menu );
QAction *actionDownload = new QAction( tr( "Download Assets…" ), menu );
connect( actionDownload, &QAction::triggered, this, [itemItem, context] { downloadAssets( itemItem, context ); } );
menu->addAction( actionDownload );

QAction *actionDetails = new QAction( tr( "Details" ), menu );
QAction *actionDetails = new QAction( tr( "Details" ), menu );
connect( actionDetails, &QAction::triggered, this, [itemItem] { showDetails( itemItem ); } );
menu->addAction( actionDetails );
}
Expand Down
28 changes: 28 additions & 0 deletions src/gui/stac/qgsstacdownloadassetsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

#include <QTreeWidget>
#include <QPushButton>
#include <QAction>
#include <QMenu>
#include <QClipboard>

///@cond PRIVATE

Expand All @@ -38,8 +41,14 @@ QgsStacDownloadAssetsDialog::QgsStacDownloadAssetsDialog( QWidget *parent ) :
mFileWidget->setFilePath( defPath );
mFileWidget->lineEdit()->setReadOnly( true );

mContextMenu = new QMenu( this );

connect( mSelectAllButton, &QPushButton::clicked, this, &QgsStacDownloadAssetsDialog::selectAll );
connect( mDeselectAllButton, &QPushButton::clicked, this, &QgsStacDownloadAssetsDialog::deselectAll );

mTreeWidget->setContextMenuPolicy( Qt::CustomContextMenu );
connect( mTreeWidget, &QWidget::customContextMenuRequested,
this, &QgsStacDownloadAssetsDialog::showContextMenu );
}

void QgsStacDownloadAssetsDialog::setStacItem( QgsStacItem *stacItem )
Expand Down Expand Up @@ -86,6 +95,25 @@ QStringList QgsStacDownloadAssetsDialog::selectedUrls()
return urls;
}

void QgsStacDownloadAssetsDialog::showContextMenu( QPoint p )
{
QTreeWidgetItem *item = mTreeWidget->itemAt( p );
if ( !item )
return;

mTreeWidget->setCurrentItem( item );
mContextMenu->clear();

const QString url = item->text( 5 );
QAction *copyUrlAction = new QAction( tr( "Copy URL" ), mContextMenu );
connect( copyUrlAction, &QAction::triggered, this, [url]
{
QApplication::clipboard()->setText( url );
} );
mContextMenu->addAction( copyUrlAction );
mContextMenu->exec( QCursor::pos() );
}

void QgsStacDownloadAssetsDialog::selectAll()
{
for ( int i = 0; i < mTreeWidget->topLevelItemCount(); ++i )
Expand Down
4 changes: 4 additions & 0 deletions src/gui/stac/qgsstacdownloadassetsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ class QgsStacDownloadAssetsDialog : public QDialog, private Ui::QgsStacDownloadA
QString selectedFolder();
QStringList selectedUrls();

private slots:
void showContextMenu( QPoint p );

private:
void selectAll();
void deselectAll();

QMenu *mContextMenu = nullptr;
};

///@endcond
Expand Down
5 changes: 5 additions & 0 deletions src/gui/stac/qgsstacobjectdetailsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "qgsgui.h"
#include "qgsapplication.h"
#include "qgsstacitem.h"
#include <QDesktopServices>

///@cond PRIVATE

Expand Down Expand Up @@ -53,6 +54,10 @@ void QgsStacObjectDetailsDialog::setStacObject( QgsStacObject *stacObject )
html = html.replace( QLatin1String( "<head>" ), QStringLiteral( R"raw(<head><style type="text/css">%1</style>)raw" ) ).arg( myStyle );

mWebView->page()->setLinkDelegationPolicy( QWebPage::LinkDelegationPolicy::DelegateAllLinks );
connect( mWebView, &QgsWebView::linkClicked, this, []( const QUrl & url )
{
QDesktopServices::openUrl( url );
} );
mWebView->setHtml( html );
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/stac/qgsstacconnectiondialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<string>URL of the connection</string>
</property>
<property name="placeholderText">
<string>http://example.com/stac/</string>
<string>https://example.com/stac/</string>
</property>
</widget>
</item>
Expand Down
4 changes: 2 additions & 2 deletions src/ui/stac/qgsstacdownloadassetsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</attribute>
<column>
<property name="text">
<string>Id</string>
<string>ID</string>
</property>
</column>
<column>
Expand All @@ -65,7 +65,7 @@
</column>
<column>
<property name="text">
<string>Url</string>
<string>URL</string>
</property>
</column>
</widget>
Expand Down
Loading