void TextEdit::setupTextActions() { QMenu *menu = new QMenu(tr("F&ormat"), this); menuBar()->addMenu(menu); actionTextBold = new QAction(QIcon(rsrcPath + "/textbold.png"), tr("&Bold"), this); actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B); QFont bold; bold.setBold(true); actionTextBold->setFont(bold); connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold())); menu->addAction(actionTextBold); actionTextBold->setCheckable(true); actionTextItalic = new QAction(QIcon(rsrcPath + "/textitalic.png"), tr("&Italic"), this); actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I); QFont italic; italic.setItalic(true); actionTextItalic->setFont(italic); connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic())); menu->addAction(actionTextItalic); actionTextItalic->setCheckable(true); actionTextUnderline = new QAction(QIcon(rsrcPath + "/textunder.png"), tr("&Underline"), this); actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U); QFont underline; underline.setUnderline(true); actionTextUnderline->setFont(underline); connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline())); menu->addAction(actionTextUnderline); actionTextUnderline->setCheckable(true); menu->addSeparator(); QActionGroup *grp = new QActionGroup(this); connect(grp, SIGNAL(triggered(QAction *)), this, SLOT(textAlign(QAction *))); actionAlignLeft = new QAction(QIcon(rsrcPath + "/textleft.png"), tr("&Left"), grp); actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L); actionAlignLeft->setCheckable(true); actionAlignCenter = new QAction(QIcon(rsrcPath + "/textcenter.png"), tr("C&enter"), grp); actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E); actionAlignCenter->setCheckable(true); actionAlignRight = new QAction(QIcon(rsrcPath + "/textright.png"), tr("&Right"), grp); actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R); actionAlignRight->setCheckable(true); actionAlignJustify = new QAction(QIcon(rsrcPath + "/textjustify.png"), tr("&Justify"), grp); actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J); actionAlignJustify->setCheckable(true); menu->addActions(grp->actions()); menu->addSeparator(); QPixmap pix(16, 16); pix.fill(Qt::black); actionTextColor = new QAction(pix, tr("&Color..."), this); connect(actionTextColor, SIGNAL(triggered()), this, SLOT(textColor())); menu->addAction(actionTextColor); }
void XYZTextEditor::setupTextActions() { QObject::connect(m_ui->btnTextBold, SIGNAL(clicked()), this, SLOT(textBold())); QObject::connect(m_ui->btnTextItalic, SIGNAL(clicked()), this, SLOT(textItalic())); QObject::connect(m_ui->btnUnderline, SIGNAL(clicked()), this, SLOT(textUnderline())); QObject::connect(m_ui->btnAlignCenter, SIGNAL(clicked()), this, SLOT(textAlign())); QObject::connect(m_ui->btnAlignJustify, SIGNAL(clicked()), this, SLOT(textAlign())); QObject::connect(m_ui->btnAlignLeft, SIGNAL(clicked()), this, SLOT(textAlign())); QObject::connect(m_ui->btnAlignRight, SIGNAL(clicked()), this, SLOT(textAlign())); QObject::connect(m_ui->btnTextColor, SIGNAL(clicked()), this, SLOT(textColor())); m_ui->comboStyle->addItem(tr("Standard")); m_ui->comboStyle->addItem(tr("Bullet List (Disc)")); m_ui->comboStyle->addItem(tr("Bullet List (Circle)")); m_ui->comboStyle->addItem(tr("Bullet List (Square)")); m_ui->comboStyle->addItem(tr("Ordered List (Decimal)")); m_ui->comboStyle->addItem(tr("Ordered List (Alpha lower)")); m_ui->comboStyle->addItem(tr("Ordered List (Alpha upper)")); QObject::connect(m_ui->comboStyle, SIGNAL(activated(int)), this, SLOT(textStyle(int))); QObject::connect(m_ui->comboFont, SIGNAL(activated(const QString &)), this, SLOT(textFamily(const QString &))); m_ui->comboSize->clear(); QFontDatabase db; foreach(int size, db.standardSizes()) m_ui->comboSize->addItem(QString::number(size)); QObject::connect(m_ui->comboSize, SIGNAL(activated(const QString &)), this, SLOT(textSize(const QString &))); m_ui->comboSize->setCurrentIndex(m_ui->comboSize->findText(QString::number(QApplication::font().pointSize()))); }
MTTextEdit::MTTextEdit(QWidget * parent): QWidget(parent) { setupUi(this); tbtnUndo->setText(QString::fromUtf8("\342\227\204")); tbtnRedo->setText(QString::fromUtf8("\342\226\272")); QPixmap pix(14, 14); pix.fill(Qt::black); tbtnColour->setIcon(pix); tbtngrpAlign = new QButtonGroup(this); tbtngrpAlign->addButton(tbtnAlignLeft); tbtngrpAlign->addButton(tbtnAlignCentre); tbtngrpAlign->addButton(tbtnAlignRight); tbtngrpAlign->addButton(tbtnAlignJustify); QObject::connect(tbtnItalic, SIGNAL(released()), this, SLOT(textItalic())); QObject::connect(tbtnBold, SIGNAL(released()), this, SLOT(textBold())); QObject::connect(tbtnUnderlined, SIGNAL(released()), this, SLOT(textUnderline())); QObject::connect(tbtnColour, SIGNAL(released()), this, SLOT(textColor())); QObject::connect(sizeComboBox, SIGNAL(activated(const QString &)), this, SLOT(textSize(const QString &))); QObject::connect(fontComboBox, SIGNAL(activated(const QString &)), this, SLOT(textFamily(const QString &))); QObject::connect(tbtngrpAlign, SIGNAL(buttonReleased(QAbstractButton *)), this, SLOT(textAlign(QAbstractButton *))); QObject::connect(theTextEdit, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), this, SLOT(currentCharFormatChanged(const QTextCharFormat &))); QObject::connect(theTextEdit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); QObject::connect(theTextEdit, SIGNAL(textChanged()), this, SIGNAL(textChanged())); }
bool TextEdit::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: fileNew(); break; case 1: fileOpen(); break; case 2: fileSave(); break; case 3: fileSaveAs(); break; case 4: filePrint(); break; case 5: fileClose(); break; case 6: fileExit(); break; case 7: editUndo(); break; case 8: editRedo(); break; case 9: editCut(); break; case 10: editCopy(); break; case 11: editPaste(); break; case 12: textBold(); break; case 13: textUnderline(); break; case 14: textItalic(); break; case 15: textFamily((const QString&)static_QUType_QString.get(_o+1)); break; case 16: textSize((const QString&)static_QUType_QString.get(_o+1)); break; case 17: textColor(); break; case 18: textAlign((QAction*)static_QUType_ptr.get(_o+1)); break; case 19: fontChanged((const QFont&)*((const QFont*)static_QUType_ptr.get(_o+1))); break; case 20: colorChanged((const QColor&)*((const QColor*)static_QUType_ptr.get(_o+1))); break; case 21: alignmentChanged((int)static_QUType_int.get(_o+1)); break; case 22: editorChanged((QWidget*)static_QUType_ptr.get(_o+1)); break; default: return QMainWindow::qt_invoke( _id, _o ); } return TRUE; }
int dMessageEditor::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: clickedSendButton(); break; case 1: splitterMoved(*(int*)_a[1],*(int*)_a[2]); break; case 2: textBold(); break; case 3: textUnderline(); break; case 4: textItalic(); break; case 5: textAlign(*(QAction**)_a[1]); break; case 6: textFamily(*(QString*)_a[1]); break; case 7: textSize(*(QString*)_a[1]); break; case 8: textColor(); break; case 9: saveMessage(); break; } _id -= 10; } return _id; }
/** Default constructor */ ChatWindow::ChatWindow(QWidget *parent) : QMainWindow(parent) { /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); GConfig config; config.loadWidgetInformation(this); _isAvatarFrameOpened = true; //creates sub widgets _avatarFrame = new ChatAvatarFrame(this); //// connect(ui.lineEdit, SIGNAL(returnPressed( ) ), this, SLOT(sendChat( ) )); connect(ui.colorButton, SIGNAL(clicked()), this, SLOT(setColor())); connect(ui.textboldButton, SIGNAL(clicked()), this, SLOT(textBold())); connect(ui.textunderlineButton, SIGNAL(clicked()), this, SLOT(textUnderline())); connect(ui.textitalicButton, SIGNAL(clicked()), this, SLOT(textItalic())); connect(ui.avatarFrameButton, SIGNAL(clicked()), SLOT(avatarFrameButtonClicked())); addAvatarFrame(); }
void TextEdit::setupTextActions() { QToolBar *tb = new QToolBar( this ); tb->setLabel( "Format Actions" ); QPopupMenu *menu = new QPopupMenu( this ); menuBar()->insertItem( tr( "F&ormat" ), menu ); comboFont = new QComboBox( TRUE, tb ); QFontDatabase db; comboFont->insertStringList( db.families() ); connect( comboFont, SIGNAL( activated( const QString & ) ), this, SLOT( textFamily( const QString & ) ) ); comboFont->lineEdit()->setText( QApplication::font().family() ); comboSize = new QComboBox( TRUE, tb ); QValueList<int> sizes = db.standardSizes(); QValueList<int>::Iterator it = sizes.begin(); for ( ; it != sizes.end(); ++it ) comboSize->insertItem( QString::number( *it ) ); connect( comboSize, SIGNAL( activated( const QString & ) ), this, SLOT( textSize( const QString & ) ) ); comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) ); actionTextBold = new QAction( QPixmap::fromMimeSource( "textbold.xpm" ), tr( "&Bold" ), CTRL + Key_B, this, "textBold" ); connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) ); actionTextBold->addTo( tb ); actionTextBold->addTo( menu ); actionTextBold->setToggleAction( TRUE ); actionTextItalic = new QAction( QPixmap::fromMimeSource( "textitalic.xpm" ), tr( "&Italic" ), CTRL + Key_I, this, "textItalic" ); connect( actionTextItalic, SIGNAL( activated() ), this, SLOT( textItalic() ) ); actionTextItalic->addTo( tb ); actionTextItalic->addTo( menu ); actionTextItalic->setToggleAction( TRUE ); actionTextUnderline = new QAction( QPixmap::fromMimeSource( "textunder.xpm" ), tr( "&Underline" ), CTRL + Key_U, this, "textUnderline" ); connect( actionTextUnderline, SIGNAL( activated() ), this, SLOT( textUnderline() ) ); actionTextUnderline->addTo( tb ); actionTextUnderline->addTo( menu ); actionTextUnderline->setToggleAction( TRUE ); menu->insertSeparator(); QActionGroup *grp = new QActionGroup( this ); connect( grp, SIGNAL( selected( QAction* ) ), this, SLOT( textAlign( QAction* ) ) ); actionAlignLeft = new QAction( QPixmap::fromMimeSource( "textleft.xpm" ), tr( "&Left" ), CTRL + Key_L, grp, "textLeft" ); actionAlignLeft->setToggleAction( TRUE ); actionAlignCenter = new QAction( QPixmap::fromMimeSource( "textcenter.xpm" ), tr( "C&enter" ), CTRL + Key_E, grp, "textCenter" ); actionAlignCenter->setToggleAction( TRUE ); actionAlignRight = new QAction( QPixmap::fromMimeSource( "textright.xpm" ), tr( "&Right" ), CTRL + Key_R, grp, "textRight" ); actionAlignRight->setToggleAction( TRUE ); actionAlignJustify = new QAction( QPixmap::fromMimeSource( "textjustify.xpm" ), tr( "&Justify" ), CTRL + Key_J, grp, "textjustify" ); actionAlignJustify->setToggleAction( TRUE ); grp->addTo( tb ); grp->addTo( menu ); menu->insertSeparator(); QPixmap pix( 16, 16 ); pix.fill( black ); actionTextColor = new QAction( pix, tr( "&Color..." ), 0, this, "textColor" ); connect( actionTextColor, SIGNAL( activated() ), this, SLOT( textColor() ) ); actionTextColor->addTo( tb ); actionTextColor->addTo( menu ); }
void CreateBlogMsg::setupTextActions() { QMenu *menu = new QMenu(tr("F&ormat"), this); menuBar()->addMenu(menu); actionTextBold = new QAction(QIcon(":/images/textedit/textbold.png"),tr("&Bold"), this); actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B); //actionTextBold->setPriority(QAction::LowPriority); QFont bold; bold.setBold(true); actionTextBold->setFont(bold); connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold())); ui.toolBar_2->addAction(actionTextBold); menu->addAction(actionTextBold); actionTextBold->setCheckable(true); actionTextItalic = new QAction(QIcon(":/images/textedit/textitalic.png"),tr("&Italic"), this); //actionTextItalic->setPriority(QAction::LowPriority); actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I); QFont italic; italic.setItalic(true); actionTextItalic->setFont(italic); connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic())); ui.toolBar_2->addAction(actionTextItalic); menu->addAction(actionTextItalic); actionTextItalic->setCheckable(true); actionTextUnderline = new QAction(QIcon(":/images/textedit/textunder.png"),tr("&Underline"), this); actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U); //actionTextUnderline->setPriority(QAction::LowPriority); QFont underline; underline.setUnderline(true); actionTextUnderline->setFont(underline); connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline())); ui.toolBar_2->addAction(actionTextUnderline); menu->addAction(actionTextUnderline); actionTextUnderline->setCheckable(true); menu->addSeparator(); QActionGroup *grp = new QActionGroup(this); connect(grp, SIGNAL(triggered(QAction*)), this, SLOT(textAlign(QAction*))); // Make sure the alignLeft is always left of the alignRight if (QApplication::isLeftToRight()) { actionAlignLeft = new QAction(QIcon(":/images/textedit/textleft.png"),tr("&Left"), grp); actionAlignCenter = new QAction(QIcon(":/images/textedit/textcenter.png"), tr("C&enter"), grp); actionAlignRight = new QAction(QIcon(":/images/textedit/textright.png"), tr("&Right"), grp); } else { actionAlignRight = new QAction(QIcon(":/images/textedit/textright.png"), tr("&Right"), grp); actionAlignCenter = new QAction(QIcon(":/images/textedit/textcenter.png"), tr("C&enter"), grp); actionAlignLeft = new QAction(QIcon(":/images/textedit/textleft.png"), tr("&Left"), grp); } actionAlignJustify = new QAction(QIcon(":/images/textedit/textjustify.png"), tr("&Justify"), grp); actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L); actionAlignLeft->setCheckable(true); //actionAlignLeft->setPriority(QAction::LowPriority); actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E); actionAlignCenter->setCheckable(true); //actionAlignCenter->setPriority(QAction::LowPriority); actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R); actionAlignRight->setCheckable(true); //actionAlignRight->setPriority(QAction::LowPriority); actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J); actionAlignJustify->setCheckable(true); //actionAlignJustify->setPriority(QAction::LowPriority); ui.toolBar_2->addActions(grp->actions()); menu->addActions(grp->actions()); menu->addSeparator(); QPixmap pix(16, 16); pix.fill(Qt::black); actionTextColor = new QAction(pix, tr("&Text Color..."), this); connect(actionTextColor, SIGNAL(triggered()), this, SLOT(textColor())); ui.toolBar_2->addAction(actionTextColor); menu->addAction(actionTextColor); menu->addAction(ui.actionOrderedlist); menu->addAction(ui.actionUnorderedlist); menu->addAction(ui.actionBlockquoute); /*comboStyle = new QComboBox(ui.toolBar_2); ui.toolBar_2->addWidget(comboStyle); comboStyle->addItem("Paragraph"); comboStyle->addItem("Heading 1"); comboStyle->addItem("Heading 2"); comboStyle->addItem("Heading 3"); comboStyle->addItem("Heading 4"); comboStyle->addItem("Heading 5"); comboStyle->addItem("Heading 6"); connect(comboStyle, SIGNAL(activated(int)), this, SLOT(changeFormatType(int)));*/ comboFont = new QFontComboBox(ui.toolBar_2); ui.toolBar_2->addWidget(comboFont); connect(comboFont, SIGNAL(activated(QString)), this, SLOT(textFamily(QString))); comboSize = new QComboBox(ui.toolBar_2); comboSize->setObjectName("comboSize"); ui.toolBar_2->addWidget(comboSize); comboSize->setEditable(true); QFontDatabase db; foreach(int size, db.standardSizes()) comboSize->addItem(QString::number(size)); connect(comboSize, SIGNAL(activated(QString)), this, SLOT(textSize(QString))); comboSize->setCurrentIndex(comboSize->findText(QString::number(QApplication::font() .pointSize()))); }
void MainWindow::createActions() { newAction = new QAction(tr("&New"), this); newAction->setIcon(QIcon(":/images/filenew.png")); newAction->setShortcut(QKeySequence::New); newAction->setStatusTip(tr("Create a new file")); connect(newAction, SIGNAL(triggered()), this, SLOT(newFile())); openAction = new QAction(tr("&Open..."), this); openAction->setIcon(QIcon(":/images/fileopen.png")); openAction->setShortcut(QKeySequence::Open); openAction->setStatusTip(tr("Open an existing file")); connect(openAction, SIGNAL(triggered()), this, SLOT(open())); printAction = new QAction(QIcon(":/images/fileprint.png"), tr("&Print"), this); printAction->setShortcut(QKeySequence::Print); printAction->setStatusTip(tr("Print File")); connect(printAction, SIGNAL(triggered()), this, SLOT(print())); saveAction = new QAction(tr("&Save"), this); saveAction->setIcon(QIcon(":/images/filesave.png")); saveAction->setShortcut(QKeySequence::Save); saveAction->setStatusTip(tr("Save the file to disk")); connect(saveAction, SIGNAL(triggered()), this, SLOT(save())); saveAsAction = new QAction(tr("Save &As..."), this); saveAsAction->setIcon(QIcon(":/images/filesave.png")); saveAsAction->setStatusTip(tr("Save the file under a new name")); connect(saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs())); exitAction = new QAction(tr("&Quit..."), this); exitAction->setShortcut(tr("Ctrl+Q")); exitAction->setStatusTip(tr("Exit the application")); connect(exitAction, SIGNAL(triggered()), this, SLOT(closep())); cutAction = new QAction(tr("Cu&t"), this); cutAction->setIcon(QIcon(":/images/editcut.png")); cutAction->setShortcut(QKeySequence::Cut); cutAction->setStatusTip(tr("Cut the current selection to the clipboard")); connect(cutAction, SIGNAL(triggered()), this, SLOT(cut())); copyAction = new QAction(tr("&Copy"), this); copyAction->setIcon(QIcon(":/images/editcopy.png")); copyAction->setShortcut(QKeySequence::Copy); copyAction->setStatusTip(tr("Copy the current selection to the clipboard")); connect(copyAction, SIGNAL(triggered()), this, SLOT(copy())); pasteAction = new QAction(tr("&Paste"), this); pasteAction->setIcon(QIcon(":/images/editpaste.png")); pasteAction->setShortcut(QKeySequence::Paste); pasteAction->setStatusTip(tr("Paste the clipboard's contents at the cursor position")); connect(pasteAction, SIGNAL(triggered()), this, SLOT(paste())); //---------------------------------------------------------- textBoldAction = new QAction(QIcon(":/images/textbold.png"), tr("&Bold"), this); textBoldAction->setShortcut(Qt::CTRL + Qt::Key_B); textBoldAction->setStatusTip(tr("Text Bold")); QFont bold; bold.setBold(true); textBoldAction->setFont(bold); textBoldAction->setCheckable(true); connect(textBoldAction, SIGNAL(triggered()), this, SLOT(textBold())); textItalicAction = new QAction(QIcon(":/images/textitalic.png"), tr("&Italic"), this); textItalicAction->setShortcut(Qt::CTRL + Qt::Key_I); textItalicAction->setStatusTip(tr("Text Italic")); QFont italic; italic.setItalic(true); textItalicAction->setFont(italic); textItalicAction->setCheckable(true); connect(textItalicAction, SIGNAL(triggered()), this, SLOT(textItalic())); textUnderlineAction = new QAction(QIcon(":/images/textunder.png"), tr("&Underline"), this); textUnderlineAction->setShortcut(Qt::CTRL + Qt::Key_U); textUnderlineAction->setStatusTip(tr("Text Underline")); QFont underline; underline.setUnderline(true); textUnderlineAction->setFont(underline); textUnderlineAction->setCheckable(true); connect(textUnderlineAction, SIGNAL(triggered()), this, SLOT(textUnderline())); QPixmap pix(16, 16); pix.fill(Qt::black); textColorAction = new QAction(pix, tr("&Color..."), this); textColorAction->setStatusTip(tr("Select Text Color")); connect(textColorAction, SIGNAL(triggered()), this, SLOT(textColor())); //create font toolbar toolbFont = new QToolBar(this); toolbFont->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea); toolbFont->setWindowTitle(tr("Format Actions")); addToolBarBreak(Qt::TopToolBarArea); //addToolBar(toolbFont); //moved to createtoolbar //create fontcombobox comboFont = new QFontComboBox(toolbFont); toolbFont->addWidget(comboFont); comboFont->setToolTip("Set Font Type"); comboFont->setStatusTip("Select Font Type"); connect(comboFont, SIGNAL(activated(const QString &)), this, SLOT(textFamily(const QString &))); //create fontsize combobox comboSize = new QComboBox(toolbFont); comboSize->setObjectName("comboSize"); toolbFont->addWidget(comboSize); comboSize->setToolTip("Set Font Size"); comboSize->setStatusTip("Select Font Size"); comboSize->setEditable(true); QFontDatabase db; foreach(int size, db.standardSizes()) comboSize->addItem(QString::number(size)); connect(comboSize, SIGNAL(activated(const QString &)), this, SLOT(textSize(const QString &))); comboSize->setCurrentIndex(comboSize->findText(QString::number(QApplication::font().pointSize()))); setFontAction = new QAction(tr("&Font"), this); setFontAction->setShortcut(Qt::CTRL + Qt::Key_F); setFontAction->setStatusTip(tr("Set Font")); connect(setFontAction, SIGNAL(triggered()), this, SLOT(setFont())); //---------------------------------------------------------- inputAction = new QAction(tr("Input"), this); inputAction->setShortcut(Qt::CTRL + Qt::Key_A); inputAction->setStatusTip(tr("Select Input Paramerters")); connect(inputAction, SIGNAL(triggered()), this, SLOT(inputparameters())); output1Action = new QAction(tr("Output1"), this); output1Action->setShortcut(Qt::CTRL + Qt::Key_R); output1Action->setStatusTip(tr("Output 1")); connect(output1Action, SIGNAL(triggered()), this, SLOT(output1())); output2Action = new QAction(tr("Output2"), this); output2Action->setShortcut(Qt::CTRL + Qt::Key_T); output2Action->setStatusTip(tr("Output 2")); connect(output2Action, SIGNAL(triggered()), this, SLOT(output2())); //---------------------------------------------------------- closeAction = new QAction(tr("Cl&ose"), this); closeAction->setShortcut(QKeySequence::Close); closeAction->setStatusTip(tr("Close the active window")); connect(closeAction, SIGNAL(triggered()), mdiArea, SLOT(closeActiveSubWindow())); closeAllAction = new QAction(tr("Close &All"), this); closeAllAction->setStatusTip(tr("Close all windows")); connect(closeAllAction, SIGNAL(triggered()), mdiArea, SLOT(closeAllSubWindows())); tileAction = new QAction(tr("&Tile"), this); tileAction->setStatusTip(tr("Tile the windows")); connect(tileAction, SIGNAL(triggered()), mdiArea, SLOT(tileSubWindows())); cascadeAction = new QAction(tr("&Cascade"), this); cascadeAction->setStatusTip(tr("Cascade the windows")); connect(cascadeAction, SIGNAL(triggered()), mdiArea, SLOT(cascadeSubWindows())); nextAction = new QAction(tr("Ne&xt"), this); nextAction->setShortcut(QKeySequence::NextChild); nextAction->setStatusTip(tr("Move the focus to the next window")); connect(nextAction, SIGNAL(triggered()), mdiArea, SLOT(activateNextSubWindow())); previousAction = new QAction(tr("Pre&vious"), this); previousAction->setShortcut(QKeySequence::PreviousChild); previousAction->setStatusTip(tr("Move the focus to the previous window")); connect(previousAction, SIGNAL(triggered()), mdiArea, SLOT(activatePreviousSubWindow())); separatorAction = new QAction(this); separatorAction->setSeparator(true); aboutAction = new QAction(tr("&About"), this); aboutAction->setStatusTip(tr("the application's About box")); connect(aboutAction, SIGNAL(triggered()), this, SLOT(about())); aboutQtAction = new QAction(tr("About &Qt"), this); aboutQtAction->setStatusTip(tr("the Qt library's About box")); connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); windowActionGroup = new QActionGroup(this); }
void GraphicTextDialog::setupTextActions() { QToolBar *tb = toolBar; QString rsrcPath = Qucs::bitmapDirectory(); actionTextBold = new QAction(QIcon(rsrcPath + "textbold.png"), tr("&Bold"), this); actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B); QFont bold; bold.setBold(true); actionTextBold->setFont(bold); connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold())); tb->addAction(actionTextBold); actionTextBold->setCheckable(true); actionTextItalic = new QAction(QIcon(rsrcPath + "textitalic.png"), tr("&Italic"), this); actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I); QFont italic; italic.setItalic(true); actionTextItalic->setFont(italic); connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic())); tb->addAction(actionTextItalic); actionTextItalic->setCheckable(true); actionTextUnderline = new QAction(QIcon(rsrcPath + "textunder.png"), tr("&Underline"), this); actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U); QFont underline; underline.setUnderline(true); actionTextUnderline->setFont(underline); connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline())); tb->addAction(actionTextUnderline); actionTextUnderline->setCheckable(true); QActionGroup *grp = new QActionGroup(this); connect(grp, SIGNAL(triggered(QAction *)), this, SLOT(textAlign(QAction *))); actionAlignLeft = new QAction(QIcon(rsrcPath + "textleft.png"), tr("&Left"), grp); actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L); actionAlignLeft->setCheckable(true); actionAlignCenter = new QAction(QIcon(rsrcPath + "textcenter.png"), tr("C&enter"), grp); actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E); actionAlignCenter->setCheckable(true); actionAlignRight = new QAction(QIcon(rsrcPath + "textright.png"), tr("&Right"), grp); actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R); actionAlignRight->setCheckable(true); actionAlignJustify = new QAction(QIcon(rsrcPath + "textjustify.png"), tr("&Justify"), grp); actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J); actionAlignJustify->setCheckable(true); tb->addActions(grp->actions()); tb->addSeparator(); QPixmap pix(16, 16); pix.fill(Qt::black); actionTextColor = new QAction(pix, tr("&Color..."), this); connect(actionTextColor, SIGNAL(triggered()), this, SLOT(textColor())); tb->addAction(actionTextColor); tb = new QToolBar(this); tb->setIconSize(QSize(16, 16)); mainLayout->insertWidget(2, tb); comboStyle = new QComboBox(tb); tb->addWidget(comboStyle); comboStyle->addItem("Standard"); comboStyle->addItem("Bullet List (Disc)"); comboStyle->addItem("Bullet List (Circle)"); comboStyle->addItem("Bullet List (Square)"); comboStyle->addItem("Ordered List (Decimal)"); comboStyle->addItem("Ordered List (Alpha lower)"); comboStyle->addItem("Ordered List (Alpha upper)"); connect(comboStyle, SIGNAL(activated(int)), this, SLOT(textStyle(int))); comboFont = new QFontComboBox(tb); tb->addWidget(comboFont); connect(comboFont, SIGNAL(activated(const QString &)), this, SLOT(textFamily(const QString &))); comboFont->setCurrentFont(font()); comboSize = new QComboBox(tb); comboSize->setObjectName("comboSize"); tb->addWidget(comboSize); comboSize->setEditable(true); QFontDatabase db; foreach(int size, db.standardSizes()) { comboSize->addItem(QString::number(size)); } connect(comboSize, SIGNAL(activated(const QString &)), this, SLOT(textSize(const QString &))); comboSize->setCurrentIndex(comboSize->findText(QString::number(QApplication::font() .pointSize()))); tb->addSeparator(); grp = new QActionGroup(this); connect(grp, SIGNAL(triggered(QAction *)), this, SLOT(textAlignSubSuperScript(QAction *))); actionAlignSubscript = new QAction(QIcon(rsrcPath + "sub.png"), tr("Subscript"), grp); actionAlignSubscript->setCheckable(true); actionAlignSupersript = new QAction(QIcon(rsrcPath + "super.png"), tr("Superscript"), grp); actionAlignSupersript->setCheckable(true); actionAlignNormalscript = new QAction(QIcon(rsrcPath + "text.png"), tr("Normal"), grp); actionAlignNormalscript->setCheckable(true); tb->addActions(grp->actions()); }
void TextEdit::setupTextActions() { QToolBar *tb = new QToolBar(this); tb->setWindowTitle(tr("Format Actions")); toolBar1.addWidget(tb); actionTextBold = new QAction(QIcon(rsrcPath + "/textbold.png"), tr("&Bold"), this); actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B); QFont bold; bold.setBold(true); actionTextBold->setFont(bold); connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold())); tb->addAction(actionTextBold); actionTextBold->setCheckable(true); actionTextItalic = new QAction(QIcon(rsrcPath + "/textitalic.png"), tr("&Italic"), this); actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I); QFont italic; italic.setItalic(true); actionTextItalic->setFont(italic); connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic())); tb->addAction(actionTextItalic); actionTextItalic->setCheckable(true); actionTextUnderline = new QAction(QIcon(rsrcPath + "/textunder.png"), tr("&Underline"), this); actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U); QFont underline; underline.setUnderline(true); actionTextUnderline->setFont(underline); connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline())); tb->addAction(actionTextUnderline); actionTextUnderline->setCheckable(true); QActionGroup *grp = new QActionGroup(this); connect(grp, SIGNAL(triggered(QAction *)), this, SLOT(textAlign(QAction *))); // Make sure the alignLeft is always left of the alignRight if (QApplication::isLeftToRight()) { actionAlignLeft = new QAction(QIcon(rsrcPath + "/textleft.png"), tr("&Left"), grp); actionAlignCenter = new QAction(QIcon(rsrcPath + "/textcenter.png"), tr("C&enter"), grp); actionAlignRight = new QAction(QIcon(rsrcPath + "/textright.png"), tr("&Right"), grp); } else { actionAlignRight = new QAction(QIcon(rsrcPath + "/textright.png"), tr("&Right"), grp); actionAlignCenter = new QAction(QIcon(rsrcPath + "/textcenter.png"), tr("C&enter"), grp); actionAlignLeft = new QAction(QIcon(rsrcPath + "/textleft.png"), tr("&Left"), grp); } actionAlignJustify = new QAction(QIcon(rsrcPath + "/textjustify.png"), tr("&Justify"), grp); actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L); actionAlignLeft->setCheckable(true); actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E); actionAlignCenter->setCheckable(true); actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R); actionAlignRight->setCheckable(true); actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J); actionAlignJustify->setCheckable(true); tb->addActions(grp->actions()); QPixmap pix(16, 16); pix.fill(Qt::black); actionTextColor = new QAction(pix, tr("&Color..."), this); connect(actionTextColor, SIGNAL(triggered()), this, SLOT(textColor())); tb->addAction(actionTextColor); tb = new QToolBar(this); tb->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea); tb->setWindowTitle(tr("Format Actions")); toolBar2.addWidget(tb); comboStyle = new QComboBox(tb); tb->addWidget(comboStyle); comboStyle->addItem("Standard"); comboStyle->addItem("Bullet List (Disc)"); comboStyle->addItem("Bullet List (Circle)"); comboStyle->addItem("Bullet List (Square)"); comboStyle->addItem("Ordered List (Decimal)"); comboStyle->addItem("Ordered List (Alpha lower)"); comboStyle->addItem("Ordered List (Alpha upper)"); connect(comboStyle, SIGNAL(activated(int)), this, SLOT(textStyle(int))); comboFont = new QFontComboBox(tb); tb->addWidget(comboFont); connect(comboFont, SIGNAL(activated(const QString &)), this, SLOT(textFamily(const QString &))); comboSize = new QComboBox(tb); comboSize->setObjectName("comboSize"); tb->addWidget(comboSize); comboSize->setEditable(true); QFontDatabase db; foreach(int size, db.standardSizes()) comboSize->addItem(QString::number(size)); connect(comboSize, SIGNAL(activated(const QString &)), this, SLOT(textSize(const QString &))); comboSize->setCurrentIndex(comboSize->findText(QString::number(QApplication::font() .pointSize()))); }
MRichTextEdit::MRichTextEdit(QWidget *parent) : QWidget(parent) { setupUi(this); m_lastBlockList = 0; f_textedit->setTabStopWidth(40); connect(f_textedit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(slotCurrentCharFormatChanged(QTextCharFormat))); connect(f_textedit, SIGNAL(cursorPositionChanged()), this, SLOT(slotCursorPositionChanged())); m_fontsize_h1 = 18; m_fontsize_h2 = 16; m_fontsize_h3 = 14; m_fontsize_h4 = 12; fontChanged(f_textedit->font()); bgColorChanged(f_textedit->textColor()); // paragraph formatting m_paragraphItems << tr("Standard") << tr("Heading 1") << tr("Heading 2") << tr("Heading 3") << tr("Heading 4") << tr("Monospace"); f_paragraph->addItems(m_paragraphItems); connect(f_paragraph, SIGNAL(activated(int)), this, SLOT(textStyle(int))); // undo & redo f_undo->setShortcut(QKeySequence::Undo); f_redo->setShortcut(QKeySequence::Redo); connect(f_textedit->document(), SIGNAL(undoAvailable(bool)), f_undo, SLOT(setEnabled(bool))); connect(f_textedit->document(), SIGNAL(redoAvailable(bool)), f_redo, SLOT(setEnabled(bool))); f_undo->setEnabled(f_textedit->document()->isUndoAvailable()); f_redo->setEnabled(f_textedit->document()->isRedoAvailable()); connect(f_undo, SIGNAL(clicked()), f_textedit, SLOT(undo())); connect(f_redo, SIGNAL(clicked()), f_textedit, SLOT(redo())); // cut, copy & paste f_cut->setShortcut(QKeySequence::Cut); f_copy->setShortcut(QKeySequence::Copy); f_paste->setShortcut(QKeySequence::Paste); f_cut->setEnabled(false); f_copy->setEnabled(false); connect(f_cut, SIGNAL(clicked()), f_textedit, SLOT(cut())); connect(f_copy, SIGNAL(clicked()), f_textedit, SLOT(copy())); connect(f_paste, SIGNAL(clicked()), f_textedit, SLOT(paste())); connect(f_textedit, SIGNAL(copyAvailable(bool)), f_cut, SLOT(setEnabled(bool))); connect(f_textedit, SIGNAL(copyAvailable(bool)), f_copy, SLOT(setEnabled(bool))); #ifndef QT_NO_CLIPBOARD connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slotClipboardDataChanged())); #endif // link f_link->setShortcut(Qt::CTRL + Qt::Key_L); connect(f_link, SIGNAL(clicked(bool)), this, SLOT(textLink(bool))); // bold, italic & underline f_bold->setShortcut(Qt::CTRL + Qt::Key_B); f_italic->setShortcut(Qt::CTRL + Qt::Key_I); f_underline->setShortcut(Qt::CTRL + Qt::Key_U); connect(f_bold, SIGNAL(clicked()), this, SLOT(textBold())); connect(f_italic, SIGNAL(clicked()), this, SLOT(textItalic())); connect(f_underline, SIGNAL(clicked()), this, SLOT(textUnderline())); connect(f_strikeout, SIGNAL(clicked()), this, SLOT(textStrikeout())); // lists f_list_bullet->setShortcut(Qt::CTRL + Qt::Key_Minus); f_list_ordered->setShortcut(Qt::CTRL + Qt::Key_Equal); connect(f_list_bullet, SIGNAL(clicked(bool)), this, SLOT(listBullet(bool))); connect(f_list_ordered, SIGNAL(clicked(bool)), this, SLOT(listOrdered(bool))); // indentation f_indent_dec->setShortcut(Qt::CTRL + Qt::Key_Comma); f_indent_inc->setShortcut(Qt::CTRL + Qt::Key_Period); connect(f_indent_inc, SIGNAL(clicked()), this, SLOT(increaseIndentation())); connect(f_indent_dec, SIGNAL(clicked()), this, SLOT(decreaseIndentation())); // font size QFontDatabase db; foreach(int size, db.standardSizes()) { f_fontsize->addItem(QString::number(size)); } connect(f_fontsize, SIGNAL(activated(QString)), this, SLOT(textSize(QString))); f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(QApplication::font().pointSize()))); // text background color QPixmap pix(16, 16); pix.fill(QApplication::palette().background().color()); f_bgcolor->setIcon(pix); connect(f_bgcolor, SIGNAL(clicked()), this, SLOT(textBgColor())); // images connect(f_image, SIGNAL(clicked()), this, SLOT(insertImage())); }
TextRoom::TextRoom(QWidget *parent, Qt::WFlags f) : QWidget(parent, f), sentenceTally(0) { setupUi(this); setObjectName("textroom"); // Set the default values for variables. numChanges = 0; prevLength = 0; wordcount = 0; alarm = 0; parasold = 0; isHighlighted = false; #ifdef Q_OS_MACX // Find the path for the app path QDir tmpDir = QDir(QCoreApplication::applicationDirPath()); // go into Resources folder tmpDir.cdUp(); tmpDir.cd("Resources"); // get the full path for the resources resourcesDir = tmpDir.path(); #endif // Create the dialog windows. optionsDialog = new OptionsDialog(this); helpDialog = new HelpDialog(this); selectFont = new SelectFont(this); aboutDialog = new AboutDialog(this); scratchDialog = new ScratchDialog(this); miniFlo = new MiniFlo(this); getAWord = new GetAWord(this); musicRoom = new MusicRoom(this); googleDocsDialog = new GoogleDocsDialog(this); // Read settings saved by Options Dialog. #ifdef Q_OS_WIN32 settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, QApplication::applicationName()); #else settings = new QSettings(); #endif readSettings(); // Sound adjustments. int audio_rate = 11025; Uint16 audio_format = AUDIO_S16SYS; int audio_channels = 2; int audio_buffers = 1024; if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) { fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit); if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0) { printf("Unable to initialize audio: %s\n", Mix_GetError()); exit(1); } // Load sounds. #ifdef Q_OS_WIN32 soundenter = Mix_LoadWAV("keyenter.wav"); #elif defined(Q_OS_MACX) QString tmp = resourcesDir; tmp.append("/sounds/keyenter.wav"); soundenter = Mix_LoadWAV(tmp.toAscii()); #else soundenter = Mix_LoadWAV("/usr/share/sounds/keyenter.wav"); #endif if(soundenter == NULL) { printf("Unable to load WAV file: %s\n", Mix_GetError()); } #ifdef Q_OS_WIN32 soundany = Mix_LoadWAV("keyany.wav"); #elif defined(Q_OS_MACX) tmp = resourcesDir; tmp.append("/sounds/keyany.wav"); soundany = Mix_LoadWAV(tmp.toAscii()); #else soundany = Mix_LoadWAV("/usr/share/sounds/keyany.wav"); #endif if(soundany == NULL) { printf("Unable to load WAV file: %s\n", Mix_GetError()); } // Create the keyboard shortcuts. new QShortcut ( QKeySequence(QKeySequence::New), this, SLOT( newFile() ) ); new QShortcut ( QKeySequence(QKeySequence::Open), this, SLOT( open() ) ); new QShortcut ( QKeySequence(QKeySequence::Save), this, SLOT( save() ) ); new QShortcut ( QKeySequence(QKeySequence::HelpContents), this, SLOT( help() ) ); #ifdef Q_OS_MACX new QShortcut ( QKeySequence(tr("F1", "Help")), this, SLOT( help() ) ); #endif new QShortcut ( QKeySequence(tr("F2", "Options")), this, SLOT( options() ) ); new QShortcut ( QKeySequence(tr("F3", "About")), this, SLOT( about() ) ); new QShortcut ( QKeySequence(tr("F5", "Spell Check")), this, SLOT( spellCheck() ) ); new QShortcut ( QKeySequence(tr("F6", "Scratch Pad")), this, SLOT( showScratchPad() ) ); new QShortcut ( QKeySequence(tr("Ctrl+P", "Print")), this, SLOT( print() ) ); new QShortcut ( QKeySequence(tr("Shift+Ctrl+S", "Save As")), this, SLOT( saveAs() ) ); new QShortcut ( QKeySequence(tr("Ctrl+D", "Insert Date")), this, SLOT( insertDate() ) ); new QShortcut ( QKeySequence(tr("Ctrl+T", "Insert Time")), this, SLOT( insertTime() ) ); new QShortcut ( QKeySequence(tr("Ctrl+Q", "Quit Application")) , this, SLOT( close() ) ); new QShortcut ( QKeySequence(tr("Alt+F4", "Quit Application")) , this, SLOT( close() ) ); new QShortcut ( QKeySequence(tr("Ctrl+F", "Find Text")) , this, SLOT( find() ) ); new QShortcut ( QKeySequence(tr("F11", "Toggle Fullscreen")) , this, SLOT( toggleFullScreen() ) ); new QShortcut ( QKeySequence(tr("Esc", "Toggle Fullscreen")) , this, SLOT( toggleEscape() ) ); new QShortcut ( QKeySequence(tr("Ctrl+M", "Minimize TextRoom")) , this, SLOT( showMinimized() ) ); new QShortcut ( QKeySequence(tr("F4", "Find Next")) , this, SLOT( find_next() ) ); new QShortcut ( QKeySequence(tr("Ctrl+F4", "Find Previous")) , this, SLOT( find_previous() ) ); new QShortcut ( QKeySequence(tr("Ctrl+B", "Bold")) , this, SLOT( textBold() ) ); new QShortcut ( QKeySequence(tr("Ctrl+I", "Italic")) , this, SLOT( textItalic() ) ); new QShortcut ( QKeySequence(tr("Ctrl+Up", "Increase Text Size")) , this, SLOT( textSizeUp() ) ); new QShortcut ( QKeySequence(tr("Ctrl+Down", "Decrease Text Size")) , this, SLOT( textSizeDown() ) ); new QShortcut ( QKeySequence(tr("Ctrl+W", "Select Font")) , this, SLOT( changeFont() ) ); new QShortcut ( QKeySequence(tr("Ctrl+R", "Align Right")) , this, SLOT( alignRight() ) ); new QShortcut ( QKeySequence(tr("Ctrl+L", "Align Left")) , this, SLOT( alignLeft() ) ); new QShortcut ( QKeySequence(tr("Ctrl+J", "Align Justify")) , this, SLOT( alignJustify() ) ); new QShortcut ( QKeySequence(tr("Ctrl+E", "Align Center")) , this, SLOT( alignCenter() ) ); new QShortcut ( QKeySequence(tr("Ctrl+Alt+I", "Insert Image")) , this, SLOT( insertImage() ) ); new QShortcut ( QKeySequence(tr("F7", "Show MiniFlo")) , this, SLOT( showMiniFlo() ) ); new QShortcut ( QKeySequence(tr("F8", "Get A Word")) , this, SLOT( showGetAWord() ) ); new QShortcut ( QKeySequence(tr("F9", "MusicRoom")) , this, SLOT( showMusicRoom() ) ); new QShortcut ( QKeySequence(tr("F10", "Google Docs")) , this, SLOT( exportToGoogle() ) ); // Service: show cursor new QShortcut ( QKeySequence(tr("Shift+F4", "Show Cursor")) , this, SLOT( sCursor() ) ); //fw = new QFileSystemWatcher(this); //fw->addPath( settings->fileName() ); // If file is changed, read the settings-> //connect(fw, SIGNAL(fileChanged(const QString)), // this, SLOT(readSettings())); // If the document is changed, do some stuff. connect(textEdit->document(), SIGNAL(contentsChanged()), this, SLOT(documentWasModified())); // If position is changed, scroll. connect(textEdit->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(vPositionChanged())); // If horizontal scrollar is changed, scroll. connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(hSliderPositionChanged())); connect(textEdit, SIGNAL(anchorClicked(QUrl)), this, SLOT(showScratchPad())); // check if we need to open some file at startup const QStringList args = QCoreApplication::arguments(); if (args.count() == 2) { QFile file( args.at(1) ); if ( file.exists() ) curFile = args.at(1); } if (!curFile.isEmpty()) loadFile(curFile); else newFile(); // set cursor position if ( isSaveCursor ) { textEdit->textCursor().setPosition(cPosition); } writeSettings(); // Refresh the file status every second. QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(getFileStatus())); timer->start(1000); }
void RichTextEdit::setupActions() { EditMenu *menu = Controller::create()->getEditMenu(); toolbar->setWindowTitle(tr("Edit Actions")); actionSave = toolbar->addAction(QIcon("icons/document-save.png"), tr("Save")); actionSave->setShortcut(QKeySequence::Save); toolbar->addSeparator(); actionUndo = toolbar->addAction(QIcon("icons/edit-undo.png"), tr("Undo")); menu->addAction(actionUndo); actionUndo->setShortcut(QKeySequence::Undo); actionRedo = toolbar->addAction(QIcon("icons/edit-redo.png"), tr("Redo")); menu->addAction(actionRedo); actionRedo->setShortcut(QKeySequence::Redo); actionCut = toolbar->addAction(QIcon("icons/edit-cut.png"), tr("Cut")); menu->addAction(actionCut); actionCut->setShortcut(QKeySequence::Cut); actionCopy = toolbar->addAction(QIcon("icons/edit-copy.png"), tr("Copy")); menu->addAction(actionCopy); actionCopy->setShortcut(QKeySequence::Copy); actionPaste = toolbar->addAction(QIcon("icons/edit-paste.png"), tr("Paste")); menu->addAction(actionPaste); actionPaste->setShortcut(QKeySequence::Paste); toolbar->addSeparator(); actionTextBold = toolbar->addAction(QIcon("icons/format-text-bold.png"), tr("Bold")); menu->addAction(actionTextBold); actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B); QFont bold; bold.setBold(true); actionTextBold->setFont(bold); connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold())); actionTextBold->setCheckable(true); actionTextItalic = toolbar->addAction(QIcon("icons/format-text-italic.png"), tr("Italic")); menu->addAction(actionTextItalic); actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I); QFont italic; italic.setItalic(true); actionTextItalic->setFont(italic); connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic())); actionTextItalic->setCheckable(true); actionTextUnderline = toolbar->addAction(QIcon("icons/format-text-underline.png"), tr("Underline")); menu->addAction(actionTextUnderline); actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U); QFont underline; underline.setUnderline(true); actionTextUnderline->setFont(underline); connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline())); actionTextUnderline->setCheckable(true); toolbar->addSeparator(); QActionGroup *grp = new QActionGroup(this); connect(grp, SIGNAL(triggered(QAction *)), this, SLOT(textAlign(QAction *))); actionAlignLeft = new QAction(QIcon("icons/format-justify-left.png"), tr("&Left"), grp); actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L); actionAlignLeft->setCheckable(true); actionAlignCenter = new QAction(QIcon("icons/format-justify-center.png"), tr("C&enter"), grp); actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E); actionAlignCenter->setCheckable(true); actionAlignRight = new QAction(QIcon("icons/format-justify-right.png"), tr("&Right"), grp); actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R); actionAlignRight->setCheckable(true); actionAlignJustify = new QAction(QIcon("icons/format-justify-fill.png"), tr("&Justify"), grp); actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J); actionAlignJustify->setCheckable(true); toolbar->addActions(grp->actions()); menu->addActions(grp->actions()); toolbar->addSeparator(); // color QPixmap pix(16, 16); pix.fill(Qt::black); actionTextColor = new QAction(pix, tr("&Color..."), this); connect(actionTextColor, SIGNAL(triggered()), this, SLOT(textColor())); toolbar->addAction(actionTextColor); menu->addAction(actionTextColor); actionFind = toolbar->addAction(QIcon("icons/edit-find.png"), tr("Find")); actionFind->setShortcut(QKeySequence::Find); menu->addAction(actionFind); }
void Note::UIsetup() { sLabel = new QLabel; sLabel->setText(tr("Loading ")); sProg = new QProgressBar; textEdit = new QTextEdit(this); setCentralWidget(textEdit); args = QCoreApplication::arguments(); if(args.count()==2) argsC=1; else argsC=0; ui->actionCut->setEnabled(false); ui->actionCopy->setEnabled(false); ui->statusBar->addWidget(sLabel, 1); ui->statusBar->addWidget(sProg, 1); sProg->setValue(1); Note::connect(ui->actionCopy, SIGNAL(triggered()), textEdit, SLOT(copy())); Note::connect(ui->actionCut, SIGNAL(triggered()), textEdit, SLOT(cut())); Note::connect(ui->actionPaste, SIGNAL(triggered()), textEdit, SLOT(paste())); Note::connect(ui->actionZoomIn, SIGNAL(triggered()), textEdit, SLOT(zoomIn())); Note::connect(ui->actionZoom_Out, SIGNAL(triggered()), textEdit, SLOT(zoomOut())); Note::connect(ui->actionBold, SIGNAL(triggered()), this, SLOT(textBold())); sProg->setValue(10); Note::connect(ui->actionItalics, SIGNAL(triggered()), this, SLOT(textItalic())); Note::connect(ui->actionUnderline, SIGNAL(triggered()), this, SLOT(textUnderline())); Note::connect(ui->actionExport, SIGNAL(triggered()), this, SLOT(filePDF())); Note::connect(ui->actionPrint, SIGNAL(triggered()), this, SLOT(filePrintPreview())); Note::connect(ui->action_About, SIGNAL(triggered()), this, SLOT(about())); sProg->setValue(50); Note::connect(textEdit, SIGNAL(copyAvailable(bool)), ui->actionCut, SLOT(setEnabled(bool))); Note::connect(textEdit, SIGNAL(copyAvailable(bool)), ui->actionCopy, SLOT(setEnabled(bool))); Note::connect(ui->actionNew, SIGNAL(triggered()), this, SLOT(newFile())); Note::connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(save())); Note::connect(ui->actionSave_As, SIGNAL(triggered()), this, SLOT(saveAs())); Note::connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(open())); Note::connect(ui->action_Quit, SIGNAL(triggered()), this, SLOT(close())); sProg->setValue(75); ui->toolBar->addAction(ui->actionNew); ui->toolBar->addSeparator(); ui->toolBar->addAction(ui->actionWarp_Text); Note::fontBox = new QFontComboBox; ui->toolBar->addSeparator(); ui->toolBar->addWidget(fontBox); ui->toolBar->addSeparator(); Note::sizeBox = new QComboBox; ui->toolBar->addWidget(sizeBox); sizeBox->setObjectName("comboSize"); sizeBox->setEditable(true); ui->toolBar->addSeparator(); ui->toolBar->addAction(ui->action_Quit); QFontDatabase db; foreach(int size, db.standardSizes()) sizeBox->addItem(QString::number(size)); sizeBox->setCurrentIndex(sizeBox->findText(QString::number(QApplication::font() .pointSize()))); sProg->setValue(100); wrapcheck = 0; ui->statusBar->removeWidget(sLabel); ui->statusBar->removeWidget(sProg); ui->statusBar->showMessage(tr("Ideal")); //font and text size Note::connect(sizeBox, SIGNAL(activated(int)), this, SLOT(textSize(int))); Note::connect(fontBox, SIGNAL(currentFontChanged(QFont)), this, SLOT(fontChanged(QFont))); }
void TextEdit::setupTextActions() { QToolBar *tb = new QToolBar(this); tb->setWindowTitle(tr("Format Actions")); addToolBar(tb); QMenu *menu = new QMenu(tr("F&ormat"), this); menuBar()->addMenu(menu); actionTextBold = new QAction(QIcon::fromTheme("format-text-bold", QIcon(rsrcPath + "/textbold.png")), tr("&Bold"), this); actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B); actionTextBold->setPriority(QAction::LowPriority); QFont bold; bold.setBold(true); actionTextBold->setFont(bold); connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold())); tb->addAction(actionTextBold); menu->addAction(actionTextBold); actionTextBold->setCheckable(true); actionTextItalic = new QAction(QIcon::fromTheme("format-text-italic", QIcon(rsrcPath + "/textitalic.png")), tr("&Italic"), this); actionTextItalic->setPriority(QAction::LowPriority); actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I); QFont italic; italic.setItalic(true); actionTextItalic->setFont(italic); connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic())); tb->addAction(actionTextItalic); menu->addAction(actionTextItalic); actionTextItalic->setCheckable(true); actionTextUnderline = new QAction(QIcon::fromTheme("format-text-underline", QIcon(rsrcPath + "/textunder.png")), tr("&Underline"), this); actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U); actionTextUnderline->setPriority(QAction::LowPriority); QFont underline; underline.setUnderline(true); actionTextUnderline->setFont(underline); connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline())); tb->addAction(actionTextUnderline); menu->addAction(actionTextUnderline); actionTextUnderline->setCheckable(true); menu->addSeparator(); QActionGroup *grp = new QActionGroup(this); connect(grp, SIGNAL(triggered(QAction*)), this, SLOT(textAlign(QAction*))); // Make sure the alignLeft is always left of the alignRight if (QApplication::isLeftToRight()) { actionAlignLeft = new QAction(QIcon::fromTheme("format-justify-left", QIcon(rsrcPath + "/textleft.png")), tr("&Left"), grp); actionAlignCenter = new QAction(QIcon::fromTheme("format-justify-center", QIcon(rsrcPath + "/textcenter.png")), tr("C&enter"), grp); actionAlignRight = new QAction(QIcon::fromTheme("format-justify-right", QIcon(rsrcPath + "/textright.png")), tr("&Right"), grp); } else { actionAlignRight = new QAction(QIcon::fromTheme("format-justify-right", QIcon(rsrcPath + "/textright.png")), tr("&Right"), grp); actionAlignCenter = new QAction(QIcon::fromTheme("format-justify-center", QIcon(rsrcPath + "/textcenter.png")), tr("C&enter"), grp); actionAlignLeft = new QAction(QIcon::fromTheme("format-justify-left", QIcon(rsrcPath + "/textleft.png")), tr("&Left"), grp); } actionAlignJustify = new QAction(QIcon::fromTheme("format-justify-fill", QIcon(rsrcPath + "/textjustify.png")), tr("&Justify"), grp); actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L); actionAlignLeft->setCheckable(true); actionAlignLeft->setPriority(QAction::LowPriority); actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E); actionAlignCenter->setCheckable(true); actionAlignCenter->setPriority(QAction::LowPriority); actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R); actionAlignRight->setCheckable(true); actionAlignRight->setPriority(QAction::LowPriority); actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J); actionAlignJustify->setCheckable(true); actionAlignJustify->setPriority(QAction::LowPriority); tb->addActions(grp->actions()); menu->addActions(grp->actions()); menu->addSeparator(); QPixmap pix(24, 24); pix.fill(Qt::black); actionTextColor = new QAction(QIcon::fromTheme("text-color", QIcon(rsrcPath + "/textcolor.png")), tr("&Text Color..."), this); connect(actionTextColor, SIGNAL(triggered()), this, SLOT(textColor())); tb->addAction(actionTextColor); menu->addAction(actionTextColor); pix.fill(Qt::green); actionHighlightedTextColor = new QAction(QIcon::fromTheme("text-highlight-color", QIcon(rsrcPath + "/texthighlight.png")), tr("&Text Highlight Color..."), this); connect(actionHighlightedTextColor, SIGNAL(triggered()), this, SLOT(HighlightedText())); tb->addAction(actionHighlightedTextColor); menu->addAction(actionHighlightedTextColor); //pix.fill(Qt::white); actionBackgroundColor = new QAction(QIcon::fromTheme("bg-color", QIcon(rsrcPath + "/bgfill.png")), tr("&Background Color..."), this); connect(actionBackgroundColor, SIGNAL(triggered()), this, SLOT(backgroundColor())); tb->addAction(actionBackgroundColor); menu->addAction(actionBackgroundColor); tb = new QToolBar(this); tb->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea); tb->setWindowTitle(tr("Format Actions")); addToolBarBreak(Qt::TopToolBarArea); addToolBar(tb); comboStyle = new QComboBox(tb); tb->addWidget(comboStyle); comboStyle->addItem("Standard"); comboStyle->addItem("Bullet List (Disc)"); comboStyle->addItem("Bullet List (Circle)"); comboStyle->addItem("Bullet List (Square)"); comboStyle->addItem("Ordered List (Decimal)"); comboStyle->addItem("Ordered List (Alpha lower)"); comboStyle->addItem("Ordered List (Alpha upper)"); comboStyle->addItem("Ordered List (Roman lower)"); comboStyle->addItem("Ordered List (Roman upper)"); connect(comboStyle, SIGNAL(activated(int)), this, SLOT(textStyle(int))); comboFont = new QFontComboBox(tb); tb->addWidget(comboFont); connect(comboFont, SIGNAL(activated(QString)), this, SLOT(textFamily(QString))); comboSize = new QComboBox(tb); comboSize->setObjectName("comboSize"); tb->addWidget(comboSize); comboSize->setEditable(true); QFontDatabase db; foreach(int size, db.standardSizes()) comboSize->addItem(QString::number(size)); connect(comboSize, SIGNAL(activated(QString)), this, SLOT(textSize(QString))); comboSize->setCurrentIndex(comboSize->findText(QString::number(QApplication::font() .pointSize()))); }
void TextEdit::setupTextActions() { QToolBar *tb = new QToolBar( this ); QPopupMenu *menu = new QPopupMenu( this ); menuBar()->insertItem( tr( "For&mat" ), menu ); comboStyle = new QComboBox( FALSE, tb ); comboStyle->insertItem( tr("Standard") ); comboStyle->insertItem( tr("Bullet List (Disc)") ); comboStyle->insertItem( tr("Bullet List (Circle)") ); comboStyle->insertItem( tr("Bullet List (Square)") ); comboStyle->insertItem( tr("Ordered List (Decimal)") ); comboStyle->insertItem( tr("Ordered List (Alpha lower)") ); comboStyle->insertItem( tr("Ordered List (Alpha upper)") ); connect( comboStyle, SIGNAL( activated( int ) ), this, SLOT( textStyle( int ) ) ); comboFont = new QComboBox( TRUE, tb ); QFontDatabase db; comboFont->insertStringList( db.families() ); connect( comboFont, SIGNAL( activated( const QString & ) ), this, SLOT( textFamily( const QString & ) ) ); comboFont->lineEdit()->setText( QApplication::font().family() ); comboSize = new QComboBox( TRUE, tb ); QValueList<int> sizes = db.standardSizes(); QValueList<int>::Iterator it = sizes.begin(); for ( ; it != sizes.end(); ++it ) comboSize->insertItem( QString::number( *it ) ); connect( comboSize, SIGNAL( activated( const QString & ) ), this, SLOT( textSize( const QString & ) ) ); comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) ); actionTextBold = new QAction( tr( "Bold" ), QPixmap( "textdrawing/textbold.png" ), tr( "&Bold" ), CTRL + Key_B, this, "textBold" ); connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) ); actionTextBold->addTo( tb ); actionTextBold->addTo( menu ); actionTextBold->setToggleAction( TRUE ); actionTextItalic = new QAction( tr( "Italic" ), QPixmap( "textdrawing/textitalic.png" ), tr( "&Italic" ), CTRL + Key_I, this, "textItalic" ); connect( actionTextItalic, SIGNAL( activated() ), this, SLOT( textItalic() ) ); actionTextItalic->addTo( tb ); actionTextItalic->addTo( menu ); actionTextItalic->setToggleAction( TRUE ); actionTextUnderline = new QAction( tr( "Underline" ), QPixmap( "textdrawing/textunderline.png" ), tr( "&Underline" ), CTRL + Key_U, this, "textUnderline" ); connect( actionTextUnderline, SIGNAL( activated() ), this, SLOT( textUnderline() ) ); actionTextUnderline->addTo( tb ); actionTextUnderline->addTo( menu ); actionTextUnderline->setToggleAction( TRUE ); menu->insertSeparator(); QActionGroup *grp = new QActionGroup( this ); grp->setExclusive( TRUE ); connect( grp, SIGNAL( selected( QAction* ) ), this, SLOT( textAlign( QAction* ) ) ); actionAlignLeft = new QAction( tr( "Left" ), QPixmap( "textdrawing/textleft.png" ), tr( "&Left" ), CTRL + Key_L, grp, "textLeft" ); actionAlignLeft->addTo( tb ); actionAlignLeft->addTo( menu ); actionAlignLeft->setToggleAction( TRUE ); actionAlignCenter = new QAction( tr( "Center" ), QPixmap( "textdrawing/textcenter.png" ), tr( "C&enter" ), CTRL + Key_M, grp, "textCenter" ); actionAlignCenter->addTo( tb ); actionAlignCenter->addTo( menu ); actionAlignCenter->setToggleAction( TRUE ); actionAlignRight = new QAction( tr( "Right" ), QPixmap( "textdrawing/textright.png" ), tr( "&Right" ), CTRL + Key_R, grp, "textRight" ); actionAlignRight->addTo( tb ); actionAlignRight->addTo( menu ); actionAlignRight->setToggleAction( TRUE ); actionAlignJustify = new QAction( tr( "Justify" ), QPixmap( "textdrawing/textjustify.png" ), tr( "&Justify" ), CTRL + Key_J, grp, "textjustify" ); actionAlignJustify->addTo( tb ); actionAlignJustify->addTo( menu ); actionAlignJustify->setToggleAction( TRUE ); menu->insertSeparator(); QPixmap pix( 16, 16 ); pix.fill( black ); actionTextColor = new QAction( tr( "Color" ), pix, tr( "&Color..." ), 0, this, "textColor" ); connect( actionTextColor, SIGNAL( activated() ), this, SLOT( textColor() ) ); actionTextColor->addTo( tb ); actionTextColor->addTo( menu ); }
void TextEdit::setupTextActions() { formattingToolBar = new QToolBar(this); formattingToolBar->setWindowTitle(tr("Format Actions")); addToolBar(formattingToolBar); QMenu *menu = new QMenu(tr("F&ormat"), this); menuBar()->addMenu(menu); actionTextBold = new QAction(QIcon(":/res/smalltextbold.png"), tr("&Bold"), this); actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B); actionTextBold->setPriority(QAction::LowPriority); QFont bold; bold.setBold(true); actionTextBold->setFont(bold); connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold())); formattingToolBar->addAction(actionTextBold); menu->addAction(actionTextBold); actionTextBold->setCheckable(true); actionTextItalic = new QAction(QIcon(":/res/smalltextitalic.png"), tr("&Italic"), this); actionTextItalic->setPriority(QAction::LowPriority); actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I); QFont italic; italic.setItalic(true); actionTextItalic->setFont(italic); connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic())); formattingToolBar->addAction(actionTextItalic); menu->addAction(actionTextItalic); actionTextItalic->setCheckable(true); actionTextUnderline = new QAction(QIcon(":/res/smalltextunder.png"), tr("&Underline"), this); actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U); actionTextUnderline->setPriority(QAction::LowPriority); QFont underline; underline.setUnderline(true); actionTextUnderline->setFont(underline); connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline())); formattingToolBar->addAction(actionTextUnderline); menu->addAction(actionTextUnderline); actionTextUnderline->setCheckable(true); menu->addSeparator(); QActionGroup *grp = new QActionGroup(this); connect(grp, SIGNAL(triggered(QAction*)), this, SLOT(textAlign(QAction*))); // Make sure the alignLeft is always left of the alignRight if (QApplication::isLeftToRight()) { actionAlignLeft = new QAction(QIcon(":/res/smalltextleft.png"), tr("&Left"), grp); actionAlignCenter = new QAction(QIcon(":/res/smalltextcenter.png"), tr("C&enter"), grp); actionAlignRight = new QAction(QIcon(":/res/smalltextright.png"), tr("&Right"), grp); } else { actionAlignRight = new QAction(QIcon(":/res/smalltextright.png"), tr("&Right"), grp); actionAlignCenter = new QAction(QIcon(":/res/smalltextcenter.png"), tr("C&enter"), grp); actionAlignLeft = new QAction(QIcon(":/res/smalltextleft.png"), tr("&Left"), grp); } actionAlignJustify = new QAction(QIcon(":/res/smalltextjustify.png"), tr("&Justify"), grp); actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L); actionAlignLeft->setCheckable(true); actionAlignLeft->setPriority(QAction::LowPriority); actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E); actionAlignCenter->setCheckable(true); actionAlignCenter->setPriority(QAction::LowPriority); actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R); actionAlignRight->setCheckable(true); actionAlignRight->setPriority(QAction::LowPriority); actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J); actionAlignJustify->setCheckable(true); actionAlignJustify->setPriority(QAction::LowPriority); formattingToolBar->addActions(grp->actions()); menu->addActions(grp->actions()); menu->addSeparator(); actionTextColor = new QAction(QIcon(":/res/smallcolor.png"), tr("&Color..."), this); colorButton = new Qtitan::PopupColorButton(formattingToolBar); colorButton->setDefaultAction(actionTextColor); formattingToolBar->addWidget(colorButton); menu->addAction(actionTextColor); connect(colorButton, SIGNAL(colorChanged(const QColor&)), this, SLOT(textColor(const QColor&))); connect(actionTextColor, SIGNAL(triggered()), this, SLOT(setColorText())); QToolBar* tb = new QToolBar(this); tb->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea); tb->setWindowTitle(tr("Format Actions")); addToolBarBreak(Qt::TopToolBarArea); addToolBar(tb); comboStyle = new QComboBox(tb); tb->addWidget(comboStyle); comboStyle->addItem("Standard"); comboStyle->addItem("Bullet List (Disc)"); comboStyle->addItem("Bullet List (Circle)"); comboStyle->addItem("Bullet List (Square)"); comboStyle->addItem("Ordered List (Decimal)"); comboStyle->addItem("Ordered List (Alpha lower)"); comboStyle->addItem("Ordered List (Alpha upper)"); comboStyle->addItem("Ordered List (Roman lower)"); comboStyle->addItem("Ordered List (Roman upper)"); connect(comboStyle, SIGNAL(activated(int)), this, SLOT(textStyle(int))); comboFont = new QFontComboBox(tb); tb->addWidget(comboFont); connect(comboFont, SIGNAL(activated(QString)), this, SLOT(textFamily(QString))); comboSize = new QComboBox(tb); comboSize->setObjectName("comboSize"); tb->addWidget(comboSize); comboSize->setEditable(true); QFontDatabase db; foreach(int size, db.standardSizes()) comboSize->addItem(QString::number(size)); connect(comboSize, SIGNAL(activated(QString)), this, SLOT(textSize(QString))); comboSize->setCurrentIndex(comboSize->findText(QString::number(QApplication::font().pointSize()))); }