diff options
author | Martin Měřinský <mermar@centrum.cz> | 2017-03-13 11:34:42 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-03-13 10:25:51 -0700 |
commit | 2b5a2352eadfe992319910495cc11a0a83c4a6cd (patch) | |
tree | bcb6bfab5e4e49462a77619b93d0d08bc8928ba7 | |
parent | 4db42808f6951953766a5ff6f2cb042a873dcb30 (diff) | |
download | subsurface-2b5a2352eadfe992319910495cc11a0a83c4a6cd.tar.gz |
Remove unused DateWidget with its icon.
-rw-r--r-- | desktop-widgets/simplewidgets.cpp | 122 | ||||
-rw-r--r-- | desktop-widgets/simplewidgets.h | 25 | ||||
-rw-r--r-- | icons/calendarbg.png | bin | 1294 -> 0 bytes | |||
-rw-r--r-- | subsurface.qrc | 1 |
4 files changed, 0 insertions, 148 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) diff --git a/desktop-widgets/simplewidgets.h b/desktop-widgets/simplewidgets.h index 2fc858cd3..ac98414a0 100644 --- a/desktop-widgets/simplewidgets.h +++ b/desktop-widgets/simplewidgets.h @@ -131,31 +131,6 @@ private: class QCalendarWidget; -class DateWidget : public QWidget { - Q_OBJECT -public: - DateWidget(QWidget *parent = 0); - QDate date() const; -public -slots: - void setDate(const QDate &date); - -protected: - void paintEvent(QPaintEvent *event); - void mousePressEvent(QMouseEvent *event); - void focusInEvent(QFocusEvent *); - void focusOutEvent(QFocusEvent *); - void keyPressEvent(QKeyEvent *); - void changeEvent(QEvent *); - bool eventFilter(QObject *, QEvent *); -signals: - void dateChanged(const QDate &date); - -private: - QDate mDate; - QCalendarWidget *calendarWidget; -}; - class DiveComponentSelection : public QDialog { Q_OBJECT public: diff --git a/icons/calendarbg.png b/icons/calendarbg.png Binary files differdeleted file mode 100644 index 4e968f7de..000000000 --- a/icons/calendarbg.png +++ /dev/null diff --git a/subsurface.qrc b/subsurface.qrc index 4cb5e3713..7167af051 100644 --- a/subsurface.qrc +++ b/subsurface.qrc @@ -60,7 +60,6 @@ <file alias="icon_ead">icons/ead.png</file> <file alias="icon_HR">icons/icon-HR.png</file> <file alias="icon_tissue">icons/heatmap.png</file> - <file alias="calendar">icons/calendarbg.png</file> <file alias="pictures">icons/pictures.png</file> <file>icons/subsurface/index.theme</file> <file>icons/subsurface/32x32/actions/go-down.png</file> |