summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/simplewidgets.cpp
diff options
context:
space:
mode:
authorGravatar Martin Měřinský <mermar@centrum.cz>2017-03-13 11:34:42 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-03-13 10:25:51 -0700
commit2b5a2352eadfe992319910495cc11a0a83c4a6cd (patch)
treebcb6bfab5e4e49462a77619b93d0d08bc8928ba7 /desktop-widgets/simplewidgets.cpp
parent4db42808f6951953766a5ff6f2cb042a873dcb30 (diff)
downloadsubsurface-2b5a2352eadfe992319910495cc11a0a83c4a6cd.tar.gz
Remove unused DateWidget with its icon.
Diffstat (limited to 'desktop-widgets/simplewidgets.cpp')
-rw-r--r--desktop-widgets/simplewidgets.cpp122
1 files changed, 0 insertions, 122 deletions
diff --git a/desktop-widgets/simplewidgets.cpp b/desktop-widgets/simplewidgets.cpp
index de00cc19f..049ce6549 100644
--- a/desktop-widgets/simplewidgets.cpp
+++ b/desktop-widgets/simplewidgets.cpp
@@ -431,128 +431,6 @@ bool isGnome3Session()
#endif
}
-DateWidget::DateWidget(QWidget *parent) : QWidget(parent),
- calendarWidget(new QCalendarWidget())
-{
- setDate(QDate::currentDate());
- setMinimumSize(QSize(80, 64));
- setFocusPolicy(Qt::StrongFocus);
- calendarWidget->setWindowFlags(Qt::FramelessWindowHint);
- calendarWidget->setFirstDayOfWeek(getLocale().firstDayOfWeek());
- calendarWidget->setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader);
-
- connect(calendarWidget, SIGNAL(activated(QDate)), calendarWidget, SLOT(hide()));
- connect(calendarWidget, SIGNAL(clicked(QDate)), calendarWidget, SLOT(hide()));
- connect(calendarWidget, SIGNAL(activated(QDate)), this, SLOT(setDate(QDate)));
- connect(calendarWidget, SIGNAL(clicked(QDate)), this, SLOT(setDate(QDate)));
- calendarWidget->installEventFilter(this);
-}
-
-bool DateWidget::eventFilter(QObject *object, QEvent *event)
-{
- if (event->type() == QEvent::FocusOut) {
- calendarWidget->hide();
- return true;
- }
- if (event->type() == QEvent::KeyPress) {
- QKeyEvent *ev = static_cast<QKeyEvent *>(event);
- if (ev->key() == Qt::Key_Escape) {
- calendarWidget->hide();
- }
- }
- return QObject::eventFilter(object, event);
-}
-
-
-void DateWidget::setDate(const QDate &date)
-{
- mDate = date;
- update();
- emit dateChanged(mDate);
-}
-
-QDate DateWidget::date() const
-{
- return mDate;
-}
-
-void DateWidget::changeEvent(QEvent *event)
-{
- if (event->type() == QEvent::EnabledChange) {
- update();
- }
-}
-
-#define DATEWIDGETWIDTH 80
-void DateWidget::paintEvent(QPaintEvent *event)
-{
- Q_UNUSED(event)
- static QPixmap pix = QPixmap(":/calendar").scaled(DATEWIDGETWIDTH, 64);
-
- QPainter painter(this);
-
- painter.drawPixmap(QPoint(0, 0), isEnabled() ? pix : QPixmap::fromImage(grayImage(pix.toImage())));
-
- QString month = mDate.toString("MMM");
- QString year = mDate.toString("yyyy");
- QString day = mDate.toString("dd");
-
- QFont font = QFont("monospace", 10);
- QFontMetrics metrics = QFontMetrics(font);
- painter.setFont(font);
- painter.setPen(QPen(QBrush(Qt::white), 0));
- painter.setBrush(QBrush(Qt::white));
- painter.drawText(QPoint(6, metrics.height() + 1), month);
- painter.drawText(QPoint(DATEWIDGETWIDTH - metrics.width(year) - 6, metrics.height() + 1), year);
-
- font.setPointSize(14);
- metrics = QFontMetrics(font);
- painter.setPen(QPen(QBrush(Qt::black), 0));
- painter.setBrush(Qt::black);
- painter.setFont(font);
- painter.drawText(QPoint(DATEWIDGETWIDTH / 2 - metrics.width(day) / 2, 45), day);
-
- if (hasFocus()) {
- QStyleOptionFocusRect option;
- option.initFrom(this);
- option.backgroundColor = palette().color(QPalette::Background);
- style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter, this);
- }
-}
-
-void DateWidget::mousePressEvent(QMouseEvent *event)
-{
- calendarWidget->setSelectedDate(mDate);
- calendarWidget->move(event->globalPos());
- calendarWidget->show();
- calendarWidget->raise();
- calendarWidget->setFocus();
-}
-
-void DateWidget::focusInEvent(QFocusEvent *event)
-{
- setFocus();
- QWidget::focusInEvent(event);
-}
-
-void DateWidget::focusOutEvent(QFocusEvent *event)
-{
- QWidget::focusOutEvent(event);
-}
-
-void DateWidget::keyPressEvent(QKeyEvent *event)
-{
- if (event->key() == Qt::Key_Return ||
- event->key() == Qt::Key_Enter ||
- event->key() == Qt::Key_Space) {
- calendarWidget->move(mapToGlobal(QPoint(0, 64)));
- calendarWidget->show();
- event->setAccepted(true);
- } else {
- QWidget::keyPressEvent(event);
- }
-}
-
#define COMPONENT_FROM_UI(_component) what->_component = ui._component->isChecked()
#define UI_FROM_COMPONENT(_component) ui._component->setChecked(what->_component)