diff --git a/images/images.qrc b/images/images.qrc
index 814fb90feeb..74fed0de908 100644
--- a/images/images.qrc
+++ b/images/images.qrc
@@ -225,6 +225,8 @@
themes/default/mIconRenderingDisabled.png
themes/default/mIconSymbology.png
themes/default/mIconTableLayer.png
+ themes/default/mIconTimerPause.png
+ themes/default/mIconTimerContinue.png
themes/default/mIconUnknownLayerType.png
themes/default/mIconVectorLayer.png
themes/default/mIconWaitingForLayerType.png
diff --git a/images/themes/default/mIconTimerContinue.png b/images/themes/default/mIconTimerContinue.png
new file mode 100644
index 00000000000..5f0091e16b5
Binary files /dev/null and b/images/themes/default/mIconTimerContinue.png differ
diff --git a/images/themes/default/mIconTimerPause.png b/images/themes/default/mIconTimerPause.png
new file mode 100644
index 00000000000..0fe7f786be1
Binary files /dev/null and b/images/themes/default/mIconTimerPause.png differ
diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp
index b022aa3434e..9113b797ab1 100644
--- a/src/app/qgisapp.cpp
+++ b/src/app/qgisapp.cpp
@@ -488,6 +488,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
mInfoBar = new QgsMessageBar( centralWidget );
mInfoBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
centralLayout->addWidget( mInfoBar, 0, 0, 1, 1 );
+ mInfoBarTimeout = settings.value( "/qgis/messageTimeout", 5 ).toInt();
//set the focus to the map canvas
mMapCanvas->setFocus();
@@ -4042,7 +4043,7 @@ void QgisApp::labeling()
messageBar()->pushMessage( tr( "Labeling Options" ),
tr( "Please select a vector layer first" ),
QgsMessageBar::INFO,
- 5 );
+ messageTimeout() );
return;
}
diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h
index d3a4f5a3516..58d547f15f8 100644
--- a/src/app/qgisapp.h
+++ b/src/app/qgisapp.h
@@ -398,6 +398,10 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
* @note added in 1.9 */
QList editableLayers( bool modified = false ) const;
+ /** Get timeout for timed messages: default of 5 seconds
+ * @note added in 1.9 */
+ int messageTimeout() { return mMessageTimeout; }
+
#ifdef Q_OS_WIN
//! ugly hack
void skipNextContextMenuEvent();
@@ -539,6 +543,11 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
//! layer selection changed
void legendLayerSelectionChanged( void );
+ /** Set timeout for timed messages
+ * @param t timeout in seconds
+ * @note added in 1.9 */
+ void setMessageTimeout( int t ) { mMessageTimeout = t; }
+
//! Watch for QFileOpenEvent.
virtual bool event( QEvent * event );
@@ -1333,6 +1342,9 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
QgsMessageBar *mInfoBar;
QWidget *mMacrosWarn;
+ //! timeout for timed messages
+ int mMessageTimeout;
+
#ifdef HAVE_TOUCH
bool gestureEvent( QGestureEvent *event );
void tapAndHoldTriggered( QTapAndHoldGesture *gesture );
diff --git a/src/app/qgsmaptooledit.cpp b/src/app/qgsmaptooledit.cpp
index fda075ca6bb..9369479ccbc 100644
--- a/src/app/qgsmaptooledit.cpp
+++ b/src/app/qgsmaptooledit.cpp
@@ -127,7 +127,7 @@ void QgsMapToolEdit::notifyNotVectorLayer()
tr( "No active vector layer" ),
tr( "Choose a vector layer in the legend" ),
QgsMessageBar::INFO,
- 5 );
+ QgisApp::instance()->messageTimeout() );
}
void QgsMapToolEdit::notifyNotEditableLayer()
@@ -136,5 +136,5 @@ void QgsMapToolEdit::notifyNotEditableLayer()
tr( "Layer not editable" ),
tr( "Use 'Toggle Editing' to make it editable" ),
QgsMessageBar::INFO,
- 5 );
+ QgisApp::instance()->messageTimeout() );
}
diff --git a/src/app/qgsmaptoolselectutils.cpp b/src/app/qgsmaptoolselectutils.cpp
index 1bd162dbeb4..283226ab73a 100644
--- a/src/app/qgsmaptoolselectutils.cpp
+++ b/src/app/qgsmaptoolselectutils.cpp
@@ -41,7 +41,7 @@ QgsVectorLayer* QgsMapToolSelectUtils::getCurrentVectorLayer( QgsMapCanvas* canv
QObject::tr( "No active vector layer" ),
QObject::tr( "To select features, choose a vector layer in the legend" ),
QgsMessageBar::INFO,
- 5 );
+ QgisApp::instance()->messageTimeout() );
}
return vlayer;
}
diff --git a/src/app/qgsoptions.cpp b/src/app/qgsoptions.cpp
index 01143d803c5..2bce31382a9 100644
--- a/src/app/qgsoptions.cpp
+++ b/src/app/qgsoptions.cpp
@@ -462,6 +462,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
}
blockSignals( false );
+ mInfoBarTimeoutSpnBx->setValue( settings.value( "/qgis/messageTimeout", 5 ).toInt() );
+
QString name = QApplication::style()->objectName();
cmbStyle->setCurrentIndex( cmbStyle->findText( name, Qt::MatchFixedString ) );
//set the state of the checkboxes
@@ -1078,6 +1080,9 @@ void QgsOptions::saveOptions()
settings.setValue( "/fontFamily", fontFamily );
QgisApp::instance()->setAppStyleSheet();
+ settings.setValue( "/qgis/messageTimeout", mInfoBarTimeoutSpnBx->value() );
+ QgisApp::instance()->setMessageTimeout( mInfoBarTimeoutSpnBx->value() );
+
// rasters settings
settings.setValue( "/Raster/defaultRedBand", spnRed->value() );
settings.setValue( "/Raster/defaultGreenBand", spnGreen->value() );
diff --git a/src/gui/qgsmessagebar.cpp b/src/gui/qgsmessagebar.cpp
index 65b82c80ec2..3d4a9dec849 100644
--- a/src/gui/qgsmessagebar.cpp
+++ b/src/gui/qgsmessagebar.cpp
@@ -27,6 +27,7 @@
#include
#include
#include
+#include
QgsMessageBar::QgsMessageBar( QWidget *parent )
@@ -45,15 +46,14 @@ QgsMessageBar::QgsMessageBar( QWidget *parent )
mCountProgress = new QProgressBar( this );
- mCountProgress->setStyleSheet( "QProgressBar { border: 1px solid rgba(0, 0, 0, 75%);"
- " border-radius: 2px; background: rgba(0, 0, 0, 0); }"
- "QProgressBar::chunk { background-color: rgba(0, 0, 0, 50%); width: 5px; }" );
+ mCountStyleSheet = QString( "QProgressBar { border: 1px solid rgba(0, 0, 0, 75%);"
+ " border-radius: 2px; background: rgba(0, 0, 0, 0);"
+ " image: url(:/images/themes/default/%1) }"
+ "QProgressBar::chunk { background-color: rgba(0, 0, 0, 30%); width: 5px; }" );
+
+ mCountProgress->setStyleSheet( mCountStyleSheet.arg( "mIconTimerPause.png" ) );
mCountProgress->setObjectName( "mCountdown" );
- mCountProgress->setToolTip( tr( "Countdown" ) );
- mCountProgress->setMinimumWidth( 25 );
- mCountProgress->setMaximumWidth( 25 );
- mCountProgress->setMinimumHeight( 10 );
- mCountProgress->setMaximumHeight( 10 );
+ mCountProgress->setFixedSize( 25, 14 );
mCountProgress->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
mCountProgress->setTextVisible( false );
mCountProgress->setRange( 0, 5 );
@@ -100,6 +100,25 @@ QgsMessageBar::~QgsMessageBar()
{
}
+void QgsMessageBar::mousePressEvent( QMouseEvent * e )
+{
+ // stop/start mCountdownTimer
+ QProgressBar *pb = static_cast( childAt( e->pos() ) );
+ if ( pb && pb->objectName() == QString( "mCountdown" ) && e->button() == Qt::LeftButton )
+ {
+ if ( mCountdownTimer->isActive() )
+ {
+ mCountdownTimer->stop();
+ pb->setStyleSheet( mCountStyleSheet.arg( "mIconTimerContinue.png" ) );
+ }
+ else
+ {
+ mCountdownTimer->start();
+ pb->setStyleSheet( mCountStyleSheet.arg( "mIconTimerPause.png" ) );
+ }
+ }
+}
+
void QgsMessageBar::popItem( QgsMessageBarItem *item )
{
Q_ASSERT( item );
@@ -340,6 +359,7 @@ void QgsMessageBar::resetCountdown()
if ( mCountdownTimer->isActive() )
mCountdownTimer->stop();
+ mCountProgress->setStyleSheet( mCountStyleSheet.arg( "mIconTimerPause.png" ) );
mCountProgress->setVisible( false );
}
diff --git a/src/gui/qgsmessagebar.h b/src/gui/qgsmessagebar.h
index 5538892edd8..308b18c5ad9 100644
--- a/src/gui/qgsmessagebar.h
+++ b/src/gui/qgsmessagebar.h
@@ -101,6 +101,9 @@ class GUI_EXPORT QgsMessageBar: public QFrame
*/
bool clearWidgets();
+ protected:
+ void mousePressEvent( QMouseEvent * e );
+
private:
class QgsMessageBarItem
{
@@ -133,6 +136,7 @@ class GUI_EXPORT QgsMessageBar: public QFrame
QAction *mActionCloseAll;
QTimer *mCountdownTimer;
QProgressBar *mCountProgress;
+ QString mCountStyleSheet;
private slots:
//! updates count of items in widget list
diff --git a/src/ui/qgsoptionsbase.ui b/src/ui/qgsoptionsbase.ui
index 24ca12062b0..f9d418a24dc 100644
--- a/src/ui/qgsoptionsbase.ui
+++ b/src/ui/qgsoptionsbase.ui
@@ -258,7 +258,7 @@
0
0
690
- 1036
+ 1073
@@ -465,6 +465,52 @@
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Timeout for timed messages or dialogs
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ s
+
+
+ 2
+
+
+ 20
+
+
+ 5
+
+
+
+
+
-
-