diff --git a/CMakeLists.txt b/CMakeLists.txt index cfdb201bb..91cf02673 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -310,7 +310,62 @@ kde4_add_ui_files(kmailprivate_LIB_SRCS ui/identitypage.ui ) -kde4_add_kcfg_files(kmailprivate_LIB_SRCS +# KCFG files. The main kmail.kcfg is configured by CMake and put +# in the build directory. + +macro (KMAIL_ADD_KCFG_FILES _sources ) + if( ${ARGV1} STREQUAL "GENERATE_MOC" ) + set(_kcfg_generatemoc TRUE) + endif( ${ARGV1} STREQUAL "GENERATE_MOC" ) + + foreach (_current_FILE ${ARGN}) + + if(NOT ${_current_FILE} STREQUAL "GENERATE_MOC") + get_filename_component(_tmp_FILE ${_current_FILE} ABSOLUTE) + get_filename_component(_abs_PATH ${_tmp_FILE} PATH) + get_filename_component(_basename ${_tmp_FILE} NAME_WE) + + file(READ ${_tmp_FILE} _contents) + string(REGEX REPLACE "^(.*\n)?File=([^\n]+kcfg).*\n.*$" "\\2" _kcfg_FILE "${_contents}") + set(_src_FILE ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp) + set(_header_FILE ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h) + set(_moc_FILE ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc) + set(_kcfg_PATH ${_abs_PATH}/${_kcfg_FILE}) +# Maybe the .kcfg is a generated file? + if(NOT EXISTS "${_kcfg_PATH}") + set(_kcfg_PATH ${CMAKE_CURRENT_BINARY_DIR}/${_kcfg_FILE}) + endif(NOT EXISTS "${_kcfg_PATH}") + if(NOT EXISTS "${_kcfg_PATH}") + message(ERROR "${_kcfg_FILE} not found; tried in ${_abs_PATH} and ${CMAKE_CURRENT_BINARY_DIR}") + endif(NOT EXISTS "${_kcfg_PATH}") + +# the command for creating the source file from the kcfg file + add_custom_command(OUTPUT ${_header_FILE} ${_src_FILE} + COMMAND ${KDE4_KCFGC_EXECUTABLE} + ARGS ${_kcfg_PATH} ${_tmp_FILE} -d ${CMAKE_CURRENT_BINARY_DIR} + MAIN_DEPENDENCY ${_tmp_FILE} + DEPENDS ${_kcfg_PATH} ${_KDE4_KCONFIG_COMPILER_DEP} ) + + if(_kcfg_generatemoc) + qt4_generate_moc(${_header_FILE} ${_moc_FILE} ) + set_source_files_properties(${_src_FILE} PROPERTIES SKIP_AUTOMOC TRUE) # don't run automoc on this file + list(APPEND ${_sources} ${_moc_FILE}) + endif(_kcfg_generatemoc) + + list(APPEND ${_sources} ${_src_FILE} ${_header_FILE}) + endif(NOT ${_current_FILE} STREQUAL "GENERATE_MOC") + endforeach (_current_FILE) + +endmacro (KMAIL_ADD_KCFG_FILES) + +if(ENTERPRISE_BUILD) + set(WARN_TOOMANY_RECIPIENTS_DEFAULT true) +else(ENTERPRISE_BUILD) + set(WARN_TOOMANY_RECIPIENTS_DEFAULT false) +endif(ENTERPRISE_BUILD) +configure_file(kmail.kcfg.cmake ${CMAKE_CURRENT_BINARY_DIR}/kmail.kcfg) + +kmail_add_kcfg_files(kmailprivate_LIB_SRCS globalsettings_base.kcfgc replyphrases.kcfgc custommimeheader.kcfgc @@ -422,7 +477,7 @@ install(TARGETS kmailprivate ${INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SK install(TARGETS kmail ${INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES KMail.desktop kmail_view.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) install(FILES - kmail.kcfg + ${CMAKE_CURRENT_BINARY_DIR}/kmail.kcfg replyphrases.kcfg custommimeheader.kcfg customtemplates_kfg.kcfg @@ -465,4 +520,3 @@ install(FILES ${CMAKE_BINARY_DIR}/kmail/org.kde.kmail.mailcomposer.xml DESTINATION ${KDE4_DBUS_INTERFACES_DIR} ) - diff --git a/configuredialog.cpp b/configuredialog.cpp index b0ec0e2c6..bb1c2c253 100644 --- a/configuredialog.cpp +++ b/configuredialog.cpp @@ -20,6 +20,8 @@ * */ +#include + // my headers: #include "configuredialog.h" #include "configuredialog_p.h" @@ -2857,6 +2859,7 @@ ComposerPageGeneralTab::ComposerPageGeneralTab( QWidget * parent ) connect( mWordWrapCheck, SIGNAL(toggled(bool)), mWrapColumnSpin, SLOT(setEnabled(bool)) ); +#ifdef ENTERPRISE_BUILD // a checkbox for "too many recipient warning" and a spinbox for the recipient threshold hlay = new QHBoxLayout(); // inherits spacing vlay->addLayout( hlay ); @@ -2890,6 +2893,7 @@ ComposerPageGeneralTab::ComposerPageGeneralTab( QWidget * parent ) // only enable the spinbox if the checkbox is checked: connect( mRecipientCheck, SIGNAL(toggled(bool)), mRecipientSpin, SLOT(setEnabled(bool)) ); +#endif hlay = new QHBoxLayout(); // inherits spacing vlay->addLayout( hlay ); @@ -2905,6 +2909,7 @@ ComposerPageGeneralTab::ComposerPageGeneralTab( QWidget * parent ) connect( mAutoSave, SIGNAL( valueChanged(int) ), this, SLOT( slotEmitChanged( void ) ) ); +#ifdef ENTERPRISE_BUILD hlay = new QHBoxLayout(); // inherits spacing vlay->addLayout( hlay ); mForwardTypeCombo = new KComboBox( false, this ); @@ -2918,6 +2923,7 @@ ComposerPageGeneralTab::ComposerPageGeneralTab( QWidget * parent ) hlay->addStretch( 1 ); connect( mForwardTypeCombo, SIGNAL( activated( int ) ), this, SLOT( slotEmitChanged() ) ); +#endif hlay = new QHBoxLayout(); // inherits spacing vlay->addLayout( hlay ); @@ -2995,13 +3001,16 @@ void ComposerPage::GeneralTab::doLoadFromGlobalSettings() { mAutoRequestMDNCheck->setChecked( GlobalSettings::self()->requestMDN() ); mWordWrapCheck->setChecked( GlobalSettings::self()->wordWrap() ); mWrapColumnSpin->setValue( GlobalSettings::self()->lineWrapWidth() ); + mAutoSave->setValue( GlobalSettings::self()->autosaveInterval() ); + +#ifdef ENTERPRISE_BUILD mRecipientCheck->setChecked( GlobalSettings::self()->tooManyRecipients() ); mRecipientSpin->setValue( GlobalSettings::self()->recipientThreshold() ); - mAutoSave->setValue( GlobalSettings::self()->autosaveInterval() ); if ( GlobalSettings::self()->forwardingInlineByDefault() ) mForwardTypeCombo->setCurrentIndex( 0 ); else mForwardTypeCombo->setCurrentIndex( 1 ); +#endif // editor group: mExternalEditorCheck->setChecked( GlobalSettings::self()->useExternalEditor() ); @@ -3028,10 +3037,14 @@ void ComposerPage::GeneralTab::installProfile( KConfig * profile ) { mWordWrapCheck->setChecked( composer.readEntry( "word-wrap", false ) ); if ( composer.hasKey( "break-at" ) ) mWrapColumnSpin->setValue( composer.readEntry( "break-at", 0 ) ); + +#ifdef ENTERPRISE_BUILD if ( composer.hasKey( "too-many-recipients" ) ) mRecipientCheck->setChecked( composer.readEntry( "too-many-recipients", false ) ); if ( composer.hasKey( "recipient-threshold" ) ) mRecipientSpin->setValue( composer.readEntry( "recipient-threshold", 5 ) ); +#endif + if ( composer.hasKey( "autosave" ) ) mAutoSave->setValue( composer.readEntry( "autosave", 0 ) ); @@ -3052,10 +3065,13 @@ void ComposerPage::GeneralTab::save() { GlobalSettings::self()->setRequestMDN( mAutoRequestMDNCheck->isChecked() ); GlobalSettings::self()->setWordWrap( mWordWrapCheck->isChecked() ); GlobalSettings::self()->setLineWrapWidth( mWrapColumnSpin->value() ); + GlobalSettings::self()->setAutosaveInterval( mAutoSave->value() ); + +#ifdef ENTERPRISE_BUILD GlobalSettings::self()->setTooManyRecipients( mRecipientCheck->isChecked() ); GlobalSettings::self()->setRecipientThreshold( mRecipientSpin->value() ); - GlobalSettings::self()->setAutosaveInterval( mAutoSave->value() ); GlobalSettings::self()->setForwardingInlineByDefault( mForwardTypeCombo->currentIndex() == 0 ); +#endif // editor group: GlobalSettings::self()->setUseExternalEditor( mExternalEditorCheck->isChecked() ); diff --git a/configuredialog_p.h b/configuredialog_p.h index 043802b4a..53c4149a2 100644 --- a/configuredialog_p.h +++ b/configuredialog_p.h @@ -5,6 +5,8 @@ #ifndef _CONFIGURE_DIALOG_PRIVATE_H_ #define _CONFIGURE_DIALOG_PRIVATE_H_ +#include + #include "kmail_export.h" #include @@ -667,12 +669,14 @@ private: QCheckBox *mShowRecentAddressesInComposer; QCheckBox *mWordWrapCheck; KIntSpinBox *mWrapColumnSpin; - QCheckBox *mRecipientCheck; - KIntSpinBox *mRecipientSpin; KIntSpinBox *mAutoSave; QCheckBox *mExternalEditorCheck; KUrlRequester *mEditorRequester; +#ifdef ENTERPRISE_BUILD KComboBox *mForwardTypeCombo; + QCheckBox *mRecipientCheck; + KIntSpinBox *mRecipientSpin; +#endif }; class ComposerPageTemplatesTab : public ConfigModuleTab { diff --git a/kmail.kcfg b/kmail.kcfg.cmake similarity index 99% rename from kmail.kcfg rename to kmail.kcfg.cmake index 4f28c7022..56709c1ee 100644 --- a/kmail.kcfg +++ b/kmail.kcfg.cmake @@ -335,7 +335,7 @@ - true + ${WARN_TOOMANY_RECIPIENTS_DEFAULT} If the number of recipients is larger than this value, KMail will warn and ask for a confirmation before sending the mail. The warning can be turned off.