summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/simplewidgets.cpp122
-rw-r--r--desktop-widgets/simplewidgets.h25
2 files changed, 0 insertions, 147 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: