SymbolChooser: use Qt's OK|Cancel buttons
- use the standard Qt buttons for the OK/Cancel action (QDialogButtonBox) advantage: better layout and cleaner than 2 own and separate buttons
This commit is contained in:
@@ -48,10 +48,6 @@ SymbolChooser::SymbolChooser(QWidget *parent,
|
||||
m_source(source)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->pbOK, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onOKClicked(bool)));
|
||||
connect(ui->pbCancel, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onCancelClicked(bool)));
|
||||
connect(ui->fcSymbolDir, SIGNAL(fileNameSelected(const QString&)),
|
||||
this, SLOT(onDirectorySelected(const QString&)));
|
||||
connect(ui->lwSymbols, SIGNAL(itemClicked(QListWidgetItem*)), //double click?
|
||||
@@ -85,10 +81,9 @@ void SymbolChooser::setUiPrimary()
|
||||
ui->lwSymbols->setAcceptDrops(false);
|
||||
}
|
||||
|
||||
void SymbolChooser::onOKClicked(bool b)
|
||||
void SymbolChooser::onOKClicked()
|
||||
{
|
||||
Q_UNUSED(b);
|
||||
// Base::Console().Message("SC::OnOKClicked()\n");
|
||||
QDialog::accept();
|
||||
QListWidgetItem* sourceItem = ui->lwSymbols->currentItem();
|
||||
if (!sourceItem)
|
||||
return;
|
||||
@@ -98,15 +93,11 @@ void SymbolChooser::onOKClicked(bool b)
|
||||
QString::fromUtf8(".svg");
|
||||
|
||||
Q_EMIT symbolSelected(m_symbolPath, m_source);
|
||||
// Base::Console().Message("SC::onOKClicked - symbol; %s\n", qPrintable(m_symbolPath));
|
||||
accept();
|
||||
}
|
||||
|
||||
void SymbolChooser::onCancelClicked(bool b)
|
||||
void SymbolChooser::onCancelClicked()
|
||||
{
|
||||
Q_UNUSED(b);
|
||||
// Base::Console().Message("SC::OnCancelCicked()\n");
|
||||
reject();
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
void SymbolChooser::onItemClicked(QListWidgetItem* item)
|
||||
|
||||
@@ -40,8 +40,8 @@ public:
|
||||
QString source = QString());
|
||||
|
||||
public Q_SLOTS:
|
||||
void onOKClicked(bool b);
|
||||
void onCancelClicked(bool b);
|
||||
void onOKClicked();
|
||||
void onCancelClicked();
|
||||
void onItemClicked(QListWidgetItem* item);
|
||||
void onDirectorySelected(const QString& newDir);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SymbolChooser</class>
|
||||
<widget class="QDialog" name="SymbolChooser">
|
||||
<class>TechDrawGui::SymbolChooser</class>
|
||||
<widget class="QDialog" name="TechDrawGui::SymbolChooser">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::WindowModal</enum>
|
||||
</property>
|
||||
@@ -14,7 +14,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>SymbolChooser</string>
|
||||
<string>Symbol Chooser</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
@@ -28,47 +28,17 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pbCancel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pbOK">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QDialogButtonBox" name="bbButtons">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
@@ -101,5 +71,38 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>bbButtons</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>TechDrawGui::SymbolChooser</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>179</x>
|
||||
<y>228</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>179</x>
|
||||
<y>139</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>bbButtons</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>TechDrawGui::SymbolChooser</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>179</x>
|
||||
<y>228</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>179</x>
|
||||
<y>139</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user