summaryrefslogtreecommitdiffabout
path: root/microkde
authorzautrix <zautrix>2005-02-08 16:24:18 (UTC)
committer zautrix <zautrix>2005-02-08 16:24:18 (UTC)
commit78c70cfbbe79243d8b0ec40f8f6438c99046e12b (patch) (side-by-side diff)
tree382bc11ad3b56f72b8f84414e1da5e5ea871204b /microkde
parent584ed7893497b2adad5ba6c3e914d90b76973b92 (diff)
downloadkdepimpi-78c70cfbbe79243d8b0ec40f8f6438c99046e12b.zip
kdepimpi-78c70cfbbe79243d8b0ec40f8f6438c99046e12b.tar.gz
kdepimpi-78c70cfbbe79243d8b0ec40f8f6438c99046e12b.tar.bz2
fix
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdatetbl.cpp36
-rw-r--r--microkde/kdatetbl.h4
-rw-r--r--microkde/kglobalsettings.cpp1
3 files changed, 25 insertions, 16 deletions
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp
index e827412..990cfb9 100644
--- a/microkde/kdatetbl.cpp
+++ b/microkde/kdatetbl.cpp
@@ -60,116 +60,115 @@ KDateValidator::validate(QString& text, int&) const
return date(text, temp);
}
QValidator::State
KDateValidator::date(const QString& text, QDate& d) const
{
QDate tmp = KGlobal::locale()->readDate(text);
if (!tmp.isNull())
{
d = tmp;
return Acceptable;
} else
return Valid;
}
void
KDateValidator::fixup( QString& ) const
{
}
KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f)
: QGridView(parent, name, f)
{
- setFontSize(10);
+ setFont( KGlobalSettings::generalFont() );
if(!date_.isValid())
{
date_=QDate::currentDate();
}
setFocusPolicy( QWidget::StrongFocus );
setNumRows(7); // 6 weeks max + headline
setNumCols(7); // 7 days a week
setHScrollBarMode(AlwaysOff);
setVScrollBarMode(AlwaysOff);
viewport()->setBackgroundColor(QColor(220,245,255));
#if 0
viewport()->setEraseColor(lightGray);
#endif
mMarkCurrent = false;
setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth
}
void
KDateTable::paintCell(QPainter *painter, int row, int col)
{
QRect rect;
QString text;
QPen pen;
int w=cellWidth();
int h=cellHeight();
int pos;
QBrush brushBlue(blue);
QBrush brushLightblue(QColor(220,245,255));
- QFont font=KGlobalSettings::generalFont();
+ QFont _font=font();
// -----
- font.setPointSize(fontsize);
if(row==0)
{ // we are drawing the headline
- font.setBold(true);
- painter->setFont(font);
+ _font.setBold(true);
+ painter->setFont(_font);
bool normalday = true;
QString daystr;
if (KGlobal::locale()->weekStartsMonday())
{
daystr = KGlobal::locale()->weekDayName(col+1, true);
if (col == 5 || col == 6)
normalday = false;
} else {
daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true);
if (col == 0 || col == 6)
normalday = false;
}
if (!normalday)
{
painter->setPen(QColor(220,245,255));
painter->setBrush(brushLightblue);
painter->drawRect(0, 0, w, h);
painter->setPen(blue);
} else {
painter->setPen(blue);
painter->setBrush(brushBlue);
painter->drawRect(0, 0, w, h);
painter->setPen(white);
}
painter->drawText(0, 0, w, h-1, AlignCenter,
daystr, -1, &rect);
painter->setPen(black);
painter->moveTo(0, h-1);
painter->lineTo(w-1, h-1);
// ----- draw the weekday:
} else {
- painter->setFont(font);
+ painter->setFont(_font);
pos=7*(row-1)+col;
if (KGlobal::locale()->weekStartsMonday())
pos++;
if(pos<firstday || (firstday+numdays<=pos))
{ // we are either
// ° painting a day of the previous month or
// ° painting a day of the following month
if(pos<firstday)
{ // previous month
text.setNum(numDaysPrevMonth+pos-firstday+1);
} else { // following month
text.setNum(pos-firstday-numdays+1);
}
painter->setPen(gray);
} else { // paint a day of the current month
text.setNum(pos-firstday+1);
painter->setPen(black);
}
pen=painter->pen();
if(firstday+date.day()-1==pos)
{
if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos)
painter->setPen(green);
@@ -279,52 +278,53 @@ KDateTable::keyPressEvent( QKeyEvent *e )
setDate(QDate(date.year(), date.month(), pos-firstday+dayoff));
updateCell(temp/7+1, temp%7); // Update the previously selected cell
updateCell(pos/7+1, pos%7); // Update the selected cell
assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid());
}
void
KDateTable::viewportResizeEvent(QResizeEvent * e)
{
QGridView::viewportResizeEvent(e);
setCellWidth(viewport()->width()/7);
setCellHeight(viewport()->height()/7);
}
void
KDateTable::setFontSize(int size)
{
int count;
QRect rect;
// ----- store rectangles:
fontsize=size;
- QFont font = KGlobalSettings::generalFont();
- font.setPointSize(fontsize);
- font.setBold( true );
- QFontMetrics metrics(font);
+ QFont _font = font();
+ _font.setPointSize(fontsize);
+ setFont( _font );
+ _font.setBold( true );
+ QFontMetrics metrics(_font);
// ----- find largest day name:
maxCell.setWidth(0);
maxCell.setHeight(0);
for(count=0; count<7; ++count)
{
rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true));
maxCell.setWidth(QMAX(maxCell.width(), rect.width()));
maxCell.setHeight(QMAX(maxCell.height(), rect.height()));
}
// ----- compare with a real wide number and add some space:
rect=metrics.boundingRect(QString::fromLatin1("88"));
maxCell.setWidth(QMAX(maxCell.width()+2, rect.width()));
#ifdef DESKTOP_VERSION
maxCell.setHeight(QMAX(maxCell.height()+8, rect.height()));
#else
maxCell.setHeight(QMAX(maxCell.height()+4, rect.height()));
#endif
if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) {
maxCell.setHeight(maxCell.width() * 1000 / 1900 );
qDebug("setmax ");
}
}
@@ -422,59 +422,63 @@ void KDateTable::focusInEvent( QFocusEvent *e )
{
repaintContents(false);
QGridView::focusInEvent( e );
}
void KDateTable::focusOutEvent( QFocusEvent *e )
{
repaintContents(false);
QGridView::focusOutEvent( e );
}
QSize
KDateTable::sizeHint() const
{
if(maxCell.height()>0 && maxCell.width()>0)
{
return QSize((maxCell.width()+2)*numCols()+2*frameWidth(),
(maxCell.height()+4)*numRows()+2*frameWidth());
} else {
return QSize(-1, -1);
}
}
KDateInternalMonthPicker::KDateInternalMonthPicker
-(int fontsize, QWidget* parent, const char* name)
+(QWidget* parent, const char* name)
: QGridView(parent, name),
result(0) // invalid
{
QRect rect;
QFont font;
// -----
activeCol = -1;
activeRow = -1;
font=KGlobalSettings::generalFont();
- //font.setPointSize(fontsize);
+ int fontsize = 10;
+ int add = 2;
+ if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
+ add += 6;
+ font.setPointSize(fontsize+add);
setFont(font);
setHScrollBarMode(AlwaysOff);
setVScrollBarMode(AlwaysOff);
setFrameStyle(QFrame::NoFrame);
setNumRows(4);
setNumCols(3);
// enable to find drawing failures:
// setTableFlags(Tbl_clipCellPainting);
#if 0
viewport()->setEraseColor(lightGray); // for consistency with the datepicker
#endif
// ----- find the preferred size
// (this is slow, possibly, but unfortunatly it is needed here):
QFontMetrics metrics(font);
for(int i=1; i <= 12; ++i)
{
rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false));
if(max.width()<rect.width()) max.setWidth(rect.width());
if(max.height()<rect.height()) max.setHeight(rect.height());
}
}
QSize
@@ -740,59 +744,63 @@ KPopupFrame::exec(QPoint pos)
{
popup(pos);
repaint();
qApp->enter_loop();
hide();
return result;
}
int
KPopupFrame::exec(int x, int y)
{
return exec(QPoint(x, y));
}
void KPopupFrame::virtual_hook( int, void* )
{ /*BASE::virtual_hook( id, data );*/ }
void KDateTable::virtual_hook( int, void* )
{ /*BASE::virtual_hook( id, data );*/ }
//#include "kdatetbl.moc"
KDateInternalWeekPicker::KDateInternalWeekPicker
-(int fontsize, QWidget* parent, const char* name)
+(QWidget* parent, const char* name)
: QGridView(parent, name),
result(0) // invalid
{
QRect rect;
QFont font;
// -----
activeCol = -1;
activeRow = -1;
font=KGlobalSettings::generalFont();
- //font.setPointSize(fontsize);
+ int fontsize = 10;
+ int add = 2;
+ if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
+ add += 4;
+ font.setPointSize(fontsize+add);
setFont(font);
setHScrollBarMode(AlwaysOff);
setVScrollBarMode(AlwaysOff);
setFrameStyle(QFrame::NoFrame);
setNumRows(13);
setNumCols(4);
// enable to find drawing failures:
// setTableFlags(Tbl_clipCellPainting);
#if 0
viewport()->setEraseColor(lightGray); // for consistency with the datepicker
#endif
// ----- find the preferred size
// (this is slow, possibly, but unfortunatly it is needed here):
QFontMetrics metrics(font);
for(int i=1; i <= 52; ++i)
{
rect=metrics.boundingRect(QString::number( i ));
if(max.width()<rect.width()) max.setWidth(rect.width());
if(max.height()<rect.height()) max.setHeight(rect.height());
}
if ( QApplication::desktop()->width() > 640 ) {
max.setWidth(max.width()+6);
max.setHeight(max.height()+8);
diff --git a/microkde/kdatetbl.h b/microkde/kdatetbl.h
index 2efa532..87808df 100644
--- a/microkde/kdatetbl.h
+++ b/microkde/kdatetbl.h
@@ -36,49 +36,49 @@ class KDateInternalMonthPicker : public QGridView
Q_OBJECT
protected:
/**
* Store the month that has been clicked [1..12].
*/
int result;
/**
* the cell under mouse cursor when LBM is pressed
*/
short int activeCol;
short int activeRow;
/**
* Contains the largest rectangle needed by the month names.
*/
QRect max;
signals:
/**
* This is send from the mouse click event handler.
*/
void closeMe(int);
public:
/**
* The constructor.
*/
- KDateInternalMonthPicker(int fontsize, QWidget* parent, const char* name=0);
+ KDateInternalMonthPicker(QWidget* parent, const char* name=0);
/**
* The size hint.
*/
QSize sizeHint() const;
/**
* Return the result. 0 means no selection (reject()), 1..12 are the
* months.
*/
int getResult() const;
protected:
/**
* Set up the painter.
*/
void setupPainter(QPainter *p);
/**
* The resize event.
*/
void viewportResizeEvent(QResizeEvent*);
/**
* Paint a cell. This simply draws the month names in it.
*/
virtual void paintCell(QPainter* painter, int row, int col);
/**
* Catch mouse click and move events to paint a rectangle around the item.
@@ -312,49 +312,49 @@ class KDateInternalWeekPicker : public QGridView
Q_OBJECT
protected:
/**
* Store the month that has been clicked [1..12].
*/
int result;
/**
* the cell under mouse cursor when LBM is pressed
*/
short int activeCol;
short int activeRow;
/**
* Contains the largest rectangle needed by the month names.
*/
QRect max;
signals:
/**
* This is send from the mouse click event handler.
*/
void closeMe(int);
public:
/**
* The constructor.
*/
- KDateInternalWeekPicker(int fontsize, QWidget* parent, const char* name=0);
+ KDateInternalWeekPicker(QWidget* parent, const char* name=0);
/**
* The size hint.
*/
QSize sizeHint() const;
/**
* Return the result. 0 means no selection (reject()), 1..12 are the
* months.
*/
int getResult() const;
protected:
/**
* Set up the painter.
*/
void setupPainter(QPainter *p);
/**
* The resize event.
*/
void viewportResizeEvent(QResizeEvent*);
/**
* Paint a cell. This simply draws the month names in it.
*/
virtual void paintCell(QPainter* painter, int row, int col);
/**
* Catch mouse click and move events to paint a rectangle around the item.
diff --git a/microkde/kglobalsettings.cpp b/microkde/kglobalsettings.cpp
index 30e793f..fbbf814 100644
--- a/microkde/kglobalsettings.cpp
+++ b/microkde/kglobalsettings.cpp
@@ -1,37 +1,38 @@
#include "kglobalsettings.h"
#include "kconfig.h"
#include "kglobal.h"
#include "kconfigbase.h"
#include <qapplication.h>
QFont KGlobalSettings::generalFont()
{
int size = 12;
if (QApplication::desktop()->width() < 480 )
size = 10;
QFont f = QApplication::font();
+ //qDebug("pointsize %d ", f.pointSize());
f.setPointSize( size );
return f;
}
QFont KGlobalSettings::toolBarFont()
{
return QApplication::font();
}
QColor KGlobalSettings::toolBarHighlightColor()
{
return QColor( "black" );
}
QRect KGlobalSettings::desktopGeometry( QWidget * )
{
return QApplication::desktop()->rect();
}
/**
* Returns whether KDE runs in single (default) or double click
* mode.
* see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html
* @return true if single click mode, or false if double click mode.
**/