aboutsummaryrefslogtreecommitdiff
path: root/src/corelib/widgets/mrichtexteditdialogsmanager_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/widgets/mrichtexteditdialogsmanager_p.h')
-rw-r--r--src/corelib/widgets/mrichtexteditdialogsmanager_p.h96
1 files changed, 94 insertions, 2 deletions
diff --git a/src/corelib/widgets/mrichtexteditdialogsmanager_p.h b/src/corelib/widgets/mrichtexteditdialogsmanager_p.h
index 652f5363..83752b7c 100644
--- a/src/corelib/widgets/mrichtexteditdialogsmanager_p.h
+++ b/src/corelib/widgets/mrichtexteditdialogsmanager_p.h
@@ -20,11 +20,77 @@
#ifndef MRICHTEXTEDITDIALOGSMANAGER_P_H
#define MRICHTEXTEDITDIALOGSMANAGER_P_H
+#include <QGraphicsWidget>
#include <QPointer>
#include <QPair>
+#include <MNamespace>
class MDialog;
class MComboBox;
+class MBasicListItem;
+
+// Rich text edit's FontStyle widget contains the implementation required for creating the
+// ui of the font widgets (Font Size and Font Color widgets). It holds the items that
+// are part of the font widgets' ui.
+class MRichTextEditFontStyleWidget : public QGraphicsWidget
+{
+ Q_OBJECT
+
+public:
+ MRichTextEditFontStyleWidget(QGraphicsItem *parent = 0);
+
+ ~MRichTextEditFontStyleWidget();
+
+ // Updates the ui for the given orientation
+ virtual void updateOrientation(M::Orientation orientation) = 0;
+
+protected:
+ virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
+
+ virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+
+ // Selects an item in the ui as current active item. /param index - item's index
+ virtual void selectItem(int index) = 0;
+
+ // Updates the size of the ui items using \param numRows and \param numColumns
+ void updateSize(int numRows, int numColumns);
+
+ // Each QRectF in the list represents an item in the ui
+ QList<QRectF> items;
+};
+
+class MRichTextEditFontSizeWidget : public MRichTextEditFontStyleWidget
+{
+ Q_OBJECT
+
+public:
+ MRichTextEditFontSizeWidget(const QList<int> &fontSizeValues, QGraphicsItem *parent = 0);
+
+ ~MRichTextEditFontSizeWidget();
+
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+
+ virtual void updateOrientation(M::Orientation orientation);
+
+ // Sets the current font size will be used for highlighting the corresponding item in the ui
+ void setActiveSize(int size);
+
+protected:
+
+ virtual void selectItem(int index);
+
+Q_SIGNALS:
+ /**
+ * \brief Emitted whenever a font size is selected
+ */
+ void fontSizeSelected(int fontSize);
+
+private:
+ // List of font size values shown in the ui
+ QList<int> sizeValues;
+ // Active item index used for highlighting
+ int activeIndex;
+};
class MRichTextEditDialogsManager : public QObject
{
@@ -38,7 +104,7 @@ public:
/*!
* \brief shows the text styling dialog with the current style
*/
- void showTextStylingDialog(const QString &fontfamily = "");
+ void showTextStylingDialog(const QString &fontfamily = "", int fontPointSize = -1);
Q_SIGNALS:
@@ -47,6 +113,17 @@ Q_SIGNALS:
*/
void fontFamilySelected(const QString &fontFamily);
+ /**
+ * \brief Emitted whenever a font size is selected
+ */
+ void fontSizeSelected(int fontPointSize);
+
+private Q_SLOTS:
+
+ void setFontSize(int fontSize);
+ void showFontSizeDialog();
+ void updateFontSizeWidgetOrientation(M::Orientation orientation);
+
private:
// QPointer<MDialog> in ActiveDialog will hold a dialog
// bool in ActiveDialog is used to avoid calling its dialog's exec() when it is active
@@ -65,9 +142,13 @@ private:
*/
void initTextStylingDialog();
/*!
+ * \brief initializes the FontSize dialog
+ */
+ void initFontSizeDialog();
+ /*!
* \brief updates the ui components of the TextStyles dialog to show the current style
*/
- void setTextStyleValues(const QString &fontfamily);
+ void setTextStyleValues(const QString &fontfamily, int fontPointSize);
/*!
* \brief launches the dialog of given type
*/
@@ -78,10 +159,21 @@ private:
struct Dialogs
{
ActiveDialog textStyles;
+ ActiveDialog fontSize;
};
Dialogs dialogs;
+ struct FontSizeData
+ {
+ QList<int> sizeValues;
+ QString titleName;
+ int activeSizeIndex;
+ };
+ FontSizeData fontSizeData;
+
MComboBox *fontFamilyCombo;
+ MBasicListItem *fontSizeListItem;
+ MRichTextEditFontSizeWidget *fontSizeWidget;
};
#endif