[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kmymoney] kmymoney: Use QDialogButtonBox when possible
From: Pino Toscano <pino () kde ! org>
Date: 2016-11-27 14:06:02
Message-ID: E1cB05i-0002Zf-Nb () code ! kde ! org
[Download RAW message or body]
Git commit 5eda09045b292072eb1a2a03bcdc8c962ba1c90c by Pino Toscano.
Committed on 27/11/2016 at 13:56.
Pushed by pino into branch 'master'.
Use QDialogButtonBox when possible
Switch few dialogs to QDialogButtonBox instead of manually creating the
buttons of dialogs: this avoids wasting strings in UI files, and to
override them later using KStandardGuiItem elements.
M +4 -7 kmymoney/dialogs/kequitypriceupdatedlg.cpp
M +5 -41 kmymoney/dialogs/kequitypriceupdatedlgdecl.ui
M +5 -8 kmymoney/dialogs/kimportdlg.cpp
M +6 -46 kmymoney/dialogs/kimportdlgdecl.ui
M +2 -7 kmymoney/dialogs/ktagreassigndlg.cpp
M +17 -53 kmymoney/dialogs/ktagreassigndlgdecl.ui
M +14 -53 kmymoney/plugins/ofximport/dialogs/kofxdirectconnectdlgdecl.ui
https://commits.kde.org/kmymoney/5eda09045b292072eb1a2a03bcdc8c962ba1c90c
diff --git a/kmymoney/dialogs/kequitypriceupdatedlg.cpp \
b/kmymoney/dialogs/kequitypriceupdatedlg.cpp index b25716a..c1ffa96 100644
--- a/kmymoney/dialogs/kequitypriceupdatedlg.cpp
+++ b/kmymoney/dialogs/kequitypriceupdatedlg.cpp
@@ -84,9 +84,6 @@ KEquityPriceUpdateDlg::KEquityPriceUpdateDlg(QWidget *parent, const \
QString& sec
btnUpdateAll->setEnabled(false);
- KGuiItem::assign(btnOK, KStandardGuiItem::ok());
- KGuiItem::assign(btnCancel, KStandardGuiItem::cancel());
-
MyMoneyFile* file = MyMoneyFile::instance();
//
@@ -133,8 +130,8 @@ KEquityPriceUpdateDlg::KEquityPriceUpdateDlg(QWidget *parent, \
const QString& sec addPricePair(currencyIds, true);
}
- connect(btnOK, SIGNAL(clicked()), this, SLOT(accept()));
- connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject()));
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(btnUpdateSelected, SIGNAL(clicked()), this, \
SLOT(slotUpdateSelectedClicked())); connect(btnUpdateAll, SIGNAL(clicked()), this, \
SLOT(slotUpdateAllClicked()));
@@ -162,7 +159,7 @@ KEquityPriceUpdateDlg::KEquityPriceUpdateDlg(QWidget *parent, \
const QString& sec }
// Hide OK button until we have received the first update
- btnOK->setEnabled(false);
+ buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
slotUpdateSelection();
@@ -525,7 +522,7 @@ void KEquityPriceUpdateDlg::slotReceivedQuote(const QString& _id, \
const QString& item->setText(DATE_COL, date.toString(Qt::ISODate));
logStatusMessage(i18n("Price for %1 updated (id %2)", _symbol, _id));
// make sure to make OK button available
- btnOK->setEnabled(true);
+ buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
} else {
logErrorMessage(i18n("Received an invalid price for %1, unable to update.", \
_symbol)); }
diff --git a/kmymoney/dialogs/kequitypriceupdatedlgdecl.ui \
b/kmymoney/dialogs/kequitypriceupdatedlgdecl.ui index 5cb0559..c594124 100644
--- a/kmymoney/dialogs/kequitypriceupdatedlgdecl.ui
+++ b/kmymoney/dialogs/kequitypriceupdatedlgdecl.ui
@@ -113,47 +113,11 @@
<widget class="QProgressBar" name="prgOnlineProgress"/>
</item>
<item>
- <layout class="QHBoxLayout">
- <item>
- <spacer name="spacer3">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>91</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="btnOK">
- <property name="text">
- <string>&OK</string>
- </property>
- <property name="default">
- <bool>true</bool>
- </property>
- <property name="stdItem" stdset="0">
- <number>1</number>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="btnCancel">
- <property name="text">
- <string>&Cancel</string>
- </property>
- <property name="stdItem" stdset="0">
- <number>2</number>
- </property>
- </widget>
- </item>
- </layout>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
</item>
</layout>
</widget>
diff --git a/kmymoney/dialogs/kimportdlg.cpp b/kmymoney/dialogs/kimportdlg.cpp
index 60eb07d..8238c47 100644
--- a/kmymoney/dialogs/kimportdlg.cpp
+++ b/kmymoney/dialogs/kimportdlg.cpp
@@ -37,7 +37,6 @@
#include <kiconloader.h>
#include <kconfiggroup.h>
#include <KGuiItem>
-#include <KStandardGuiItem>
#include <KLocalizedString>
// ----------------------------------------------------------------------------
@@ -59,13 +58,11 @@ KImportDlg::KImportDlg(QWidget *parent)
loadProfiles(true);
// load button icons
- KGuiItem::assign(m_qbuttonCancel, KStandardGuiItem::cancel());
-
KGuiItem okButtenItem(i18n("&Import"),
QIcon::fromTheme("document-import"),
i18n("Start operation"),
i18n("Use this to start the import operation"));
- KGuiItem::assign(m_qbuttonOk, okButtenItem);
+ KGuiItem::assign(m_buttonBox->button(QDialogButtonBox::Ok), okButtenItem);
KGuiItem browseButtenItem(i18n("&Browse..."),
QIcon::fromTheme("document-open"),
@@ -81,8 +78,8 @@ KImportDlg::KImportDlg(QWidget *parent)
// connect the buttons to their functionality
connect(m_qbuttonBrowse, SIGNAL(clicked()), this, SLOT(slotBrowse()));
- connect(m_qbuttonOk, SIGNAL(clicked()), this, SLOT(slotOkClicked()));
- connect(m_qbuttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
+ connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(slotOkClicked()));
+ connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(m_profileEditorButton, SIGNAL(clicked()), this, SLOT(slotNewProfile()));
// connect the change signals to the check slot and perform initial check
@@ -145,11 +142,11 @@ void KImportDlg::slotFileTextChanged(const QString& text)
#if 0
if (!text.isEmpty() && KIO::NetAccess::exists(file(), KIO::NetAccess::SourceSide, \
KMyMoneyUtils::mainWindow())) { // m_qcomboboxDateFormat->setEnabled(true);
- m_qbuttonOk->setEnabled(true);
+ m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
m_qlineeditFile->setText(text);
} else {
// m_qcomboboxDateFormat->setEnabled(false);
- m_qbuttonOk->setEnabled(false);
+ m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
}
#endif
}
diff --git a/kmymoney/dialogs/kimportdlgdecl.ui b/kmymoney/dialogs/kimportdlgdecl.ui
index 293d71e..b5fc40d 100644
--- a/kmymoney/dialogs/kimportdlgdecl.ui
+++ b/kmymoney/dialogs/kimportdlgdecl.ui
@@ -163,57 +163,17 @@
</widget>
</item>
<item>
- <layout class="QHBoxLayout">
- <property name="spacing">
- <number>6</number>
+ <widget class="QDialogButtonBox" name="m_buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
- <property name="margin">
- <number>0</number>
- </property>
- <item>
- <spacer name="Spacer1">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>411</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="m_qbuttonOk">
- <property name="text">
- <string>Import</string>
- </property>
- <property name="autoDefault">
- <bool>true</bool>
- </property>
- <property name="default">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="m_qbuttonCancel">
- <property name="text">
- <string>Cancel</string>
- </property>
- <property name="autoDefault">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
+ </widget>
</item>
</layout>
+ <zorder>m_optionGroupBox</zorder>
<zorder>qLabel1</zorder>
<zorder>Line1</zorder>
+ <zorder>m_buttonBox</zorder>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
diff --git a/kmymoney/dialogs/ktagreassigndlg.cpp \
b/kmymoney/dialogs/ktagreassigndlg.cpp index 19a1d9b..9efaae3 100644
--- a/kmymoney/dialogs/ktagreassigndlg.cpp
+++ b/kmymoney/dialogs/ktagreassigndlg.cpp
@@ -25,11 +25,8 @@
// ----------------------------------------------------------------------------
// KDE Includes
-#include <kstandardguiitem.h>
#include <kmessagebox.h>
#include <kguiutils.h>
-#include <KGuiItem>
-#include <KStandardGuiItem>
#include <KLocalizedString>
// ----------------------------------------------------------------------------
@@ -40,11 +37,9 @@
KTagReassignDlg::KTagReassignDlg(QWidget* parent) :
KTagReassignDlgDecl(parent)
{
- KGuiItem::assign(buttonOk, KStandardGuiItem::ok());
- KGuiItem::assign(buttonCancel, KStandardGuiItem::cancel());
kMandatoryFieldGroup* mandatory = new kMandatoryFieldGroup(this);
mandatory->add(tagCombo);
- mandatory->setOkButton(buttonOk);
+ mandatory->setOkButton(buttonBox->button(QDialogButtonBox::Ok));
}
KTagReassignDlg::~KTagReassignDlg()
@@ -70,7 +65,7 @@ QString KTagReassignDlg::show(const QList<MyMoneyTag>& tagslist)
void KTagReassignDlg::accept()
{
// force update of tagCombo
- buttonOk->setFocus();
+ buttonBox->button(QDialogButtonBox::Ok)->setFocus();
if (tagCombo->selectedItem().isEmpty()) {
KMessageBox::information(this, i18n("This dialog does not allow new tags to be \
created. Please pick a tag from the list."), i18n("Tag creation"));
diff --git a/kmymoney/dialogs/ktagreassigndlgdecl.ui \
b/kmymoney/dialogs/ktagreassigndlgdecl.ui index ac33ae9..4aa75cc 100644
--- a/kmymoney/dialogs/ktagreassigndlgdecl.ui
+++ b/kmymoney/dialogs/ktagreassigndlgdecl.ui
@@ -95,47 +95,11 @@
</widget>
</item>
<item>
- <layout class="QHBoxLayout">
- <item>
- <spacer name="Horizontal Spacing2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>305</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="buttonOk">
- <property name="text">
- <string>OK</string>
- </property>
- <property name="autoDefault">
- <bool>true</bool>
- </property>
- <property name="default">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="buttonCancel">
- <property name="text">
- <string>Cancel</string>
- </property>
- <property name="autoDefault">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
</item>
</layout>
</widget>
@@ -151,34 +115,34 @@
<resources/>
<connections>
<connection>
- <sender>buttonOk</sender>
- <signal>clicked()</signal>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
<receiver>KTagReassignDlgDecl</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
- <x>20</x>
- <y>20</y>
+ <x>313</x>
+ <y>286</y>
</hint>
<hint type="destinationlabel">
- <x>20</x>
- <y>20</y>
+ <x>76</x>
+ <y>308</y>
</hint>
</hints>
</connection>
<connection>
- <sender>buttonCancel</sender>
- <signal>clicked()</signal>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
<receiver>KTagReassignDlgDecl</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
- <x>20</x>
- <y>20</y>
+ <x>462</x>
+ <y>291</y>
</hint>
<hint type="destinationlabel">
- <x>20</x>
- <y>20</y>
+ <x>392</x>
+ <y>308</y>
</hint>
</hints>
</connection>
diff --git a/kmymoney/plugins/ofximport/dialogs/kofxdirectconnectdlgdecl.ui \
b/kmymoney/plugins/ofximport/dialogs/kofxdirectconnectdlgdecl.ui index \
bcd97b2..25e03ab 100644
--- a/kmymoney/plugins/ofximport/dialogs/kofxdirectconnectdlgdecl.ui
+++ b/kmymoney/plugins/ofximport/dialogs/kofxdirectconnectdlgdecl.ui
@@ -31,53 +31,14 @@
<widget class="QProgressBar" name="kProgress1"/>
</item>
<item>
- <layout class="QHBoxLayout">
- <item>
- <spacer name="spacer4">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>51</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="buttonCancel">
- <property name="text">
- <string>Cancel</string>
- </property>
- <property name="shortcut">
- <string/>
- </property>
- <property name="autoDefault">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="spacer3">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>61</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel</set>
+ </property>
+ <property name="centerButtons">
+ <bool>true</bool>
+ </property>
+ </widget>
</item>
</layout>
</widget>
@@ -85,18 +46,18 @@
<resources/>
<connections>
<connection>
- <sender>buttonCancel</sender>
- <signal>clicked()</signal>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
<receiver>KOfxDirectConnectDlgDecl</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
- <x>20</x>
- <y>20</y>
+ <x>175</x>
+ <y>92</y>
</hint>
<hint type="destinationlabel">
- <x>20</x>
- <y>20</y>
+ <x>101</x>
+ <y>103</y>
</hint>
</hints>
</connection>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic