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

A different approach to avoiding accidently scroll changes #4274

Merged
merged 3 commits into from
Mar 21, 2017
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
8 changes: 7 additions & 1 deletion python/console/console_settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</widget>
</item>
<item row="0" column="0">
<widget class="QScrollArea" name="scrollArea">
<widget class="QgsScrollArea" name="scrollArea">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
Expand Down Expand Up @@ -1139,6 +1139,12 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsScrollArea</class>
<extends>QScrollArea</extends>
<header location="global">qgis.gui</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
Expand Down
1 change: 1 addition & 0 deletions python/gui/gui.sip
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
%Include qgsscalerangewidget.sip
%Include qgsscalevisibilitydialog.sip
%Include qgsscalewidget.sip
%Include qgsscrollarea.sip
%Include qgssearchquerybuilder.sip
%Include qgsshortcutsmanager.sip
%Include qgsslider.sip
Expand Down
15 changes: 15 additions & 0 deletions python/gui/qgsscrollarea.sip
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class QgsScrollArea : QScrollArea
{
%TypeHeaderCode
#include <qgsscrollarea.h>
%End

public:
explicit QgsScrollArea( QWidget *parent /TransferThis/ = 0 );
void scrollOccurred();
bool hasScrolled() const;

protected:
void wheelEvent( QWheelEvent *event );

};
7 changes: 4 additions & 3 deletions python/plugins/processing/modeler/ModelerParametersDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@
from qgis.PyQt.QtCore import Qt, QUrl, QMetaObject
from qgis.PyQt.QtWidgets import (QDialog, QDialogButtonBox, QLabel, QLineEdit,
QFrame, QPushButton, QSizePolicy, QVBoxLayout,
QHBoxLayout, QTabWidget, QWidget, QScrollArea,
QHBoxLayout, QTabWidget, QWidget,
QTextBrowser)
from qgis.PyQt.QtNetwork import QNetworkRequest, QNetworkReply

from qgis.core import QgsNetworkAccessManager

from qgis.gui import QgsMessageBar
from qgis.gui import (QgsMessageBar,
QgsScrollArea)

from processing.gui.wrappers import InvalidParameterValue
from processing.gui.MultipleInputPanel import MultipleInputPanel
Expand Down Expand Up @@ -187,7 +188,7 @@ def setupUi(self):
self.tabWidget.setMinimumWidth(300)
self.paramPanel = QWidget()
self.paramPanel.setLayout(self.verticalLayout)
self.scrollArea = QScrollArea()
self.scrollArea = QgsScrollArea()
self.scrollArea.setWidget(self.paramPanel)
self.scrollArea.setWidgetResizable(True)
self.tabWidget.addTab(self.scrollArea, self.tr('Parameters'))
Expand Down
11 changes: 8 additions & 3 deletions python/plugins/processing/ui/DlgModeler.ui
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea_1">
<widget class="QgsScrollArea" name="scrollArea_1">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -138,7 +138,7 @@
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea_2">
<widget class="QgsScrollArea" name="scrollArea_2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -222,7 +222,7 @@
<number>2</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea_3">
<widget class="QgsScrollArea" name="scrollArea_3">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -505,6 +505,11 @@
</action>
</widget>
<customwidgets>
<customwidget>
<class>QgsScrollArea</class>
<extends>QScrollArea</extends>
<header>qgis.gui</header>
</customwidget>
<customwidget>
<class>QgsFilterLineEdit</class>
<extends>QLineEdit</extends>
Expand Down
8 changes: 7 additions & 1 deletion python/plugins/processing/ui/widgetParametersPanel.ui
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea">
<widget class="QgsScrollArea" name="scrollArea">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
Expand Down Expand Up @@ -88,6 +88,12 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsScrollArea</class>
<extends>QScrollArea</extends>
<header>qgis.gui</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
Expand Down
1 change: 0 additions & 1 deletion src/app/composer/qgsattributeselectiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QScrollArea>
#include <QSpinBox>
#include <QSortFilterProxyModel>

