diff --git a/ofdEditor/model/Doc/DocImageBlock.cpp b/ofdEditor/model/Doc/DocImageBlock.cpp index 742b5df7762fdca6fa33fc3e176a49c719eb320a..afb1befbf950e78330b4cb8f1d2a9c1164a6038d 100644 --- a/ofdEditor/model/Doc/DocImageBlock.cpp +++ b/ofdEditor/model/Doc/DocImageBlock.cpp @@ -34,7 +34,6 @@ DocImageBlock::DocImageBlock(QWidget *parent) this, SLOT(imagePropertiesChanged(double,double, double,double, bool))); - } /** @@ -96,7 +95,7 @@ double DocImageBlock::getWidthHeightRatio() void DocImageBlock::focusInEvent(QFocusEvent *e) { //qDebug() << "focus In Event"; - + emit signals_currrentImageBlock(this); this->setFrameShape(QFrame::Box); this->setLineWidth(1); QLabel::focusInEvent(e); diff --git a/ofdEditor/model/Doc/DocImageBlock.h b/ofdEditor/model/Doc/DocImageBlock.h index 909a075deb5b99dab4068f85fe4d76eb6b6856f3..8ac5f9e875ad4a8602bf40944b882883f44b867e 100644 --- a/ofdEditor/model/Doc/DocImageBlock.h +++ b/ofdEditor/model/Doc/DocImageBlock.h @@ -28,6 +28,8 @@ public slots: double new_x, double new_y, bool ratio_locked); + void changeImage(); + void setImageProperties(); protected: void focusInEvent(QFocusEvent *ev); @@ -42,9 +44,6 @@ private: ImagePropertiesDialog * properties_dialog; bool width_height_ratio_locked; double width_height_ratio; -private slots: - void changeImage(); - void setImageProperties(); signals: void sendImageInfo(double image_width, @@ -54,6 +53,7 @@ signals: double page_width, double page_height, bool ratio_is_locked); + void signals_currrentImageBlock(DocImageBlock * textBlock); //当前操作的imageBlock }; #endif // DOCIMAGEBLOCK_H diff --git a/ofdEditor/model/Doc/DocPage.cpp b/ofdEditor/model/Doc/DocPage.cpp index 9b7053b74a0b42374a5ed5674fdf9355a5d7abf7..9788fdc3b07134514d91f5e42b9978a86517f466 100644 --- a/ofdEditor/model/Doc/DocPage.cpp +++ b/ofdEditor/model/Doc/DocPage.cpp @@ -134,7 +134,15 @@ void DocPage::addBlock(DocBlock *block, DocPage::Layer layer) passage,SIGNAL(signals_currentCharFormatChanged(QTextCharFormat&))); connect(textBlock,SIGNAL(signals_currentTextBlock(DocTextBlock*)), passage,SIGNAL(signals_currentTextBlock(DocTextBlock*))); + } else if (block->isImageBlock()) + { + DocImageBlock * imageBlock = block->getImageBlock(); + DocPassage * passage = this->getPassage(); + //emit this->signals_insertImageBlock(); + //转发给passage + this->connect(imageBlock, SIGNAL(signals_currrentImageBlock(DocImageBlock*)), + passage, SIGNAL(signals_currentImageBlock(DocImageBlock*))); } // 分到层 diff --git a/ofdEditor/model/Doc/DocPassage.h b/ofdEditor/model/Doc/DocPassage.h index 0502ecb9342abaa049ca25a1ba4b0f9d90ad291a..76082f340f25572c5e8b30d409617602d1d5f050 100644 --- a/ofdEditor/model/Doc/DocPassage.h +++ b/ofdEditor/model/Doc/DocPassage.h @@ -20,6 +20,7 @@ class CT_DocInfo; class CT_CommonData; class DocBlock; class DocTextBlock; +class DocImageBlock; /** * @Author Chaoqun @@ -105,6 +106,7 @@ signals: void signals_currentBlockFormatChanged( QTextBlockFormat& fmt); // 当前选择的block格式发生了变化 void signals_currentTextBlock(DocTextBlock* textBlock); // 当前操作的textBlock + void signals_currentImageBlock(DocImageBlock* imageBlock); //当前操作的imageBlock }; diff --git a/ofdEditor/model/Widget/imagepropertiesdialog.cpp b/ofdEditor/model/Widget/imagepropertiesdialog.cpp index db6d99c25449a0b32700c64d25dde8e6b54cb1e3..0ad83ec3e330cfe336dbbd06632e219531dd2a7f 100644 --- a/ofdEditor/model/Widget/imagepropertiesdialog.cpp +++ b/ofdEditor/model/Widget/imagepropertiesdialog.cpp @@ -41,6 +41,12 @@ ImagePropertiesDialog::ImagePropertiesDialog(DocImageBlock * _block, QWidget *pa this->connect(ui->WidthInPixel, SIGNAL(valueChanged(double)), this, SLOT(Pixel2Percentage(double))); this->connect(ui->xInPixel, SIGNAL(valueChanged(double)), this, SLOT(Pixel2Percentage(double))); this->connect(ui->yInPixel, SIGNAL(valueChanged(double)), this, SLOT(Pixel2Percentage(double))); + this->connect(ui->WidthInPixel, + SIGNAL(valueChanged(double)), + this, SLOT(Width2HeightTrans(double))); + this->connect(ui->HeightInPixel, + SIGNAL(valueChanged(double)), + this, SLOT(Height2WidthTrans(double))); } /** * @Author Pan @@ -113,20 +119,16 @@ void ImagePropertiesDialog::emitMessage() */ void ImagePropertiesDialog::lockRatioStateChanged(int locked) { + qDebug() << "Waaaa"; if (locked == Qt::Checked && !ratio_locked) { -// qDebug() << "Set to Checked."; + qDebug() << "Set to Checked."; ratio_locked = true; - this->connect(ui->WidthInPixel, - SIGNAL(valueChanged(double)), - this, SLOT(Width2HeightTrans(double))); - this->connect(ui->HeightInPixel, - SIGNAL(valueChanged(double)), - this, SLOT(Height2WidthTrans(double))); + } else if (locked == Qt::Unchecked && ratio_locked) { -// qDebug() << "Set to Unchecked."; + qDebug() << "Set to Unchecked."; ratio_locked = false; this->disconnect(ui->WidthInPercentage, SIGNAL(valueChanged(double)), @@ -147,8 +149,11 @@ void ImagePropertiesDialog::lockRatioStateChanged(int locked) void ImagePropertiesDialog::Width2HeightTrans(double value) { //qDebug() << "W2H"; - double ratio = initial_height / initial_width; - ui->HeightInPixel->setValue(value * ratio); + if (ratio_locked) + { + double ratio = initial_height / initial_width; + ui->HeightInPixel->setValue(value * ratio); + } } /** @@ -160,9 +165,11 @@ void ImagePropertiesDialog::Width2HeightTrans(double value) */ void ImagePropertiesDialog::Height2WidthTrans(double value) { - //qDebug() << "H2W"; - double ratio = initial_width / initial_height; - ui->WidthInPixel->setValue(value * ratio); + if (ratio_locked) + { + double ratio = initial_width / initial_height; + ui->WidthInPixel->setValue(value * ratio); + } } /** @@ -176,7 +183,7 @@ void ImagePropertiesDialog::Pixel2Percentage(double value) { // static int cnt = 1; // qDebug() << cnt++; - qDebug() << ui->HeightInPixel->value(); +// qDebug() << ui->HeightInPixel->value(); ui->HeightInPercentage->setValue(100.0 * ui->HeightInPixel->value() / initial_height); ui->WidthInPercentage->setValue(100.0 * ui->WidthInPixel->value() / initial_width); ui->xInPercentage->setValue(100.0 * ui->xInPixel->value() / page_width); diff --git a/ofdEditor/start/ui/PassageMainWindow.cpp b/ofdEditor/start/ui/PassageMainWindow.cpp index aa004e8f028467dc343abb1352809593f9ca45b3..d3c2ff41ab0eefb7caf8a7560a8b0e4545ab7ffe 100644 --- a/ofdEditor/start/ui/PassageMainWindow.cpp +++ b/ofdEditor/start/ui/PassageMainWindow.cpp @@ -288,6 +288,9 @@ void PassageMainWindow::connectAction() connect(this->paragraphFormat,SIGNAL(triggered(bool)), this,SLOT(paragraphDialog())); // 修改段落 + connect(this->imageFormat, SIGNAL(triggered(bool)), + this, SLOT(imageDialog())); //修改图片 + connect(this->area, SIGNAL(subWindowActivated(QMdiSubWindow*)), this->connector, SLOT(updateActivePassage(QMdiSubWindow*))); // 检测ActivePassage更新 } @@ -355,7 +358,8 @@ void PassageMainWindow::openFile() */ void PassageMainWindow::fontDialog() { - this->textBlock->customFontDialog(); // 用自定义窗口修改字体 + if (textBlock) + this->textBlock->customFontDialog(); // 用自定义窗口修改字体 } /** @@ -367,7 +371,14 @@ void PassageMainWindow::fontDialog() */ void PassageMainWindow::paragraphDialog() { - this->textBlock->textParagraph(); // 用自定义段落窗口修改段落 + if (textBlock) + this->textBlock->textParagraph(); // 用自定义段落窗口修改段落 +} + +void PassageMainWindow::imageDialog() +{ + if (imageBlock) + this->imageBlock->setImageProperties(); } /** @@ -380,6 +391,7 @@ void PassageMainWindow::paragraphDialog() void PassageMainWindow::acceptTextBlock(DocTextBlock *textBlock) { this->textBlock = textBlock; // 修改引用 + this->imageBlock = NULL; } /** @@ -406,10 +418,15 @@ void PassageMainWindow::acceptTextBlockFormat(QTextBlockFormat &blockFormat) void PassageMainWindow::acceptTextCharFormat(QTextCharFormat &charFormat) { this->_currentCharFormat = &charFormat; // 留下引用 - // 更新界面显示 } +void PassageMainWindow::acceptImageBlock(DocImageBlock *imageBlock) +{ + this->imageBlock = imageBlock; + this->textBlock = NULL; +} + /** * @Author Chaoqun * @brief 获取激活的窗口 @@ -452,7 +469,9 @@ DocPassage *PassageMainWindow::addDocPassage(DocPassage *passage) // 处理变更的textBlock this->connect(passage,SIGNAL(signals_currentTextBlock(DocTextBlock*)), this,SLOT(acceptTextBlock(DocTextBlock*))); - + //处理变更的imageBlock + this->connect(passage, SIGNAL(signals_currentImageBlock(DocImageBlock*)), + this, SLOT(acceptImageBlock(DocImageBlock*))); return passage; } diff --git a/ofdEditor/start/ui/PassageMainWindow.h b/ofdEditor/start/ui/PassageMainWindow.h index d07719f3bf0bbf94f6f042b70feb1d5194c36055..5b1364b2af0b5819ba0d7aede5088ad96a01cd39 100644 --- a/ofdEditor/start/ui/PassageMainWindow.h +++ b/ofdEditor/start/ui/PassageMainWindow.h @@ -15,6 +15,7 @@ class DocTextBlock; class QTextCharFormat; class QTextBlockFormat; class ActionConnector; // 函数功能的中间件 +class DocImageBlock; // 编辑窗口的主界面 class PassageMainWindow @@ -66,6 +67,7 @@ private: QAction * insertTableAction; // 插入表格 // 格式 + QAction * pageFormat; // 页面格式调整 QAction * textFormat; // 文字格式调整 QAction * paragraphFormat; // 段落格式调整 QAction * imageFormat; // 图形格式调整 @@ -91,16 +93,19 @@ private: QTextCharFormat* _currentCharFormat; // 当前字符格式 QTextBlockFormat* _currentBlockFormat; // 当前块格式 + DocImageBlock *imageBlock; //图片块 + private slots: void openFile(); // 打开新文件 void fontDialog(); // 打开字体框 void paragraphDialog(); // 打开段落框 + void imageDialog(); // 打开图片框 void acceptTextBlock(DocTextBlock* textBlock); // 接受当前处理的文字块的更新 void acceptTextBlockFormat(QTextBlockFormat& blockFormat); // 接受当前处理的块格式 void acceptTextCharFormat(QTextCharFormat& charFormat); // 接受当前处理的字符格式 - + void acceptImageBlock(DocImageBlock * imageBlock); //接受当前处理的图片块 }; #endif // PASSAGEMAINWINDOW_H