mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
plasma: new Plasma::CalendarWidget class
to be used by the clock and calendar applets Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
3c697cf8ce
commit
7e78f97d61
5 changed files with 177 additions and 0 deletions
|
@ -539,6 +539,7 @@ install(
|
|||
Plasma/ToolTipContent
|
||||
Plasma/ToolTipManager
|
||||
Plasma/TreeView
|
||||
Plasma/CalendarWidget
|
||||
Plasma/Version
|
||||
Plasma/View
|
||||
Plasma/Wallpaper
|
||||
|
|
1
includes/Plasma/CalendarWidget
Normal file
1
includes/Plasma/CalendarWidget
Normal file
|
@ -0,0 +1 @@
|
|||
#include "../../plasma/widgets/calendarwidget.h"
|
|
@ -138,6 +138,7 @@ set(plasma_LIB_SRCS
|
|||
widgets/textbrowser.cpp
|
||||
widgets/treeview.cpp
|
||||
widgets/textedit.cpp
|
||||
widgets/calendarwidget.cpp
|
||||
)
|
||||
|
||||
set_source_files_properties(
|
||||
|
@ -256,6 +257,7 @@ install(
|
|||
widgets/textbrowser.h
|
||||
widgets/treeview.h
|
||||
widgets/textedit.h
|
||||
widgets/calendarwidget.h
|
||||
DESTINATION ${KDE4_INCLUDE_INSTALL_DIR}/plasma/widgets
|
||||
)
|
||||
|
||||
|
|
83
plasma/widgets/calendarwidget.cpp
Normal file
83
plasma/widgets/calendarwidget.cpp
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright 2023 Ivailo Monev <xakepa10@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "calendarwidget.h"
|
||||
#include "private/style_p.h"
|
||||
#include "kcalendarwidget.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class CalendarWidgetPrivate
|
||||
{
|
||||
public:
|
||||
Plasma::Style::Ptr style;
|
||||
};
|
||||
|
||||
CalendarWidget::CalendarWidget(QGraphicsWidget *parent)
|
||||
: QGraphicsProxyWidget(parent),
|
||||
d(new CalendarWidgetPrivate())
|
||||
{
|
||||
KCalendarWidget *native = new KCalendarWidget();
|
||||
setWidget(native);
|
||||
native->setWindowIcon(QIcon());
|
||||
native->setAttribute(Qt::WA_NoSystemBackground);
|
||||
// the popup of the navigation bar does not inherit the WA_NoSystemBackground attribute
|
||||
native->setNavigationBarVisible(false);
|
||||
connect(native, SIGNAL(clicked(QDate)), this, SIGNAL(clicked(QDate)));
|
||||
connect(native, SIGNAL(activated(QDate)), this, SIGNAL(activated(QDate)));
|
||||
|
||||
d->style = Plasma::Style::sharedStyle();
|
||||
native->setStyle(d->style.data());
|
||||
}
|
||||
|
||||
CalendarWidget::~CalendarWidget()
|
||||
{
|
||||
delete d;
|
||||
Plasma::Style::doneWithSharedStyle();
|
||||
}
|
||||
|
||||
void CalendarWidget::setSelectedDate(const QDate &date)
|
||||
{
|
||||
nativeWidget()->setSelectedDate(date);
|
||||
}
|
||||
|
||||
QDate CalendarWidget::selectedDate() const
|
||||
{
|
||||
return nativeWidget()->selectedDate();
|
||||
}
|
||||
|
||||
void CalendarWidget::setStyleSheet(const QString &stylesheet)
|
||||
{
|
||||
widget()->setStyleSheet(stylesheet);
|
||||
}
|
||||
|
||||
QString CalendarWidget::styleSheet()
|
||||
{
|
||||
return widget()->styleSheet();
|
||||
}
|
||||
|
||||
KCalendarWidget *CalendarWidget::nativeWidget() const
|
||||
{
|
||||
return static_cast<KCalendarWidget*>(widget());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include "moc_calendarwidget.cpp"
|
90
plasma/widgets/calendarwidget.h
Normal file
90
plasma/widgets/calendarwidget.h
Normal file
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* Copyright 2023 Ivailo Monev <xakepa10@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef PLASMA_CALENDARWIDGET_H
|
||||
#define PLASMA_CALENDARWIDGET_H
|
||||
|
||||
#include <QtGui/QGraphicsProxyWidget>
|
||||
|
||||
#include <plasma/plasma_export.h>
|
||||
|
||||
class KCalendarWidget;
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class CalendarWidgetPrivate;
|
||||
|
||||
/**
|
||||
* @class CalendarWidget plasma/widgets/calendarwidget.h <Plasma/Widgets/CalendarWidget>
|
||||
*
|
||||
* @short Provides a plasma-themed KCalendarWidget.
|
||||
*/
|
||||
class PLASMA_EXPORT CalendarWidget : public QGraphicsProxyWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QDate selectedDate READ selectedDate WRITE setSelectedDate)
|
||||
Q_PROPERTY(QGraphicsWidget *parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
|
||||
Q_PROPERTY(KCalendarWidget *nativeWidget READ nativeWidget)
|
||||
|
||||
public:
|
||||
explicit CalendarWidget(QGraphicsWidget *parent = 0);
|
||||
~CalendarWidget();
|
||||
|
||||
/**
|
||||
* @return the date selected
|
||||
*/
|
||||
QDate selectedDate() const;
|
||||
|
||||
/**
|
||||
* Sets the selected data
|
||||
*
|
||||
* @param model the model to display
|
||||
*/
|
||||
void setSelectedDate(const QDate &date);
|
||||
|
||||
/**
|
||||
* Sets the stylesheet used to control the visual display of this CalendarWidget
|
||||
*
|
||||
* @param stylesheet a CSS string
|
||||
*/
|
||||
void setStyleSheet(const QString &stylesheet);
|
||||
|
||||
/**
|
||||
* @return the stylesheet currently used with this widget
|
||||
*/
|
||||
QString styleSheet();
|
||||
|
||||
/**
|
||||
* @return the native widget wrapped by this CalendarWidget
|
||||
*/
|
||||
KCalendarWidget *nativeWidget() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void clicked(QDate);
|
||||
void activated(QDate);
|
||||
|
||||
private:
|
||||
CalendarWidgetPrivate *const d;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // multiple inclusion guard
|
Loading…
Add table
Reference in a new issue