Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 174f45fc authored by Ralf Habacker's avatar Ralf Habacker

Merge duplicated code for handling foot chooser into class MultiPageDialogBase

Font chooser code was duplicated in class SettingsDialog and UmlViewDialog.
parent cfe2f4b7
......@@ -392,14 +392,13 @@ KPageWidgetItem *MultiPageDialogBase::setupFontPage(AssociationWidget *widget)
}
/**
* updates the font page data
* @param widget Widget to save the font data into
* Set the font page to show the font from the given widget
* @param widget
*/
void MultiPageDialogBase::applyFontPage(UMLWidget *widget)
void MultiPageDialogBase::resetFontPage(QWidget *widget)
{
Q_UNUSED(widget);
Q_ASSERT(m_fontChooser);
widget->setFont(m_fontChooser->font());
m_fontChooser->setFont(widget->font());
}
/**
......@@ -408,11 +407,36 @@ void MultiPageDialogBase::applyFontPage(UMLWidget *widget)
*/
void MultiPageDialogBase::applyFontPage(AssociationWidget *widget)
{
Q_UNUSED(widget);
Q_ASSERT(m_fontChooser);
widget->lwSetFont(m_fontChooser->font());
}
void MultiPageDialogBase::applyFontPage(Settings::OptionState *state)
{
Q_ASSERT(m_fontChooser);
state->uiState.font = m_fontChooser->font();
}
/**
* updates the font page data
* @param widget Widget to save the font data into
*/
void MultiPageDialogBase::applyFontPage(UMLScene *scene)
{
Q_ASSERT(m_fontChooser);
scene->setFont(m_fontChooser->font(), true);
}
/**
* updates the font page data
* @param widget Widget to save the font data into
*/
void MultiPageDialogBase::applyFontPage(UMLWidget *widget)
{
Q_ASSERT(m_fontChooser);
widget->setFont(m_fontChooser->font());
}
/**
* Sets up the style page.
* @param widget The widget to load the initial data from
......
......@@ -30,6 +30,8 @@ class QFrame;
class UMLWidget;
class UMLWidgetStylePage;
class WidgetBase;
class UMLScene;
namespace Settings { class OptionState; }
/**
* Base class for property dialogs
......@@ -109,8 +111,11 @@ protected:
KPageWidgetItem *setupFontPage(const QFont &font);
KPageWidgetItem *setupFontPage(UMLWidget *widget);
KPageWidgetItem *setupFontPage(AssociationWidget *widget);
void applyFontPage(UMLWidget *widget);
void resetFontPage(QWidget *widget);
void applyFontPage(AssociationWidget *widget);
void applyFontPage(Settings::OptionState *state);
void applyFontPage(UMLScene *scene);
void applyFontPage(UMLWidget *wigdet);
KPageWidgetItem *setupStylePage(WidgetBase *widget);
KPageWidgetItem *setupStylePage(AssociationWidget *widget);
......
......@@ -54,7 +54,7 @@ SettingsDialog::SettingsDialog(QWidget * parent, Settings::OptionState *state)
m_bChangesApplied = false;
m_pOptionState = state;
setupGeneralPage();
setupFontPage();
pageFont = setupFontPage(state->uiState.font);
setupUIPage();
setupClassPage();
setupCodeImportPage();
......@@ -265,20 +265,6 @@ void SettingsDialog::setupCodeViewerPage(Settings::CodeViewerState options)
Icon_Utils::it_Properties_CodeViewer, m_pCodeViewerPage);
}
void SettingsDialog::setupFontPage()
{
#if QT_VERSION >= 0x050000
m_FontWidgets.chooser = new QFontDialog();
m_FontWidgets.chooser->setCurrentFont(m_pOptionState->uiState.font);
m_FontWidgets.chooser->setOption(QFontDialog::NoButtons);
#else
m_FontWidgets.chooser = new KFontChooser(0, KFontChooser::NoDisplayFlags, QStringList(), 0);
m_FontWidgets.chooser->setFont(m_pOptionState->uiState.font);
#endif
pageFont = createPage(i18n("Font"), i18n("Font Settings"),
Icon_Utils::it_Properties_Font, m_FontWidgets.chooser);
}
void SettingsDialog::setupAutoLayoutPage()
{
m_pAutoLayoutPage = new AutoLayoutOptionPage;
......@@ -317,11 +303,7 @@ void SettingsDialog::slotDefault()
}
else if (current == pageFont)
{
#if QT_VERSION >= 0x050000
m_FontWidgets.chooser->setCurrentFont(parentWidget()->font());
#else
m_FontWidgets.chooser->setFont(parentWidget()->font());
#endif
resetFontPage(parentWidget());
}
else if (current == pageUserInterface)
{
......@@ -360,11 +342,7 @@ void SettingsDialog::applyPage(KPageWidgetItem*item)
}
else if (item == pageFont)
{
#if QT_VERSION >= 0x050000
m_pOptionState->uiState.font = m_FontWidgets.chooser->currentFont();
#else
m_pOptionState->uiState.font = m_FontWidgets.chooser->font();
#endif
applyFontPage(m_pOptionState);
}
else if (item == pageUserInterface)
{
......
......@@ -90,16 +90,7 @@ private:
}
;//end struct UIWidgets
struct FontWidgets {
#if QT_VERSION >= 0x050000
QFontDialog *chooser;
#else
KFontChooser *chooser;
#endif
};
//private methods
void setupFontPage();
void setupUIPage();
void setupGeneralPage();
void setupClassPage();
......@@ -110,7 +101,6 @@ private:
void applyPage(KPageWidgetItem*);
//private attributes
FontWidgets m_FontWidgets;
UIWidgets m_UiWidgets;
Settings::OptionState *m_pOptionState;
UMLWidgetStylePage * m_pUserInterfacePage;
......
......@@ -83,7 +83,7 @@ void UMLViewDialog::setupPages()
{
setupDiagramPropertiesPage();
setupStylePage();
setupFontPage();
m_pageFontItem = setupFontPage(m_pScene->optionState().uiState.font);
setupDisplayPage();
}
......@@ -125,23 +125,6 @@ void UMLViewDialog::setupStylePage()
Icon_Utils::it_Properties_Color, m_pStylePage);
}
/**
* Sets up font page.
*/
void UMLViewDialog::setupFontPage()
{
#if QT_VERSION >= 0x050000
m_pChooser = new QFontDialog();
m_pChooser->setCurrentFont(m_pScene->optionState().uiState.font);
m_pChooser->setOption(QFontDialog::NoButtons);
#else
m_pChooser = new KFontChooser(0, KFontChooser::NoDisplayFlags, QStringList(), 0);
m_pChooser->setFont(m_pScene->optionState().uiState.font);
#endif
m_pageFontItem = createPage(i18n("Font"), i18n("Font Settings"),
Icon_Utils::it_Properties_Font, m_pChooser);
}
/**
* Applies the properties of the given page.
*/
......@@ -162,13 +145,7 @@ void UMLViewDialog::applyPage(KPageWidgetItem *item)
}
else if (item == m_pageFontItem)
{
#if QT_VERSION >= 0x050000
QFont font = m_pChooser->currentFont();
#else
QFont font = m_pChooser->font();
#endif
uDebug() << "setting font " << font.toString();
m_pScene->setFont(font, true);
applyFontPage(m_pScene);
}
else if (item == m_pageDisplayItem)
{
......
......@@ -48,7 +48,6 @@ protected:
void setupDiagramPropertiesPage();
void setupDisplayPage();
void setupStylePage();
void setupFontPage();
void applyPage(KPageWidgetItem*);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment