[PATCH 3 of 3] Merged
Wald Commits
scm-commit at wald.intevation.org
Wed Jul 2 11:57:53 CEST 2014
# HG changeset patch
# User Sascha Wilde <wilde at intevation.de>
# Date 1404295052 -7200
# Node ID 6bb3018b966d163ad3f05ee6d39623a848362595
# Parent ff2efc1cb8fa489f4ebe30a06e7bd595255e2eaf
# Parent 2c63bb63de769793f721708f142924d2d178ebdd
Merged
diff -r ff2efc1cb8fa -r 6bb3018b966d ui/certificateitemwidget.cpp
--- a/ui/certificateitemwidget.cpp Wed Jul 02 11:56:56 2014 +0200
+++ b/ui/certificateitemwidget.cpp Wed Jul 02 11:57:32 2014 +0200
@@ -9,6 +9,7 @@
#include <QHBoxLayout>
#include <QDebug>
+#include <QStyleFactory>
CertificateItemWidget::CertificateItemWidget(QWidget *parent,
const Certificate &cert,
@@ -26,18 +27,32 @@
setupGUI();
}
+
+/* We use the label as data to hide it in the normal dropdown menu and only
+ * show it when the popup is shown.*/
+
void CertificateItemWidget::setupGUI()
{
mLabel = new QLabel(mCertificate.subjectCN());
- mComboBox = new QComboBox;
+ mComboBox = new IconOnlyTextPopupBox;
+ QStyle *fusionStyle = QStyleFactory::create("Fusion");
+ if (!fusionStyle) {
+ qDebug() << "Failed to create fusion style";
+ } else {
+ mComboBox->setStyle(fusionStyle);
+ }
+
mComboBox->setFixedWidth(46);
+
+ mLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ mComboBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
connect(mComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(currentStateChanged(int)));
QHBoxLayout *layout = new QHBoxLayout;
if (mCertificate.isInstallCert()) {
- mComboBox->addItem(QIcon(":/img/security-high.png"), mInstallLabel, QVariant("true"));
- mComboBox->addItem(QIcon(":/img/security-low.png"), mRemoveLabel, QVariant("false"));
+ mComboBox->addItem(QIcon(":/img/security-high.png"), QString(), mInstallLabel);
+ mComboBox->addItem(QIcon(":/img/security-low.png"), QString(), mRemoveLabel);
if (mState)
mComboBox->setCurrentIndex(0);
else {
@@ -72,7 +87,14 @@
if (!mEditable) {
return true;
}
- return mComboBox->currentData().toBool();
+
+ const QString currentString = mComboBox->currentData().toString();
+
+ if (!mCertificate.isInstallCert()) {
+ return currentString == tr("uninstall");
+ }
+
+ return currentString == mInstallLabel;
}
void CertificateItemWidget::setState(bool state)
@@ -100,3 +122,17 @@
bool state = mComboBox->currentData().toBool();
emit stateChanged(state, mCertificate);
}
+
+void IconOnlyTextPopupBox::showPopup() {
+ for (int i = 0; i < count(); i++) {
+ setItemText(i, itemData(i).toString());
+ }
+ QComboBox::showPopup();
+}
+
+void IconOnlyTextPopupBox::hidePopup() {
+ for (int i = 0; i < count(); i++) {
+ setItemText(i, QString());
+ }
+ QComboBox::hidePopup();
+}
diff -r ff2efc1cb8fa -r 6bb3018b966d ui/certificateitemwidget.h
--- a/ui/certificateitemwidget.h Wed Jul 02 11:56:56 2014 +0200
+++ b/ui/certificateitemwidget.h Wed Jul 02 11:57:32 2014 +0200
@@ -17,6 +17,17 @@
#include <QComboBox>
#include "certificate.h"
+/** @brief A combo box that shows the text only in the popup
+ *
+ * The text shown is the data set as Qt::UserRole
+ */
+class IconOnlyTextPopupBox : public QComboBox
+{
+protected:
+ virtual void showPopup();
+ virtual void hidePopup();
+};
+
class CertificateItemWidget : public QWidget
{
@@ -41,7 +52,7 @@
bool mState;
bool mEditable;
QLabel *mLabel;
- QComboBox *mComboBox;
+ IconOnlyTextPopupBox *mComboBox;
QString mInstallLabel;
QString mRemoveLabel;
diff -r ff2efc1cb8fa -r 6bb3018b966d ui/mainwindow.cpp
--- a/ui/mainwindow.cpp Wed Jul 02 11:56:56 2014 +0200
+++ b/ui/mainwindow.cpp Wed Jul 02 11:57:32 2014 +0200
@@ -548,11 +548,11 @@
updatesHeaderTextLayout->addSpacing(10);
updatesHeaderTextLayout->addWidget(updatesTip);
- QPushButton *searchUpdates = new QPushButton(tr("Check for updates"));
+ QPushButton *searchUpdates = new QPushButton(" " + tr("Check for updates"));
searchUpdates->setIcon(QIcon(":/img/edit-find.png"));
- mQuitButton = new QPushButton(tr("Quit without saving"));
+ mQuitButton = new QPushButton(" " + tr("Quit without saving"));
mQuitButton->setIcon(QIcon(":/img/application-exit.png"));
- QPushButton *installButton = new QPushButton(tr("Apply changes"));
+ QPushButton *installButton = new QPushButton(" " + tr("Apply changes"));
#ifdef Q_OS_WIN
if (is_admin()) {
QIcon uacShield = QApplication::style()->standardIcon(QStyle::SP_VistaShield);
@@ -625,6 +625,8 @@
SIGNAL(clicked()),
this,
SLOT(toggleUpdatesManual()));
+ mUpdatesDetailsManual->hide();
+ mUpdatesManualCertificates->hide();
updatesManualLayout->addWidget(mUpdatesManualCertificates);
updatesManualLayout->addWidget(mUpdatesDetailsManual);
updatesManualLayout->insertStretch(2, 10);
@@ -815,13 +817,21 @@
int totalCount = mUpdatesRemove->selectedCertCount() +
mUpdatesNew->selectedCertCount() + mUpdatesManual->certificates().size();
+ if (mUpdatesManual->certificates().size()) {
+ mUpdatesDetailsManual->show();
+ mUpdatesManualCertificates->show();
+ } else {
+ mUpdatesDetailsManual->hide();
+ mUpdatesManualCertificates->hide();
+ }
+
if (!totalCount) {
/* No changes */
- mQuitButton->setText(tr("Quit"));
+ mQuitButton->setText(" " + tr("Quit"));
mUpdatesHeader->setText("<h2>" + tr("Certificates unchanged") +
"</h2>");
} else {
- mQuitButton->setText(tr("Quit without saving"));
+ mQuitButton->setText(" " + tr("Quit without saving"));
mUpdatesHeader->setText("<h2>" + tr("Changes (%1)")
.arg(totalCount) +
"</h2>");
More information about the Trustbridge-commits
mailing list