summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp31
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--korganizer/komonthview.cpp5
-rw-r--r--korganizer/koprefs.cpp28
-rw-r--r--korganizer/ktimeedit.cpp6
-rw-r--r--korganizer/mainwindow.cpp27
-rw-r--r--korganizer/navigatorbar.cpp3
-rw-r--r--libkdepim/kdatepicker.cpp10
-rw-r--r--microkde/kdatetbl.cpp22
-rw-r--r--microkde/kglobalsettings.cpp6
10 files changed, 91 insertions, 48 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 0fbaa9a..a9de65a 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -2439,88 +2439,91 @@ void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
}
delete cal;
mes = i18n("KO/Pi: Ready for beaming");
topLevelWidget()->setCaption(mes);
KApplication::convert2latin1( fn );
#ifndef DESKTOP_VERSION
Ir *ir = new Ir( this );
connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
ir->send( fn, description, "text/x-vCalendar" );
#endif
}
}
void CalendarView::beamDone( Ir *ir )
{
#ifndef DESKTOP_VERSION
delete ir;
#endif
topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
topLevelWidget()->raise();
}
void CalendarView::moveIncidence(Incidence * inc )
{
if ( !inc ) return;
- // qDebug("showDatePickerForIncidence( ) ");
- if ( mDateFrame->isVisible() )
- mDateFrame->hide();
- else {
- int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
- int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
- int dw = QApplication::desktop()->width();
- int dh = QApplication::desktop()->height();
- mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
- mDateFrame->show();
- }
+ showDatePickerPopup();
mDatePickerMode = 2;
mMoveIncidence = inc ;
QDate da;
if ( mMoveIncidence->type() == "Todo" ) {
Todo * to = (Todo *) mMoveIncidence;
if ( to->hasDueDate() )
da = to->dtDue().date();
else
da = QDate::currentDate();
} else {
da = mMoveIncidence->dtStart().date();
}
//PENDING set date for recurring incidence to date of recurrence
//mMoveIncidenceOldDate;
mDatePicker->setDate( da );
}
-void CalendarView::showDatePicker( )
+void CalendarView::showDatePickerPopup()
{
- //qDebug("CalendarView::showDatePicker( ) ");
if ( mDateFrame->isVisible() )
mDateFrame->hide();
else {
+ int offX = 0, offY = 0;
+#ifdef DESKTOP_VERSION
+ int w =mDatePicker->sizeHint().width() ;
+ int h = mDatePicker->sizeHint().height() ;
+ int dw = topLevelWidget()->width();
+ int dh = topLevelWidget()->height();
+ offX = topLevelWidget()->x();
+ offY = topLevelWidget()->y();
+#else
int w =mDatePicker->sizeHint().width() ;
int h = mDatePicker->sizeHint().height() ;
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
- mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
+#endif
+ mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
mDateFrame->show();
}
+}
+void CalendarView::showDatePicker( )
+{
+ showDatePickerPopup();
mDatePickerMode = 1;
mDatePicker->setDate( mNavigator->selectedDates().first() );
}
void CalendarView::showEventEditor()
{
#ifdef DESKTOP_VERSION
mEventEditor->show();
#else
if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
qApp->processEvents();
delete mEventEditor;
mEventEditor = mDialogManager->getEventEditor();
topLevelWidget()->setCaption( i18n("") );
}
mEventEditor->showMaximized();
#endif
}
void CalendarView::showTodoEditor()
{
#ifdef DESKTOP_VERSION
mTodoEditor->show();
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 731298d..e626ea3 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -421,48 +421,49 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
void toggleAllDaySize();
void dialogClosing(Incidence *);
/** Look for new messages in the inbox */
void lookForIncomingMessages();
/** Look for new messages in the outbox */
void lookForOutgoingMessages();
void processMainViewSelection( Incidence * );
void processTodoListSelection( Incidence * );
void processIncidenceSelection( Incidence * );
void purgeCompleted();
bool removeCompletedSubTodos( Todo* );
void slotCalendarChanged();
bool importBday();
bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
bool importQtopia( const QString &categoriesFile,
const QString &datebookFile,
const QString &tasklistFile );
void syncExternal( int mode );
void slotSelectPickerDate( QDate ) ;
void showDatePicker( ) ;
+ void showDatePickerPopup() ;
void moveIncidence(Incidence *) ;
void beamIncidence(Incidence *) ;
void beamCalendar() ;
void beamFilteredCalendar() ;
void beamIncidenceList(QPtrList<Incidence>) ;
void manageCategories();
int addCategories();
void removeCategories();
void setSyncDevice( QString );
void setSyncName( QString );
void showDay( QDate );
void undo_delete();
protected slots:
void timerAlarm();
void suspendAlarm();
void beamDone( Ir *ir );
/** Select a view or adapt the current view to display the specified dates. */
void showDates( const KCal::DateList & );
void selectWeekNum ( int );
public:
// show a standard warning
// returns KMsgBox::yesNoCancel()
int msgCalModified();
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 6ae4c6f..02d2585 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -904,50 +904,53 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
}
//connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
mContextMenu = eventPopup();
// updateConfig(); //useless here...
// ... but we need mWidthLongDayLabel computed
QFontMetrics fontmetric(mDayLabels[0]->font());
mWidthLongDayLabel = 0;
for (int i = 0; i < 7; i++) {
int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
}
//mWeekLabels[mNumWeeks]->setText( i18n("W"));
if ( mShowWeekView )
mWidStack->raiseWidget( mWeekView );
else
mWidStack->raiseWidget( mMonthView );
emit incidenceSelected( 0 );
#ifndef DESKTOP_VERSION
resize( QApplication::desktop()->size() );
- computeLayout();
+#else
+ resize(640, 480 );
#endif
+ computeLayout();
+
}
KOMonthView::~KOMonthView()
{
delete mContextMenu;
}
void KOMonthView::selectInternalWeekNum ( int n )
{
switchView();
emit selectWeekNum ( n );
}
int KOMonthView::currentWeek()
{
if ( mShowWeekView )
return mWeekLabelsW[0]->getWeekNum();
return mWeekLabels[0]->getWeekNum();
}
void KOMonthView::switchView()
{
if ( selectedCell( ) )
selectedCell()->deselect();
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 576c265..5bfe2a1 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -15,81 +15,85 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <time.h>
#ifndef _WIN32_
#include <unistd.h>
#endif
#include <qdir.h>
#include <qtextstream.h>
#include <qtextcodec.h>
#include <qstring.h>
#include <qregexp.h>
#include <qfont.h>
#include <qcolor.h>
#include <qstringlist.h>
#include <stdlib.h>
#include <kglobal.h>
+#include <kglobalsettings.h>
#include <kconfig.h>
#include <klocale.h>
#include <kdebug.h>
#include <kemailsettings.h>
#include <kstaticdeleter.h>
#include <libkdepim/kpimglobalprefs.h>
#include "koprefs.h"
#include "mainwindow.h"
KOPrefs *KOPrefs::mInstance = 0;
static KStaticDeleter<KOPrefs> insd;
KOPrefs::KOPrefs() :
KPimPrefs("korganizerrc")
{
mCategoryColors.setAutoDelete(true);
fillMailDefaults();
mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
QColor defaultHolidayColor = QColor(255,0,0);
QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
QColor defaultTodoDueTodayColor = QColor(255,220,100);
QColor defaultTodoOverdueColor = QColor(255,153,125);
+ /*
mTimeBarFont = QFont("helvetica",10);//,QFont::Bold);
mDefaultViewFont = QFont("helvetica",10);
mDefaultMonthViewFont = QFont("helvetica",8);
mMarcusBainsFont= QFont("helvetica",10);
mDateNavigatorFont= QFont("helvetica",10, QFont::Bold);
mEditBoxFont = QFont("helvetica",12);
mJornalViewFont = QFont("helvetica",12);
+ */
+
KPrefs::setCurrentGroup("General");
addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
addItemBool("ShowIconSearch",&mShowIconSearch,true);
addItemBool("ShowIconList",&mShowIconList,true);
addItemBool("ShowIconDay1",&mShowIconDay1,true);
addItemBool("ShowIconDay5",&mShowIconDay5,true);
addItemBool("ShowIconDay7",&mShowIconDay7,true);
addItemBool("ShowIconMonth",&mShowIconMonth,true);
addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
addItemBool("ShowIconBack",&mShowIconBack,true);
addItemBool("ShowIconToday",&mShowIconToday,true);
addItemBool("ShowIconForward",&mShowIconForward,true);
addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true);
addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
addItemBool("ShowIconNext",&mShowIconNext,true);
addItemBool("ShowIconJournal",&mShowIconJournal,true);
@@ -135,60 +139,60 @@ KOPrefs::KOPrefs() :
addItemInt("Mail Client",&mMailClient,MailClientKMail);
addItemBool("Use Control Center Email",&mEmailControlCenter,false);
addItemBool("Bcc",&mBcc,false);
KPrefs::setCurrentGroup("Time & Date");
addItemInt("Default Start Time",&mStartTime,10);
addItemInt("Default Duration",&mDefaultDuration,2);
addItemInt("Default Alarm Time",&mAlarmTime,3);
KPrefs::setCurrentGroup("AlarmSettings");
addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
KPrefs::setCurrentGroup("Calendar");
addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
KPrefs::setCurrentGroup("Fonts");
// qDebug(" KPrefs::setCurrentGroup(Fonts); ");
- addItemFont("TimeBar Font",&mTimeBarFont);
- addItemFont("MonthView Font",&mMonthViewFont);
- addItemFont("AgendaView Font",&mAgendaViewFont);
- addItemFont("MarcusBains Font",&mMarcusBainsFont);
- addItemFont("TimeLabels Font",&mTimeLabelsFont);
- addItemFont("TodoView Font",&mTodoViewFont);
- addItemFont("ListView Font",&mListViewFont);
- addItemFont("DateNavigator Font",&mDateNavigatorFont);
- addItemFont("EditBox Font",&mEditBoxFont);
- addItemFont("JournalView Font",&mJornalViewFont);
- addItemFont("WhatsNextView Font",&mWhatsNextFont);
- addItemFont("EventView Font",&mEventViewFont);
+ addItemFont("TimeBar Font",&mTimeBarFont,KGlobalSettings::generalFont() );
+ addItemFont("MonthView Font",&mMonthViewFont,KGlobalSettings::generalFont());
+ addItemFont("AgendaView Font",&mAgendaViewFont,KGlobalSettings::generalFont());
+ addItemFont("MarcusBains Font",&mMarcusBainsFont,KGlobalSettings::generalFont());
+ addItemFont("TimeLabels Font",&mTimeLabelsFont,KGlobalSettings::generalFont());
+ addItemFont("TodoView Font",&mTodoViewFont,KGlobalSettings::generalFont());
+ addItemFont("ListView Font",&mListViewFont,KGlobalSettings::generalFont());
+ addItemFont("DateNavigator Font",&mDateNavigatorFont,KGlobalSettings::generalFont());
+ addItemFont("EditBox Font",&mEditBoxFont,KGlobalSettings::generalFont());
+ addItemFont("JournalView Font",&mJornalViewFont,KGlobalSettings::generalFont());
+ addItemFont("WhatsNextView Font",&mWhatsNextFont,KGlobalSettings::generalFont());
+ addItemFont("EventView Font",&mEventViewFont,KGlobalSettings::generalFont());
KPrefs::setCurrentGroup("RemoteSyncing");
addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
addItemInt("LastSyncTime",&mLastSyncTime,0);
#ifdef _WIN32_
QString hdp= locateLocal("data","korganizer")+"\\\\";
#else
QString hdp= locateLocal("data","korganizer")+"/";
#endif
KPrefs::setCurrentGroup("LoadSaveFileNames");
addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
KPrefs::setCurrentGroup("Locale");
addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
diff --git a/korganizer/ktimeedit.cpp b/korganizer/ktimeedit.cpp
index 5222ac9..61a0931 100644
--- a/korganizer/ktimeedit.cpp
+++ b/korganizer/ktimeedit.cpp
@@ -28,51 +28,53 @@
#include <qlistbox.h>
#include <qapplication.h>
#include <kmessagebox.h>
#include <kglobal.h>
#include <kdebug.h>
#include <klocale.h>
#include <kpimglobalprefs.h>
#include "ktimeedit.h"
#include "koprefs.h"
#include <qvalidator.h>
// Validator for a time value with only hours and minutes (no seconds)
// Mostly locale aware. Author: David Faure <faure@kde.org>
// KTimeWidget/QTimeEdit provide nicer editing, but don't provide a combobox.
// Difficult to get all in one...
// But Qt-3.2 will offer QLineEdit::setMask, so a "99:99" mask would help.
KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name)
: QComboBox(TRUE, parent, name)
{
setInsertionPolicy(NoInsertion);
mFlagKeyPressed = false;
-
- if ( QApplication::desktop()->width() < 650 )
+ if ( QApplication::desktop()->height() <= 480 ) {
setSizeLimit ( 6 );
+ } else {
+ setSizeLimit ( 12 );
+ }
mTime = qt;
// mNoTimeString = i18n("No Time");
// insertItem( mNoTimeString );
// Fill combo box with selection of times in localized format.
QTime timeEntry(0,0,0);
do {
insertItem(KGlobal::locale()->formatTime(timeEntry));
timeEntry = timeEntry.addSecs(60*15);
} while (!timeEntry.isNull());
// Add end of day.
insertItem( KGlobal::locale()->formatTime( QTime( 23, 59, 59 ) ) );
updateText();
setFocusPolicy(QWidget::StrongFocus);
connect(this, SIGNAL(activated(int)), this, SLOT(activ(int)));
connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int)));
connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText()));
QFontMetrics fm ( font() );
QString timeString = "24:00";
if ( KPimGlobalPrefs::instance()->mPreferredTime == 1 )
timeString = "02:00pm";
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 7810bf9..61c39f5 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -2009,41 +2009,58 @@ void MainWindow::getFile( bool success )
mView->openCalendar( defaultFileName() );
if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
mSyncManager->slotSyncMenu( 999 );
}
setCaption( i18n("Pi-Sync successful!") );
}
void MainWindow::printSel( )
{
mView->viewManager()->agendaView()->agenda()->printSelection();
}
void MainWindow::printCal()
{
mView->print();//mCp->showDialog();
}
#include "libkdepim/kdatepicker.h"
#include <kdatetbl.h>
void MainWindow::weekAction()
{
int month;
KPopupFrame* popup = new KPopupFrame(this);
- int size = 12;
- if ( QApplication::desktop()->width() >= 480 )
- size = 18;
- KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(size, popup);
+ KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(10, popup);
// -----
picker->resize(picker->sizeHint());
popup->setMainWidget(picker);
picker->setFocus();
connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
- if(popup->exec(iconToolBar->mapToGlobal(QPoint(0, iconToolBar->height()))))
+ int x = 0;
+ int y = iconToolBar->height();
+ int dX = 0;
+ int dY = 0;
+ if ( iconToolBar->orientation () == Qt:: Horizontal ) {
+ if ( iconToolBar->y() > height()/2 ) {
+ dY = iconToolBar->height()+picker->sizeHint().height();
+ y = 0;
+ }
+ } else {
+ if ( iconToolBar->x() > width()/2 ) { // right side
+ x=0;
+ dX= iconToolBar->width()+picker->sizeHint().width();
+ y = 0;
+ } else {
+ x= iconToolBar->width();
+ y = 0;
+ }
+ }
+ qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
+ if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
{
month = picker->getResult();
emit selectWeek ( month );
//qDebug("weekSelected %d ", month);
}
delete popup;
}
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp
index f05e6f6..4a31c77 100644
--- a/korganizer/navigatorbar.cpp
+++ b/korganizer/navigatorbar.cpp
@@ -19,70 +19,71 @@
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <qstring.h>
#include <qtooltip.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qframe.h>
#include <qlabel.h>
#include <qpopupmenu.h>
#include <qapplication.h>
#include <kdebug.h>
#include <klocale.h>
#include <kglobal.h>
#include <kiconloader.h>
#include "libkdepim/kdatepicker.h"
#include <knotifyclient.h>
#include "kdatetbl.h"
#include "koglobals.h"
+#include <kglobalsettings.h>
#include "koprefs.h"
#ifndef KORG_NOPLUGINS
#include "kocore.h"
#endif
#include <kcalendarsystem.h>
#include "navigatorbar.h"
NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name )
: QWidget( parent, name )
{
QBoxLayout *topLayout = new QHBoxLayout( this );
// Set up the control buttons and date label
mCtrlFrame = new QFrame( this );
mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised);
mCtrlFrame->setLineWidth(1);
topLayout->addWidget( mCtrlFrame );
- QFont tfont = font();
+ QFont tfont = KGlobalSettings::generalFont();//font();
if ( QApplication::desktop()->width() >= 480 )
tfont.setPointSize(tfont.pointSize()+2);
tfont.setBold(true);
bool isRTL = KOGlobals::self()->reverseLayout();
#ifndef DESKTOP_VERSION
bool isDesktop = false;
#else
bool isDesktop = true;
#endif
if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 )
isDesktop = true;
// Create backward navigation buttons
mPrevYear = new QPushButton( mCtrlFrame );
mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) );
QToolTip::add( mPrevYear, i18n("Previous Year") );
mPrevMonth = new QPushButton( mCtrlFrame );
mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") );
QToolTip::add( mPrevMonth, i18n("Previous Month") );
// Create forward navigation buttons
mNextMonth = new QPushButton( mCtrlFrame );
mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") );
diff --git a/libkdepim/kdatepicker.cpp b/libkdepim/kdatepicker.cpp
index d8bc9f5..2be9c9e 100644
--- a/libkdepim/kdatepicker.cpp
+++ b/libkdepim/kdatepicker.cpp
@@ -12,74 +12,70 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "kdatepicker.h"
#include <kglobal.h>
#include <kapplication.h>
#include <klocale.h>
#include <kiconloader.h>
#include <qframe.h>
#include <qpainter.h>
#include <qdialog.h>
#include <qtoolbutton.h>
#include <qfont.h>
#include <qapplication.h>
#include <qlineedit.h>
#include <qvalidator.h>
#include <kdebug.h>
#include <knotifyclient.h>
+#include <kglobalsettings.h>
#include "kdatetbl.h"
#include "kdateedit.h"
//#include "kdatepicker.moc"
KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name)
: QFrame(parent,name),
yearForward(new QToolButton(this)),
yearBackward(new QToolButton(this)),
monthForward(new QToolButton(this)),
monthBackward(new QToolButton(this)),
selectMonth(new QToolButton(this)),
selectYear(new QToolButton(this)),
//line(new QLineEdit(this)),
val(new KDateValidator(this))
//table(new KDateTable(this)),
//fontsize(1)
{
- // -----
- int size = 12;
- if ( QApplication::desktop()->width() >= 480 )
- size = 18;
- fontsize = size;
- setFont ( QFont("helvetica",size) );
+ setFont ( KGlobalSettings::generalFont() );
table = new KDateTable(this);
- setFontSize(size);
+ setFontSize(font().pointSize()+2);
//line->setValidator(val);
lineDate = new KDateEdit( this, "dateediipicker", true );
yearForward->setPixmap(SmallIcon("2rightarrowB"));
yearBackward->setPixmap(SmallIcon("2leftarrowB"));
monthForward->setPixmap(SmallIcon("1rightarrowB"));
monthBackward->setPixmap(SmallIcon("1leftarrowB"));
setDate(dt); // set button texts
connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate)));
connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot()));
connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked()));
connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked()));
connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked()));
connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked()));
connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked()));
connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked()));
//connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed()));
connect(lineDate, SIGNAL(dateChanged(QDate)), SLOT(slotSetDate(QDate)));
connect(lineDate, SIGNAL(returnPressed()), SLOT(lineEnterPressed()));
table->setFocus();
}
KDatePicker::~KDatePicker()
{
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp
index fce0e5a..e827412 100644
--- a/microkde/kdatetbl.cpp
+++ b/microkde/kdatetbl.cpp
@@ -177,50 +177,54 @@ KDateTable::paintCell(QPainter *painter, int row, int col)
painter->setPen(red);
if(hasFocus())
{
painter->setBrush(darkRed);
pen=white;
} else {
painter->setBrush(darkGray);
pen=white;
}
} else {
if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos)
{
painter->setPen(green);
painter->setBrush(darkGreen);
pen=white;
} else {
painter->setBrush(QColor(220,245,255));
painter->setPen(QColor(220,245,255));
}
}
painter->drawRect(0, 0, w, h);
painter->setPen(pen);
painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect);
}
+ /*
if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width());
- if(rect.height()>maxCell.height()) maxCell.setHeight(rect.height());
+ if(rect.height()>maxCell.height()) {
+ maxCell.setHeight(rect.height());
+ }
+ */
}
void
KDateTable::keyPressEvent( QKeyEvent *e )
{
/*
// not working properly
if ( e->key() == Qt::Key_Prior ) {
if ( date.month() == 1 ) {
KNotifyClient::beep();
return;
}
int day = date.day();
if ( day > 27 )
while ( !QDate::isValid( date.year(), date.month()-1, day ) )
day--;
setDate(QDate(date.year(), date.month()-1, day));
return;
}
if ( e->key() == Qt::Key_Next ) {
if ( date.month() == 12 ) {
KNotifyClient::beep();
return;
}
@@ -292,51 +296,57 @@ KDateTable::viewportResizeEvent(QResizeEvent * e)
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);
// ----- 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()));
- if ( maxCell.width() * 1000 / maxCell.height() > 1900 )
+#endif
+ if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) {
maxCell.setHeight(maxCell.width() * 1000 / 1900 );
+ qDebug("setmax ");
+ }
}
void
KDateTable::contentsMousePressEvent(QMouseEvent *e)
{
if(e->type()!=QEvent::MouseButtonPress)
{ // the KDatePicker only reacts on mouse press events:
return;
}
if(!isEnabled())
{
KNotifyClient::beep();
return;
}
int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0;
// -----
int row, col, pos, temp;
QPoint mouseCoord;
// -----
mouseCoord = e->pos();
row=rowAt(mouseCoord.y());
col=columnAt(mouseCoord.x());
if(row<0 || col<0)
@@ -422,49 +432,49 @@ void KDateTable::focusOutEvent( QFocusEvent *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)
: QGridView(parent, name),
result(0) // invalid
{
QRect rect;
QFont font;
// -----
activeCol = -1;
activeRow = -1;
font=KGlobalSettings::generalFont();
- font.setPointSize(fontsize);
+ //font.setPointSize(fontsize);
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,70 +750,74 @@ 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)
: QGridView(parent, name),
result(0) // invalid
{
QRect rect;
QFont font;
// -----
activeCol = -1;
activeRow = -1;
font=KGlobalSettings::generalFont();
- font.setPointSize(fontsize);
+ //font.setPointSize(fontsize);
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);
+ }
}
QSize
KDateInternalWeekPicker::sizeHint() const
{
return QSize((max.width()+6)*numCols()+2*frameWidth(),
(max.height()+6)*numRows()+2*frameWidth());
}
int
KDateInternalWeekPicker::getResult() const
{
return result;
}
void
KDateInternalWeekPicker::setupPainter(QPainter *p)
{
p->setPen(black);
}
void
KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*)
{
diff --git a/microkde/kglobalsettings.cpp b/microkde/kglobalsettings.cpp
index 2fff8fc..30e793f 100644
--- a/microkde/kglobalsettings.cpp
+++ b/microkde/kglobalsettings.cpp
@@ -1,41 +1,43 @@
#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;
- return QFont("helvetica",size);
+ QFont f = QApplication::font();
+ f.setPointSize( size );
+ return f;
}
QFont KGlobalSettings::toolBarFont()
{
- return QFont("helevetica",12);
+ 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.
**/
bool KGlobalSettings::singleClick()
{
KConfig *c = KGlobal::config();
KConfigGroupSaver cgs( c, "KDE" );
return c->readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK);
}