diff --git a/src/app/options/qgsoptions.cpp b/src/app/options/qgsoptions.cpp index 74c64ef3f808..0e53c638d932 100644 --- a/src/app/options/qgsoptions.cpp +++ b/src/app/options/qgsoptions.cpp @@ -754,6 +754,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListsetChecked( mSettings->value( QStringLiteral( "/qgis/checkVersion" ), true ).toBool() ); cbxCheckVersion->setVisible( mSettings->value( QStringLiteral( "/qgis/allowVersionCheck" ), true ).toBool() ); cbxAttributeTableDocked->setChecked( mSettings->value( QStringLiteral( "/qgis/dockAttributeTable" ), false ).toBool() ); + cbxAutosizeAttributeTable->setChecked( QgsSettingsRegistryCore::settingsAutosizeAttributeTable->value() ); mComboCopyFeatureFormat->addItem( tr( "Plain Text, No Geometry" ), QgsClipboard::AttributesOnly ); mComboCopyFeatureFormat->addItem( tr( "Plain Text, WKT Geometry" ), QgsClipboard::AttributesWithWKT ); @@ -1613,6 +1614,7 @@ void QgsOptions::saveOptions() mSettings->setValue( QStringLiteral( "/qgis/checkVersion" ), cbxCheckVersion->isChecked() ); mSettings->setValue( QStringLiteral( "/qgis/dockAttributeTable" ), cbxAttributeTableDocked->isChecked() ); + QgsSettingsRegistryCore::settingsAutosizeAttributeTable->setValue( cbxAutosizeAttributeTable->isChecked() ); mSettings->setEnumValue( QStringLiteral( "/qgis/attributeTableBehavior" ), ( QgsAttributeTableFilterModel::FilterMode )cmbAttrTableBehavior->currentData().toInt() ); mSettings->setValue( QStringLiteral( "/qgis/attributeTableView" ), mAttrTableViewComboBox->currentData() ); mSettings->setValue( QStringLiteral( "/qgis/attributeTableRowCache" ), spinBoxAttrTableRowCache->value() ); diff --git a/src/app/qgsattributetabledialog.cpp b/src/app/qgsattributetabledialog.cpp index 31a16d981021..baab38feccca 100644 --- a/src/app/qgsattributetabledialog.cpp +++ b/src/app/qgsattributetabledialog.cpp @@ -54,6 +54,7 @@ #include "qgsdockablewidgethelper.h" #include "qgsactionmenu.h" #include "qgsdockwidget.h" +#include "qgssettingsregistrycore.h" QgsExpressionContext QgsAttributeTableDialog::createExpressionContext() const { @@ -410,6 +411,11 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr mMainView->setView( static_cast< QgsDualView::ViewMode >( initialView ) ); mMainViewButtonGroup->button( initialView )->setChecked( true ); + if ( QgsSettingsRegistryCore::settingsAutosizeAttributeTable->value() ) + { + mMainView->tableView()->resizeColumnsToContents(); + } + connect( mActionToggleMultiEdit, &QAction::toggled, mMainView, &QgsDualView::setMultiEditEnabled ); connect( mActionSearchForm, &QAction::toggled, mMainView, &QgsDualView::toggleSearchMode ); updateMultiEditButtonState(); diff --git a/src/core/settings/qgssettingsregistrycore.cpp b/src/core/settings/qgssettingsregistrycore.cpp index 1fb3209c9499..e0b12336b947 100644 --- a/src/core/settings/qgssettingsregistrycore.cpp +++ b/src/core/settings/qgssettingsregistrycore.cpp @@ -119,6 +119,8 @@ const QgsSettingsEntryString *QgsSettingsRegistryCore::settingsNetworkCacheDirec const QgsSettingsEntryInteger64 *QgsSettingsRegistryCore::settingsNetworkCacheSize = new QgsSettingsEntryInteger64( QStringLiteral( "size-bytes" ), QgsSettingsTree::sTreeNetworkCache, 0, QStringLiteral( "Network disk cache size in bytes (0 = automatic size)" ) ); +const QgsSettingsEntryBool *QgsSettingsRegistryCore::settingsAutosizeAttributeTable = new QgsSettingsEntryBool( QStringLiteral( "autosize-attribute-table" ), QgsSettingsTree::sTreeAttributeTable, false ); + QgsSettingsRegistryCore::QgsSettingsRegistryCore() : QgsSettingsRegistry() { diff --git a/src/core/settings/qgssettingsregistrycore.h b/src/core/settings/qgssettingsregistrycore.h index fe3ec0df8844..5960cfd2e604 100644 --- a/src/core/settings/qgssettingsregistrycore.h +++ b/src/core/settings/qgssettingsregistrycore.h @@ -172,6 +172,9 @@ class CORE_EXPORT QgsSettingsRegistryCore : public QgsSettingsRegistry //! Settings entry network cache directory static const QgsSettingsEntryInteger64 *settingsNetworkCacheSize; + //! Settings entry autosize columns by default when opening attribute table + static const QgsSettingsEntryBool *settingsAutosizeAttributeTable; + private: friend class QgsApplication; diff --git a/src/core/settings/qgssettingstree.h b/src/core/settings/qgssettingstree.h index 36a6221d8c73..1ceeff815a25 100644 --- a/src/core/settings/qgssettingstree.h +++ b/src/core/settings/qgssettingstree.h @@ -64,6 +64,7 @@ class CORE_EXPORT QgsSettingsTree static inline QgsSettingsTreeNode *sTreeMeasure = treeRoot()->createChildNode( QStringLiteral( "measure" ) ); static inline QgsSettingsTreeNode *sTreeAnnotations = treeRoot()->createChildNode( QStringLiteral( "annotations" ) ); static inline QgsSettingsTreeNode *sTreeNetworkCache = treeRoot()->createChildNode( QStringLiteral( "cache" ) ); + static inline QgsSettingsTreeNode *sTreeAttributeTable = treeRoot()->createChildNode( QStringLiteral( "attribute-table" ) ); #endif diff --git a/src/ui/qgsoptionsbase.ui b/src/ui/qgsoptionsbase.ui index 53c7aed2752b..56fde9a6e7fc 100644 --- a/src/ui/qgsoptionsbase.ui +++ b/src/ui/qgsoptionsbase.ui @@ -122,7 +122,7 @@ - 0 + 4 @@ -971,8 +971,8 @@ 0 0 - 578 - 1069 + 843 + 1068 @@ -1331,10 +1331,10 @@ Current environment variables (read-only - bold indicates modified at startup) - + false - + true @@ -1510,8 +1510,8 @@ 0 0 - 611 - 465 + 857 + 685 @@ -1534,7 +1534,7 @@ - + true @@ -1640,7 +1640,7 @@ - + 0 @@ -1754,8 +1754,8 @@ 0 0 - 596 - 105 + 857 + 685 @@ -1837,8 +1837,8 @@ 0 0 - 637 - 744 + 843 + 772 @@ -1860,14 +1860,10 @@ Feature Attributes and Table - - - - Open attribute table as docked window - - + + - + @@ -1876,7 +1872,34 @@ - + + + + Default view + + + + + + + + + + Open attribute table as docked window + + + + + + + + + + Representation for NULL values + + + + @@ -1890,19 +1913,6 @@ - - - Representation for NULL values - - - - - - - - - - @@ -1915,7 +1925,7 @@ - + 0 @@ -1931,20 +1941,17 @@ - - - - - + + - Default view + Copy features as - - + + - Copy features as + Autosize all columns by default when opening attribute table @@ -2441,7 +2448,7 @@ 0 0 508 - 482 + 487 @@ -2680,7 +2687,7 @@ 0.100000000000000 - + true @@ -2718,7 +2725,7 @@ 20.000000000000000 - + true @@ -2824,7 +2831,7 @@ 0 0 622 - 923 + 925 @@ -3222,7 +3229,7 @@ Coordinate and Bearing Display - + projgeneral @@ -3320,7 +3327,7 @@ The bigger the number, the faster zooming with the mouse wheel will be. 200 - + true @@ -3487,8 +3494,8 @@ The bigger the number, the faster zooming with the mouse wheel will be. 0 0 - 843 - 1031 + 575 + 1038 @@ -4393,8 +4400,8 @@ The bigger the number, the faster zooming with the mouse wheel will be. 0 0 - 482 - 539 + 476 + 542 @@ -4878,6 +4885,9 @@ The bigger the number, the faster zooming with the mouse wheel will be. Specify the cache size in megabytes. Clear the value to enable smart cache size, which sets the maximum cache size based on available space. + + Smart cache size + MB @@ -4890,14 +4900,11 @@ The bigger the number, the faster zooming with the mouse wheel will be. 100 - - 0 - - + true - - Smart cache size + + false @@ -4971,10 +4978,10 @@ The bigger the number, the faster zooming with the mouse wheel will be. true - + false - + true @@ -5235,11 +5242,8 @@ The bigger the number, the faster zooming with the mouse wheel will be. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -hr { height: 1px; border-width: 0; } -li.unchecked::marker { content: "\2610"; } -li.checked::marker { content: "\2612"; } </style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Noto Sans'; font-size:10pt;"><br /></p></body></html> @@ -5635,6 +5639,7 @@ li.checked::marker { content: "\2612"; } +