mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 20:23:25 +00:00
Added a Partly Functional Date Picker widget.
This widget shows a date in a better way that it was done in the old widget, much more elegantly. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
867d9f1391
commit
a08d4ec790
3 changed files with 62 additions and 0 deletions
|
@ -298,3 +298,49 @@ bool isGnome3Session()
|
|||
return !p_stdout.isEmpty();
|
||||
#endif
|
||||
}
|
||||
|
||||
DateWidget::DateWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
setDate(QDate::currentDate());
|
||||
}
|
||||
|
||||
void DateWidget::setDate(const QDate& date)
|
||||
{
|
||||
mDate = date;
|
||||
update();
|
||||
}
|
||||
|
||||
QDate DateWidget::date() const
|
||||
{
|
||||
return mDate;
|
||||
}
|
||||
|
||||
void DateWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
static QPixmap pix = QPixmap(":/calendar").scaled(64,64);
|
||||
static int pixRedTag = 18; /* calculated using a ruler. */
|
||||
|
||||
QPainter painter(this);
|
||||
painter.drawPixmap(QPoint(0,0), pix);
|
||||
|
||||
QString month = mDate.toString("MMM");
|
||||
QString year = mDate.toString("yyyy");
|
||||
QString day = mDate.toString("dd");
|
||||
|
||||
|
||||
QFont font = QFont("monospace", 5);
|
||||
QFontMetrics metrics = QFontMetrics(font);
|
||||
painter.setFont(font);
|
||||
painter.setPen(QPen(QBrush(Qt::white), 0));
|
||||
painter.setBrush(QBrush(Qt::white));
|
||||
painter.drawText(QPoint(4, metrics.height() + 3), month);
|
||||
painter.drawText(QPoint(64 - metrics.width(year) -6, 14), year);
|
||||
|
||||
font.setPointSize(14);
|
||||
metrics = QFontMetrics(font);
|
||||
painter.setPen(QPen(QBrush(Qt::black),0));
|
||||
painter.setBrush(Qt::black);
|
||||
painter.setFont(font);
|
||||
painter.drawText(QPoint(32 - metrics.width(day)/2, 45), day);
|
||||
|
||||
}
|
||||
|
|
|
@ -88,6 +88,21 @@ private:
|
|||
time_t dcImageEpoch;
|
||||
};
|
||||
|
||||
class DateWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DateWidget(QWidget *parent = 0);
|
||||
void setDate(const QDate& date);
|
||||
QDate date() const;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
private:
|
||||
QDate mDate;
|
||||
|
||||
};
|
||||
|
||||
bool isGnome3Session();
|
||||
|
||||
#endif // SIMPLEWIDGETS_H
|
||||
|
|
|
@ -53,5 +53,6 @@
|
|||
<file alias="icon_ceiling_dc">icons/pc.png</file>
|
||||
<file alias="icon_ead">icons/ead.png</file>
|
||||
<file alias="icon_HR">icons/icon-HR.png</file>
|
||||
<file alias="calendar">icons/calendarbg.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
Loading…
Add table
Reference in a new issue