-rw-r--r-- | libkdepim/kdateedit.cpp | 1 | ||||
-rw-r--r-- | microkde/kdialogbase.cpp | 7 |
2 files changed, 6 insertions, 2 deletions
diff --git a/libkdepim/kdateedit.cpp b/libkdepim/kdateedit.cpp index 946fc0d..3d9e690 100644 --- a/libkdepim/kdateedit.cpp +++ b/libkdepim/kdateedit.cpp | |||
@@ -38,96 +38,97 @@ | |||
38 | #include <qpalette.h> | 38 | #include <qpalette.h> |
39 | 39 | ||
40 | #include "kdateedit.h" | 40 | #include "kdateedit.h" |
41 | //#include "kdateedit.moc" | 41 | //#include "kdateedit.moc" |
42 | 42 | ||
43 | KDateEdit::KDateEdit(QWidget *parent, const char *name, bool withoutDP ) | 43 | KDateEdit::KDateEdit(QWidget *parent, const char *name, bool withoutDP ) |
44 | : QHBox(parent, name) | 44 | : QHBox(parent, name) |
45 | { | 45 | { |
46 | dateFormShort = true; | 46 | dateFormShort = true; |
47 | withoutDp = withoutDP; | 47 | withoutDp = withoutDP; |
48 | mDateEdit = new QLineEdit(this); | 48 | mDateEdit = new QLineEdit(this); |
49 | mDateEdit->setText(KGlobal::locale()->formatDate(QDate::currentDate(),dateFormShort)); | 49 | mDateEdit->setText(KGlobal::locale()->formatDate(QDate::currentDate(),dateFormShort)); |
50 | setFocusProxy(mDateEdit); | 50 | setFocusProxy(mDateEdit); |
51 | mDateEdit->installEventFilter(this); | 51 | mDateEdit->installEventFilter(this); |
52 | 52 | ||
53 | // Highlight Background and Textcolor | 53 | // Highlight Background and Textcolor |
54 | QPalette palette = QWidget::palette(); | 54 | QPalette palette = QWidget::palette(); |
55 | unsigned char red, green, blue; | 55 | unsigned char red, green, blue; |
56 | red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10; | 56 | red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10; |
57 | green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10; | 57 | green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10; |
58 | blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10; | 58 | blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10; |
59 | palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) ); | 59 | palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) ); |
60 | palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) ); | 60 | palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) ); |
61 | mDateEdit->setPalette( palette ); | 61 | mDateEdit->setPalette( palette ); |
62 | 62 | ||
63 | if ( withoutDP ) { | 63 | if ( withoutDP ) { |
64 | mDateFrame = 0; | 64 | mDateFrame = 0; |
65 | mDateButton = 0; | 65 | mDateButton = 0; |
66 | mDatePicker = 0; | 66 | mDatePicker = 0; |
67 | } else { | 67 | } else { |
68 | QPixmap pixmap = SmallIcon("smallcal"); | 68 | QPixmap pixmap = SmallIcon("smallcal"); |
69 | mDateButton = new QPushButton(this); | 69 | mDateButton = new QPushButton(this); |
70 | mDateButton->setPixmap(pixmap); | 70 | mDateButton->setPixmap(pixmap); |
71 | 71 | ||
72 | mDateFrame = new QVBox(0,0,WType_Popup); | 72 | mDateFrame = new QVBox(0,0,WType_Popup); |
73 | // mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 73 | // mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
74 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 74 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
75 | mDateFrame->setLineWidth(3); | 75 | mDateFrame->setLineWidth(3); |
76 | mDateFrame->hide(); | 76 | mDateFrame->hide(); |
77 | 77 | ||
78 | mDatePicker = new KDatePicker(mDateFrame,QDate::currentDate()); | 78 | mDatePicker = new KDatePicker(mDateFrame,QDate::currentDate()); |
79 | connect(mDatePicker,SIGNAL(dateEntered(QDate)),SLOT(setDate(QDate))); | 79 | connect(mDatePicker,SIGNAL(dateEntered(QDate)),SLOT(setDate(QDate))); |
80 | connect(mDatePicker,SIGNAL(dateEntered(QDate)),SIGNAL(dateChanged(QDate))); | 80 | connect(mDatePicker,SIGNAL(dateEntered(QDate)),SIGNAL(dateChanged(QDate))); |
81 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(setDate(QDate))); | 81 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(setDate(QDate))); |
82 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SIGNAL(dateChanged(QDate))); | 82 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SIGNAL(dateChanged(QDate))); |
83 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),mDateFrame,SLOT(hide())); | 83 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),mDateFrame,SLOT(hide())); |
84 | connect(mDateButton,SIGNAL(clicked()),SLOT(toggleDatePicker())); | 84 | connect(mDateButton,SIGNAL(clicked()),SLOT(toggleDatePicker())); |
85 | mDateButton->setFocusPolicy( QWidget::NoFocus ); | 85 | mDateButton->setFocusPolicy( QWidget::NoFocus ); |
86 | mDateButton->setAutoDefault( false ); | ||
86 | //mDateFrame->resize( 400, 300 ); | 87 | //mDateFrame->resize( 400, 300 ); |
87 | 88 | ||
88 | } | 89 | } |
89 | connect(mDateEdit,SIGNAL(returnPressed()),SLOT(lineEnterPressed())); | 90 | connect(mDateEdit,SIGNAL(returnPressed()),SLOT(lineEnterPressed())); |
90 | connect(mDateEdit,SIGNAL(textChanged(const QString &)), | 91 | connect(mDateEdit,SIGNAL(textChanged(const QString &)), |
91 | SLOT(textChanged(const QString &))); | 92 | SLOT(textChanged(const QString &))); |
92 | 93 | ||
93 | // Create the keyword list. This will be used to match against when the user | 94 | // Create the keyword list. This will be used to match against when the user |
94 | // enters information. | 95 | // enters information. |
95 | mKeywordMap[i18n("tomorrow")] = 1; | 96 | mKeywordMap[i18n("tomorrow")] = 1; |
96 | mKeywordMap[i18n("today")] = 0; | 97 | mKeywordMap[i18n("today")] = 0; |
97 | mKeywordMap[i18n("yesterday")] = -1; | 98 | mKeywordMap[i18n("yesterday")] = -1; |
98 | 99 | ||
99 | /* | 100 | /* |
100 | * This loop uses some math tricks to figure out the offset in days | 101 | * This loop uses some math tricks to figure out the offset in days |
101 | * to the next date the given day of the week occurs. There | 102 | * to the next date the given day of the week occurs. There |
102 | * are two cases, that the new day is >= the current day, which means | 103 | * are two cases, that the new day is >= the current day, which means |
103 | * the new day has not occured yet or that the new day < the current day, | 104 | * the new day has not occured yet or that the new day < the current day, |
104 | * which means the new day is already passed (so we need to find the | 105 | * which means the new day is already passed (so we need to find the |
105 | * day in the next week). | 106 | * day in the next week). |
106 | */ | 107 | */ |
107 | QString dayName; | 108 | QString dayName; |
108 | int currentDay = QDate::currentDate().dayOfWeek(); | 109 | int currentDay = QDate::currentDate().dayOfWeek(); |
109 | for (int i = 1; i <= 7; ++i) | 110 | for (int i = 1; i <= 7; ++i) |
110 | { | 111 | { |
111 | dayName = KGlobal::locale()->weekDayName(i).lower(); | 112 | dayName = KGlobal::locale()->weekDayName(i).lower(); |
112 | if (i >= currentDay) | 113 | if (i >= currentDay) |
113 | mKeywordMap[dayName] = i - currentDay; | 114 | mKeywordMap[dayName] = i - currentDay; |
114 | else | 115 | else |
115 | mKeywordMap[dayName] = 7 - currentDay + i; | 116 | mKeywordMap[dayName] = 7 - currentDay + i; |
116 | } | 117 | } |
117 | 118 | ||
118 | mTextChanged = false; | 119 | mTextChanged = false; |
119 | mHandleInvalid = false; | 120 | mHandleInvalid = false; |
120 | // QWidget::setTabOrder( mDateEdit, mDateButton ); | 121 | // QWidget::setTabOrder( mDateEdit, mDateButton ); |
121 | } | 122 | } |
122 | 123 | ||
123 | KDateEdit::~KDateEdit() | 124 | KDateEdit::~KDateEdit() |
124 | { | 125 | { |
125 | delete mDateFrame; | 126 | delete mDateFrame; |
126 | } | 127 | } |
127 | void KDateEdit::clear() | 128 | void KDateEdit::clear() |
128 | { | 129 | { |
129 | bool b = mDateEdit->signalsBlocked(); | 130 | bool b = mDateEdit->signalsBlocked(); |
130 | mDateEdit->blockSignals(true); | 131 | mDateEdit->blockSignals(true); |
131 | mDateEdit->setText(""); | 132 | mDateEdit->setText(""); |
132 | mDateEdit->blockSignals(b); | 133 | mDateEdit->blockSignals(b); |
133 | } | 134 | } |
diff --git a/microkde/kdialogbase.cpp b/microkde/kdialogbase.cpp index d1f7630..801094a 100644 --- a/microkde/kdialogbase.cpp +++ b/microkde/kdialogbase.cpp | |||
@@ -1,124 +1,127 @@ | |||
1 | #include <qtabwidget.h> | 1 | #include <qtabwidget.h> |
2 | #include <qpushbutton.h> | 2 | #include <qpushbutton.h> |
3 | #include <qlayout.h> | 3 | #include <qlayout.h> |
4 | #include <qframe.h> | 4 | #include <qframe.h> |
5 | 5 | ||
6 | 6 | ||
7 | #include "klocale.h" | 7 | #include "klocale.h" |
8 | #include "kdebug.h" | 8 | #include "kdebug.h" |
9 | 9 | ||
10 | #include "kdialogbase.h" | 10 | #include "kdialogbase.h" |
11 | 11 | ||
12 | KDialogBase::KDialogBase() | 12 | KDialogBase::KDialogBase() |
13 | { | 13 | { |
14 | } | 14 | } |
15 | 15 | ||
16 | KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal, | 16 | KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal, |
17 | const QString &caption, | 17 | const QString &caption, |
18 | int buttonMask, ButtonCode defaultButton, | 18 | int buttonMask, ButtonCode defaultButton, |
19 | bool separator, | 19 | bool separator, |
20 | const QString &user1, | 20 | const QString &user1, |
21 | const QString &user2, | 21 | const QString &user2, |
22 | const QString &user3) : | 22 | const QString &user3) : |
23 | KDialog( parent, name, modal ) | 23 | KDialog( parent, name, modal ) |
24 | { | 24 | { |
25 | init( caption, buttonMask, user1, user2 ); | 25 | init( caption, buttonMask, user1, user2 ); |
26 | if (findButton( defaultButton ) ) | 26 | if (findButton( defaultButton ) ) { |
27 | (findButton( defaultButton ) )->setFocus(); | 27 | (findButton( defaultButton ) )->setFocus(); |
28 | (findButton( defaultButton ) )->setDefault( true ); | ||
29 | } | ||
28 | 30 | ||
29 | } | 31 | } |
30 | 32 | ||
31 | KDialogBase::KDialogBase( int dialogFace, const QString &caption, | 33 | KDialogBase::KDialogBase( int dialogFace, const QString &caption, |
32 | int buttonMask, ButtonCode defaultButton, | 34 | int buttonMask, ButtonCode defaultButton, |
33 | QWidget *parent, const char *name, bool modal, | 35 | QWidget *parent, const char *name, bool modal, |
34 | bool separator, | 36 | bool separator, |
35 | const QString &user1, | 37 | const QString &user1, |
36 | const QString &user2, | 38 | const QString &user2, |
37 | const QString &user3) : | 39 | const QString &user3) : |
38 | KDialog( parent, name, modal ) | 40 | KDialog( parent, name, modal ) |
39 | { | 41 | { |
40 | init( caption, buttonMask, user1, user2 ); | 42 | init( caption, buttonMask, user1, user2 ); |
41 | if (findButton( defaultButton ) ) | 43 | if (findButton( defaultButton ) ) |
42 | (findButton( defaultButton ) )->setFocus(); | 44 | (findButton( defaultButton ) )->setFocus(); |
43 | 45 | ||
44 | } | 46 | } |
45 | 47 | ||
46 | KDialogBase::~KDialogBase() | 48 | KDialogBase::~KDialogBase() |
47 | { | 49 | { |
48 | } | 50 | } |
49 | 51 | ||
50 | void KDialogBase::init( const QString &caption, int buttonMask, | 52 | void KDialogBase::init( const QString &caption, int buttonMask, |
51 | const QString &user1 ,const QString &user2 ) | 53 | const QString &user1 ,const QString &user2 ) |
52 | { | 54 | { |
53 | mMainWidget = 0; | 55 | mMainWidget = 0; |
54 | mTabWidget = 0; | 56 | mTabWidget = 0; |
55 | mPlainPage = 0; | 57 | mPlainPage = 0; |
56 | mTopLayout = 0; | 58 | mTopLayout = 0; |
57 | if ( !caption.isEmpty() ) { | 59 | if ( !caption.isEmpty() ) { |
58 | setCaption( caption ); | 60 | setCaption( caption ); |
59 | } | 61 | } |
60 | 62 | ||
61 | if ( buttonMask & User1 ) { | 63 | if ( buttonMask & User1 ) { |
62 | mUser1Button = new QPushButton( user1, this ); | 64 | mUser1Button = new QPushButton( user1, this ); |
63 | connect( mUser1Button, SIGNAL( clicked() ), SLOT( slotUser1() ) ); | 65 | connect( mUser1Button, SIGNAL( clicked() ), SLOT( slotUser1() ) ); |
64 | } else { | 66 | } else { |
65 | mUser1Button = 0; | 67 | mUser1Button = 0; |
66 | } | 68 | } |
67 | if ( buttonMask & User2 ) { | 69 | if ( buttonMask & User2 ) { |
68 | mUser2Button = new QPushButton( user2, this ); | 70 | mUser2Button = new QPushButton( user2, this ); |
69 | connect( mUser2Button, SIGNAL( clicked() ), SLOT( slotUser2() ) ); | 71 | connect( mUser2Button, SIGNAL( clicked() ), SLOT( slotUser2() ) ); |
70 | } else { | 72 | } else { |
71 | mUser2Button = 0; | 73 | mUser2Button = 0; |
72 | } | 74 | } |
73 | 75 | ||
74 | if ( buttonMask & Ok ) { | 76 | if ( buttonMask & Ok ) { |
75 | mOkButton = new QPushButton( i18n("Ok"), this ); | 77 | mOkButton = new QPushButton( i18n("Ok"), this ); |
76 | connect( mOkButton, SIGNAL( clicked() ), SLOT( slotOk() ) ); | 78 | connect( mOkButton, SIGNAL( clicked() ), SLOT( slotOk() ) ); |
79 | mOkButton->setDefault( true ); | ||
77 | } else { | 80 | } else { |
78 | mOkButton = 0; | 81 | mOkButton = 0; |
79 | } | 82 | } |
80 | if ( buttonMask & Default ) { | 83 | if ( buttonMask & Default ) { |
81 | mDefaultButton = new QPushButton( i18n("Default"), this ); | 84 | mDefaultButton = new QPushButton( i18n("Default"), this ); |
82 | connect( mDefaultButton, SIGNAL( clicked() ), SIGNAL( defaultClicked() ) ); | 85 | connect( mDefaultButton, SIGNAL( clicked() ), SIGNAL( defaultClicked() ) ); |
83 | } else { | 86 | } else { |
84 | mDefaultButton = 0; | 87 | mDefaultButton = 0; |
85 | } | 88 | } |
86 | 89 | ||
87 | if ( buttonMask & Apply ) { | 90 | if ( buttonMask & Apply ) { |
88 | mApplyButton = new QPushButton( i18n("Apply"), this ); | 91 | mApplyButton = new QPushButton( i18n("Apply"), this ); |
89 | connect( mApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) ); | 92 | connect( mApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) ); |
90 | } else { | 93 | } else { |
91 | mApplyButton = 0; | 94 | mApplyButton = 0; |
92 | } | 95 | } |
93 | 96 | ||
94 | if ( buttonMask & Cancel ) { | 97 | if ( buttonMask & Cancel ) { |
95 | mCancelButton = new QPushButton( i18n("Cancel"), this ); | 98 | mCancelButton = new QPushButton( i18n("Cancel"), this ); |
96 | connect( mCancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ) ); | 99 | connect( mCancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ) ); |
97 | } else { | 100 | } else { |
98 | mCancelButton = 0; | 101 | mCancelButton = 0; |
99 | } | 102 | } |
100 | 103 | ||
101 | if ( buttonMask & Close ) { | 104 | if ( buttonMask & Close ) { |
102 | mCloseButton = new QPushButton( i18n("Close"), this ); | 105 | mCloseButton = new QPushButton( i18n("Close"), this ); |
103 | connect( mCloseButton, SIGNAL( clicked() ), SLOT( slotClose() ) ); | 106 | connect( mCloseButton, SIGNAL( clicked() ), SLOT( slotClose() ) ); |
104 | } else { | 107 | } else { |
105 | mCloseButton = 0; | 108 | mCloseButton = 0; |
106 | } | 109 | } |
107 | } | 110 | } |
108 | 111 | ||
109 | QTabWidget *KDialogBase::tabWidget() | 112 | QTabWidget *KDialogBase::tabWidget() |
110 | { | 113 | { |
111 | if ( !mTabWidget ) { | 114 | if ( !mTabWidget ) { |
112 | mTabWidget = new QTabWidget( this ); | 115 | mTabWidget = new QTabWidget( this ); |
113 | setMainWidget( mTabWidget ); | 116 | setMainWidget( mTabWidget ); |
114 | } | 117 | } |
115 | return mTabWidget; | 118 | return mTabWidget; |
116 | } | 119 | } |
117 | 120 | ||
118 | void KDialogBase::hideButtons() | 121 | void KDialogBase::hideButtons() |
119 | { | 122 | { |
120 | if ( mUser1Button ) mUser1Button->hide() ; | 123 | if ( mUser1Button ) mUser1Button->hide() ; |
121 | if ( mUser2Button ) mUser2Button->hide() ; | 124 | if ( mUser2Button ) mUser2Button->hide() ; |
122 | if ( mOkButton ) mOkButton->hide() ; | 125 | if ( mOkButton ) mOkButton->hide() ; |
123 | if ( mApplyButton ) mApplyButton->hide() ; | 126 | if ( mApplyButton ) mApplyButton->hide() ; |
124 | if ( mDefaultButton ) mDefaultButton->hide(); | 127 | if ( mDefaultButton ) mDefaultButton->hide(); |