summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Habacker <[email protected]>2018-01-27 13:43:21 +0100
committerRalf Habacker <[email protected]>2018-01-27 14:04:16 +0100
commit174f45fc6b98537eb9f3e54f6a851753b7084445 (patch)
tree14ed4902af2acaf3872e1399b1378b3180e0183c
parentcfe2f4b7e7312a27795ff75e038eea2574644dbc (diff)
Merge duplicated code for handling foot chooser into class MultiPageDialogBase
Font chooser code was duplicated in class SettingsDialog and UmlViewDialog.
-rw-r--r--umbrello/dialogs/multipagedialogbase.cpp36
-rw-r--r--umbrello/dialogs/multipagedialogbase.h7
-rw-r--r--umbrello/dialogs/settingsdialog.cpp28
-rw-r--r--umbrello/dialogs/settingsdialog.h10
-rw-r--r--umbrello/dialogs/umlviewdialog.cpp27
-rw-r--r--umbrello/dialogs/umlviewdialog.h1
6 files changed, 41 insertions, 68 deletions
diff --git a/umbrello/dialogs/multipagedialogbase.cpp b/umbrello/dialogs/multipagedialogbase.cpp
index 780406e..043c312 100644
--- a/umbrello/dialogs/multipagedialogbase.cpp
+++ b/umbrello/dialogs/multipagedialogbase.cpp
@@ -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
diff --git a/umbrello/dialogs/multipagedialogbase.h b/umbrello/dialogs/multipagedialogbase.h
index 29fd0d7..0a4f114 100644
--- a/umbrello/dialogs/multipagedialogbase.h
+++ b/umbrello/dialogs/multipagedialogbase.h
@@ -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);
diff --git a/umbrello/dialogs/settingsdialog.cpp b/umbrello/dialogs/settingsdialog.cpp
index 5628016..a1c1ac8 100644
--- a/umbrello/dialogs/settingsdialog.cpp
+++ b/umbrello/dialogs/settingsdialog.cpp
@@ -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)
{
diff --git a/umbrello/dialogs/settingsdialog.h b/umbrello/dialogs/settingsdialog.h
index 402ad46..2240572 100644
--- a/umbrello/dialogs/settingsdialog.h
+++ b/umbrello/dialogs/settingsdialog.h
@@ -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;
diff --git a/umbrello/dialogs/umlviewdialog.cpp b/umbrello/dialogs/umlviewdialog.cpp
index 2a19800..b0b9c0e 100644
--- a/umbrello/dialogs/umlviewdialog.cpp
+++ b/umbrello/dialogs/umlviewdialog.cpp
@@ -83,7 +83,7 @@ void UMLViewDialog::setupPages()
{
setupDiagramPropertiesPage();
setupStylePage();
- setupFontPage();
+ m_pageFontItem = setupFontPage(m_pScene->optionState().uiState.font);
setupDisplayPage();
}
@@ -126,23 +126,6 @@ void UMLViewDialog::setupStylePage()
}
/**
- * 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.
*/
void UMLViewDialog::applyPage(KPageWidgetItem *item)
@@ -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)
{
diff --git a/umbrello/dialogs/umlviewdialog.h b/umbrello/dialogs/umlviewdialog.h
index 6713f1c..9d89652 100644
--- a/umbrello/dialogs/umlviewdialog.h
+++ b/umbrello/dialogs/umlviewdialog.h
@@ -48,7 +48,6 @@ protected:
void setupDiagramPropertiesPage();
void setupDisplayPage();
void setupStylePage();
- void setupFontPage();
void applyPage(KPageWidgetItem*);