mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-27 20:58:47 +00:00
Remove unused DateWidget with its icon.
This commit is contained in:
parent
4db42808f6
commit
2b5a2352ea
4 changed files with 0 additions and 148 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue