Commit 78b095b4 authored by Ralf Habacker's avatar Ralf Habacker
Browse files

Move association specific user interface options to ui page of settings dialog

Move code for selecting association line layout type from general option page
into a separate class named SelectLayoutTypeWidget and add it to new ui page
group "Associations".

Move angular line option to ui options page from generic page.

This commit also adds the ComboBoxWidgetBase class, which can be used as
a base class for combo box related dialog widgets and helps to avoid
duplicated code.

BUG:414537
FIXED-IN:2.30.80 (KDE Applications 20.03.80)
parent 05d449e9
......@@ -244,10 +244,12 @@ set(libdialogs_SRCS
dialogs/pages/uioptionspage.cpp
dialogs/pages/umlroleproperties.cpp
dialogs/pages/umlwidgetstylepage.cpp
dialogs/widgets/comboboxwidgetbase.cpp
dialogs/widgets/documentationwidget.cpp
dialogs/widgets/imagetypewidget.cpp
dialogs/widgets/resolutionwidget.cpp
dialogs/widgets/selectdiagramwidget.cpp
dialogs/widgets/selectlayouttypewidget.cpp
dialogs/widgets/umlartifacttypewidget.cpp
dialogs/widgets/umldatatypewidget.cpp
dialogs/widgets/defaultvaluewidget.cpp
......
......@@ -13,6 +13,7 @@
// local includes
#include "dialog_utils.h"
#include "selectlayouttypewidget.h"
#include "optionstate.h"
// kde includes
......@@ -71,10 +72,6 @@ GeneralOptionPage::GeneralOptionPage(QWidget* parent)
m_GeneralWidgets.newcodegenCB->setChecked(optionState.generalState.newcodegen);
miscLayout->addWidget(m_GeneralWidgets.newcodegenCB, 1, 0);
#endif
m_GeneralWidgets.angularLinesCB = new QCheckBox(i18n("Use angular association lines"), m_GeneralWidgets.miscGB);
m_GeneralWidgets.angularLinesCB->setChecked(optionState.generalState.angularlines);
miscLayout->addWidget(m_GeneralWidgets.angularLinesCB, 1, 1);
m_GeneralWidgets.footerPrintingCB = new QCheckBox(i18n("Turn on footer and page numbers when printing"), m_GeneralWidgets.miscGB);
m_GeneralWidgets.footerPrintingCB->setChecked(optionState.generalState.footerPrinting);
miscLayout->addWidget(m_GeneralWidgets.footerPrintingCB, 2, 0);
......@@ -83,21 +80,6 @@ GeneralOptionPage::GeneralOptionPage(QWidget* parent)
m_GeneralWidgets.uml2CB->setChecked(optionState.generalState.uml2);
miscLayout->addWidget(m_GeneralWidgets.uml2CB, 2, 1);
m_GeneralWidgets.layoutTypeL = new QLabel(i18n("Create new association lines as:"), m_GeneralWidgets.miscGB);
miscLayout->addWidget(m_GeneralWidgets.layoutTypeL, 3, 0);
m_GeneralWidgets.layoutTypeKB = new KComboBox(m_GeneralWidgets.miscGB);
#if QT_VERSION < 0x050000
m_GeneralWidgets.layoutTypeKB->setCompletionMode(KGlobalSettings::CompletionPopup);
#endif
miscLayout->addWidget(m_GeneralWidgets.layoutTypeKB, 3, 1);
for (int layoutTypeNo = 1; layoutTypeNo < 5; ++layoutTypeNo) {
Uml::LayoutType::Enum lt = Uml::LayoutType::fromInt(layoutTypeNo);
insertLayoutType(Uml::LayoutType::toString(lt), layoutTypeNo - 1);
}
m_GeneralWidgets.layoutTypeKB->setCurrentIndex((int)optionState.generalState.layoutType-1);
topLayout->addWidget(m_GeneralWidgets.miscGB);
//setup autosave settings
m_GeneralWidgets.autosaveGB = new QGroupBox(i18n("Autosave"));
topLayout->addWidget(m_GeneralWidgets.autosaveGB);
......@@ -221,8 +203,6 @@ void GeneralOptionPage::apply()
#ifdef ENABLE_NEW_CODE_GENERATORS
optionState.generalState.newcodegen = m_GeneralWidgets.newcodegenCB->isChecked();
#endif
optionState.generalState.angularlines = m_GeneralWidgets.angularLinesCB->isChecked();
optionState.generalState.layoutType = Uml::LayoutType::fromInt(m_GeneralWidgets.layoutTypeKB->currentIndex() + 1);
optionState.generalState.footerPrinting = m_GeneralWidgets.footerPrintingCB->isChecked();
optionState.generalState.uml2 = m_GeneralWidgets.uml2CB->isChecked();
optionState.generalState.autosave = m_GeneralWidgets.autosaveCB->isChecked();
......@@ -244,15 +224,6 @@ void GeneralOptionPage::insertDiagram(const QString& type, int index)
m_GeneralWidgets.diagramKB->completionObject()->addItem(type);
}
/**
* Inserts @p type into the type-combobox as well as its completion object.
*/
void GeneralOptionPage::insertLayoutType(const QString& type, int index)
{
m_GeneralWidgets.layoutTypeKB->insertItem(index, type);
m_GeneralWidgets.layoutTypeKB->completionObject()->addItem(type);
}
/**
* Slot for clicked event.
*/
......
......@@ -25,6 +25,8 @@ class QLabel;
class QSpinBox;
#endif
class SelectLayoutTypeWidget;
/**
* A dialog page to display auto layouts options
*
......@@ -62,9 +64,7 @@ protected:
QCheckBox * undoCB;
QCheckBox * tabdiagramsCB;
QCheckBox * newcodegenCB;
QCheckBox * angularLinesCB;
QLabel * layoutTypeL;
KComboBox * layoutTypeKB;
SelectLayoutTypeWidget *layoutTypeW;
QCheckBox * footerPrintingCB;
QCheckBox * uml2CB;
......
......@@ -15,6 +15,8 @@
#include "optionstate.h"
#include "umbrellosettings.h"
#include "selectlayouttypewidget.h"
//// kde includes
#include <KLocalizedString>
#include <KColorButton>
......@@ -69,6 +71,18 @@ void UIOptionsPage::setupPage()
m_rightToLeftUI->setChecked(UmbrelloSettings::rightToLeftUI());
otherLayout->addWidget(m_rightToLeftUI, 0, 0);
QGroupBox *boxAssocs = new QGroupBox(i18nc("Association options", "Associations"), this);
QGridLayout *layoutAssocs = new QGridLayout(boxAssocs);
layoutAssocs->setMargin(fontMetrics().height());
uiPageLayout->addWidget(boxAssocs);
m_angularLinesCB = new QCheckBox(i18n("Use angular association lines"), boxAssocs);
m_angularLinesCB->setChecked(Settings::OptionState().generalState.angularlines);
layoutAssocs->addWidget(m_angularLinesCB, 0, 0);
m_layoutTypeW = new SelectLayoutTypeWidget(i18n("Create new association lines as:"), Settings::optionState().generalState.layoutType, boxAssocs);
m_layoutTypeW->addToLayout(layoutAssocs, 1);
m_colorGB = new QGroupBox(i18nc("color group box", "Color"), this);
QGridLayout * colorLayout = new QGridLayout(m_colorGB);
//colorLayout->setSpacing(spacingHint());
......@@ -164,6 +178,8 @@ void UIOptionsPage::setDefaults()
slotBgCBChecked(false);
slotLineWidthCBChecked(false);
m_rightToLeftUI->setChecked(false);
m_layoutTypeW->setCurrentLayout(Uml::LayoutType::Direct);
m_angularLinesCB->setChecked(false);
}
/**
......@@ -178,6 +194,8 @@ void UIOptionsPage::apply()
m_options->uiState.lineWidth = m_lineWidthB->value();
m_options->uiState.backgroundColor = m_bgColorB->color();
m_options->uiState.gridDotColor = m_gridColorB->color();
m_options->generalState.layoutType = m_layoutTypeW->currentLayout();
m_options->generalState.angularlines = m_angularLinesCB->isChecked();
UmbrelloSettings::setRightToLeftUI(m_rightToLeftUI->isChecked());
qApp->setLayoutDirection(UmbrelloSettings::rightToLeftUI() ? Qt::RightToLeft : Qt::LeftToRight);
}
......
......@@ -17,6 +17,8 @@ namespace Settings {
class OptionState;
}
class SelectLayoutTypeWidget;
class KColorButton;
class KComboBox;
class KIntSpinBox;
......@@ -68,6 +70,8 @@ protected:
KIntSpinBox * m_lineWidthB;
#endif
QCheckBox * m_useFillColorCB;
QCheckBox *m_angularLinesCB;
SelectLayoutTypeWidget *m_layoutTypeW;
void setupPage();
protected slots:
......
/***************************************************************************
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2019 *
* Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
***************************************************************************/
#include "comboboxwidgetbase.h"
#include <KComboBox>
#include <QHBoxLayout>
#include <QLabel>
ComboBoxWidgetBase::ComboBoxWidgetBase(const QString &title, QWidget *parent)
: QWidget(parent)
{
QHBoxLayout *layout = new QHBoxLayout;
layout->setContentsMargins(0,0,0,0);
m_label = new QLabel(title, this);
layout->addWidget(m_label);
m_editField = new KComboBox(this);
m_editField->setEditable(true);
#if QT_VERSION < 0x050000
m_editField->setCompletionMode(KGlobalSettings::CompletionPopup);
#endif
layout->addWidget(m_editField, 2);
setLayout(layout);
}
/**
* Add this widget to a given grid layout. Umbrello dialogs places labels in column 0
* and the editable field in column 1.
* @param layout The layout to which the widget should be added
* @param row The row in the grid layout where the widget should be placed
*/
void ComboBoxWidgetBase::addToLayout(QGridLayout *layout, int row)
{
layout->addWidget(m_label, row, 0);
layout->addWidget(m_editField, row, 1);
}
/***************************************************************************
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2019 *
* Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
***************************************************************************/
#ifndef COMBOBOXWIDGETBASE_H
#define COMBOBOXWIDGETBASE_H
#include <QWidget>
class KComboBox;
class QGridLayout;
class QLabel;
class ComboBoxWidgetBase : public QWidget
{
Q_OBJECT
public:
explicit ComboBoxWidgetBase(const QString &title, QWidget *parent = nullptr);
void addToLayout(QGridLayout *layout, int row);
protected:
QLabel *m_label;
KComboBox *m_editField;
};
#endif // COMBOBOXWIDGETBASE_H
/***************************************************************************
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2019 *
* Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
***************************************************************************/
#include "selectlayouttypewidget.h"
#include <KComboBox>
SelectLayoutTypeWidget::SelectLayoutTypeWidget(const QString &title, Uml::LayoutType::Enum selected, QWidget *parent)
: ComboBoxWidgetBase(title, parent)
{
for (int layoutTypeNo = Uml::LayoutType::Undefined + 1; layoutTypeNo < Uml::LayoutType::N_LAYOUTTYPES; ++layoutTypeNo) {
Uml::LayoutType::Enum lt = Uml::LayoutType::fromInt(layoutTypeNo);
const QString type = Uml::LayoutType::toString(lt);
m_editField->insertItem(layoutTypeNo-1, type);
m_editField->completionObject()->addItem(type);
}
m_editField->setCurrentIndex(selected - 1);
}
void SelectLayoutTypeWidget::setCurrentLayout(Uml::LayoutType::Enum layout)
{
m_editField->setCurrentIndex(layout - 1);
}
Uml::LayoutType::Enum SelectLayoutTypeWidget::currentLayout()
{
return Uml::LayoutType::fromInt(m_editField->currentIndex()+1);
}
/***************************************************************************
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2019 *
* Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
***************************************************************************/
#ifndef SELECTLAYOUTTYPEWIDGET_H
#define SELECTLAYOUTTYPEWIDGET_H
#include "basictypes.h"
#include "comboboxwidgetbase.h"
class SelectLayoutTypeWidget : public ComboBoxWidgetBase
{
public:
explicit SelectLayoutTypeWidget(const QString &title, Uml::LayoutType::Enum selected, QWidget *parent = nullptr);
void setCurrentLayout(Uml::LayoutType::Enum layout);
Uml::LayoutType::Enum currentLayout();
};
#endif // SELECTLAYOUTTYPEWIDGET_H
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