#include "imgprocessor.h"
#include <QIcon>
#include <QFileDialog>
#include <QTextStream>
#include <QFile>
#include <QMatrix>
#include <QPrinter>
#include <QPrintDialog>
#include <QColor>
#include <QColorDialog>
#include <QTextList>
#include <QMessageBox>
#include <QPainter>
#include <QPixmap>
#include <QDebug>
ImgProcessor::ImgProcessor(QWidget *parent)
: QMainWindow(parent)
{
setWindowTitle (tr("仿word文档"));
showWidget = new ShowWidget(this);
setCentralWidget (showWidget);
//排序
listLabel = new QLabel(tr("排序"));
listComboBox = new QComboBox;
listComboBox->addItem ("Standard");
listComboBox->addItem ("QTextListFormat::ListDisc");
listComboBox->addItem ("QTextListFormat::ListCircle");
listComboBox->addItem ("QTextListFormat::ListSquare");
listComboBox->addItem ("QTextListFormat::ListDecimal");
listComboBox->addItem ("QTextListFormat::ListLowerAlpha");
listComboBox->addItem ("QTextListFormat::ListUpperAlpha");
listComboBox->addItem ("QTextListFormat::ListLowerRoman");
listComboBox->addItem ("QTextListFormat::ListUpperRoman");
connect(listComboBox,SIGNAL(activated(int)),this,SLOT(ShowList(int)));
// connect(showWidget->text->document(),SIGNAL(undoAvailable(bool)),redoAction,SLOT(setEnabled(bool)));
// connect(showWidget->text->document(),SIGNAL(redoAvailable(bool)),redoAction,SLOT(setEnabled(bool)));
connect(showWidget->text,SIGNAL(cursorPositionChanged()),this,SLOT(ShowCursorPositionChanged()));
//在工具栏上嵌入控件
//设置字体
fontLabel = new QLabel(tr("字体:"));
fontComboBox = new QFontComboBox;
fontComboBox->setFontFilters (QFontComboBox::ScalableFonts);
connect (fontComboBox,SIGNAL(activated(QString)),this,SLOT(showFontComboBox(QString)));
fontLabel2 = new QLabel(tr("字号:"));
sizeComboBox = new QComboBox;
QFontDatabase db;
foreach(int size,db.standardSizes ())
sizeComboBox->addItem (QString::number (size));
connect (sizeComboBox,SIGNAL(activated(QString)),this,SLOT(showSizeSpinBox(QString)));
boldBtn = new QToolButton;
boldBtn->setIcon (QIcon(":/images/bold.png"));
boldBtn->setCheckable (true);
connect (boldBtn,SIGNAL(clicked(bool)),this,SLOT(showBoldBtn()));
italicBtn = new QToolButton;
italicBtn->setIcon (QIcon(":/images/italic.png"));
italicBtn->setCheckable (true);
connect (italicBtn,SIGNAL(clicked(bool)),this,SLOT(showItalicBtn()));
underlineBtn = new QToolButton;
underlineBtn->setIcon(QIcon(":/images/underline.png"));
underlineBtn->setCheckable (true);
connect (underlineBtn,SIGNAL(clicked(bool)),this,SLOT(showUnderlineBtn()));
colorBtn = new QToolButton;
colorBtn->setIcon (QIcon(":/images/color.png"));
colorBtn->setCheckable (true);
connect (colorBtn,SIGNAL(clicked(bool)),this,SLOT(showColorBtn()));
/*创建动作 菜单 工具栏的函数*/
createActions ();
createMenus ();
createToolBars ();
if(img.load (":/images/image.png"))
{
showWidget->imageLabel->setPixmap (QPixmap::fromImage (img));//在imageLabel对象中放置图像
}
}
ImgProcessor::~ImgProcessor()
{
}
void ImgProcessor::createActions ()
{
//"打开"动作
openFileAction = new QAction(QIcon(":/images/open.png"),tr("打开(&O)"),this);
openFileAction->setShortcut (tr("Ctrl+O"));
openFileAction->setStatusTip (tr("打开一个文件"));
connect (openFileAction,SIGNAL(triggered(bool)),this,SLOT(showOpenFile()));
//"新建"动作
newFileAction = new QAction(QIcon(":/images/new.png"),tr("新建(&N)"),this);
newFileAction->setShortcut (tr("Ctrl+N"));
newFileAction->setStatusTip (tr("新建一个文件"));
connect (newFileAction,SIGNAL(triggered(bool)),this,SLOT(showNewFile()));
//"保存"动作
saveFileAction = new QAction(QIcon(":/images/save.png"),tr("保存(&S)"),this);
saveFileAction->setShortcut (tr("Ctrl+S"));
saveFileAction->setStatusTip (tr("保存一个文件"));
connect (saveFileAction,SIGNAL(triggered(bool)),this,SLOT(showSaveFile()));
//"另存为"动作
saveAsAction = new QAction(QIcon(":/images/saveAs.png"),tr("另存为"),this);
saveAsAction->setShortcut (tr("Ctrl+A"));
saveAsAction->setStatusTip (tr("将文件另存为"));
connect (saveAsAction,SIGNAL(triggered(bool)),this,SLOT(showSaveAsFile()));
//"退出"动作
exitAction = new QAction(QIcon(":/images/exit.png"),tr("退出(&Q)"),this);
exitAction->setShortcut (tr("Ctrl+Q"));
exitAction->setStatusTip (tr("退出程序"));
connect (exitAction,SIGNAL(triggered(bool)),this,SLOT(close()));
//"复制"动作
copyAction = new QAction(QIcon(":/images/copy.png"),tr("复制(&C)"),this);
copyAction->setShortcut (tr("Ctrl+C"));
copyAction->setStatusTip (tr("复制文件"));
connect (copyAction,SIGNAL(triggered(bool)),showWidget->text,SLOT(copy()));
//"剪切"动作
cutAction = new QAction(QIcon(":/images/cut.png"),tr("剪切(&X)"),this);
cutAction->setShortcut (tr("Ctrl+X"));
cutAction->setStatusTip (tr("剪切文件"));
connect (cutAction,SIGNAL(triggered(bool)),showWidget->text,SLOT(cut()));
//"粘贴"动作
pasteAction = new QAction(QIcon(":/images/paste.png"),tr("粘贴(&P)"),this);
pasteAction->setShortcut (tr("Ctrl+V"));
pasteAction->setStatusTip (tr("粘贴文件"));
connect (pasteAction,SIGNAL(triggered(bool)),showWidget->text,SLOT(paste()));
//"关于"动作
aboutAction = new QAction(QIcon(":/images/about.png"),tr("关于(&A)"),this);
aboutAction->setStatusTip (tr("关于仿word文档"));
connect (aboutAction,SIGNAL(triggered(bool)),this,SLOT(showAbout()));
//"关于Qt"动作
aboutQtAction = new QAction(QIcon(":/images/aboutQt.png"),tr("关于Qt(&Q)"),this);
aboutQtAction->setStatusTip (tr("关于 Qt 库"));
connect (aboutQtAction,SIGNAL(triggered(bool)),this,SLOT(showAboutQt()));
//"打印文本"动作
printTextAction = new QAction(QIcon(":/images/printText.png"),tr("打印文本(&P)"),this);
printTextAction->setStatusTip (tr("打印一个文本"));
connect (printTextAction,SIGNAL(triggered(bool)),this,SLOT(showPrintText()));
//"打印图像"动作
printImageAction = new QAction(QIcon(":/images/printImage.png"),tr("打印图像"),this);
printImageAction->setStatusTip (tr("打印一幅图像"));
connect (printImageAction,SIGNAL(triggered(bool)),this,SLOT(showPrintImage()));
//"开启图像"动作
openImageAction = new QAction(QIcon(":/images/openImage.png"),tr("开启图像"),this);
openImageAction->setStatusTip (tr("开启桌面显示的图像"));
connect (openImageAction,SIGNAL(triggered(bool)),this,SLOT(showOpenImage()));
//"关闭图像"动作
closeImageAction = new QAction(QIcon(":/images/close.png"),tr("关闭图像"),this);
closeImageAction->setStatusTip (tr("关闭桌面显示的图像"));
connect (closeImageAction,SIGNAL(triggered(bool)),this,SLOT(showCloseImage()));
//"放大"动作
zoomInAction =new QAction(QIcon(":/images/zoomin.png"),tr("放大"),this);
zoomInAction->setStatusTip(tr("放大一张图片"));
connect (zoomInAction,SIGNAL(triggered(bool)),this,SLOT(showZoomIn()));
//"缩小"动作
zoomOutAction = new QAction(QIcon(":/images/zoomout.png"),tr("缩小"),this);
zoomOutAction->setStatusTip (tr("缩小一张图片"));
connect (zoomOutAction,SIGNAL(triggered(bool)),this,SLOT(showZoomOut()));
//旋转90°
rotate90Action = new QAction(QIcon(":/images/rotate90.png"),tr("旋转 90°"),this);
rotate90Action->setStatusTip (tr("将一幅图旋转90°"));
connect (rotate90Action,SIGNAL(triggered(bool)),this,SLOT(showRotate90()));
//旋转180°
评论3
最新资源