Changeset 2b5a235 in subsurface


Ignore:
Timestamp:
Mar 13, 2017, 10:25:51 AM (2 months ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
8834fc0
Parents:
4db4280
git-author:
Martin Měřinský <mermar@…> (03/13/17 03:34:42)
git-committer:
Dirk Hohndel <dirk@…> (03/13/17 10:25:51)
Message:

Remove unused DateWidget? with its icon.

Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • desktop-widgets/simplewidgets.cpp

    rb39b641 r2b5a235  
    430430        return !p_stdout.isEmpty();
    431431#endif
    432 }
    433 
    434 DateWidget::DateWidget(QWidget *parent) : QWidget(parent),
    435         calendarWidget(new QCalendarWidget())
    436 {
    437         setDate(QDate::currentDate());
    438         setMinimumSize(QSize(80, 64));
    439         setFocusPolicy(Qt::StrongFocus);
    440         calendarWidget->setWindowFlags(Qt::FramelessWindowHint);
    441         calendarWidget->setFirstDayOfWeek(getLocale().firstDayOfWeek());
    442         calendarWidget->setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader);
    443 
    444         connect(calendarWidget, SIGNAL(activated(QDate)), calendarWidget, SLOT(hide()));
    445         connect(calendarWidget, SIGNAL(clicked(QDate)), calendarWidget, SLOT(hide()));
    446         connect(calendarWidget, SIGNAL(activated(QDate)), this, SLOT(setDate(QDate)));
    447         connect(calendarWidget, SIGNAL(clicked(QDate)), this, SLOT(setDate(QDate)));
    448         calendarWidget->installEventFilter(this);
    449 }
    450 
    451 bool DateWidget::eventFilter(QObject *object, QEvent *event)
    452 {
    453         if (event->type() == QEvent::FocusOut) {
    454                 calendarWidget->hide();
    455                 return true;
    456         }
    457         if (event->type() == QEvent::KeyPress) {
    458                 QKeyEvent *ev = static_cast<QKeyEvent *>(event);
    459                 if (ev->key() == Qt::Key_Escape) {
    460                         calendarWidget->hide();
    461                 }
    462         }
    463         return QObject::eventFilter(object, event);
    464 }
    465 
    466 
    467 void DateWidget::setDate(const QDate &date)
    468 {
    469         mDate = date;
    470         update();
    471         emit dateChanged(mDate);
    472 }
    473 
    474 QDate DateWidget::date() const
    475 {
    476         return mDate;
    477 }
    478 
    479 void DateWidget::changeEvent(QEvent *event)
    480 {
    481         if (event->type() == QEvent::EnabledChange) {
    482                 update();
    483         }
    484 }
    485 
    486 #define DATEWIDGETWIDTH 80
    487 void DateWidget::paintEvent(QPaintEvent *event)
    488 {
    489         Q_UNUSED(event)
    490         static QPixmap pix = QPixmap(":/calendar").scaled(DATEWIDGETWIDTH, 64);
    491 
    492         QPainter painter(this);
    493 
    494         painter.drawPixmap(QPoint(0, 0), isEnabled() ? pix : QPixmap::fromImage(grayImage(pix.toImage())));
    495 
    496         QString month = mDate.toString("MMM");
    497         QString year = mDate.toString("yyyy");
    498         QString day = mDate.toString("dd");
    499 
    500         QFont font = QFont("monospace", 10);
    501         QFontMetrics metrics = QFontMetrics(font);
    502         painter.setFont(font);
    503         painter.setPen(QPen(QBrush(Qt::white), 0));
    504         painter.setBrush(QBrush(Qt::white));
    505         painter.drawText(QPoint(6, metrics.height() + 1), month);
    506         painter.drawText(QPoint(DATEWIDGETWIDTH - metrics.width(year) - 6, metrics.height() + 1), year);
    507 
    508         font.setPointSize(14);
    509         metrics = QFontMetrics(font);
    510         painter.setPen(QPen(QBrush(Qt::black), 0));
    511         painter.setBrush(Qt::black);
    512         painter.setFont(font);
    513         painter.drawText(QPoint(DATEWIDGETWIDTH / 2 - metrics.width(day) / 2, 45), day);
    514 
    515         if (hasFocus()) {
    516                 QStyleOptionFocusRect option;
    517                 option.initFrom(this);
    518                 option.backgroundColor = palette().color(QPalette::Background);
    519                 style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter, this);
    520         }
    521 }
    522 
    523 void DateWidget::mousePressEvent(QMouseEvent *event)
    524 {
    525         calendarWidget->setSelectedDate(mDate);
    526         calendarWidget->move(event->globalPos());
    527         calendarWidget->show();
    528         calendarWidget->raise();
    529         calendarWidget->setFocus();
    530 }
    531 
    532 void DateWidget::focusInEvent(QFocusEvent *event)
    533 {
    534         setFocus();
    535         QWidget::focusInEvent(event);
    536 }
    537 
    538 void DateWidget::focusOutEvent(QFocusEvent *event)
    539 {
    540         QWidget::focusOutEvent(event);
    541 }
    542 
    543 void DateWidget::keyPressEvent(QKeyEvent *event)
    544 {
    545         if (event->key() == Qt::Key_Return ||
    546             event->key() == Qt::Key_Enter ||
    547             event->key() == Qt::Key_Space) {
    548                 calendarWidget->move(mapToGlobal(QPoint(0, 64)));
    549                 calendarWidget->show();
    550                 event->setAccepted(true);
    551         } else {
    552                 QWidget::keyPressEvent(event);
    553         }
    554432}
    555433
  • desktop-widgets/simplewidgets.h

    rdb17adfb r2b5a235  
    132132class QCalendarWidget;
    133133
    134 class DateWidget : public QWidget {
    135         Q_OBJECT
    136 public:
    137         DateWidget(QWidget *parent = 0);
    138         QDate date() const;
    139 public
    140 slots:
    141         void setDate(const QDate &date);
    142 
    143 protected:
    144         void paintEvent(QPaintEvent *event);
    145         void mousePressEvent(QMouseEvent *event);
    146         void focusInEvent(QFocusEvent *);
    147         void focusOutEvent(QFocusEvent *);
    148         void keyPressEvent(QKeyEvent *);
    149         void changeEvent(QEvent *);
    150         bool eventFilter(QObject *, QEvent *);
    151 signals:
    152         void dateChanged(const QDate &date);
    153 
    154 private:
    155         QDate mDate;
    156         QCalendarWidget *calendarWidget;
    157 };
    158 
    159134class DiveComponentSelection : public QDialog {
    160135        Q_OBJECT
  • subsurface.qrc

    r1ef1496 r2b5a235  
    6161        <file alias="icon_HR">icons/icon-HR.png</file>
    6262        <file alias="icon_tissue">icons/heatmap.png</file>
    63         <file alias="calendar">icons/calendarbg.png</file>
    6463        <file alias="pictures">icons/pictures.png</file>
    6564        <file>icons/subsurface/index.theme</file>
Note: See TracChangeset for help on using the changeset viewer.