Expand Down
2 changes: 2 additions & 0 deletions src/customwidgets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ SET (QGIS_CUSTOMWIDGETS_SRCS
qgsrelationreferencewidgetplugin.cpp
qgsscalerangewidgetplugin.cpp
qgsscalewidgetplugin.cpp
qgsscrollareawidgetplugin.cpp
qgsspinboxplugin.cpp
)

Expand All @@ -57,6 +58,7 @@ SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
qgsrelationreferencewidgetplugin.h
qgsscalerangewidgetplugin.h
qgsscalewidgetplugin.h
qgsscrollareawidgetplugin.h
qgsspinboxplugin.h
)

Expand Down
95 changes: 95 additions & 0 deletions src/customwidgets/qgsscrollareawidgetplugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/***************************************************************************
qgsscrollareawidgetplugin.cpp
--------------------------------------
Date : March 2017
Copyright : (C) 2017 Nyall Dawson
Email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/


#include "qgiscustomwidgets.h"
#include "qgsscrollareawidgetplugin.h"
#include "qgsscrollarea.h"


QgsScrollAreaWidgetPlugin::QgsScrollAreaWidgetPlugin( QObject *parent )
: QObject( parent )
{}

QString QgsScrollAreaWidgetPlugin::name() const
{
return "QgsScrollArea";
}

QString QgsScrollAreaWidgetPlugin::group() const
{
return QgisCustomWidgets::groupName();
}

QString QgsScrollAreaWidgetPlugin::includeFile() const
{
return "qgsscrollarea.h";
}

QIcon QgsScrollAreaWidgetPlugin::icon() const
{
return QIcon( ":/images/icons/qgis-icon-60x60.png" );
}

bool QgsScrollAreaWidgetPlugin::isContainer() const
{
return true;
}

QWidget *QgsScrollAreaWidgetPlugin::createWidget( QWidget *parent )
{
return new QgsScrollArea( parent );
}

bool QgsScrollAreaWidgetPlugin::isInitialized() const
{
return mInitialized;
}

void QgsScrollAreaWidgetPlugin::initialize( QDesignerFormEditorInterface *core )
{
Q_UNUSED( core );
if ( mInitialized )
return;
mInitialized = true;
}


QString QgsScrollAreaWidgetPlugin::toolTip() const
{
return tr( "Scroll area" );
}

QString QgsScrollAreaWidgetPlugin::whatsThis() const
{
return "";
}

QString QgsScrollAreaWidgetPlugin::domXml() const
{
return QString( "<ui language=\"c++\">\n"
" <widget class=\"%1\" name=\"mScrollArea\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>300</width>\n"
" <height>100</height>\n"
" </rect>\n"
" </property>\n"
" </widget>\n"
"</ui>\n" )
.arg( name() );
}
50 changes: 50 additions & 0 deletions src/customwidgets/qgsscrollareawidgetplugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/***************************************************************************
qgsscrollareawidgetplugin.h
--------------------------------------
Date : March 2017
Copyright : (C) 2017 Nyall Dawson
Email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSSCROLLAREAWIDGETPLUGIN_H
#define QGSSCROLLAREAWIDGETPLUGIN_H


#include <QtGlobal>
#include <QtUiPlugin/QDesignerCustomWidgetInterface>
#include <QtUiPlugin/QDesignerExportWidget>
#include "qgis_customwidgets.h"

class CUSTOMWIDGETS_EXPORT QgsScrollAreaWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES( QDesignerCustomWidgetInterface )

public:
explicit QgsScrollAreaWidgetPlugin( QObject *parent = 0 );

private:
bool mInitialized = false;

// QDesignerCustomWidgetInterface interface
public:
QString name() const override;
QString group() const override;
QString includeFile() const override;
QIcon icon() const override;
bool isContainer() const override;
QWidget *createWidget( QWidget *parent ) override;
bool isInitialized() const override;
void initialize( QDesignerFormEditorInterface *core ) override;
QString toolTip() const override;
QString whatsThis() const override;
QString domXml() const override;
};
#endif // QGSSCROLLAREAWIDGETPLUGIN_H
2 changes: 2 additions & 0 deletions src/gui/CMakeLists.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ SET(QGIS_GUI_SRCS
qgsscalerangewidget.cpp
qgsscalevisibilitydialog.cpp
qgsscalewidget.cpp
qgsscrollarea.cpp
qgssearchquerybuilder.cpp
qgsshortcutsmanager.cpp
qgsslider.cpp
Expand Down Expand Up @@ -442,6 +443,7 @@ SET(QGIS_GUI_MOC_HDRS
qgsscalerangewidget.h
qgsscalevisibilitydialog.h
qgsscalewidget.h
qgsscrollarea.h
qgssearchquerybuilder.h
qgsshortcutsmanager.h
qgsslider.h
Expand Down
3 changes: 2 additions & 1 deletion src/gui/attributetable/qgsdualview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "qgsorganizetablecolumnsdialog.h"
#include "qgseditorwidgetregistry.h"
#include "qgssettings.h"
#include "qgsscrollarea.h"

#include <QClipboard>
#include <QDialog>
Expand Down Expand Up @@ -95,7 +96,7 @@ void QgsDualView::init( QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, const Qg
mAttributeForm = new QgsAttributeForm( mLayer, QgsFeature(), mEditorContext );
if ( !context.parentContext() )
{
mAttributeEditorScrollArea = new QScrollArea();
mAttributeEditorScrollArea = new QgsScrollArea();
mAttributeEditorScrollArea->setWidgetResizable( true );
mAttributeEditor->layout()->addWidget( mAttributeEditorScrollArea );
mAttributeEditorScrollArea->setWidget( mAttributeForm );
Expand Down
4 changes: 2 additions & 2 deletions src/gui/attributetable/qgsdualview.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
class QgsFeatureRequest;
class QSignalMapper;
class QgsMapLayerAction;
class QScrollArea;
class QgsScrollArea;

/** \ingroup gui
* This widget is used to show the attributes of a set of features of a {@link QgsVectorLayer}.
Expand Down Expand Up @@ -351,7 +351,7 @@ class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBas
QgsDistanceArea mDistanceArea;
QString mDisplayExpression;
QgsAttributeTableConfig mConfig;
QScrollArea *mAttributeEditorScrollArea = nullptr;
QgsScrollArea *mAttributeEditorScrollArea = nullptr;
QgsMapCanvas *mMapCanvas = nullptr;

friend class TestQgsDualView;
Expand Down
6 changes: 3 additions & 3 deletions src/gui/qgsattributeform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "qgslogger.h"
#include "qgstabwidget.h"
#include "qgssettings.h"
#include "qgsscrollarea.h"

#include <QDir>
#include <QTextStream>
Expand All @@ -42,7 +43,6 @@
#include <QKeyEvent>
#include <QLabel>
#include <QPushButton>
#include <QScrollArea>
#include <QUiLoader>
#include <QMessageBox>
#include <QToolButton>
Expand Down Expand Up @@ -1210,7 +1210,7 @@ void QgsAttributeForm::init()
if ( mContext.formMode() != QgsAttributeEditorContext::Embed )
{
// put the form into a scroll area to nicely handle cases with lots of attributes
QScrollArea *scrollArea = new QScrollArea( this );
QgsScrollArea *scrollArea = new QgsScrollArea( this );
scrollArea->setWidget( formWidget );
scrollArea->setWidgetResizable( true );
scrollArea->setFrameShape( QFrame::NoFrame );
Expand Down Expand Up @@ -1599,7 +1599,7 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt

if ( context.formMode() != QgsAttributeEditorContext::Embed )
{
QScrollArea *scrollArea = new QScrollArea( parent );
QgsScrollArea *scrollArea = new QgsScrollArea( parent );

scrollArea->setWidget( myContainer );
scrollArea->setWidgetResizable( true );
Expand Down
1 change: 0 additions & 1 deletion src/gui/qgsattributetypeloaddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <QComboBox>
#include <QLabel>
#include <QFrame>
#include <QScrollArea>
#include <QCompleter>
#include <QSpinBox>
#include <QPushButton>
Expand Down
Loading