From 751f0664399d35f0324ea64ffb9a7546091f7117 Mon Sep 17 00:00:00 2001 From: Herwig Birke Date: Thu, 3 May 2018 16:16:55 +0200 Subject: [PATCH] . --- cchapterwindow.cpp | 17 ++ cchapterwindow.ui | 18 +- ccharacterwindow.cpp | 79 ++++++++- ccharacterwindow.ui | 84 +++++++--- ccheckbox.cpp | 20 +++ ccheckbox.h | 27 +++ ccombobox.cpp | 20 +++ ccombobox.h | 27 +++ cdateedit.cpp | 19 +++ cdateedit.h | 27 +++ cdatetimeedit.cpp | 20 +++ cdatetimeedit.h | 27 +++ cdoublespinbox.cpp | 19 +++ cdoublespinbox.h | 27 +++ cimagewidget.cpp | 5 + cimagewidget.ui | 9 +- clineedit.cpp | 19 +++ clineedit.h | 27 +++ cmainwindow.cpp | 379 +++++++++++++++++++++++++++++-------------- cmainwindow.h | 72 ++++++-- cobjectwindow.cpp | 11 ++ cobjectwindow.ui | 18 +- cpartwindow.cpp | 14 ++ cpartwindow.h | 1 + cpartwindow.ui | 16 +- cplacewindow.cpp | 14 ++ cplacewindow.ui | 20 ++- cradiobutton.cpp | 19 +++ cradiobutton.h | 27 +++ crecherchewindow.cpp | 20 +++ crecherchewindow.ui | 29 +++- cscenewindow.cpp | 38 +++++ cscenewindow.ui | 44 +++-- ctextedit.cpp | 184 +++++++++++++++++++++ ctextedit.h | 47 +++++- ctreeview.cpp | 18 ++ ctreeview.h | 27 +++ main.cpp | 1 + qtStoryWriter.pro | 20 ++- 39 files changed, 1304 insertions(+), 206 deletions(-) create mode 100644 ccheckbox.cpp create mode 100644 ccheckbox.h create mode 100644 ccombobox.cpp create mode 100644 ccombobox.h create mode 100644 cdateedit.cpp create mode 100644 cdateedit.h create mode 100644 cdatetimeedit.cpp create mode 100644 cdatetimeedit.h create mode 100644 cdoublespinbox.cpp create mode 100644 cdoublespinbox.h create mode 100644 clineedit.cpp create mode 100644 clineedit.h create mode 100644 cradiobutton.cpp create mode 100644 cradiobutton.h create mode 100644 ctreeview.cpp create mode 100644 ctreeview.h diff --git a/cchapterwindow.cpp b/cchapterwindow.cpp index 8de5ff6..512543d 100644 --- a/cchapterwindow.cpp +++ b/cchapterwindow.cpp @@ -1,6 +1,8 @@ #include "cchapterwindow.h" #include "ui_cchapterwindow.h" +#include "cmainwindow.h" + #include @@ -14,6 +16,21 @@ cChapterWindow::cChapterWindow(QWidget *parent) : m_lpSceneModel = new QStandardItemModel(0, 1); ui->m_lpSceneList->setModel(m_lpSceneModel); + + connect(ui->m_lpName, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpName, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpPart, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpPart, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpSceneList, SIGNAL(gotFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewGotFocus(cTreeView*))); + connect(ui->m_lpSceneList, SIGNAL(lostFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewLostFocus(cTreeView*))); + + connect(ui->m_lpDescription, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); + connect(ui->m_lpDescription, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); + + connect(ui->m_lpText, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); + connect(ui->m_lpText, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); } cChapterWindow::~cChapterWindow() diff --git a/cchapterwindow.ui b/cchapterwindow.ui index 4b5bc45..e98b0f5 100644 --- a/cchapterwindow.ui +++ b/cchapterwindow.ui @@ -30,7 +30,7 @@ - + @@ -43,7 +43,7 @@ - + @@ -56,7 +56,7 @@ - + QAbstractItemView::NoEditTriggers @@ -82,7 +82,7 @@ - + true @@ -98,6 +98,16 @@ QTextEdit
ctextedit.h
+ + cLineEdit + QLineEdit +
clineedit.h
+
+ + cTreeView + QTreeView +
ctreeview.h
+
m_lpName diff --git a/ccharacterwindow.cpp b/ccharacterwindow.cpp index 433cfee..d6b2d97 100644 --- a/ccharacterwindow.cpp +++ b/ccharacterwindow.cpp @@ -3,6 +3,8 @@ #include "cimagewidget.h" +#include "cmainwindow.h" + #include @@ -13,6 +15,81 @@ cCharacterWindow::cCharacterWindow(QWidget *parent) : { ui->setupUi(this); ui->m_lpTab->setCurrentIndex(0); + + connect(ui->m_lpFirstName, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpFirstName, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpMiddleName, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpMiddleName, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpLastName, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpLastName, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpMainCharacter, SIGNAL(gotFocus(cCheckBox*)), (cMainWindow*)parent, SLOT(onCheckBoxGotFocus(cCheckBox*))); + connect(ui->m_lpMainCharacter, SIGNAL(lostFocus(cCheckBox*)), (cMainWindow*)parent, SLOT(onCheckBoxLostFocus(cCheckBox*))); + + connect(ui->m_lpCreature, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpCreature, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpTitle, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpTitle, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpMale, SIGNAL(gotFocus(cRadioButton*)), (cMainWindow*)parent, SLOT(onRadioButtonGotFocus(cRadioButton*))); + connect(ui->m_lpMale, SIGNAL(lostFocus(cRadioButton*)), (cMainWindow*)parent, SLOT(onRadioButtonLostFocus(cRadioButton*))); + + connect(ui->m_lpFemale, SIGNAL(gotFocus(cRadioButton*)), (cMainWindow*)parent, SLOT(onRadioButtonGotFocus(cRadioButton*))); + connect(ui->m_lpFemale, SIGNAL(lostFocus(cRadioButton*)), (cMainWindow*)parent, SLOT(onRadioButtonLostFocus(cRadioButton*))); + + connect(ui->m_lpOther, SIGNAL(gotFocus(cRadioButton*)), (cMainWindow*)parent, SLOT(onRadioButtonGotFocus(cRadioButton*))); + connect(ui->m_lpOther, SIGNAL(lostFocus(cRadioButton*)), (cMainWindow*)parent, SLOT(onRadioButtonLostFocus(cRadioButton*))); + + connect(ui->m_lpDayOfBirth, SIGNAL(gotFocus(cDateEdit*)), (cMainWindow*)parent, SLOT(onDateEditGotFocus(cDateEdit*))); + connect(ui->m_lpDayOfBirth, SIGNAL(lostFocus(cDateEdit*)), (cMainWindow*)parent, SLOT(onDateEditLostFocus(cDateEdit*))); + + connect(ui->m_lpDayOfDeath, SIGNAL(gotFocus(cDateEdit*)), (cMainWindow*)parent, SLOT(onDateEditGotFocus(cDateEdit*))); + connect(ui->m_lpDayOfDeath, SIGNAL(lostFocus(cDateEdit*)), (cMainWindow*)parent, SLOT(onDateEditLostFocus(cDateEdit*))); + + connect(ui->m_lpPlaceOfBirth, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpPlaceOfBirth, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpPlaceOfDeath, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpPlaceOfDeath, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpHeight, SIGNAL(gotFocus(cDoubleSpinBox*)), (cMainWindow*)parent, SLOT(onDoubleSpinBoxGotFocus(cDoubleSpinBox*))); + connect(ui->m_lpHeight, SIGNAL(lostFocus(cDoubleSpinBox*)), (cMainWindow*)parent, SLOT(onDoubleSpinBoxLostFocus(cDoubleSpinBox*))); + + connect(ui->m_lpWeight, SIGNAL(gotFocus(cDoubleSpinBox*)), (cMainWindow*)parent, SLOT(onDoubleSpinBoxGotFocus(cDoubleSpinBox*))); + connect(ui->m_lpWeight, SIGNAL(lostFocus(cDoubleSpinBox*)), (cMainWindow*)parent, SLOT(onDoubleSpinBoxLostFocus(cDoubleSpinBox*))); + + connect(ui->m_lpFigure, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpFigure, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpSkin, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpSkin, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpNature, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpNature, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpHairColor, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpHairColor, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpHairCut, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpHairCut, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpHairLength, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpHairLength, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpSchool, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); + connect(ui->m_lpSchool, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); + + connect(ui->m_lpSpokenLanguages, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); + connect(ui->m_lpSpokenLanguages, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); + + connect(ui->m_lpJob, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); + connect(ui->m_lpJob, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); + + connect(ui->m_lpDescription, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); + connect(ui->m_lpDescription, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); } cCharacterWindow::~cCharacterWindow() @@ -55,7 +132,7 @@ void cCharacterWindow::setCharacter(cCharacter* lpCharacter) ui->m_lpHairCut->setText(lpCharacter->hairCut()); ui->m_lpHairLength->setText(lpCharacter->hairLength()); ui->m_lpSchool->setText(lpCharacter->school()); - ui->m_lpspokenLanguages->setText(lpCharacter->spokenLanguages()); + ui->m_lpSpokenLanguages->setText(lpCharacter->spokenLanguages()); ui->m_lpJob->setHtml(lpCharacter->job()); ui->m_lpDescription->setDocument(lpCharacter->description()); diff --git a/ccharacterwindow.ui b/ccharacterwindow.ui index 4f5b7c9..75db31f 100644 --- a/ccharacterwindow.ui +++ b/ccharacterwindow.ui @@ -17,7 +17,7 @@ - 1 + 0 @@ -27,7 +27,7 @@ - + @@ -40,17 +40,17 @@ - + 999999.000000000000000 - + - + @@ -93,10 +93,10 @@ - + - + @@ -109,10 +109,10 @@ - + - + Main Character @@ -129,7 +129,7 @@ - + 999999.000000000000000 @@ -166,7 +166,7 @@ - + @@ -179,7 +179,7 @@ - + @@ -192,10 +192,10 @@ - + - + @@ -228,13 +228,13 @@ - + - + - + @@ -247,7 +247,7 @@ - + @@ -270,7 +270,7 @@ - + @@ -303,16 +303,16 @@ - + - + - + - + @@ -321,21 +321,21 @@ - + Male - + Female - + Other @@ -394,6 +394,38 @@ + + + cTextEdit + QTextEdit +
ctextedit.h
+
+ + cLineEdit + QLineEdit +
clineedit.h
+
+ + cCheckBox + QCheckBox +
ccheckbox.h
+
+ + cRadioButton + QRadioButton +
cradiobutton.h
+
+ + cDateEdit + QDateEdit +
cdateedit.h
+
+ + cDoubleSpinBox + QDoubleSpinBox +
cdoublespinbox.h
+
+
m_lpFirstName m_lpDescription diff --git a/ccheckbox.cpp b/ccheckbox.cpp new file mode 100644 index 0000000..ce7b6cb --- /dev/null +++ b/ccheckbox.cpp @@ -0,0 +1,20 @@ +#include "ccheckbox.h" + + +cCheckBox::cCheckBox(QWidget* parent) : + QCheckBox(parent) +{ + +} + +void cCheckBox::focusInEvent(QFocusEvent* event) +{ + gotFocus(this); + QCheckBox::focusInEvent(event); +} + +void cCheckBox::focusOutEvent(QFocusEvent* event) +{ + lostFocus(this); + QCheckBox::focusOutEvent(event); +} diff --git a/ccheckbox.h b/ccheckbox.h new file mode 100644 index 0000000..6f14436 --- /dev/null +++ b/ccheckbox.h @@ -0,0 +1,27 @@ +#ifndef CCHECKBOX_H +#define CCHECKBOX_H + + +#include +#include + + +class cCheckBox : public QCheckBox +{ + Q_OBJECT + +public: + cCheckBox(QWidget* parent = Q_NULLPTR); + +signals: + void gotFocus(cCheckBox* lpCheckBox); + void lostFocus(cCheckBox* lpCheckBox); + +protected: + void focusInEvent(QFocusEvent *event); + void focusOutEvent(QFocusEvent *event); +}; + +Q_DECLARE_METATYPE(cCheckBox*) + +#endif // CCHECKBOX_H diff --git a/ccombobox.cpp b/ccombobox.cpp new file mode 100644 index 0000000..58adba7 --- /dev/null +++ b/ccombobox.cpp @@ -0,0 +1,20 @@ +#include "ccombobox.h" + + +cComboBox::cComboBox(QWidget* parent) : + QComboBox(parent) +{ + +} + +void cComboBox::focusInEvent(QFocusEvent* event) +{ + gotFocus(this); + QComboBox::focusInEvent(event); +} + +void cComboBox::focusOutEvent(QFocusEvent* event) +{ + lostFocus(this); + QComboBox::focusOutEvent(event); +} diff --git a/ccombobox.h b/ccombobox.h new file mode 100644 index 0000000..f12a32b --- /dev/null +++ b/ccombobox.h @@ -0,0 +1,27 @@ +#ifndef CCOMBOBOX_H +#define CCOMBOBOX_H + + +#include +#include + + +class cComboBox : public QComboBox +{ + Q_OBJECT + +public: + cComboBox(QWidget* parent = Q_NULLPTR); + +signals: + void gotFocus(cComboBox* lpComboBox); + void lostFocus(cComboBox* lpComboBox); + +protected: + void focusInEvent(QFocusEvent *event); + void focusOutEvent(QFocusEvent *event); +}; + +Q_DECLARE_METATYPE(cComboBox*) + +#endif // CCOMBOBOX_H diff --git a/cdateedit.cpp b/cdateedit.cpp new file mode 100644 index 0000000..fdf0c55 --- /dev/null +++ b/cdateedit.cpp @@ -0,0 +1,19 @@ +#include "cdateedit.h" + + +cDateEdit::cDateEdit(QWidget* parent) : + QDateEdit(parent) +{ +} + +void cDateEdit::focusInEvent(QFocusEvent* event) +{ + gotFocus(this); + QDateEdit::focusInEvent(event); +} + +void cDateEdit::focusOutEvent(QFocusEvent* event) +{ + lostFocus(this); + QDateEdit::focusOutEvent(event); +} diff --git a/cdateedit.h b/cdateedit.h new file mode 100644 index 0000000..50b55c8 --- /dev/null +++ b/cdateedit.h @@ -0,0 +1,27 @@ +#ifndef CDATEEDIT_H +#define CDATEEDIT_H + + +#include +#include + + +class cDateEdit : public QDateEdit +{ + Q_OBJECT + +public: + cDateEdit(QWidget* parent = Q_NULLPTR); + +signals: + void gotFocus(cDateEdit* lpDateEdit); + void lostFocus(cDateEdit* lpDateEdit); + +protected: + void focusInEvent(QFocusEvent *event); + void focusOutEvent(QFocusEvent *event); +}; + +Q_DECLARE_METATYPE(cDateEdit*) + +#endif // CDATEEDIT_H diff --git a/cdatetimeedit.cpp b/cdatetimeedit.cpp new file mode 100644 index 0000000..96961ac --- /dev/null +++ b/cdatetimeedit.cpp @@ -0,0 +1,20 @@ +#include "cdatetimeedit.h" + + +cDateTimeEdit::cDateTimeEdit(QWidget* parent) : + QDateTimeEdit(parent) +{ + +} + +void cDateTimeEdit::focusInEvent(QFocusEvent* event) +{ + gotFocus(this); + QDateTimeEdit::focusInEvent(event); +} + +void cDateTimeEdit::focusOutEvent(QFocusEvent* event) +{ + lostFocus(this); + QDateTimeEdit::focusOutEvent(event); +} diff --git a/cdatetimeedit.h b/cdatetimeedit.h new file mode 100644 index 0000000..9e9e0d3 --- /dev/null +++ b/cdatetimeedit.h @@ -0,0 +1,27 @@ +#ifndef CDATETIMEEDIT_H +#define CDATETIMEEDIT_H + + +#include +#include + + +class cDateTimeEdit : public QDateTimeEdit +{ + Q_OBJECT + +public: + cDateTimeEdit(QWidget* parent = Q_NULLPTR); + +signals: + void gotFocus(cDateTimeEdit* lpDateTimeEdit); + void lostFocus(cDateTimeEdit* lpDateTimeEdit); + +protected: + void focusInEvent(QFocusEvent *event); + void focusOutEvent(QFocusEvent *event); +}; + +Q_DECLARE_METATYPE(cDateTimeEdit*) + +#endif // CDATETIMEEDIT_H diff --git a/cdoublespinbox.cpp b/cdoublespinbox.cpp new file mode 100644 index 0000000..f5f726b --- /dev/null +++ b/cdoublespinbox.cpp @@ -0,0 +1,19 @@ +#include "cdoublespinbox.h" + +cDoubleSpinBox::cDoubleSpinBox(QWidget* parent) : + QDoubleSpinBox(parent) +{ + +} + +void cDoubleSpinBox::focusInEvent(QFocusEvent* event) +{ + gotFocus(this); + QDoubleSpinBox::focusInEvent(event); +} + +void cDoubleSpinBox::focusOutEvent(QFocusEvent* event) +{ + lostFocus(this); + QDoubleSpinBox::focusOutEvent(event); +} diff --git a/cdoublespinbox.h b/cdoublespinbox.h new file mode 100644 index 0000000..b7bec64 --- /dev/null +++ b/cdoublespinbox.h @@ -0,0 +1,27 @@ +#ifndef CDOUBLESPINBOX_H +#define CDOUBLESPINBOX_H + + +#include +#include + + +class cDoubleSpinBox : public QDoubleSpinBox +{ + Q_OBJECT + +public: + cDoubleSpinBox(QWidget* parent = Q_NULLPTR); + +signals: + void gotFocus(cDoubleSpinBox* lpDoubleSpinBox); + void lostFocus(cDoubleSpinBox* lpDoubleSpinBox); + +protected: + void focusInEvent(QFocusEvent *event); + void focusOutEvent(QFocusEvent *event); +}; + +Q_DECLARE_METATYPE(cDoubleSpinBox*) + +#endif // CDOUBLESPINBOX_H diff --git a/cimagewidget.cpp b/cimagewidget.cpp index ca8c6ff..c729b98 100644 --- a/cimagewidget.cpp +++ b/cimagewidget.cpp @@ -1,12 +1,17 @@ #include "cimagewidget.h" #include "ui_cimagewidget.h" +#include "cmainwindow.h" + cImageWidget::cImageWidget(QWidget *parent) : QWidget(parent), ui(new Ui::cImageWidget) { ui->setupUi(this); + + connect(ui->m_lpDescription, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); + connect(ui->m_lpDescription, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); } cImageWidget::~cImageWidget() diff --git a/cimagewidget.ui b/cimagewidget.ui index dd2e4db..de7ffef 100644 --- a/cimagewidget.ui +++ b/cimagewidget.ui @@ -23,7 +23,7 @@ - + @@ -52,6 +52,13 @@
+ + + cTextEdit + QTextEdit +
ctextedit.h
+
+
diff --git a/clineedit.cpp b/clineedit.cpp new file mode 100644 index 0000000..222a130 --- /dev/null +++ b/clineedit.cpp @@ -0,0 +1,19 @@ +#include "clineedit.h" + + +cLineEdit::cLineEdit(QWidget* parent) : + QLineEdit(parent) +{ +} + +void cLineEdit::focusInEvent(QFocusEvent* event) +{ + gotFocus(this); + QLineEdit::focusInEvent(event); +} + +void cLineEdit::focusOutEvent(QFocusEvent* event) +{ + lostFocus(this); + QLineEdit::focusOutEvent(event); +} diff --git a/clineedit.h b/clineedit.h new file mode 100644 index 0000000..9892629 --- /dev/null +++ b/clineedit.h @@ -0,0 +1,27 @@ +#ifndef CLINEEDIT_H +#define CLINEEDIT_H + + +#include +#include + + +class cLineEdit : public QLineEdit +{ + Q_OBJECT + +public: + cLineEdit(QWidget* parent = Q_NULLPTR); + +signals: + void gotFocus(cLineEdit* lpLineEdit); + void lostFocus(cLineEdit* lpLineEdit); + +protected: + void focusInEvent(QFocusEvent *event); + void focusOutEvent(QFocusEvent *event); +}; + +Q_DECLARE_METATYPE(cLineEdit*) + +#endif // CLINEEDIT_H diff --git a/cmainwindow.cpp b/cmainwindow.cpp index 4399cef..619c3de 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -1,7 +1,10 @@ +#include "common.h" + #include "cmainwindow.h" #include "ui_cmainwindow.h" #include "ctextdocument.h" +#include "ctextedit.h" #include "cpartwindow.h" @@ -32,11 +35,20 @@ cMainWindow::cMainWindow(QWidget *parent) : m_lpPlaceModel(0), m_lpObjectModel(0), m_bUpdatingTab(false), - m_lpStoryBook(0) + m_lpStoryBook(0), + m_lpFileMenu(0), + m_lpEditMenu(0), + m_lpTextMenu(0), + m_lpFileToolBar(0), + m_lpEditToolBar(0), + m_lpTextToolBar(0), + m_lpFormatToolBar(0) { initUI(); createActions(); + //disableTextEdit(); + QString szPath = QDir::homePath() + QDir::separator() + "OneDrive - WINDESIGN" + QDir::separator() + "__BOOKS__" + QDir::separator() + "qtStoryWriter" + QDir::separator() + "rückwärts.storyWriter" ; m_lpStoryBook = new cStoryBook(szPath); m_lpStoryBook->fillOutlineList(ui->m_lpOutlineList); @@ -56,6 +68,26 @@ cMainWindow::~cMainWindow() delete ui; } +QAction* cMainWindow::actionAlignLeft() +{ + return(m_lpActionAlignLeft); +} + +QAction* cMainWindow::actionAlignCenter() +{ + return(m_lpActionAlignCenter); +} + +QAction* cMainWindow::actionAlignRight() +{ + return(m_lpActionAlignRight); +} + +QAction* cMainWindow::actionAlignJustify() +{ + return(m_lpActionAlignJustify); +} + void cMainWindow::closeEvent(QCloseEvent *event) { QSettings settings; @@ -132,95 +164,91 @@ void cMainWindow::createActions() void cMainWindow::createFileActions() { QAction* lpAction; - QToolBar* lpToolBar = addToolBar(tr("File Actions")); - QMenu* lpMenu = menuBar()->addMenu(tr("&File")); + + m_lpFileMenu = menuBar()->addMenu(tr("&File")); + m_lpFileToolBar = addToolBar(tr("File Actions")); const QIcon newIcon = QIcon::fromTheme("document-new", QIcon(":/images/mac/filenew.png")); - lpAction = lpMenu->addAction(newIcon, tr("&New"), this, &cMainWindow::onFileNew); - lpToolBar->addAction(lpAction); + lpAction = m_lpFileMenu->addAction(newIcon, tr("&New"), this, &cMainWindow::onFileNew); + m_lpFileToolBar->addAction(lpAction); lpAction->setPriority(QAction::LowPriority); lpAction->setShortcut(QKeySequence::New); const QIcon openIcon = QIcon::fromTheme("document-open", QIcon(":/images/mac/fileopen.png")); - lpAction = lpMenu->addAction(openIcon, tr("&Open..."), this, &cMainWindow::onFileOpen); + lpAction = m_lpFileMenu->addAction(openIcon, tr("&Open..."), this, &cMainWindow::onFileOpen); lpAction->setShortcut(QKeySequence::Open); - lpToolBar->addAction(lpAction); + m_lpFileToolBar->addAction(lpAction); - lpMenu->addSeparator(); + m_lpFileMenu->addSeparator(); const QIcon saveIcon = QIcon::fromTheme("document-save", QIcon(":/images/mac/filesave.png")); - m_lpActionSave = lpMenu->addAction(saveIcon, tr("&Save"), this, &cMainWindow::onFileSave); + m_lpActionSave = m_lpFileMenu->addAction(saveIcon, tr("&Save"), this, &cMainWindow::onFileSave); m_lpActionSave->setShortcut(QKeySequence::Save); m_lpActionSave->setEnabled(false); - lpToolBar->addAction(m_lpActionSave); + m_lpFileToolBar->addAction(m_lpActionSave); - lpAction = lpMenu->addAction(tr("Save &As..."), this, &cMainWindow::onFileSaveAs); + lpAction = m_lpFileMenu->addAction(tr("Save &As..."), this, &cMainWindow::onFileSaveAs); lpAction->setPriority(QAction::LowPriority); - lpMenu->addSeparator(); + m_lpFileMenu->addSeparator(); #ifndef QT_NO_PRINTER const QIcon printIcon = QIcon::fromTheme("document-print", QIcon(":/images/mac/fileprint.png")); - lpAction = lpMenu->addAction(printIcon, tr("&Print..."), this, &cMainWindow::onFilePrint); + lpAction = m_lpFileMenu->addAction(printIcon, tr("&Print..."), this, &cMainWindow::onFilePrint); lpAction->setPriority(QAction::LowPriority); lpAction->setShortcut(QKeySequence::Print); - lpToolBar->addAction(lpAction); + m_lpFileToolBar->addAction(lpAction); const QIcon filePrintIcon = QIcon::fromTheme("fileprint", QIcon(":/images/mac/fileprint.png")); - lpMenu->addAction(filePrintIcon, tr("Print Preview..."), this, &cMainWindow::onFilePrintPreview); + m_lpFileMenu->addAction(filePrintIcon, tr("Print Preview..."), this, &cMainWindow::onFilePrintPreview); const QIcon exportPdfIcon = QIcon::fromTheme("exportpdf", QIcon(":/images/mac/exportpdf.png")); - lpAction = lpMenu->addAction(exportPdfIcon, tr("&Export PDF..."), this, &cMainWindow::onFilePrintPdf); + lpAction = m_lpFileMenu->addAction(exportPdfIcon, tr("&Export PDF..."), this, &cMainWindow::onFilePrintPdf); lpAction->setPriority(QAction::LowPriority); lpAction->setShortcut(Qt::CTRL + Qt::Key_D); - lpToolBar->addAction(lpAction); + m_lpFileToolBar->addAction(lpAction); - lpMenu->addSeparator(); + m_lpFileMenu->addSeparator(); #endif - lpAction = lpMenu->addAction(tr("&Quit"), this, &QWidget::close); + lpAction = m_lpFileMenu->addAction(tr("&Quit"), this, &QWidget::close); lpAction->setShortcut(Qt::CTRL + Qt::Key_Q); } void cMainWindow::createEditActions() { - QToolBar* lpToolBar = addToolBar(tr("Edit Actions")); - QMenu* lpMenu = menuBar()->addMenu(tr("&Edit")); + m_lpEditMenu = menuBar()->addMenu(tr("&Edit")); + m_lpEditToolBar = addToolBar(tr("Edit Actions")); const QIcon undoIcon = QIcon::fromTheme("edit-undo", QIcon(":/images/mac/editundo.png")); -// m_lpActionUndo = lpMenu->addAction(undoIcon, tr("&Undo"), textEdit, &QTextEdit::undo); - m_lpActionUndo = lpMenu->addAction(undoIcon, tr("&Undo"), this, &cMainWindow::onSpecialUndo); + m_lpActionUndo = m_lpEditMenu->addAction(undoIcon, tr("&Undo")); m_lpActionUndo->setShortcut(QKeySequence::Undo); - lpToolBar->addAction(m_lpActionUndo); + m_lpEditToolBar->addAction(m_lpActionUndo); const QIcon redoIcon = QIcon::fromTheme("edit-redo", QIcon(":/images/mac/editredo.png")); -// m_lpActionRedo = lpMenu->addAction(redoIcon, tr("&Redo"), textEdit, &QTextEdit::redo); - m_lpActionRedo = lpMenu->addAction(redoIcon, tr("&Redo"), this, &cMainWindow::onSpecialRedo); + m_lpActionRedo = m_lpEditMenu->addAction(redoIcon, tr("&Redo")); m_lpActionRedo->setPriority(QAction::LowPriority); m_lpActionRedo->setShortcut(QKeySequence::Redo); - lpToolBar->addAction(m_lpActionRedo); - lpMenu->addSeparator(); + m_lpEditToolBar->addAction(m_lpActionRedo); + m_lpEditMenu->addSeparator(); #ifndef QT_NO_CLIPBOARD const QIcon cutIcon = QIcon::fromTheme("edit-cut", QIcon(":/images/mac/editcut.png")); -// m_lpActionCut = lpMenu->addAction(cutIcon, tr("Cu&t"), textEdit, &QTextEdit::cut); - m_lpActionCut = lpMenu->addAction(cutIcon, tr("Cu&t"), this, &cMainWindow::onSpecialCut); + m_lpActionCut = m_lpEditMenu->addAction(cutIcon, tr("Cu&t")); m_lpActionCut->setPriority(QAction::LowPriority); m_lpActionCut->setShortcut(QKeySequence::Cut); - lpToolBar->addAction(m_lpActionCut); + m_lpEditToolBar->addAction(m_lpActionCut); const QIcon copyIcon = QIcon::fromTheme("edit-copy", QIcon(":/images/mac/editcopy.png")); -// m_lpActionCopy = lpMenu->addAction(copyIcon, tr("&Copy"), textEdit, &QTextEdit::copy); - m_lpActionCopy = lpMenu->addAction(copyIcon, tr("&Copy"), this, &cMainWindow::onSpecialCopy); + m_lpActionCopy = m_lpEditMenu->addAction(copyIcon, tr("&Copy")); m_lpActionCopy->setPriority(QAction::LowPriority); m_lpActionCopy->setShortcut(QKeySequence::Copy); - lpToolBar->addAction(m_lpActionCopy); + m_lpEditToolBar->addAction(m_lpActionCopy); const QIcon pasteIcon = QIcon::fromTheme("edit-paste", QIcon(":/images/mac/editpaste.png")); -// m_lpActionPaste = lpMenu->addAction(pasteIcon, tr("&Paste"), textEdit, &QTextEdit::paste); - m_lpActionPaste = lpMenu->addAction(pasteIcon, tr("&Paste"), this, &cMainWindow::onSpecialPaste); + m_lpActionPaste = m_lpEditMenu->addAction(pasteIcon, tr("&Paste")); m_lpActionPaste->setPriority(QAction::LowPriority); m_lpActionPaste->setShortcut(QKeySequence::Paste); - lpToolBar->addAction(m_lpActionPaste); + m_lpEditToolBar->addAction(m_lpActionPaste); if(const QMimeData* md = QApplication::clipboard()->mimeData()) m_lpActionPaste->setEnabled(md->hasText()); #endif @@ -228,40 +256,40 @@ void cMainWindow::createEditActions() void cMainWindow::createTextActions() { - QToolBar* lpToolBar = addToolBar(tr("Format Actions")); - QMenu* lpMenu = menuBar()->addMenu(tr("F&ormat")); + m_lpTextMenu = menuBar()->addMenu(tr("F&ormat")); + m_lpTextToolBar = addToolBar(tr("Format Actions")); const QIcon boldIcon = QIcon::fromTheme("format-text-bold", QIcon(":/images/mac/textbold.png")); - m_lpActionTextBold = lpMenu->addAction(boldIcon, tr("&Bold"), this, &cMainWindow::onTextBold); + m_lpActionTextBold = m_lpTextMenu->addAction(boldIcon, tr("&Bold")); m_lpActionTextBold->setShortcut(Qt::CTRL + Qt::Key_B); m_lpActionTextBold->setPriority(QAction::LowPriority); QFont bold; bold.setBold(true); m_lpActionTextBold->setFont(bold); - lpToolBar->addAction(m_lpActionTextBold); + m_lpTextToolBar->addAction(m_lpActionTextBold); m_lpActionTextBold->setCheckable(true); const QIcon italicIcon = QIcon::fromTheme("format-text-italic", QIcon(":/images/mac/textitalic.png")); - m_lpActionTextItalic = lpMenu->addAction(italicIcon, tr("&Italic"), this, &cMainWindow::onTextItalic); + m_lpActionTextItalic = m_lpTextMenu->addAction(italicIcon, tr("&Italic")); m_lpActionTextItalic->setPriority(QAction::LowPriority); m_lpActionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I); QFont italic; italic.setItalic(true); m_lpActionTextItalic->setFont(italic); - lpToolBar->addAction(m_lpActionTextItalic); + m_lpTextToolBar->addAction(m_lpActionTextItalic); m_lpActionTextItalic->setCheckable(true); const QIcon underlineIcon = QIcon::fromTheme("format-text-underline", QIcon(":/images/mac/textunder.png")); - m_lpActionTextUnderline = lpMenu->addAction(underlineIcon, tr("&Underline"), this, &cMainWindow::onTextUnderline); + m_lpActionTextUnderline = m_lpTextMenu->addAction(underlineIcon, tr("&Underline")); m_lpActionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U); m_lpActionTextUnderline->setPriority(QAction::LowPriority); QFont underline; underline.setUnderline(true); m_lpActionTextUnderline->setFont(underline); - lpToolBar->addAction(m_lpActionTextUnderline); + m_lpTextToolBar->addAction(m_lpActionTextUnderline); m_lpActionTextUnderline->setCheckable(true); - lpMenu->addSeparator(); + m_lpTextMenu->addSeparator(); const QIcon leftIcon = QIcon::fromTheme("format-justify-left", QIcon(":/images/mac/textleft.png")); m_lpActionAlignLeft = new QAction(leftIcon, tr("&Left"), this); @@ -285,67 +313,107 @@ void cMainWindow::createTextActions() m_lpActionAlignJustify->setPriority(QAction::LowPriority); // Make sure the alignLeft is always left of the alignRight - QActionGroup* alignGroup = new QActionGroup(this); - connect(alignGroup, &QActionGroup::triggered, this, &cMainWindow::onTextAlign); + m_lpAlignGroup = new QActionGroup(this); if(QApplication::isLeftToRight()) { - alignGroup->addAction(m_lpActionAlignLeft); - alignGroup->addAction(m_lpActionAlignCenter); - alignGroup->addAction(m_lpActionAlignRight); + m_lpAlignGroup->addAction(m_lpActionAlignLeft); + m_lpAlignGroup->addAction(m_lpActionAlignCenter); + m_lpAlignGroup->addAction(m_lpActionAlignRight); } else { - alignGroup->addAction(m_lpActionAlignRight); - alignGroup->addAction(m_lpActionAlignCenter); - alignGroup->addAction(m_lpActionAlignLeft); + m_lpAlignGroup->addAction(m_lpActionAlignRight); + m_lpAlignGroup->addAction(m_lpActionAlignCenter); + m_lpAlignGroup->addAction(m_lpActionAlignLeft); } - alignGroup->addAction(m_lpActionAlignJustify); + m_lpAlignGroup->addAction(m_lpActionAlignJustify); - lpToolBar->addActions(alignGroup->actions()); - lpMenu->addActions(alignGroup->actions()); + m_lpTextToolBar->addActions(m_lpAlignGroup->actions()); + m_lpTextMenu->addActions(m_lpAlignGroup->actions()); - lpMenu->addSeparator(); + m_lpTextMenu->addSeparator(); QPixmap pix(16, 16); pix.fill(Qt::black); - m_lpActionTextColor = lpMenu->addAction(pix, tr("&Color..."), this, &cMainWindow::onTextColor); - lpToolBar->addAction(m_lpActionTextColor); + m_lpActionTextColor = m_lpTextMenu->addAction(pix, tr("&Color...")); + m_lpTextToolBar->addAction(m_lpActionTextColor); - lpToolBar = addToolBar(tr("Format Actions")); - lpToolBar->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea); + m_lpFormatToolBar = addToolBar(tr("Format Actions")); + m_lpFormatToolBar->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea); addToolBarBreak(Qt::TopToolBarArea); - addToolBar(lpToolBar); + addToolBar(m_lpFormatToolBar); - m_lpComboStyle = new QComboBox(lpToolBar); - lpToolBar->addWidget(m_lpComboStyle); - m_lpComboStyle->addItem("Standard"); - m_lpComboStyle->addItem("Bullet List (Disc)"); - m_lpComboStyle->addItem("Bullet List (Circle)"); - m_lpComboStyle->addItem("Bullet List (Square)"); - m_lpComboStyle->addItem("Ordered List (Decimal)"); - m_lpComboStyle->addItem("Ordered List (Alpha lower)"); - m_lpComboStyle->addItem("Ordered List (Alpha upper)"); - m_lpComboStyle->addItem("Ordered List (Roman lower)"); - m_lpComboStyle->addItem("Ordered List (Roman upper)"); + m_lpComboFont = new QFontComboBox(m_lpFormatToolBar); + m_lpFormatToolBar->addWidget(m_lpComboFont); + m_focusException.append(m_lpComboFont); - connect(m_lpComboStyle, QOverload::of(&QComboBox::activated), this, &cMainWindow::onTextStyle); - - m_lpComboFont = new QFontComboBox(lpToolBar); - lpToolBar->addWidget(m_lpComboFont); - connect(m_lpComboFont, QOverload::of(&QComboBox::activated), this, &cMainWindow::onTextFamily); - - m_lpComboSize = new QComboBox(lpToolBar); + m_lpComboSize = new QComboBox(m_lpFormatToolBar); m_lpComboSize->setObjectName("comboSize"); - lpToolBar->addWidget(m_lpComboSize); + m_lpFormatToolBar->addWidget(m_lpComboSize); m_lpComboSize->setEditable(true); const QList standardSizes = QFontDatabase::standardSizes(); foreach(int size, standardSizes) m_lpComboSize->addItem(QString::number(size)); m_lpComboSize->setCurrentIndex(standardSizes.indexOf(QApplication::font().pointSize())); + m_focusException.append(m_lpComboSize); +} - connect(m_lpComboSize, QOverload::of(&QComboBox::activated), this, &cMainWindow::onTextSize); +void cMainWindow::disableTextEdit() +{ + m_lpEditMenu->setEnabled(false); + m_lpEditToolBar->setEnabled(false); + m_lpTextMenu->setEnabled(false); + m_lpTextToolBar->setEnabled(false); + m_lpFormatToolBar->setEnabled(false); +} + +void cMainWindow::prepareTextEdit(cTextEdit* lpTextEdit) +{ + m_lpEditMenu->setEnabled(true); + m_lpEditToolBar->setEnabled(true); + m_lpTextMenu->setEnabled(true); + m_lpTextToolBar->setEnabled(true); + m_lpFormatToolBar->setEnabled(true); + + connect(m_lpActionTextBold, &QAction::triggered, lpTextEdit, &cTextEdit::onTextBold); + connect(m_lpActionTextItalic, &QAction::triggered, lpTextEdit, &cTextEdit::onTextItalic); + connect(m_lpActionTextUnderline, &QAction::triggered, lpTextEdit, &cTextEdit::onTextUnderline); + + connect(m_lpActionTextColor, &QAction::triggered, lpTextEdit, &cTextEdit::onTextColor); + + connect(lpTextEdit->document(), &cTextDocument::undoAvailable, m_lpActionUndo, &QAction::setEnabled); + connect(lpTextEdit->document(), &cTextDocument::redoAvailable, m_lpActionRedo, &QAction::setEnabled); + m_lpActionUndo->setEnabled(lpTextEdit->document()->isUndoAvailable()); + m_lpActionRedo->setEnabled(lpTextEdit->document()->isRedoAvailable()); + + connect(m_lpActionUndo, &QAction::triggered, lpTextEdit, &cTextEdit::undo); + connect(m_lpActionRedo, &QAction::triggered, lpTextEdit, &cTextEdit::redo); + +#ifndef QT_NO_CLIPBOARD + m_lpActionCut->setEnabled(false); + m_lpActionCopy->setEnabled(false); + + disconnect(m_lpActionCut, SIGNAL(triggered(bool))); + disconnect(m_lpActionCopy, SIGNAL(triggered(bool))); + disconnect(m_lpActionPaste, SIGNAL(triggered(bool))); + + connect(QApplication::clipboard(), &QClipboard::dataChanged, this, &cMainWindow::onClipboardDataChanged); + + connect(m_lpActionCut, SIGNAL(triggered(bool)), lpTextEdit, SLOT(cut())); + connect(m_lpActionCopy, SIGNAL(triggered(bool)), lpTextEdit, SLOT(copy())); + connect(m_lpActionPaste, SIGNAL(triggered(bool)), lpTextEdit, SLOT(paste())); +#endif + + connect(m_lpAlignGroup, &QActionGroup::triggered, lpTextEdit, &cTextEdit::onTextAlign); + + connect(m_lpComboFont, QOverload::of(&QComboBox::activated), lpTextEdit, &cTextEdit::onTextFamily); + connect(m_lpComboSize, QOverload::of(&QComboBox::activated), lpTextEdit, &cTextEdit::onTextSize); + + connect(lpTextEdit, &cTextEdit::fontChanged, this, &cMainWindow::onFontChanged); + connect(lpTextEdit, &cTextEdit::colorChanged, this, &cMainWindow::onColorChanged); + connect(lpTextEdit, &cTextEdit::alignmentChanged, this, &cMainWindow::onAlignmentChanged); } void cMainWindow::updateWindowTitle() @@ -365,6 +433,87 @@ void cMainWindow::updateWindowTitle() setWindowTitle(QString("\"%1\" by %2 - qtStoryWriter").arg(szTitle).arg(szAuthor)); } +void cMainWindow::onTextEditGotFocus(cTextEdit* lpTextEdit) +{ + prepareTextEdit(lpTextEdit); +} + +void cMainWindow::onTextEditLostFocus(cTextEdit* /*lpTextEdit*/) +{ +} + +void cMainWindow::onLineEditGotFocus(cLineEdit* /*lpLineEdit*/) +{ + disableTextEdit(); +} + +void cMainWindow::onLineEditLostFocus(cLineEdit* /*lpLineEdit*/) +{ +} + +void cMainWindow::onTreeViewGotFocus(cTreeView* /*lpTreeView*/) +{ + disableTextEdit(); +} + +void cMainWindow::onTreeViewLostFocus(cTreeView * /*lpTreeView*/) +{ +} + +void cMainWindow::onCheckBoxGotFocus(cCheckBox* /*lpCheckBox*/) +{ + disableTextEdit(); +} + +void cMainWindow::onCheckBoxLostFocus(cCheckBox* /*lpCheckBox*/) +{ +} + +void cMainWindow::onRadioButtonGotFocus(cRadioButton* /*lpRadioButton*/) +{ + disableTextEdit(); +} + +void cMainWindow::onRadioButtonLostFocus(cRadioButton* /*lpRadioButton*/) +{ +} + +void cMainWindow::onDateEditGotFocus(cDateEdit* /*lpDateEdit*/) +{ + disableTextEdit(); +} + +void cMainWindow::onDateEditLostFocus(cDateEdit* /*lpDateEdit*/) +{ +} + +void cMainWindow::onDoubleSpinBoxGotFocus(cDoubleSpinBox* /*lpDoubleSpinBox*/) +{ + disableTextEdit(); +} + +void cMainWindow::onDoubleSpinBoxLostFocus(cDoubleSpinBox* /*lpDoubleSpinBox*/) +{ +} + +void cMainWindow::onDateTimeEditGotFocus(cDateTimeEdit* /*lpDateTimeEdit*/) +{ + disableTextEdit(); +} + +void cMainWindow::onDateTimeEditLostFocus(cDateTimeEdit* /*lpDateTimeEdit*/) +{ +} + +void cMainWindow::onComboBoxGotFocus(cComboBox* /*lpComboBox*/) +{ + disableTextEdit(); +} + +void cMainWindow::onComboBoxLostFocus(cComboBox* /*lpComboBox*/) +{ +} + void cMainWindow::onMainTabCurrentChanged(int /*index*/) { if(m_bUpdatingTab) @@ -721,54 +870,38 @@ void cMainWindow::onFilePrintPdf() { } -void cMainWindow::onTextBold() +void cMainWindow::onClipboardDataChanged() { +#ifndef QT_NO_CLIPBOARD + if(const QMimeData *md = QApplication::clipboard()->mimeData()) + m_lpActionPaste->setEnabled(md->hasText()); +#endif } -void cMainWindow::onTextItalic() +void cMainWindow::onFontChanged(const QFont& font) { + m_lpComboFont->setCurrentIndex(m_lpComboFont->findText(QFontInfo(font).family())); + m_lpComboSize->setCurrentIndex(m_lpComboSize->findText(QString::number(font.pointSize()))); + m_lpActionTextBold->setChecked(font.bold()); + m_lpActionTextItalic->setChecked(font.italic()); + m_lpActionTextUnderline->setChecked(font.underline()); } -void cMainWindow::onTextUnderline() +void cMainWindow::onColorChanged(const QColor& color) { + QPixmap pix(16, 16); + pix.fill(color); + m_lpActionTextColor->setIcon(pix); } -void cMainWindow::onTextAlign(QAction *a) -{ -} - -void cMainWindow::onTextFamily(const QString &f) -{ -} - -void cMainWindow::onTextSize(const QString &p) -{ -} - -void cMainWindow::onTextStyle(int styleIndex) -{ -} - -void cMainWindow::onTextColor() -{ -} - -void cMainWindow::onSpecialUndo() -{ -} - -void cMainWindow::onSpecialRedo() -{ -} - -void cMainWindow::onSpecialCut() -{ -} - -void cMainWindow::onSpecialCopy() -{ -} - -void cMainWindow::onSpecialPaste() +void cMainWindow::onAlignmentChanged(const Qt::Alignment &alignment) { + if(alignment & Qt::AlignLeft) + m_lpActionAlignLeft->setChecked(true); + else if(alignment & Qt::AlignHCenter) + m_lpActionAlignCenter->setChecked(true); + else if(alignment & Qt::AlignRight) + m_lpActionAlignRight->setChecked(true); + else if(alignment & Qt::AlignJustify) + m_lpActionAlignJustify->setChecked(true); } diff --git a/cmainwindow.h b/cmainwindow.h index 95f5804..a2e1056 100644 --- a/cmainwindow.h +++ b/cmainwindow.h @@ -3,6 +3,15 @@ #include "cstorybook.h" +#include "ctextedit.h" +#include "clineedit.h" +#include "ctreeview.h" +#include "ccheckbox.h" +#include "cradiobutton.h" +#include "cdateedit.h" +#include "cdoublespinbox.h" +#include "cdatetimeedit.h" +#include "ccombobox.h" #include #include @@ -14,6 +23,8 @@ #include +#include + namespace Ui { class cMainWindow; @@ -24,12 +35,36 @@ class cMainWindow : public QMainWindow Q_OBJECT public: - explicit cMainWindow(QWidget *parent = 0); + explicit cMainWindow(QWidget* parent = 0); ~cMainWindow(); void updateWindowTitle(); + QAction* actionAlignLeft(); + QAction* actionAlignCenter(); + QAction* actionAlignRight(); + QAction* actionAlignJustify(); + private slots: + void onTextEditGotFocus(cTextEdit* lpTextEdit); + void onTextEditLostFocus(cTextEdit* lpTextEdit); + void onLineEditGotFocus(cLineEdit* lpLineEdit); + void onLineEditLostFocus(cLineEdit* lpLineEdit); + void onTreeViewGotFocus(cTreeView* lpTreeView); + void onTreeViewLostFocus(cTreeView* lpTreeView); + void onCheckBoxGotFocus(cCheckBox* CheckBox); + void onCheckBoxLostFocus(cCheckBox* lpCheckBox); + void onRadioButtonGotFocus(cRadioButton* lpRadioButton); + void onRadioButtonLostFocus(cRadioButton* lpRadioButton); + void onDateEditGotFocus(cDateEdit* lpDateEdit); + void onDateEditLostFocus(cDateEdit* lpDateEdit); + void onDoubleSpinBoxGotFocus(cDoubleSpinBox* lpDoubleSpinBox); + void onDoubleSpinBoxLostFocus(cDoubleSpinBox* lpDoubleSpinBox); + void onDateTimeEditGotFocus(cDateTimeEdit* lpDateTimeEdit); + void onDateTimeEditLostFocus(cDateTimeEdit* lpDateTimeEdit); + void onComboBoxGotFocus(cComboBox* lpComboBox); + void onComboBoxLostFocus(cComboBox* lpComboBox); + void onMainTabCurrentChanged(int index); void onMainTabTabCloseRequested(int index); void onMdiAreaSubWindowActivated(QMdiSubWindow *arg1); @@ -58,22 +93,11 @@ private slots: void onFilePrintPreview(); void onFilePrintPdf(); - void onTextBold(); - void onTextItalic(); - void onTextUnderline(); + void onClipboardDataChanged(); - void onTextFamily(const QString &f); - void onTextSize(const QString &p); - void onTextStyle(int styleIndex); - void onTextColor(); - - void onTextAlign(QAction *a); - - void onSpecialUndo(); - void onSpecialRedo(); - void onSpecialCut(); - void onSpecialCopy(); - void onSpecialPaste(); + void onFontChanged(const QFont& font); + void onColorChanged(const QColor& color); + void onAlignmentChanged(const Qt::Alignment& alignment); private: Ui::cMainWindow* ui; @@ -85,6 +109,16 @@ private: bool m_bUpdatingTab; cStoryBook* m_lpStoryBook; + QList m_focusException; + + QMenu* m_lpFileMenu; + QMenu* m_lpEditMenu; + QMenu* m_lpTextMenu; + + QToolBar* m_lpFileToolBar; + QToolBar* m_lpEditToolBar; + QToolBar* m_lpTextToolBar; + QToolBar* m_lpFormatToolBar; QAction* m_lpActionSave; QAction* m_lpActionUndo; QAction* m_lpActionRedo; @@ -104,7 +138,8 @@ private: QAction* m_lpActionCopy; QAction* m_lpActionPaste; - QComboBox* m_lpComboStyle; + QActionGroup* m_lpAlignGroup; + QFontComboBox* m_lpComboFont; QComboBox* m_lpComboSize; @@ -115,6 +150,9 @@ private: void createEditActions(); void createTextActions(); + void disableTextEdit(); + void prepareTextEdit(cTextEdit* lpTextEdit); + protected: void closeEvent(QCloseEvent *event); }; diff --git a/cobjectwindow.cpp b/cobjectwindow.cpp index cd722e9..25c039a 100644 --- a/cobjectwindow.cpp +++ b/cobjectwindow.cpp @@ -3,6 +3,8 @@ #include "cimagewidget.h" +#include "cmainwindow.h" + #include @@ -12,6 +14,15 @@ cObjectWindow::cObjectWindow(QWidget *parent) : m_lpObject(0) { ui->setupUi(this); + + connect(ui->m_lpName, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpName, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpType, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpType, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpDescription, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); + connect(ui->m_lpDescription, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); } cObjectWindow::~cObjectWindow() diff --git a/cobjectwindow.ui b/cobjectwindow.ui index 3a878f8..55be58b 100644 --- a/cobjectwindow.ui +++ b/cobjectwindow.ui @@ -27,10 +27,10 @@ - + - + @@ -53,7 +53,7 @@ - + @@ -115,6 +115,18 @@
+ + + cTextEdit + QTextEdit +
ctextedit.h
+
+ + cLineEdit + QLineEdit +
clineedit.h
+
+
m_lpName m_lpDescription diff --git a/cpartwindow.cpp b/cpartwindow.cpp index 9b8ff23..7c5b4cf 100644 --- a/cpartwindow.cpp +++ b/cpartwindow.cpp @@ -1,6 +1,8 @@ #include "cpartwindow.h" #include "ui_cpartwindow.h" +#include "cmainwindow.h" + #include @@ -14,6 +16,18 @@ cPartWindow::cPartWindow(QWidget *parent) : m_lpChapterModel = new QStandardItemModel(0, 1); ui->m_lpChapterList->setModel(m_lpChapterModel); + + connect(ui->m_lpDescription, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); + connect(ui->m_lpDescription, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); + + connect(ui->m_lpText, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); + connect(ui->m_lpText, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); + + connect(ui->m_lpName, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpName, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpChapterList, SIGNAL(gotFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewGotFocus(cTreeView*))); + connect(ui->m_lpChapterList, SIGNAL(lostFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewLostFocus(cTreeView*))); } cPartWindow::~cPartWindow() diff --git a/cpartwindow.h b/cpartwindow.h index 1224107..86c5c67 100644 --- a/cpartwindow.h +++ b/cpartwindow.h @@ -25,6 +25,7 @@ public: void setPart(cPart* lpPart, cChapterList* lpChapterList); cPart* part(); + private: Ui::cPartWindow* ui; cPart* m_lpPart; diff --git a/cpartwindow.ui b/cpartwindow.ui index 560a34b..530a4b1 100644 --- a/cpartwindow.ui +++ b/cpartwindow.ui @@ -27,7 +27,7 @@
- + @@ -43,7 +43,7 @@ - + @@ -56,7 +56,7 @@ - + QAbstractItemView::NoEditTriggers @@ -81,6 +81,16 @@ QTextEdit
ctextedit.h
+ + cLineEdit + QLineEdit +
clineedit.h
+
+ + cTreeView + QTreeView +
ctreeview.h
+
m_lpName diff --git a/cplacewindow.cpp b/cplacewindow.cpp index 900d611..a26419a 100644 --- a/cplacewindow.cpp +++ b/cplacewindow.cpp @@ -3,6 +3,8 @@ #include "cimagewidget.h" +#include "cmainwindow.h" + #include @@ -12,6 +14,18 @@ cPlaceWindow::cPlaceWindow(QWidget *parent) : m_lpPlace(0) { ui->setupUi(this); + + connect(ui->m_lpName, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpName, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpType, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpType, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpLocation, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpLocation, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpDescription, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); + connect(ui->m_lpDescription, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); } cPlaceWindow::~cPlaceWindow() diff --git a/cplacewindow.ui b/cplacewindow.ui index 8399e82..333c6ff 100644 --- a/cplacewindow.ui +++ b/cplacewindow.ui @@ -47,7 +47,7 @@
- + @@ -60,7 +60,7 @@ - + @@ -73,10 +73,10 @@ - + - + @@ -128,6 +128,18 @@
+ + + cTextEdit + QTextEdit +
ctextedit.h
+
+ + cLineEdit + QLineEdit +
clineedit.h
+
+
m_lpName m_lpType diff --git a/cradiobutton.cpp b/cradiobutton.cpp new file mode 100644 index 0000000..b4bc5bd --- /dev/null +++ b/cradiobutton.cpp @@ -0,0 +1,19 @@ +#include "cradiobutton.h" + + +cRadioButton::cRadioButton(QWidget* parent) : + QRadioButton(parent) +{ +} + +void cRadioButton::focusInEvent(QFocusEvent* event) +{ + gotFocus(this); + QRadioButton::focusInEvent(event); +} + +void cRadioButton::focusOutEvent(QFocusEvent* event) +{ + lostFocus(this); + QRadioButton::focusOutEvent(event); +} diff --git a/cradiobutton.h b/cradiobutton.h new file mode 100644 index 0000000..61ee88c --- /dev/null +++ b/cradiobutton.h @@ -0,0 +1,27 @@ +#ifndef CRADIOBUTTON_H +#define CRADIOBUTTON_H + + +#include +#include + + +class cRadioButton : public QRadioButton +{ + Q_OBJECT + +public: + cRadioButton(QWidget* parent = Q_NULLPTR); + +signals: + void gotFocus(cRadioButton* lpRadioButton); + void lostFocus(cRadioButton* lpRadioButton); + +protected: + void focusInEvent(QFocusEvent *event); + void focusOutEvent(QFocusEvent *event); +}; + +Q_DECLARE_METATYPE(cRadioButton*) + +#endif // CRADIOBUTTON_H diff --git a/crecherchewindow.cpp b/crecherchewindow.cpp index b3cbe50..8049085 100644 --- a/crecherchewindow.cpp +++ b/crecherchewindow.cpp @@ -3,6 +3,8 @@ #include "cimagewidget.h" +#include "cmainwindow.h" + #include @@ -28,6 +30,24 @@ cRechercheWindow::cRechercheWindow(QWidget *parent) : connect(ui->m_lpCharacterList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onCharacterDoubleClicked(QModelIndex))); connect(ui->m_lpPlaceList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onPlaceDoubleClicked(QModelIndex))); connect(ui->m_lpObjectList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onObjectDoubleClicked(QModelIndex))); + + connect(ui->m_lpName, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpName, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpLink, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpLink, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpDescription, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); + connect(ui->m_lpDescription, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); + + connect(ui->m_lpCharacterList, SIGNAL(gotFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewGotFocus(cTreeView*))); + connect(ui->m_lpCharacterList, SIGNAL(lostFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewLostFocus(cTreeView*))); + + connect(ui->m_lpObjectList, SIGNAL(gotFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewGotFocus(cTreeView*))); + connect(ui->m_lpObjectList, SIGNAL(lostFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewLostFocus(cTreeView*))); + + connect(ui->m_lpPlaceList, SIGNAL(gotFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewGotFocus(cTreeView*))); + connect(ui->m_lpPlaceList, SIGNAL(lostFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewLostFocus(cTreeView*))); } cRechercheWindow::~cRechercheWindow() diff --git a/crecherchewindow.ui b/crecherchewindow.ui index 51b61eb..572ba3f 100644 --- a/crecherchewindow.ui +++ b/crecherchewindow.ui @@ -37,7 +37,7 @@ - + @@ -50,10 +50,10 @@ - + - + @@ -117,7 +117,7 @@ - + QAbstractItemView::NoEditTriggers @@ -131,7 +131,7 @@ - + QAbstractItemView::NoEditTriggers @@ -145,7 +145,7 @@ - + QAbstractItemView::NoEditTriggers @@ -157,6 +157,23 @@ + + + cTextEdit + QTextEdit +
ctextedit.h
+
+ + cLineEdit + QLineEdit +
clineedit.h
+
+ + cTreeView + QTreeView +
ctreeview.h
+
+
m_lpName m_lpLink diff --git a/cscenewindow.cpp b/cscenewindow.cpp index 763884d..a2d0b9c 100644 --- a/cscenewindow.cpp +++ b/cscenewindow.cpp @@ -1,6 +1,8 @@ #include "cscenewindow.h" #include "ui_cscenewindow.h" +#include "cmainwindow.h" + #include @@ -42,6 +44,42 @@ cSceneWindow::cSceneWindow(QWidget *parent) : connect(ui->m_lpCharacterList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onCharacterDoubleClicked(QModelIndex))); connect(ui->m_lpPlaceList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onPlaceDoubleClicked(QModelIndex))); connect(ui->m_lpObjectList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onObjectDoubleClicked(QModelIndex))); + + connect(ui->m_lpPart, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpPart, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpChapter, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpChapter, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpName, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); + connect(ui->m_lpName, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + + connect(ui->m_lpDescription, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); + connect(ui->m_lpDescription, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); + + connect(ui->m_lpCharacterList, SIGNAL(gotFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewGotFocus(cTreeView*))); + connect(ui->m_lpCharacterList, SIGNAL(lostFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewLostFocus(cTreeView*))); + + connect(ui->m_lpObjectList, SIGNAL(gotFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewGotFocus(cTreeView*))); + connect(ui->m_lpObjectList, SIGNAL(lostFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewLostFocus(cTreeView*))); + + connect(ui->m_lpPlaceList, SIGNAL(gotFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewGotFocus(cTreeView*))); + connect(ui->m_lpPlaceList, SIGNAL(lostFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewLostFocus(cTreeView*))); + + connect(ui->m_lpState, SIGNAL(gotFocus(cComboBox*)), (cMainWindow*)parent, SLOT(onComboBoxGotFocus(cComboBox*))); + connect(ui->m_lpState, SIGNAL(lostFocus(cComboBox*)), (cMainWindow*)parent, SLOT(onComboBoxLostFocus(cComboBox*))); + + connect(ui->m_lpStartedAt, SIGNAL(gotFocus(cDateTimeEdit*)), (cMainWindow*)parent, SLOT(onDateTimeEditGotFocus(cDateTimeEdit*))); + connect(ui->m_lpStartedAt, SIGNAL(lostFocus(cDateTimeEdit*)), (cMainWindow*)parent, SLOT(onDateTimeEditLostFocus(cDateTimeEdit*))); + + connect(ui->m_lpFinishedAt, SIGNAL(gotFocus(cDateTimeEdit*)), (cMainWindow*)parent, SLOT(onDateTimeEditGotFocus(cDateTimeEdit*))); + connect(ui->m_lpFinishedAt, SIGNAL(lostFocus(cDateTimeEdit*)), (cMainWindow*)parent, SLOT(onDateTimeEditLostFocus(cDateTimeEdit*))); + + connect(ui->m_lpTargetDate, SIGNAL(gotFocus(cDateTimeEdit*)), (cMainWindow*)parent, SLOT(onDateTimeEditGotFocus(cDateTimeEdit*))); + connect(ui->m_lpTargetDate, SIGNAL(lostFocus(cDateTimeEdit*)), (cMainWindow*)parent, SLOT(onDateTimeEditLostFocus(cDateTimeEdit*))); + + connect(ui->m_lpText, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); + connect(ui->m_lpText, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); } cSceneWindow::~cSceneWindow() diff --git a/cscenewindow.ui b/cscenewindow.ui index 1dc5e37..900ef34 100644 --- a/cscenewindow.ui +++ b/cscenewindow.ui @@ -19,7 +19,7 @@ - 3 + 0 @@ -27,7 +27,7 @@ - + @@ -37,7 +37,7 @@ - + QAbstractItemView::NoEditTriggers @@ -57,7 +57,7 @@ - + QAbstractItemView::NoEditTriggers @@ -77,7 +77,7 @@ - + QAbstractItemView::NoEditTriggers @@ -94,7 +94,7 @@ - + true @@ -121,7 +121,7 @@ - + @@ -157,10 +157,10 @@ - + - + true @@ -177,7 +177,7 @@ - + @@ -190,14 +190,14 @@ - + true - + true @@ -213,6 +213,26 @@ QTextEdit
ctextedit.h
+ + cLineEdit + QLineEdit +
clineedit.h
+
+ + cTreeView + QTreeView +
ctreeview.h
+
+ + cComboBox + QComboBox +
ccombobox.h
+
+ + cDateTimeEdit + QDateTimeEdit +
cdatetimeedit.h
+
m_lpName diff --git a/ctextedit.cpp b/ctextedit.cpp index 9e2b5d3..63b0e6c 100644 --- a/ctextedit.cpp +++ b/ctextedit.cpp @@ -1,14 +1,34 @@ +#include "common.h" + #include "ctextedit.h" +#include "cmainwindow.h" + #include #include #include #include +#include +#include + +#include +#include + cTextEdit::cTextEdit(QWidget* parent) : QTextEdit(parent) { + connect(this, &cTextEdit::currentCharFormatChanged, this, &cTextEdit::onCurrentCharFormatChanged); + connect(this, &cTextEdit::cursorPositionChanged, this, &cTextEdit::onCursorPositionChanged); + + foreach(QWidget *w, qApp->topLevelWidgets()) + { + m_lpMainWindow = qobject_cast(w); + if(m_lpMainWindow) + return; + } + m_lpMainWindow = 0; } cTextEdit::cTextEdit(const QString& text, QWidget* parent) : @@ -61,3 +81,167 @@ void cTextEdit::dropTextFile(const QUrl& url) if(file.open(QIODevice::ReadOnly | QIODevice::Text)) textCursor().insertText(file.readAll()); } + +void cTextEdit::focusInEvent(QFocusEvent* event) +{ + gotFocus(this); + QTextEdit::focusInEvent(event); +} + +void cTextEdit::focusOutEvent(QFocusEvent* event) +{ + lostFocus(this); + QTextEdit::focusOutEvent(event); +} + +void cTextEdit::onCurrentCharFormatChanged(const QTextCharFormat &format) +{ + fontChanged(format.font()); + colorChanged(format.foreground().color()); +} + +void cTextEdit::onCursorPositionChanged() +{ + alignmentChanged(alignment()); +} + +void cTextEdit::onTextBold(bool isChecked) +{ + QTextCharFormat fmt; + fmt.setFontWeight(isChecked ? QFont::Bold : QFont::Normal); + mergeFormatOnWordOrSelection(fmt); +} + +void cTextEdit::onTextUnderline(bool isChecked) +{ + QTextCharFormat fmt; + fmt.setFontUnderline(isChecked); + mergeFormatOnWordOrSelection(fmt); +} + +void cTextEdit::onTextItalic(bool isChecked) +{ + QTextCharFormat fmt; + fmt.setFontItalic(isChecked); + mergeFormatOnWordOrSelection(fmt); +} + +void cTextEdit::onTextAlign(QAction *a) +{ + if(!m_lpMainWindow) + return; + + if(a == m_lpMainWindow->actionAlignLeft()) + setAlignment(Qt::AlignLeft | Qt::AlignAbsolute); + else if(a == m_lpMainWindow->actionAlignCenter()) + setAlignment(Qt::AlignHCenter); + else if(a == m_lpMainWindow->actionAlignRight()) + setAlignment(Qt::AlignRight | Qt::AlignAbsolute); + else if(a == m_lpMainWindow->actionAlignJustify()) + setAlignment(Qt::AlignJustify); +} + +void cTextEdit::onTextFamily(const QString &f) +{ + QTextCharFormat fmt; + fmt.setFontFamily(f); + mergeFormatOnWordOrSelection(fmt); +} + +void cTextEdit::onTextSize(const QString &p) +{ + qreal pointSize = p.toFloat(); + if(p.toFloat() > 0) + { + QTextCharFormat fmt; + fmt.setFontPointSize(pointSize); + mergeFormatOnWordOrSelection(fmt); + } +} + +void cTextEdit::onTextColor() +{ + QColor col = QColorDialog::getColor(textColor(), this); + if(!col.isValid()) + return; + QTextCharFormat fmt; + fmt.setForeground(col); + mergeFormatOnWordOrSelection(fmt); +// colorChanged(col); +} + +void cTextEdit::onTextStyle(int styleIndex) +{ + QTextCursor cursor = textCursor(); + + if(styleIndex != 0) + { + QTextListFormat::Style style = QTextListFormat::ListDisc; + + switch(styleIndex) + { + default: + case 1: + style = QTextListFormat::ListDisc; + break; + case 2: + style = QTextListFormat::ListCircle; + break; + case 3: + style = QTextListFormat::ListSquare; + break; + case 4: + style = QTextListFormat::ListDecimal; + break; + case 5: + style = QTextListFormat::ListLowerAlpha; + break; + case 6: + style = QTextListFormat::ListUpperAlpha; + break; + case 7: + style = QTextListFormat::ListLowerRoman; + break; + case 8: + style = QTextListFormat::ListUpperRoman; + break; + } + + cursor.beginEditBlock(); + + QTextBlockFormat blockFmt = cursor.blockFormat(); + QTextListFormat listFmt; + + if(cursor.currentList()) + { + listFmt = cursor.currentList()->format(); + } + else + { + listFmt.setIndent(blockFmt.indent() + 1); + blockFmt.setIndent(0); + cursor.setBlockFormat(blockFmt); + } + + listFmt.setStyle(style); + + cursor.createList(listFmt); + + cursor.endEditBlock(); + } + else + { + QTextBlockFormat bfmt; + bfmt.setObjectIndex(-1); + cursor.mergeBlockFormat(bfmt); + } +} + +void cTextEdit::mergeFormatOnWordOrSelection(const QTextCharFormat &format) +{ + QTextCursor cursor = textCursor(); + if(!cursor.hasSelection()) + cursor.select(QTextCursor::WordUnderCursor); + cursor.mergeCharFormat(format); + mergeCurrentCharFormat(format); +} diff --git a/ctextedit.h b/ctextedit.h index 0caf307..0a9f5d9 100644 --- a/ctextedit.h +++ b/ctextedit.h @@ -3,20 +3,59 @@ #include +#include +class cMainWindow; + class cTextEdit : public QTextEdit { + Q_OBJECT + public: cTextEdit(QWidget* parent = Q_NULLPTR); cTextEdit(const QString& text, QWidget* parent = Q_NULLPTR); - bool canInsertFromMimeData(const QMimeData* source) const; - void insertFromMimeData(const QMimeData* source); + bool canInsertFromMimeData(const QMimeData* source) const; + void insertFromMimeData(const QMimeData* source); + +signals: + void gotFocus(cTextEdit* lpTextEdit); + void lostFocus(cTextEdit* lpTextEdit); + + void fontChanged(const QFont& font); + void colorChanged(const QColor& color); + void alignmentChanged(const Qt::Alignment& alignment); + +public slots: + void onTextBold(bool isChecked); + void onTextUnderline(bool isChecked); + void onTextItalic(bool isChecked); + + void onTextAlign(QAction *a); + + void onTextFamily(const QString &f); + void onTextSize(const QString &p); + void onTextStyle(int styleIndex); + + void onTextColor(); + + void onCurrentCharFormatChanged(const QTextCharFormat &format); + void onCursorPositionChanged(); private: - void dropImage(const QUrl& url, const QImage& image); - void dropTextFile(const QUrl& url); + cMainWindow* m_lpMainWindow; + + void dropImage(const QUrl& url, const QImage& image); + void dropTextFile(const QUrl& url); + + void mergeFormatOnWordOrSelection(const QTextCharFormat& format); + +protected: + void focusInEvent(QFocusEvent *event); + void focusOutEvent(QFocusEvent *event); }; +Q_DECLARE_METATYPE(cTextEdit*) + #endif // CTEXTEDIT_H diff --git a/ctreeview.cpp b/ctreeview.cpp new file mode 100644 index 0000000..2723382 --- /dev/null +++ b/ctreeview.cpp @@ -0,0 +1,18 @@ +#include "ctreeview.h" + +cTreeView::cTreeView(QWidget* parent) : + QTreeView(parent) +{ +} + +void cTreeView::focusInEvent(QFocusEvent* event) +{ + gotFocus(this); + QTreeView::focusInEvent(event); +} + +void cTreeView::focusOutEvent(QFocusEvent* event) +{ + lostFocus(this); + QTreeView::focusOutEvent(event); +} diff --git a/ctreeview.h b/ctreeview.h new file mode 100644 index 0000000..dee4b19 --- /dev/null +++ b/ctreeview.h @@ -0,0 +1,27 @@ +#ifndef CTREEVIEW_H +#define CTREEVIEW_H + + +#include +#include + + +class cTreeView : public QTreeView +{ + Q_OBJECT + +public: + cTreeView(QWidget* parent = Q_NULLPTR); + +signals: + void gotFocus(cTreeView* lpTreeView); + void lostFocus(cTreeView* lpTreeView); + +protected: + void focusInEvent(QFocusEvent *event); + void focusOutEvent(QFocusEvent *event); +}; + +Q_DECLARE_METATYPE(cTreeView*) + +#endif // CTREEVIEW_H diff --git a/main.cpp b/main.cpp index c258647..80ae3c1 100644 --- a/main.cpp +++ b/main.cpp @@ -14,6 +14,7 @@ int main(int argc, char *argv[]) QSettings settings; cMainWindow w; + if(settings.value("main/maximized").toBool()) w.showMaximized(); else diff --git a/qtStoryWriter.pro b/qtStoryWriter.pro index f4d485d..5d09557 100644 --- a/qtStoryWriter.pro +++ b/qtStoryWriter.pro @@ -65,7 +65,15 @@ SOURCES += \ cobjectwindow.cpp \ cplacewindow.cpp \ crecherchewindow.cpp \ - cmdisubwindow.cpp + cmdisubwindow.cpp \ + clineedit.cpp \ + ctreeview.cpp \ + ccheckbox.cpp \ + cradiobutton.cpp \ + cdateedit.cpp \ + cdoublespinbox.cpp \ + ccombobox.cpp \ + cdatetimeedit.cpp HEADERS += \ cmainwindow.h \ @@ -92,7 +100,15 @@ HEADERS += \ cobjectwindow.h \ cplacewindow.h \ crecherchewindow.h \ - cmdisubwindow.h + cmdisubwindow.h \ + clineedit.h \ + ctreeview.h \ + ccheckbox.h \ + cradiobutton.h \ + cdateedit.h \ + cdoublespinbox.h \ + ccombobox.h \ + cdatetimeedit.h FORMS += \ cmainwindow.ui \