.
This commit is contained in:
+309
@@ -20,6 +20,9 @@
|
||||
|
||||
#include <QTextEdit>
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QMimeData>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
|
||||
@@ -112,6 +115,11 @@ void cMainWindow::initUI()
|
||||
|
||||
void cMainWindow::createActions()
|
||||
{
|
||||
setToolButtonStyle(Qt::ToolButtonFollowStyle);
|
||||
createFileActions();
|
||||
createEditActions();
|
||||
createTextActions();
|
||||
|
||||
connect(ui->m_lpMainTab, SIGNAL(currentChanged(int)), this, SLOT(onMainTabCurrentChanged(int)));
|
||||
connect(ui->m_lpMainTab, SIGNAL(tabCloseRequested(int)), this,SLOT(onMainTabTabCloseRequested(int)));
|
||||
connect(ui->m_lpMdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(onMdiAreaSubWindowActivated(QMdiSubWindow*)));
|
||||
@@ -119,6 +127,225 @@ void cMainWindow::createActions()
|
||||
connect(ui->m_lpOutlineList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onOutlineDoubleClicked(QModelIndex)));
|
||||
}
|
||||
|
||||
void cMainWindow::createFileActions()
|
||||
{
|
||||
QAction* lpAction;
|
||||
QToolBar* lpToolBar = addToolBar(tr("File Actions"));
|
||||
QMenu* lpMenu = menuBar()->addMenu(tr("&File"));
|
||||
|
||||
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->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->setShortcut(QKeySequence::Open);
|
||||
lpToolBar->addAction(lpAction);
|
||||
|
||||
lpMenu->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->setShortcut(QKeySequence::Save);
|
||||
m_lpActionSave->setEnabled(false);
|
||||
lpToolBar->addAction(m_lpActionSave);
|
||||
|
||||
lpAction = lpMenu->addAction(tr("Save &As..."), this, &cMainWindow::onFileSaveAs);
|
||||
lpAction->setPriority(QAction::LowPriority);
|
||||
lpMenu->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->setPriority(QAction::LowPriority);
|
||||
lpAction->setShortcut(QKeySequence::Print);
|
||||
lpToolBar->addAction(lpAction);
|
||||
|
||||
const QIcon filePrintIcon = QIcon::fromTheme("fileprint", QIcon(":/images/mac/fileprint.png"));
|
||||
lpMenu->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->setPriority(QAction::LowPriority);
|
||||
lpAction->setShortcut(Qt::CTRL + Qt::Key_D);
|
||||
lpToolBar->addAction(lpAction);
|
||||
|
||||
lpMenu->addSeparator();
|
||||
#endif
|
||||
|
||||
lpAction = lpMenu->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"));
|
||||
|
||||
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->setShortcut(QKeySequence::Undo);
|
||||
lpToolBar->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->setPriority(QAction::LowPriority);
|
||||
m_lpActionRedo->setShortcut(QKeySequence::Redo);
|
||||
lpToolBar->addAction(m_lpActionRedo);
|
||||
lpMenu->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->setPriority(QAction::LowPriority);
|
||||
m_lpActionCut->setShortcut(QKeySequence::Cut);
|
||||
lpToolBar->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->setPriority(QAction::LowPriority);
|
||||
m_lpActionCopy->setShortcut(QKeySequence::Copy);
|
||||
lpToolBar->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->setPriority(QAction::LowPriority);
|
||||
m_lpActionPaste->setShortcut(QKeySequence::Paste);
|
||||
lpToolBar->addAction(m_lpActionPaste);
|
||||
if(const QMimeData* md = QApplication::clipboard()->mimeData())
|
||||
m_lpActionPaste->setEnabled(md->hasText());
|
||||
#endif
|
||||
}
|
||||
|
||||
void cMainWindow::createTextActions()
|
||||
{
|
||||
QToolBar* lpToolBar = addToolBar(tr("Format Actions"));
|
||||
QMenu* lpMenu = menuBar()->addMenu(tr("F&ormat"));
|
||||
|
||||
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->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_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->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_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->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_lpActionTextUnderline->setCheckable(true);
|
||||
|
||||
lpMenu->addSeparator();
|
||||
|
||||
const QIcon leftIcon = QIcon::fromTheme("format-justify-left", QIcon(":/images/mac/textleft.png"));
|
||||
m_lpActionAlignLeft = new QAction(leftIcon, tr("&Left"), this);
|
||||
m_lpActionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L);
|
||||
m_lpActionAlignLeft->setCheckable(true);
|
||||
m_lpActionAlignLeft->setPriority(QAction::LowPriority);
|
||||
const QIcon centerIcon = QIcon::fromTheme("format-justify-center", QIcon(":/images/mac/textcenter.png"));
|
||||
m_lpActionAlignCenter = new QAction(centerIcon, tr("C&enter"), this);
|
||||
m_lpActionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E);
|
||||
m_lpActionAlignCenter->setCheckable(true);
|
||||
m_lpActionAlignCenter->setPriority(QAction::LowPriority);
|
||||
const QIcon rightIcon = QIcon::fromTheme("format-justify-right", QIcon(":/images/mac/textright.png"));
|
||||
m_lpActionAlignRight = new QAction(rightIcon, tr("&Right"), this);
|
||||
m_lpActionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R);
|
||||
m_lpActionAlignRight->setCheckable(true);
|
||||
m_lpActionAlignRight->setPriority(QAction::LowPriority);
|
||||
const QIcon fillIcon = QIcon::fromTheme("format-justify-fill", QIcon(":/images/mac/textjustify.png"));
|
||||
m_lpActionAlignJustify = new QAction(fillIcon, tr("&Justify"), this);
|
||||
m_lpActionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J);
|
||||
m_lpActionAlignJustify->setCheckable(true);
|
||||
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);
|
||||
|
||||
if(QApplication::isLeftToRight())
|
||||
{
|
||||
alignGroup->addAction(m_lpActionAlignLeft);
|
||||
alignGroup->addAction(m_lpActionAlignCenter);
|
||||
alignGroup->addAction(m_lpActionAlignRight);
|
||||
}
|
||||
else
|
||||
{
|
||||
alignGroup->addAction(m_lpActionAlignRight);
|
||||
alignGroup->addAction(m_lpActionAlignCenter);
|
||||
alignGroup->addAction(m_lpActionAlignLeft);
|
||||
}
|
||||
alignGroup->addAction(m_lpActionAlignJustify);
|
||||
|
||||
lpToolBar->addActions(alignGroup->actions());
|
||||
lpMenu->addActions(alignGroup->actions());
|
||||
|
||||
lpMenu->addSeparator();
|
||||
|
||||
QPixmap pix(16, 16);
|
||||
pix.fill(Qt::black);
|
||||
m_lpActionTextColor = lpMenu->addAction(pix, tr("&Color..."), this, &cMainWindow::onTextColor);
|
||||
lpToolBar->addAction(m_lpActionTextColor);
|
||||
|
||||
lpToolBar = addToolBar(tr("Format Actions"));
|
||||
lpToolBar->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
|
||||
addToolBarBreak(Qt::TopToolBarArea);
|
||||
addToolBar(lpToolBar);
|
||||
|
||||
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)");
|
||||
|
||||
connect(m_lpComboStyle, QOverload<int>::of(&QComboBox::activated), this, &cMainWindow::onTextStyle);
|
||||
|
||||
m_lpComboFont = new QFontComboBox(lpToolBar);
|
||||
lpToolBar->addWidget(m_lpComboFont);
|
||||
connect(m_lpComboFont, QOverload<const QString &>::of(&QComboBox::activated), this, &cMainWindow::onTextFamily);
|
||||
|
||||
m_lpComboSize = new QComboBox(lpToolBar);
|
||||
m_lpComboSize->setObjectName("comboSize");
|
||||
lpToolBar->addWidget(m_lpComboSize);
|
||||
m_lpComboSize->setEditable(true);
|
||||
|
||||
const QList<int> standardSizes = QFontDatabase::standardSizes();
|
||||
foreach(int size, standardSizes)
|
||||
m_lpComboSize->addItem(QString::number(size));
|
||||
m_lpComboSize->setCurrentIndex(standardSizes.indexOf(QApplication::font().pointSize()));
|
||||
|
||||
connect(m_lpComboSize, QOverload<const QString &>::of(&QComboBox::activated), this, &cMainWindow::onTextSize);
|
||||
}
|
||||
|
||||
void cMainWindow::updateWindowTitle()
|
||||
{
|
||||
if(!m_lpStoryBook)
|
||||
@@ -279,3 +506,85 @@ void cMainWindow::showSceneWindow(cScene* lpScene)
|
||||
|
||||
lpSceneWindow->show();
|
||||
}
|
||||
|
||||
void cMainWindow::onFileNew()
|
||||
{
|
||||
}
|
||||
|
||||
void cMainWindow::onFileOpen()
|
||||
{
|
||||
}
|
||||
|
||||
bool cMainWindow::onFileSave()
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cMainWindow::onFileSaveAs()
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
|
||||
void cMainWindow::onFilePrint()
|
||||
{
|
||||
}
|
||||
|
||||
void cMainWindow::onFilePrintPreview()
|
||||
{
|
||||
}
|
||||
|
||||
void cMainWindow::onFilePrintPdf()
|
||||
{
|
||||
}
|
||||
|
||||
void cMainWindow::onTextBold()
|
||||
{
|
||||
}
|
||||
|
||||
void cMainWindow::onTextItalic()
|
||||
{
|
||||
}
|
||||
|
||||
void cMainWindow::onTextUnderline()
|
||||
{
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QFontComboBox>
|
||||
|
||||
#include <QCloseEvent>
|
||||
|
||||
|
||||
@@ -32,6 +35,32 @@ private slots:
|
||||
void onMdiAreaSubWindowActivated(QMdiSubWindow *arg1);
|
||||
|
||||
void onOutlineDoubleClicked(const QModelIndex& index);
|
||||
|
||||
void onFileNew();
|
||||
void onFileOpen();
|
||||
bool onFileSave();
|
||||
bool onFileSaveAs();
|
||||
void onFilePrint();
|
||||
void onFilePrintPreview();
|
||||
void onFilePrintPdf();
|
||||
|
||||
void onTextBold();
|
||||
void onTextItalic();
|
||||
void onTextUnderline();
|
||||
|
||||
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();
|
||||
|
||||
private:
|
||||
Ui::cMainWindow* ui;
|
||||
QStandardItemModel* m_lpOutlineModel;
|
||||
@@ -42,9 +71,36 @@ private:
|
||||
bool m_bUpdatingTab;
|
||||
cStoryBook* m_lpStoryBook;
|
||||
|
||||
QAction* m_lpActionSave;
|
||||
QAction* m_lpActionUndo;
|
||||
QAction* m_lpActionRedo;
|
||||
|
||||
QAction* m_lpActionTextBold;
|
||||
QAction* m_lpActionTextItalic;
|
||||
QAction* m_lpActionTextUnderline;
|
||||
|
||||
QAction* m_lpActionAlignLeft;
|
||||
QAction* m_lpActionAlignCenter;
|
||||
QAction* m_lpActionAlignRight;
|
||||
QAction* m_lpActionAlignJustify;
|
||||
|
||||
QAction* m_lpActionTextColor;
|
||||
|
||||
QAction* m_lpActionCut;
|
||||
QAction* m_lpActionCopy;
|
||||
QAction* m_lpActionPaste;
|
||||
|
||||
QComboBox* m_lpComboStyle;
|
||||
QFontComboBox* m_lpComboFont;
|
||||
QComboBox* m_lpComboSize;
|
||||
|
||||
void initUI();
|
||||
void createActions();
|
||||
|
||||
void createFileActions();
|
||||
void createEditActions();
|
||||
void createTextActions();
|
||||
|
||||
void showPartWindow(cPart* lpPart);
|
||||
void showChapterWindow(cChapter* lpChapter);
|
||||
void showSceneWindow(cScene* lpScene);
|
||||
|
||||
@@ -277,13 +277,6 @@
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_File">
|
||||
<property name="title">
|
||||
<string>&File</string>
|
||||
</property>
|
||||
<addaction name="action_Close"/>
|
||||
</widget>
|
||||
<addaction name="menu_File"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="m_lpMainToolBar">
|
||||
<attribute name="toolBarArea">
|
||||
|
||||
Reference in New Issue
Block a user