DevGUI::DevGUI() : QMainWindow(0), noname_count(0) { setupFileActions(); setupEditActions(); setupTextActions(); setupCompiler(); setupExplorer(); Editor = new DevMDI(this); Editor->setWindowState(Qt::WindowMaximized); connect(Editor, SIGNAL(currentChanged(int)), this, SLOT(editorChanged())); setCentralWidget(Editor); connect(QApplication::clipboard() , SIGNAL(dataChanged()), this , SLOT (clipboardDataChanged()) ); for (int i = 1; i < DEV_APP->argc(); ++i) load(DEV_APP->argv()[i]); setWindowState(Qt::WindowMaximized); setWindowTitle("Dev-Qt++ 0.1.0 [*]"); show(); }
XYZTextEditor::XYZTextEditor(QWidget *parent) : QWidget(parent), m_ui(new Ui::XYZTextEditor) { m_ui->setupUi(this); setupTextActions(); fontChanged(m_ui->textEdit->font()); alignmentChanged(m_ui->textEdit->alignment()); m_ui->textEdit->setFocus(); textEdit = m_ui->textEdit; QButtonGroup *btnGroup = new QButtonGroup(this); btnGroup->addButton(m_ui->btnAlignCenter); btnGroup->addButton(m_ui->btnAlignJustify); btnGroup->addButton(m_ui->btnAlignLeft); btnGroup->addButton(m_ui->btnAlignRight); QObject::connect(m_ui->textEdit, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), this, SLOT(currentCharFormatChanged(const QTextCharFormat &))); QObject::connect(m_ui->textEdit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); QObject::connect(m_ui->btnCut, SIGNAL(clicked()), m_ui->textEdit, SLOT(cut())); QObject::connect(m_ui->btnCopy, SIGNAL(clicked()), m_ui->textEdit, SLOT(copy())); QObject::connect(m_ui->btnPaste, SIGNAL(clicked()), m_ui->textEdit, SLOT(paste())); QObject::connect(m_ui->btnTextDirection, SIGNAL(clicked()), this, SLOT(textDirection())); // m_ui->textEdit->document()->defaultTextOption().setTextDirection(QApplication::layoutDirection()); // QTextCursor cursor = m_ui->textEdit->textCursor(); // QTextBlockFormat blockFmt = cursor.blockFormat(); // if (QApplication::layoutDirection() == Qt::RightToLeft) { // blockFmt.setLayoutDirection(Qt::RightToLeft); // } else { // blockFmt.setLayoutDirection(Qt::LeftToRight); // } // cursor.setBlockFormat(blockFmt); // qDebug()<<m_ui->textEdit->document()->defaultTextOption().textDirection(); // qDebug()<<m_ui->textEdit->toHtml(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { TestAssistance *pt = TestAssistance::get(); //main window init ui->setupUi(this); ui->toolBox->hide(); if(pt->isUserAdmin()){ ui->actionAdmin->setEnabled(true); ui->mainToolBar->addSeparator(); ui->mainToolBar->addAction(ui->actionAdmin); } else ui->actionAdmin->setEnabled(false); setWindowTitle(tr("[*]自动出卷系统 ") + TESTASSITANCE_VERSION); setWindowIcon(QIcon(":/TestAssist.ico")); setupFileActions(); setupEditActions(); setupTextActions(); //init editor initTextEditor(); setWindowModified(false); setWelcomActions(false); //init status QLabel *plabel = new QLabel(ui->statusBar); plabel->setText("当前用户:" + pt->get()->getUserName() + " 是否为管理员:" + (pt->get()->isUserAdmin()?"yes":"no")); ui->statusBar->addWidget(plabel); }
TextEdit::TextEdit(QWidget *parent) : QWidget(parent), layout(parent), toolBar1(parent), toolBar2(parent) { setupEditActions(); setupTextActions(); { setLayout(&layout); layout.addItem(&toolBar1); layout.addItem(&toolBar2); } textEdit = new QTextEdit(this); connect(textEdit, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), this, SLOT(currentCharFormatChanged(const QTextCharFormat &))); connect(textEdit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); layout.addWidget(textEdit); textEdit->setFocus(); fontChanged(textEdit->font()); colorChanged(textEdit->textColor()); alignmentChanged(textEdit->alignment()); 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()); 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))); connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); QString initialFile = ":/example.html"; const QStringList args = QCoreApplication::arguments(); if (args.count() == 2) initialFile = args.at(1); }
TextEdit::TextEdit( QWidget *parent, const char *name ) : QMainWindow( parent, name, 0 ) { setupFileActions(); setupEditActions(); setupTextActions(); tabWidget = new QTabWidget( this ); connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ), this, SLOT( editorChanged( QWidget * ) ) ); setCentralWidget( tabWidget ); }
TextEdit::TextEdit( QWidget *parent, const char *name ) : QMainWindow( parent, name ) { setupFileActions(); setupEditActions(); setupTextActions(); tabWidget = new QTabWidget( this ); connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ), this, SLOT( editorChanged( QWidget * ) ) ); setCentralWidget( tabWidget ); if ( qApp->argc() == 1 ) { load( "example.html" ); } else { for ( int i = 1; i < qApp->argc(); ++i ) load( qApp->argv()[ i ] ); } }
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(); }
/** 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(); }
GraphicTextDialog::GraphicTextDialog(GraphicText *text, Qucs::UndoOption opt, QWidget *parent) : QDialog(parent), textItem(text), undoOption(opt) { mainLayout = new QVBoxLayout(this); mainLayout->setSpacing(-1); toolBarLayout = new QHBoxLayout; mainLayout->addItem(toolBarLayout); toolBar = new QToolBar(this); toolBar->setIconSize(QSize(16, 16)); toolBarLayout->addWidget(toolBar); toolBarLayout->setSpacing(-1); toolBarLayout->setContentsMargins(0,0,0,0); setupEditActions(); setupTextActions(); textEdit = new QTextEdit; if(textItem) { QString latex = Qucs::unicodeToLatex(textItem->richText()); textEdit->setHtml(latex); } mainLayout->addWidget(textEdit); connect(textEdit, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), SLOT(currentCharFormatChanged(const QTextCharFormat &))); connect(textEdit, SIGNAL(cursorPositionChanged()), SLOT(cursorPositionChanged())); textEdit->setFocus(); fontChanged(textEdit->font()); colorChanged(textEdit->textColor()); alignmentChanged(textEdit->alignment()); subSuperAlignmentChanged(textEdit->currentCharFormat().verticalAlignment()); connect(textEdit->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool))); connect(textEdit->document(), SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool))); 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))); connect(QApplication::clipboard(), SIGNAL(dataChanged()), SLOT(clipboardDataChanged())); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); buttonBox->button(QDialogButtonBox::Ok)->setText(tr("&OK")); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); mainLayout->addWidget(buttonBox); adjustSize(); }
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(); }