mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -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/mIconSymbology.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/mIconVectorLayer.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->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;
|
||||
}
|
||||
|
||||
|
@ -398,6 +398,10 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
|
||||
* @note added in 1.9 */
|
||||
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
|
||||
//! 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 );
|
||||
|
@ -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() );
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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() );
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <QTimer>
|
||||
#include <QGridLayout>
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
|
||||
|
||||
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<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 )
|
||||
{
|
||||
Q_ASSERT( item );
|
||||
@ -340,6 +359,7 @@ void QgsMessageBar::resetCountdown()
|
||||
if ( mCountdownTimer->isActive() )
|
||||
mCountdownTimer->stop();
|
||||
|
||||
mCountProgress->setStyleSheet( mCountStyleSheet.arg( "mIconTimerPause.png" ) );
|
||||
mCountProgress->setVisible( false );
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -258,7 +258,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>690</width>
|
||||
<height>1036</height>
|
||||
<height>1073</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
@ -465,6 +465,52 @@
|
||||
</item>
|
||||
</layout>
|
||||
</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>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user