mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Add stop/start and user default option for timeout of timed QgsMessageBars
- Add pause/start icons to timeout countdown progress bar - Add user-defined option for general message timeouts - [API] Add get/set methods for general message timeouts to QgisApp
This commit is contained in:
parent
98d8d507ef
commit
3ea0a37fb6
@ -225,6 +225,8 @@
|
|||||||
<file>themes/default/mIconRenderingDisabled.png</file>
|
<file>themes/default/mIconRenderingDisabled.png</file>
|
||||||
<file>themes/default/mIconSymbology.png</file>
|
<file>themes/default/mIconSymbology.png</file>
|
||||||
<file>themes/default/mIconTableLayer.png</file>
|
<file>themes/default/mIconTableLayer.png</file>
|
||||||
|
<file>themes/default/mIconTimerPause.png</file>
|
||||||
|
<file>themes/default/mIconTimerContinue.png</file>
|
||||||
<file>themes/default/mIconUnknownLayerType.png</file>
|
<file>themes/default/mIconUnknownLayerType.png</file>
|
||||||
<file>themes/default/mIconVectorLayer.png</file>
|
<file>themes/default/mIconVectorLayer.png</file>
|
||||||
<file>themes/default/mIconWaitingForLayerType.png</file>
|
<file>themes/default/mIconWaitingForLayerType.png</file>
|
||||||
|
BIN
images/themes/default/mIconTimerContinue.png
Normal file
BIN
images/themes/default/mIconTimerContinue.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 207 B |
BIN
images/themes/default/mIconTimerPause.png
Normal file
BIN
images/themes/default/mIconTimerPause.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 199 B |
@ -488,6 +488,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
|
|||||||
mInfoBar = new QgsMessageBar( centralWidget );
|
mInfoBar = new QgsMessageBar( centralWidget );
|
||||||
mInfoBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
|
mInfoBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
|
||||||
centralLayout->addWidget( mInfoBar, 0, 0, 1, 1 );
|
centralLayout->addWidget( mInfoBar, 0, 0, 1, 1 );
|
||||||
|
mInfoBarTimeout = settings.value( "/qgis/messageTimeout", 5 ).toInt();
|
||||||
|
|
||||||
//set the focus to the map canvas
|
//set the focus to the map canvas
|
||||||
mMapCanvas->setFocus();
|
mMapCanvas->setFocus();
|
||||||
@ -4042,7 +4043,7 @@ void QgisApp::labeling()
|
|||||||
messageBar()->pushMessage( tr( "Labeling Options" ),
|
messageBar()->pushMessage( tr( "Labeling Options" ),
|
||||||
tr( "Please select a vector layer first" ),
|
tr( "Please select a vector layer first" ),
|
||||||
QgsMessageBar::INFO,
|
QgsMessageBar::INFO,
|
||||||
5 );
|
messageTimeout() );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,6 +398,10 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
|
|||||||
* @note added in 1.9 */
|
* @note added in 1.9 */
|
||||||
QList<QgsMapLayer *> editableLayers( bool modified = false ) const;
|
QList<QgsMapLayer *> 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
|
#ifdef Q_OS_WIN
|
||||||
//! ugly hack
|
//! ugly hack
|
||||||
void skipNextContextMenuEvent();
|
void skipNextContextMenuEvent();
|
||||||
@ -539,6 +543,11 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
|
|||||||
//! layer selection changed
|
//! layer selection changed
|
||||||
void legendLayerSelectionChanged( void );
|
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.
|
//! Watch for QFileOpenEvent.
|
||||||
virtual bool event( QEvent * event );
|
virtual bool event( QEvent * event );
|
||||||
|
|
||||||
@ -1333,6 +1342,9 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
|
|||||||
QgsMessageBar *mInfoBar;
|
QgsMessageBar *mInfoBar;
|
||||||
QWidget *mMacrosWarn;
|
QWidget *mMacrosWarn;
|
||||||
|
|
||||||
|
//! timeout for timed messages
|
||||||
|
int mMessageTimeout;
|
||||||
|
|
||||||
#ifdef HAVE_TOUCH
|
#ifdef HAVE_TOUCH
|
||||||
bool gestureEvent( QGestureEvent *event );
|
bool gestureEvent( QGestureEvent *event );
|
||||||
void tapAndHoldTriggered( QTapAndHoldGesture *gesture );
|
void tapAndHoldTriggered( QTapAndHoldGesture *gesture );
|
||||||
|
@ -127,7 +127,7 @@ void QgsMapToolEdit::notifyNotVectorLayer()
|
|||||||
tr( "No active vector layer" ),
|
tr( "No active vector layer" ),
|
||||||
tr( "Choose a vector layer in the legend" ),
|
tr( "Choose a vector layer in the legend" ),
|
||||||
QgsMessageBar::INFO,
|
QgsMessageBar::INFO,
|
||||||
5 );
|
QgisApp::instance()->messageTimeout() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsMapToolEdit::notifyNotEditableLayer()
|
void QgsMapToolEdit::notifyNotEditableLayer()
|
||||||
@ -136,5 +136,5 @@ void QgsMapToolEdit::notifyNotEditableLayer()
|
|||||||
tr( "Layer not editable" ),
|
tr( "Layer not editable" ),
|
||||||
tr( "Use 'Toggle Editing' to make it editable" ),
|
tr( "Use 'Toggle Editing' to make it editable" ),
|
||||||
QgsMessageBar::INFO,
|
QgsMessageBar::INFO,
|
||||||
5 );
|
QgisApp::instance()->messageTimeout() );
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ QgsVectorLayer* QgsMapToolSelectUtils::getCurrentVectorLayer( QgsMapCanvas* canv
|
|||||||
QObject::tr( "No active vector layer" ),
|
QObject::tr( "No active vector layer" ),
|
||||||
QObject::tr( "To select features, choose a vector layer in the legend" ),
|
QObject::tr( "To select features, choose a vector layer in the legend" ),
|
||||||
QgsMessageBar::INFO,
|
QgsMessageBar::INFO,
|
||||||
5 );
|
QgisApp::instance()->messageTimeout() );
|
||||||
}
|
}
|
||||||
return vlayer;
|
return vlayer;
|
||||||
}
|
}
|
||||||
|
@ -462,6 +462,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
|
|||||||
}
|
}
|
||||||
blockSignals( false );
|
blockSignals( false );
|
||||||
|
|
||||||
|
mInfoBarTimeoutSpnBx->setValue( settings.value( "/qgis/messageTimeout", 5 ).toInt() );
|
||||||
|
|
||||||
QString name = QApplication::style()->objectName();
|
QString name = QApplication::style()->objectName();
|
||||||
cmbStyle->setCurrentIndex( cmbStyle->findText( name, Qt::MatchFixedString ) );
|
cmbStyle->setCurrentIndex( cmbStyle->findText( name, Qt::MatchFixedString ) );
|
||||||
//set the state of the checkboxes
|
//set the state of the checkboxes
|
||||||
@ -1078,6 +1080,9 @@ void QgsOptions::saveOptions()
|
|||||||
settings.setValue( "/fontFamily", fontFamily );
|
settings.setValue( "/fontFamily", fontFamily );
|
||||||
QgisApp::instance()->setAppStyleSheet();
|
QgisApp::instance()->setAppStyleSheet();
|
||||||
|
|
||||||
|
settings.setValue( "/qgis/messageTimeout", mInfoBarTimeoutSpnBx->value() );
|
||||||
|
QgisApp::instance()->setMessageTimeout( mInfoBarTimeoutSpnBx->value() );
|
||||||
|
|
||||||
// rasters settings
|
// rasters settings
|
||||||
settings.setValue( "/Raster/defaultRedBand", spnRed->value() );
|
settings.setValue( "/Raster/defaultRedBand", spnRed->value() );
|
||||||
settings.setValue( "/Raster/defaultGreenBand", spnGreen->value() );
|
settings.setValue( "/Raster/defaultGreenBand", spnGreen->value() );
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
|
||||||
QgsMessageBar::QgsMessageBar( QWidget *parent )
|
QgsMessageBar::QgsMessageBar( QWidget *parent )
|
||||||
@ -45,15 +46,14 @@ QgsMessageBar::QgsMessageBar( QWidget *parent )
|
|||||||
|
|
||||||
mCountProgress = new QProgressBar( this );
|
mCountProgress = new QProgressBar( this );
|
||||||
|
|
||||||
mCountProgress->setStyleSheet( "QProgressBar { border: 1px solid rgba(0, 0, 0, 75%);"
|
mCountStyleSheet = QString( "QProgressBar { border: 1px solid rgba(0, 0, 0, 75%);"
|
||||||
" border-radius: 2px; background: rgba(0, 0, 0, 0); }"
|
" border-radius: 2px; background: rgba(0, 0, 0, 0);"
|
||||||
"QProgressBar::chunk { background-color: rgba(0, 0, 0, 50%); width: 5px; }" );
|
" 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->setObjectName( "mCountdown" );
|
||||||
mCountProgress->setToolTip( tr( "Countdown" ) );
|
mCountProgress->setFixedSize( 25, 14 );
|
||||||
mCountProgress->setMinimumWidth( 25 );
|
|
||||||
mCountProgress->setMaximumWidth( 25 );
|
|
||||||
mCountProgress->setMinimumHeight( 10 );
|
|
||||||
mCountProgress->setMaximumHeight( 10 );
|
|
||||||
mCountProgress->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
mCountProgress->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||||
mCountProgress->setTextVisible( false );
|
mCountProgress->setTextVisible( false );
|
||||||
mCountProgress->setRange( 0, 5 );
|
mCountProgress->setRange( 0, 5 );
|
||||||
@ -100,6 +100,25 @@ QgsMessageBar::~QgsMessageBar()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsMessageBar::mousePressEvent( QMouseEvent * e )
|
||||||
|
{
|
||||||
|
// stop/start mCountdownTimer
|
||||||
|
QProgressBar *pb = static_cast<QProgressBar *>( 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 )
|
void QgsMessageBar::popItem( QgsMessageBarItem *item )
|
||||||
{
|
{
|
||||||
Q_ASSERT( item );
|
Q_ASSERT( item );
|
||||||
@ -340,6 +359,7 @@ void QgsMessageBar::resetCountdown()
|
|||||||
if ( mCountdownTimer->isActive() )
|
if ( mCountdownTimer->isActive() )
|
||||||
mCountdownTimer->stop();
|
mCountdownTimer->stop();
|
||||||
|
|
||||||
|
mCountProgress->setStyleSheet( mCountStyleSheet.arg( "mIconTimerPause.png" ) );
|
||||||
mCountProgress->setVisible( false );
|
mCountProgress->setVisible( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +101,9 @@ class GUI_EXPORT QgsMessageBar: public QFrame
|
|||||||
*/
|
*/
|
||||||
bool clearWidgets();
|
bool clearWidgets();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void mousePressEvent( QMouseEvent * e );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class QgsMessageBarItem
|
class QgsMessageBarItem
|
||||||
{
|
{
|
||||||
@ -133,6 +136,7 @@ class GUI_EXPORT QgsMessageBar: public QFrame
|
|||||||
QAction *mActionCloseAll;
|
QAction *mActionCloseAll;
|
||||||
QTimer *mCountdownTimer;
|
QTimer *mCountdownTimer;
|
||||||
QProgressBar *mCountProgress;
|
QProgressBar *mCountProgress;
|
||||||
|
QString mCountStyleSheet;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//! updates count of items in widget list
|
//! updates count of items in widget list
|
||||||
|
@ -258,7 +258,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>690</width>
|
<width>690</width>
|
||||||
<height>1036</height>
|
<height>1073</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
@ -465,6 +465,52 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_28">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="mInfoBarTimeoutLabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Timeout for timed messages or dialogs</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_13">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="mInfoBarTimeoutSpnBx">
|
||||||
|
<property name="suffix">
|
||||||
|
<string> s</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>20</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||||
<item>
|
<item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user