void MainWindow::initTextEditor() { //create tab QWidget *tab = new QWidget(this); QString objName = QString("tab"), fileName = ""; tab->setObjectName(objName); //create layout QHBoxLayout *layout = new QHBoxLayout(tab); layout->setSpacing(0); layout->setContentsMargins(11, 11, 11, 11); layout->setObjectName(QString("horizontalLayout")); layout->setContentsMargins(0, 0, 0, 0); //create textedit QTextEdit *edit = new QTextEdit(tab); edit->setObjectName(QString("textEdit")); layout->addWidget(edit); ui->tabs->addWidget(tab); //slot and signal //font change signal connect(edit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat))); connect(edit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); //modification connect(edit->document(), SIGNAL(modificationChanged(bool)), ui->actionSave, SLOT(setEnabled(bool))); connect(edit->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool))); connect(edit->document(), SIGNAL(undoAvailable(bool)), ui->actionUndo, SLOT(setEnabled(bool))); connect(edit->document(), SIGNAL(redoAvailable(bool)), ui->actionRedo, SLOT(setEnabled(bool))); //redo undo connect(ui->actionUndo, SIGNAL(triggered()), edit, SLOT(undo())); connect(ui->actionRedo, SIGNAL(triggered()), edit, SLOT(redo())); //cut copy paste connect(ui->actionCut, SIGNAL(triggered()), edit, SLOT(cut())); connect(ui->actionCopy, SIGNAL(triggered()), edit, SLOT(copy())); connect(ui->actionPaste, SIGNAL(triggered()), edit, SLOT(paste())); connect(edit, SIGNAL(copyAvailable(bool)), ui->actionCut, SLOT(setEnabled(bool))); connect(edit, SIGNAL(copyAvailable(bool)), ui->actionCopy, SLOT(setEnabled(bool))); textEditor.tab = tab; textEditor.editor = edit; textEditor.layout = layout; textEditor.objName = objName; textEditor.fileName = fileName; }
chat::chat(QString pasvusername, QString pasvuserip) : ui(new Ui::chat) { ui->setupUi(this); ui->textEdit->setFocusPolicy(Qt::StrongFocus); ui->textBrowser->setFocusPolicy(Qt::NoFocus); ui->textEdit->setFocus(); ui->textEdit->installEventFilter(this); a = 0; is_opened = false; // this->is_opened = false; xpasvusername = pasvusername; xpasvuserip = pasvuserip; ui->label->setText(tr("与%1聊天中 对方IP:%2").arg(xpasvusername).arg(pasvuserip)); //UDP部分 xchat = new QUdpSocket(this); xport = 45456; // xchat->bind(xport, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); xchat->bind( QHostAddress(getIP()), xport ); connect(xchat, SIGNAL(readyRead()), this, SLOT(processPendingDatagrams())); //TCP部分 server = new TcpServer(this); connect(server,SIGNAL(sendFileName(QString)),this,SLOT(sentFileName(QString))); connect(ui->textEdit,SIGNAL(currentCharFormatChanged(QTextCharFormat)),this,SLOT(currentFormatChanged(const QTextCharFormat))); }
chat::chat(QString pasvusername,QString pasvuserip): ui(new Ui::chat) { ui->setupUi(this); ui->textEdit->setFocusPolicy(Qt::StrongFocus); ui->textBrowser->setFocusPolicy(Qt::NoFocus); ui->textEdit->setFocus(); ui->textEdit->installEventFilter(this); ui->send->setStyleSheet(tr("QPushButton{ border:0px;border-radius:5px;color:white;background-color:rgb(172, 213, 191)}QPushButton:hover{background-color:rgb(153, 186, 255);}QPushButton:pressed{background-color:rgb(153, 186, 255);}")); //退出按钮 ui->close->setStyleSheet(tr("QPushButton{border:0px;border-radius:5px;color:white;background-color:rgb(195, 195, 195);}QPushButton:hover{background-color:#505050;}QPushButton:pressed{background-color:#505050;}")); a = 0; is_opened = false; // this->is_opened = false; xpasvusername = pasvusername; xpasvuserip = pasvuserip; ui->label->setText(tr("与%1聊天中 对方IP:%2").arg(xpasvusername).arg(pasvuserip)); //UDP部分 xchat = new QUdpSocket(this); xport=6900; // xchat->bind(xport, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); QHostAddress chat_me(getIP()); xchat->bind( chat_me, xport); connect(xchat, SIGNAL(readyRead()), this, SLOT(processPendingDatagrams())); //TCP部分 server = new TcpSend(this); connect(server,SIGNAL(sendFileName(QString)),this,SLOT(sentFileName(QString))); connect(ui->textEdit,SIGNAL(currentCharFormatChanged(QTextCharFormat)),this,SLOT(currentFormatChanged(const QTextCharFormat))); }
void Stack::addDocument(Document* document) { document->setSceneList(m_scenes); connect(document, SIGNAL(alert(Alert*)), m_alerts, SLOT(addAlert(Alert*))); connect(document, SIGNAL(alignmentChanged()), this, SIGNAL(updateFormatAlignmentActions())); connect(document, SIGNAL(changedName()), this, SIGNAL(updateFormatActions())); connect(document, SIGNAL(footerVisible(bool)), this, SLOT(setFooterVisible(bool))); connect(document, SIGNAL(headerVisible(bool)), this, SLOT(setHeaderVisible(bool))); connect(document, SIGNAL(scenesVisible(bool)), this, SLOT(setScenesVisible(bool))); connect(document->text(), SIGNAL(copyAvailable(bool)), this, SIGNAL(copyAvailable(bool))); connect(document->text(), SIGNAL(redoAvailable(bool)), this, SIGNAL(redoAvailable(bool))); connect(document->text(), SIGNAL(undoAvailable(bool)), this, SIGNAL(undoAvailable(bool))); connect(document->text(), SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SIGNAL(updateFormatActions())); m_documents.append(document); m_contents->addWidget(document); m_contents->setCurrentWidget(document); QAction* action = new QAction(this); action->setCheckable(true); action->setActionGroup(m_menu_group); m_document_actions.push_back(action); m_menu->addAction(action); updateMenuIndexes(); document->loadTheme(m_theme); document->text()->setFixedSize(m_foreground_size); emit documentAdded(document); emit updateFormatActions(); }
ConsoleWidget::ConsoleWidget(QWidget *parent) : QWidget(parent) { mLayout = new QVBoxLayout(this); mLayout->setContentsMargins(0, 0, 0, 0); mLayout->setSpacing(0); mText = new QTextEdit(this); mEdit = new QLineEdit(this); mEdit->setPlaceholderText(" Inject"); QFile *style; QString str; #ifdef Q_OS_WIN style = new QFile(":/styles/QLineEditConsoleWin.qss"); #endif #ifdef Q_OS_MAC style = new QFile(":/styles/QLineEditConsoleMac.qss"); QFont font("Monaco", 10); mText->setFont(font); #endif if (style->open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(style); str = in.readAll(); } style->close(); delete style; mEdit->setStyleSheet(str); mEdit->setFrame(QFrame::NoFrame); mEdit->setAttribute(Qt::WA_MacShowFocusRect, false); QPalette *palette = new QPalette(); palette->setColor(QPalette::Text, Qt::lightGray); mEdit->setPalette(*palette); mLayout->addWidget(mText); mLayout->addWidget(mEdit); mText->verticalScrollBar()->setStyleSheet("background: #161616;"); mText->horizontalScrollBar()->setStyleSheet("background: #161616;"); mText->setFrameStyle(QFrame::NoFrame); mText->setReadOnly(true); #ifdef Q_OS_WIN mText->setFontPointSize(10); #endif connect(mText, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(setFontSize())); }
ChatWidgit::ChatWidgit(QWidget *parent) : QWidget(parent), ui(new Ui::ChatWidgit) { ui->setupUi(this); ui->tbHistory->hide(); //ui->teEdit->setFocusPolicy(Qt::StrongFocus);//键盘事件,设置获得焦点的方式:通过Tab键获得焦点和被单击获得焦点// ui->teEdit->setFocus();//设置焦点 //ui->teEdit->installEventFilter(this);//注册成监视对象,使this可监视其(子控件)的键盘事件// this->resize(500, 400); //字符格式化信息发生改变,发送信号,改变相应的控件 connect(ui->teEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentFormatChanged(const QTextCharFormat))); }
void MainWindow::setFont() { bool ok; QFont font = QFontDialog::getFont(&ok, QFont("Courier", 9), this); if (!ok){ return; }//if else{ QTextCharFormat fmt; fmt.setFont(font); mergeFormatOnWordOrSelection(fmt); currentCharFormatChanged(fmt); }//else }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); initControls(); layoutControls(); connect( ui->txtEdt, SIGNAL(currentCharFormatChanged( QTextCharFormat)), this, SLOT(onTextCharFormatChanged(QTextCharFormat)) ); QFont fnt = currentFont(); m_pCmbFont->setCurrentText( fnt.family() ); m_pCmbFontPointSize->setCurrentText( QString::number( fnt.pointSize() ) ); }
Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); udpSocket = new QUdpSocket(this); port = 45454; udpSocket->bind(port, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); connect(udpSocket, SIGNAL(readyRead()), this, SLOT(processPendingDatagrams())); sendMessage(NewParticipant); server = new TcpServer(this); connect(server, SIGNAL(sendFileName(QString)), this, SLOT(getFileName(QString))); connect(ui->messageTextEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentFormatChanged(const QTextCharFormat))); }
Widget::Widget(QWidget *parent, QString usrname) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); uName = usrname; udpSocket = new QUdpSocket(this); port = 23232; udpSocket->bind(port, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); connect(udpSocket, SIGNAL(readyRead()), this, SLOT(processPendingDategrams())); sndMsg(UsrEnter); srv = new Server(this); connect(srv, SIGNAL(sndFileName(QString)), this, SLOT(getFileName(QString))); connect(ui->msgTxtEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(curFmtChanged(const QTextCharFormat))); }
WidgetChatInput::WidgetChatInput(QWidget *parent, bool isIRC) : QMainWindow(parent), ui(new Ui::WidgetChatInput) { ui->setupUi(this); bIsIRC = isIRC; textEditInput = new WidgetReturnEmitTextEdit(this); connect(textEditInput, SIGNAL(cursorPositionChanged()), this, SLOT(updateToolbar())); ui->horizontalLayoutInput->addWidget(textEditInput); checkBoxSendOnEnter = new QCheckBox(tr("Send On Enter"), this); checkBoxSendOnEnter->setChecked(true); connect(checkBoxSendOnEnter, SIGNAL(toggled(bool)), textEditInput, SLOT(setEmitsReturn(bool))); connect(textEditInput, SIGNAL(returnPressed()), ui->toolButtonSend, SLOT(click())); connect(textEditInput, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(onTextFormatChange(QTextCharFormat))); toolButtonSmilies = new QToolButton(); toolButtonSmilies->setPopupMode(QToolButton::InstantPopup); toolButtonSmilies->setToolTip(tr("Smilies")); toolButtonSmilies->setIcon(QIcon(":/Resource/Smileys/0.png")); widgetSmileyList = new WidgetSmileyList(this); toolButtonSmilies->setMenu(widgetSmileyList); toolButtonPickColor = new QToolButton(this); toolButtonPickColor->setStyleSheet(QString("QToolButton { background-color: %1; border-style: outset; border-width: 2px; border-radius: 6px; border-color: lightgrey; }").arg(textEditInput->textColor().name())); toolButtonPickColor->setToolTip(tr("Font Color")); connect(toolButtonPickColor, SIGNAL(clicked()), this, SLOT(pickColor())); toolButtonPrivateMessage = new QToolButton(this); toolButtonPrivateMessage->setText(tr("New Private Message")); toolButtonPrivateMessage->setToolTip(tr("New Private Message")); toolButtonPrivateMessage->setIcon(QIcon(":/Resource/Chat/Chat.png")); ui->toolBarTextTools->insertWidget(ui->actionBold, toolButtonPickColor); ui->toolBarTextTools->addSeparator(); ui->toolBarTextTools->addWidget(toolButtonSmilies); ui->toolBarTextTools->addWidget(checkBoxSendOnEnter); ui->actionBold->setChecked(textEditInput->fontWeight() == QFont::Bold); ui->actionItalic->setChecked(textEditInput->fontItalic()); ui->actionUnderline->setChecked(textEditInput->fontUnderline()); ui->toolBarTextTools->addWidget(toolButtonPrivateMessage); toolButtonPrivateMessage->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); connect(ui->actionItalic, SIGNAL(toggled(bool)), textEditInput, SLOT(setFontItalic(bool))); connect(ui->actionUnderline, SIGNAL(toggled(bool)), textEditInput, SLOT(setFontUnderline(bool))); connect(toolButtonPrivateMessage, SIGNAL(clicked()), this, SLOT(addPrivateMessage())); }
void TextZone::createContent() { // sounds = new Sounds(this); this->setAttribute(Qt::WA_KeyCompression, true); textDocument = new MainTextDocument(this); createActions(); setContextMenuPolicy(Qt::DefaultContextMenu); connect(this, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(charFormat(QTextCharFormat))); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChangedSlot())); setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); applyConfig(); }
void Stack::addDocument(Document* document) { document->setSceneList(m_scenes); connect(document, SIGNAL(alert(Alert*)), m_alerts, SLOT(addAlert(Alert*))); connect(document, SIGNAL(alignmentChanged()), this, SIGNAL(updateFormatAlignmentActions())); connect(document, SIGNAL(changedName()), this, SIGNAL(updateFormatActions())); connect(document, SIGNAL(changedName()), this, SLOT(updateMapping())); connect(document, SIGNAL(footerVisible(bool)), this, SLOT(setFooterVisible(bool))); connect(document, SIGNAL(headerVisible(bool)), this, SLOT(setHeaderVisible(bool))); connect(document, SIGNAL(scenesVisible(bool)), this, SLOT(setScenesVisible(bool))); connect(document->text(), SIGNAL(copyAvailable(bool)), this, SIGNAL(copyAvailable(bool))); connect(document->text(), SIGNAL(redoAvailable(bool)), this, SIGNAL(redoAvailable(bool))); connect(document->text(), SIGNAL(undoAvailable(bool)), this, SIGNAL(undoAvailable(bool))); connect(document->text(), SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SIGNAL(updateFormatActions())); m_documents.append(document); m_contents->addWidget(document); m_contents->setCurrentWidget(document); updateMapping(); emit documentAdded(document); emit updateFormatActions(); }
Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); ui->label->setText("<a href=\"http://www.yafeilinux.com\"> www.yafeilinux.com </a>"); this->resize(850,550); ui->textEdit->setFocusPolicy(Qt::StrongFocus); ui->textBrowser->setFocusPolicy(Qt::NoFocus); ui->textEdit->setFocus(); ui->textEdit->installEventFilter(this); udpSocket = new QUdpSocket(this); port = 45454; udpSocket->bind(port,QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); connect(udpSocket,SIGNAL(readyRead()),this,SLOT(processPendingDatagrams())); sendMessage(NewParticipant); server = new TcpServer(this); connect(server,SIGNAL(sendFileName(QString)),this,SLOT(sentFileName(QString))); connect(ui->textEdit,SIGNAL(currentCharFormatChanged(QTextCharFormat)),this,SLOT(currentFormatChanged(const QTextCharFormat))); }
KNoteEdit::KNoteEdit( KActionCollection *actions, QWidget *parent ) : KTextEdit( parent ), m_note( 0 ) { setAcceptDrops( true ); setWordWrapMode( QTextOption::WordWrap ); setLineWrapMode( WidgetWidth ); if ( acceptRichText() ) { setAutoFormatting( AutoAll ); } else { setAutoFormatting( AutoNone ); } setCheckSpellingEnabled( true ); // create the actions modifying the text format m_textBold = new KToggleAction( KIcon( "format-text-bold" ), i18n( "Bold" ), this ); actions->addAction( "format_bold", m_textBold ); m_textBold->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_B ) ); m_textItalic = new KToggleAction( KIcon( "format-text-italic" ), i18n( "Italic" ), this ); actions->addAction( "format_italic", m_textItalic ); m_textItalic->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_I ) ); m_textUnderline = new KToggleAction( KIcon( "format-text-underline" ), i18n( "Underline" ), this ); actions->addAction( "format_underline", m_textUnderline ); m_textUnderline->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_U ) ); m_textStrikeOut = new KToggleAction( KIcon( "format-text-strikethrough" ), i18n( "Strike Out" ), this ); actions->addAction( "format_strikeout", m_textStrikeOut ); m_textStrikeOut->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_S ) ); connect( m_textBold, SIGNAL(toggled(bool)), SLOT(textBold(bool)) ); connect( m_textItalic, SIGNAL(toggled(bool)), SLOT(setFontItalic(bool)) ); connect( m_textUnderline, SIGNAL(toggled(bool)), SLOT(setFontUnderline(bool)) ); connect( m_textStrikeOut, SIGNAL(toggled(bool)), SLOT(textStrikeOut(bool)) ); m_textAlignLeft = new KToggleAction( KIcon( "format-justify-left" ), i18n( "Align Left" ), this ); actions->addAction( "format_alignleft", m_textAlignLeft ); connect( m_textAlignLeft, SIGNAL(triggered(bool)), SLOT(textAlignLeft()) ); m_textAlignLeft->setShortcut( QKeySequence( Qt::ALT + Qt::Key_L ) ); m_textAlignLeft->setChecked( true ); // just a dummy, will be updated later m_textAlignCenter = new KToggleAction( KIcon( "format-justify-center" ), i18n( "Align Center" ), this ); actions->addAction( "format_aligncenter", m_textAlignCenter ); connect( m_textAlignCenter, SIGNAL(triggered(bool)), SLOT(textAlignCenter()) ); m_textAlignCenter->setShortcut( QKeySequence( Qt::ALT + Qt::Key_C ) ); m_textAlignRight = new KToggleAction( KIcon( "format-justify-right" ), i18n( "Align Right" ), this ); actions->addAction( "format_alignright", m_textAlignRight ); connect( m_textAlignRight, SIGNAL(triggered(bool)), SLOT(textAlignRight()) ); m_textAlignRight->setShortcut( QKeySequence( Qt::ALT + Qt::Key_R ) ); m_textAlignBlock = new KToggleAction( KIcon( "format-justify-fill" ), i18n( "Align Block" ), this ); actions->addAction( "format_alignblock", m_textAlignBlock ); connect( m_textAlignBlock, SIGNAL(triggered(bool)), SLOT(textAlignBlock()) ); m_textAlignBlock->setShortcut( QKeySequence( Qt::ALT + Qt::Key_B ) ); QActionGroup *group = new QActionGroup( this ); group->addAction( m_textAlignLeft ); group->addAction( m_textAlignCenter ); group->addAction( m_textAlignRight ); group->addAction( m_textAlignBlock ); m_textList = new KToggleAction( KIcon( "format-list-ordered" ), i18n( "List" ), this ); actions->addAction( "format_list", m_textList ); connect( m_textList, SIGNAL(triggered(bool)), SLOT(textList()) ); m_textSuper = new KToggleAction( KIcon( "format-text-superscript" ), i18n( "Superscript" ), this ); actions->addAction( "format_super", m_textSuper ); connect( m_textSuper, SIGNAL(triggered(bool)), SLOT(textSuperScript()) ); m_textSub = new KToggleAction( KIcon( "format-text-subscript" ), i18n( "Subscript" ), this ); actions->addAction( "format_sub", m_textSub ); connect( m_textSub, SIGNAL(triggered(bool)), SLOT(textSubScript()) ); m_textIncreaseIndent = new KAction( KIcon( "format-indent-more" ), i18n( "Increase Indent" ), this ); actions->addAction( "format_increaseindent", m_textIncreaseIndent ); m_textIncreaseIndent->setShortcut( QKeySequence( Qt::CTRL + Qt::ALT + Qt::Key_I ) ); connect( m_textIncreaseIndent, SIGNAL(triggered(bool)), SLOT(textIncreaseIndent()) ); m_textDecreaseIndent = new KAction( KIcon( "format-indent-less" ), i18n( "Decrease Indent" ), this ); actions->addAction( "format_decreaseindent", m_textDecreaseIndent ); m_textDecreaseIndent->setShortcut( QKeySequence( Qt::CTRL + Qt::ALT + Qt::Key_D ) ); connect( m_textDecreaseIndent, SIGNAL(triggered(bool)), SLOT( textDecreaseIndent() ) ); group = new QActionGroup( this ); group->addAction( m_textIncreaseIndent ); group->addAction( m_textDecreaseIndent ); QPixmap pix( ICON_SIZE, ICON_SIZE ); pix.fill( Qt::black ); // just a dummy, gets updated before widget is shown m_textColor = new KAction( i18n( "Text Color..." ), this ); actions->addAction( "format_color", m_textColor ); m_textColor->setIcon( pix ); connect( m_textColor, SIGNAL(triggered(bool)), SLOT(slotTextColor()) ); KAction *act = new KAction(KIcon( "format-fill-color" ), i18n( "Text Background Color..." ), this ); actions->addAction( "text_background_color", act ); connect( act, SIGNAL(triggered(bool)), SLOT(slotTextBackgroundColor()) ); m_textFont = new KFontAction( i18n( "Text Font" ), this ); actions->addAction( "format_font", m_textFont ); connect( m_textFont, SIGNAL(triggered(QString)), this, SLOT(setFontFamily(QString)) ); m_textSize = new KFontSizeAction( i18n( "Text Size" ), this ); actions->addAction( "format_size", m_textSize ); connect( m_textSize, SIGNAL(fontSizeChanged(int)), this, SLOT(setTextFontSize(int)) ); // QTextEdit connections connect( this, SIGNAL(currentCharFormatChanged(QTextCharFormat)), SLOT(slotCurrentCharFormatChanged(QTextCharFormat)) ); connect( this, SIGNAL(cursorPositionChanged()), SLOT(slotCursorPositionChanged()) ); slotCurrentCharFormatChanged( currentCharFormat() ); slotCursorPositionChanged(); }
/** Constructor */ CreateBlogMsg::CreateBlogMsg(std::string cId ,QWidget* parent, Qt::WFlags flags) : mBlogId(cId), QMainWindow (parent, flags) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); setAttribute ( Qt::WA_DeleteOnClose, true ); setupFileActions(); setupEditActions(); setupViewActions(); setupInsertActions(); setupParagraphActions(); setAcceptDrops(true); setStartupText(); newBlogMsg(); ui.toolBar_2->addAction(ui.actionIncreasefontsize); ui.toolBar_2->addAction(ui.actionDecreasefontsize); ui.toolBar_2->addAction(ui.actionBlockquoute); ui.toolBar_2->addAction(ui.actionOrderedlist); ui.toolBar_2->addAction(ui.actionUnorderedlist); ui.toolBar_2->addAction(ui.actionBlockquoute); ui.toolBar_2->addAction(ui.actionCode); ui.toolBar_2->addAction(ui.actionsplitPost); setupTextActions(); connect(ui.actionPublish, SIGNAL(triggered()), this, SLOT(sendMsg())); connect(ui.actionNew, SIGNAL(triggered()), this, SLOT (fileNew())); connect(ui.actionIncreasefontsize, SIGNAL (triggered()), this, SLOT (fontSizeIncrease())); connect(ui.actionDecreasefontsize, SIGNAL (triggered()), this, SLOT (fontSizeDecrease())); connect(ui.actionBlockquoute, SIGNAL (triggered()), this, SLOT (blockQuote())); connect(ui.actionCode, SIGNAL (triggered()), this, SLOT (toggleCode())); connect(ui.actionsplitPost, SIGNAL (triggered()), this, SLOT (addPostSplitter())); connect(ui.actionOrderedlist, SIGNAL (triggered()), this, SLOT (addOrderedList())); connect(ui.actionUnorderedlist, SIGNAL (triggered()), this, SLOT (addUnorderedList())); //connect(webView, SIGNAL(loadFinished(bool)),this, SLOT(updateTextEdit())); connect( ui.msgEdit, SIGNAL( textChanged(const QString &)), this, SLOT(updateTextEdit())); connect( ui.msgEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat))); connect( ui.msgEdit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); QPalette palette = QApplication::palette(); codeBackground = palette.color( QPalette::Active, QPalette::Midlight ); fontChanged(ui.msgEdit->font()); colorChanged(ui.msgEdit->textColor()); alignmentChanged(ui.msgEdit->alignment()); connect( ui.msgEdit->document(), SIGNAL(modificationChanged(bool)), actionSave, SLOT(setEnabled(bool))); connect( ui.msgEdit->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool))); connect( ui.msgEdit->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool))); connect( ui.msgEdit->document(), SIGNAL(undoAvailable(bool)), ui.actionUndo, SLOT(setEnabled(bool))); connect( ui.msgEdit->document(), SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool))); setWindowModified( ui.msgEdit->document()->isModified()); actionSave->setEnabled( ui.msgEdit->document()->isModified()); actionUndo->setEnabled( ui.msgEdit->document()->isUndoAvailable()); ui.actionUndo->setEnabled( ui.msgEdit->document()->isUndoAvailable()); actionRedo->setEnabled( ui.msgEdit->document()->isRedoAvailable()); connect(actionUndo, SIGNAL(triggered()), ui.msgEdit, SLOT(undo())); connect(ui.actionUndo, SIGNAL(triggered()), ui.msgEdit, SLOT(undo())); connect(actionRedo, SIGNAL(triggered()), ui.msgEdit, SLOT(redo())); actionCut->setEnabled(false); actionCopy->setEnabled(false); connect(actionCut, SIGNAL(triggered()), ui.msgEdit, SLOT(cut())); connect(actionCopy, SIGNAL(triggered()), ui.msgEdit, SLOT(copy())); connect(actionPaste, SIGNAL(triggered()), ui.msgEdit, SLOT(paste())); connect(ui.msgEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); connect(ui.msgEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); #ifndef QT_NO_CLIPBOARD connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); #endif //defaultCharFormat defaultCharFormat = ui.msgEdit->currentCharFormat(); const QFont defaultFont = ui.msgEdit->document()->defaultFont(); defaultCharFormat.setFont( defaultFont ); defaultCharFormat.setForeground( ui.msgEdit->currentCharFormat().foreground() ); defaultCharFormat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 0 ) ); defaultCharFormat.setBackground( palette.color( QPalette::Active, QPalette::Base ) ); defaultCharFormat.setProperty( TextFormat::HasCodeStyle, QVariant( false ) ); //defaultBlockFormat defaultBlockFormat = ui.msgEdit->textCursor().blockFormat(); }
/*! \class LabelWidget \brief Widget for editing the properties of a TextLabel object, mostly used in an an appropriate dock widget. In order the properties of the label to be shown, \c loadConfig() has to be called with the correspondig KConfigGroup (settings for a label in *Plot, Axis etc. or for an independent label on the worksheet). \ingroup kdefrontend */ LabelWidget::LabelWidget(QWidget* parent) : QWidget(parent), m_initializing(false), m_dateTimeMenu(new KMenu(this)), m_teXEnabled(false) { ui.setupUi(this); m_dateTimeMenu->setSeparatorsCollapsible(false); //we don't want the first separator to be removed QGridLayout* layout = static_cast<QGridLayout*>(this->layout()); layout->setContentsMargins(2,2,2,2); layout->setHorizontalSpacing(2); layout->setVerticalSpacing(2); ui.kcbFontColor->setColor(Qt::black); // default color //Icons ui.tbFontBold->setIcon( KIcon("format-text-bold") ); ui.tbFontItalic->setIcon( KIcon("format-text-italic") ); ui.tbFontUnderline->setIcon( KIcon("format-text-underline") ); ui.tbFontStrikeOut->setIcon( KIcon("format-text-strikethrough") ); ui.tbFontSuperScript->setIcon( KIcon("format-text-superscript") ); ui.tbFontSubScript->setIcon( KIcon("format-text-subscript") ); ui.tbSymbols->setIcon( KIcon("labplot-format-text-symbol") ); ui.tbDateTime->setIcon( KIcon("chronometer") ); ui.tbTexUsed->setIconSize(QSize(20, 20)); ui.tbTexUsed->setIcon( KIcon("labplot-TeX-logo") ); //Positioning and alignment ui.cbPositionX->addItem(i18n("left")); ui.cbPositionX->addItem(i18n("center")); ui.cbPositionX->addItem(i18n("right")); ui.cbPositionX->addItem(i18n("custom")); ui.cbPositionY->addItem(i18n("top")); ui.cbPositionY->addItem(i18n("center")); ui.cbPositionY->addItem(i18n("bottom")); ui.cbPositionY->addItem(i18n("custom")); ui.cbHorizontalAlignment->addItem(i18n("left")); ui.cbHorizontalAlignment->addItem(i18n("center")); ui.cbHorizontalAlignment->addItem(i18n("right")); ui.cbVerticalAlignment->addItem(i18n("top")); ui.cbVerticalAlignment->addItem(i18n("center")); ui.cbVerticalAlignment->addItem(i18n("bottom")); //check whether the used latex compiler is available. //Following logic is implemented (s.a. LabelWidget::teXUsedChanged()): //1. in case latex was used to generate the text label in the stored project //and no latex is available on the target system, latex button is toggled and //the user still can switch to the non-latex mode. //2. in case the label was in the non-latex mode and no latex is available, //deactivate the latex button so the user cannot switch to this mode. m_teXEnabled = TeXRenderer::enabled(); //SLOTS // text properties connect(ui.tbTexUsed, SIGNAL(clicked(bool)), this, SLOT(teXUsedChanged(bool)) ); connect(ui.teLabel, SIGNAL(textChanged()), this, SLOT(textChanged())); connect(ui.teLabel, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(charFormatChanged(QTextCharFormat))); connect(ui.kcbFontColor, SIGNAL(changed(QColor)), this, SLOT(fontColorChanged(QColor))); connect(ui.tbFontBold, SIGNAL(clicked(bool)), this, SLOT(fontBoldChanged(bool))); connect(ui.tbFontItalic, SIGNAL(clicked(bool)), this, SLOT(fontItalicChanged(bool))); connect(ui.tbFontUnderline, SIGNAL(clicked(bool)), this, SLOT(fontUnderlineChanged(bool))); connect(ui.tbFontStrikeOut, SIGNAL(clicked(bool)), this, SLOT(fontStrikeOutChanged(bool))); connect(ui.tbFontSuperScript, SIGNAL(clicked(bool)), this, SLOT(fontSuperScriptChanged(bool))); connect(ui.tbFontSubScript, SIGNAL(clicked(bool)), this, SLOT(fontSubScriptChanged(bool))); connect(ui.tbSymbols, SIGNAL(clicked(bool)), this, SLOT(charMenu())); connect(ui.tbDateTime, SIGNAL(clicked(bool)), this, SLOT(dateTimeMenu())); connect(m_dateTimeMenu, SIGNAL(triggered(QAction*)), this, SLOT(insertDateTime(QAction*)) ); connect(ui.kfontRequester, SIGNAL(fontSelected(QFont)), this, SLOT(fontChanged(QFont))); connect(ui.sbFontSize, SIGNAL(valueChanged(int)), this, SLOT(fontSizeChanged(int)) ); // geometry connect( ui.cbPositionX, SIGNAL(currentIndexChanged(int)), this, SLOT(positionXChanged(int)) ); connect( ui.cbPositionY, SIGNAL(currentIndexChanged(int)), this, SLOT(positionYChanged(int)) ); connect( ui.sbPositionX, SIGNAL(valueChanged(double)), this, SLOT(customPositionXChanged(double)) ); connect( ui.sbPositionY, SIGNAL(valueChanged(double)), this, SLOT(customPositionYChanged(double)) ); connect( ui.cbHorizontalAlignment, SIGNAL(currentIndexChanged(int)), this, SLOT(horizontalAlignmentChanged(int)) ); connect( ui.cbVerticalAlignment, SIGNAL(currentIndexChanged(int)), this, SLOT(verticalAlignmentChanged(int)) ); connect( ui.sbRotation, SIGNAL(valueChanged(int)), this, SLOT(rotationChanged(int)) ); connect( ui.sbOffsetX, SIGNAL(valueChanged(double)), this, SLOT(offsetXChanged(double)) ); connect( ui.sbOffsetY, SIGNAL(valueChanged(double)), this, SLOT(offsetYChanged(double)) ); connect( ui.chbVisible, SIGNAL(clicked(bool)), this, SLOT(visibilityChanged(bool)) ); //TODO: https://bugreports.qt.io/browse/QTBUG-25420 ui.tbFontUnderline->hide(); ui.tbFontStrikeOut->hide(); }
EditorWidget::EditorWidget(QString theme, QWidget *parent) : QWidget(parent), editor_rich_text(new EditorRichText(this)), editor_plain_text(new CodeEditor(this, CodeEditor::Html)), pag_stacked(new QStackedWidget(this)), m_state(Clean), m_initialPag(RichTextIndex) { m_theme = theme; m_color = editor_rich_text->textColor(); connect(editor_plain_text, SIGNAL(textChanged()), this, SLOT(plainTextChanged())); connect(editor_rich_text, SIGNAL(textChanged()), this, SLOT(richTextChanged())); connect(editor_rich_text, SIGNAL(simplifyRichTextChanged(bool)), this, SLOT(richTextChanged())); connect(editor_rich_text, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat))); connect(editor_rich_text, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); list_smile = new QListWidget(this); list_smile->setMaximumSize(QSize(155, 16777215)); list_smile->setMovement(QListView::Static); list_smile->setResizeMode(QListView::Adjust); list_smile->setViewMode(QListView::IconMode); connect(list_smile, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(list_smile_itemDoubleClicked(QListWidgetItem*))); toolbar_find_replace = new QWidget(this); toolbar_find_replace->setMinimumSize(QSize(0, 30)); QVBoxLayout *main_layout = new QVBoxLayout(this); main_layout->setContentsMargins(0, 0, 0, 0); main_layout->setSpacing(4); QHBoxLayout *toolbar_layout = new QHBoxLayout(); toolbar_layout->setContentsMargins(0, 0, 0, 0); toolbar_layout->setSpacing(10); QToolBar *toolbar_edit = new QToolBar(this); toolbar_edit->setMinimumSize(QSize(0, 30)); toolbar_edit->setIconSize(QSize(20, 20)); toolbar_edit->setStyleSheet("QToolBar{border:0px;}"); // Save Pdf /* m_pdf_action = createAction(QIcon(m_theme +"img16/pdf.png"), tr("Exportar a PDF") +"...", false, toolbar_edit); m_pdf_action->setPriority(QAction::LowPriority); m_pdf_action->setShortcut(Qt::CTRL + Qt::Key_D); connect(m_pdf_action, SIGNAL(triggered()), this, SLOT(on_edit_export_pdf())); toolbar_edit->addAction(m_pdf_action); toolbar_edit->addSeparator();*/ // combos font and size QWidget *toolbar_font_input = new QWidget(this); QHBoxLayout *combofont_layout = new QHBoxLayout(toolbar_font_input); combofont_layout->setContentsMargins(0, 0, 2, 0); m_font_input = new QFontComboBox(toolbar_edit); connect(m_font_input, SIGNAL(activated(QString)), this, SLOT(on_edit_font(QString))); combofont_layout->addWidget(m_font_input); m_font_size_input = new QComboBox(toolbar_edit); QFontDatabase font_db; foreach(int size, font_db.standardSizes()) m_font_size_input->addItem(QString::number(size)); connect(m_font_size_input, SIGNAL(activated(QString)), this, SLOT(on_edit_font_size(QString))); combofont_layout->addWidget(m_font_size_input); // combofont_layout->setStretch(0, 1); toolbar_edit->addWidget(toolbar_font_input); toolbar_edit->addSeparator(); // cut, copy, paste m_cut_action = createAction(QIcon(m_theme +"img16/edit_cut.png"), tr("Cortar"), false, toolbar_edit); m_cut_action->setPriority(QAction::LowPriority); m_cut_action->setShortcut(QKeySequence::Cut); connect(m_cut_action, SIGNAL(triggered()), this, SLOT(on_edit_cut())); toolbar_edit->addAction(m_cut_action); m_copy_action = createAction(QIcon(m_theme +"img16/edit_copy.png"), tr("Copiar"), false, toolbar_edit); m_copy_action->setPriority(QAction::LowPriority); m_copy_action->setShortcut(QKeySequence::Copy); connect(m_copy_action, SIGNAL(triggered()), this, SLOT(on_edit_copy())); toolbar_edit->addAction(m_copy_action); m_paste_action = createAction(QIcon(m_theme +"img16/edit_paste.png"), tr("Pegar"), false, toolbar_edit); m_paste_action->setPriority(QAction::LowPriority); m_paste_action->setShortcut(QKeySequence::Paste); connect(m_paste_action, SIGNAL(triggered()), this, SLOT(on_edit_paste())); toolbar_edit->addAction(m_paste_action); toolbar_edit->addSeparator(); // undo, redo m_undo_action = createAction(QIcon(m_theme +"img16/edit_deshacer.png"), tr("Deshacer"), false, toolbar_edit); m_undo_action->setShortcut(QKeySequence::Undo); connect(m_undo_action, SIGNAL(triggered()), this, SLOT(on_edit_undo())); toolbar_edit->addAction(m_undo_action); m_redo_action = createAction(QIcon(m_theme +"img16/edit_rehacer.png"), tr("Rehacer"), false, toolbar_edit); m_redo_action->setPriority(QAction::LowPriority); m_redo_action->setShortcut(QKeySequence::Redo); connect(m_redo_action, SIGNAL(triggered()), this, SLOT(on_edit_redo())); toolbar_edit->addAction(m_redo_action); toolbar_edit->addSeparator(); // bold, italic, underline, , m_bold_action = createAction(QIcon(m_theme +"img16/edit_negrita.png"), tr("Negrita"), true, toolbar_edit); m_bold_action->setPriority(QAction::LowPriority); m_bold_action->setShortcut(Qt::CTRL + Qt::Key_B); connect(m_bold_action, SIGNAL(triggered()), this, SLOT(on_edit_bold())); toolbar_edit->addAction(m_bold_action); m_italic_action = createAction(QIcon(m_theme +"img16/edit_cursiva.png"), tr("Cursiva"), true, toolbar_edit); m_italic_action->setPriority(QAction::LowPriority); m_italic_action->setShortcut(Qt::CTRL + Qt::Key_I); connect(m_italic_action, SIGNAL(triggered()), this, SLOT(on_edit_italic())); toolbar_edit->addAction(m_italic_action); m_underline_action = createAction(QIcon(m_theme +"img16/edit_subrayada.png"), tr("Subrayado"), true, toolbar_edit); m_underline_action->setPriority(QAction::LowPriority); m_underline_action->setShortcut(Qt::CTRL + Qt::Key_U); connect(m_underline_action, SIGNAL(triggered()), this, SLOT(on_edit_underline())); toolbar_edit->addAction(m_underline_action); toolbar_edit->addSeparator(); // align: left, center, right, justify QActionGroup *grp = new QActionGroup(toolbar_edit); connect(grp, SIGNAL(triggered(QAction*)), this, SLOT(on_edit_text_align(QAction*))); if (QApplication::isLeftToRight()) { m_align_left_action = createAction(QIcon(m_theme +"img16/edit_text_left.png"), tr("Izquierdo"), true, grp); m_align_center_action = createAction(QIcon(m_theme +"img16/edit_text_center.png"), tr("Centro"), true, grp); m_align_right_action = createAction(QIcon(m_theme +"img16/edit_text_right.png"), tr("Derecho"), true, grp); } else { m_align_right_action = createAction(QIcon(m_theme +"img16/edit_text_right.png"), tr("Derecho"), true, grp); m_align_center_action = createAction(QIcon(m_theme +"img16/edit_text_center.png"), tr("Centro"), true, grp); m_align_left_action = createAction(QIcon(m_theme +"img16/edit_text_left.png"), tr("Izquierdo"), true, grp); } m_align_justify_action = createAction(QIcon(m_theme +"img16/edit_text_justify.png"), tr("Justificado"), true, grp); m_align_left_action->setPriority(QAction::LowPriority); m_align_left_action->setShortcut(Qt::CTRL + Qt::Key_L); m_align_center_action->setPriority(QAction::LowPriority); m_align_center_action->setShortcut(Qt::CTRL + Qt::Key_E); m_align_right_action->setPriority(QAction::LowPriority); m_align_right_action->setShortcut(Qt::CTRL + Qt::Key_R); m_align_justify_action->setPriority(QAction::LowPriority); m_align_justify_action->setShortcut(Qt::CTRL + Qt::Key_J); toolbar_edit->addActions(grp->actions()); toolbar_edit->addSeparator(); // superscript, subscript m_valign_sup_action = createAction(QIcon(m_theme +"img16/edit_text_super.png"), tr("Superíndice"), true, toolbar_edit); connect(m_valign_sup_action, SIGNAL(triggered(bool)), this, SLOT(on_edit_valign_sup())); toolbar_edit->addAction(m_valign_sup_action); m_valign_sub_action = createAction(QIcon(m_theme +"img16/edit_text_subs.png"), tr("Subíndice"), true, toolbar_edit); connect(m_valign_sub_action, SIGNAL(triggered(bool)), this, SLOT(on_edit_valign_sub())); toolbar_edit->addAction(m_valign_sub_action); toolbar_edit->addSeparator(); // image, link, color, simplify m_image_action = createAction(QIcon(m_theme +"img16/edit_imagen.png"), tr("Imagen"), false, toolbar_edit); connect(m_image_action, SIGNAL(triggered()), this, SLOT(on_edit_image())); toolbar_edit->addAction(m_image_action); m_link_action = createAction(QIcon(m_theme +"img16/edit_enlace.png"), tr("Enlace"), true, toolbar_edit); connect(m_link_action, SIGNAL(triggered(bool)), this, SLOT(on_edit_link(bool))); toolbar_edit->addAction(m_link_action); QPixmap pix(16, 16); pix.fill(Qt::black); m_color_action = createAction(QIcon(pix), tr("Color") +"...", false, toolbar_edit); connect(m_color_action, SIGNAL(triggered()), this, SLOT(on_edit_color())); toolbar_edit->addAction(m_color_action); toolbar_edit->addSeparator(); m_simplify_richtext_action = createAction(QIcon(m_theme +"img16/edit_simplify_richtext.png"), tr("Simplificar") +" Html", true, toolbar_edit); m_simplify_richtext_action->setChecked(editor_rich_text->simplifyRichText()); connect(m_simplify_richtext_action, SIGNAL(triggered(bool)), editor_rich_text, SLOT(setSimplifyRichText(bool))); connect(editor_rich_text, SIGNAL(simplifyRichTextChanged(bool)), m_simplify_richtext_action, SLOT(setChecked(bool))); toolbar_edit->addAction(m_simplify_richtext_action); toolbar_layout->addWidget(toolbar_edit); QToolBar *toolbar_opts = new QToolBar(this); toolbar_opts->setIconSize(QSize(20, 20)); toolbar_opts->setMinimumSize(QSize(30, 30)); toolbar_opts->setStyleSheet("QToolBar{border:0px;}"); m_find_replace_text_action = createAction(QIcon(m_theme +"img16/edit_buscar.png"), tr("Buscar") +"/"+ tr("Reemplazar"), true, toolbar_opts); m_find_replace_text_action->setPriority(QAction::LowPriority); m_find_replace_text_action->setShortcut(QKeySequence::Find); connect(m_find_replace_text_action, SIGNAL(triggered(bool)), this, SLOT(on_show_find_replace(bool))); toolbar_opts->addAction(m_find_replace_text_action); m_rich_plain_action = createAction(QIcon(m_theme +"img16/script.png"), tr("Editor") +"/"+ tr("Código"), true, toolbar_opts); connect(m_rich_plain_action, SIGNAL(triggered(bool)), this, SLOT(on_show_source(bool))); toolbar_opts->addAction(m_rich_plain_action); m_smiles_action = createAction(QIcon(m_theme +"img16/smile.png"), tr("Smiles"), true, toolbar_opts); connect(m_smiles_action, SIGNAL(triggered(bool)), list_smile, SLOT(setVisible(bool))); toolbar_opts->addAction(m_smiles_action); toolbar_layout->addWidget(toolbar_opts); toolbar_layout->setStretch(0, 1); main_layout->addLayout(toolbar_layout); QHBoxLayout *edit_smiles_layout = new QHBoxLayout(); edit_smiles_layout->setContentsMargins(0, 0, 0, 0); edit_smiles_layout->setSpacing(4); QWidget *rich_edit = new QWidget(); QVBoxLayout *rich_edit_layout = new QVBoxLayout(rich_edit); rich_edit_layout->setContentsMargins(0, 0, 0, 0); rich_edit_layout->addWidget(editor_rich_text); pag_stacked->addWidget(rich_edit); QWidget *plain_edit = new QWidget(); QVBoxLayout *plain_edit_layout = new QVBoxLayout(plain_edit); plain_edit_layout->setContentsMargins(0, 0, 0, 0); plain_edit_layout->addWidget(editor_plain_text); pag_stacked->addWidget(plain_edit); connect(pag_stacked, SIGNAL(currentChanged(int)), this, SLOT(pagIndexChanged(int))); edit_smiles_layout->addWidget(pag_stacked); edit_smiles_layout->addWidget(list_smile); main_layout->addLayout(edit_smiles_layout); QGridLayout *gridLayout = new QGridLayout(toolbar_find_replace); gridLayout->setSpacing(4); gridLayout->setContentsMargins(0, 0, 0, 0); QLabel *lb_find = new QLabel(tr("Buscar")+":", toolbar_find_replace); gridLayout->addWidget(lb_find, 0, 0, 1, 1); txt_find = new QLineEdit(toolbar_find_replace); txt_find->setMinimumSize(QSize(0, 24)); connect(txt_find, SIGNAL(textChanged(QString)), this, SLOT(txtFindTextChanged(QString))); gridLayout->addWidget(txt_find, 0, 1, 1, 1); QToolButton *btnFindBack = createToolButton(QIcon(m_theme +"img16/edit_buscar_anterior.png"), tr("Buscar anterior"), toolbar_find_replace); btnFindBack->setShortcut(QKeySequence::FindPrevious); connect(btnFindBack, SIGNAL(clicked()), this, SLOT(btnFindBack_clicked())); gridLayout->addWidget(btnFindBack, 0, 2, 1, 1); QToolButton *btnFindNext = createToolButton(QIcon(m_theme +"img16/edit_buscar_siguiente.png"), tr("Buscar siguiente"), toolbar_find_replace); btnFindBack->setShortcut(QKeySequence::FindNext); connect(btnFindNext, SIGNAL(clicked()), this, SLOT(btnFindNext_clicked())); gridLayout->addWidget(btnFindNext, 0, 3, 1, 1); chkCaseSensitive = new QCheckBox(tr("Coincidir mayúsculas/minúsculas"), toolbar_find_replace); chkCaseSensitive->setChecked(false); connect(chkCaseSensitive, SIGNAL(toggled(bool)), this, SLOT(chkCaseSensitive_toggled(bool))); gridLayout->addWidget(chkCaseSensitive, 0, 5, 1, 1); QCheckBox *chkReplace = new QCheckBox(tr("Reemplazar por") +":", toolbar_find_replace); chkReplace->setChecked(false); connect(chkReplace, SIGNAL(toggled(bool)), this, SLOT(chkReplace_toggled(bool))); gridLayout->addWidget(chkReplace, 1, 0, 1, 1); txt_replace = new QLineEdit(toolbar_find_replace); txt_replace->setEnabled(false); txt_replace->setMinimumSize(QSize(0, 24)); gridLayout->addWidget(txt_replace, 1, 1, 1, 1); btnReplace = createToolButton(QIcon(m_theme +"img16/edit_reemplazar.png"), tr("Reemplazar"), toolbar_find_replace); btnReplace->setEnabled(false); connect(btnReplace, SIGNAL(clicked()), this, SLOT(btnReplace_clicked())); gridLayout->addWidget(btnReplace, 1, 2, 1, 1); btnReplaceAndNext = createToolButton(QIcon(m_theme +"img16/edit_reemplazar.png"), tr("Reemplazar siguiente"), toolbar_find_replace); btnReplaceAndNext->setEnabled(false); connect(btnReplaceAndNext, SIGNAL(clicked()), this, SLOT(btnReplaceAndNext_clicked())); gridLayout->addWidget(btnReplaceAndNext, 1, 3, 1, 1); btnReplaceAll = createToolButton(QIcon(m_theme +"img16/edit_reemplazar.png"), tr("Reemplazar todo"), toolbar_find_replace); btnReplaceAll->setEnabled(false); connect(btnReplaceAll, SIGNAL(clicked()), this, SLOT(btnReplaceAll_clicked())); gridLayout->addWidget(btnReplaceAll, 1, 4, 1, 1); chkWholeWords = new QCheckBox(tr("Solo palabras completas"), toolbar_find_replace); gridLayout->addWidget(chkWholeWords, 1, 5, 1, 1); main_layout->addWidget(toolbar_find_replace); #ifndef QT_NO_CLIPBOARD connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); #endif showSource(m_initialPag == RichTextIndex ? false : true); showFindReplace(false); showSmiles(false); setTabStopWidth(40); fontChanged(editor_rich_text->font()); colorChanged(editor_rich_text->textColor()); alignmentChanged(editor_rich_text->alignment()); }
// see legacy/LabelWidget.cpp LabelWidget::LabelWidget(QWidget *parent): QWidget(parent), m_initializing(false), m_dateTimeMenu(new KMenu(this)) { ui.setupUi(this); m_dateTimeMenu->setSeparatorsCollapsible(false); //we don't want the first separator to be removed QGridLayout* layout =static_cast<QGridLayout*>(this->layout()); layout->setContentsMargins(2,2,2,2); layout->setHorizontalSpacing(2); layout->setVerticalSpacing(2); ui.kcbFontColor->setColor(Qt::black); // default color //Icons ui.tbFontBold->setIcon( KIcon("format-text-bold") ); ui.tbFontItalic->setIcon( KIcon("format-text-italic") ); ui.tbFontUnderline->setIcon( KIcon("format-text-underline") ); ui.tbFontStrikeOut->setIcon( KIcon("format-text-strikethrough") ); ui.tbFontSuperScript->setIcon( KIcon("format-text-superscript") ); ui.tbFontSubScript->setIcon( KIcon("format-text-subscript") ); ui.tbSymbols->setIcon( KIcon("labplot-format-text-symbol") ); ui.tbDateTime->setIcon( KIcon("chronometer") ); ui.tbTexUsed->setIconSize(QSize(20, 20)); ui.tbTexUsed->setIcon( KIcon("labplot-TeX-logo") ); //Positioning and alignment ui.cbPositionX->addItem(i18n("left")); ui.cbPositionX->addItem(i18n("center")); ui.cbPositionX->addItem(i18n("right")); ui.cbPositionX->addItem(i18n("custom")); ui.cbPositionY->addItem(i18n("top")); ui.cbPositionY->addItem(i18n("center")); ui.cbPositionY->addItem(i18n("bottom")); ui.cbPositionY->addItem(i18n("custom")); ui.cbHorizontalAlignment->addItem(i18n("left")); ui.cbHorizontalAlignment->addItem(i18n("center")); ui.cbHorizontalAlignment->addItem(i18n("right")); ui.cbVerticalAlignment->addItem(i18n("top")); ui.cbVerticalAlignment->addItem(i18n("center")); ui.cbVerticalAlignment->addItem(i18n("bottom")); //SLOTS // text properties connect(ui.tbTexUsed, SIGNAL(clicked(bool)), this, SLOT(teXUsedChanged(bool)) ); connect(ui.teLabel, SIGNAL(textChanged()), this, SLOT(textChanged())); connect(ui.teLabel, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(charFormatChanged(QTextCharFormat))); connect(ui.kcbFontColor, SIGNAL(changed(QColor)), this, SLOT(fontColorChanged(QColor))); connect(ui.tbFontBold, SIGNAL(clicked(bool)), this, SLOT(fontBoldChanged(bool))); connect(ui.tbFontItalic, SIGNAL(clicked(bool)), this, SLOT(fontItalicChanged(bool))); connect(ui.tbFontUnderline, SIGNAL(clicked(bool)), this, SLOT(fontUnderlineChanged(bool))); connect(ui.tbFontStrikeOut, SIGNAL(clicked(bool)), this, SLOT(fontStrikeOutChanged(bool))); connect(ui.tbFontSuperScript, SIGNAL(clicked(bool)), this, SLOT(fontSuperScriptChanged(bool))); connect(ui.tbFontSubScript, SIGNAL(clicked(bool)), this, SLOT(fontSubScriptChanged(bool))); connect(ui.tbSymbols, SIGNAL(clicked(bool)), this, SLOT(charMenu())); connect(ui.tbDateTime, SIGNAL(clicked(bool)), this, SLOT(dateTimeMenu())); connect(m_dateTimeMenu, SIGNAL(triggered(QAction*)), this, SLOT(insertDateTime(QAction*)) ); connect(ui.kfontRequester, SIGNAL(fontSelected(QFont)), this, SLOT(fontChanged(QFont))); connect(ui.sbFontSize, SIGNAL(valueChanged(int)), this, SLOT(fontSizeChanged(int)) ); // geometry connect( ui.cbPositionX, SIGNAL(currentIndexChanged(int)), this, SLOT(positionXChanged(int)) ); connect( ui.cbPositionY, SIGNAL(currentIndexChanged(int)), this, SLOT(positionYChanged(int)) ); connect( ui.sbPositionX, SIGNAL(valueChanged(double)), this, SLOT(customPositionXChanged(double)) ); connect( ui.sbPositionY, SIGNAL(valueChanged(double)), this, SLOT(customPositionYChanged(double)) ); connect( ui.cbHorizontalAlignment, SIGNAL(currentIndexChanged(int)), this, SLOT(horizontalAlignmentChanged(int)) ); connect( ui.cbVerticalAlignment, SIGNAL(currentIndexChanged(int)), this, SLOT(verticalAlignmentChanged(int)) ); connect( ui.sbRotation, SIGNAL(valueChanged(int)), this, SLOT(rotationChanged(int)) ); connect( ui.sbOffsetX, SIGNAL(valueChanged(double)), this, SLOT(offsetXChanged(double)) ); connect( ui.sbOffsetY, SIGNAL(valueChanged(double)), this, SLOT(offsetYChanged(double)) ); connect( ui.chbVisible, SIGNAL(clicked(bool)), this, SLOT(visibilityChanged(bool)) ); //TODO: https://bugreports.qt.io/browse/QTBUG-25420 ui.tbFontUnderline->hide(); ui.tbFontStrikeOut->hide(); }
/** Constructor */ FriendsDialog::FriendsDialog(QWidget *parent) : RsAutoUpdatePage(1500,parent) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); if (instance == NULL) { instance = this; } last_status_send_time = 0 ; inChatCharFormatChanged = false; connect( ui.mypersonalstatusLabel, SIGNAL(clicked()), SLOT(statusmessage())); connect( ui.actionSet_your_Avatar, SIGNAL(triggered()), this, SLOT(getAvatar())); connect( ui.actionSet_your_Personal_Message, SIGNAL(triggered()), this, SLOT(statusmessage())); connect( ui.addfileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); connect( ui.actionAdd_Friend, SIGNAL(triggered()), this, SLOT(addFriend())); connect( ui.actionFriendRecommendations, SIGNAL(triggered()), this, SLOT(recommendFriends())); connect( ui.actionServicePermission, SIGNAL(triggered()), this, SLOT(servicePermission())); connect( ui.filter_lineEdit, SIGNAL(textChanged(QString)), ui.friendList, SLOT(filterItems(QString))); ui.filter_lineEdit->setPlaceholderText(tr("Search")) ; ui.filter_lineEdit->showFilterIcon(); ui.avatar->setFrameType(AvatarWidget::STATUS_FRAME); ui.avatar->setOwnId(); ui.tabWidget->setTabPosition(QTabWidget::North); ui.tabWidget->addTab(networkView = new NetworkView(),QIcon(IMAGE_NETWORK2), tr("Local network")); ui.tabWidget->addTab(networkDialog = new NetworkDialog(),QIcon(IMAGE_PEERS), tr("Known people")); //ui.tabWidget->addTab(new ProfileWidget(), tr("Profile")); //newsFeed = new NewsFeed(); //int newsFeedTabIndex = ui.tabWidget->insertTab(0, newsFeed, tr("News Feed")); //ui.tabWidget->setCurrentIndex(newsFeedTabIndex); ui.tabWidget->hideCloseButton(0); ui.tabWidget->hideCloseButton(1); ui.tabWidget->hideCloseButton(2); ui.tabWidget->hideCloseButton(3); /* get the current text and text color of the tab bar */ //newsFeedTabColor = ui.tabWidget->tabBar()->tabTextColor(newsFeedTabIndex); //newsFeedText = ui.tabWidget->tabBar()->tabText(newsFeedTabIndex); //connect(newsFeed, SIGNAL(newsFeedChanged(int)), this, SLOT(newsFeedChanged(int))); connect(ui.Sendbtn, SIGNAL(clicked()), this, SLOT(sendMsg())); connect(ui.emoticonBtn, SIGNAL(clicked()), this, SLOT(smileyWidgetgroupchat())); connect(ui.msgText,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(contextMenuMsgText(QPoint))); connect(ui.lineEdit,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(contextMenu(QPoint))); // reset text and color after removing all characters from the QTextEdit and after calling QTextEdit::clear connect(ui.lineEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(chatCharFormatChanged())); connect(ui.textboldChatButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui.textunderlineChatButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui.textitalicChatButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui.fontsButton, SIGNAL(clicked()), this, SLOT(chooseFont())); connect(ui.colorChatButton, SIGNAL(clicked()), this, SLOT(chooseColor())); connect(ui.actionSave_History, SIGNAL(triggered()), this, SLOT(fileSaveAs())); connect(ui.hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>))); ui.fontsButton->setIcon(QIcon(QString(":/images/fonts.png"))); mCurrentColor = Qt::black; mCurrentFont.fromString(Settings->getChatScreenFont()); colorChanged(); fontChanged(); setColorAndFont(); style.setStyleFromSettings(ChatStyle::TYPE_PUBLIC); setChatInfo(tr("Welcome to RetroShare's group chat."), QString::fromUtf8("blue")); if (rsHistory->getEnable(true)) { int messageCount = Settings->getPublicChatHistoryCount(); if (messageCount > 0) { std::list<HistoryMsg> historyMsgs; rsHistory->getMessages("", historyMsgs, messageCount); std::list<HistoryMsg>::iterator it; for (it = historyMsgs.begin(); it != historyMsgs.end(); it++) { addChatMsg(it->incoming, true, QString::fromUtf8(it->peerName.c_str()), QDateTime::fromTime_t(it->sendTime), QDateTime::fromTime_t(it->recvTime), QString::fromUtf8(it->message.c_str())); } } } QMenu *menu = new QMenu(); menu->addAction(ui.actionClear_Chat_History); menu->addAction(ui.actionDelete_Chat_History); menu->addAction(ui.actionSave_History); menu->addAction(ui.actionMessageHistory); ui.menuButton->setMenu(menu); menu = new QMenu(); menu->addAction(ui.actionAdd_Friend); menu->addAction(ui.actionAdd_Group); menu->addAction(ui.actionCreate_new_Chat_lobby); menu->addAction(ui.actionFriendRecommendations); menu->addAction(ui.actionServicePermission); menu->addSeparator(); menu->addAction(ui.actionSet_your_Avatar); menu->addAction(ui.actionSet_your_Personal_Message); ui.menutoolButton->setMenu(menu); setAcceptDrops(true); ui.lineEdit->setAcceptDrops(false); ui.hashBox->setDropWidget(this); ui.hashBox->setAutoHide(true); /* Set initial size the splitter */ QList<int> sizes; sizes << height() << 100; // Qt calculates the right sizes ui.splitter_2->setSizes(sizes); loadmypersonalstatus(); ui.displayButton->setMenu(ui.friendList->createDisplayMenu()); // load settings RsAutoUpdatePage::lockAllEvents(); ui.friendList->setShowStatusColumn(true); ui.friendList->setShowLastContactColumn(false); ui.friendList->setShowAvatarColumn(false); ui.friendList->setRootIsDecorated(true); ui.friendList->setShowGroups(true); processSettings(true); RsAutoUpdatePage::unlockAllEvents(); ui.lineEdit->installEventFilter(this); // add self nick and Avatar to Friends. RsPeerDetails pd ; if (rsPeers->getPeerDetails(rsPeers->getOwnId(),pd)) { ui.nicknameLabel->setText(PeerDefs::nameWithLocation(pd)); } /* Hide platform specific features */ #ifdef Q_WS_WIN #endif }
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())); }
InputWidget::InputWidget(QWidget *parent) : AbstractItemView(parent), _networkId(0) { ui.setupUi(this); connect(ui.ownNick, SIGNAL(activated(QString)), this, SLOT(changeNick(QString))); layout()->setAlignment(ui.ownNick, Qt::AlignBottom); layout()->setAlignment(ui.inputEdit, Qt::AlignBottom); layout()->setAlignment(ui.showStyleButton, Qt::AlignBottom); layout()->setAlignment(ui.styleFrame, Qt::AlignBottom); ui.styleFrame->setVisible(false); setFocusProxy(ui.inputEdit); ui.ownNick->setFocusProxy(ui.inputEdit); ui.ownNick->setSizeAdjustPolicy(QComboBox::AdjustToContents); ui.ownNick->installEventFilter(new MouseWheelFilter(this)); ui.inputEdit->installEventFilter(this); ui.inputEdit->setMinHeight(1); ui.inputEdit->setMaxHeight(5); ui.inputEdit->setMode(MultiLineEdit::MultiLine); ui.inputEdit->setPasteProtectionEnabled(true); ui.boldButton->setIcon(SmallIcon("format-text-bold")); ui.italicButton->setIcon(SmallIcon("format-text-italic")); ui.underlineButton->setIcon(SmallIcon("format-text-underline")); ui.textcolorButton->setIcon(SmallIcon("format-text-color")); ui.highlightcolorButton->setIcon(SmallIcon("format-fill-color")); ui.encryptionIconLabel->hide(); _colorMenu = new QMenu(); _colorFillMenu = new QMenu(); QStringList names; names << tr("White") << tr("Black") << tr("Dark blue") << tr("Dark green") << tr("Red") << tr("Dark red") << tr("Dark magenta") << tr("Orange") << tr("Yellow") << tr("Green") << tr("Dark cyan") << tr("Cyan") << tr("Blue") << tr("Magenta") << tr("Dark gray") << tr("Light gray"); QPixmap pix(16, 16); for (int i = 0; i < inputLine()->mircColorMap().count(); i++) { pix.fill(inputLine()->mircColorMap().values()[i]); _colorMenu->addAction(pix, names[i])->setData(inputLine()->mircColorMap().keys()[i]); _colorFillMenu->addAction(pix, names[i])->setData(inputLine()->mircColorMap().keys()[i]); } pix.fill(Qt::transparent); _colorMenu->addAction(pix, tr("Clear Color"))->setData(""); _colorFillMenu->addAction(pix, tr("Clear Color"))->setData(""); ui.textcolorButton->setMenu(_colorMenu); connect(_colorMenu, SIGNAL(triggered(QAction *)), this, SLOT(colorChosen(QAction *))); ui.highlightcolorButton->setMenu(_colorFillMenu); connect(_colorFillMenu, SIGNAL(triggered(QAction *)), this, SLOT(colorHighlightChosen(QAction *))); new TabCompleter(ui.inputEdit); UiStyleSettings fs("Fonts"); fs.notify("UseCustomInputWidgetFont", this, SLOT(setUseCustomFont(QVariant))); fs.notify("InputWidget", this, SLOT(setCustomFont(QVariant))); if (fs.value("UseCustomInputWidgetFont", false).toBool()) setCustomFont(fs.value("InputWidget", QFont())); UiSettings s("InputWidget"); #ifdef HAVE_KDE s.notify("EnableSpellCheck", this, SLOT(setEnableSpellCheck(QVariant))); setEnableSpellCheck(s.value("EnableSpellCheck", false)); #endif s.notify("EnableEmacsMode", this, SLOT(setEnableEmacsMode(QVariant))); setEnableEmacsMode(s.value("EnableEmacsMode", false)); s.notify("ShowNickSelector", this, SLOT(setShowNickSelector(QVariant))); setShowNickSelector(s.value("ShowNickSelector", true)); s.notify("ShowStyleButtons", this, SLOT(setShowStyleButtons(QVariant))); setShowStyleButtons(s.value("ShowStyleButtons", true)); s.notify("EnablePerChatHistory", this, SLOT(setEnablePerChatHistory(QVariant))); setEnablePerChatHistory(s.value("EnablePerChatHistory", false)); s.notify("MaxNumLines", this, SLOT(setMaxLines(QVariant))); setMaxLines(s.value("MaxNumLines", 5)); s.notify("EnableScrollBars", this, SLOT(setScrollBarsEnabled(QVariant))); setScrollBarsEnabled(s.value("EnableScrollBars", true)); s.notify("EnableLineWrap", this, SLOT(setLineWrapEnabled(QVariant))); setLineWrapEnabled(s.value("EnableLineWrap", false)); s.notify("EnableMultiLine", this, SLOT(setMultiLineEnabled(QVariant))); setMultiLineEnabled(s.value("EnableMultiLine", true)); ActionCollection *coll = QtUi::actionCollection(); Action *activateInputline = coll->add<Action>("FocusInputLine"); connect(activateInputline, SIGNAL(triggered()), SLOT(setFocus())); activateInputline->setText(tr("Focus Input Line")); activateInputline->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L)); connect(inputLine(), SIGNAL(textEntered(QString)), SLOT(onTextEntered(QString)), Qt::QueuedConnection); // make sure the line is already reset, bug #984 connect(inputLine(), SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat))); }
ChatWidget::ChatWidget(QWidget *parent) : QWidget(parent), ui(new Ui::ChatWidget) { ui->setupUi(this); newMessages = false; typing = false; peerStatus = 0; isChatLobby = false; firstShow = true; inChatCharFormatChanged = false; lastStatusSendTime = 0 ; connect(ui->sendButton, SIGNAL(clicked()), this, SLOT(sendChat())); connect(ui->addFileButton, SIGNAL(clicked()), this , SLOT(addExtraFile())); connect(ui->textboldButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui->textunderlineButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui->textitalicButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui->attachPictureButton, SIGNAL(clicked()), this, SLOT(addExtraPicture())); connect(ui->colorButton, SIGNAL(clicked()), this, SLOT(chooseColor())); connect(ui->emoteiconButton, SIGNAL(clicked()), this, SLOT(smileyWidget())); connect(ui->actionSaveChatHistory, SIGNAL(triggered()), this, SLOT(fileSaveAs())); connect(ui->actionClearChatHistory, SIGNAL(triggered()), this, SLOT(clearChatHistory())); connect(ui->actionDeleteChatHistory, SIGNAL(triggered()), this, SLOT(deleteChatHistory())); connect(ui->actionMessageHistory, SIGNAL(triggered()), this, SLOT(messageHistory())); connect(ui->actionChooseFont, SIGNAL(triggered()), this, SLOT(chooseFont())); connect(ui->actionResetFont, SIGNAL(triggered()), this, SLOT(resetFont())); connect(ui->hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>))); connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&, int)), this, SLOT(updateStatus(const QString&, int))); connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&))); connect(ui->textBrowser, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTextBrowser(QPoint))); connect(ui->chatTextEdit, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint))); // reset text and color after removing all characters from the QTextEdit and after calling QTextEdit::clear connect(ui->chatTextEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(chatCharFormatChanged())); ui->infoFrame->setVisible(false); ui->statusMessageLabel->hide(); setAcceptDrops(true); ui->chatTextEdit->setAcceptDrops(false); ui->hashBox->setDropWidget(this); ui->hashBox->setAutoHide(true); QMenu *menu = new QMenu(); menu->addAction(ui->actionChooseFont); menu->addAction(ui->actionResetFont); ui->fontButton->setMenu(menu); menu = new QMenu(); menu->addAction(ui->actionClearChatHistory); menu->addAction(ui->actionDeleteChatHistory); menu->addAction(ui->actionSaveChatHistory); menu->addAction(ui->actionMessageHistory); ui->pushtoolsButton->setMenu(menu); ui->chatTextEdit->installEventFilter(this); //#if QT_VERSION < 0x040700 // embedded images are not supported before QT 4.7.0 ui->attachPictureButton->setVisible(false); //#endif resetStatusBar(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { // open database connection db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("/Users/jdoud/dev/brainstorm.sqlite"); if(!db.open()) { qDebug() << db.lastError(); qFatal("Failed to connect."); } // setup UI ui->setupUi(this); ui->toolBar->addWidget(ui->comboFonts); ui->toolBar->addWidget(ui->comboFontSizes); ui->toolBar->addWidget(ui->comboColors); // set text editor defaults ui->textNote->document()->setIndentWidth(20); ui->textNote->setTabStopWidth(20); ui->textNote->setTabChangesFocus(false); ui->actionIncrease_Indent->setShortcut(Qt::Key_Tab); ui->actionDecrease_Indent->setShortcut(Qt::Key_Backtab); // setup comboColors QPixmap pix(16, 16); pix.fill(Qt::white); ui->comboColors->addItem(pix, ""); pix.fill(Qt::black); ui->comboColors->addItem(pix, ""); pix.fill(Qt::red); ui->comboColors->addItem(pix, ""); pix.fill(Qt::blue); ui->comboColors->addItem(pix, ""); pix.fill(Qt::darkGreen); ui->comboColors->addItem(pix, ""); pix.fill(Qt::gray); ui->comboColors->addItem(pix, ""); // create system tray icon createActions(); createTrayIcon(); // create models categoriesModel = new QSqlTableModel(); categoriesModel->setTable("categories"); categoriesModel->setSort(1, Qt::AscendingOrder); categoriesModel->select(); ui->listCategories->setModel(categoriesModel); ui->listCategories->setModelColumn(1); notesModel = new QSqlTableModel(); notesModel->setTable("notes"); ui->listNotes->setModel(notesModel); ui->listNotes->setModelColumn(2); // set splitter size QList<int> sizes; sizes << 230 << 150; ui->splitterLists->setSizes(sizes); sizes.clear(); sizes << 230 << 600; ui->splitterNote->setSizes(sizes); // connect File menu slots connect(ui->actionNew_Category, SIGNAL(triggered()), this, SLOT(newCategory())); connect(ui->actionRename_Category, SIGNAL(triggered()), this, SLOT(renameCategory())); connect(ui->actionDelete_Category, SIGNAL(triggered()), this, SLOT(deleteCategory())); connect(ui->actionNew_Note, SIGNAL(triggered()), this, SLOT(newNote())); connect(ui->actionRename_Note, SIGNAL(triggered()), this, SLOT(renameNote())); connect(ui->actionSave_Note, SIGNAL(triggered()), this, SLOT(saveNote())); connect(ui->actionDelete_Note, SIGNAL(triggered()), this, SLOT(deleteNote())); connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(quit())); // connect Edit menu slots connect(ui->actionFind_Replace, SIGNAL(triggered()), this, SLOT(findAndReplace())); // connect Format menu slots connect(ui->actionBold, SIGNAL(triggered()), this, SLOT(bold())); connect(ui->actionItalic, SIGNAL(triggered()), this, SLOT(italic())); connect(ui->actionUnderline, SIGNAL(triggered()), this, SLOT(underline())); connect(ui->actionStrikethrough, SIGNAL(triggered()), this, SLOT(strikethrough())); connect(ui->actionBullet_List, SIGNAL(triggered()), this, SLOT(bulletList())); connect(ui->actionNumber_List, SIGNAL(triggered()), this, SLOT(numberList())); connect(ui->actionIncrease_Indent, SIGNAL(triggered()), this, SLOT(increaseIndent())); connect(ui->actionDecrease_Indent, SIGNAL(triggered()), this, SLOT(decreaseIndent())); connect(ui->actionShow_Colors, SIGNAL(triggered()), this, SLOT(showColors())); connect(ui->actionShow_Fonts, SIGNAL(triggered()), this, SLOT(showFonts())); connect(ui->actionIncrease_Font, SIGNAL(triggered()), this, SLOT(increaseFont())); connect(ui->actionDecrease_Font, SIGNAL(triggered()), this, SLOT(decreaseFont())); connect(ui->actionReset_Font, SIGNAL(triggered()), this, SLOT(resetFont())); connect(ui->actionAlign_Left, SIGNAL(triggered()), this, SLOT(alignLeft())); connect(ui->actionAlign_Center, SIGNAL(triggered()), this, SLOT(alignCenter())); connect(ui->actionAlign_Right, SIGNAL(triggered()), this, SLOT(alignRight())); connect(ui->actionAlign_Justify, SIGNAL(triggered()), this, SLOT(alignJustify())); // connect View menu slots connect(ui->actionHide_Window, SIGNAL(triggered()), this, SLOT(hide())); connect(ui->actionPrevious_Category, SIGNAL(triggered()), this, SLOT(previousCategory())); connect(ui->actionNext_Category, SIGNAL(triggered()), this, SLOT(nextCategory())); connect(ui->actionPrevious_Note, SIGNAL(triggered()), this, SLOT(previousNote())); connect(ui->actionNext_Note, SIGNAL(triggered()), this, SLOT(nextNote())); // connect Help menu slots connect(ui->actionAbout_Brainstorm, SIGNAL(triggered()), this, SLOT(aboutBrainstorm())); connect(ui->actionAbout_Qt, SIGNAL(triggered()), this, SLOT(aboutQt())); // connect application slots connect(ui->textNote, SIGNAL(cursorPositionChanged()), this, SLOT(updateMenus())); connect(ui->textNote, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(updateMenus())); connect(ui->comboFonts, SIGNAL(activated(QString)), this, SLOT(setFont(QString))); connect(ui->comboFontSizes, SIGNAL(activated(QString)), this, SLOT(setFontSize(QString))); connect(ui->comboColors, SIGNAL(activated(int)), this, SLOT(setFontColor(int))); // connect category list slots connect(ui->listCategories->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(updateNoteList(QModelIndex))); // connect note list slots connect(ui->listNotes->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(updateNoteText(QModelIndex))); // connect text slots ui->textNote->installEventFilter((this)); // connect system tray icon connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); // initialize default data ui->listCategories->selectionModel()->setCurrentIndex(categoriesModel->index(0, 1), QItemSelectionModel::SelectCurrent); }
MyChat::MyChat(ClientInfo &c, QWidget* parent):QWidget(parent) { this->clientInfo = c; this->resize(588, 512); showText = new QTextBrowser(); // showText->setGeometry(10,10,566,290); inputText = new QTextEdit(); // inputText->setGeometry(10,320,566,80); closeBtn = new QPushButton(); closeBtn->setText("Close"); sendBtn = new QPushButton(); sendBtn->setText("Send"); fontHomeBox = new QFontComboBox(); fontHomeBox->setEditable(false); fontSizeBox = new QComboBox(); QStringList sizeList; sizeList<<"9"<<"10"<<"11"<<"12"<<"13"<<"14"<<"15"<<"16"<<"17"<<"18"<<"19"<<"20"<<"21"<<"22"; fontSizeBox->insertItems(0, sizeList); fontSizeBox->setCurrentIndex(3); boldToolBtn = new QToolButton(); boldToolBtn->setCheckable(true);//可以按下 boldToolBtn->setIcon(QIcon(":/root/chatIcon/bold.png")); boldToolBtn->setIconSize(QSize(32,32)); boldToolBtn->setAutoRaise(true); italicToolBtn = new QToolButton(); italicToolBtn->setCheckable(true); italicToolBtn->setIcon(QIcon(":/root/chatIcon/italic.png")); italicToolBtn->setIconSize(QSize(32,32)); italicToolBtn->setAutoRaise(true); underlineToolBtn = new QToolButton(); underlineToolBtn->setCheckable(true); underlineToolBtn->setIcon(QIcon(":/root/chatIcon/underline.png")); underlineToolBtn->setIconSize(QSize(32,32)); underlineToolBtn->setAutoRaise(true); colorToolBtn = new QToolButton(); colorToolBtn->setIcon(QIcon(":/root/chatIcon/color.png")); colorToolBtn->setIconSize(QSize(32,32)); colorToolBtn->setAutoRaise(true); sendToolBtn = new QToolButton(); sendToolBtn->setIcon(QIcon(":/root/chatIcon/sendfile.png")); sendToolBtn->setIconSize(QSize(32,32)); sendToolBtn->setAutoRaise(true); saveToolBtn = new QToolButton(); saveToolBtn->setIcon(QIcon(":/root/chatIcon/savemsg.png")); saveToolBtn->setIconSize(QSize(32,32)); saveToolBtn->setAutoRaise(true); clearToolBtn = new QToolButton(); clearToolBtn->setIcon(QIcon(":/root/chatIcon/clearmsg.png")); clearToolBtn->setIconSize(QSize(32,32)); clearToolBtn->setAutoRaise(true); QHBoxLayout* h2 = new QHBoxLayout(); h2->addWidget(fontHomeBox); h2->addWidget(fontSizeBox); h2->addWidget(boldToolBtn); h2->addWidget(italicToolBtn); h2->addWidget(underlineToolBtn); h2->addWidget(colorToolBtn); h2->addWidget(sendToolBtn); h2->addWidget(saveToolBtn); h2->addWidget(clearToolBtn); QVBoxLayout* v1 = new QVBoxLayout(); v1->addWidget(showText, 6); v1->addLayout(h2); v1->addWidget(inputText, 2); // v1->addStretch(3); QHBoxLayout* h1 = new QHBoxLayout(); h1->addWidget(closeBtn, 0); h1->addWidget(sendBtn, 0); h1->setAlignment(Qt::AlignHCenter | Qt::AlignRight); // h1->addStretch(); QVBoxLayout* v2 = new QVBoxLayout(this); v2->addLayout(v1); v2->addLayout(h1); connect(sendBtn,SIGNAL(clicked()), this, SLOT(sendMsg())); connect(closeBtn, SIGNAL(clicked()), this, SLOT(closeClicked())); connect(fontHomeBox, SIGNAL(currentFontChanged(QFont)), this, SLOT(fontHomeChange())); connect(fontSizeBox, SIGNAL(currentIndexChanged(int)), this, SLOT(fontSizeChange())); connect(boldToolBtn, SIGNAL(clicked(bool)), this, SLOT(fontBoldChange())); connect(italicToolBtn, SIGNAL(clicked(bool)), this, SLOT(fontItalicChange())); connect(underlineToolBtn, SIGNAL(clicked(bool)), this, SLOT(fontUnderlineChange())); connect(colorToolBtn, SIGNAL(clicked()), this,SLOT(colorBtnClicked())); connect(saveToolBtn, SIGNAL(clicked()), this, SLOT(saveBtnClicked())); connect(clearToolBtn, SIGNAL(clicked()), this, SLOT(clearBtnClicked())); //当单击输入框中一个字体时,字体格式设置会变成设置这个字体时的设置 connect(inputText, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(fontFormatChanged(const QTextCharFormat))); mySocket = MySocket::getInstance(); }
TextEdit::TextEdit(QWidget *parent) : QMainWindow(parent) { setToolButtonStyle(Qt::ToolButtonFollowStyle); setupFileActions(); setupEditActions(); setupTextActions(); { // QMenu *helpMenu = new QMenu(tr("Help"), this); // menuBar()->addMenu(helpMenu); // helpMenu->addAction(tr("About"), this, SLOT(about())); // helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt())); } textEdit = new QTextEdit(this); ////////////////////////////////////////////////// connect(textEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat))); connect(textEdit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); /////////// //setCentralWidget(textEdit); //blank=new Blank(this); //setCentralWidget(blank); //create a transparent canvas and put it on the top of textEdit image =new MyCanvas(900,800,this); textEdit->setFixedSize(QSize(800,800)); textEdit->setBackgroundRole(QPalette::Light); //scrollArea对象的背景色设为Dark image->setFixedSize(QSize(800,800)); image->setStyleSheet(QString::fromUtf8("border:1px solid #000000;")); QScrollArea* scrollArea = new QScrollArea; scrollArea->setFixedSize(QSize(1800,900)); //scrollArea->setWidget(image); //将画布添加到scrollArea中 scrollArea->setBackgroundRole(QPalette::Light); //scrollArea对象的背景色设为Dark //scrollArea->setBackgroundColor(QColor::white); // QStackedLayout *stackedLayout = new QStackedLayout; // stackedLayout->addWidget(image); // stackedLayout->addWidget(textEdit); // stackedLayout->setStackingMode(QStackedLayout::StackAll); QHBoxLayout* hLayout=new QHBoxLayout(); hLayout->addWidget(textEdit); hLayout->addWidget(image); // scrollArea->setLayout(stackedLayout); scrollArea->setLayout(hLayout); //scrollArea->setGeometry(QRect(50,50,800,800)); setCentralWidget(scrollArea); //将scrollArea加入到主窗口的中心区new QPainter(this); scrollArea->setAlignment(Qt::AlignHCenter); //after canvas handle the mouse-drag event, emit it to the edittext for farther handling connect(image,SIGNAL(mouseMoveSig(QMouseEvent*)),this,SLOT(onMouseMove(QMouseEvent*))); //connect(image,SIGNAL(mouseMoveSig(QMouseEvent*)),textEdit,SLOT(mouseMoveEvent(QMouseEvent*))); //connect(image,SIGNAL(mouseMoveSig(QMouseEvent*)),textEdit,SLOT(cursorPositionChanged(QMouseEvent*))); //connect(this,SIGNAL(mouseMoveSig(QMouseEvent*)),image,SLOT(mouseMoveSlot(QMouseEvent*))); //connect(textEdit,SIGNAL(mouseMoveEvent(QMouseEvent*)),image,SLOT(mouseMoveSlot(QMouseEvent*))); // textEdit->setFocus(); setCurrentFileName(QString()); fontChanged(textEdit->font()); colorChanged(textEdit->textColor()); alignmentChanged(textEdit->alignment()); connect(textEdit->document(), SIGNAL(modificationChanged(bool)), actionSave, SLOT(setEnabled(bool))); connect(textEdit->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool))); connect(textEdit->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool))); connect(textEdit->document(), SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool))); setWindowModified(textEdit->document()->isModified()); actionSave->setEnabled(textEdit->document()->isModified()); actionUndo->setEnabled(textEdit->document()->isUndoAvailable()); actionRedo->setEnabled(textEdit->document()->isRedoAvailable()); connect(actionUndo, SIGNAL(triggered()), textEdit, SLOT(undo())); connect(actionRedo, SIGNAL(triggered()), textEdit, SLOT(redo())); actionCut->setEnabled(false); actionCopy->setEnabled(false); connect(actionCut, SIGNAL(triggered()), textEdit, SLOT(cut())); connect(actionCopy, SIGNAL(triggered()), textEdit, SLOT(copy())); connect(actionPaste, SIGNAL(triggered()), textEdit, SLOT(paste())); connect(textEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); connect(textEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); #ifndef QT_NO_CLIPBOARD connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); #endif //QString initialFile = ":/data/example.html"; QString initialFile = ":/data/test.txt"; const QStringList args = QCoreApplication::arguments(); if (args.count() == 2) initialFile = args.at(1); if (!load(initialFile)) fileNew(); }
EditorRichText::EditorRichText(QWidget *parent) : QTextEdit(parent), m_simplifyRichText(simplifyRichTextDefault) { connect(this, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SIGNAL(stateChanged())); connect(this, SIGNAL(cursorPositionChanged()), this, SIGNAL(stateChanged())); }
TextEdit::TextEdit(QWidget *parent) : QMainWindow(parent) { setToolButtonStyle(Qt::ToolButtonFollowStyle); setupFileActions(); setupEditActions(); setupTextActions(); { QMenu *helpMenu = new QMenu(tr("Help"), this); menuBar()->addMenu(helpMenu); helpMenu->addAction(tr("About"), this, SLOT(about())); helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt())); } textEdit = new QTextEdit(this); connect(textEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat))); connect(textEdit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); setCentralWidget(textEdit); textEdit->setFocus(); setCurrentFileName(QString()); fontChanged(textEdit->font()); colorChanged(textEdit->textColor()); alignmentChanged(textEdit->alignment()); connect(textEdit->document(), SIGNAL(modificationChanged(bool)), actionSave, SLOT(setEnabled(bool))); connect(textEdit->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool))); connect(textEdit->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool))); connect(textEdit->document(), SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool))); setWindowModified(textEdit->document()->isModified()); actionSave->setEnabled(textEdit->document()->isModified()); actionUndo->setEnabled(textEdit->document()->isUndoAvailable()); actionRedo->setEnabled(textEdit->document()->isRedoAvailable()); connect(actionUndo, SIGNAL(triggered()), textEdit, SLOT(undo())); connect(actionRedo, SIGNAL(triggered()), textEdit, SLOT(redo())); actionCut->setEnabled(false); actionCopy->setEnabled(false); connect(actionCut, SIGNAL(triggered()), textEdit, SLOT(cut())); connect(actionCopy, SIGNAL(triggered()), textEdit, SLOT(copy())); connect(actionPaste, SIGNAL(triggered()), textEdit, SLOT(paste())); connect(textEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); connect(textEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); #ifndef QT_NO_CLIPBOARD connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); #endif QString initialFile = "/example.html"; const QStringList args = QCoreApplication::arguments(); if (args.count() == 2) initialFile = args.at(1); if (!load(initialFile)) fileNew(); }
/*! \class LabelWidget \brief Widget for editing the properties of a TextLabel object, mostly used in an appropriate dock widget. In order the properties of the label to be shown, \c loadConfig() has to be called with the correspondig KConfigGroup (settings for a label in *Plot, Axis etc. or for an independent label on the worksheet). \ingroup kdefrontend */ LabelWidget::LabelWidget(QWidget* parent) : QWidget(parent), m_label(0), m_initializing(false), m_dateTimeMenu(new QMenu(this)), m_teXEnabled(false) { // see legacy/LabelWidget.cpp ui.setupUi(this); QSplitter* splitter = new QSplitter(Qt::Vertical, this); splitter->setHandleWidth(1); splitter->addWidget(ui.frameTop); splitter->addWidget(ui.frameBottom); splitter->setChildrenCollapsible(false); ui.lText->setMinimumWidth(ui.lGeometry->width()); this->layout()->addWidget(splitter); m_dateTimeMenu->setSeparatorsCollapsible(false); //we don't want the first separator to be removed ui.kcbFontColor->setColor(Qt::black); // default color //Icons ui.tbFontBold->setIcon( QIcon::fromTheme("format-text-bold") ); ui.tbFontItalic->setIcon( QIcon::fromTheme("format-text-italic") ); ui.tbFontUnderline->setIcon( QIcon::fromTheme("format-text-underline") ); ui.tbFontStrikeOut->setIcon( QIcon::fromTheme("format-text-strikethrough") ); ui.tbFontSuperScript->setIcon( QIcon::fromTheme("format-text-superscript") ); ui.tbFontSubScript->setIcon( QIcon::fromTheme("format-text-subscript") ); ui.tbSymbols->setIcon( QIcon::fromTheme("labplot-format-text-symbol") ); ui.tbDateTime->setIcon( QIcon::fromTheme("chronometer") ); ui.tbTexUsed->setIcon( QIcon::fromTheme("labplot-TeX-logo") ); //Positioning and alignment ui.cbPositionX->addItem(i18n("left")); ui.cbPositionX->addItem(i18n("center")); ui.cbPositionX->addItem(i18n("right")); ui.cbPositionX->addItem(i18n("custom")); ui.cbPositionY->addItem(i18n("top")); ui.cbPositionY->addItem(i18n("center")); ui.cbPositionY->addItem(i18n("bottom")); ui.cbPositionY->addItem(i18n("custom")); ui.cbHorizontalAlignment->addItem(i18n("left")); ui.cbHorizontalAlignment->addItem(i18n("center")); ui.cbHorizontalAlignment->addItem(i18n("right")); ui.cbVerticalAlignment->addItem(i18n("top")); ui.cbVerticalAlignment->addItem(i18n("center")); ui.cbVerticalAlignment->addItem(i18n("bottom")); //check whether the used latex compiler is available. //Following logic is implemented (s.a. LabelWidget::teXUsedChanged()): //1. in case latex was used to generate the text label in the stored project //and no latex is available on the target system, latex button is toggled and //the user still can switch to the non-latex mode. //2. in case the label was in the non-latex mode and no latex is available, //deactivate the latex button so the user cannot switch to this mode. m_teXEnabled = TeXRenderer::enabled(); #ifdef HAVE_KF5_SYNTAX_HIGHLIGHTING m_highlighter = new KSyntaxHighlighting::SyntaxHighlighter(ui.teLabel->document()); m_highlighter->setDefinition(m_repository.definitionForName("LaTeX")); #endif //SLOTS // text properties connect(ui.tbTexUsed, SIGNAL(clicked(bool)), this, SLOT(teXUsedChanged(bool)) ); connect(ui.teLabel, SIGNAL(textChanged()), this, SLOT(textChanged())); connect(ui.teLabel, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(charFormatChanged(QTextCharFormat))); connect(ui.kcbFontColor, SIGNAL(changed(QColor)), this, SLOT(fontColorChanged(QColor))); connect(ui.tbFontBold, SIGNAL(clicked(bool)), this, SLOT(fontBoldChanged(bool))); connect(ui.tbFontItalic, SIGNAL(clicked(bool)), this, SLOT(fontItalicChanged(bool))); connect(ui.tbFontUnderline, SIGNAL(clicked(bool)), this, SLOT(fontUnderlineChanged(bool))); connect(ui.tbFontStrikeOut, SIGNAL(clicked(bool)), this, SLOT(fontStrikeOutChanged(bool))); connect(ui.tbFontSuperScript, SIGNAL(clicked(bool)), this, SLOT(fontSuperScriptChanged(bool))); connect(ui.tbFontSubScript, SIGNAL(clicked(bool)), this, SLOT(fontSubScriptChanged(bool))); connect(ui.tbSymbols, SIGNAL(clicked(bool)), this, SLOT(charMenu())); connect(ui.tbDateTime, SIGNAL(clicked(bool)), this, SLOT(dateTimeMenu())); connect(m_dateTimeMenu, SIGNAL(triggered(QAction*)), this, SLOT(insertDateTime(QAction*)) ); connect(ui.kfontRequester, SIGNAL(fontSelected(QFont)), this, SLOT(fontChanged(QFont))); connect(ui.kfontRequesterTeX, SIGNAL(fontSelected(QFont)), this, SLOT(teXFontChanged(QFont))); connect(ui.sbFontSize, SIGNAL(valueChanged(int)), this, SLOT(fontSizeChanged(int)) ); // geometry connect( ui.cbPositionX, SIGNAL(currentIndexChanged(int)), this, SLOT(positionXChanged(int)) ); connect( ui.cbPositionY, SIGNAL(currentIndexChanged(int)), this, SLOT(positionYChanged(int)) ); connect( ui.sbPositionX, SIGNAL(valueChanged(double)), this, SLOT(customPositionXChanged(double)) ); connect( ui.sbPositionY, SIGNAL(valueChanged(double)), this, SLOT(customPositionYChanged(double)) ); connect( ui.cbHorizontalAlignment, SIGNAL(currentIndexChanged(int)), this, SLOT(horizontalAlignmentChanged(int)) ); connect( ui.cbVerticalAlignment, SIGNAL(currentIndexChanged(int)), this, SLOT(verticalAlignmentChanged(int)) ); connect( ui.sbRotation, SIGNAL(valueChanged(int)), this, SLOT(rotationChanged(int)) ); connect( ui.sbOffsetX, SIGNAL(valueChanged(double)), this, SLOT(offsetXChanged(double)) ); connect( ui.sbOffsetY, SIGNAL(valueChanged(double)), this, SLOT(offsetYChanged(double)) ); connect( ui.chbVisible, SIGNAL(clicked(bool)), this, SLOT(visibilityChanged(bool)) ); //TODO: https://bugreports.qt.io/browse/QTBUG-25420 ui.tbFontUnderline->hide(); ui.tbFontStrikeOut->hide(); }