⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qdesigner_actions.cpp

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    connect(m_widgetHelp, SIGNAL(triggered()), this, SLOT(showWidgetSpecificHelp()));    m_helpActions->addAction(m_widgetHelp);    sep = new QAction(this);    sep->setSeparator(true);    m_helpActions->addAction(sep);    m_whatsNewAction = new QAction(tr("What's New in Qt Designer?"), this);    connect(m_whatsNewAction, SIGNAL(triggered()), this, SLOT(showWhatsNew()));    m_helpActions->addAction(m_whatsNewAction);    // On Mac OS X, the about items are merged in so this separator is redundant.#ifndef Q_WS_MAC    sep = new QAction(this);    sep->setSeparator(true);    m_helpActions->addAction(sep);    m_aboutPluginsAction = new QAction(tr("About Plugins"), this);#else    m_aboutPluginsAction = new QAction(tr("Plugin Information"), this);#endif    connect(m_aboutPluginsAction, SIGNAL(triggered()), this, SLOT(aboutPlugins()));    m_helpActions->addAction(m_aboutPluginsAction);    m_aboutDesignerAction = new QAction(tr("About Qt Designer"), this);    connect(m_aboutDesignerAction, SIGNAL(triggered()), this, SLOT(aboutDesigner()));    m_helpActions->addAction(m_aboutDesignerAction);    m_aboutQtAction = new QAction(tr("About Qt"), this);    connect(m_aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));    m_helpActions->addAction(m_aboutQtAction);//// connections//    fixActionContext();    activeFormWindowChanged(core()->formWindowManager()->activeFormWindow());}QDesignerActions::~QDesignerActions(){}QActionGroup *QDesignerActions::toolActions() const{ return m_toolActions; }QDesignerWorkbench *QDesignerActions::workbench() const{ return m_workbench; }QDesignerFormEditorInterface *QDesignerActions::core() const{ return m_core; }QActionGroup *QDesignerActions::fileActions() const{ return m_fileActions; }QActionGroup *QDesignerActions::editActions() const{ return m_editActions; }QActionGroup *QDesignerActions::formActions() const{ return m_formActions; }QActionGroup *QDesignerActions::windowActions() const{ return m_windowActions; }QActionGroup *QDesignerActions::helpActions() const{ return m_helpActions; }QActionGroup *QDesignerActions::styleActions() const{ return m_styleActions; }QAction *QDesignerActions::newFormAction() const{ return m_newFormAction; }QAction *QDesignerActions::openFormAction() const{ return m_openFormAction; }QAction *QDesignerActions::saveFormAction() const{ return m_saveFormAction; }QAction *QDesignerActions::saveFormAsAction() const{ return m_saveFormAsAction; }QAction *QDesignerActions::saveFormAsTemplateAction() const{ return m_saveFormAsTemplateAction; }QAction *QDesignerActions::closeFormAction() const{ return m_closeFormAction; }QAction *QDesignerActions::quitAction() const{ return m_quitAction; }QAction *QDesignerActions::undoAction() const{ return m_undoAction; }QAction *QDesignerActions::redoAction() const{ return m_redoAction; }QAction *QDesignerActions::cutAction() const{ return m_cutAction; }QAction *QDesignerActions::copyAction() const{ return m_copyAction; }QAction *QDesignerActions::pasteAction() const{ return m_pasteAction; }QAction *QDesignerActions::selectAllAction() const{ return m_selectAllAction; }QAction *QDesignerActions::deleteAction() const{ return m_deleteAction; }QAction *QDesignerActions::sendToBackAction() const{ return m_sendToBackAction; }QAction *QDesignerActions::bringToFrontAction() const{ return m_bringToFrontAction; }QAction *QDesignerActions::mainHelpAction() const{ return m_mainHelpAction; }QAction *QDesignerActions::whatsNewAction() const{ return m_whatsNewAction; }QAction *QDesignerActions::aboutQtAction() const{ return m_aboutQtAction; }QAction *QDesignerActions::aboutDesignerAction() const{ return m_aboutDesignerAction; }QAction *QDesignerActions::layoutHorizontallyAction() const{ return m_layoutHorizontallyAction; }QAction *QDesignerActions::layoutVerticallyAction() const{ return m_layoutVerticallyAction; }QAction *QDesignerActions::layoutHorizontallyInSplitterAction() const{ return m_layoutHorizontallyInSplitterAction; }QAction *QDesignerActions::layoutVerticallyInSplitterAction() const{ return m_layoutVerticallyInSplitterAction; }QAction *QDesignerActions::layoutGridAction() const{ return m_layoutGridAction; }QAction *QDesignerActions::breakLayoutAction() const{ return m_breakLayoutAction; }QAction *QDesignerActions::adjustSizeAction() const{ return m_adjustSizeAction; }QAction *QDesignerActions::previewFormAction() const{ return m_previewFormAction; }QAction *QDesignerActions::formSettings() const{ return m_formSettings; }void QDesignerActions::editWidgetsSlot(){    QDesignerFormWindowManagerInterface *formWindowManager = core()->formWindowManager();    for (int i=0; i<formWindowManager->formWindowCount(); ++i) {        QDesignerFormWindowInterface *formWindow = formWindowManager->formWindow(i);        formWindow->editWidgets();    }}void QDesignerActions::createForm(){    NewForm *dlg = new NewForm(workbench(), 0);    dlg->setAttribute(Qt::WA_DeleteOnClose);    dlg->setAttribute(Qt::WA_ShowModal);    dlg->show();}bool QDesignerActions::openForm(){    QString fileName = QFileDialog::getOpenFileName(            core()->topLevel(),            tr("Open Form"), m_openDirectory,            tr("Designer UI files (*.ui)"), 0, QFileDialog::DontUseSheet);    if (!fileName.isEmpty()) {        return readInForm(fileName);    }    return false;}bool QDesignerActions::saveFormAs(QDesignerFormWindowInterface *fw){    QString fileName = fw->fileName().isEmpty() ? QDir::current().absolutePath()            + QLatin1String("/untitled.ui") : fw->fileName();    QString saveFile = QFileDialog::getSaveFileName(fw, tr("Save form as"),            fileName,            tr("Designer UI files (*.ui)"));    if (saveFile.isEmpty())        return false;    if (QFileInfo(saveFile).suffix() != QLatin1String("ui"))        saveFile.append(QLatin1String(".ui"));    fw->setFileName(saveFile);    return writeOutForm(fw, saveFile);}void QDesignerActions::saveForm(){    if (QDesignerFormWindowInterface *fw = core()->formWindowManager()->activeFormWindow())        saveForm(fw);}bool QDesignerActions::saveForm(QDesignerFormWindowInterface *fw){    bool ret;    if (fw->fileName().isEmpty())        ret = saveFormAs(fw);    else        ret =  writeOutForm(fw, fw->fileName());    return ret;}void QDesignerActions::closeForm(){    if (QDesignerFormWindowInterface *fw = core()->formWindowManager()->activeFormWindow())        fw->parentWidget()->close();}void QDesignerActions::saveFormAs(){    if (QDesignerFormWindowInterface *fw = core()->formWindowManager()->activeFormWindow())        saveFormAs(fw);}void QDesignerActions::saveFormAsTemplate(){    if (QDesignerFormWindowInterface *fw = core()->formWindowManager()->activeFormWindow()) {        SaveFormAsTemplate dlg(fw, fw->window());        dlg.exec();    }}void QDesignerActions::notImplementedYet(){    QMessageBox::information(core()->topLevel(), tr("Designer"), tr("Feature not implemented yet!"));}void QDesignerActions::updateUIMode(QAction *act){    QDesignerWorkbench::UIMode mode = QDesignerWorkbench::TopLevelMode;    if (act == m_dockedMdiAction)        mode = QDesignerWorkbench::DockedMode;    QDesignerSettings settings;    settings.setUIMode(mode);    m_workbench->setUIMode(QDesignerWorkbench::UIMode(settings.uiMode()));}void QDesignerActions::previewFormLater(QAction *action){    qRegisterMetaType<QAction*>("QAction*");    QMetaObject::invokeMethod(this, "previewForm", Qt::QueuedConnection,                                Q_ARG(QAction*, action));}void QDesignerActions::previewForm(QAction *action){    if (QDesignerFormWindowInterface *fw = core()->formWindowManager()->activeFormWindow()) {        qdesigner_internal::QDesignerFormBuilder builder(core());        builder.setWorkingDirectory(fw->absoluteDir());        QByteArray bytes = fw->contents().toUtf8();        QBuffer buffer(&bytes);        QWidget *widget = builder.load(&buffer, 0);        Q_ASSERT(widget);        widget->setParent(fw->window(), Qt::Dialog);        widget->setWindowModality(Qt::ApplicationModal);        widget->setAttribute(Qt::WA_DeleteOnClose, true);        widget->move(fw->mapToGlobal(QPoint(0, 0)) + QPoint(10, 10));        QStyle *style = 0;        if (action != 0 && action->objectName().startsWith(QLatin1String("__qt_action_style_"))) {            QString styleName = action->objectName().mid(QString::fromUtf8("__qt_action_style_").count());            style = QStyleFactory::create(styleName);            if (style != 0) {                style->setParent(widget);                widget->setStyle(style);                widget->setPalette(style->standardPalette());                QList<QWidget*> lst = qFindChildren<QWidget*>(widget);                foreach (QWidget *w, lst) {                    if (w->windowType() == Qt::Popup)                        w->setPalette(style->standardPalette());                    w->setStyle(style);                }            }        }        widget->setWindowTitle(tr("%1 - [Preview]").arg(widget->windowTitle()));        widget->show();    }}void QDesignerActions::fixActionContext(){    QList<QAction*> actions;    actions += m_fileActions->actions();    actions += m_editActions->actions();    actions += m_toolActions->actions();    actions += m_formActions->actions();    actions += m_windowActions->actions();    actions += m_helpActions->actions();    foreach (QAction *a, actions) {        a->setShortcutContext(Qt::ApplicationShortcut);    }}bool QDesignerActions::readInForm(const QString &fileName){    // First make sure that we don't have this one open already.    QDesignerFormWindowManagerInterface *formWindowManager = core()->formWindowManager();    int totalWindows = formWindowManager->formWindowCount();    for (int i = 0; i < totalWindows; ++i) {        QDesignerFormWindowInterface *w = formWindowManager->formWindow(i);        if (w->fileName() == fileName) {            w->raise();            formWindowManager->setActiveFormWindow(w);            addRecentFile(fileName);            return true;        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -