LipstickCompositor::LipstickCompositor() : QWaylandCompositor(this), m_totalWindowCount(0), m_nextWindowId(1), m_homeActive(true), m_shaderEffect(0), m_fullscreenSurface(0), m_directRenderingActive(false), m_topmostWindowId(0), m_screenOrientation(Qt::PrimaryOrientation), m_displayState(new MeeGo::QmDisplayState(this)), m_retainedSelection(0) { setColor(Qt::black); setRetainedSelectionEnabled(true); if (m_instance) qFatal("LipstickCompositor: Only one compositor instance per process is supported"); m_instance = this; QObject::connect(this, SIGNAL(frameSwapped()), this, SLOT(windowSwapped())); QObject::connect(this, SIGNAL(beforeSynchronizing()), this, SLOT(clearUpdateRequest())); connect(m_displayState, SIGNAL(displayStateChanged(MeeGo::QmDisplayState::DisplayState)), this, SLOT(reactOnDisplayStateChanges(MeeGo::QmDisplayState::DisplayState))); QObject::connect(HomeApplication::instance(), SIGNAL(aboutToDestroy()), this, SLOT(homeApplicationAboutToDestroy())); m_orientationSensor = new QOrientationSensor(this); QObject::connect(m_orientationSensor, SIGNAL(readingChanged()), this, SLOT(setScreenOrientationFromSensor())); if (!m_orientationSensor->connectToBackend()) { qWarning() << "Could not connect to the orientation sensor backend"; } else { if (!m_orientationSensor->start()) qWarning() << "Could not start the orientation sensor"; } emit HomeApplication::instance()->homeActiveChanged(); QDesktopServices::setUrlHandler("http", this, "openUrl"); QDesktopServices::setUrlHandler("https", this, "openUrl"); QDesktopServices::setUrlHandler("mailto", this, "openUrl"); connect(QGuiApplication::clipboard(), SIGNAL(dataChanged()), SLOT(clipboardDataChanged())); }
VncView::VncView(QWidget *parent, const KUrl &url, KConfigGroup configGroup) : RemoteView(parent), m_initDone(false), m_buttonMask(0), m_repaint(false), m_quitFlag(false), m_firstPasswordTry(true), m_dontSendClipboard(false), m_horizontalFactor(1.0), m_verticalFactor(1.0), m_forceLocalCursor(false) { m_url = url; m_host = url.host(); m_port = url.port(); // BlockingQueuedConnection can cause deadlocks when exiting, handled in startQuitting() connect(&vncThread, SIGNAL(imageUpdated(int,int,int,int)), this, SLOT(updateImage(int,int,int,int)), Qt::BlockingQueuedConnection); connect(&vncThread, SIGNAL(gotCut(QString)), this, SLOT(setCut(QString)), Qt::BlockingQueuedConnection); connect(&vncThread, SIGNAL(passwordRequest(bool)), this, SLOT(requestPassword(bool)), Qt::BlockingQueuedConnection); connect(&vncThread, SIGNAL(outputErrorMessage(QString)), this, SLOT(outputErrorMessage(QString))); m_clipboard = QApplication::clipboard(); connect(m_clipboard, SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); #ifndef QTONLY m_hostPreferences = new VncHostPreferences(configGroup, this); #else Q_UNUSED(configGroup); #endif }
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(); }
DictionaryTextEdit::DictionaryTextEdit(QWidget *parent) : QTextEdit(parent), m_copyImage(false) { XmlBasedSettings::loadXmlBasedSettings(); initActions(); //setContextMenuPolicy(Qt::ActionsContextMenu); connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); }
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); }
void CoreEditingPlugin::updateEditingActions() { // Update our editing actions if (mEditingInterface) { bool editorAndHasSelectedText = mEditor && mEditor->hasSelectedText(); bool fileReadableOrWritable = Core::FileManager::instance()->isReadableAndWritable(mFileName); mEditCutAction->setEnabled(editorAndHasSelectedText && fileReadableOrWritable); mEditCopyAction->setEnabled(editorAndHasSelectedText); clipboardDataChanged(); mEditDeleteAction->setEnabled(editorAndHasSelectedText && fileReadableOrWritable); } }
MyQTextEdit::MyQTextEdit(QWidget *parent):QTextEdit(parent) { this->setFontPointSize(10.0); this->setupFileActions(); this->setupEditActions(); this->setupTextActions(); connect(this, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)) , this, SLOT(currentCharFormatChanged(const QTextCharFormat &))); connect(this, SIGNAL(cursorPositionChanged()) , this, SLOT(cursorPositionChanged())); this->setFocus(); this->setCurrentFileName(QString()); this->fontChanged(this->font()); this->colorChanged(this->textColor()); this->alignmentChanged(this->alignment()); this->connectDocument(); this->setWindowModified(this->document()->isModified()); this->actionSaveAs->setEnabled(this->document()->isModified()); this->actionUndo->setEnabled(this->document()->isUndoAvailable()); this->actionRedo->setEnabled(this->document()->isRedoAvailable()); connect(actionUndo, SIGNAL(triggered()), this, SLOT(undo())); connect(actionRedo, SIGNAL(triggered()), this, SLOT(redo())); connect(actionSelectAll, SIGNAL(triggered()), this, SLOT(selectAll())); this->actionCut->setEnabled(false); this->actionCopy->setEnabled(false); this->actionDelete->setEnabled(false); connect(actionCut, SIGNAL(triggered()), this, SLOT(cut())); connect(actionCopy, SIGNAL(triggered()), this, SLOT(copy())); connect(actionPaste, SIGNAL(triggered()), this, SLOT(paste())); connect(actionDelete, SIGNAL(triggered()), this, SLOT(deleteSelectedText())); connect(this, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); connect(this, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); connect(this, SIGNAL(copyAvailable(bool)), actionDelete, SLOT(setEnabled(bool))); connect(QApplication::clipboard(), SIGNAL(dataChanged()), this , SLOT(clipboardDataChanged())); }
void DictionaryTextEdit::initActions() { copyAction = new QAction("&Copy", this); copyAction->setShortcut(QKeySequence::Copy); copyAction->setIcon(QIcon(":/Resources/Images/copy.png")); copyAction->setEnabled(false); connect(copyAction, SIGNAL(triggered()), this, SLOT(copy())); connect(this, SIGNAL(copyAvailable(bool)), copyAction, SLOT(setEnabled(bool))); addAction(copyAction); _editActionsList.push_back(copyAction); cutAction = new QAction("C&ut", this); cutAction->setShortcut(QKeySequence::Cut); cutAction->setIcon(QIcon(":/Resources/Images/cut.png")); cutAction->setEnabled(false); connect(cutAction, SIGNAL(triggered()), this, SLOT(cut())); connect(this, SIGNAL(copyAvailable(bool)), cutAction, SLOT(setEnabled(bool))); addAction((cutAction)); _editActionsList.push_back(cutAction); pasteAction = new QAction("&Paste", this); pasteAction->setShortcut(QKeySequence::Paste); pasteAction->setIcon(QIcon(":/Resources/Images/paste.png")); clipboardDataChanged(); connect(pasteAction, SIGNAL(triggered()), this, SLOT(paste())); _editActionsList.push_back(pasteAction); zoomInAction = new QAction("Zoom In", this); zoomInAction->setShortcut(QKeySequence::ZoomIn); zoomInAction->setIcon(QIcon(":/Resources/Images/zoom_in.png")); connect(zoomInAction, SIGNAL(triggered()), this, SLOT(zoomIn())); _fontActionsList.push_back(zoomInAction); zoomOutAction = new QAction("Zoom Out", this); zoomOutAction->setShortcut(QKeySequence::ZoomOut); zoomOutAction->setIcon(QIcon(":/Resources/Images/zoom_out.png")); connect(zoomOutAction, SIGNAL(triggered()), this, SLOT(zoomOut())); _fontActionsList.push_back(zoomOutAction); defaultSizeAction = new QAction("Default Size", this); defaultSizeAction->setShortcut(QKeySequence("Ctrl+0")); defaultSizeAction->setIcon(QIcon(":/Resources/Images/search.png")); _fontActionsList.push_back(defaultSizeAction); }
pEditor::pEditor( QWidget* p ) : QsciScintilla( p ) { const QSize mPixSize = QSize( 16, 16 ); // register image for bookmarks markerDefine( QPixmap( ":/editor/bookmark.png" ).scaled( mPixSize ), mdBookmark ); // deal with utf8 setUtf8( true ); // connection connect( this, SIGNAL( linesChanged() ), this, SLOT( linesChanged() ) ); connect( this, SIGNAL( copyAvailable( bool ) ), this, SLOT( setCopyAvailable( bool ) ) ); connect( this, SIGNAL( cursorPositionChanged( int, int ) ), this, SLOT( cursorPositionChanged( int, int ) ) ); connect( this, SIGNAL( textChanged() ), this, SLOT( textChanged() ) ); connect( QApplication::clipboard(), SIGNAL( dataChanged() ), this, SLOT( clipboardDataChanged() ) ); // init pasteAvailable if ( !mPasteAvailableInit ) { mPasteAvailableInit = true; mPasteAvailable = !QApplication::clipboard()->text().isEmpty(); } // init qscishortcutsmanager if needed standardCommands()->clearKeys(); standardCommands()->clearAlternateKeys(); SendScintilla( QsciScintillaBase::SCI_ASSIGNCMDKEY, SCK_TAB, SCI_TAB); SendScintilla( QsciScintillaBase::SCI_ASSIGNCMDKEY, SCK_ESCAPE, SCI_CANCEL); SendScintilla( QsciScintillaBase::SCI_ASSIGNCMDKEY, SCK_RETURN, SCI_NEWLINE); SendScintilla( QsciScintillaBase::SCI_ASSIGNCMDKEY, SCK_DOWN, SCI_LINEDOWN); SendScintilla( QsciScintillaBase::SCI_ASSIGNCMDKEY, SCK_UP, SCI_LINEUP); SendScintilla( QsciScintillaBase::SCI_ASSIGNCMDKEY, SCK_RIGHT, SCI_CHARRIGHT); SendScintilla( QsciScintillaBase::SCI_ASSIGNCMDKEY, SCK_LEFT, SCI_CHARLEFT); SendScintilla( QsciScintillaBase::SCI_ASSIGNCMDKEY, SCK_BACK, SCI_DELETEBACK); SendScintilla( QsciScintillaBase::SCI_ASSIGNCMDKEY, SCK_PRIOR, SCI_PAGEUP); SendScintilla( QsciScintillaBase::SCI_ASSIGNCMDKEY, SCK_NEXT, SCI_PAGEDOWN); SendScintilla( QsciScintillaBase::SCI_ASSIGNCMDKEY, SCK_HOME, SCI_VCHOME); SendScintilla( QsciScintillaBase::SCI_ASSIGNCMDKEY, SCK_END, SCI_LINEEND); // Create shortcuts manager, if not created qSciShortcutsManager::instance(); }
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(); }
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(); }
LipstickCompositor::LipstickCompositor() : QWaylandQuickCompositor(this, 0, (QWaylandCompositor::ExtensionFlags)QWaylandCompositor::DefaultExtensions & ~QWaylandCompositor::QtKeyExtension) , m_totalWindowCount(0) , m_nextWindowId(1) , m_homeActive(true) , m_shaderEffect(0) , m_fullscreenSurface(0) , m_directRenderingActive(false) , m_topmostWindowId(0) , m_topmostWindowProcessId(0) , m_screenOrientation(Qt::PrimaryOrientation) , m_sensorOrientation(Qt::PrimaryOrientation) , m_displayState(0) , m_retainedSelection(0) , m_currentDisplayState(MeeGo::QmDisplayState::Unknown) , m_updatesEnabled(true) , m_completed(false) , m_onUpdatesDisabledUnfocusedWindowId(0) , m_keymap(0) , m_fakeRepaintTriggered(false) { setColor(Qt::black); setRetainedSelectionEnabled(true); addDefaultShell(); if (m_instance) qFatal("LipstickCompositor: Only one compositor instance per process is supported"); m_instance = this; m_orientationLock = new MGConfItem("/lipstick/orientationLock", this); connect(m_orientationLock, SIGNAL(valueChanged()), SIGNAL(orientationLockChanged())); // Load legacy settings from the config file and delete it from there QSettings legacySettings("nemomobile", "lipstick"); QString legacyOrientationKey("Compositor/orientationLock"); if (legacySettings.contains(legacyOrientationKey)) { m_orientationLock->set(legacySettings.value(legacyOrientationKey)); legacySettings.remove(legacyOrientationKey); } connect(this, SIGNAL(visibleChanged(bool)), this, SLOT(onVisibleChanged(bool))); QObject::connect(this, SIGNAL(afterRendering()), this, SLOT(windowSwapped())); QObject::connect(HomeApplication::instance(), SIGNAL(aboutToDestroy()), this, SLOT(homeApplicationAboutToDestroy())); connect(this, &QQuickWindow::afterRendering, this, &LipstickCompositor::readContent, Qt::DirectConnection); m_orientationSensor = new QOrientationSensor(this); QObject::connect(m_orientationSensor, SIGNAL(readingChanged()), this, SLOT(setScreenOrientationFromSensor())); if (!m_orientationSensor->connectToBackend()) { qWarning() << "Could not connect to the orientation sensor backend"; } else { if (!m_orientationSensor->start()) qWarning() << "Could not start the orientation sensor"; } emit HomeApplication::instance()->homeActiveChanged(); QDesktopServices::setUrlHandler("http", this, "openUrl"); QDesktopServices::setUrlHandler("https", this, "openUrl"); QDesktopServices::setUrlHandler("mailto", this, "openUrl"); connect(QGuiApplication::clipboard(), SIGNAL(dataChanged()), SLOT(clipboardDataChanged())); m_recorder = new LipstickRecorderManager; addGlobalInterface(m_recorder); addGlobalInterface(new AlienManagerGlobal); HwcRenderStage::initialize(this); setUpdatesEnabled(false); QTimer::singleShot(0, this, SLOT(initialize())); }
/** 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(); }
BrailleMusicEditor::BrailleMusicEditor(QWidget *parent) : QMainWindow(parent), ok(this), fail(this), lilypond(this) { #ifdef Q_OS_OSX setUnifiedTitleAndToolBarOnMac(true); #endif setToolButtonStyle(Qt::ToolButtonFollowStyle); setupFileActions(); setupEditActions(); setupOptionsActions(); setupSoundEffects(); { auto helpMenu = new QMenu(tr("Help"), this); menuBar()->addMenu(helpMenu); helpMenu->addAction(tr("About"), this, SLOT(about())); helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt())); helpMenu->addAction(tr("&Report a problem..."), this, SLOT(reportBug())); } textEdit = new QTextEdit(this); textEdit->setWordWrapMode(QTextOption::NoWrap); connect(textEdit, &QTextEdit::cursorPositionChanged, this, &BrailleMusicEditor::cursorPositionChanged); connect(textEdit, &QTextEdit::textChanged, this, &BrailleMusicEditor::textChanged); svgScrollArea = new QScrollArea(this); svgScrollArea->setFocusPolicy(Qt::NoFocus); auto splitter = new QSplitter(Qt::Vertical); splitter->addWidget(textEdit); splitter->addWidget(svgScrollArea); QSettings settings; if (settings.value("ui/persist_layout",1).toInt() && settings.contains("ui/layout_data")) { splitter->restoreState(settings.value("ui/layout_data").toByteArray()); } else { splitter->setStretchFactor(0, 1); splitter->setStretchFactor(1, 1); } setCentralWidget(splitter); textEdit->setFocus(); setCurrentFileName(QString()); QFont textFont("Helvetica"); textFont.setStyleHint(QFont::SansSerif); textEdit->setFont(textFont); fontChanged(textEdit->font()); colorChanged(textEdit->textColor()); connect(textEdit->document(), &QTextDocument::modificationChanged, actionSave, &QAction::setEnabled); connect(textEdit->document(), &QTextDocument::modificationChanged, this, &BrailleMusicEditor::setWindowModified); connect(textEdit->document(), &QTextDocument::undoAvailable, actionUndo, &QAction::setEnabled); connect(textEdit->document(), &QTextDocument::redoAvailable, actionRedo, &QAction::setEnabled); setWindowModified(textEdit->document()->isModified()); actionSave->setEnabled(textEdit->document()->isModified()); actionUndo->setEnabled(textEdit->document()->isUndoAvailable()); actionRedo->setEnabled(textEdit->document()->isRedoAvailable()); connect(actionUndo, &QAction::triggered, textEdit, &QTextEdit::undo); connect(actionRedo, &QAction::triggered, textEdit, &QTextEdit::redo); actionCut->setEnabled(false); actionCopy->setEnabled(false); connect(actionCut, &QAction::triggered, textEdit, &QTextEdit::cut); connect(actionCopy, &QAction::triggered, textEdit, &QTextEdit::copy); connect(actionPaste, &QAction::triggered, textEdit, &QTextEdit::paste); connect(textEdit, &QTextEdit::copyAvailable, actionCut, &QAction::setEnabled); connect(textEdit, &QTextEdit::copyAvailable, actionCopy, &QAction::setEnabled); #ifndef QT_NO_CLIPBOARD connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); #endif connect(&lilypond, &QProcess::started, this, &BrailleMusicEditor::lilyPondStarted); connect(&lilypond, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)> (&QProcess::finished), this, &BrailleMusicEditor::lilyPondFinished); connect(&lilypond, static_cast<void (QProcess::*)(QProcess::ProcessError)> (&QProcess::error), this, &BrailleMusicEditor::lilyPondError); QString initialFile = ":/examples/bwv988-v01.bmc"; const QStringList args = QCoreApplication::arguments(); if (args.count() == 2) initialFile = args.at(1); if (!load(initialFile)) fileNew(); }
KillRing::KillRing() : currentView(0), iter(ring.begin()), ignore(false) { connect(QApplication::clipboard(), SIGNAL(dataChanged()), SLOT(clipboardDataChanged())); }
// --------------------------------------------------------------------------- TextEdit::TextEdit(QWidget * parent) : QMainWindow(parent, Qt::Dialog) { setWindowModality (Qt::ApplicationModal); setupFileActions(); setupEditActions(); { QMenu *helpMenu = new QMenu(tr("Help"), this); menuBar()->addMenu(helpMenu); helpMenu->addAction(tr("About"), this, SLOT(about())); } textEdit = new QPlainTextEdit(this); // textEdit->setLineWrapMode(QTextEdit::NoWrap); connect(textEdit, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), this, SLOT(currentCharFormatChanged(const QTextCharFormat &))); connect(textEdit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); setCentralWidget(textEdit); textEdit->setFocus(); setCurrentFileName(QString()); 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))); 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); if (!load(initialFile)) fileNew(); }
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()); }
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(); }
RichTextEdit::RichTextEdit(QWidget *parent) : QWidget(parent) { layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); toolbar = new QToolBar; setupActions(); layout->addWidget(toolbar); fontToolbar = new QToolBar; setupFontActions(); layout->addWidget(fontToolbar); textedit = new QTextEdit; textedit->setTabStopWidth(40); layout->addWidget(textedit); findWidget = new TextFind(this); findWidget->hide(); layout->addWidget(findWidget); setLayout(layout); // find connect(actionFind, SIGNAL(triggered()), findWidget, SLOT(show())); connect(findWidget->getNextBtn(), SIGNAL(clicked()), this, SLOT(findNext())); connect(findWidget->getPrevBtn(), SIGNAL(clicked()), this, SLOT(findPrev())); connect(findWidget->getFindEdit(), SIGNAL(textChanged(const QString&)), this, SLOT(findFirst())); // save connect(actionSave, SIGNAL(triggered()), this, SLOT(saveContent())); // alignment alignmentChanged(textedit->alignment()); connect(textedit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); // color & font connect(textedit, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), this, SLOT(currentCharFormatChanged(const QTextCharFormat &))); colorChanged(textedit->textColor()); fontChanged(textedit->font()); // undo & redo 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())); // cut, copy, paste 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())); }
void KoPAView::initActions() { KAction *action = actionCollection()->addAction( KStandardAction::Cut, "edit_cut", 0, 0); new KoCutController(kopaCanvas(), action); action = actionCollection()->addAction( KStandardAction::Copy, "edit_copy", 0, 0 ); new KoCopyController(kopaCanvas(), action); d->editPaste = actionCollection()->addAction( KStandardAction::Paste, "edit_paste", proxyObject, SLOT( editPaste() ) ); connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); connect(d->canvas->toolProxy(), SIGNAL(toolChanged(const QString&)), this, SLOT(clipboardDataChanged())); clipboardDataChanged(); actionCollection()->addAction(KStandardAction::SelectAll, "edit_select_all", this, SLOT(editSelectAll())); actionCollection()->addAction(KStandardAction::Deselect, "edit_deselect_all", this, SLOT(editDeselectAll())); d->deleteSelectionAction = new KAction(KIcon("edit-delete"), i18n("D&elete"), this); actionCollection()->addAction("edit_delete", d->deleteSelectionAction ); d->deleteSelectionAction->setShortcut(QKeySequence("Del")); d->deleteSelectionAction->setEnabled(false); connect(d->deleteSelectionAction, SIGNAL(triggered()), this, SLOT(editDeleteSelection())); connect(d->canvas->toolProxy(), SIGNAL(selectionChanged(bool)), d->deleteSelectionAction, SLOT(setEnabled(bool))); KToggleAction *showGrid= d->doc->gridData().gridToggleAction(d->canvas); actionCollection()->addAction("view_grid", showGrid ); d->actionViewSnapToGrid = new KToggleAction(i18n("Snap to Grid"), this); d->actionViewSnapToGrid->setChecked(d->doc->gridData().snapToGrid()); actionCollection()->addAction("view_snaptogrid", d->actionViewSnapToGrid); connect( d->actionViewSnapToGrid, SIGNAL( triggered( bool ) ), this, SLOT (viewSnapToGrid( bool ))); KToggleAction *actionViewShowGuides = KoStandardAction::showGuides(this, SLOT(viewGuides(bool)), this); actionViewShowGuides->setChecked( d->doc->guidesData().showGuideLines() ); actionCollection()->addAction(KoStandardAction::name(KoStandardAction::ShowGuides), actionViewShowGuides ); d->actionViewShowMasterPages = new KToggleAction(i18n( "Show Master Pages" ), this ); actionCollection()->addAction( "view_masterpages", d->actionViewShowMasterPages ); connect( d->actionViewShowMasterPages, SIGNAL( triggered( bool ) ), this, SLOT( setMasterMode( bool ) ) ); d->viewRulers = new KToggleAction(i18n("Show Rulers"), this); actionCollection()->addAction("view_rulers", d->viewRulers ); d->viewRulers->setToolTip(i18n("Show/hide the view's rulers")); connect(d->viewRulers, SIGNAL(triggered(bool)), proxyObject, SLOT(setShowRulers(bool))); setShowRulers(d->doc->rulersVisible()); d->actionInsertPage = new KAction( KIcon("document-new"), i18n( "Insert Page" ), this ); actionCollection()->addAction( "page_insertpage", d->actionInsertPage ); d->actionInsertPage->setToolTip( i18n( "Insert a new page after the current one" ) ); d->actionInsertPage->setWhatsThis( i18n( "Insert a new page after the current one" ) ); connect( d->actionInsertPage, SIGNAL( triggered() ), proxyObject, SLOT( insertPage() ) ); d->actionCopyPage = new KAction( i18n( "Copy Page" ), this ); actionCollection()->addAction( "page_copypage", d->actionCopyPage ); d->actionCopyPage->setToolTip( i18n( "Copy the current page" ) ); d->actionCopyPage->setWhatsThis( i18n( "Copy the current page" ) ); connect( d->actionCopyPage, SIGNAL( triggered() ), this, SLOT( copyPage() ) ); d->actionDeletePage = new KAction( i18n( "Delete Page" ), this ); d->actionDeletePage->setEnabled( d->doc->pageCount() > 1 ); actionCollection()->addAction( "page_deletepage", d->actionDeletePage ); d->actionDeletePage->setToolTip( i18n( "Delete the current page" ) ); d->actionDeletePage->setWhatsThis( i18n( "Delete the current page" ) ); connect( d->actionDeletePage, SIGNAL( triggered() ), this, SLOT( deletePage() ) ); d->actionMasterPage = new KAction(i18n("Master Page..."), this); actionCollection()->addAction("format_masterpage", d->actionMasterPage); connect(d->actionMasterPage, SIGNAL(triggered()), this, SLOT(formatMasterPage())); d->actionPageLayout = new KAction( i18n( "Page Layout..." ), this ); actionCollection()->addAction( "format_pagelayout", d->actionPageLayout ); connect( d->actionPageLayout, SIGNAL( triggered() ), this, SLOT( formatPageLayout() ) ); actionCollection()->addAction(KStandardAction::Prior, "page_previous", this, SLOT(goToPreviousPage())); actionCollection()->addAction(KStandardAction::Next, "page_next", this, SLOT(goToNextPage())); actionCollection()->addAction(KStandardAction::FirstPage, "page_first", this, SLOT(goToFirstPage())); actionCollection()->addAction(KStandardAction::LastPage, "page_last", this, SLOT(goToLastPage())); KActionMenu *actionMenu = new KActionMenu(i18n("Variable"), this); foreach(QAction *action, d->doc->inlineTextObjectManager()->createInsertVariableActions(d->canvas)) actionMenu->addAction(action); actionCollection()->addAction("insert_variable", actionMenu); KAction * am = new KAction(i18n("Import Document..."), this); actionCollection()->addAction("import_document", am); connect(am, SIGNAL(triggered()), this, SLOT(importDocument())); d->actionConfigure = new KAction(KIcon("configure"), i18n("Configure..."), this); actionCollection()->addAction("configure", d->actionConfigure); connect(d->actionConfigure, SIGNAL(triggered()), this, SLOT(configure())); d->find = new KoFind( this, d->canvas->resourceManager(), actionCollection() ); actionCollection()->action( "object_group" )->setShortcut( QKeySequence( "Ctrl+G" ) ); actionCollection()->action( "object_ungroup" )->setShortcut( QKeySequence( "Ctrl+Shift+G" ) ); }
void CoreEditingPlugin::initializePlugin(QMainWindow *pMainWindow) { // Create our different File|New actions mFileNewFileAction = Core::newAction(QIcon(":/oxygen/actions/document-new.png"), QKeySequence::New, pMainWindow); // Create our Edit menu mEditMenu = Core::newMenu("Edit", pMainWindow); // Create our different Edit actions, and add them to our Edit menu mEditUndoAction = Core::newAction(QIcon(":/oxygen/actions/edit-undo.png"), QKeySequence::Undo, pMainWindow); mEditRedoAction = Core::newAction(QIcon(":/oxygen/actions/edit-redo.png"), QKeySequence::Redo, pMainWindow); mEditCutAction = Core::newAction(QIcon(":/oxygen/actions/edit-cut.png"), QKeySequence::Cut, pMainWindow); mEditCopyAction = Core::newAction(QIcon(":/oxygen/actions/edit-copy.png"), QKeySequence::Copy, pMainWindow); mEditPasteAction = Core::newAction(QIcon(":/oxygen/actions/edit-paste.png"), QKeySequence::Paste, pMainWindow); mEditDeleteAction = Core::newAction(QIcon(":/oxygen/actions/edit-delete.png"), QKeySequence::Delete, pMainWindow); mEditFindReplaceAction = Core::newAction(QIcon(":/oxygen/actions/edit-find.png"), QKeySequence::Find, pMainWindow); mEditFindNextAction = Core::newAction(QKeySequence::FindNext, pMainWindow); mEditFindPreviousAction = Core::newAction(QKeySequence::FindPrevious, pMainWindow); mEditSelectAllAction = Core::newAction(QKeySequence::SelectAll, pMainWindow); populateEditMenu(); // Keep track of changes to the clipboard connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); // Some connections to handle our different editing actions connect(mFileNewFileAction, SIGNAL(triggered(bool)), this, SLOT(newFile())); connect(mEditUndoAction, SIGNAL(triggered(bool)), this, SLOT(doUndo())); connect(mEditRedoAction, SIGNAL(triggered(bool)), this, SLOT(doRedo())); connect(mEditCutAction, SIGNAL(triggered(bool)), this, SLOT(doCut())); connect(mEditCopyAction, SIGNAL(triggered(bool)), this, SLOT(doCopy())); connect(mEditPasteAction, SIGNAL(triggered(bool)), this, SLOT(doPaste())); connect(mEditDeleteAction, SIGNAL(triggered(bool)), this, SLOT(doDelete())); connect(mEditFindReplaceAction, SIGNAL(triggered(bool)), this, SLOT(doFindReplace())); connect(mEditFindNextAction, SIGNAL(triggered(bool)), this, SLOT(doFindNext())); connect(mEditFindPreviousAction, SIGNAL(triggered(bool)), this, SLOT(doFindPrevious())); connect(mEditSelectAllAction, SIGNAL(triggered(bool)), this, SLOT(doSelectAll())); }