Skip to content
Permalink
Browse files

[addlayerbutton] Data Source Manager toolbar and menu

This implements the proposal from @srneto:

- new toolbar with the new dialog button and
  all the "new" data soource buttons
- old layer toolbar hidden by default
- new dialog open from first item in layer menu
  • Loading branch information
elpaso committed Jun 2, 2017
1 parent e761395 commit 23ae508798d5286e500179e4d6cc64a4569fc21a
Showing with 160 additions and 84 deletions.
  1. +18 −13 scripts/mkuidefaults.py
  2. +2 −0 src/app/qgisapp.cpp
  3. +1 −0 src/app/qgisapp.h
  4. +4 −0 src/app/qgsdatasourcemanagerdialog.cpp
  5. +112 −70 src/app/ui_defaults.h
  6. +23 −1 src/ui/qgisapp.ui
@@ -37,35 +37,40 @@ def chunks(l, n):

s = QSettings()

ba = s.value("/UI/geometry").toByteArray()
ba = bytes(s.value("/UI/geometry"))

f = open("src/app/ui_defaults.h", "w")

f.write("#ifndef UI_DEFAULTS_H\n#define UI_DEFAULTS_H\n\nstatic const unsigned char defaultUIgeometry[] =\n{\n")

for chunk in chunks(ba, 16):
f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % ord(x), chunk)))
f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % x, chunk)))

f.write("};\n\nstatic const unsigned char defaultUIstate[] =\n{\n")

ba = s.value("/UI/state").toByteArray()
ba = bytes(s.value("/UI/state"))

for chunk in chunks(ba, 16):
f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % ord(x), chunk)))
f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % x, chunk)))

ba = s.value("/Composer/geometry").toByteArray()
try:
ba = bytes(s.value("/Composer/geometry"))

f.write("};\n\nstatic const unsigned char defaultComposerUIgeometry[] =\n{\n")
f.write("};\n\nstatic const unsigned char defaultComposerUIgeometry[] =\n{\n")

for chunk in chunks(ba, 16):
f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % ord(x), chunk)))

f.write("};\n\nstatic const unsigned char defaultComposerUIstate[] =\n{\n")
for chunk in chunks(ba, 16):
f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % x, chunk)))
except TypeError as ex:
pass

ba = s.value("/ComposerUI/state").toByteArray()
try:
ba = bytes(s.value("/ComposerUI/state"))
f.write("};\n\nstatic const unsigned char defaultComposerUIstate[] =\n{\n")

for chunk in chunks(ba, 16):
f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % ord(x), chunk)))
for chunk in chunks(ba, 16):
f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % x, chunk)))
except TypeError as ex:
pass

f.write("};\n\n#endif // UI_DEFAULTS_H\n")

@@ -2239,6 +2239,7 @@ void QgisApp::createToolBars()

QList<QToolBar *> toolbarMenuToolBars;
toolbarMenuToolBars << mFileToolBar
<< mDataSourceManagerToolBar
<< mLayerToolBar
<< mDigitizeToolBar
<< mAdvancedDigitizeToolBar
@@ -2703,6 +2704,7 @@ void QgisApp::createStatusBar()
actionObjects << menuBar()
<< mAdvancedDigitizeToolBar
<< mFileToolBar
<< mDataSourceManagerToolBar
<< mLayerToolBar
<< mDigitizeToolBar
<< mMapNavToolBar
@@ -522,6 +522,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
*/
QToolBar *fileToolBar() { return mFileToolBar; }
QToolBar *layerToolBar() { return mLayerToolBar; }
QToolBar *dataSourceManagerToolBar() { return mDataSourceManagerToolBar; }
QToolBar *mapNavToolToolBar() { return mMapNavToolBar; }
QToolBar *digitizeToolBar() { return mDigitizeToolBar; }
QToolBar *advancedDigitizeToolBar() { return mAdvancedDigitizeToolBar; }
@@ -72,6 +72,10 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QgsMapCanvas *mapCanvas,
addDbProviderDialog( QStringLiteral( "postgres" ), tr( "PostgreSQL" ), QStringLiteral( "/mActionAddPostgisLayer.svg" ) );
#endif

#ifdef HAVE_ORACLE
addDbProviderDialog( QStringLiteral( "oracle" ), tr( "Oracle" ), QStringLiteral( "/mActionAddOracleLayer.svg" ) );
#endif

addDbProviderDialog( QStringLiteral( "spatialite" ), tr( "Spatialite" ), QStringLiteral( "/mActionAddSpatiaLiteLayer.svg" ) );

addDbProviderDialog( QStringLiteral( "mssql" ), tr( "MSSQL" ), QStringLiteral( "/mActionAddMssqlLayer.svg" ) );

0 comments on commit 23ae508

Please sign in to comment.
You can’t perform that action at this time.