diff options
-rw-r--r-- | Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp | 8 | ||||
-rw-r--r-- | Swift/QtUI/QtVCardWidget/QtVCardGeneralField.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp b/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp index 74d9c59..155bd4f 100644 --- a/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp +++ b/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp @@ -9,18 +9,19 @@ * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #include <Swift/QtUI/QtVCardWidget/QtVCardGeneralField.h> #include <cassert> #include <QHBoxLayout> +#include <QToolTip> namespace Swift { QtVCardGeneralField::QtVCardGeneralField(QWidget* parent, QGridLayout* layout, bool editable, int row, QString label, bool preferrable, bool taggable) : QWidget(parent), editable(editable), preferrable(preferrable), starVisible(false), taggable(taggable), layout(layout), row(row), preferredCheckBox(0), label(0), labelText(label), tagComboBox(0), tagLabel(NULL), closeButton(0) { } QtVCardGeneralField::~QtVCardGeneralField() { @@ -32,18 +33,19 @@ void QtVCardGeneralField::initialize() { preferredCheckBox = new QCheckBox(this); preferredCheckBox->setToolTip(tr("Stars can be used to mark preferred contact details.")); preferredCheckBox->setStyleSheet( "QCheckBox::indicator { width: 18px; height: 18px; }" "QCheckBox::indicator:checked { image: url(:/icons/star-checked.png); }" "QCheckBox::indicator:unchecked { image: url(:/icons/star-unchecked); }" ); layout->addWidget(preferredCheckBox, row, 0, Qt::AlignVCenter); childWidgets << preferredCheckBox; + connect(preferredCheckBox, SIGNAL(stateChanged(int)), SLOT(handlePreferredStarStateChanged(int))); } label = new QLabel(this); label->setText(labelText); layout->addWidget(label, row, 1, Qt::AlignVCenter | Qt::AlignRight); tagLabel = new QLabel(this); tagLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); tagComboBox = new QtTagComboBox(this); @@ -118,18 +120,24 @@ QGridLayout* QtVCardGeneralField::getGridLayout() const { void QtVCardGeneralField::handleCloseButtonClicked() { customCleanup(); foreach(QWidget* widget, childWidgets) { widget->hide(); layout->removeWidget(widget); } deleteField(this); } +void QtVCardGeneralField::handlePreferredStarStateChanged(int state) { + if (state == Qt::Checked) { + QToolTip::showText(QCursor::pos(), tr("Marked as your preferred %1. Click again to undo.").arg(labelText)); + } +} + void QtVCardGeneralField::updatePreferredStarVisibility() { if (preferredCheckBox) { bool showStar = false; if (editable) { if (starVisible) { showStar = true; } else { showStar = preferredCheckBox->isChecked(); diff --git a/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.h b/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.h index 93d326b..4f4cccd 100644 --- a/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.h +++ b/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.h @@ -59,18 +59,19 @@ class QtVCardGeneralField : public QWidget { QtTagComboBox* getTagComboBox() const; QGridLayout* getGridLayout() const; signals: void editableChanged(bool); void deleteField(QtVCardGeneralField*); public slots: void handleCloseButtonClicked(); + void handlePreferredStarStateChanged(int statte); protected: QList<QWidget*> childWidgets; private: void updatePreferredStarVisibility(); private: bool editable; |