[PATCH 5 of 5] Change button text when toggling details and select the first list item
Wald Commits
scm-commit at wald.intevation.org
Wed Jun 25 14:56:46 CEST 2014
# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1403700979 -7200
# Branch trustbridge-refactor
# Node ID 39f03316f675497bbd3d317ca863bad8b55fe4b2
# Parent f65503c1833bb17a4d86fe3387c2de2bf4fdfb40
Change button text when toggling details and select the first list item.
diff -r f65503c1833b -r 39f03316f675 ui/certificatelistwidget.cpp
--- a/ui/certificatelistwidget.cpp Wed Jun 25 14:54:45 2014 +0200
+++ b/ui/certificatelistwidget.cpp Wed Jun 25 14:56:19 2014 +0200
@@ -235,3 +235,11 @@
}
return false;
}
+
+void CertificateListWidget::setSelected(int index)
+{
+ mCertificateList->setFocus();
+ if (mCertificateList->count() > 0) {
+ mCertificateList->item(0)->setSelected(true);
+ }
+}
diff -r f65503c1833b -r 39f03316f675 ui/certificatelistwidget.h
--- a/ui/certificatelistwidget.h Wed Jun 25 14:54:45 2014 +0200
+++ b/ui/certificatelistwidget.h Wed Jun 25 14:56:19 2014 +0200
@@ -38,6 +38,7 @@
QList<Certificate> certificateList();
int selectedCertCount();
bool contains(const Certificate &cert);
+ void setSelected(int index);
private:
void setupGUI();
diff -r f65503c1833b -r 39f03316f675 ui/mainwindow.cpp
--- a/ui/mainwindow.cpp Wed Jun 25 14:54:45 2014 +0200
+++ b/ui/mainwindow.cpp Wed Jun 25 14:56:19 2014 +0200
@@ -998,44 +998,42 @@
void MainWindow::toggleUpdatesNew() {
if (!mUpdatesNew->isVisible()) {
+ mUpdatesDetailsNew->setText(tr("Hide Details"));
mUpdatesNew->show();
- if (mUpdatesNewSize == 0) {
- mUpdatesNewSize = mUpdatesNew->height();
- }
- mUpdatesWidget->resize(old.width(), old.height() + mUpdatesNewSize);
+ mUpdatesNew->setSelected(0);
}
else {
+ mUpdatesNew->hide();
+ mUpdatesDetailsNew->setText(tr("Show Details"));
+ QSize old = mUpdatesWidget->size();
mUpdatesWidget->resize(old.width(), old.height() - mUpdatesNew->height());
- mUpdatesNew->hide();
}
}
void MainWindow::toggleUpdatesRemove() {
- QSize old = mUpdatesWidget->size();
if (!mUpdatesRemove->isVisible()) {
+ mUpdatesDetailsRemove->setText(tr("Hide Details"));
mUpdatesRemove->show();
- if (mUpdatesRemoveSize == 0) {
- mUpdatesRemoveSize = mUpdatesRemove->height();
- }
- mUpdatesWidget->resize(old.width(), old.height() + mUpdatesRemoveSize);
+ mUpdatesRemove->setSelected(0);
}
else {
+ mUpdatesRemove->hide();
+ mUpdatesDetailsRemove->setText(tr("Show Details"));
+ QSize old = mUpdatesWidget->size();
mUpdatesWidget->resize(old.width(), old.height() - mUpdatesRemove->height());
- mUpdatesRemove->hide();
}
}
void MainWindow::toggleUpdatesManual() {
- QSize old = mUpdatesWidget->size();
if (!mUpdatesManual->isVisible()) {
+ mUpdatesDetailsManual->setText(tr("Hide Details"));
mUpdatesManual->show();
- if (mUpdatesManualSize == 0) {
- mUpdatesManualSize = mUpdatesManual->height();
- }
- mUpdatesWidget->resize(old.width(), old.height() + mUpdatesManualSize);
+ mUpdatesManual->setSelected(0);
}
else {
+ mUpdatesDetailsManual->setText(tr("Show Details"));
+ mUpdatesManual->hide();
+ QSize old = mUpdatesWidget->size();
mUpdatesWidget->resize(old.width(), old.height() - mUpdatesManual->height());
- mUpdatesManual->hide();
}
}
More information about the Trustbridge-commits
mailing list