Skip to content
Permalink
Browse files

Use a message bar in Style Manager dialog to avoid annoying

success message boxes after performing import actions
  • Loading branch information
nyalldawson committed May 10, 2019
1 parent 85ff9ae commit 2a457f0e44dec26870da119ca5fb5d6d4797a7f7
@@ -30,6 +30,7 @@
#include "qgssmartgroupeditordialog.h"
#include "qgssettings.h"
#include "qgsstylemodel.h"
#include "qgsmessagebar.h"

#include <QAction>
#include <QFile>
@@ -154,6 +155,10 @@ QgsStyleManagerDialog::QgsStyleManagerDialog( QgsStyle *style, QWidget *parent,
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsStyleManagerDialog::showHelp );
connect( buttonBox, &QDialogButtonBox::rejected, this, &QgsStyleManagerDialog::onClose );

mMessageBar = new QgsMessageBar();
mMessageBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
mVerticalLayout->insertWidget( 0, mMessageBar );

#ifdef Q_OS_MAC
setWindowModality( Qt::WindowModal );
#endif
@@ -484,9 +489,7 @@ void QgsStyleManagerDialog::copyItemsToDefault()
cursorOverride.reset();
if ( count > 0 )
{
QMessageBox::information( this, tr( "Import Items" ),
count > 1 ? tr( "Successfully imported %1 items." ).arg( count )
: tr( "Successfully imported item." ) );
mMessageBar->pushSuccess( tr( "Import Items" ), count > 1 ? tr( "Successfully imported %1 items." ).arg( count ) : tr( "Successfully imported item." ) );
}
}
}
@@ -1424,8 +1427,7 @@ int QgsStyleManagerDialog::addTag()
int check = mStyle->tagId( itemName );
if ( check > 0 )
{
QMessageBox::critical( this, tr( "Add Tag" ),
tr( "Tag name already exists in your symbol database." ) );
mMessageBar->pushCritical( tr( "Add Tag" ), tr( "The tag “%1” already exists." ).arg( itemName ) );
return 0;
}

@@ -1437,9 +1439,7 @@ int QgsStyleManagerDialog::addTag()

if ( !id )
{
QMessageBox::critical( this, tr( "Add Tag" ),
tr( "New tag could not be created.\n"
"There was a problem with your symbol database." ) );
mMessageBar->pushCritical( tr( "Add Tag" ), tr( "New tag could not be created — There was a problem with the symbol database." ) );
return 0;
}

@@ -1498,6 +1498,7 @@ void QgsStyleManagerDialog::removeGroup()
QString data = index.data( Qt::UserRole + 1 ).toString();
if ( data == QLatin1String( "all" ) || data == QLatin1String( "favorite" ) || data == QLatin1String( "tags" ) || index.data() == "smartgroups" )
{
// should never appear -- blocked by GUI
int err = QMessageBox::critical( this, tr( "Remove Group" ),
tr( "Invalid selection. Cannot delete system defined categories.\n"
"Kindly select a group or smart group you might want to delete." ) );
@@ -1801,6 +1802,7 @@ void QgsStyleManagerDialog::editSmartgroupAction()
QModelIndex present = groupTree->currentIndex();
if ( present.parent().data( Qt::UserRole + 1 ) != "smartgroups" )
{
// should never appear - blocked by GUI logic
QMessageBox::critical( this, tr( "Edit Smart Group" ),
tr( "You have not selected a Smart Group. Kindly select a Smart Group to edit." ) );
return;
@@ -1822,8 +1824,7 @@ void QgsStyleManagerDialog::editSmartgroupAction()
mBlockGroupUpdates--;
if ( !id )
{
QMessageBox::critical( this, tr( "Edit Smart Group" ),
tr( "There was some error while editing the smart group." ) );
mMessageBar->pushCritical( tr( "Edit Smart Group" ), tr( "There was an error while editing the smart group." ) );
return;
}
item->setText( dlg.smartgroupName() );
@@ -28,6 +28,7 @@

class QgsStyle;
class QgsTemporaryCursorOverride;
class QgsMessageBar;

#ifndef SIP_RUN
///@cond PRIVATE
@@ -354,6 +355,7 @@ class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleMan
QWidget *parentWidget, std::unique_ptr<QgsTemporaryCursorOverride> &cursorOverride,
bool isImport, const QStringList &importTags, bool addToFavorites, bool ignoreSourceTags );

QgsMessageBar *mMessageBar = nullptr;

QgsStyle *mStyle = nullptr;

@@ -13,7 +13,7 @@
<property name="windowTitle">
<string>Style Manager</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QVBoxLayout" name="mVerticalLayout">
<property name="leftMargin">
<number>6</number>
</property>
@@ -26,7 +26,7 @@
<property name="bottomMargin">
<number>6</number>
</property>
<item row="3" column="0">
<item>
<widget class="QSplitter" name="mSplitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -445,7 +445,7 @@
</widget>
</widget>
</item>
<item row="4" column="0">
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>

0 comments on commit 2a457f0

Please sign in to comment.
You can’t perform that action at this time.