彻底改版2.0
This commit is contained in:
52
third/designer/qdesigner/designer_enums.h
Normal file
52
third/designer/qdesigner/designer_enums.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Designer of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.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 the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef DESIGNERENUMS_H
|
||||
#define DESIGNERENUMS_H
|
||||
|
||||
enum UIMode
|
||||
{
|
||||
NeutralMode,
|
||||
TopLevelMode,
|
||||
DockedMode
|
||||
};
|
||||
|
||||
#endif // DESIGNERENUMS_H
|
||||
323
third/designer/qdesigner/qdesigner.cpp
Normal file
323
third/designer/qdesigner/qdesigner.cpp
Normal file
@@ -0,0 +1,323 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Designer of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.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 the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
// designer
|
||||
#include "qdesigner.h"
|
||||
#include "qdesigner_actions.h"
|
||||
#include "qdesigner_server.h"
|
||||
#include "qdesigner_settings.h"
|
||||
#include "qdesigner_workbench.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <qdesigner_propertysheet_p.h>
|
||||
|
||||
#include <QtGui/QFileOpenEvent>
|
||||
#include <QtGui/QCloseEvent>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QIcon>
|
||||
#include <QtGui/QErrorMessage>
|
||||
#include <QtCore/QMetaObject>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QLibraryInfo>
|
||||
#include <QtCore/QLocale>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtCore/QTranslator>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
#include <QtDesigner/QDesignerComponents>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
static const char *designerApplicationName = "Designer";
|
||||
static const char *designerWarningPrefix = "Designer: ";
|
||||
|
||||
static void designerMessageHandler(QtMsgType type, const char *msg)
|
||||
{
|
||||
// Only Designer warnings are displayed as box
|
||||
QDesigner *designerApp = qDesigner;
|
||||
if (type != QtWarningMsg || !designerApp || qstrncmp(designerWarningPrefix, msg, qstrlen(designerWarningPrefix))) {
|
||||
qInstallMsgHandler(0);
|
||||
qt_message_output(type, msg);
|
||||
qInstallMsgHandler (designerMessageHandler);
|
||||
return;
|
||||
}
|
||||
designerApp->showErrorMessage(msg);
|
||||
}
|
||||
|
||||
QDesigner::QDesigner(int &argc, char **argv)
|
||||
: QApplication(argc, argv),
|
||||
m_server(0),
|
||||
m_client(0),
|
||||
m_workbench(0), m_suppressNewFormShow(false)
|
||||
{
|
||||
setOrganizationName(QLatin1String("Trolltech"));
|
||||
setApplicationName(QLatin1String(designerApplicationName));
|
||||
QDesignerComponents::initializeResources();
|
||||
|
||||
initialize();
|
||||
}
|
||||
|
||||
QDesigner::~QDesigner()
|
||||
{
|
||||
if (m_workbench) {
|
||||
delete m_workbench;
|
||||
}
|
||||
if (m_server) {
|
||||
delete m_server;
|
||||
}
|
||||
if (m_client) {
|
||||
delete m_client;
|
||||
}
|
||||
}
|
||||
|
||||
void QDesigner::showErrorMessage(const char *message)
|
||||
{
|
||||
// strip the prefix
|
||||
const QString qMessage = QString::fromUtf8(message + qstrlen(designerWarningPrefix));
|
||||
// If there is no main window yet, just store the message.
|
||||
// The QErrorMessage would otherwise be hidden by the main window.
|
||||
if (m_mainWindow) {
|
||||
showErrorMessageBox(qMessage);
|
||||
} else {
|
||||
qInstallMsgHandler(0);
|
||||
qt_message_output(QtWarningMsg, message); // just in case we crash
|
||||
qInstallMsgHandler (designerMessageHandler);
|
||||
m_initializationErrors += qMessage;
|
||||
m_initializationErrors += QLatin1Char('\n');
|
||||
}
|
||||
}
|
||||
|
||||
void QDesigner::showErrorMessageBox(const QString &msg)
|
||||
{
|
||||
// Manually suppress consecutive messages.
|
||||
// This happens if for example sth is wrong with custom widget creation.
|
||||
// The same warning will be displayed by Widget box D&D and form Drop
|
||||
// while trying to create instance.
|
||||
if (m_errorMessageDialog && m_lastErrorMessage == msg) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_errorMessageDialog) {
|
||||
m_lastErrorMessage.clear();
|
||||
m_errorMessageDialog = new QErrorMessage(m_mainWindow);
|
||||
const QString title = QCoreApplication::translate("QDesigner", "%1 - warning").arg(QLatin1String(designerApplicationName));
|
||||
m_errorMessageDialog->setWindowTitle(title);
|
||||
m_errorMessageDialog->setMinimumSize(QSize(600, 250));
|
||||
m_errorMessageDialog->setWindowFlags(m_errorMessageDialog->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
}
|
||||
m_errorMessageDialog->showMessage(msg);
|
||||
m_lastErrorMessage = msg;
|
||||
}
|
||||
|
||||
QDesignerWorkbench *QDesigner::workbench() const
|
||||
{
|
||||
return m_workbench;
|
||||
}
|
||||
|
||||
QDesignerServer *QDesigner::server() const
|
||||
{
|
||||
return m_server;
|
||||
}
|
||||
|
||||
bool QDesigner::parseCommandLineArgs(QStringList &fileNames, QString &resourceDir)
|
||||
{
|
||||
const QStringList args = arguments();
|
||||
const QStringList::const_iterator acend = args.constEnd();
|
||||
QStringList::const_iterator it = args.constBegin();
|
||||
for (++it; it != acend; ++it) {
|
||||
const QString &argument = *it;
|
||||
do {
|
||||
// Arguments
|
||||
if (!argument.startsWith(QLatin1Char('-'))) {
|
||||
if (!fileNames.contains(argument)) {
|
||||
fileNames.append(argument);
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Options
|
||||
if (argument == QLatin1String("-server")) {
|
||||
m_server = new QDesignerServer();
|
||||
printf("%d\n", m_server->serverPort());
|
||||
fflush(stdout);
|
||||
break;
|
||||
}
|
||||
if (argument == QLatin1String("-client")) {
|
||||
bool ok = true;
|
||||
if (++it == acend) {
|
||||
qWarning("** WARNING The option -client requires an argument");
|
||||
return false;
|
||||
}
|
||||
const quint16 port = it->toUShort(&ok);
|
||||
if (ok) {
|
||||
m_client = new QDesignerClient(port, this);
|
||||
} else {
|
||||
qWarning("** WARNING Non-numeric argument specified for -client");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (argument == QLatin1String("-resourcedir")) {
|
||||
if (++it == acend) {
|
||||
qWarning("** WARNING The option -resourcedir requires an argument");
|
||||
return false;
|
||||
}
|
||||
resourceDir = QFile::decodeName(it->toLocal8Bit());
|
||||
break;
|
||||
}
|
||||
if (argument == QLatin1String("-enableinternaldynamicproperties")) {
|
||||
QDesignerPropertySheet::setInternalDynamicPropertiesEnabled(true);
|
||||
break;
|
||||
}
|
||||
const QString msg = QString::fromUtf8("** WARNING Unknown option %1").arg(argument);
|
||||
qWarning("%s", qPrintable(msg));
|
||||
} while (false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void QDesigner::initialize()
|
||||
{
|
||||
// initialize the sub components
|
||||
QStringList files;
|
||||
QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
|
||||
parseCommandLineArgs(files, resourceDir);
|
||||
|
||||
QTranslator *translator = new QTranslator(this);
|
||||
translator->load(":/trolltech/designer/images/designer_zh_CN.qm");
|
||||
this->installTranslator(translator);
|
||||
|
||||
if (QLibraryInfo::licensedProducts() == QLatin1String("Console")) {
|
||||
QMessageBox::information(0, tr("Qt Designer"),
|
||||
tr("This application cannot be used for the Console edition of Qt"));
|
||||
QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection);
|
||||
return;
|
||||
}
|
||||
|
||||
m_workbench = new QDesignerWorkbench();
|
||||
|
||||
emit initialized();
|
||||
qInstallMsgHandler(designerMessageHandler); // Warn when loading faulty forms
|
||||
|
||||
m_suppressNewFormShow = m_workbench->readInBackup();
|
||||
|
||||
if (!files.empty()) {
|
||||
const QStringList::const_iterator cend = files.constEnd();
|
||||
for (QStringList::const_iterator it = files.constBegin(); it != cend; ++it) {
|
||||
// Ensure absolute paths for recent file list to be unique
|
||||
QString fileName = *it;
|
||||
const QFileInfo fi(fileName);
|
||||
if (fi.exists() && fi.isRelative()) {
|
||||
fileName = fi.absoluteFilePath();
|
||||
}
|
||||
m_workbench->readInForm(fileName);
|
||||
}
|
||||
}
|
||||
if ( m_workbench->formWindowCount()) {
|
||||
m_suppressNewFormShow = true;
|
||||
}
|
||||
|
||||
// Show up error box with parent now if something went wrong
|
||||
if (m_initializationErrors.isEmpty()) {
|
||||
if (!m_suppressNewFormShow && QDesignerSettings(m_workbench->core()).showNewFormOnStartup()) {
|
||||
QTimer::singleShot(100, this, SLOT(callCreateForm())); // won't show anything if suppressed
|
||||
}
|
||||
} else {
|
||||
showErrorMessageBox(m_initializationErrors);
|
||||
m_initializationErrors.clear();
|
||||
}
|
||||
}
|
||||
|
||||
bool QDesigner::event(QEvent *ev)
|
||||
{
|
||||
bool eaten;
|
||||
switch (ev->type()) {
|
||||
case QEvent::FileOpen:
|
||||
// Set it true first since, if it's a Qt 3 form, the messagebox from convert will fire the timer.
|
||||
m_suppressNewFormShow = true;
|
||||
if (!m_workbench->readInForm(static_cast<QFileOpenEvent *>(ev)->file())) {
|
||||
m_suppressNewFormShow = false;
|
||||
}
|
||||
eaten = true;
|
||||
break;
|
||||
case QEvent::Close: {
|
||||
QCloseEvent *closeEvent = static_cast<QCloseEvent *>(ev);
|
||||
closeEvent->setAccepted(m_workbench->handleClose());
|
||||
if (closeEvent->isAccepted()) {
|
||||
// We're going down, make sure that we don't get our settings saved twice.
|
||||
if (m_mainWindow) {
|
||||
m_mainWindow->setCloseEventPolicy(MainWindowBase::AcceptCloseEvents);
|
||||
}
|
||||
eaten = QApplication::event(ev);
|
||||
}
|
||||
eaten = true;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
eaten = QApplication::event(ev);
|
||||
break;
|
||||
}
|
||||
return eaten;
|
||||
}
|
||||
|
||||
void QDesigner::setMainWindow(MainWindowBase *tw)
|
||||
{
|
||||
m_mainWindow = tw;
|
||||
}
|
||||
|
||||
MainWindowBase *QDesigner::mainWindow() const
|
||||
{
|
||||
return m_mainWindow;
|
||||
}
|
||||
|
||||
void QDesigner::callCreateForm()
|
||||
{
|
||||
if (!m_suppressNewFormShow) {
|
||||
QFile file("quc.ui");
|
||||
if (file.exists()) {
|
||||
m_workbench->actionManager()->readInForm("quc.ui");
|
||||
} else {
|
||||
m_workbench->actionManager()->createForm();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
102
third/designer/qdesigner/qdesigner.h
Normal file
102
third/designer/qdesigner/qdesigner.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Designer of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.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 the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDESIGNER_H
|
||||
#define QDESIGNER_H
|
||||
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtGui/QApplication>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#define qDesigner \
|
||||
(static_cast<QDesigner*>(QCoreApplication::instance()))
|
||||
|
||||
class QDesignerWorkbench;
|
||||
class QDesignerToolWindow;
|
||||
class MainWindowBase;
|
||||
class QDesignerServer;
|
||||
class QDesignerClient;
|
||||
class QErrorMessage;
|
||||
|
||||
class QDesigner: public QApplication
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDesigner(int &argc, char **argv);
|
||||
virtual ~QDesigner();
|
||||
|
||||
QDesignerWorkbench *workbench() const;
|
||||
QDesignerServer *server() const;
|
||||
MainWindowBase *mainWindow() const;
|
||||
void setMainWindow(MainWindowBase *tw);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *ev);
|
||||
|
||||
signals:
|
||||
void initialized();
|
||||
|
||||
public slots:
|
||||
void showErrorMessage(const char *message);
|
||||
|
||||
private slots:
|
||||
void initialize();
|
||||
void callCreateForm();
|
||||
|
||||
private:
|
||||
bool parseCommandLineArgs(QStringList &fileNames, QString &resourceDir);
|
||||
void showErrorMessageBox(const QString &);
|
||||
|
||||
QDesignerServer *m_server;
|
||||
QDesignerClient *m_client;
|
||||
QDesignerWorkbench *m_workbench;
|
||||
QPointer<MainWindowBase> m_mainWindow;
|
||||
QPointer<QErrorMessage> m_errorMessageDialog;
|
||||
|
||||
QString m_initializationErrors;
|
||||
QString m_lastErrorMessage;
|
||||
bool m_suppressNewFormShow;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QDESIGNER_H
|
||||
23
third/designer/qdesigner/qdesigner.pri
Normal file
23
third/designer/qdesigner/qdesigner.pri
Normal file
@@ -0,0 +1,23 @@
|
||||
FORMS += \
|
||||
$$PWD/qdesigner_appearanceoptions.ui
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/designer_enums.h \
|
||||
$$PWD/qdesigner.h \
|
||||
$$PWD/qdesigner_actions.h \
|
||||
$$PWD/qdesigner_appearanceoptions.h \
|
||||
$$PWD/qdesigner_formwindow.h \
|
||||
$$PWD/qdesigner_server.h \
|
||||
$$PWD/qdesigner_settings.h \
|
||||
$$PWD/qdesigner_toolwindow.h \
|
||||
$$PWD/qdesigner_workbench.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/qdesigner.cpp \
|
||||
$$PWD/qdesigner_actions.cpp \
|
||||
$$PWD/qdesigner_appearanceoptions.cpp \
|
||||
$$PWD/qdesigner_formwindow.cpp \
|
||||
$$PWD/qdesigner_server.cpp \
|
||||
$$PWD/qdesigner_settings.cpp \
|
||||
$$PWD/qdesigner_toolwindow.cpp \
|
||||
$$PWD/qdesigner_workbench.cpp
|
||||
1437
third/designer/qdesigner/qdesigner_actions.cpp
Normal file
1437
third/designer/qdesigner/qdesigner_actions.cpp
Normal file
File diff suppressed because it is too large
Load Diff
231
third/designer/qdesigner/qdesigner_actions.h
Normal file
231
third/designer/qdesigner/qdesigner_actions.h
Normal file
@@ -0,0 +1,231 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Designer of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.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 the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDESIGNER_ACTIONS_H
|
||||
#define QDESIGNER_ACTIONS_H
|
||||
|
||||
#include "assistantclient.h"
|
||||
#include "qdesigner_settings.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtGui/QPrinter>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerWorkbench;
|
||||
|
||||
class QDir;
|
||||
class QTimer;
|
||||
class QAction;
|
||||
class QActionGroup;
|
||||
class QDesignerFormEditorInterface;
|
||||
class QDesignerFormWindowInterface;
|
||||
class AppFontDialog;
|
||||
|
||||
class QRect;
|
||||
class QWidget;
|
||||
class QPixmap;
|
||||
class QMenu;
|
||||
|
||||
namespace qdesigner_internal {
|
||||
class PreviewConfiguration;
|
||||
class PreviewManager;
|
||||
}
|
||||
|
||||
class QDesignerActions: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QDesignerActions(QDesignerWorkbench *mainWindow);
|
||||
virtual ~QDesignerActions();
|
||||
|
||||
QDesignerWorkbench *workbench() const;
|
||||
QDesignerFormEditorInterface *core() const;
|
||||
|
||||
bool saveForm(QDesignerFormWindowInterface *fw);
|
||||
bool readInForm(const QString &fileName);
|
||||
bool writeOutForm(QDesignerFormWindowInterface *formWindow, const QString &fileName);
|
||||
|
||||
QActionGroup *fileActions() const;
|
||||
QActionGroup *recentFilesActions() const;
|
||||
QActionGroup *editActions() const;
|
||||
QActionGroup *formActions() const;
|
||||
QActionGroup *settingsActions() const;
|
||||
QActionGroup *windowActions() const;
|
||||
QActionGroup *toolActions() const;
|
||||
QActionGroup *helpActions() const;
|
||||
QActionGroup *uiMode() const;
|
||||
QActionGroup *styleActions() const;
|
||||
// file actions
|
||||
QAction *openFormAction() const;
|
||||
QAction *closeFormAction() const;
|
||||
// window actions
|
||||
QAction *minimizeAction() const;
|
||||
// edit mode actions
|
||||
QAction *editWidgets() const;
|
||||
// form actions
|
||||
QAction *previewFormAction() const;
|
||||
QAction *viewCodeAction() const;
|
||||
|
||||
void setBringAllToFrontVisible(bool visible);
|
||||
void setWindowListSeparatorVisible(bool visible);
|
||||
|
||||
bool openForm(QWidget *parent);
|
||||
|
||||
QString uiExtension() const;
|
||||
|
||||
// Boolean dynamic property set on actions to
|
||||
// show them in the default toolbar layout
|
||||
static const char *defaultToolbarPropertyName;
|
||||
|
||||
public slots:
|
||||
void activeFormWindowChanged(QDesignerFormWindowInterface *formWindow);
|
||||
void createForm();
|
||||
void slotOpenForm();
|
||||
void helpRequested(const QString &manual, const QString &document);
|
||||
|
||||
signals:
|
||||
void useBigIcons(bool);
|
||||
|
||||
private slots:
|
||||
void saveForm();
|
||||
void saveFormAs();
|
||||
void saveAllForms();
|
||||
void saveFormAsTemplate();
|
||||
void viewCode();
|
||||
void notImplementedYet();
|
||||
void shutdown();
|
||||
void editWidgetsSlot();
|
||||
void openRecentForm();
|
||||
void clearRecentFiles();
|
||||
void closeForm();
|
||||
void showDesignerHelp();
|
||||
void showWhatsNew();
|
||||
void aboutDesigner();
|
||||
void showWidgetSpecificHelp();
|
||||
void backupForms();
|
||||
void showNewFormDialog(const QString &fileName);
|
||||
void showPreferencesDialog();
|
||||
void showAppFontDialog();
|
||||
void savePreviewImage();
|
||||
void printPreviewImage();
|
||||
void updateCloseAction();
|
||||
void formWindowCountChanged();
|
||||
void formWindowSettingsChanged(QDesignerFormWindowInterface *fw);
|
||||
|
||||
private:
|
||||
QAction *createRecentFilesMenu();
|
||||
bool saveFormAs(QDesignerFormWindowInterface *fw);
|
||||
void fixActionContext();
|
||||
void updateRecentFileActions();
|
||||
void addRecentFile(const QString &fileName);
|
||||
void showHelp(const QString &help);
|
||||
void closePreview();
|
||||
QRect fixDialogRect(const QRect &rect) const;
|
||||
QString fixResourceFileBackupPath(QDesignerFormWindowInterface *fwi, const QDir& backupDir);
|
||||
void showStatusBarMessage(const QString &message) const;
|
||||
QActionGroup *createHelpActions();
|
||||
bool ensureBackupDirectories();
|
||||
QPixmap createPreviewPixmap(QDesignerFormWindowInterface *fw);
|
||||
qdesigner_internal::PreviewConfiguration previewConfiguration();
|
||||
|
||||
enum { MaxRecentFiles = 10 };
|
||||
QDesignerWorkbench *m_workbench;
|
||||
QDesignerFormEditorInterface *m_core;
|
||||
QDesignerSettings m_settings;
|
||||
AssistantClient m_assistantClient;
|
||||
QString m_openDirectory;
|
||||
QString m_saveDirectory;
|
||||
|
||||
|
||||
QString m_backupPath;
|
||||
QString m_backupTmpPath;
|
||||
|
||||
QTimer* m_backupTimer;
|
||||
|
||||
QActionGroup *m_fileActions;
|
||||
QActionGroup *m_recentFilesActions;
|
||||
QActionGroup *m_editActions;
|
||||
QActionGroup *m_formActions;
|
||||
QActionGroup *m_settingsActions;
|
||||
QActionGroup *m_windowActions;
|
||||
QActionGroup *m_toolActions;
|
||||
QActionGroup *m_helpActions;
|
||||
QActionGroup *m_styleActions;
|
||||
|
||||
QAction *m_editWidgetsAction;
|
||||
|
||||
QAction *m_newFormAction;
|
||||
QAction *m_openFormAction;
|
||||
QAction *m_saveFormAction;
|
||||
QAction *m_saveFormAsAction;
|
||||
QAction *m_saveAllFormsAction;
|
||||
QAction *m_saveFormAsTemplateAction;
|
||||
QAction *m_closeFormAction;
|
||||
QAction *m_savePreviewImageAction;
|
||||
QAction *m_printPreviewAction;
|
||||
|
||||
QAction *m_quitAction;
|
||||
|
||||
QAction *m_previewFormAction;
|
||||
QAction *m_viewCodeAction;
|
||||
|
||||
QAction *m_minimizeAction;
|
||||
QAction *m_bringAllToFrontSeparator;
|
||||
QAction *m_bringAllToFrontAction;
|
||||
QAction *m_windowListSeparatorAction;
|
||||
|
||||
QAction *m_preferencesAction;
|
||||
QAction *m_appFontAction;
|
||||
|
||||
QPointer<AppFontDialog> m_appFontDialog;
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
QPrinter *m_printer;
|
||||
#endif
|
||||
|
||||
qdesigner_internal::PreviewManager *m_previewManager;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QDESIGNER_ACTIONS_H
|
||||
167
third/designer/qdesigner/qdesigner_appearanceoptions.cpp
Normal file
167
third/designer/qdesigner/qdesigner_appearanceoptions.cpp
Normal file
@@ -0,0 +1,167 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Designer of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.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 the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdesigner_appearanceoptions.h"
|
||||
#include "ui_qdesigner_appearanceoptions.h"
|
||||
|
||||
#include "qdesigner_settings.h"
|
||||
#include "qdesigner_toolwindow.h"
|
||||
|
||||
#include <QtDesigner/QDesignerFormEditorInterface>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// ---------------- AppearanceOptions
|
||||
AppearanceOptions::AppearanceOptions() :
|
||||
uiMode(DockedMode)
|
||||
{
|
||||
}
|
||||
|
||||
bool AppearanceOptions::equals(const AppearanceOptions &rhs) const
|
||||
{
|
||||
return uiMode == rhs.uiMode && toolWindowFontSettings == rhs.toolWindowFontSettings;
|
||||
}
|
||||
|
||||
void AppearanceOptions::toSettings(QDesignerSettings &settings) const
|
||||
{
|
||||
settings.setUiMode(uiMode);
|
||||
settings.setToolWindowFont(toolWindowFontSettings);
|
||||
}
|
||||
|
||||
void AppearanceOptions::fromSettings(const QDesignerSettings &settings)
|
||||
{
|
||||
uiMode = settings.uiMode();
|
||||
toolWindowFontSettings = settings.toolWindowFont();
|
||||
}
|
||||
|
||||
// ---------------- QDesignerAppearanceOptionsWidget
|
||||
QDesignerAppearanceOptionsWidget::QDesignerAppearanceOptionsWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
m_ui(new Ui::AppearanceOptionsWidget),
|
||||
m_initialUIMode(NeutralMode)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->m_uiModeCombo->addItem(tr("Docked Window"), QVariant(DockedMode));
|
||||
m_ui->m_uiModeCombo->addItem(tr("Multiple Top-Level Windows"), QVariant(TopLevelMode));
|
||||
connect(m_ui->m_uiModeCombo, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(slotUiModeComboChanged()));
|
||||
|
||||
m_ui->m_fontPanel->setCheckable(true);
|
||||
m_ui->m_fontPanel->setTitle(tr("Toolwindow Font"));
|
||||
|
||||
}
|
||||
|
||||
QDesignerAppearanceOptionsWidget::~QDesignerAppearanceOptionsWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
UIMode QDesignerAppearanceOptionsWidget::uiMode() const
|
||||
{
|
||||
return static_cast<UIMode>(m_ui->m_uiModeCombo->itemData(m_ui->m_uiModeCombo->currentIndex()).toInt());
|
||||
}
|
||||
|
||||
AppearanceOptions QDesignerAppearanceOptionsWidget::appearanceOptions() const
|
||||
{
|
||||
AppearanceOptions rc;
|
||||
rc.uiMode = uiMode();
|
||||
rc.toolWindowFontSettings.m_font = m_ui->m_fontPanel->selectedFont();
|
||||
rc.toolWindowFontSettings.m_useFont = m_ui->m_fontPanel->isChecked();
|
||||
rc.toolWindowFontSettings.m_writingSystem = m_ui->m_fontPanel->writingSystem();
|
||||
return rc;
|
||||
}
|
||||
|
||||
void QDesignerAppearanceOptionsWidget::setAppearanceOptions(const AppearanceOptions &ao)
|
||||
{
|
||||
m_initialUIMode = ao.uiMode;
|
||||
m_ui->m_uiModeCombo->setCurrentIndex(m_ui->m_uiModeCombo->findData(QVariant(ao.uiMode)));
|
||||
m_ui->m_fontPanel->setWritingSystem(ao.toolWindowFontSettings.m_writingSystem);
|
||||
m_ui->m_fontPanel->setSelectedFont(ao.toolWindowFontSettings.m_font);
|
||||
m_ui->m_fontPanel->setChecked(ao.toolWindowFontSettings.m_useFont);
|
||||
}
|
||||
|
||||
void QDesignerAppearanceOptionsWidget::slotUiModeComboChanged()
|
||||
{
|
||||
emit uiModeChanged(m_initialUIMode != uiMode());
|
||||
}
|
||||
|
||||
// ----------- QDesignerAppearanceOptionsPage
|
||||
QDesignerAppearanceOptionsPage::QDesignerAppearanceOptionsPage(QDesignerFormEditorInterface *core) :
|
||||
m_core(core)
|
||||
{
|
||||
}
|
||||
|
||||
QString QDesignerAppearanceOptionsPage::name() const
|
||||
{
|
||||
//: Tab in preferences dialog
|
||||
return QCoreApplication::translate("QDesignerAppearanceOptionsPage", "Appearance");
|
||||
}
|
||||
|
||||
QWidget *QDesignerAppearanceOptionsPage::createPage(QWidget *parent)
|
||||
{
|
||||
m_widget = new QDesignerAppearanceOptionsWidget(parent);
|
||||
m_initialOptions.fromSettings(QDesignerSettings(m_core));
|
||||
m_widget->setAppearanceOptions(m_initialOptions);
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
void QDesignerAppearanceOptionsPage::apply()
|
||||
{
|
||||
if (m_widget) {
|
||||
const AppearanceOptions newOptions = m_widget->appearanceOptions();
|
||||
if (newOptions != m_initialOptions) {
|
||||
QDesignerSettings settings(m_core);
|
||||
newOptions.toSettings(settings);
|
||||
QTimer::singleShot(0, this, SIGNAL(settingsChangedDelayed()));
|
||||
m_initialOptions = newOptions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QDesignerAppearanceOptionsPage::finish()
|
||||
{
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
136
third/designer/qdesigner/qdesigner_appearanceoptions.h
Normal file
136
third/designer/qdesigner/qdesigner_appearanceoptions.h
Normal file
@@ -0,0 +1,136 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Designer of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.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 the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDESIGNER_APPEARANCEOPTIONS_H
|
||||
#define QDESIGNER_APPEARANCEOPTIONS_H
|
||||
|
||||
#include "designer_enums.h"
|
||||
#include "qdesigner_toolwindow.h"
|
||||
|
||||
#include <QtDesigner/private/abstractoptionspage_p.h>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerFormEditorInterface;
|
||||
class QDesignerSettings;
|
||||
|
||||
namespace Ui {
|
||||
class AppearanceOptionsWidget;
|
||||
}
|
||||
|
||||
/* AppearanceOptions data */
|
||||
struct AppearanceOptions {
|
||||
AppearanceOptions();
|
||||
bool equals(const AppearanceOptions&) const;
|
||||
void toSettings(QDesignerSettings &) const;
|
||||
void fromSettings(const QDesignerSettings &);
|
||||
|
||||
UIMode uiMode;
|
||||
ToolWindowFontSettings toolWindowFontSettings;
|
||||
};
|
||||
|
||||
inline bool operator==(const AppearanceOptions &ao1, const AppearanceOptions &ao2)
|
||||
{
|
||||
return ao1.equals(ao2);
|
||||
}
|
||||
|
||||
inline bool operator!=(const AppearanceOptions &ao1, const AppearanceOptions &ao2)
|
||||
{
|
||||
return !ao1.equals(ao2);
|
||||
}
|
||||
|
||||
/* QDesignerAppearanceOptionsWidget: Let the user edit AppearanceOptions */
|
||||
class QDesignerAppearanceOptionsWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QDesignerAppearanceOptionsWidget(QWidget *parent = 0);
|
||||
~QDesignerAppearanceOptionsWidget();
|
||||
|
||||
AppearanceOptions appearanceOptions() const;
|
||||
void setAppearanceOptions(const AppearanceOptions &ao);
|
||||
|
||||
signals:
|
||||
void uiModeChanged(bool modified);
|
||||
|
||||
private slots:
|
||||
void slotUiModeComboChanged();
|
||||
|
||||
private:
|
||||
UIMode uiMode() const;
|
||||
|
||||
Ui::AppearanceOptionsWidget *m_ui;
|
||||
UIMode m_initialUIMode;
|
||||
};
|
||||
|
||||
/* The options page for appearance options. Emits a Timer-0 delayed changed
|
||||
* signal to allow the preferences dialog to close (and be deleted) before a
|
||||
* possible switch from docked mode to top-level mode happens. (The switch
|
||||
* would delete the main window, which the preference dialog is a child of
|
||||
* -> BOOM) */
|
||||
|
||||
class QDesignerAppearanceOptionsPage : public QObject, public QDesignerOptionsPageInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QDesignerAppearanceOptionsPage(QDesignerFormEditorInterface *core);
|
||||
|
||||
QString name() const;
|
||||
QWidget *createPage(QWidget *parent);
|
||||
virtual void apply();
|
||||
virtual void finish();
|
||||
|
||||
signals:
|
||||
void settingsChangedDelayed();
|
||||
|
||||
private:
|
||||
QDesignerFormEditorInterface *m_core;
|
||||
QPointer<QDesignerAppearanceOptionsWidget> m_widget;
|
||||
AppearanceOptions m_initialOptions;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QDESIGNER_APPEARANCEOPTIONS_H
|
||||
57
third/designer/qdesigner/qdesigner_appearanceoptions.ui
Normal file
57
third/designer/qdesigner/qdesigner_appearanceoptions.ui
Normal file
@@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AppearanceOptionsWidget</class>
|
||||
<widget class="QWidget" name="AppearanceOptionsWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>325</width>
|
||||
<height>360</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="m_uiModeGroupBox">
|
||||
<property name="title">
|
||||
<string>User Interface Mode</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="m_uiModeCombo"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="FontPanel" name="m_fontPanel"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>FontPanel</class>
|
||||
<extends>QGroupBox</extends>
|
||||
<header>fontpanel.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
289
third/designer/qdesigner/qdesigner_formwindow.cpp
Normal file
289
third/designer/qdesigner/qdesigner_formwindow.cpp
Normal file
@@ -0,0 +1,289 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Designer of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.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 the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdesigner_formwindow.h"
|
||||
#include "qdesigner_workbench.h"
|
||||
#include "formwindowbase_p.h"
|
||||
|
||||
// sdk
|
||||
#include <QtDesigner/QDesignerFormWindowInterface>
|
||||
#include <QtDesigner/QDesignerFormEditorInterface>
|
||||
#include <QtDesigner/QDesignerPropertySheetExtension>
|
||||
#include <QtDesigner/QDesignerPropertyEditorInterface>
|
||||
#include <QtDesigner/QDesignerFormWindowManagerInterface>
|
||||
#include <QtDesigner/QDesignerTaskMenuExtension>
|
||||
#include <QtDesigner/QExtensionManager>
|
||||
|
||||
#include <QtCore/QEvent>
|
||||
#include <QtCore/QFile>
|
||||
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QCloseEvent>
|
||||
#include <QtGui/QFileDialog>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QUndoCommand>
|
||||
#include <QtGui/QWindowStateChangeEvent>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QDesignerFormWindow::QDesignerFormWindow(QDesignerFormWindowInterface *editor, QDesignerWorkbench *workbench, QWidget *parent, Qt::WindowFlags flags)
|
||||
: QWidget(parent, flags),
|
||||
m_editor(editor),
|
||||
m_workbench(workbench),
|
||||
m_action(new QAction(this)),
|
||||
m_initialized(false),
|
||||
m_windowTitleInitialized(false)
|
||||
{
|
||||
Q_ASSERT(workbench);
|
||||
|
||||
setMaximumSize(0xFFF, 0xFFF);
|
||||
QDesignerFormEditorInterface *core = workbench->core();
|
||||
|
||||
if (m_editor) {
|
||||
m_editor->setParent(this);
|
||||
} else {
|
||||
m_editor = core->formWindowManager()->createFormWindow(this);
|
||||
}
|
||||
|
||||
QVBoxLayout *l = new QVBoxLayout(this);
|
||||
l->setMargin(0);
|
||||
l->addWidget(m_editor);
|
||||
|
||||
m_action->setCheckable(true);
|
||||
|
||||
connect(m_editor->commandHistory(), SIGNAL(indexChanged(int)), this, SLOT(updateChanged()));
|
||||
connect(m_editor, SIGNAL(geometryChanged()), this, SLOT(geometryChanged()));
|
||||
qdesigner_internal::FormWindowBase::setupDefaultAction(m_editor);
|
||||
}
|
||||
|
||||
QDesignerFormWindow::~QDesignerFormWindow()
|
||||
{
|
||||
if (workbench())
|
||||
workbench()->removeFormWindow(this);
|
||||
}
|
||||
|
||||
QAction *QDesignerFormWindow::action() const
|
||||
{
|
||||
return m_action;
|
||||
}
|
||||
|
||||
void QDesignerFormWindow::changeEvent(QEvent *e)
|
||||
{
|
||||
switch (e->type()) {
|
||||
case QEvent::WindowTitleChange:
|
||||
m_action->setText(windowTitle().remove(QLatin1String("[*]")));
|
||||
break;
|
||||
case QEvent::WindowIconChange:
|
||||
m_action->setIcon(windowIcon());
|
||||
break;
|
||||
case QEvent::WindowStateChange: {
|
||||
const QWindowStateChangeEvent *wsce = static_cast<const QWindowStateChangeEvent *>(e);
|
||||
const bool wasMinimized = Qt::WindowMinimized & wsce->oldState();
|
||||
const bool isMinimizedNow = isMinimized();
|
||||
if (wasMinimized != isMinimizedNow )
|
||||
emit minimizationStateChanged(m_editor, isMinimizedNow);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
|
||||
QRect QDesignerFormWindow::geometryHint() const
|
||||
{
|
||||
const QPoint point(0, 0);
|
||||
// If we have a container, we want to be just as big.
|
||||
// QMdiSubWindow attempts to resize its children to sizeHint() when switching user interface modes.
|
||||
if (QWidget *mainContainer = m_editor->mainContainer())
|
||||
return QRect(point, mainContainer->size());
|
||||
|
||||
return QRect(point, sizeHint());
|
||||
}
|
||||
|
||||
QDesignerFormWindowInterface *QDesignerFormWindow::editor() const
|
||||
{
|
||||
return m_editor;
|
||||
}
|
||||
|
||||
QDesignerWorkbench *QDesignerFormWindow::workbench() const
|
||||
{
|
||||
return m_workbench;
|
||||
}
|
||||
|
||||
void QDesignerFormWindow::firstShow()
|
||||
{
|
||||
// Set up handling of file name changes and set initial title.
|
||||
if (!m_windowTitleInitialized) {
|
||||
m_windowTitleInitialized = true;
|
||||
if (m_editor) {
|
||||
connect(m_editor, SIGNAL(fileNameChanged(QString)), this, SLOT(updateWindowTitle(QString)));
|
||||
updateWindowTitle(m_editor->fileName());
|
||||
}
|
||||
}
|
||||
show();
|
||||
}
|
||||
|
||||
int QDesignerFormWindow::getNumberOfUntitledWindows() const
|
||||
{
|
||||
const int totalWindows = m_workbench->formWindowCount();
|
||||
if (!totalWindows)
|
||||
return 0;
|
||||
|
||||
int maxUntitled = 0;
|
||||
// Find the number of untitled windows excluding ourselves.
|
||||
// Do not fall for 'untitled.ui', match with modified place holder.
|
||||
// This will cause some problems with i18n, but for now I need the string to be "static"
|
||||
QRegExp rx(QLatin1String("untitled( (\\d+))?\\[\\*\\]"));
|
||||
for (int i = 0; i < totalWindows; ++i) {
|
||||
QDesignerFormWindow *fw = m_workbench->formWindow(i);
|
||||
if (fw != this) {
|
||||
const QString title = m_workbench->formWindow(i)->windowTitle();
|
||||
if (rx.indexIn(title) != -1) {
|
||||
if (maxUntitled == 0)
|
||||
++maxUntitled;
|
||||
if (rx.captureCount() > 1) {
|
||||
const QString numberCapture = rx.cap(2);
|
||||
if (!numberCapture.isEmpty())
|
||||
maxUntitled = qMax(numberCapture.toInt(), maxUntitled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return maxUntitled;
|
||||
}
|
||||
|
||||
void QDesignerFormWindow::updateWindowTitle(const QString &fileName)
|
||||
{
|
||||
if (!m_windowTitleInitialized) {
|
||||
m_windowTitleInitialized = true;
|
||||
if (m_editor)
|
||||
connect(m_editor, SIGNAL(fileNameChanged(QString)), this, SLOT(updateWindowTitle(QString)));
|
||||
}
|
||||
|
||||
QString fileNameTitle;
|
||||
if (fileName.isEmpty()) {
|
||||
fileNameTitle = QLatin1String("untitled");
|
||||
if (const int maxUntitled = getNumberOfUntitledWindows()) {
|
||||
fileNameTitle += QLatin1Char(' ');
|
||||
fileNameTitle += QString::number(maxUntitled + 1);
|
||||
}
|
||||
} else {
|
||||
fileNameTitle = QFileInfo(fileName).fileName();
|
||||
}
|
||||
|
||||
if (const QWidget *mc = m_editor->mainContainer()) {
|
||||
setWindowIcon(mc->windowIcon());
|
||||
setWindowTitle(tr("%1 - %2[*]").arg(mc->windowTitle()).arg(fileNameTitle));
|
||||
} else {
|
||||
setWindowTitle(fileNameTitle);
|
||||
}
|
||||
}
|
||||
|
||||
void QDesignerFormWindow::closeEvent(QCloseEvent *ev)
|
||||
{
|
||||
if (m_editor->isDirty()) {
|
||||
raise();
|
||||
QMessageBox box(QMessageBox::Information, tr("Save Form?"),
|
||||
tr("Do you want to save the changes to this document before closing?"),
|
||||
QMessageBox::Discard | QMessageBox::Cancel | QMessageBox::Save, m_editor);
|
||||
box.setInformativeText(tr("If you don't save, your changes will be lost."));
|
||||
box.setWindowModality(Qt::WindowModal);
|
||||
static_cast<QPushButton *>(box.button(QMessageBox::Save))->setDefault(true);
|
||||
|
||||
switch (box.exec()) {
|
||||
case QMessageBox::Save: {
|
||||
bool ok = workbench()->saveForm(m_editor);
|
||||
ev->setAccepted(ok);
|
||||
m_editor->setDirty(!ok);
|
||||
break;
|
||||
}
|
||||
case QMessageBox::Discard:
|
||||
m_editor->setDirty(false); // Not really necessary, but stops problems if we get close again.
|
||||
ev->accept();
|
||||
break;
|
||||
case QMessageBox::Cancel:
|
||||
ev->ignore();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QDesignerFormWindow::updateChanged()
|
||||
{
|
||||
// Sometimes called after form window destruction.
|
||||
if (m_editor) {
|
||||
setWindowModified(m_editor->isDirty());
|
||||
updateWindowTitle(m_editor->fileName());
|
||||
}
|
||||
}
|
||||
|
||||
void QDesignerFormWindow::resizeEvent(QResizeEvent *rev)
|
||||
{
|
||||
if(m_initialized) {
|
||||
m_editor->setDirty(true);
|
||||
setWindowModified(true);
|
||||
}
|
||||
|
||||
m_initialized = true;
|
||||
QWidget::resizeEvent(rev);
|
||||
}
|
||||
|
||||
void QDesignerFormWindow::geometryChanged()
|
||||
{
|
||||
// If the form window changes, re-update the geometry of the current widget in the property editor.
|
||||
// Note that in the case of layouts, non-maincontainer widgets must also be updated,
|
||||
// so, do not do it for the main container only
|
||||
const QDesignerFormEditorInterface *core = m_editor->core();
|
||||
QObject *object = core->propertyEditor()->object();
|
||||
if (object == 0 || !object->isWidgetType())
|
||||
return;
|
||||
static const QString geometryProperty = QLatin1String("geometry");
|
||||
const QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), object);
|
||||
const int geometryIndex = sheet->indexOf(geometryProperty);
|
||||
if (geometryIndex == -1)
|
||||
return;
|
||||
core->propertyEditor()->setPropertyValue(geometryProperty, sheet->property(geometryIndex));
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
97
third/designer/qdesigner/qdesigner_formwindow.h
Normal file
97
third/designer/qdesigner/qdesigner_formwindow.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Designer of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.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 the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDESIGNER_FORMWINDOW_H
|
||||
#define QDESIGNER_FORMWINDOW_H
|
||||
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerWorkbench;
|
||||
class QDesignerFormWindowInterface;
|
||||
|
||||
class QDesignerFormWindow: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDesignerFormWindow(QDesignerFormWindowInterface *formWindow, QDesignerWorkbench *workbench,
|
||||
QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
||||
|
||||
void firstShow();
|
||||
|
||||
virtual ~QDesignerFormWindow();
|
||||
|
||||
QAction *action() const;
|
||||
QDesignerWorkbench *workbench() const;
|
||||
QDesignerFormWindowInterface *editor() const;
|
||||
|
||||
QRect geometryHint() const;
|
||||
|
||||
public slots:
|
||||
void updateChanged();
|
||||
|
||||
private slots:
|
||||
void updateWindowTitle(const QString &fileName);
|
||||
void geometryChanged();
|
||||
|
||||
signals:
|
||||
void minimizationStateChanged(QDesignerFormWindowInterface *formWindow, bool minimized);
|
||||
void triggerAction();
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *e);
|
||||
virtual void closeEvent(QCloseEvent *ev);
|
||||
virtual void resizeEvent(QResizeEvent* rev);
|
||||
|
||||
private:
|
||||
int getNumberOfUntitledWindows() const;
|
||||
QPointer<QDesignerFormWindowInterface> m_editor;
|
||||
QPointer<QDesignerWorkbench> m_workbench;
|
||||
QAction *m_action;
|
||||
bool m_initialized;
|
||||
bool m_windowTitleInitialized;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QDESIGNER_FORMWINDOW_H
|
||||
59
third/designer/qdesigner/qdesigner_pch.h
Normal file
59
third/designer/qdesigner/qdesigner_pch.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Designer of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.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 the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#if defined __cplusplus
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtGui/QCloseEvent>
|
||||
#include <QtGui/QHeaderView>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtDesigner/abstractformeditor.h>
|
||||
#include <QtDesigner/abstractformwindow.h>
|
||||
|
||||
#include "qdesigner.h"
|
||||
#include "qdesigner_formwindow.h"
|
||||
#include "qdesigner_settings.h"
|
||||
#include "qdesigner_toolwindow.h"
|
||||
#include "qdesigner_workbench.h"
|
||||
#endif
|
||||
156
third/designer/qdesigner/qdesigner_server.cpp
Normal file
156
third/designer/qdesigner/qdesigner_server.cpp
Normal file
@@ -0,0 +1,156 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Designer of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.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 the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
#include <QtNetwork/QHostAddress>
|
||||
#include <QtNetwork/QTcpServer>
|
||||
#include <QtNetwork/QTcpSocket>
|
||||
|
||||
#include "qdesigner.h"
|
||||
#include "qdesigner_server.h"
|
||||
|
||||
#include <qevent.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// ### review
|
||||
|
||||
QDesignerServer::QDesignerServer(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
m_socket = 0;
|
||||
m_server = new QTcpServer(this);
|
||||
m_server->listen(QHostAddress::LocalHost, 0);
|
||||
if (m_server->isListening())
|
||||
{
|
||||
connect(m_server, SIGNAL(newConnection()),
|
||||
this, SLOT(handleNewConnection()));
|
||||
}
|
||||
}
|
||||
|
||||
QDesignerServer::~QDesignerServer()
|
||||
{
|
||||
}
|
||||
|
||||
quint16 QDesignerServer::serverPort() const
|
||||
{
|
||||
return m_server ? m_server->serverPort() : 0;
|
||||
}
|
||||
|
||||
void QDesignerServer::sendOpenRequest(int port, const QStringList &files)
|
||||
{
|
||||
QTcpSocket *sSocket = new QTcpSocket();
|
||||
sSocket->connectToHost(QHostAddress::LocalHost, port);
|
||||
if(sSocket->waitForConnected(3000))
|
||||
{
|
||||
foreach(const QString &file, files)
|
||||
{
|
||||
QFileInfo fi(file);
|
||||
sSocket->write(fi.absoluteFilePath().toUtf8() + '\n');
|
||||
}
|
||||
sSocket->waitForBytesWritten(3000);
|
||||
sSocket->close();
|
||||
}
|
||||
delete sSocket;
|
||||
}
|
||||
|
||||
void QDesignerServer::readFromClient()
|
||||
{
|
||||
while (m_socket->canReadLine()) {
|
||||
QString file = QString::fromUtf8(m_socket->readLine());
|
||||
if (!file.isNull()) {
|
||||
file.remove(QLatin1Char('\n'));
|
||||
file.remove(QLatin1Char('\r'));
|
||||
qDesigner->postEvent(qDesigner, new QFileOpenEvent(file));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QDesignerServer::socketClosed()
|
||||
{
|
||||
m_socket = 0;
|
||||
}
|
||||
|
||||
void QDesignerServer::handleNewConnection()
|
||||
{
|
||||
// no need for more than one connection
|
||||
if (m_socket == 0) {
|
||||
m_socket = m_server->nextPendingConnection();
|
||||
connect(m_socket, SIGNAL(readyRead()),
|
||||
this, SLOT(readFromClient()));
|
||||
connect(m_socket, SIGNAL(disconnected()),
|
||||
this, SLOT(socketClosed()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QDesignerClient::QDesignerClient(quint16 port, QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
m_socket = new QTcpSocket(this);
|
||||
m_socket->connectToHost(QHostAddress::LocalHost, port);
|
||||
connect(m_socket, SIGNAL(readyRead()),
|
||||
this, SLOT(readFromSocket()));
|
||||
|
||||
}
|
||||
|
||||
QDesignerClient::~QDesignerClient()
|
||||
{
|
||||
m_socket->close();
|
||||
m_socket->flush();
|
||||
}
|
||||
|
||||
void QDesignerClient::readFromSocket()
|
||||
{
|
||||
while (m_socket->canReadLine()) {
|
||||
QString file = QString::fromUtf8(m_socket->readLine());
|
||||
if (!file.isNull()) {
|
||||
file.remove(QLatin1Char('\n'));
|
||||
file.remove(QLatin1Char('\r'));
|
||||
if (QFile::exists(file))
|
||||
qDesigner->postEvent(qDesigner, new QFileOpenEvent(file));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
89
third/designer/qdesigner/qdesigner_server.h
Normal file
89
third/designer/qdesigner/qdesigner_server.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Designer of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.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 the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDESIGNER_SERVER_H
|
||||
#define QDESIGNER_SERVER_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QTcpServer;
|
||||
class QTcpSocket;
|
||||
|
||||
class QDesignerServer: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QDesignerServer(QObject *parent = 0);
|
||||
virtual ~QDesignerServer();
|
||||
|
||||
quint16 serverPort() const;
|
||||
|
||||
static void sendOpenRequest(int port, const QStringList &files);
|
||||
|
||||
private slots:
|
||||
void handleNewConnection();
|
||||
void readFromClient();
|
||||
void socketClosed();
|
||||
|
||||
private:
|
||||
QTcpServer *m_server;
|
||||
QTcpSocket *m_socket;
|
||||
};
|
||||
|
||||
class QDesignerClient: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QDesignerClient(quint16 port, QObject *parent = 0);
|
||||
virtual ~QDesignerClient();
|
||||
|
||||
private slots:
|
||||
void readFromSocket();
|
||||
|
||||
private:
|
||||
QTcpSocket *m_socket;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QDESIGNER_SERVER_H
|
||||
250
third/designer/qdesigner/qdesigner_settings.cpp
Normal file
250
third/designer/qdesigner/qdesigner_settings.cpp
Normal file
@@ -0,0 +1,250 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Designer of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.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 the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdesigner.h"
|
||||
#include "qdesigner_settings.h"
|
||||
#include "qdesigner_toolwindow.h"
|
||||
#include "qdesigner_workbench.h"
|
||||
|
||||
#include <abstractformeditor.h>
|
||||
#include <abstractsettings_p.h>
|
||||
#include <qdesigner_utils_p.h>
|
||||
#include <previewmanager_p.h>
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtCore/QDir>
|
||||
|
||||
#include <QtGui/QDesktopWidget>
|
||||
#include <QtGui/QStyle>
|
||||
#include <QtGui/QListView>
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
enum { debugSettings = 0 };
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
static const char *newFormShowKey = "newFormDialog/ShowOnStartup";
|
||||
|
||||
// Change the version whenever the arrangement changes significantly.
|
||||
static const char *mainWindowStateKey = "MainWindowState45";
|
||||
static const char *toolBarsStateKey = "ToolBarsState45";
|
||||
|
||||
static const char *backupOrgListKey = "backup/fileListOrg";
|
||||
static const char *backupBakListKey = "backup/fileListBak";
|
||||
static const char *recentFilesListKey = "recentFilesList";
|
||||
|
||||
QDesignerSettings::QDesignerSettings(QDesignerFormEditorInterface *core) :
|
||||
qdesigner_internal::QDesignerSharedSettings(core)
|
||||
{
|
||||
}
|
||||
|
||||
void QDesignerSettings::setValue(const QString &key, const QVariant &value)
|
||||
{
|
||||
settings()->setValue(key, value);
|
||||
}
|
||||
|
||||
QVariant QDesignerSettings::value(const QString &key, const QVariant &defaultValue) const
|
||||
{
|
||||
return settings()->value(key, defaultValue);
|
||||
}
|
||||
|
||||
static inline QChar modeChar(UIMode mode)
|
||||
{
|
||||
return QLatin1Char(static_cast<char>(mode) + '0');
|
||||
}
|
||||
|
||||
void QDesignerSettings::saveGeometryFor(const QWidget *w)
|
||||
{
|
||||
Q_ASSERT(w && !w->objectName().isEmpty());
|
||||
QDesignerSettingsInterface *s = settings();
|
||||
const bool visible = w->isVisible();
|
||||
if (debugSettings)
|
||||
qDebug() << Q_FUNC_INFO << w << "visible=" << visible;
|
||||
s->beginGroup(w->objectName());
|
||||
s->setValue(QLatin1String("visible"), visible);
|
||||
s->setValue(QLatin1String("geometry"), w->saveGeometry());
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
void QDesignerSettings::restoreGeometry(QWidget *w, QRect fallBack) const
|
||||
{
|
||||
Q_ASSERT(w && !w->objectName().isEmpty());
|
||||
const QString key = w->objectName();
|
||||
const QByteArray ba(settings()->value(key + QLatin1String("/geometry")).toByteArray());
|
||||
const bool visible = settings()->value(key + QLatin1String("/visible"), true).toBool();
|
||||
|
||||
if (debugSettings)
|
||||
qDebug() << Q_FUNC_INFO << w << fallBack << "visible=" << visible;
|
||||
if (ba.isEmpty()) {
|
||||
/// Apply default geometry, check for null and maximal size
|
||||
if (fallBack.isNull())
|
||||
fallBack = QRect(QPoint(0, 0), w->sizeHint());
|
||||
if (fallBack.size() == QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)) {
|
||||
w->setWindowState(w->windowState() | Qt::WindowMaximized);
|
||||
} else {
|
||||
w->move(fallBack.topLeft());
|
||||
w->resize(fallBack.size());
|
||||
}
|
||||
} else {
|
||||
w->restoreGeometry(ba);
|
||||
}
|
||||
|
||||
if (visible)
|
||||
w->show();
|
||||
}
|
||||
|
||||
QStringList QDesignerSettings::recentFilesList() const
|
||||
{
|
||||
return settings()->value(QLatin1String(recentFilesListKey)).toStringList();
|
||||
}
|
||||
|
||||
void QDesignerSettings::setRecentFilesList(const QStringList &sl)
|
||||
{
|
||||
settings()->setValue(QLatin1String(recentFilesListKey), sl);
|
||||
}
|
||||
|
||||
void QDesignerSettings::setShowNewFormOnStartup(bool showIt)
|
||||
{
|
||||
settings()->setValue(QLatin1String(newFormShowKey), showIt);
|
||||
}
|
||||
|
||||
bool QDesignerSettings::showNewFormOnStartup() const
|
||||
{
|
||||
return settings()->value(QLatin1String(newFormShowKey), true).toBool();
|
||||
}
|
||||
|
||||
QByteArray QDesignerSettings::mainWindowState(UIMode mode) const
|
||||
{
|
||||
return settings()->value(QLatin1String(mainWindowStateKey) + modeChar(mode)).toByteArray();
|
||||
}
|
||||
|
||||
void QDesignerSettings::setMainWindowState(UIMode mode, const QByteArray &mainWindowState)
|
||||
{
|
||||
settings()->setValue(QLatin1String(mainWindowStateKey) + modeChar(mode), mainWindowState);
|
||||
}
|
||||
|
||||
QByteArray QDesignerSettings::toolBarsState(UIMode mode) const
|
||||
{
|
||||
QString key = QLatin1String(toolBarsStateKey);
|
||||
key += modeChar(mode);
|
||||
return settings()->value(key).toByteArray();
|
||||
}
|
||||
|
||||
void QDesignerSettings::setToolBarsState(UIMode mode, const QByteArray &toolBarsState)
|
||||
{
|
||||
QString key = QLatin1String(toolBarsStateKey);
|
||||
key += modeChar(mode);
|
||||
settings()->setValue(key, toolBarsState);
|
||||
}
|
||||
|
||||
void QDesignerSettings::clearBackup()
|
||||
{
|
||||
QDesignerSettingsInterface *s = settings();
|
||||
s->remove(QLatin1String(backupOrgListKey));
|
||||
s->remove(QLatin1String(backupBakListKey));
|
||||
}
|
||||
|
||||
void QDesignerSettings::setBackup(const QMap<QString, QString> &map)
|
||||
{
|
||||
const QStringList org = map.keys();
|
||||
const QStringList bak = map.values();
|
||||
|
||||
QDesignerSettingsInterface *s = settings();
|
||||
s->setValue(QLatin1String(backupOrgListKey), org);
|
||||
s->setValue(QLatin1String(backupBakListKey), bak);
|
||||
}
|
||||
|
||||
QMap<QString, QString> QDesignerSettings::backup() const
|
||||
{
|
||||
const QStringList org = settings()->value(QLatin1String(backupOrgListKey), QStringList()).toStringList();
|
||||
const QStringList bak = settings()->value(QLatin1String(backupBakListKey), QStringList()).toStringList();
|
||||
|
||||
QMap<QString, QString> map;
|
||||
const int orgCount = org.count();
|
||||
for (int i = 0; i < orgCount; ++i)
|
||||
map.insert(org.at(i), bak.at(i));
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
void QDesignerSettings::setUiMode(UIMode mode)
|
||||
{
|
||||
QDesignerSettingsInterface *s = settings();
|
||||
s->beginGroup(QLatin1String("UI"));
|
||||
s->setValue(QLatin1String("currentMode"), mode);
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
UIMode QDesignerSettings::uiMode() const
|
||||
{
|
||||
#ifdef Q_WS_MAC
|
||||
const UIMode defaultMode = TopLevelMode;
|
||||
#else
|
||||
const UIMode defaultMode = DockedMode;
|
||||
#endif
|
||||
UIMode uiMode = static_cast<UIMode>(value(QLatin1String("UI/currentMode"), defaultMode).toInt());
|
||||
return uiMode;
|
||||
}
|
||||
|
||||
void QDesignerSettings::setToolWindowFont(const ToolWindowFontSettings &fontSettings)
|
||||
{
|
||||
QDesignerSettingsInterface *s = settings();
|
||||
s->beginGroup(QLatin1String("UI"));
|
||||
s->setValue(QLatin1String("font"), fontSettings.m_font);
|
||||
s->setValue(QLatin1String("useFont"), fontSettings.m_useFont);
|
||||
s->setValue(QLatin1String("writingSystem"), fontSettings.m_writingSystem);
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
ToolWindowFontSettings QDesignerSettings::toolWindowFont() const
|
||||
{
|
||||
ToolWindowFontSettings fontSettings;
|
||||
fontSettings.m_writingSystem =
|
||||
static_cast<QFontDatabase::WritingSystem>(value(QLatin1String("UI/writingSystem"),
|
||||
QFontDatabase::Any).toInt());
|
||||
fontSettings.m_font = qVariantValue<QFont>(value(QLatin1String("UI/font")));
|
||||
fontSettings.m_useFont =
|
||||
settings()->value(QLatin1String("UI/useFont"), QVariant(false)).toBool();
|
||||
return fontSettings;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
94
third/designer/qdesigner/qdesigner_settings.h
Normal file
94
third/designer/qdesigner/qdesigner_settings.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Designer of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.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 the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDESIGNER_SETTINGS_H
|
||||
#define QDESIGNER_SETTINGS_H
|
||||
|
||||
#include "designer_enums.h"
|
||||
#include <shared_settings_p.h>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QRect>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerFormEditorInterface;
|
||||
class QDesignerSettingsInterface;
|
||||
struct ToolWindowFontSettings;
|
||||
|
||||
class QDesignerSettings : public qdesigner_internal::QDesignerSharedSettings
|
||||
{
|
||||
public:
|
||||
QDesignerSettings(QDesignerFormEditorInterface *core);
|
||||
|
||||
void setValue(const QString &key, const QVariant &value);
|
||||
QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const;
|
||||
|
||||
void restoreGeometry(QWidget *w, QRect fallBack = QRect()) const;
|
||||
void saveGeometryFor(const QWidget *w);
|
||||
|
||||
QStringList recentFilesList() const;
|
||||
void setRecentFilesList(const QStringList &list);
|
||||
|
||||
void setShowNewFormOnStartup(bool showIt);
|
||||
bool showNewFormOnStartup() const;
|
||||
|
||||
void setUiMode(UIMode mode);
|
||||
UIMode uiMode() const;
|
||||
|
||||
void setToolWindowFont(const ToolWindowFontSettings &fontSettings);
|
||||
ToolWindowFontSettings toolWindowFont() const;
|
||||
|
||||
QByteArray mainWindowState(UIMode mode) const;
|
||||
void setMainWindowState(UIMode mode, const QByteArray &mainWindowState);
|
||||
|
||||
QByteArray toolBarsState(UIMode mode) const;
|
||||
void setToolBarsState(UIMode mode, const QByteArray &mainWindowState);
|
||||
|
||||
void clearBackup();
|
||||
void setBackup(const QMap<QString, QString> &map);
|
||||
QMap<QString, QString> backup() const;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QDESIGNER_SETTINGS_H
|
||||
438
third/designer/qdesigner/qdesigner_toolwindow.cpp
Normal file
438
third/designer/qdesigner/qdesigner_toolwindow.cpp
Normal file
@@ -0,0 +1,438 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Designer of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.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 the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdesigner.h"
|
||||
#include "qdesigner_toolwindow.h"
|
||||
#include "qdesigner_settings.h"
|
||||
#include "qdesigner_workbench.h"
|
||||
|
||||
#include <QtDesigner/QDesignerPropertyEditorInterface>
|
||||
#include <QtDesigner/QDesignerFormEditorInterface>
|
||||
#include <QtDesigner/QDesignerActionEditorInterface>
|
||||
#include <QtDesigner/QDesignerObjectInspectorInterface>
|
||||
#include <QtDesigner/QDesignerWidgetBoxInterface>
|
||||
#include <QtDesigner/QDesignerComponents>
|
||||
|
||||
#include <QtCore/QEvent>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QCloseEvent>
|
||||
|
||||
enum { debugToolWindow = 0 };
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// ---------------- QDesignerToolWindowFontSettings
|
||||
ToolWindowFontSettings::ToolWindowFontSettings() :
|
||||
m_writingSystem(QFontDatabase::Any),
|
||||
m_useFont(false)
|
||||
{
|
||||
}
|
||||
|
||||
bool ToolWindowFontSettings::equals(const ToolWindowFontSettings &rhs) const
|
||||
{
|
||||
return m_useFont == rhs.m_useFont &&
|
||||
m_writingSystem == rhs.m_writingSystem &&
|
||||
m_font == rhs.m_font;
|
||||
}
|
||||
|
||||
// ---------------- QDesignerToolWindow
|
||||
QDesignerToolWindow::QDesignerToolWindow(QDesignerWorkbench *workbench,
|
||||
QWidget *w,
|
||||
const QString &objectName,
|
||||
const QString &title,
|
||||
const QString &actionObjectName,
|
||||
Qt::DockWidgetArea dockAreaHint,
|
||||
QWidget *parent,
|
||||
Qt::WindowFlags flags) :
|
||||
MainWindowBase(parent, flags),
|
||||
m_dockAreaHint(dockAreaHint),
|
||||
m_workbench(workbench),
|
||||
m_action(new QAction(this))
|
||||
{
|
||||
setObjectName(objectName);
|
||||
setCentralWidget(w);
|
||||
|
||||
setWindowTitle(title);
|
||||
|
||||
m_action->setObjectName(actionObjectName);
|
||||
m_action->setShortcutContext(Qt::ApplicationShortcut);
|
||||
m_action->setText(title);
|
||||
m_action->setCheckable(true);
|
||||
connect(m_action, SIGNAL(triggered(bool)), this, SLOT(showMe(bool)));
|
||||
}
|
||||
|
||||
void QDesignerToolWindow::showMe(bool v)
|
||||
{
|
||||
// Access the QMdiSubWindow in MDI mode.
|
||||
if (QWidget *target = m_workbench->mode() == DockedMode ? parentWidget() : this) {
|
||||
if (v)
|
||||
target->setWindowState(target->windowState() & ~Qt::WindowMinimized);
|
||||
target->setVisible(v);
|
||||
}
|
||||
}
|
||||
|
||||
void QDesignerToolWindow::showEvent(QShowEvent *e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
|
||||
bool blocked = m_action->blockSignals(true);
|
||||
m_action->setChecked(true);
|
||||
m_action->blockSignals(blocked);
|
||||
}
|
||||
|
||||
void QDesignerToolWindow::hideEvent(QHideEvent *e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
|
||||
bool blocked = m_action->blockSignals(true);
|
||||
m_action->setChecked(false);
|
||||
m_action->blockSignals(blocked);
|
||||
}
|
||||
|
||||
QAction *QDesignerToolWindow::action() const
|
||||
{
|
||||
return m_action;
|
||||
}
|
||||
|
||||
void QDesignerToolWindow::changeEvent(QEvent *e)
|
||||
{
|
||||
switch (e->type()) {
|
||||
case QEvent::WindowTitleChange:
|
||||
m_action->setText(windowTitle());
|
||||
break;
|
||||
case QEvent::WindowIconChange:
|
||||
m_action->setIcon(windowIcon());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
QMainWindow::changeEvent(e);
|
||||
}
|
||||
|
||||
QDesignerWorkbench *QDesignerToolWindow::workbench() const
|
||||
{
|
||||
return m_workbench;
|
||||
}
|
||||
|
||||
QRect QDesignerToolWindow::geometryHint() const
|
||||
{
|
||||
return QRect();
|
||||
}
|
||||
|
||||
QRect QDesignerToolWindow::availableToolWindowGeometry() const
|
||||
{
|
||||
return m_workbench->availableGeometry();
|
||||
}
|
||||
|
||||
// ---------------------- PropertyEditorToolWindow
|
||||
|
||||
static inline QWidget *createPropertyEditor(QDesignerFormEditorInterface *core, QWidget *parent = 0)
|
||||
{
|
||||
QDesignerPropertyEditorInterface *widget = QDesignerComponents::createPropertyEditor(core, parent);
|
||||
core->setPropertyEditor(widget);
|
||||
return widget;
|
||||
}
|
||||
|
||||
class PropertyEditorToolWindow : public QDesignerToolWindow
|
||||
{
|
||||
public:
|
||||
explicit PropertyEditorToolWindow(QDesignerWorkbench *workbench);
|
||||
|
||||
virtual QRect geometryHint() const;
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
};
|
||||
|
||||
PropertyEditorToolWindow::PropertyEditorToolWindow(QDesignerWorkbench *workbench) :
|
||||
QDesignerToolWindow(workbench,
|
||||
createPropertyEditor(workbench->core()),
|
||||
QLatin1String("qt_designer_propertyeditor"),
|
||||
QDesignerToolWindow::tr("Property Editor"),
|
||||
QLatin1String("__qt_property_editor_action"),
|
||||
Qt::RightDockWidgetArea)
|
||||
{
|
||||
action()->setShortcut(Qt::CTRL + Qt::Key_I);
|
||||
|
||||
}
|
||||
|
||||
QRect PropertyEditorToolWindow::geometryHint() const
|
||||
{
|
||||
const QRect g = availableToolWindowGeometry();
|
||||
const int margin = workbench()->marginHint();
|
||||
const int spacing = 40;
|
||||
const QSize sz(g.width() * 1/4, g.height() * 4/6);
|
||||
|
||||
const QRect rc = QRect((g.right() + 1 - sz.width() - margin),
|
||||
(g.top() + margin + g.height() * 1/6) + spacing,
|
||||
sz.width(), sz.height());
|
||||
if (debugToolWindow)
|
||||
qDebug() << Q_FUNC_INFO << rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
void PropertyEditorToolWindow::showEvent(QShowEvent *event)
|
||||
{
|
||||
if (QDesignerPropertyEditorInterface *e = workbench()->core()->propertyEditor()) {
|
||||
// workaround to update the propertyeditor when it is not visible!
|
||||
e->setObject(e->object()); // ### remove me
|
||||
}
|
||||
|
||||
QDesignerToolWindow::showEvent(event);
|
||||
}
|
||||
|
||||
// ---------------------- ActionEditorToolWindow
|
||||
|
||||
static inline QWidget *createActionEditor(QDesignerFormEditorInterface *core, QWidget *parent = 0)
|
||||
{
|
||||
QDesignerActionEditorInterface *widget = QDesignerComponents::createActionEditor(core, parent);
|
||||
core->setActionEditor(widget);
|
||||
return widget;
|
||||
}
|
||||
|
||||
class ActionEditorToolWindow: public QDesignerToolWindow
|
||||
{
|
||||
public:
|
||||
explicit ActionEditorToolWindow(QDesignerWorkbench *workbench);
|
||||
|
||||
virtual QRect geometryHint() const;
|
||||
};
|
||||
|
||||
ActionEditorToolWindow::ActionEditorToolWindow(QDesignerWorkbench *workbench) :
|
||||
QDesignerToolWindow(workbench,
|
||||
createActionEditor(workbench->core()),
|
||||
QLatin1String("qt_designer_actioneditor"),
|
||||
QDesignerToolWindow::tr("Action Editor"),
|
||||
QLatin1String("__qt_action_editor_tool_action"),
|
||||
Qt::RightDockWidgetArea)
|
||||
{
|
||||
}
|
||||
|
||||
QRect ActionEditorToolWindow::geometryHint() const
|
||||
{
|
||||
const QRect g = availableToolWindowGeometry();
|
||||
const int margin = workbench()->marginHint();
|
||||
|
||||
const QSize sz(g.width() * 1/4, g.height() * 1/6);
|
||||
|
||||
const QRect rc = QRect((g.right() + 1 - sz.width() - margin),
|
||||
g.top() + margin,
|
||||
sz.width(), sz.height());
|
||||
if (debugToolWindow)
|
||||
qDebug() << Q_FUNC_INFO << rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
// ---------------------- ObjectInspectorToolWindow
|
||||
|
||||
static inline QWidget *createObjectInspector(QDesignerFormEditorInterface *core, QWidget *parent = 0)
|
||||
{
|
||||
QDesignerObjectInspectorInterface *widget = QDesignerComponents::createObjectInspector(core, parent);
|
||||
core->setObjectInspector(widget);
|
||||
return widget;
|
||||
}
|
||||
|
||||
class ObjectInspectorToolWindow: public QDesignerToolWindow
|
||||
{
|
||||
public:
|
||||
explicit ObjectInspectorToolWindow(QDesignerWorkbench *workbench);
|
||||
|
||||
virtual QRect geometryHint() const;
|
||||
};
|
||||
|
||||
ObjectInspectorToolWindow::ObjectInspectorToolWindow(QDesignerWorkbench *workbench) :
|
||||
QDesignerToolWindow(workbench,
|
||||
createObjectInspector(workbench->core()),
|
||||
QLatin1String("qt_designer_objectinspector"),
|
||||
QDesignerToolWindow::tr("Object Inspector"),
|
||||
QLatin1String("__qt_object_inspector_tool_action"),
|
||||
Qt::RightDockWidgetArea)
|
||||
{
|
||||
}
|
||||
|
||||
QRect ObjectInspectorToolWindow::geometryHint() const
|
||||
{
|
||||
const QRect g = availableToolWindowGeometry();
|
||||
const int margin = workbench()->marginHint();
|
||||
|
||||
const QSize sz(g.width() * 1/4, g.height() * 1/6);
|
||||
|
||||
const QRect rc = QRect((g.right() + 1 - sz.width() - margin),
|
||||
g.top() + margin,
|
||||
sz.width(), sz.height());
|
||||
if (debugToolWindow)
|
||||
qDebug() << Q_FUNC_INFO << rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
// ---------------------- ResourceEditorToolWindow
|
||||
|
||||
class ResourceEditorToolWindow: public QDesignerToolWindow
|
||||
{
|
||||
public:
|
||||
explicit ResourceEditorToolWindow(QDesignerWorkbench *workbench);
|
||||
|
||||
virtual QRect geometryHint() const;
|
||||
};
|
||||
|
||||
ResourceEditorToolWindow::ResourceEditorToolWindow(QDesignerWorkbench *workbench) :
|
||||
QDesignerToolWindow(workbench,
|
||||
QDesignerComponents::createResourceEditor(workbench->core(), 0),
|
||||
QLatin1String("qt_designer_resourceeditor"),
|
||||
QDesignerToolWindow::tr("Resource Browser"),
|
||||
QLatin1String("__qt_resource_editor_tool_action"),
|
||||
Qt::RightDockWidgetArea)
|
||||
{
|
||||
}
|
||||
|
||||
QRect ResourceEditorToolWindow::geometryHint() const
|
||||
{
|
||||
const QRect g = availableToolWindowGeometry();
|
||||
const int margin = workbench()->marginHint();
|
||||
|
||||
const QSize sz(g.width() * 1/3, g.height() * 1/6);
|
||||
QRect r(QPoint(0, 0), sz);
|
||||
r.moveCenter(g.center());
|
||||
r.moveBottom(g.bottom() - margin);
|
||||
if (debugToolWindow)
|
||||
qDebug() << Q_FUNC_INFO << r;
|
||||
return r;
|
||||
}
|
||||
|
||||
// ---------------------- SignalSlotEditorToolWindow
|
||||
|
||||
class SignalSlotEditorToolWindow: public QDesignerToolWindow
|
||||
{
|
||||
public:
|
||||
explicit SignalSlotEditorToolWindow(QDesignerWorkbench *workbench);
|
||||
|
||||
virtual QRect geometryHint() const;
|
||||
};
|
||||
|
||||
SignalSlotEditorToolWindow::SignalSlotEditorToolWindow(QDesignerWorkbench *workbench) :
|
||||
QDesignerToolWindow(workbench,
|
||||
QDesignerComponents::createSignalSlotEditor(workbench->core(), 0),
|
||||
QLatin1String("qt_designer_signalsloteditor"),
|
||||
QDesignerToolWindow::tr("Signal/Slot Editor"),
|
||||
QLatin1String("__qt_signal_slot_editor_tool_action"),
|
||||
Qt::RightDockWidgetArea)
|
||||
{
|
||||
}
|
||||
|
||||
QRect SignalSlotEditorToolWindow::geometryHint() const
|
||||
{
|
||||
const QRect g = availableToolWindowGeometry();
|
||||
const int margin = workbench()->marginHint();
|
||||
|
||||
const QSize sz(g.width() * 1/3, g.height() * 1/6);
|
||||
QRect r(QPoint(0, 0), sz);
|
||||
r.moveCenter(g.center());
|
||||
r.moveTop(margin + g.top());
|
||||
if (debugToolWindow)
|
||||
qDebug() << Q_FUNC_INFO << r;
|
||||
return r;
|
||||
}
|
||||
|
||||
// ---------------------- WidgetBoxToolWindow
|
||||
|
||||
static inline QWidget *createWidgetBox(QDesignerFormEditorInterface *core, QWidget *parent = 0)
|
||||
{
|
||||
QDesignerWidgetBoxInterface *widget = QDesignerComponents::createWidgetBox(core, parent);
|
||||
core->setWidgetBox(widget);
|
||||
return widget;
|
||||
}
|
||||
|
||||
class WidgetBoxToolWindow: public QDesignerToolWindow
|
||||
{
|
||||
public:
|
||||
explicit WidgetBoxToolWindow(QDesignerWorkbench *workbench);
|
||||
|
||||
virtual QRect geometryHint() const;
|
||||
};
|
||||
|
||||
WidgetBoxToolWindow::WidgetBoxToolWindow(QDesignerWorkbench *workbench) :
|
||||
QDesignerToolWindow(workbench,
|
||||
createWidgetBox(workbench->core()),
|
||||
QLatin1String("qt_designer_widgetbox"),
|
||||
QDesignerToolWindow::tr("Widget Box"),
|
||||
QLatin1String("__qt_widget_box_tool_action"),
|
||||
Qt::LeftDockWidgetArea)
|
||||
{
|
||||
}
|
||||
|
||||
QRect WidgetBoxToolWindow::geometryHint() const
|
||||
{
|
||||
const QRect g = availableToolWindowGeometry();
|
||||
const int margin = workbench()->marginHint();
|
||||
const QRect rc = QRect(g.left() + margin,
|
||||
g.top() + margin,
|
||||
g.width() * 1/4, g.height() * 5/6);
|
||||
if (debugToolWindow)
|
||||
qDebug() << Q_FUNC_INFO << rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
// -- Factory
|
||||
QDesignerToolWindow *QDesignerToolWindow::createStandardToolWindow(StandardToolWindow which,
|
||||
QDesignerWorkbench *workbench)
|
||||
{
|
||||
switch (which) {
|
||||
case ActionEditor:
|
||||
return new ActionEditorToolWindow(workbench);
|
||||
case ResourceEditor:
|
||||
return new ResourceEditorToolWindow(workbench);
|
||||
case SignalSlotEditor:
|
||||
return new SignalSlotEditorToolWindow(workbench);
|
||||
case PropertyEditor:
|
||||
return new PropertyEditorToolWindow(workbench);
|
||||
case ObjectInspector:
|
||||
return new ObjectInspectorToolWindow(workbench);
|
||||
case WidgetBox:
|
||||
return new WidgetBoxToolWindow(workbench);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
123
third/designer/qdesigner/qdesigner_toolwindow.h
Normal file
123
third/designer/qdesigner/qdesigner_toolwindow.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Designer of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.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 the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDESIGNER_TOOLWINDOW_H
|
||||
#define QDESIGNER_TOOLWINDOW_H
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtGui/QFontDatabase>
|
||||
#include <QtGui/QMainWindow>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
struct ToolWindowFontSettings {
|
||||
ToolWindowFontSettings();
|
||||
bool equals(const ToolWindowFontSettings &) const;
|
||||
|
||||
QFont m_font;
|
||||
QFontDatabase::WritingSystem m_writingSystem;
|
||||
bool m_useFont;
|
||||
};
|
||||
|
||||
inline bool operator==(const ToolWindowFontSettings &tw1, const ToolWindowFontSettings &tw2)
|
||||
{
|
||||
return tw1.equals(tw2);
|
||||
}
|
||||
|
||||
inline bool operator!=(const ToolWindowFontSettings &tw1, const ToolWindowFontSettings &tw2)
|
||||
{
|
||||
return !tw1.equals(tw2);
|
||||
}
|
||||
|
||||
class QDesignerWorkbench;
|
||||
|
||||
/* A tool window with an action that activates it. Note that in toplevel mode,
|
||||
* the Widget box is a tool window as well as the applications' main window,
|
||||
* So, we need to inherit from MainWindowBase. */
|
||||
|
||||
class QDesignerToolWindow : public MainWindowBase
|
||||
{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
explicit QDesignerToolWindow(QDesignerWorkbench *workbench,
|
||||
QWidget *w,
|
||||
const QString &objectName,
|
||||
const QString &title,
|
||||
const QString &actionObjectName,
|
||||
Qt::DockWidgetArea dockAreaHint,
|
||||
QWidget *parent = 0,
|
||||
Qt::WindowFlags flags = Qt::Window);
|
||||
|
||||
public:
|
||||
// Note: The order influences the dock widget position.
|
||||
enum StandardToolWindow { WidgetBox, ObjectInspector, PropertyEditor,
|
||||
ResourceEditor, ActionEditor, SignalSlotEditor,
|
||||
StandardToolWindowCount };
|
||||
|
||||
static QDesignerToolWindow *createStandardToolWindow(StandardToolWindow which, QDesignerWorkbench *workbench);
|
||||
|
||||
QDesignerWorkbench *workbench() const;
|
||||
QAction *action() const;
|
||||
|
||||
Qt::DockWidgetArea dockWidgetAreaHint() const { return m_dockAreaHint; }
|
||||
virtual QRect geometryHint() const;
|
||||
|
||||
private slots:
|
||||
void showMe(bool);
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *e);
|
||||
virtual void hideEvent(QHideEvent *e);
|
||||
virtual void changeEvent(QEvent *e);
|
||||
|
||||
QRect availableToolWindowGeometry() const;
|
||||
|
||||
private:
|
||||
const Qt::DockWidgetArea m_dockAreaHint;
|
||||
QDesignerWorkbench *m_workbench;
|
||||
QAction *m_action;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QDESIGNER_TOOLWINDOW_H
|
||||
1098
third/designer/qdesigner/qdesigner_workbench.cpp
Normal file
1098
third/designer/qdesigner/qdesigner_workbench.cpp
Normal file
File diff suppressed because it is too large
Load Diff
215
third/designer/qdesigner/qdesigner_workbench.h
Normal file
215
third/designer/qdesigner/qdesigner_workbench.h
Normal file
@@ -0,0 +1,215 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Designer of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.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 the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDESIGNER_WORKBENCH_H
|
||||
#define QDESIGNER_WORKBENCH_H
|
||||
|
||||
#include "designer_enums.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QSet>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QRect>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerActions;
|
||||
class QDesignerToolWindow;
|
||||
class QDesignerFormWindow;
|
||||
class DockedMainWindow;
|
||||
class QDesignerSettings;
|
||||
|
||||
class QAction;
|
||||
class QActionGroup;
|
||||
class QDockWidget;
|
||||
class QMenu;
|
||||
class QMenuBar;
|
||||
class QMainWindow;
|
||||
class QToolBar;
|
||||
class QMdiArea;
|
||||
class QMdiSubWindow;
|
||||
class QCloseEvent;
|
||||
class QFont;
|
||||
class QtToolBarManager;
|
||||
class ToolBarManager;
|
||||
|
||||
class QDesignerFormEditorInterface;
|
||||
class QDesignerFormWindowInterface;
|
||||
class QDesignerFormWindowManagerInterface;
|
||||
|
||||
namespace qdesigner_internal {
|
||||
class QDesignerIntegration;
|
||||
}
|
||||
|
||||
class QDesignerWorkbench: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QDesignerWorkbench();
|
||||
virtual ~QDesignerWorkbench();
|
||||
|
||||
UIMode mode() const;
|
||||
|
||||
QDesignerFormEditorInterface *core() const;
|
||||
QDesignerFormWindow *findFormWindow(QWidget *widget) const;
|
||||
|
||||
QDesignerFormWindow *openForm(const QString &fileName, QString *errorMessage);
|
||||
QDesignerFormWindow *openTemplate(const QString &templateFileName,
|
||||
const QString &editorFileName,
|
||||
QString *errorMessage);
|
||||
|
||||
int toolWindowCount() const;
|
||||
QDesignerToolWindow *toolWindow(int index) const;
|
||||
|
||||
int formWindowCount() const;
|
||||
QDesignerFormWindow *formWindow(int index) const;
|
||||
|
||||
QDesignerActions *actionManager() const;
|
||||
|
||||
QActionGroup *modeActionGroup() const;
|
||||
|
||||
QRect availableGeometry() const;
|
||||
QRect desktopGeometry() const;
|
||||
|
||||
int marginHint() const;
|
||||
|
||||
bool readInForm(const QString &fileName) const;
|
||||
bool writeOutForm(QDesignerFormWindowInterface *formWindow, const QString &fileName) const;
|
||||
bool saveForm(QDesignerFormWindowInterface *fw);
|
||||
bool handleClose();
|
||||
bool readInBackup();
|
||||
void updateBackup(QDesignerFormWindowInterface* fwi);
|
||||
|
||||
signals:
|
||||
void modeChanged(UIMode mode);
|
||||
void initialized();
|
||||
|
||||
public slots:
|
||||
void addFormWindow(QDesignerFormWindow *formWindow);
|
||||
void removeFormWindow(QDesignerFormWindow *formWindow);
|
||||
void bringAllToFront();
|
||||
void toggleFormMinimizationState();
|
||||
|
||||
private slots:
|
||||
void switchToNeutralMode();
|
||||
void switchToDockedMode();
|
||||
void switchToTopLevelMode();
|
||||
void initializeCorePlugins();
|
||||
void handleCloseEvent(QCloseEvent *);
|
||||
void slotFormWindowActivated(QDesignerFormWindow* fw);
|
||||
void updateWindowMenu(QDesignerFormWindowInterface *fw);
|
||||
void formWindowActionTriggered(QAction *a);
|
||||
void adjustMDIFormPositions();
|
||||
void minimizationStateChanged(QDesignerFormWindowInterface *formWindow, bool minimized);
|
||||
|
||||
void restoreUISettings();
|
||||
void slotFileDropped(const QString &f);
|
||||
|
||||
private:
|
||||
QWidget *magicalParent(const QWidget *w) const;
|
||||
Qt::WindowFlags magicalWindowFlags(const QWidget *widgetForFlags) const;
|
||||
QDesignerFormWindowManagerInterface *formWindowManager() const;
|
||||
void closeAllToolWindows();
|
||||
QDesignerToolWindow *widgetBoxToolWindow() const;
|
||||
QDesignerFormWindow *loadForm(const QString &fileName, bool detectLineTermiantorMode, bool *uic3Converted, QString *errorMessage);
|
||||
void resizeForm(QDesignerFormWindow *fw, const QWidget *mainContainer) const;
|
||||
void saveGeometriesForModeChange();
|
||||
void saveGeometries(QDesignerSettings &settings) const;
|
||||
|
||||
bool isFormWindowMinimized(const QDesignerFormWindow *fw);
|
||||
void setFormWindowMinimized(QDesignerFormWindow *fw, bool minimized);
|
||||
void saveSettings() const;
|
||||
|
||||
QDesignerFormEditorInterface *m_core;
|
||||
qdesigner_internal::QDesignerIntegration *m_integration;
|
||||
|
||||
QDesignerActions *m_actionManager;
|
||||
QActionGroup *m_windowActions;
|
||||
|
||||
QMenu *m_windowMenu;
|
||||
|
||||
QMenuBar *m_globalMenuBar;
|
||||
|
||||
struct TopLevelData {
|
||||
ToolBarManager *toolbarManager;
|
||||
QList<QToolBar *> toolbars;
|
||||
};
|
||||
TopLevelData m_topLevelData;
|
||||
|
||||
UIMode m_mode;
|
||||
DockedMainWindow *m_dockedMainWindow;
|
||||
|
||||
QList<QDesignerToolWindow*> m_toolWindows;
|
||||
QList<QDesignerFormWindow*> m_formWindows;
|
||||
|
||||
QMenu *m_toolbarMenu;
|
||||
|
||||
// Helper class to remember the position of a window while switching user
|
||||
// interface modes.
|
||||
class Position {
|
||||
public:
|
||||
Position(const QDockWidget *dockWidget);
|
||||
Position(const QMdiSubWindow *mdiSubWindow, const QPoint &mdiAreaOffset);
|
||||
Position(const QWidget *topLevelWindow, const QPoint &desktopTopLeft);
|
||||
|
||||
void applyTo(QMdiSubWindow *mdiSubWindow, const QPoint &mdiAreaOffset) const;
|
||||
void applyTo(QWidget *topLevelWindow, const QPoint &desktopTopLeft) const;
|
||||
void applyTo(QDockWidget *dockWidget) const;
|
||||
|
||||
QPoint position() const { return m_position; }
|
||||
private:
|
||||
bool m_minimized;
|
||||
// Position referring to top-left corner (desktop in top-level mode or
|
||||
// main window in MDI mode)
|
||||
QPoint m_position;
|
||||
};
|
||||
typedef QHash<QWidget*, Position> PositionMap;
|
||||
PositionMap m_Positions;
|
||||
|
||||
enum State { StateInitializing, StateUp, StateClosing };
|
||||
State m_state;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QDESIGNER_WORKBENCH_H
|
||||
Reference in New Issue
Block a user