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

📄 tool_widgeteditor.cpp

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 CPP
字号:
/******************************************************************************** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.**** This file is part of the Qt Designer of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file.  Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://www.trolltech.com/products/qt/opensource.html**** If you are unsure which license is appropriate for your use, please** review the following information:** http://www.trolltech.com/products/qt/licensing.html or contact the** sales department at sales@trolltech.com.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#include "tool_widgeteditor.h"#include "formwindow.h"// sdk#include <QtDesigner/QtDesigner>#include <layoutinfo_p.h>#include <QtGui/qevent.h>#include <QtGui/QAction>#include <QtCore/qdebug.h>using namespace qdesigner_internal;WidgetEditorTool::WidgetEditorTool(FormWindow *formWindow)    : QDesignerFormWindowToolInterface(formWindow),      m_formWindow(formWindow){    m_action = new QAction(tr("Edit Widgets"), this);}QAction *WidgetEditorTool::action() const{    return m_action;}WidgetEditorTool::~WidgetEditorTool(){}QDesignerFormEditorInterface *WidgetEditorTool::core() const{    return m_formWindow->core();}QDesignerFormWindowInterface *WidgetEditorTool::formWindow() const{    return m_formWindow;}bool WidgetEditorTool::handleEvent(QWidget *widget, QWidget *managedWidget, QEvent *event){    bool passive = core()->widgetFactory()->isPassiveInteractor(widget) != 0;    switch (event->type()) {    case QEvent::Resize:    case QEvent::Move:        m_formWindow->updateSelection(widget);        if (event->type() != QEvent::Resize)            m_formWindow->updateChildSelections(widget);        break;    case QEvent::FocusOut:    case QEvent::FocusIn:        return !(passive || widget == m_formWindow);    case QEvent::KeyPress:        return !passive && handleKeyPressEvent(widget, managedWidget, static_cast<QKeyEvent*>(event));    case QEvent::KeyRelease:        return !passive && handleKeyReleaseEvent(widget, managedWidget, static_cast<QKeyEvent*>(event));    case QEvent::MouseMove:        return !passive && handleMouseMoveEvent(widget, managedWidget, static_cast<QMouseEvent*>(event));    case QEvent::MouseButtonPress:        return !passive && handleMousePressEvent(widget, managedWidget, static_cast<QMouseEvent*>(event));    case QEvent::MouseButtonRelease:        return !passive && handleMouseReleaseEvent(widget, managedWidget, static_cast<QMouseEvent*>(event));    case QEvent::MouseButtonDblClick:        return !passive && handleMouseButtonDblClickEvent(widget, managedWidget, static_cast<QMouseEvent*>(event));    case QEvent::ContextMenu:        return !passive && handleContextMenu(widget, managedWidget, static_cast<QContextMenuEvent*>(event));    default: break;    } // end switch    return false;}// ### remove mebool WidgetEditorTool::handleContextMenu(QWidget *widget, QWidget *managedWidget, QContextMenuEvent *e){    return m_formWindow->handleContextMenu(widget, managedWidget, e);}bool WidgetEditorTool::handleMouseButtonDblClickEvent(QWidget *widget, QWidget *managedWidget, QMouseEvent *e){    return m_formWindow->handleMouseButtonDblClickEvent(widget, managedWidget, e);}bool WidgetEditorTool::handleMousePressEvent(QWidget *widget, QWidget *managedWidget, QMouseEvent *e){    return m_formWindow->handleMousePressEvent(widget, managedWidget, e);}bool WidgetEditorTool::handleMouseMoveEvent(QWidget *widget, QWidget *managedWidget, QMouseEvent *e){    return m_formWindow->handleMouseMoveEvent(widget, managedWidget, e);}bool WidgetEditorTool::handleMouseReleaseEvent(QWidget *widget, QWidget *managedWidget, QMouseEvent *e){    return m_formWindow->handleMouseReleaseEvent(widget, managedWidget, e);}bool WidgetEditorTool::handleKeyPressEvent(QWidget *widget, QWidget *managedWidget, QKeyEvent *e){    return m_formWindow->handleKeyPressEvent(widget, managedWidget, e);}bool WidgetEditorTool::handleKeyReleaseEvent(QWidget *widget, QWidget *managedWidget, QKeyEvent *e){    return m_formWindow->handleKeyReleaseEvent(widget, managedWidget, e);}bool WidgetEditorTool::handlePaintEvent(QWidget *widget, QWidget *managedWidget, QPaintEvent *e){    Q_UNUSED(widget);    Q_UNUSED(managedWidget);    Q_UNUSED(e);    return false;}QWidget *WidgetEditorTool::editor() const{    Q_ASSERT(formWindow() != 0);    return formWindow()->mainContainer();}void WidgetEditorTool::activated(){    if (core()->widgetBox())        core()->widgetBox()->setEnabled(true);    if (m_formWindow == 0)        return;    QList<QWidget*> sel = m_formWindow->selectedWidgets();    foreach (QWidget *w, sel)        m_formWindow->raiseSelection(w);}void WidgetEditorTool::deactivated(){    if (core()->widgetBox())        core()->widgetBox()->setEnabled(false);    if (m_formWindow == 0)        return;    m_formWindow->clearSelection();}

⌨️ 快捷键说明

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