-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 83 | ||||
-rw-r--r-- | microkde/kdialog.cpp | 12 |
2 files changed, 32 insertions, 63 deletions
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index bedc75a..bf81b01 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp @@ -54,157 +54,164 @@ RecurBase::RecurBase( QWidget *parent, const char *name ) : QWidget( parent, name ) { mFrequencyEdit = new QSpinBox( 1, 9999, 1, this ); mFrequencyEdit->setValue( 1 ); } QWidget *RecurBase::frequencyEdit() { return mFrequencyEdit; } void RecurBase::setFrequency( int f ) { if ( f < 1 ) f = 1; mFrequencyEdit->setValue( f ); } int RecurBase::frequency() { return mFrequencyEdit->value(); } /////////////////////////// RecurDaily /////////////////////////////// RecurDaily::RecurDaily( QWidget *parent, const char *name ) : RecurBase( parent, name ) { QBoxLayout *topLayout = new QHBoxLayout( this ); topLayout->setSpacing( KDialog::spacingHint() ); + topLayout->setMargin( KDialog::marginHintSmall() ); QLabel *preLabel = new QLabel( i18n("Recur every"), this ); topLayout->addWidget( preLabel ); topLayout->addWidget( frequencyEdit() ); QLabel *postLabel = new QLabel( i18n("day(s)"), this ); topLayout->addWidget( postLabel ); } /////////////////////////// RecurWeekly /////////////////////////////// RecurWeekly::RecurWeekly( QWidget *parent, const char *name ) : RecurBase( parent, name ) { QBoxLayout *topLayout = new QVBoxLayout( this ); topLayout->setSpacing( KDialog::spacingHint() ); + topLayout->setMargin( KDialog::marginHintSmall() ); - topLayout->addStretch( 1 ); + //topLayout->addStretch( 1 ); QBoxLayout *weeksLayout = new QHBoxLayout( topLayout ); QLabel *preLabel = new QLabel( i18n("Recur every"), this ); weeksLayout->addWidget( preLabel ); weeksLayout->addWidget( frequencyEdit() ); QLabel *postLabel = new QLabel( i18n("week(s) on:"), this ); weeksLayout->addWidget( postLabel ); QHBox *dayBox = new QHBox( this ); topLayout->addWidget( dayBox, 1, AlignVCenter ); // TODO: Respect start of week setting for ( int i = 0; i < 7; ++i ) { QString weekDayName = KGlobal::locale()->weekDayName( i + 1, true ); - if ( KOPrefs::instance()->mCompactDialogs ) { - weekDayName = weekDayName.left( 1 ); + int left = 1; + if ( QApplication::desktop()->width() > 480 ) { + ++left; + if ( QApplication::desktop()->width() > 640 ) + ++left; } - mDayBoxes[ i ] = new QCheckBox( weekDayName, dayBox ); + mDayBoxes[ i ] = new QCheckBox( weekDayName.left( left ), dayBox ); } - topLayout->addStretch( 1 ); + topLayout->addStretch( ); } void RecurWeekly::setDays( const QBitArray &days ) { for ( int i = 0; i < 7; ++i ) { mDayBoxes[ i ]->setChecked( days.testBit( i ) ); } } QBitArray RecurWeekly::days() { QBitArray days( 7 ); for ( int i = 0; i < 7; ++i ) { days.setBit( i, mDayBoxes[ i ]->isChecked() ); } return days; } /////////////////////////// RecurMonthly /////////////////////////////// RecurMonthly::RecurMonthly( QWidget *parent, const char *name ) : RecurBase( parent, name ) { QBoxLayout *topLayout = new QVBoxLayout( this ); topLayout->setSpacing( KDialog::spacingHint() ); + topLayout->setMargin( KDialog::marginHintSmall() ); QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); QLabel *preLabel = new QLabel( i18n("every"), this ); freqLayout->addWidget( preLabel ); freqLayout->addWidget( frequencyEdit() ); QLabel *postLabel = new QLabel( i18n("month(s)"), this ); freqLayout->addWidget( postLabel ); QButtonGroup *buttonGroup = new QButtonGroup( this ); buttonGroup->setFrameStyle( QFrame::NoFrame ); topLayout->addWidget( buttonGroup, 1, AlignVCenter ); QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 ); buttonLayout->setSpacing( KDialog::spacingHint() ); + buttonLayout->setMargin( KDialog::marginHintSmall() ); QString recurOnText; - if ( !KOPrefs::instance()->mCompactDialogs ) { + if ( QApplication::desktop()->width() > 320 ) { recurOnText = i18n("Recur on the"); } mByDayRadio = new QRadioButton( recurOnText, buttonGroup ); buttonLayout->addWidget( mByDayRadio, 0, 0 ); mByDayCombo = new QComboBox( buttonGroup ); mByDayCombo->setSizeLimit( 7 ); mByDayCombo->insertItem( i18n("1st") ); mByDayCombo->insertItem( i18n("2nd") ); mByDayCombo->insertItem( i18n("3rd") ); mByDayCombo->insertItem( i18n("4th") ); mByDayCombo->insertItem( i18n("5th") ); mByDayCombo->insertItem( i18n("6th") ); mByDayCombo->insertItem( i18n("7th") ); mByDayCombo->insertItem( i18n("8th") ); mByDayCombo->insertItem( i18n("9th") ); mByDayCombo->insertItem( i18n("10th") ); mByDayCombo->insertItem( i18n("11th") ); mByDayCombo->insertItem( i18n("12th") ); mByDayCombo->insertItem( i18n("13th") ); mByDayCombo->insertItem( i18n("14th") ); mByDayCombo->insertItem( i18n("15th") ); mByDayCombo->insertItem( i18n("16th") ); mByDayCombo->insertItem( i18n("17th") ); mByDayCombo->insertItem( i18n("18th") ); mByDayCombo->insertItem( i18n("19th") ); mByDayCombo->insertItem( i18n("20th") ); mByDayCombo->insertItem( i18n("21st") ); mByDayCombo->insertItem( i18n("22nd") ); mByDayCombo->insertItem( i18n("23rd") ); mByDayCombo->insertItem( i18n("24th") ); @@ -259,64 +266,65 @@ void RecurMonthly::setByPos( int count, int weekday ) bool RecurMonthly::byDay() { return mByDayRadio->isChecked(); } bool RecurMonthly::byPos() { return mByPosRadio->isChecked(); } int RecurMonthly::day() { return mByDayCombo->currentItem() + 1; } int RecurMonthly::count() { return mByPosCountCombo->currentItem() + 1; } int RecurMonthly::weekday() { return mByPosWeekdayCombo->currentItem(); } /////////////////////////// RecurYearly /////////////////////////////// RecurYearly::RecurYearly( QWidget *parent, const char *name ) : RecurBase( parent, name ) { QBoxLayout *topLayout = new QVBoxLayout( this ); topLayout->setSpacing( KDialog::spacingHint() ); + topLayout->setMargin( KDialog::marginHintSmall() ); QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); QLabel *preLabel = new QLabel( i18n("every"), this ); freqLayout->addWidget( preLabel ); freqLayout->addWidget( frequencyEdit() ); QLabel *postLabel = new QLabel( i18n("year(s)"), this ); freqLayout->addWidget( postLabel ); QButtonGroup *buttonGroup = new QButtonGroup( this ); buttonGroup->setFrameStyle( QFrame::NoFrame ); topLayout->addWidget( buttonGroup, 1, AlignVCenter ); QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 2, 3 ); mByMonthRadio = new QRadioButton( i18n("On day "), buttonGroup); buttonLayout->addWidget( mByMonthRadio, 0, 0 , Qt::AlignRight); mByDayLabel = new QLabel( i18n("%1 of ").arg(1), buttonGroup ); buttonLayout->addWidget( mByDayLabel, 0, 1 ); mByMonthCombo = new QComboBox( buttonGroup ); mByMonthCombo->insertItem( i18n("January") ); mByMonthCombo->insertItem( i18n("February") ); mByMonthCombo->insertItem( i18n("March") ); mByMonthCombo->insertItem( i18n("April") ); mByMonthCombo->insertItem( i18n("May") ); mByMonthCombo->insertItem( i18n("June") ); mByMonthCombo->insertItem( i18n("July") ); @@ -476,98 +484,99 @@ ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) : } void ExceptionsDialog::setDefaults( const QDateTime &from ) { mExceptions->setDefaults( from ); } void ExceptionsDialog::setDates( const DateList &dates ) { mExceptions->setDates( dates ); } DateList ExceptionsDialog::dates() { return mExceptions->dates(); } ///////////////////////// RecurrenceRangeWidget /////////////////////////// RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent, const char *name ) : QWidget( parent, name ) { QBoxLayout *topLayout = new QVBoxLayout( this ); mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"), this ); topLayout->addWidget( mRangeGroupBox ); QWidget *rangeBox = new QWidget( mRangeGroupBox ); QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox ); rangeLayout->setSpacing( KDialog::spacingHint() ); + rangeLayout->setMargin( KDialog::marginHintSmall() ); mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox ); rangeLayout->addWidget( mStartDateLabel ); QButtonGroup *rangeButtonGroup = new QButtonGroup; mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox ); rangeButtonGroup->insert( mNoEndDateButton ); rangeLayout->addWidget( mNoEndDateButton ); QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout ); durationLayout->setSpacing( KDialog::spacingHint() ); mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox ); rangeButtonGroup->insert( mEndDurationButton ); durationLayout->addWidget( mEndDurationButton ); mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox ); durationLayout->addWidget( mEndDurationEdit ); QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox ); durationLayout ->addWidget( endDurationLabel ); QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout ); endDateLayout->setSpacing( KDialog::spacingHint() ); mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox ); rangeButtonGroup->insert( mEndDateButton ); endDateLayout->addWidget( mEndDateButton ); mEndDateEdit = new KDateEdit( rangeBox ); endDateLayout->addWidget( mEndDateEdit ); - endDateLayout->addStretch( 1 ); + //endDateLayout->addStretch( 1 ); connect( mNoEndDateButton, SIGNAL( toggled( bool ) ), SLOT( showCurrentRange() ) ); connect( mEndDurationButton, SIGNAL( toggled( bool ) ), SLOT( showCurrentRange() ) ); connect( mEndDateButton, SIGNAL( toggled( bool ) ), SLOT( showCurrentRange() ) ); } void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) { mNoEndDateButton->setChecked( true ); setDateTimes( from ); mEndDateEdit->setDate( from.date() ); } void RecurrenceRangeWidget::setDuration( int duration ) { if ( duration == -1 ) { mNoEndDateButton->setChecked( true ); } else if ( duration == 0 ) { mEndDateButton->setChecked( true ); } else { mEndDurationButton->setChecked( true ); mEndDurationEdit->setValue( duration ); } } int RecurrenceRangeWidget::duration() { if ( mNoEndDateButton->isChecked() ) { @@ -622,242 +631,194 @@ void RecurrenceRangeDialog::setDefaults( const QDateTime &from ) void RecurrenceRangeDialog::setDuration( int duration ) { mRecurrenceRangeWidget->setDuration( duration ); } int RecurrenceRangeDialog::duration() { return mRecurrenceRangeWidget->duration(); } void RecurrenceRangeDialog::setEndDate( const QDate &date ) { mRecurrenceRangeWidget->setEndDate( date ); } QDate RecurrenceRangeDialog::endDate() { return mRecurrenceRangeWidget->endDate(); } void RecurrenceRangeDialog::setDateTimes( const QDateTime &start, const QDateTime &end ) { mRecurrenceRangeWidget->setDateTimes( start, end ); } //////////////////////////// RecurrenceChooser //////////////////////// RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : QWidget( parent, name ) { - QBoxLayout *topLayout = new QVBoxLayout( this ); + QBoxLayout *topLayout = new QVBoxLayout( this ); - if ( KOPrefs::instance()->mCompactDialogs ) { mTypeCombo = new QComboBox( this ); mTypeCombo->insertItem( i18n("Daily") ); mTypeCombo->insertItem( i18n("Weekly") ); mTypeCombo->insertItem( i18n("Monthly") ); mTypeCombo->insertItem( i18n("Yearly") ); topLayout->addWidget( mTypeCombo ); connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); - } else { - mTypeCombo = 0; - - QButtonGroup *ruleButtonGroup = new QButtonGroup( 1, Horizontal, this ); - ruleButtonGroup->setFrameStyle( QFrame::NoFrame ); - topLayout->addWidget( ruleButtonGroup ); - - mDailyButton = new QRadioButton( i18n("Daily"), ruleButtonGroup ); - mWeeklyButton = new QRadioButton( i18n("Weekly"), ruleButtonGroup ); - mMonthlyButton = new QRadioButton( i18n("Monthly"), ruleButtonGroup ); - mYearlyButton = new QRadioButton( i18n("Yearly"), ruleButtonGroup ); - - connect( mDailyButton, SIGNAL( toggled( bool ) ), - SLOT( emitChoice() ) ); - connect( mWeeklyButton, SIGNAL( toggled( bool ) ), - SLOT( emitChoice() ) ); - connect( mMonthlyButton, SIGNAL( toggled( bool ) ), - SLOT( emitChoice() ) ); - connect( mYearlyButton, SIGNAL( toggled( bool ) ), - SLOT( emitChoice() ) ); - } + } int RecurrenceChooser::type() { if ( mTypeCombo ) { return mTypeCombo->currentItem(); } else { if ( mDailyButton->isChecked() ) return Daily; else if ( mWeeklyButton->isChecked() ) return Weekly; else if ( mMonthlyButton->isChecked() ) return Monthly; else return Yearly; } } void RecurrenceChooser::setType( int type ) { if ( mTypeCombo ) { mTypeCombo->setCurrentItem( type ); } else { switch ( type ) { case Daily: mDailyButton->setChecked( true ); break; case Weekly: mWeeklyButton->setChecked( true ); break; case Monthly: mMonthlyButton->setChecked( true ); break; case Yearly: default: mYearlyButton->setChecked( true ); break; } } } void RecurrenceChooser::emitChoice() { emit chosen ( type() ); } /////////////////////////////// Main Widget ///////////////////////////// KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : QWidget( parent, name ) { QGridLayout *topLayout = new QGridLayout( this, 2,2 ); topLayout->setSpacing( KDialog::spacingHint() ); + topLayout->setMargin( KDialog::marginHintSmall() ); mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); connect( mEnabledCheck, SIGNAL( toggled( bool ) ), SLOT( setEnabled( bool ) ) ); topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Appointment Time "), this ); topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); - if ( KOPrefs::instance()->mCompactDialogs ) { + if ( QApplication::desktop()->width() <= 320) { mTimeGroupBox->hide(); } // QFrame *timeFrame = new QFrame( mTimeGroupBox ); // QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); // layoutTimeFrame->setSpacing( KDialog::spacingHint() ); mDateTimeLabel = new QLabel( mTimeGroupBox ); // mDateTimeLabel = new QLabel( timeFrame ); // layoutTimeFrame->addWidget( mDateTimeLabel ); - Qt::Orientation orientation; - if ( KOPrefs::instance()->mCompactDialogs ) orientation = Horizontal; - else orientation = Vertical; - - mRuleBox = new QGroupBox( 1, orientation, i18n("Recurrence Rule"), this ); - if ( KOPrefs::instance()->mCompactDialogs ) { - topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); - } else { - topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); - } + mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this ); + topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), SLOT( showCurrentRule( int ) ) ); - if ( !KOPrefs::instance()->mCompactDialogs ) { - QFrame *ruleSepFrame = new QFrame( mRuleBox ); - ruleSepFrame->setFrameStyle( QFrame::VLine | QFrame::Sunken ); - } mRuleStack = new QWidgetStack( mRuleBox ); mDaily = new RecurDaily( mRuleStack ); mRuleStack->addWidget( mDaily, 0 ); mWeekly = new RecurWeekly( mRuleStack ); mRuleStack->addWidget( mWeekly, 0 ); mMonthly = new RecurMonthly( mRuleStack ); mRuleStack->addWidget( mMonthly, 0 ); mYearly = new RecurYearly( mRuleStack ); mRuleStack->addWidget( mYearly, 0 ); showCurrentRule( mRecurrenceChooser->type() ); - - if ( KOPrefs::instance()->mCompactDialogs ) { mRecurrenceRangeWidget = 0; mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); mRecurrenceRange = mRecurrenceRangeDialog; mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), this ); connect( mRecurrenceRangeButton, SIGNAL( clicked() ), SLOT( showRecurrenceRangeDialog() ) ); mExceptionsWidget = 0; mExceptionsDialog = new ExceptionsDialog( this ); mExceptions = mExceptionsDialog; mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); if ( QApplication::desktop()->width() < 320 ) { topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); } else { topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); topLayout->addWidget( mExceptionsButton, 3, 1 ); } connect( mExceptionsButton, SIGNAL( clicked() ), SLOT( showExceptionsDialog() ) ); - - } else { - mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); - mRecurrenceRangeDialog = 0; - mRecurrenceRange = mRecurrenceRangeWidget; - mRecurrenceRangeButton = 0; - topLayout->addWidget( mRecurrenceRangeWidget, 3, 0 ); - - mExceptionsWidget = new ExceptionsWidget( this ); - mExceptionsDialog = 0; - mExceptions = mExceptionsWidget; - mExceptionsButton = 0; - topLayout->addWidget( mExceptionsWidget, 3, 1 ); - } } KOEditorRecurrence::~KOEditorRecurrence() { } void KOEditorRecurrence::setEnabled( bool enabled ) { // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; mTimeGroupBox->setEnabled( enabled ); if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); mRuleBox->setEnabled( enabled ); } void KOEditorRecurrence::showCurrentRule( int current ) { switch ( current ) { case Daily: mRuleStack->raiseWidget( mDaily ); break; case Weekly: mRuleStack->raiseWidget( mWeekly ); break; case Monthly: mRuleStack->raiseWidget( mMonthly ); break; default: case Yearly: diff --git a/microkde/kdialog.cpp b/microkde/kdialog.cpp index 3d62cdd..961631e 100644 --- a/microkde/kdialog.cpp +++ b/microkde/kdialog.cpp @@ -1,17 +1,25 @@ #include <kdialog.h> #include <qapp.h> KDialog::KDialog( QWidget *parent, const char *name, bool modal ) : QDialog( parent, name, modal ) { ; } +#ifdef DESKTOP_VERSION +int KDialog::spacingHint() { return 7; } +int KDialog::marginHint() { return 7; } +int KDialog::spacingHintSmall() { return 4; } +int KDialog::marginHintSmall() { return 4; } + +#else int KDialog::spacingHint() { return 3; } int KDialog::marginHint() { return 3; } -int KDialog::spacingHintSmall() { if (QApplication::desktop()->width() < 700 ) return 1;else return 3; } -int KDialog::marginHintSmall() { if (QApplication::desktop()->width() < 700 ) return 1;else return 3; } +int KDialog::spacingHintSmall() { return 1; } +int KDialog::marginHintSmall() { return 1; } +#endif |