qtbase/examples/sql/sqlbrowser/qsqlconnectiondialog.ui
Marc Mutz 8dbd0828e9 sqlbrowser example: use idiomatic Qt [2/3]: use button-box / override accept()
- The old code used two QPushButtons in a QHBoxLayout to provide
  Ok/Cancel buttons. This hard-codes the positions and text (and
  icons) of these buttons, instead of adapting to the platform style.

  The new code simply uses QDialogButtonBox, which is designed for
  this purpose.

- Also, the old code connected the Ok button's clicked() signal to a
  custom slot that then called QDialog::accept(). This means that the
  code in the custom slot is not executed when the dialog is accepted
  by other means (e.g. return press in one of the line edits
  ("auto-default"), though I'm not sure here).

  The new code uses the idiomatic Qt way of overriding
  QDialog::accept() instead, and connects the button-box's accepted()
  signal to it. This is done in the .ui file, so it already works in
  Designer preview.

- Finally, the old code made a manual connection from the Cancel
  button to QDialog::reject().

  The new code uses the Qt idiom of connecting in the .ui file
  directly, using QDialogButtonBox::rejected() as the signal.

Amends 2690822428deec4f0c08f4d118d69a7c6036369e, which, however,
inherited all of the above from even older code.

Pick-to: 6.8
Change-Id: I83afd6156a0811e0c0f99f2480625ea6b69ff78b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 3419c299369ac1da94ba5710aaf5f5f65c38c33c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-02 09:57:23 +00:00

236 lines
6.0 KiB
XML

<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>QSqlConnectionDialogUi</class>
<widget class="QDialog" name="QSqlConnectionDialogUi" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>315</width>
<height>302</height>
</rect>
</property>
<property name="windowTitle" >
<string>Connect...</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>8</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QGroupBox" name="connGroupBox" >
<property name="title" >
<string>Connection settings</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>8</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="1" >
<widget class="QComboBox" name="comboDriver" />
</item>
<item row="2" column="0" >
<widget class="QLabel" name="textLabel4" >
<property name="text" >
<string>&amp;Username:</string>
</property>
<property name="buddy" >
<cstring>editUsername</cstring>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="textLabel2" >
<property name="text" >
<string>D&amp;river</string>
</property>
<property name="buddy" >
<cstring>comboDriver</cstring>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="editDatabase" />
</item>
<item row="5" column="1" >
<widget class="QSpinBox" name="portSpinBox" >
<property name="specialValueText" >
<string>Default</string>
</property>
<property name="maximum" >
<number>65535</number>
</property>
<property name="minimum" >
<number>-1</number>
</property>
<property name="value" >
<number>-1</number>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="textLabel3" >
<property name="text" >
<string>Database Name:</string>
</property>
<property name="buddy" >
<cstring>editDatabase</cstring>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLineEdit" name="editPassword" >
<property name="echoMode" >
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="editUsername" />
</item>
<item row="4" column="1" >
<widget class="QLineEdit" name="editHostname" />
</item>
<item row="4" column="0" >
<widget class="QLabel" name="textLabel5" >
<property name="text" >
<string>&amp;Hostname:</string>
</property>
<property name="buddy" >
<cstring>editHostname</cstring>
</property>
</widget>
</item>
<item row="5" column="0" >
<widget class="QLabel" name="textLabel5_2" >
<property name="text" >
<string>P&amp;ort:</string>
</property>
<property name="buddy" >
<cstring>portSpinBox</cstring>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="textLabel4_2" >
<property name="text" >
<string>&amp;Password:</string>
</property>
<property name="buddy" >
<cstring>editPassword</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="dbCheckBox" >
<property name="text" >
<string>Us&amp;e predefined in-memory database</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<tabstops>
<tabstop>comboDriver</tabstop>
<tabstop>editDatabase</tabstop>
<tabstop>editUsername</tabstop>
<tabstop>editPassword</tabstop>
<tabstop>editHostname</tabstop>
<tabstop>portSpinBox</tabstop>
<tabstop>dbCheckBox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>dbCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>connGroupBox</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>165</x>
<y>248</y>
</hint>
<hint type="destinationlabel">
<x>107</x>
<y>221</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QSqlConnectionDialogUi</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>19</x>
<y>278</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>244</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QSqlConnectionDialogUi</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>58</x>
<y>276</y>
</hint>
<hint type="destinationlabel">
<x>58</x>
<y>258</y>
</hint>
</hints>
</connection>
</connections>
</ui>