From 75c37aa0292f8451286d097bf586e4da7567a6c8 Mon Sep 17 00:00:00 2001 From: cfdev Date: Wed, 7 Nov 2012 21:26:09 +0000 Subject: [PATCH] Title block properties: added a "Set to current date" button. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@1959 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/titleblockpropertieswidget.cpp | 19 ++++++++++++++++++- sources/titleblockpropertieswidget.h | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/sources/titleblockpropertieswidget.cpp b/sources/titleblockpropertieswidget.cpp index b01ea3bca..33ea77a06 100644 --- a/sources/titleblockpropertieswidget.cpp +++ b/sources/titleblockpropertieswidget.cpp @@ -27,7 +27,7 @@ */ TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(const TitleBlockProperties &titleblock, bool current, QWidget *parent) : QWidget(parent), - display_current_date(false), + display_current_date(false), tbt_collection_(0) { initWidgets(titleblock); @@ -297,6 +297,14 @@ void TitleBlockPropertiesWidget::initWidgets(const TitleBlockProperties &titlebl connect(titleblock_fixed_date, SIGNAL(toggled(bool)), titleblock_date, SLOT(setEnabled(bool))); titleblock_date -> setCalendarPopup(true); + titleblock_dateNow = new QPushButton (this); + titleblock_dateNow -> setEnabled(titleblock_fixed_date -> isChecked()); + QIcon icon_dateNow(QET::Icons::ArrowLeft); + titleblock_dateNow->setIcon(icon_dateNow); + titleblock_dateNow->setIconSize(QSize(16, 16)); + connect(titleblock_fixed_date, SIGNAL(toggled(bool)), titleblock_dateNow, SLOT(setEnabled(bool))); + connect(titleblock_dateNow, SIGNAL(clicked()), this, SLOT(setDateNow())); + // we add a bunch of tooltips for users to know how they can put these // values into their title block templates QString variable_tooltip = tr("Disponible en tant que %1 pour les mod\350les de cartouches."); @@ -308,6 +316,7 @@ void TitleBlockPropertiesWidget::initWidgets(const TitleBlockProperties &titlebl titleblock_current_date -> setToolTip(date_variable_tooltip); titleblock_fixed_date -> setToolTip(date_variable_tooltip); titleblock_date -> setToolTip(date_variable_tooltip); + titleblock_dateNow -> setToolTip(tr("Appliquer la date actuelle")); folio_tip -> setToolTip(tr("%id et %total sont disponibles en tant que %{folio-id} et %{folio-total} (respectivement) pour les mod\350les de cartouches.")); // widgets for users to enter their own name/value pairs @@ -340,6 +349,7 @@ void TitleBlockPropertiesWidget::initLayouts() { layout_date -> addWidget(titleblock_current_date, 1, 0); layout_date -> addWidget(titleblock_fixed_date, 2, 0); layout_date -> addWidget(titleblock_date, 2, 1); + layout_date -> addWidget(titleblock_dateNow, 2, 2); layout_date -> setColumnStretch(0, 1); layout_date -> setColumnStretch(1, 500); @@ -398,3 +408,10 @@ void TitleBlockPropertiesWidget::initLayouts() { this_layout -> addWidget(titleblock_infos); setLayout(this_layout); } + +/** + Set the current Date to the combo Date + */ +void TitleBlockPropertiesWidget::setDateNow(){ + titleblock_date->setDate( QDate::currentDate() ); +} diff --git a/sources/titleblockpropertieswidget.h b/sources/titleblockpropertieswidget.h index 911e26d03..c83dd677b 100644 --- a/sources/titleblockpropertieswidget.h +++ b/sources/titleblockpropertieswidget.h @@ -54,6 +54,7 @@ class TitleBlockPropertiesWidget : public QWidget { void updateTemplateList(); void editCurrentTitleBlockTemplate(); void duplicateCurrentTitleBlockTemplate(); + void setDateNow(); // private methods private: @@ -75,6 +76,7 @@ class TitleBlockPropertiesWidget : public QWidget { QLineEdit *titleblock_title; QLineEdit *titleblock_author; QDateEdit *titleblock_date; + QPushButton *titleblock_dateNow; QLineEdit *titleblock_filename; QLineEdit *titleblock_folio; QLabel *folio_tip;