summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp86
-rw-r--r--korganizer/kodaymatrix.cpp8
-rw-r--r--microkde/KDGanttMinimizeSplitter.cpp8
-rw-r--r--microkde/kdialogbase.cpp8
4 files changed, 87 insertions, 23 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 2b05d37..8d32152 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -97,40 +97,103 @@ TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
viewport()->setBackgroundMode( PaletteBackground );
}
void TimeLabels::setCellHeight(int height)
{
mCellHeight = height;
}
/*
Optimization so that only the "dirty" portion of the scroll view
is redrawn. Unfortunately, this is not called by default paintEvent() method.
*/
void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
{
- // if ( globalFlagBlockAgenda )
- // return;
- // bug: the parameters cx, cy, cw, ch are the areas that need to be
- // redrawn, not the area of the widget. unfortunately, this
- // code assumes the latter...
-
- // now, for a workaround...
- // these two assignments fix the weird redraw bug
+ cx = contentsX() + frameWidth()*2;
+ cw = contentsWidth() ;
+ // end of workaround
+
+ int cell = ((int)(cy/mCellHeight));
+ int y = cell * mCellHeight;
+ QFontMetrics fm = fontMetrics();
+ QString hour;
+ QString suffix = "am";
+ int timeHeight = fm.ascent();
+ QFont nFont = p->font();
+
+ if (!KGlobal::locale()->use12Clock()) {
+ if ( QApplication::desktop()->width() <= 320 )
+ suffix = "00";
+ else
+ suffix = "00";
+ }
+
+ if ( timeHeight > mCellHeight ) {
+ timeHeight = mCellHeight-1;
+ int pointS = nFont.pointSize();
+ while ( pointS > 4 ) {
+ nFont.setPointSize( pointS );
+ fm = QFontMetrics( nFont );
+ if ( fm.ascent() < mCellHeight )
+ break;
+ -- pointS;
+ }
+ fm = QFontMetrics( nFont );
+ timeHeight = fm.ascent();
+ }
+ //timeHeight -= (timeHeight/4-2);
+ QFont sFont = nFont;
+ sFont.setPointSize( sFont.pointSize()/2 );
+ QFontMetrics fmS( sFont );
+ int sHei = fmS.ascent() ;
+ //sHei -= (sHei/4-2);
+ int startW = this->width() - frameWidth()-2;
+ int tw2 = fmS.width(suffix);
+ timeHeight = (timeHeight-1) /2 -1;
+ while (y < cy + ch+mCellHeight) {
+ p->drawLine(startW-tw2+1 ,y,cw,y);
+ hour.setNum(cell);
+ // handle 24h and am/pm time formats
+ if (KGlobal::locale()->use12Clock()) {
+ if (cell > 11) suffix = "pm";
+ else
+ suffix = "am";
+ if (cell == 0) hour.setNum(12);
+ if (cell > 12) hour.setNum(cell - 12);
+ }
+
+ // center and draw the time label
+ int timeWidth = fm.width(hour);
+ int offset = startW - timeWidth - tw2 ;
+ p->setFont( nFont );
+ p->drawText( offset, y+ timeHeight, hour);
+ p->setFont( sFont );
+ offset = startW - tw2+1;
+ p->drawText( offset, y -1, suffix);
+
+ // increment indices
+ y += mCellHeight;
+ cell++;
+ }
+
+
+
+
+#if 0
mRedrawNeeded = true;
if ( mRedrawNeeded ) {
cx = contentsX() + frameWidth()*2;
cw = contentsWidth() ;
// end of workaround
int cell = ((int)(cy/mCellHeight));
int y = cell * mCellHeight;
QFontMetrics fm = fontMetrics();
QString hour;
QString suffix;
int timeHeight = fm.ascent();
QFont nFont = p->font();
if (!KGlobal::locale()->use12Clock()) {
if ( QApplication::desktop()->width() <= 320 )
@@ -179,59 +242,60 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
p->setFont( nFont );
p->drawText( offset, y+ timeHeight, hour);
p->setFont( sFont );
offset = startW - tw2+1;
p->drawText( offset, y+ sHei, suffix);
// increment indices
y += mCellHeight;
cell++;
}
} else {
//qDebug("NO redraw ");
}
// double buffer not yet implemented
//bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
//mRedrawNeeded = false;
+#endif
}
/**
Calculates the minimum width.
*/
int TimeLabels::minimumWidth() const
{
return mMiniWidth;
}
/** updates widget's internal state */
void TimeLabels::updateConfig()
{
mRedrawNeeded = true;
// set the font
// config->setGroup("Fonts");
// QFont font = config->readFontEntry("TimeBar Font");
setFont(KOPrefs::instance()->mTimeBarFont);
QString test = "20";
if (KGlobal::locale()->use12Clock())
test = "12";
mMiniWidth = fontMetrics().width(test);
if (KGlobal::locale()->use12Clock())
test = "pm";
else {
if ( QApplication::desktop()->width() <= 320 )
- test = "";
+ test = "00";
else
test = "00";
}
QFont sFont = font();
sFont.setPointSize( sFont.pointSize()/2 );
QFontMetrics fmS( sFont );
mMiniWidth += fmS.width( test ) + frameWidth()*2 +4 ;
// update geometry restrictions based on new settings
setFixedWidth( mMiniWidth );
// update HourSize
mCellHeight = KOPrefs::instance()->mHourSize*4;
resizeContents(50,mRows * mCellHeight);
}
/** update time label positions */
@@ -661,32 +725,34 @@ KOAgendaButton* KOAgendaView::getNewDaylabel()
void KOAgendaView::createDayLabels()
{
if ( mBlockUpdating || globalFlagBlockLabel == 1) {
// qDebug(" KOAgendaView::createDayLabels() blocked ");
return;
}
int newHight;
// ### Before deleting and recreating we could check if mSelectedDates changed...
// It would remove some flickering and gain speed (since this is called by
// each updateView() call)
int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
+ if ( QApplication::desktop()->width() <= 320 )
+ maxWid -= 10;
mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
if ( maxWid < 0 )
maxWid = 20;
QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
QFontMetrics fm ( dlf );
int selCount = mSelectedDates.count();
QString dayTest = "Mon 20";
//QString dayTest = "Mon 20";
int wid = fm.width( dayTest );
//maxWid -= ( selCount * 3 ); //working for QLabels
maxWid -= ( selCount * 3 ); //working for QPushButton
if ( maxWid < 0 )
maxWid = 20;
int needWid = wid * selCount;
//qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
@@ -719,35 +785,37 @@ void KOAgendaView::createDayLabels()
mDayLabels->setFont( dlf );
// mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
// mLayoutDayLabels->addSpacing(mTimeLabels->width());
//mLayoutDayLabels->addSpacing( 2 );
// QFont lFont = dlf;
bool appendLabels = false;
KOAgendaButton *dayLabel;
dayLabel = mDayLabelsList.first();
if ( !dayLabel ) {
appendLabels = true;
dayLabel = getNewDaylabel();
}
dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
dayLabel->setFont( dlf );
dayLabel->setNum( -1 );
//dayLabel->setAlignment(QLabel::AlignHCenter);
+#if 0
if ( QApplication::desktop()->width() <= 320 )
dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) );
else
+#endif
dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
dayLabel->show();
DateList::ConstIterator dit;
bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
int counter = -1;
for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
++counter;
QDate date = *dit;
// QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
if ( ! appendLabels ) {
dayLabel = mDayLabelsList.next();
if ( !dayLabel )
appendLabels = true;
}
if ( appendLabels ) {
dayLabel = getNewDaylabel();
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index b8a0f09..8affe50 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -754,48 +754,48 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
if ( rowModulo ) {
if ( row >= 6 - rowModulo )
addRow = row - 5 + rowModulo;
}
if ( colModulo ) {
int colt1 = mSelEndT%7;
//qDebug("colt1 %d ", colt1 );
if ( colt1 >= 7 - colModulo )
addCol = colt1 - 7 + colModulo+1;
int colt = mSelStartT%7;
if ( colt >= 7 - colModulo )
addCol2 = colt - 7 + colModulo;
addCol -= addCol2;
//qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 );
}
// Single row selection
- if ( row == 0)
- addRow = 1;
+ //if ( row == 0)
+ // addRow = 1;
p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2,
row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol);
} else {
// draw first row to the right
if ( colModulo ) {
if ( col >= 7 - colModulo )
addCol2 = col - 7 + colModulo;
}
if ( rowModulo ) {
if ( row >= 6 - rowModulo )
addRow = row - 5 + rowModulo;
}
- if ( row == 0)
- addRow = 1;
+ //if ( row == 0)
+ // addRow = 1;
int drawWid = width()-(col*dwidth+1+addCol2)-1;
p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid,
dheight+1, selcol);
// draw full block till last line
selh = mSelEndT/7-row;
addRow = 0;
if ( rowModulo ) {
if ( mSelEndT/7 >= 6 - rowModulo )
addRow = mSelEndT/7 - 5 + rowModulo;
}
//qDebug("%d %d %d ",selh, row, addRow );
int addrow2 = addRow-selh+1;
if ( addrow2 < 0 )
addrow2 = 0;
if (selh > 1) {
p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol);
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp
index 253175e..2a30346 100644
--- a/microkde/KDGanttMinimizeSplitter.cpp
+++ b/microkde/KDGanttMinimizeSplitter.cpp
@@ -260,52 +260,48 @@ QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions()
}
return list;
}
void KDGanttSplitterHandle::paintEvent( QPaintEvent * )
{
QPixmap buffer( size() );
QPainter p( &buffer );
//LR
// Draw the splitter rectangle
p.setBrush( colorGroup().background() );
p.setPen( colorGroup().foreground() );
//p.drawRect( rect() );
#ifndef DESKTOP_VERSION
if ( mMouseDown )
- buffer.fill( QColor( 242,27,255 ) );
+ buffer.fill( colorGroup().background().dark() );
else
#endif
buffer.fill( colorGroup().background() );
//buffer.fill( backgroundColor() );
// parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup());
int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size
// arrow color
QColor col;
if ( _activeButton )
col = colorGroup().background().dark( 250 );
else {
if ( mMouseDown )
-#ifndef DESKTOP_VERSION
- col = QColor( 178,18,188);//QColor( 242,27,255 );//Qt::white;
-#else
col = Qt::white;
-#endif
else
col = colorGroup().background().dark( 150 );
}
//QColor col = backgroundColor().dark( 130 );
p.setBrush( col );
p.setPen( col );
QValueList<QPointArray> list = buttonRegions();
int index = 1;
if ( mUseOffset )
p.translate( 0, 1 );
for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
if ( index == _activeButton ) {
/*
if ( ! _collapsed ) {
@@ -675,33 +671,33 @@ void KDGanttMinimizeSplitter::setRubberband( int p )
2*rBord, r.height() );
if ( p >= 0 )
paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() );
} else {
if ( opaqueOldPos >= 0 )
paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord,
r.width(), 2*rBord );
if ( p >= 0 )
paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );
}
opaqueOldPos = p;
#else
if ( !mRubberBand ) {
mRubberBand = new QFrame( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop);
mRubberBand->setFrameStyle( Box | Raised );
//mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) );
- mRubberBand->setPalette( QPalette ( QColor( 178,18,188), QColor( 242,27,255 ) ));
+ mRubberBand->setPalette( QPalette ( colorGroup().background().light(), colorGroup().background().dark() ));
}
QRect r = contentsRect();
static int rBord = 0; //Themable????
if ( !rBord ) {
if (QApplication::desktop()->width() <= 320 )
rBord = 3;
else
rBord = 4;
}
int sw = style().splitterWidth();
if ( orient == Horizontal ) {
if ( p >= 0 ) {
QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y()));
mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() );
}
} else {
diff --git a/microkde/kdialogbase.cpp b/microkde/kdialogbase.cpp
index e6144de..11635e1 100644
--- a/microkde/kdialogbase.cpp
+++ b/microkde/kdialogbase.cpp
@@ -123,49 +123,49 @@ QTabWidget *KDialogBase::tabWidget()
void KDialogBase::hideButtons()
{
if ( mUser1Button ) mUser1Button->hide() ;
if ( mUser2Button ) mUser2Button->hide() ;
if ( mOkButton ) mOkButton->hide() ;
if ( mApplyButton ) mApplyButton->hide() ;
if ( mDefaultButton ) mDefaultButton->hide();
if ( mCancelButton ) mCancelButton->hide() ;
if ( mCloseButton ) mCloseButton->hide() ;
}
void KDialogBase::initLayout()
{
delete mTopLayout;
mTopLayout = new QVBoxLayout( this );
- mTopLayout->setMargin( marginHint() );
- mTopLayout->setSpacing( spacingHint() );
+ mTopLayout->setMargin( marginHintSmall() );
+ mTopLayout->setSpacing( spacingHintSmall() );
mTopLayout->addWidget( mMainWidget );
QBoxLayout *buttonLayout = new QHBoxLayout;
mTopLayout->addLayout( buttonLayout );
if ( mUser1Button ) buttonLayout->addWidget( mUser1Button );
if ( mUser2Button ) buttonLayout->addWidget( mUser2Button );
if ( mOkButton ) buttonLayout->addWidget( mOkButton );
if ( mApplyButton ) buttonLayout->addWidget( mApplyButton );
if ( mDefaultButton ) buttonLayout->addWidget( mDefaultButton );
if ( mCancelButton ) buttonLayout->addWidget( mCancelButton );
if ( mCloseButton ) buttonLayout->addWidget( mCloseButton );
- buttonLayout->setMargin( 0 );
- buttonLayout->setSpacing( spacingHint() );
+ buttonLayout->setMargin( marginHintSmall() );
+ buttonLayout->setSpacing( spacingHintSmall() );
}
QFrame *KDialogBase::addPage( const QString &name )
{
// kdDebug() << "KDialogBase::addPage(): " << name << endl;
QFrame *frame = new QFrame( tabWidget() );
tabWidget()->addTab( frame, name );
return frame;
}
QFrame *KDialogBase::addPage( const QString &name, int, const QPixmap & )
{
return addPage( name );
}